diff --git a/src/wp-includes/js/tinymce/plugins/lists/plugin.js b/src/wp-includes/js/tinymce/plugins/lists/plugin.js index 06e4f189e0..d1a1c1c3d0 100644 --- a/src/wp-includes/js/tinymce/plugins/lists/plugin.js +++ b/src/wp-includes/js/tinymce/plugins/lists/plugin.js @@ -433,9 +433,9 @@ tinymce.PluginManager.add('lists', function(editor) { return true; } - if (sibling && sibling.nodeName == 'LI' && isListNode(li.lastChild)) { + /*if (sibling && sibling.nodeName == 'LI' && isListNode(li.lastChild)) { return false; - } + }*/ sibling = li.previousSibling; if (sibling && sibling.nodeName == 'LI') { @@ -695,11 +695,15 @@ tinymce.PluginManager.add('lists', function(editor) { } nonEmptyBlocks = editor.schema.getNonEmptyElements(); - walker = new tinymce.dom.TreeWalker(rng.startContainer, editor.getBody()); + if (node.nodeType == 1) { + node = tinymce.dom.RangeUtils.getNode(node, offset); + } + + walker = new tinymce.dom.TreeWalker(node, editor.getBody()); // Delete at
[a
]b
->[a]
b
function adjustSelectionToVisibleSelection() { function findSelectionEnd(start, end) { var walker = new TreeWalker(end); - for (node = walker.current(); node; node = walker.prev()) { + for (node = walker.prev2(); node; node = walker.prev2()) { + if (node.nodeType == 3 && node.data.length > 0) { + return node; + } + if (node.childNodes.length > 1 || node == start || node.tagName == 'BR') { return node; } @@ -18999,7 +19047,7 @@ define("tinymce/Formatter", [ if (start != end && rng.endOffset === 0) { var newEnd = findSelectionEnd(start, end); - var endOffset = newEnd.nodeType == 3 ? newEnd.length : newEnd.childNodes.length; + var endOffset = newEnd.nodeType == 3 ? newEnd.data.length : newEnd.childNodes.length; rng.setEnd(newEnd, endOffset); } @@ -19669,6 +19717,10 @@ define("tinymce/Formatter", [ // Find first node with similar format settings node = dom.getParent(node, function(node) { + if (matchesUnInheritedFormatSelector(node, name)) { + return true; + } + return node.parentNode === root || !!matchNode(node, name, vars, true); }); @@ -19802,6 +19854,10 @@ define("tinymce/Formatter", [ matchedFormats[format] = callbacks; return false; } + + if (matchesUnInheritedFormatSelector(node, format)) { + return false; + } }); }); @@ -22172,6 +22228,529 @@ define("tinymce/ForceBlocks", [], function() { }; }); +// Included from: js/tinymce/classes/caret/CaretUtils.js + +/** + * CaretUtils.js + * + * Released under LGPL License. + * Copyright (c) 1999-2015 Ephox Corp. All rights reserved + * + * License: http://www.tinymce.com/license + * Contributing: http://www.tinymce.com/contributing + */ + +/** + * Utility functions shared by the caret logic. + * + * @private + * @class tinymce.caret.CaretUtils + */ +define("tinymce/caret/CaretUtils", [ + "tinymce/util/Fun", + "tinymce/dom/TreeWalker", + "tinymce/dom/NodeType", + "tinymce/caret/CaretPosition", + "tinymce/caret/CaretContainer", + "tinymce/caret/CaretCandidate" +], function(Fun, TreeWalker, NodeType, CaretPosition, CaretContainer, CaretCandidate) { + var isContentEditableTrue = NodeType.isContentEditableTrue, + isContentEditableFalse = NodeType.isContentEditableFalse, + isBlockLike = NodeType.matchStyleValues('display', 'block table table-cell table-caption'), + isCaretContainer = CaretContainer.isCaretContainer, + curry = Fun.curry, + isElement = NodeType.isElement, + isCaretCandidate = CaretCandidate.isCaretCandidate; + + function isForwards(direction) { + return direction > 0; + } + + function isBackwards(direction) { + return direction < 0; + } + + function findNode(node, direction, predicateFn, rootNode, shallow) { + var walker = new TreeWalker(node, rootNode); + + if (isBackwards(direction)) { + if (isContentEditableFalse(node)) { + node = walker.prev(true); + if (predicateFn(node)) { + return node; + } + } + + while ((node = walker.prev(shallow))) { + if (predicateFn(node)) { + return node; + } + } + } + + if (isForwards(direction)) { + if (isContentEditableFalse(node)) { + node = walker.next(true); + if (predicateFn(node)) { + return node; + } + } + + while ((node = walker.next(shallow))) { + if (predicateFn(node)) { + return node; + } + } + } + + return null; + } + + function getEditingHost(node, rootNode) { + for (node = node.parentNode; node && node != rootNode; node = node.parentNode) { + if (isContentEditableTrue(node)) { + return node; + } + } + + return rootNode; + } + + function getParentBlock(node, rootNode) { + while (node && node != rootNode) { + if (isBlockLike(node)) { + return node; + } + + node = node.parentNode; + } + + return null; + } + + function isInSameBlock(caretPosition1, caretPosition2, rootNode) { + return getParentBlock(caretPosition1.container(), rootNode) == getParentBlock(caretPosition2.container(), rootNode); + } + + function isInSameEditingHost(caretPosition1, caretPosition2, rootNode) { + return getEditingHost(caretPosition1.container(), rootNode) == getEditingHost(caretPosition2.container(), rootNode); + } + + function getChildNodeAtRelativeOffset(relativeOffset, caretPosition) { + var container, offset; + + if (!caretPosition) { + return null; + } + + container = caretPosition.container(); + offset = caretPosition.offset(); + + if (!isElement(container)) { + return null; + } + + return container.childNodes[offset + relativeOffset]; + } + + function beforeAfter(before, node) { + var range = node.ownerDocument.createRange(); + + if (before) { + range.setStartBefore(node); + range.setEndBefore(node); + } else { + range.setStartAfter(node); + range.setEndAfter(node); + } + + return range; + } + + function isNodesInSameBlock(rootNode, node1, node2) { + return getParentBlock(node1, rootNode) == getParentBlock(node2, rootNode); + } + + function lean(left, rootNode, node) { + var sibling, siblingName; + + if (left) { + siblingName = 'previousSibling'; + } else { + siblingName = 'nextSibling'; + } + + while (node && node != rootNode) { + sibling = node[siblingName]; + + if (isCaretContainer(sibling)) { + sibling = sibling[siblingName]; + } + + if (isContentEditableFalse(sibling)) { + if (isNodesInSameBlock(rootNode, sibling, node)) { + return sibling; + } + + break; + } + + if (isCaretCandidate(sibling)) { + break; + } + + node = node.parentNode; + } + + return null; + } + + var before = curry(beforeAfter, true); + var after = curry(beforeAfter, false); + + function normalizeRange(direction, rootNode, range) { + var node, container, offset, location; + var leanLeft = curry(lean, true, rootNode); + var leanRight = curry(lean, false, rootNode); + + container = range.startContainer; + offset = range.startOffset; + + if (CaretContainer.isCaretContainerBlock(container)) { + if (!isElement(container)) { + container = container.parentNode; + } + + location = container.getAttribute('data-mce-caret'); + + if (location == 'before') { + node = container.nextSibling; + if (isContentEditableFalse(node)) { + return before(node); + } + } + + if (location == 'after') { + node = container.previousSibling; + if (isContentEditableFalse(node)) { + return after(node); + } + } + } + + if (!range.collapsed) { + return range; + } + + if (NodeType.isText(container)) { + if (isCaretContainer(container)) { + if (direction === 1) { + node = leanRight(container); + if (node) { + return before(node); + } + + node = leanLeft(container); + if (node) { + return after(node); + } + } + + if (direction === -1) { + node = leanLeft(container); + if (node) { + return after(node); + } + + node = leanRight(container); + if (node) { + return before(node); + } + } + + return range; + } + + if (CaretContainer.endsWithCaretContainer(container) && offset >= container.data.length - 1) { + if (direction === 1) { + node = leanRight(container); + if (node) { + return before(node); + } + } + + return range; + } + + if (CaretContainer.startsWithCaretContainer(container) && offset <= 1) { + if (direction === -1) { + node = leanLeft(container); + if (node) { + return after(node); + } + } + + return range; + } + + if (offset === container.data.length) { + node = leanRight(container); + if (node) { + return before(node); + } + + return range; + } + + if (offset === 0) { + node = leanLeft(container); + if (node) { + return after(node); + } + + return range; + } + } + + return range; + } + + function isNextToContentEditableFalse(relativeOffset, caretPosition) { + return isContentEditableFalse(getChildNodeAtRelativeOffset(relativeOffset, caretPosition)); + } + + return { + isForwards: isForwards, + isBackwards: isBackwards, + findNode: findNode, + getEditingHost: getEditingHost, + getParentBlock: getParentBlock, + isInSameBlock: isInSameBlock, + isInSameEditingHost: isInSameEditingHost, + isBeforeContentEditableFalse: curry(isNextToContentEditableFalse, 0), + isAfterContentEditableFalse: curry(isNextToContentEditableFalse, -1), + normalizeRange: normalizeRange + }; +}); + +// Included from: js/tinymce/classes/caret/CaretWalker.js + +/** + * CaretWalker.js + * + * Released under LGPL License. + * Copyright (c) 1999-2015 Ephox Corp. All rights reserved + * + * License: http://www.tinymce.com/license + * Contributing: http://www.tinymce.com/contributing + */ + +/** + * This module contains logic for moving around a virtual caret in logical order within a DOM element. + * + * It ignores the most obvious invalid caret locations such as within a script element or within a + * contentEditable=false element but it will return locations that isn't possible to render visually. + * + * @private + * @class tinymce.caret.CaretWalker + * @example + * var caretWalker = new CaretWalker(rootElm); + * + * var prevLogicalCaretPosition = caretWalker.prev(CaretPosition.fromRangeStart(range)); + * var nextLogicalCaretPosition = caretWalker.next(CaretPosition.fromRangeEnd(range)); + */ +define("tinymce/caret/CaretWalker", [ + "tinymce/dom/NodeType", + "tinymce/caret/CaretCandidate", + "tinymce/caret/CaretPosition", + "tinymce/caret/CaretUtils", + "tinymce/util/Arr", + "tinymce/util/Fun" +], function(NodeType, CaretCandidate, CaretPosition, CaretUtils, Arr, Fun) { + var isContentEditableFalse = NodeType.isContentEditableFalse, + isText = NodeType.isText, + isElement = NodeType.isElement, + isForwards = CaretUtils.isForwards, + isBackwards = CaretUtils.isBackwards, + isCaretCandidate = CaretCandidate.isCaretCandidate, + isAtomic = CaretCandidate.isAtomic, + isEditableCaretCandidate = CaretCandidate.isEditableCaretCandidate; + + function getParents(node, rootNode) { + var parents = []; + + while (node && node != rootNode) { + parents.push(node); + node = node.parentNode; + } + + return parents; + } + + function nodeAtIndex(container, offset) { + if (container.hasChildNodes() && offset < container.childNodes.length) { + return container.childNodes[offset]; + } + + return null; + } + + function getCaretCandidatePosition(direction, node) { + if (isForwards(direction)) { + if (isCaretCandidate(node.previousSibling) && !isText(node.previousSibling)) { + return CaretPosition.before(node); + } + + if (isText(node)) { + return CaretPosition(node, 0); + } + } + + if (isBackwards(direction)) { + if (isCaretCandidate(node.nextSibling) && !isText(node.nextSibling)) { + return CaretPosition.after(node); + } + + if (isText(node)) { + return CaretPosition(node, node.data.length); + } + } + + if (isBackwards(direction)) { + return CaretPosition.after(node); + } + + return CaretPosition.before(node); + } + + function findCaretPosition(direction, startCaretPosition, rootNode) { + var container, offset, node, nextNode, innerNode, + rootContentEditableFalseElm, caretPosition; + + if (!isElement(rootNode) || !startCaretPosition) { + return null; + } + + caretPosition = startCaretPosition; + container = caretPosition.container(); + offset = caretPosition.offset(); + + if (isText(container)) { + if (isBackwards(direction) && offset > 0) { + return CaretPosition(container, --offset); + } + + if (isForwards(direction) && offset < container.length) { + return CaretPosition(container, ++offset); + } + + node = container; + } else { + if (isBackwards(direction) && offset > 0) { + nextNode = nodeAtIndex(container, offset - 1); + if (isCaretCandidate(nextNode)) { + if (!isAtomic(nextNode)) { + innerNode = CaretUtils.findNode(nextNode, direction, isEditableCaretCandidate, nextNode); + if (innerNode) { + if (isText(innerNode)) { + return CaretPosition(innerNode, innerNode.data.length); + } + + return CaretPosition.after(innerNode); + } + } + + if (isText(nextNode)) { + return CaretPosition(nextNode, nextNode.data.length); + } + + return CaretPosition.before(nextNode); + } + } + + if (isForwards(direction) && offset < container.childNodes.length) { + nextNode = nodeAtIndex(container, offset); + if (isCaretCandidate(nextNode)) { + if (!isAtomic(nextNode)) { + innerNode = CaretUtils.findNode(nextNode, direction, isEditableCaretCandidate, nextNode); + if (innerNode) { + if (isText(innerNode)) { + return CaretPosition(innerNode, 0); + } + + return CaretPosition.before(innerNode); + } + } + + if (isText(nextNode)) { + return CaretPosition(nextNode, 0); + } + + return CaretPosition.after(nextNode); + } + } + + node = caretPosition.getNode(); + } + + if ((isForwards(direction) && caretPosition.isAtEnd()) || (isBackwards(direction) && caretPosition.isAtStart())) { + node = CaretUtils.findNode(node, direction, Fun.constant(true), rootNode, true); + if (isEditableCaretCandidate(node)) { + return getCaretCandidatePosition(direction, node); + } + } + + nextNode = CaretUtils.findNode(node, direction, isEditableCaretCandidate, rootNode); + + rootContentEditableFalseElm = Arr.last(Arr.filter(getParents(container, rootNode), isContentEditableFalse)); + if (rootContentEditableFalseElm && (!nextNode || !rootContentEditableFalseElm.contains(nextNode))) { + if (isForwards(direction)) { + caretPosition = CaretPosition.after(rootContentEditableFalseElm); + } else { + caretPosition = CaretPosition.before(rootContentEditableFalseElm); + } + + return caretPosition; + } + + if (nextNode) { + return getCaretCandidatePosition(direction, nextNode); + } + + return null; + } + + return function(rootNode) { + return { + /** + * Returns the next logical caret position from the specificed input + * caretPoisiton or null if there isn't any more positions left for example + * at the end specified root element. + * + * @method next + * @param {tinymce.caret.CaretPosition} caretPosition Caret position to start from. + * @return {tinymce.caret.CaretPosition} CaretPosition or null if no position was found. + */ + next: function(caretPosition) { + return findCaretPosition(1, caretPosition, rootNode); + }, + + /** + * Returns the previous logical caret position from the specificed input + * caretPoisiton or null if there isn't any more positions left for example + * at the end specified root element. + * + * @method prev + * @param {tinymce.caret.CaretPosition} caretPosition Caret position to start from. + * @return {tinymce.caret.CaretPosition} CaretPosition or null if no position was found. + */ + prev: function(caretPosition) { + return findCaretPosition(-1, caretPosition, rootNode); + } + }; + }; +}); + // Included from: js/tinymce/classes/EditorCommands.js /** @@ -22196,13 +22775,16 @@ define("tinymce/EditorCommands", [ "tinymce/util/Tools", "tinymce/dom/ElementUtils", "tinymce/dom/RangeUtils", - "tinymce/dom/TreeWalker" -], function(Serializer, Env, Tools, ElementUtils, RangeUtils, TreeWalker) { + "tinymce/dom/TreeWalker", + "tinymce/caret/CaretWalker", + "tinymce/caret/CaretPosition", + "tinymce/dom/NodeType" +], function(Serializer, Env, Tools, ElementUtils, RangeUtils, TreeWalker, CaretWalker, CaretPosition, NodeType) { // Added for compression purposes var each = Tools.each, extend = Tools.extend; var map = Tools.map, inArray = Tools.inArray, explode = Tools.explode; var isIE = Env.ie, isOldIE = Env.ie && Env.ie < 11; - var TRUE = true, FALSE = false; + var TRUE = true, FALSE = false, isTableCell = NodeType.matchNodeNames('td th'); return function(editor) { var dom, selection, formatter, @@ -22704,7 +23286,7 @@ define("tinymce/EditorCommands", [ } function moveSelectionToMarker(marker) { - var parentEditableFalseElm; + var parentEditableFalseElm, parentNode, nextRng; function getContentEditableFalseParent(node) { var root = editor.getBody(); @@ -22754,8 +23336,34 @@ define("tinymce/EditorCommands", [ rng.setEndBefore(marker); } + function findNextCaretRng(rng) { + var caretPos = CaretPosition.fromRangeStart(rng); + var caretWalker = new CaretWalker(editor.getBody()); + + caretPos = caretWalker.next(caretPos); + if (caretPos) { + return caretPos.toRange(); + } + } + // Remove the marker node and set the new range + parentNode = marker.parentNode; dom.remove(marker); + + if (dom.isEmpty(parentNode) && dom.isBlock(parentNode)) { + editor.$(parentNode).empty(); + + rng.setStart(parentNode, 0); + rng.setEnd(parentNode, 0); + + if (!isTableCell(parentNode) && (nextRng = findNextCaretRng(rng))) { + rng = nextRng; + dom.remove(parentNode); + } else { + dom.add(parentNode, dom.create('br', {'data-mce-bogus': '1'})); + } + } + selection.setRng(rng); } @@ -29518,6 +30126,7 @@ define("tinymce/ui/Window", [ setTimeout(function() { self.classes.add('in'); + self.fire('open'); }, 0); self._super(); @@ -32714,14 +33323,34 @@ define("tinymce/Mode", [], function() { } } - function setMode(editor, mode) { - var currentMode = editor.readonly ? 'readonly' : 'design'; + function clickBlocker(editor) { + var target, handler; - if (mode == currentMode) { - return; + target = editor.getBody(); + + handler = function(e) { + if (editor.dom.getParents(e.target, 'a').length > 0) { + e.preventDefault(); + } + }; + + editor.dom.bind(target, 'click', handler); + + return { + unbind: function() { + editor.dom.unbind(target, 'click', handler); + } + }; + } + + function toggleReadOnly(editor, state) { + if (editor._clickBlocker) { + editor._clickBlocker.unbind(); + editor._clickBlocker = null; } - if (mode == 'readonly') { + if (state) { + editor._clickBlocker = clickBlocker(editor); editor.selection.controlSelection.hideResizeRect(); editor.readonly = true; editor.getBody().contentEditable = false; @@ -32734,6 +33363,22 @@ define("tinymce/Mode", [], function() { editor.focus(); editor.nodeChanged(); } + } + + function setMode(editor, mode) { + var currentMode = editor.readonly ? 'readonly' : 'design'; + + if (mode == currentMode) { + return; + } + + if (editor.initialized) { + toggleReadOnly(editor, mode == 'readonly'); + } else { + editor.on('init', function() { + toggleReadOnly(editor, mode == 'readonly'); + }); + } // Event is NOT preventable editor.fire('SwitchMode', {mode: mode}); @@ -33641,529 +34286,6 @@ define("tinymce/EditorUpload", [ }; }); -// Included from: js/tinymce/classes/caret/CaretUtils.js - -/** - * CaretUtils.js - * - * Released under LGPL License. - * Copyright (c) 1999-2015 Ephox Corp. All rights reserved - * - * License: http://www.tinymce.com/license - * Contributing: http://www.tinymce.com/contributing - */ - -/** - * Utility functions shared by the caret logic. - * - * @private - * @class tinymce.caret.CaretUtils - */ -define("tinymce/caret/CaretUtils", [ - "tinymce/util/Fun", - "tinymce/dom/TreeWalker", - "tinymce/dom/NodeType", - "tinymce/caret/CaretPosition", - "tinymce/caret/CaretContainer", - "tinymce/caret/CaretCandidate" -], function(Fun, TreeWalker, NodeType, CaretPosition, CaretContainer, CaretCandidate) { - var isContentEditableTrue = NodeType.isContentEditableTrue, - isContentEditableFalse = NodeType.isContentEditableFalse, - isBlockLike = NodeType.matchStyleValues('display', 'block table table-cell table-caption'), - isCaretContainer = CaretContainer.isCaretContainer, - curry = Fun.curry, - isElement = NodeType.isElement, - isCaretCandidate = CaretCandidate.isCaretCandidate; - - function isForwards(direction) { - return direction > 0; - } - - function isBackwards(direction) { - return direction < 0; - } - - function findNode(node, direction, predicateFn, rootNode, shallow) { - var walker = new TreeWalker(node, rootNode); - - if (isBackwards(direction)) { - if (isContentEditableFalse(node)) { - node = walker.prev(true); - if (predicateFn(node)) { - return node; - } - } - - while ((node = walker.prev(shallow))) { - if (predicateFn(node)) { - return node; - } - } - } - - if (isForwards(direction)) { - if (isContentEditableFalse(node)) { - node = walker.next(true); - if (predicateFn(node)) { - return node; - } - } - - while ((node = walker.next(shallow))) { - if (predicateFn(node)) { - return node; - } - } - } - - return null; - } - - function getEditingHost(node, rootNode) { - for (node = node.parentNode; node && node != rootNode; node = node.parentNode) { - if (isContentEditableTrue(node)) { - return node; - } - } - - return rootNode; - } - - function getParentBlock(node, rootNode) { - while (node && node != rootNode) { - if (isBlockLike(node)) { - return node; - } - - node = node.parentNode; - } - - return null; - } - - function isInSameBlock(caretPosition1, caretPosition2, rootNode) { - return getParentBlock(caretPosition1.container(), rootNode) == getParentBlock(caretPosition2.container(), rootNode); - } - - function isInSameEditingHost(caretPosition1, caretPosition2, rootNode) { - return getEditingHost(caretPosition1.container(), rootNode) == getEditingHost(caretPosition2.container(), rootNode); - } - - function getChildNodeAtRelativeOffset(relativeOffset, caretPosition) { - var container, offset; - - if (!caretPosition) { - return null; - } - - container = caretPosition.container(); - offset = caretPosition.offset(); - - if (!isElement(container)) { - return null; - } - - return container.childNodes[offset + relativeOffset]; - } - - function beforeAfter(before, node) { - var range = node.ownerDocument.createRange(); - - if (before) { - range.setStartBefore(node); - range.setEndBefore(node); - } else { - range.setStartAfter(node); - range.setEndAfter(node); - } - - return range; - } - - function isNodesInSameBlock(rootNode, node1, node2) { - return getParentBlock(node1, rootNode) == getParentBlock(node2, rootNode); - } - - function lean(left, rootNode, node) { - var sibling, siblingName; - - if (left) { - siblingName = 'previousSibling'; - } else { - siblingName = 'nextSibling'; - } - - while (node && node != rootNode) { - sibling = node[siblingName]; - - if (isCaretContainer(sibling)) { - sibling = sibling[siblingName]; - } - - if (isContentEditableFalse(sibling)) { - if (isNodesInSameBlock(rootNode, sibling, node)) { - return sibling; - } - - break; - } - - if (isCaretCandidate(sibling)) { - break; - } - - node = node.parentNode; - } - - return null; - } - - var before = curry(beforeAfter, true); - var after = curry(beforeAfter, false); - - function normalizeRange(direction, rootNode, range) { - var node, container, offset, location; - var leanLeft = curry(lean, true, rootNode); - var leanRight = curry(lean, false, rootNode); - - container = range.startContainer; - offset = range.startOffset; - - if (CaretContainer.isCaretContainerBlock(container)) { - if (!isElement(container)) { - container = container.parentNode; - } - - location = container.getAttribute('data-mce-caret'); - - if (location == 'before') { - node = container.nextSibling; - if (isContentEditableFalse(node)) { - return before(node); - } - } - - if (location == 'after') { - node = container.previousSibling; - if (isContentEditableFalse(node)) { - return after(node); - } - } - } - - if (!range.collapsed) { - return range; - } - - if (NodeType.isText(container)) { - if (isCaretContainer(container)) { - if (direction === 1) { - node = leanRight(container); - if (node) { - return before(node); - } - - node = leanLeft(container); - if (node) { - return after(node); - } - } - - if (direction === -1) { - node = leanLeft(container); - if (node) { - return after(node); - } - - node = leanRight(container); - if (node) { - return before(node); - } - } - - return range; - } - - if (CaretContainer.endsWithCaretContainer(container) && offset >= container.data.length - 1) { - if (direction === 1) { - node = leanRight(container); - if (node) { - return before(node); - } - } - - return range; - } - - if (CaretContainer.startsWithCaretContainer(container) && offset <= 1) { - if (direction === -1) { - node = leanLeft(container); - if (node) { - return after(node); - } - } - - return range; - } - - if (offset === container.data.length) { - node = leanRight(container); - if (node) { - return before(node); - } - - return range; - } - - if (offset === 0) { - node = leanLeft(container); - if (node) { - return after(node); - } - - return range; - } - } - - return range; - } - - function isNextToContentEditableFalse(relativeOffset, caretPosition) { - return isContentEditableFalse(getChildNodeAtRelativeOffset(relativeOffset, caretPosition)); - } - - return { - isForwards: isForwards, - isBackwards: isBackwards, - findNode: findNode, - getEditingHost: getEditingHost, - getParentBlock: getParentBlock, - isInSameBlock: isInSameBlock, - isInSameEditingHost: isInSameEditingHost, - isBeforeContentEditableFalse: curry(isNextToContentEditableFalse, 0), - isAfterContentEditableFalse: curry(isNextToContentEditableFalse, -1), - normalizeRange: normalizeRange - }; -}); - -// Included from: js/tinymce/classes/caret/CaretWalker.js - -/** - * CaretWalker.js - * - * Released under LGPL License. - * Copyright (c) 1999-2015 Ephox Corp. All rights reserved - * - * License: http://www.tinymce.com/license - * Contributing: http://www.tinymce.com/contributing - */ - -/** - * This module contains logic for moving around a virtual caret in logical order within a DOM element. - * - * It ignores the most obvious invalid caret locations such as within a script element or within a - * contentEditable=false element but it will return locations that isn't possible to render visually. - * - * @private - * @class tinymce.caret.CaretWalker - * @example - * var caretWalker = new CaretWalker(rootElm); - * - * var prevLogicalCaretPosition = caretWalker.prev(CaretPosition.fromRangeStart(range)); - * var nextLogicalCaretPosition = caretWalker.next(CaretPosition.fromRangeEnd(range)); - */ -define("tinymce/caret/CaretWalker", [ - "tinymce/dom/NodeType", - "tinymce/caret/CaretCandidate", - "tinymce/caret/CaretPosition", - "tinymce/caret/CaretUtils", - "tinymce/util/Arr", - "tinymce/util/Fun" -], function(NodeType, CaretCandidate, CaretPosition, CaretUtils, Arr, Fun) { - var isContentEditableFalse = NodeType.isContentEditableFalse, - isText = NodeType.isText, - isElement = NodeType.isElement, - isForwards = CaretUtils.isForwards, - isBackwards = CaretUtils.isBackwards, - isCaretCandidate = CaretCandidate.isCaretCandidate, - isAtomic = CaretCandidate.isAtomic, - isEditableCaretCandidate = CaretCandidate.isEditableCaretCandidate; - - function getParents(node, rootNode) { - var parents = []; - - while (node && node != rootNode) { - parents.push(node); - node = node.parentNode; - } - - return parents; - } - - function nodeAtIndex(container, offset) { - if (container.hasChildNodes() && offset < container.childNodes.length) { - return container.childNodes[offset]; - } - - return null; - } - - function getCaretCandidatePosition(direction, node) { - if (isForwards(direction)) { - if (isCaretCandidate(node.previousSibling) && !isText(node.previousSibling)) { - return CaretPosition.before(node); - } - - if (isText(node)) { - return CaretPosition(node, 0); - } - } - - if (isBackwards(direction)) { - if (isCaretCandidate(node.nextSibling) && !isText(node.nextSibling)) { - return CaretPosition.after(node); - } - - if (isText(node)) { - return CaretPosition(node, node.data.length); - } - } - - if (isBackwards(direction)) { - return CaretPosition.after(node); - } - - return CaretPosition.before(node); - } - - function findCaretPosition(direction, startCaretPosition, rootNode) { - var container, offset, node, nextNode, innerNode, - rootContentEditableFalseElm, caretPosition; - - if (!isElement(rootNode) || !startCaretPosition) { - return null; - } - - caretPosition = startCaretPosition; - container = caretPosition.container(); - offset = caretPosition.offset(); - - if (isText(container)) { - if (isBackwards(direction) && offset > 0) { - return CaretPosition(container, --offset); - } - - if (isForwards(direction) && offset < container.length) { - return CaretPosition(container, ++offset); - } - - node = container; - } else { - if (isBackwards(direction) && offset > 0) { - nextNode = nodeAtIndex(container, offset - 1); - if (isCaretCandidate(nextNode)) { - if (!isAtomic(nextNode)) { - innerNode = CaretUtils.findNode(nextNode, direction, isEditableCaretCandidate, nextNode); - if (innerNode) { - if (isText(innerNode)) { - return CaretPosition(innerNode, innerNode.data.length); - } - - return CaretPosition.after(innerNode); - } - } - - if (isText(nextNode)) { - return CaretPosition(nextNode, nextNode.data.length); - } - - return CaretPosition.before(nextNode); - } - } - - if (isForwards(direction) && offset < container.childNodes.length) { - nextNode = nodeAtIndex(container, offset); - if (isCaretCandidate(nextNode)) { - if (!isAtomic(nextNode)) { - innerNode = CaretUtils.findNode(nextNode, direction, isEditableCaretCandidate, nextNode); - if (innerNode) { - if (isText(innerNode)) { - return CaretPosition(innerNode, 0); - } - - return CaretPosition.before(innerNode); - } - } - - if (isText(nextNode)) { - return CaretPosition(nextNode, 0); - } - - return CaretPosition.after(nextNode); - } - } - - node = caretPosition.getNode(); - } - - if ((isForwards(direction) && caretPosition.isAtEnd()) || (isBackwards(direction) && caretPosition.isAtStart())) { - node = CaretUtils.findNode(node, direction, Fun.constant(true), rootNode, true); - if (isEditableCaretCandidate(node)) { - return getCaretCandidatePosition(direction, node); - } - } - - nextNode = CaretUtils.findNode(node, direction, isEditableCaretCandidate, rootNode); - - rootContentEditableFalseElm = Arr.last(Arr.filter(getParents(container, rootNode), isContentEditableFalse)); - if (rootContentEditableFalseElm && (!nextNode || !rootContentEditableFalseElm.contains(nextNode))) { - if (isForwards(direction)) { - caretPosition = CaretPosition.after(rootContentEditableFalseElm); - } else { - caretPosition = CaretPosition.before(rootContentEditableFalseElm); - } - - return caretPosition; - } - - if (nextNode) { - return getCaretCandidatePosition(direction, nextNode); - } - - return null; - } - - return function(rootNode) { - return { - /** - * Returns the next logical caret position from the specificed input - * caretPoisiton or null if there isn't any more positions left for example - * at the end specified root element. - * - * @method next - * @param {tinymce.caret.CaretPosition} caretPosition Caret position to start from. - * @return {tinymce.caret.CaretPosition} CaretPosition or null if no position was found. - */ - next: function(caretPosition) { - return findCaretPosition(1, caretPosition, rootNode); - }, - - /** - * Returns the previous logical caret position from the specificed input - * caretPoisiton or null if there isn't any more positions left for example - * at the end specified root element. - * - * @method prev - * @param {tinymce.caret.CaretPosition} caretPosition Caret position to start from. - * @return {tinymce.caret.CaretPosition} CaretPosition or null if no position was found. - */ - prev: function(caretPosition) { - return findCaretPosition(-1, caretPosition, rootNode); - } - }; - }; -}); - // Included from: js/tinymce/classes/caret/FakeCaret.js /** @@ -35877,10 +35999,11 @@ define("tinymce/Editor", [ * @param {tinymce.EditorManager} editorManager EditorManager instance. */ function Editor(id, settings, editorManager) { - var self = this, documentBaseUrl, baseUri; + var self = this, documentBaseUrl, baseUri, defaultSettings; documentBaseUrl = self.documentBaseUrl = editorManager.documentBaseURL; baseUri = editorManager.baseURI; + defaultSettings = editorManager.defaultSettings; /** * Name/value collection with editor settings. @@ -35891,7 +36014,7 @@ define("tinymce/Editor", [ * // Get the value of the theme setting * tinymce.activeEditor.windowManager.alert("You are using the " + tinymce.activeEditor.settings.theme + " theme"); */ - self.settings = settings = extend({ + settings = extend({ id: id, theme: 'modern', delta_width: 0, @@ -35929,11 +36052,16 @@ define("tinymce/Editor", [ url_converter: self.convertURL, url_converter_scope: self, ie7_compat: true - }, editorManager.defaultSettings, settings); + }, defaultSettings, settings); + // Merge external_plugins + if (defaultSettings && defaultSettings.external_plugins && settings.external_plugins) { + settings.external_plugins = extend({}, defaultSettings.external_plugins, settings.external_plugins); + } + + self.settings = settings; AddOnManager.language = settings.language || 'en'; AddOnManager.languageLoad = settings.language_load; - AddOnManager.baseURL = editorManager.baseURL; /** @@ -38425,16 +38553,20 @@ define("tinymce/EditorManager", [ function globalEventDelegate(e) { each(EditorManager.editors, function(editor) { - editor.fire('ResizeWindow', e); + if (e.type === 'scroll') { + editor.fire('ScrollWindow', e); + } else { + editor.fire('ResizeWindow', e); + } }); } function toggleGlobalEvents(editors, state) { if (state !== boundGlobalEvents) { if (state) { - $(window).on('resize', globalEventDelegate); + $(window).on('resize scroll', globalEventDelegate); } else { - $(window).off('resize', globalEventDelegate); + $(window).off('resize scroll', globalEventDelegate); } boundGlobalEvents = state; @@ -38502,7 +38634,7 @@ define("tinymce/EditorManager", [ * @property minorVersion * @type String */ - minorVersion: '3.7', + minorVersion: '3.8', /** * Release date of TinyMCE build. @@ -38510,7 +38642,7 @@ define("tinymce/EditorManager", [ * @property releaseDate * @type String */ - releaseDate: '2016-03-02', + releaseDate: '2016-03-15', /** * Collection of editor instances. diff --git a/src/wp-includes/js/tinymce/tinymce.min.js b/src/wp-includes/js/tinymce/tinymce.min.js index 62cafffcaf..0702c15eea 100644 --- a/src/wp-includes/js/tinymce/tinymce.min.js +++ b/src/wp-includes/js/tinymce/tinymce.min.js @@ -1,13 +1,13 @@ -// 4.3.7 (2016-03-02) -!function(e,t){"use strict";function n(e,t){for(var n,r=[],i=0;i]*>( | |\s|\u00a0|)<\/p>[\r\n]*|
[\r\n]*)$/,"")}),n.load({initial:!0,format:"html"}),n.startContent=n.getContent({format:"raw"}),n.initialized=!0,n.bindPendingEventDelegates(),n.fire("init"),n.focus(!0),n.nodeChanged({initial:!0}),n.execCallback("init_instance_callback",n),n.on("compositionstart compositionend",function(e){n.composing="compositionstart"===e.type}),n.contentStyles.length>0&&(m="",P(n.contentStyles,function(e){m+=e+"\r\n"}),n.dom.addStyle(m)),P(n.contentCSS,function(e){n.loadedCSS[e]||(n.dom.loadCSS(e),n.loadedCSS[e]=!0)}),r.auto_focus&&N.setEditorTimeout(n,function(){var e;e=r.auto_focus===!0?n:n.editorManager.get(r.auto_focus),e.destroyed||e.focus()},100),s=h=p=null},focus:function(e){function t(e){return n.dom.getParent(e,function(e){return"true"===n.dom.getContentEditable(e)})}var n=this,r=n.selection,i=n.settings.content_editable,o,a,s=n.getDoc(),l=n.getBody(),c;if(!e){if(o=r.getRng(),o.item&&(a=o.item(0)),n._refreshContentEditable(),c=t(r.getNode()),n.$.contains(l,c))return c.focus(),r.normalize(),void n.editorManager.setActive(n);if(i||(w.opera||n.getBody().focus(),n.getWin().focus()),W||i){if(l.setActive)try{l.setActive()}catch(u){l.focus()}else l.focus();i&&r.normalize()}a&&a.ownerDocument==s&&(o=s.body.createControlRange(),o.addElement(a),o.select())}n.editorManager.setActive(n)},execCallback:function(e){var t=this,n=t.settings[e],r;if(n)return t.callbackLookup&&(r=t.callbackLookup[e])&&(n=r.func,r=r.scope),"string"==typeof n&&(r=n.replace(/\.\w+$/,""),r=r?F(r):0,n=F(n),t.callbackLookup=t.callbackLookup||{},t.callbackLookup[e]={func:n,scope:r}),n.apply(r||t,Array.prototype.slice.call(arguments,1))},translate:function(e){var t=this.settings.language||"en",n=this.editorManager.i18n;return e?n.data[t+"."+e]||e.replace(/\{\#([^\}]+)\}/g,function(e,r){return n.data[t+"."+r]||"{#"+r+"}"}):""},getLang:function(e,n){return this.editorManager.i18n.data[(this.settings.language||"en")+"."+e]||(n!==t?n:"{#"+e+"}")},getParam:function(e,t,n){var r=e in this.settings?this.settings[e]:t,i;return"hash"===n?(i={},"string"==typeof r?P(r.indexOf("=")>0?r.split(/[;,](?![^=;,]*(?:[;,]|$))/):r.split(","),function(e){e=e.split("="),e.length>1?i[I(e[0])]=I(e[1]):i[I(e[0])]=I(e)}):i=r,i):r},nodeChanged:function(e){this._nodeChangeDispatcher.nodeChanged(e)},addButton:function(e,t){var n=this;t.cmd&&(t.onclick=function(){n.execCommand(t.cmd)}),t.text||t.icon||(t.icon=e),n.buttons=n.buttons||{},t.tooltip=t.tooltip||t.title,n.buttons[e]=t},addMenuItem:function(e,t){var n=this;t.cmd&&(t.onclick=function(){n.execCommand(t.cmd)}),n.menuItems=n.menuItems||{},n.menuItems[e]=t},addContextToolbar:function(e,t){var n=this,r;n.contextToolbars=n.contextToolbars||[],"string"==typeof e&&(r=e,e=function(e){return n.dom.is(e,r)}),n.contextToolbars.push({predicate:e,items:t})},addCommand:function(e,t,n){this.editorCommands.addCommand(e,t,n)},addQueryStateHandler:function(e,t,n){this.editorCommands.addQueryStateHandler(e,t,n)},addQueryValueHandler:function(e,t,n){this.editorCommands.addQueryValueHandler(e,t,n)},addShortcut:function(e,t,n,r){this.shortcuts.add(e,t,n,r)},execCommand:function(e,t,n,r){return this.editorCommands.execCommand(e,t,n,r)},queryCommandState:function(e){return this.editorCommands.queryCommandState(e)},queryCommandValue:function(e){return this.editorCommands.queryCommandValue(e)},queryCommandSupported:function(e){return this.editorCommands.queryCommandSupported(e)},show:function(){var e=this;e.hidden&&(e.hidden=!1,e.inline?e.getBody().contentEditable=!0:(B.show(e.getContainer()),B.hide(e.id)),e.load(),e.fire("show"))},hide:function(){var e=this,t=e.getDoc();e.hidden||(V&&t&&!e.inline&&t.execCommand("SelectAll"),e.save(),e.inline?(e.getBody().contentEditable=!1,e==e.editorManager.focusedEditor&&(e.editorManager.focusedEditor=null)):(B.hide(e.getContainer()),B.setStyle(e.id,"display",e.orgDisplay)),e.hidden=!0,e.fire("hide"))},isHidden:function(){return!!this.hidden},setProgressState:function(e,t){this.fire("ProgressState",{state:e,time:t})},load:function(e){var n=this,r=n.getElement(),i;return r?(e=e||{},e.load=!0,i=n.setContent(r.value!==t?r.value:r.innerHTML,e),e.element=r,e.no_events||n.fire("LoadContent",e),e.element=r=null,i):void 0},save:function(e){var t=this,n=t.getElement(),r,i;if(n&&t.initialized)return e=e||{},e.save=!0,e.element=n,r=e.content=t.getContent(e),e.no_events||t.fire("SaveContent",e),"raw"==e.format&&t.fire("RawSaveContent",e),r=e.content,/TEXTAREA|INPUT/i.test(n.nodeName)?n.value=r:(t.inline||(n.innerHTML=r),(i=B.getParent(t.id,"form"))&&P(i.elements,function(e){return e.name==t.id?(e.value=r,!1):void 0})),e.element=n=null,e.set_dirty!==!1&&t.setDirty(!1),r},setContent:function(e,t){var n=this,r=n.getBody(),i,o;return t=t||{},t.format=t.format||"html",t.set=!0,t.content=e,t.no_events||n.fire("BeforeSetContent",t),e=t.content,0===e.length||/^\s+$/.test(e)?(o=V&&11>V?"":'
',"TABLE"==r.nodeName?e="
]*>( | |\s|\u00a0|)<\/p>[\r\n]*|
[\r\n]*)$/,"")}),n.load({initial:!0,format:"html"}),n.startContent=n.getContent({format:"raw"}),n.initialized=!0,n.bindPendingEventDelegates(),n.fire("init"),n.focus(!0),n.nodeChanged({initial:!0}),n.execCallback("init_instance_callback",n),n.on("compositionstart compositionend",function(e){n.composing="compositionstart"===e.type}),n.contentStyles.length>0&&(m="",P(n.contentStyles,function(e){m+=e+"\r\n"}),n.dom.addStyle(m)),P(n.contentCSS,function(e){n.loadedCSS[e]||(n.dom.loadCSS(e),n.loadedCSS[e]=!0)}),r.auto_focus&&N.setEditorTimeout(n,function(){var e;e=r.auto_focus===!0?n:n.editorManager.get(r.auto_focus),e.destroyed||e.focus()},100),s=h=p=null},focus:function(e){function t(e){return n.dom.getParent(e,function(e){return"true"===n.dom.getContentEditable(e)})}var n=this,r=n.selection,i=n.settings.content_editable,o,a,s=n.getDoc(),l=n.getBody(),c;if(!e){if(o=r.getRng(),o.item&&(a=o.item(0)),n._refreshContentEditable(),c=t(r.getNode()),n.$.contains(l,c))return c.focus(),r.normalize(),void n.editorManager.setActive(n);if(i||(w.opera||n.getBody().focus(),n.getWin().focus()),W||i){if(l.setActive)try{l.setActive()}catch(u){l.focus()}else l.focus();i&&r.normalize()}a&&a.ownerDocument==s&&(o=s.body.createControlRange(),o.addElement(a),o.select())}n.editorManager.setActive(n)},execCallback:function(e){var t=this,n=t.settings[e],r;if(n)return t.callbackLookup&&(r=t.callbackLookup[e])&&(n=r.func,r=r.scope),"string"==typeof n&&(r=n.replace(/\.\w+$/,""),r=r?F(r):0,n=F(n),t.callbackLookup=t.callbackLookup||{},t.callbackLookup[e]={func:n,scope:r}),n.apply(r||t,Array.prototype.slice.call(arguments,1))},translate:function(e){var t=this.settings.language||"en",n=this.editorManager.i18n;return e?n.data[t+"."+e]||e.replace(/\{\#([^\}]+)\}/g,function(e,r){return n.data[t+"."+r]||"{#"+r+"}"}):""},getLang:function(e,n){return this.editorManager.i18n.data[(this.settings.language||"en")+"."+e]||(n!==t?n:"{#"+e+"}")},getParam:function(e,t,n){var r=e in this.settings?this.settings[e]:t,i;return"hash"===n?(i={},"string"==typeof r?P(r.indexOf("=")>0?r.split(/[;,](?![^=;,]*(?:[;,]|$))/):r.split(","),function(e){e=e.split("="),e.length>1?i[I(e[0])]=I(e[1]):i[I(e[0])]=I(e)}):i=r,i):r},nodeChanged:function(e){this._nodeChangeDispatcher.nodeChanged(e)},addButton:function(e,t){var n=this;t.cmd&&(t.onclick=function(){n.execCommand(t.cmd)}),t.text||t.icon||(t.icon=e),n.buttons=n.buttons||{},t.tooltip=t.tooltip||t.title,n.buttons[e]=t},addMenuItem:function(e,t){var n=this;t.cmd&&(t.onclick=function(){n.execCommand(t.cmd)}),n.menuItems=n.menuItems||{},n.menuItems[e]=t},addContextToolbar:function(e,t){var n=this,r;n.contextToolbars=n.contextToolbars||[],"string"==typeof e&&(r=e,e=function(e){return n.dom.is(e,r)}),n.contextToolbars.push({predicate:e,items:t})},addCommand:function(e,t,n){this.editorCommands.addCommand(e,t,n)},addQueryStateHandler:function(e,t,n){this.editorCommands.addQueryStateHandler(e,t,n)},addQueryValueHandler:function(e,t,n){this.editorCommands.addQueryValueHandler(e,t,n)},addShortcut:function(e,t,n,r){this.shortcuts.add(e,t,n,r)},execCommand:function(e,t,n,r){return this.editorCommands.execCommand(e,t,n,r)},queryCommandState:function(e){return this.editorCommands.queryCommandState(e)},queryCommandValue:function(e){return this.editorCommands.queryCommandValue(e)},queryCommandSupported:function(e){return this.editorCommands.queryCommandSupported(e)},show:function(){var e=this;e.hidden&&(e.hidden=!1,e.inline?e.getBody().contentEditable=!0:(B.show(e.getContainer()),B.hide(e.id)),e.load(),e.fire("show"))},hide:function(){var e=this,t=e.getDoc();e.hidden||(V&&t&&!e.inline&&t.execCommand("SelectAll"),e.save(),e.inline?(e.getBody().contentEditable=!1,e==e.editorManager.focusedEditor&&(e.editorManager.focusedEditor=null)):(B.hide(e.getContainer()),B.setStyle(e.id,"display",e.orgDisplay)),e.hidden=!0,e.fire("hide"))},isHidden:function(){return!!this.hidden},setProgressState:function(e,t){this.fire("ProgressState",{state:e,time:t})},load:function(e){var n=this,r=n.getElement(),i;return r?(e=e||{},e.load=!0,i=n.setContent(r.value!==t?r.value:r.innerHTML,e),e.element=r,e.no_events||n.fire("LoadContent",e),e.element=r=null,i):void 0},save:function(e){var t=this,n=t.getElement(),r,i;if(n&&t.initialized)return e=e||{},e.save=!0,e.element=n,r=e.content=t.getContent(e),e.no_events||t.fire("SaveContent",e),"raw"==e.format&&t.fire("RawSaveContent",e),r=e.content,/TEXTAREA|INPUT/i.test(n.nodeName)?n.value=r:(t.inline||(n.innerHTML=r),(i=B.getParent(t.id,"form"))&&P(i.elements,function(e){return e.name==t.id?(e.value=r,!1):void 0})),e.element=n=null,e.set_dirty!==!1&&t.setDirty(!1),r},setContent:function(e,t){var n=this,r=n.getBody(),i,o;return t=t||{},t.format=t.format||"html",t.set=!0,t.content=e,t.no_events||n.fire("BeforeSetContent",t),e=t.content,0===e.length||/^\s+$/.test(e)?(o=V&&11>V?"":'
',"TABLE"==r.nodeName?e="
x
def
'); + Utils.setSelection('h1', 3); + editor.execCommand('mceInsertContent', false, 'def
'); +}); + +test('mceInsertContent HR at end of H1 with P sibling', function() { + editor.setContent('def
'); + Utils.setSelection('h1', 3); + editor.execCommand('mceInsertContent', false, '| \u00a0 |
def
'); +}); + test('mceInsertContent - p inside whole p', function() { var rng; @@ -211,7 +237,7 @@ test('mceInsertContent - image inside p', function() { rng.setEnd(editor.dom.select('p')[0].firstChild, 1); editor.selection.setRng(rng); editor.execCommand('mceInsertContent', false, 'test 123
'); editor.setContent('test 123'); editor.execCommand('SelectAll'); - editor.execCommand('FontSize',false,'7'); + editor.execCommand('FontSize', false, '7'); equal(editor.getContent(), 'test 123
'); editor.setContent('test 123'); @@ -493,17 +519,17 @@ test('Formatting commands (alignInline)', function() { editor.setContent('
');
editor.selection.select(editor.dom.select('img')[0]);
editor.execCommand('JustifyLeft');
- equal(editor.getContent(), '

');
editor.selection.select(editor.dom.select('img')[0]);
editor.execCommand('JustifyCenter');
- equal(editor.getContent(), '

');
editor.selection.select(editor.dom.select('img')[0]);
editor.execCommand('JustifyRight');
- equal(editor.getContent(), '

123
'); Utils.setSelection('p', 3); editor.execCommand('InsertLineBreak'); - equal(Utils.cleanHtml(editor.getBody().innerHTML), (tinymce.isIE && tinymce.Env.ie < 11) ? '123
123
123
123
\u00a0
\u00a0
\u00a0
\u00a0
abc
abc
abc
abc
abc
abc
abc
\u00a0
'); + equal(editor.getContent(), 'abc
\u00a0
'); }); test('Enter before last INPUT in P with text', function() { diff --git a/tests/qunit/editor/tinymce/Formatter_apply.js b/tests/qunit/editor/tinymce/Formatter_apply.js index af80669a96..d11f616d51 100644 --- a/tests/qunit/editor/tinymce/Formatter_apply.js +++ b/tests/qunit/editor/tinymce/Formatter_apply.js @@ -15,7 +15,7 @@ module("tinymce.Formatter - Apply", { disable_nodechange: true, entities: 'raw', valid_styles: { - '*': 'color,font-size,font-family,background-color,font-weight,font-style,text-decoration,float,margin,margin-top,margin-right,margin-bottom,margin-left,display' + '*': 'color,font-size,font-family,background-color,font-weight,font-style,text-decoration,float,margin,margin-top,margin-right,margin-bottom,margin-left,display,text-align' }, init_instance_callback: function(ed) { window.editor = ed; @@ -36,7 +36,7 @@ module("tinymce.Formatter - Apply", { disable_nodechange: true, entities: 'raw', valid_styles: { - '*': 'color,font-size,font-family,background-color,font-weight,font-style,text-decoration,float,margin,margin-top,margin-right,margin-bottom,margin-left,display' + '*': 'color,font-size,font-family,background-color,font-weight,font-style,text-decoration,float,margin,margin-top,margin-right,margin-bottom,margin-left,display,text-align' }, init_instance_callback: function(ed) { window.inlineEditor = ed; @@ -1535,6 +1535,56 @@ test('Align specified table element with collapsed: false and selection collapse equal(getContent(), '| a |
a' +
+ '
| ' +
+ '
a' +
+ '
| ' +
+ '
ab
'; @@ -1640,4 +1690,19 @@ asyncTest('Bug #7412 - valid_styles affects the Bold and Italic buttons, althoug equal(getContent(), '1 1234 1
'); } }); -}); \ No newline at end of file +}); + +test('Format selection from with end at beginning of block', function(){ + editor.setContent("abcd
'); +}); diff --git a/tests/qunit/editor/tinymce/dom/Serializer.js b/tests/qunit/editor/tinymce/dom/Serializer.js index 44e5392ff1..cfb368270c 100644 --- a/tests/qunit/editor/tinymce/dom/Serializer.js +++ b/tests/qunit/editor/tinymce/dom/Serializer.js @@ -44,7 +44,7 @@ test('Schema rules', function() { ser = new tinymce.dom.Serializer({invalid_elements : 'hr,br'}); DOM.setHTML('test', '


\n

')), 'text
');
+ equal(serializer.serialize(new tinymce.html.DomParser().parse('text
')), 'text
');
equal(serializer.serialize(new tinymce.html.DomParser().parse('')), '');
equal(serializer.serialize(new tinymce.html.DomParser().parse('')), '');
equal(serializer.serialize(new tinymce.html.DomParser().parse('')), '');