[TASK] RTE: Move JS method getNodeByPosition 34/33934/3
authorStanislas Rolland <typo3@sjbr.ca>
Sun, 9 Nov 2014 23:10:44 +0000 (18:10 -0500)
committerStanislas Rolland <typo3@sjbr.ca>
Sun, 9 Nov 2014 23:25:54 +0000 (00:25 +0100)
Move JavaScript method getNodeByPosition from HTMLArea.Editor to
HTMLArea.DOM.Node where it belongs.

Releases: master
Resolves: #62804
Change-Id: I3709678e8ed639eeb49daabd2cbfc46b58912554
Reviewed-on: http://review.typo3.org/33934
Reviewed-by: Stanislas Rolland <typo3@sjbr.ca>
Tested-by: Stanislas Rolland <typo3@sjbr.ca>
typo3/sysext/core/Documentation/Changelog/master/Breaking-62804-RTEJavaScriptMethodMoved.rst [new file with mode: 0644]
typo3/sysext/rtehtmlarea/Resources/Public/JavaScript/HTMLArea/DOM/HTMLArea.DOM.BookMark.js
typo3/sysext/rtehtmlarea/Resources/Public/JavaScript/HTMLArea/DOM/HTMLArea.DOM.Node.js
typo3/sysext/rtehtmlarea/Resources/Public/JavaScript/HTMLArea/Editor/HTMLArea.Editor.js

