diff --git a/Build/types/TYPO3/index.d.ts b/Build/types/TYPO3/index.d.ts index ad983114dbaccd9380cf5dffb1357b2475b9561d..87d5e16fb1e4a13f11f97ebb1e9afeae5db348f7 100644 --- a/Build/types/TYPO3/index.d.ts +++ b/Build/types/TYPO3/index.d.ts @@ -31,12 +31,6 @@ declare namespace TYPO3 { public readonly: number; } } - - export namespace RecordList { - export class LinkBrowser { - public getLinkAttributeValues(): {[key: string]: string}; - } - } } } @@ -60,10 +54,6 @@ declare module 'TYPO3/CMS/Backend/Severity' { export = new TYPO3.CMS.Backend.Severity(); } -declare module 'TYPO3/CMS/Recordlist/LinkBrowser' { - export = new TYPO3.CMS.RecordList.LinkBrowser(); -} - // Type definition for global namespace object interface Window { TYPO3: any; diff --git a/typo3/sysext/rte_ckeditor/Resources/Private/TypeScript/RteLinkBrowser.ts b/typo3/sysext/rte_ckeditor/Resources/Private/TypeScript/RteLinkBrowser.ts deleted file mode 100644 index 4ff8fd8d1d07473fde8cedc294b9cc2681c33a5b..0000000000000000000000000000000000000000 --- a/typo3/sysext/rte_ckeditor/Resources/Private/TypeScript/RteLinkBrowser.ts +++ /dev/null @@ -1,102 +0,0 @@ -/* - * This file is part of the TYPO3 CMS project. - * - * It is free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License, either version 2 - * of the License, or any later version. - * - * For the full copyright and license information, please read the - * LICENSE.txt file that was distributed with this source code. - * - * The TYPO3 project - inspiring people to share! - */ - -/** - * Module: TYPO3/CMS/RteCkeditor/RteLinkBrowser - * LinkBrowser communication with parent window - */ -import $ = require('jquery'); -import LinkBrowser = require('TYPO3/CMS/Recordlist/LinkBrowser'); -import Modal = require('TYPO3/CMS/Backend/Modal'); - -class RteLinkBrowser { - private plugin: any = null; - - private CKEditor: CKEDITOR.editor = null; - - private siteUrl = ''; - - /** - * @param {string} editorId Id of CKEditor - */ - public initialize(editorId: string): void { - let callerWindow: Window; - if (typeof top.TYPO3.Backend !== 'undefined' && typeof top.TYPO3.Backend.ContentContainer.get() !== 'undefined') { - callerWindow = top.TYPO3.Backend.ContentContainer.get(); - } else { - callerWindow = window.parent; - } - - $.each((callerWindow as any).CKEDITOR.instances, (name: string, editor: CKEDITOR.editor) => { - if (editor.id === editorId) { - this.CKEditor = editor; - } - }); - - // siteUrl etc are added as data attributes to the body tag - $.extend(RteLinkBrowser, $('body').data()); - - $('.t3js-removeCurrentLink').on('click', (event: Event) => { - event.preventDefault(); - this.CKEditor.execCommand('unlink'); - Modal.dismiss(); - }); - } - - /** - * Store the final link - * - * @param {stringify} link The select element or anything else which identifies - * the link (e.g. "page:<pageUid>" or "file:<uid>") - */ - public finalizeFunction(link: string): void { - const linkElement: CKEDITOR.dom.element = this.CKEditor.document.createElement('a'); - const attributes = LinkBrowser.getLinkAttributeValues(); - const params: string = attributes.params ? attributes.params : ''; - - if (attributes.target) { - linkElement.setAttribute('target', attributes.target); - } - if (attributes.class) { - linkElement.setAttribute('class', attributes.class); - } - if (attributes.title) { - linkElement.setAttribute('title', attributes.title); - } - delete attributes.title; - delete attributes.class; - delete attributes.target; - delete attributes.params; - - $.each(attributes, (attrName: string, attrValue: string) => { - linkElement.setAttribute(attrName, attrValue); - }); - - linkElement.setAttribute('href', link + params); - - const selection: CKEDITOR.dom.selection = this.CKEditor.getSelection(); - if (selection && selection.getSelectedText() === '') { - selection.selectElement(selection.getStartElement()); - } - if (selection && selection.getSelectedText()) { - linkElement.setText(selection.getSelectedText()); - } else { - linkElement.setText(linkElement.getAttribute('href')); - } - this.CKEditor.insertElement(linkElement); - - Modal.dismiss(); - } -} - -export = new RteLinkBrowser(); diff --git a/typo3/sysext/rte_ckeditor/Resources/Public/JavaScript/RteLinkBrowser.js b/typo3/sysext/rte_ckeditor/Resources/Public/JavaScript/RteLinkBrowser.js index a0a42005c095d2f010c2b42df6b82a46e2e27811..e59c571b2a2b2b304912291159d7f43ed7cc913f 100644 --- a/typo3/sysext/rte_ckeditor/Resources/Public/JavaScript/RteLinkBrowser.js +++ b/typo3/sysext/rte_ckeditor/Resources/Public/JavaScript/RteLinkBrowser.js @@ -10,80 +10,96 @@ * * The TYPO3 project - inspiring people to share! */ -define(["require", "exports", "jquery", "TYPO3/CMS/Recordlist/LinkBrowser", "TYPO3/CMS/Backend/Modal"], function (require, exports, $, LinkBrowser, Modal) { - "use strict"; - var RteLinkBrowser = (function () { - function RteLinkBrowser() { - this.plugin = null; - this.CKEditor = null; - this.siteUrl = ''; - } - /** - * @param {string} editorId Id of CKEditor - */ - RteLinkBrowser.prototype.initialize = function (editorId) { - var _this = this; - var callerWindow; - if (typeof top.TYPO3.Backend !== 'undefined' && typeof top.TYPO3.Backend.ContentContainer.get() !== 'undefined') { - callerWindow = top.TYPO3.Backend.ContentContainer.get(); - } - else { - callerWindow = window.parent; - } - $.each(callerWindow.CKEDITOR.instances, function (name, editor) { - if (editor.id === editorId) { - _this.CKEditor = editor; - } - }); - // siteUrl etc are added as data attributes to the body tag - $.extend(RteLinkBrowser, $('body').data()); - $('.t3js-removeCurrentLink').on('click', function (event) { - event.preventDefault(); - _this.CKEditor.execCommand('unlink'); - Modal.dismiss(); - }); - }; - /** - * Store the final link - * - * @param {stringify} link The select element or anything else which identifies - * the link (e.g. "page:<pageUid>" or "file:<uid>") - */ - RteLinkBrowser.prototype.finalizeFunction = function (link) { - var linkElement = this.CKEditor.document.createElement('a'); - var attributes = LinkBrowser.getLinkAttributeValues(); - var params = attributes.params ? attributes.params : ''; - if (attributes.target) { - linkElement.setAttribute('target', attributes.target); - } - if (attributes.class) { - linkElement.setAttribute('class', attributes.class); - } - if (attributes.title) { - linkElement.setAttribute('title', attributes.title); - } - delete attributes.title; - delete attributes.class; - delete attributes.target; - delete attributes.params; - $.each(attributes, function (attrName, attrValue) { - linkElement.setAttribute(attrName, attrValue); - }); - linkElement.setAttribute('href', link + params); - var selection = this.CKEditor.getSelection(); - if (selection && selection.getSelectedText() === '') { - selection.selectElement(selection.getStartElement()); - } - if (selection && selection.getSelectedText()) { - linkElement.setText(selection.getSelectedText()); - } - else { - linkElement.setText(linkElement.getAttribute('href')); - } - this.CKEditor.insertElement(linkElement); - Modal.dismiss(); - }; - return RteLinkBrowser; - }()); - return new RteLinkBrowser(); + +/** + * Module: TYPO3/CMS/RteCkeditor/RteLinkBrowser + * LinkBrowser communication with parent window + */ +define(['jquery', 'TYPO3/CMS/Recordlist/LinkBrowser', 'TYPO3/CMS/Backend/Modal'], function ($, LinkBrowser, Modal) { + 'use strict'; + + /** + * + * @type {{plugin: null, CKEditor: null, siteUrl: string}} + * @exports TYPO3/CMS/RteCkeditor/RteLinkBrowser + */ + var RteLinkBrowser = { + plugin: null, + CKEditor: null, + siteUrl: '' + }; + + /** + * @param {String} editorId Id of CKEditor + */ + RteLinkBrowser.initialize = function (editorId) { + var callerWindow; + if (typeof top.TYPO3.Backend !== 'undefined' && typeof top.TYPO3.Backend.ContentContainer.get() !== 'undefined') { + callerWindow = top.TYPO3.Backend.ContentContainer.get(); + } else { + callerWindow = window.parent; + } + + $.each(callerWindow.CKEDITOR.instances, function (name, editor) { + if (editor.id === editorId) { + RteLinkBrowser.CKEditor = editor; + } + }); + + // siteUrl etc are added as data attributes to the body tag + $.extend(RteLinkBrowser, $('body').data()); + + $('.t3js-removeCurrentLink').on('click', function (event) { + event.preventDefault(); + RteLinkBrowser.CKEditor.execCommand('unlink'); + Modal.dismiss(); + }); + }; + + /** + * Store the final link + * + * @param {String} link The select element or anything else which identifies the link (e.g. "page:<pageUid>" or "file:<uid>") + */ + LinkBrowser.finalizeFunction = function (link) { + + var linkElement = RteLinkBrowser.CKEditor.document.createElement('a'); + var attributes = LinkBrowser.getLinkAttributeValues(); + var params = attributes.params ? attributes.params : ''; + + if (attributes.target) { + linkElement.setAttribute('target', attributes.target); + } + if (attributes.class) { + linkElement.setAttribute('class', attributes.class); + } + if (attributes.title) { + linkElement.setAttribute('title', attributes.title); + } + delete attributes.title; + delete attributes.class; + delete attributes.target; + delete attributes.params; + + $.each(attributes, function (attrName, attrValue) { + linkElement.setAttribute(attrName, attrValue); + }); + + linkElement.setAttribute('href', link + params); + + var selection = RteLinkBrowser.CKEditor.getSelection(); + if (selection && selection.getSelectedText() === '') { + selection.selectElement(selection.getStartElement()); + } + if (selection && selection.getSelectedText()) { + linkElement.setText(selection.getSelectedText()); + } else { + linkElement.setText(linkElement.getAttribute('href')); + } + RteLinkBrowser.CKEditor.insertElement(linkElement); + + Modal.dismiss(); + }; + + return RteLinkBrowser; });