[TASK] Revert "Port RteLinkBrowser to TypeScript" 74/53274/3
authorBenni Mack <benni@typo3.org>
Tue, 20 Jun 2017 09:48:11 +0000 (11:48 +0200)
committerBenni Mack <benni@typo3.org>
Tue, 20 Jun 2017 10:28:37 +0000 (12:28 +0200)
This change introduced a flaw in the RteLinkBrowser JS file
which needs to override LinkBrowser class instead of just
writing RteLinkBrowser.

See https://review.typo3.org/#/c/53062/
This reverts commit c5d75c151cdd23ed24ea0acd9e01767054ac7353.

Resolves: #81630
Reverts: #81444
Releases: master
Change-Id: I4a3a9dc52bd6b9cee183ba6411389e8da2eebd21
Reviewed-on: https://review.typo3.org/53274
Reviewed-by: Susanne Moog <susanne.moog@typo3.org>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
Build/types/TYPO3/index.d.ts
typo3/sysext/rte_ckeditor/Resources/Private/TypeScript/RteLinkBrowser.ts [deleted file]
typo3/sysext/rte_ckeditor/Resources/Public/JavaScript/RteLinkBrowser.js

index ad98311..87d5e16 100644 (file)
@@ -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 (file)
index 4ff8fd8..0000000
+++ /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();
index a0a4200..e59c571 100644 (file)
  *
  * 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;
 });