diff --git a/typo3/sysext/core/Documentation/Changelog/master/Breaking-62804-RTEJavaScriptMethodMoved.rst b/typo3/sysext/core/Documentation/Changelog/master/Breaking-62804-RTEJavaScriptMethodMoved.rst
new file mode 100644 (file)
index 0000000..c562aa9
--- /dev/null
@@ -0,0 +1,27 @@
+=====================================================================================
+Breaking: #62804 - RTE JavaScript method HTMLArea.Editor::getNodeByPosition was moved
+=====================================================================================
+
+Description
+===========
+
+RTE JavaScript method getNodeByPosition was moved from HTMLArea.Editor to HTMLArea.DOM.Node where it belongs.
+
+
+Impact
+======
+
+3rd party extensions referring to HTMLArea.Editor::getNodeByPosition will fail.
+
+
+Affected installations
+======================
+
+A TYPO3 instance is affected if a 3rd party extension refers to the method HTMLArea.Editor::getNodeByPosition.
+
+
+Migration
+=========
+
+The affected 3rd party extensions must be modified to use method HTMLArea.DOM.Node::getNodeByPosition
+instead of HTMLArea.Editor::getNodeByPosition.
\ No newline at end of file
index 78ae093..2db3fb2 100644 (file)
@@ -188,8 +188,8 @@ HTMLArea.DOM.BookMark = Ext.extend(HTMLArea.DOM.BookMark, {
                                }
                        }
                        bookMark = {
                                }
                        }
                        bookMark = {
-                               start: this.editor.domNode.getPositionWithinTree(startContainer, normalized),
-                               end: collapsed ? null : getPositionWithinTree(endContainer, normalized),
+                               start: this.editor.getDomNode().getPositionWithinTree(startContainer, normalized),
+                               end: collapsed ? null : this.editor.getDomNode().getPositionWithinTree(endContainer, normalized),
                                startOffset: startOffset,
                                endOffset: endOffset,
                                normalized: normalized,
                                startOffset: startOffset,
                                endOffset: endOffset,
                                normalized: normalized,
@@ -288,12 +288,12 @@ HTMLArea.DOM.BookMark = Ext.extend(HTMLArea.DOM.BookMark, {
        moveToNonIntrusiveBookMark: function (range, bookMark) {
                if (bookMark.start) {
                        // Get the start information
        moveToNonIntrusiveBookMark: function (range, bookMark) {
                if (bookMark.start) {
                        // Get the start information
-                       var startContainer = this.editor.getNodeByPosition(bookMark.start, bookMark.normalized),
+                       var startContainer = this.editor.getDomNode().getNodeByPosition(bookMark.start, bookMark.normalized),
                                startOffset = bookMark.startOffset;
                        // Set the start boundary
                        range.setStart(startContainer, startOffset);
                        // Get the end information
                                startOffset = bookMark.startOffset;
                        // Set the start boundary
                        range.setStart(startContainer, startOffset);
                        // Get the end information
-                       var endContainer = bookMark.end && this.editor.getNodeByPosition(bookMark.end, bookMark.normalized),
+                       var endContainer = bookMark.end && this.editor.getDomNode().getNodeByPosition(bookMark.end, bookMark.normalized),
                                endOffset = bookMark.endOffset;
                        // Set the end boundary. If not available, collapse the range
                        if (endContainer) {
                                endOffset = bookMark.endOffset;
                        // Set the end boundary. If not available, collapse the range
                        if (endContainer) {
index 44fdf66..3c0e474 100644 (file)
@@ -135,7 +135,7 @@ HTMLArea.DOM.Node = Ext.extend(HTMLArea.DOM.Node, {
                        this.selection.selectNodeContents(element, false);
                }
        },
                        this.selection.selectNodeContents(element, false);
                }
        },
-       /*
+       /**
         * Get the position of the node within the document tree.
         * The tree address returned is an array of integers, with each integer
         * indicating a child index of a DOM node, starting from
         * Get the position of the node within the document tree.
         * The tree address returned is an array of integers, with each integer
         * indicating a child index of a DOM node, starting from
@@ -163,6 +163,46 @@ HTMLArea.DOM.Node = Ext.extend(HTMLArea.DOM.Node, {
                }
                return position;
        },
                }
                return position;
        },
+
+       /**
+        * Get the node given its position in the document tree.
+        * Adapted from FCKeditor
+        * See HTMLArea.DOM.Node::getPositionWithinTree
+        *
+        * @param       array           position: the position of the node in the document tree
+        * @param       boolean         normalized: if true, a normalized position is given
+        *
+        * @return      objet           the node
+        */
+       getNodeByPosition: function (position, normalized) {
+               var current = this.document.documentElement;
+               var i, j, n, m;
+               for (i = 0, n = position.length; current && i < n; i++) {
+                       var target = position[i];
+                       if (normalized) {
+                               var currentIndex = -1;
+                               for (j = 0, m = current.childNodes.length; j < m; j++) {
+                                       var candidate = current.childNodes[j];
+                                       if (
+                                               candidate.nodeType == HTMLArea.DOM.TEXT_NODE
+                                               && candidate.previousSibling
+                                               && candidate.previousSibling.nodeType == HTMLArea.DOM.TEXT_NODE
+                                       ) {
+                                               continue;
+                                       }
+                                       currentIndex++;
+                                       if (currentIndex == target) {
+                                               current = candidate;
+                                               break;
+                                       }
+                               }
+                       } else {
+                               current = current.childNodes[target];
+                       }
+               }
+               return current ? current : null;
+       },
+
        /**
         * Clean Apple wrapping span and font elements under the specified node
         *
        /**
         * Clean Apple wrapping span and font elements under the specified node
         *
index 1820c0f..504533f 100644 (file)
@@ -376,45 +376,8 @@ HTMLArea.Editor = Ext.extend(Ext.util.Observable, {
                                break;
                }
        },
                                break;
                }
        },
-       /*
-        * Get the node given its position in the document tree.
-        * Adapted from FCKeditor
-        * See HTMLArea.DOM.Node::getPositionWithinTree
-        *
-        * @param       array           position: the position of the node in the document tree
-        * @param       boolean         normalized: if true, a normalized position is given
-        *
-        * @return      objet           the node
-        */
-       getNodeByPosition: function (position, normalized) {
-               var current = this.document.documentElement;
-               var i, j, n, m;
-               for (i = 0, n = position.length; current && i < n; i++) {
-                       var target = position[i];
-                       if (normalized) {
-                               var currentIndex = -1;
-                               for (j = 0, m = current.childNodes.length; j < m; j++) {
-                                       var candidate = current.childNodes[j];
-                                       if (
-                                               candidate.nodeType == HTMLArea.DOM.TEXT_NODE
-                                               && candidate.previousSibling
-                                               && candidate.previousSibling.nodeType == HTMLArea.DOM.TEXT_NODE
-                                       ) {
-                                               continue;
-                                       }
-                                       currentIndex++;
-                                       if (currentIndex == target) {
-                                               current = candidate;
-                                               break;
-                                       }
-                               }
-                       } else {
-                               current = current.childNodes[target];
-                       }
-               }
-               return current ? current : null;
-       },
-       /*
+
+       /**
         * Instantiate the specified plugin and register it with the editor
         *
         * @param       string          plugin: the name of the plugin
         * Instantiate the specified plugin and register it with the editor
         *
         * @param       string          plugin: the name of the plugin