Rev 637 | Rev 759 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 637 | Rev 679 | ||
---|---|---|---|
Line 2... | Line 2... | ||
2 | * Copyright (c) Tiny Technologies, Inc. All rights reserved. |
2 | * Copyright (c) Tiny Technologies, Inc. All rights reserved. |
3 | * Licensed under the LGPL or a commercial license. |
3 | * Licensed under the LGPL or a commercial license. |
4 | * For LGPL see License.txt in the project root for license information. |
4 | * For LGPL see License.txt in the project root for license information. |
5 | * For commercial licenses see https://www.tiny.cloud/ |
5 | * For commercial licenses see https://www.tiny.cloud/ |
6 | * |
6 | * |
7 | * Version: 5.9.2 (2021-09-08) |
7 | * Version: 5.10.2 (2021-11-17) |
8 | */ |
8 | */ |
9 | (function () { |
9 | (function () { |
10 | 'use strict'; |
10 | 'use strict'; |
11 | 11 | ||
12 | var Cell = function (initial) { |
12 | var Cell = function (initial) { |
Line 171... | Line 171... | ||
171 | from: from |
171 | from: from |
172 | }; |
172 | }; |
173 | 173 | ||
174 | var punctuation = punctuation$1; |
174 | var punctuation = punctuation$1; |
175 | 175 | ||
- | 176 | var global$2 = tinymce.util.Tools.resolve('tinymce.Env'); |
|
- | 177 | ||
176 | var global$2 = tinymce.util.Tools.resolve('tinymce.util.Tools'); |
178 | var global$1 = tinymce.util.Tools.resolve('tinymce.util.Tools'); |
177 | 179 | ||
178 | var nativeSlice = Array.prototype.slice; |
180 | var nativeSlice = Array.prototype.slice; |
179 | var nativePush = Array.prototype.push; |
181 | var nativePush = Array.prototype.push; |
180 | var map = function (xs, f) { |
182 | var map = function (xs, f) { |
181 | var len = xs.length; |
183 | var len = xs.length; |
Line 393... | Line 395... | ||
393 | 395 | ||
394 | var descendants = function (scope, selector) { |
396 | var descendants = function (scope, selector) { |
395 | return all(selector, scope); |
397 | return all(selector, scope); |
396 | }; |
398 | }; |
397 | 399 | ||
398 | var global$1 = tinymce.util.Tools.resolve('tinymce.dom.TreeWalker'); |
400 | var global = tinymce.util.Tools.resolve('tinymce.dom.TreeWalker'); |
399 | 401 | ||
400 | var isSimpleBoundary = function (dom, node) { |
402 | var isSimpleBoundary = function (dom, node) { |
401 | return dom.isBlock(node) || has(dom.schema.getShortEndedElements(), node.nodeName); |
403 | return dom.isBlock(node) || has(dom.schema.getShortEndedElements(), node.nodeName); |
402 | }; |
404 | }; |
403 | var isContentEditableFalse = function (dom, node) { |
405 | var isContentEditableFalse = function (dom, node) { |
Line 457... | Line 459... | ||
457 | var collectTextToBoundary = function (dom, section, node, rootNode, forwards) { |
459 | var collectTextToBoundary = function (dom, section, node, rootNode, forwards) { |
458 | if (isBoundary(dom, node)) { |
460 | if (isBoundary(dom, node)) { |
459 | return; |
461 | return; |
460 | } |
462 | } |
461 | var rootBlock = dom.getParent(rootNode, dom.isBlock); |
463 | var rootBlock = dom.getParent(rootNode, dom.isBlock); |
462 | var walker = new global$1(node, rootBlock); |
464 | var walker = new global(node, rootBlock); |
463 | var walkerFn = forwards ? walker.next.bind(walker) : walker.prev.bind(walker); |
465 | var walkerFn = forwards ? walker.next.bind(walker) : walker.prev.bind(walker); |
464 | walk(dom, walkerFn, node, { |
466 | walk(dom, walkerFn, node, { |
465 | boundary: always, |
467 | boundary: always, |
466 | cef: always, |
468 | cef: always, |
467 | text: function (next) { |
469 | text: function (next) { |
Line 476... | Line 478... | ||
476 | }; |
478 | }; |
477 | var collect = function (dom, rootNode, startNode, endNode, callbacks, skipStart) { |
479 | var collect = function (dom, rootNode, startNode, endNode, callbacks, skipStart) { |
478 | if (skipStart === void 0) { |
480 | if (skipStart === void 0) { |
479 | skipStart = true; |
481 | skipStart = true; |
480 | } |
482 | } |
481 | var walker = new global$1(startNode, rootNode); |
483 | var walker = new global(startNode, rootNode); |
482 | var sections = []; |
484 | var sections = []; |
483 | var current = nuSection(); |
485 | var current = nuSection(); |
484 | collectTextToBoundary(dom, current, startNode, rootNode, false); |
486 | collectTextToBoundary(dom, current, startNode, rootNode, false); |
485 | var finishSection = function () { |
487 | var finishSection = function () { |
486 | if (current.elements.length > 0) { |
488 | if (current.elements.length > 0) { |
Line 672... | Line 674... | ||
672 | } |
674 | } |
673 | node.parentNode.removeChild(node); |
675 | node.parentNode.removeChild(node); |
674 | }; |
676 | }; |
675 | var findSpansByIndex = function (editor, index) { |
677 | var findSpansByIndex = function (editor, index) { |
676 | var spans = []; |
678 | var spans = []; |
677 | var nodes = global$2.toArray(editor.getBody().getElementsByTagName('span')); |
679 | var nodes = global$1.toArray(editor.getBody().getElementsByTagName('span')); |
678 | if (nodes.length) { |
680 | if (nodes.length) { |
679 | for (var i = 0; i < nodes.length; i++) { |
681 | for (var i = 0; i < nodes.length; i++) { |
680 | var nodeIndex = getElmIndex(nodes[i]); |
682 | var nodeIndex = getElmIndex(nodes[i]); |
681 | if (nodeIndex === null || !nodeIndex.length) { |
683 | if (nodeIndex === null || !nodeIndex.length) { |
682 | continue; |
684 | continue; |
Line 726... | Line 728... | ||
726 | var escapedText = text.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&').replace(/\s/g, '[^\\S\\r\\n\\uFEFF]'); |
728 | var escapedText = text.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&').replace(/\s/g, '[^\\S\\r\\n\\uFEFF]'); |
727 | var wordRegex = '(' + escapedText + ')'; |
729 | var wordRegex = '(' + escapedText + ')'; |
728 | return wholeWord ? '(?:^|\\s|' + punctuation() + ')' + wordRegex + ('(?=$|\\s|' + punctuation() + ')') : wordRegex; |
730 | return wholeWord ? '(?:^|\\s|' + punctuation() + ')' + wordRegex + ('(?=$|\\s|' + punctuation() + ')') : wordRegex; |
729 | }; |
731 | }; |
730 | var find = function (editor, currentSearchState, text, matchCase, wholeWord, inSelection) { |
732 | var find = function (editor, currentSearchState, text, matchCase, wholeWord, inSelection) { |
- | 733 | var selection = editor.selection; |
|
731 | var escapedText = escapeSearchText(text, wholeWord); |
734 | var escapedText = escapeSearchText(text, wholeWord); |
- | 735 | var isForwardSelection = selection.isForward(); |
|
732 | var pattern = { |
736 | var pattern = { |
733 | regex: new RegExp(escapedText, matchCase ? 'g' : 'gi'), |
737 | regex: new RegExp(escapedText, matchCase ? 'g' : 'gi'), |
734 | matchIndex: 1 |
738 | matchIndex: 1 |
735 | }; |
739 | }; |
736 | var count = markAllMatches(editor, currentSearchState, pattern, inSelection); |
740 | var count = markAllMatches(editor, currentSearchState, pattern, inSelection); |
- | 741 | if (global$2.browser.isSafari()) { |
|
- | 742 | selection.setRng(selection.getRng(), isForwardSelection); |
|
- | 743 | } |
|
737 | if (count) { |
744 | if (count) { |
738 | var newIndex = moveSelection(editor, currentSearchState, true); |
745 | var newIndex = moveSelection(editor, currentSearchState, true); |
739 | currentSearchState.set({ |
746 | currentSearchState.set({ |
740 | index: newIndex, |
747 | index: newIndex, |
741 | count: count, |
748 | count: count, |
Line 763... | Line 770... | ||
763 | var searchState = currentSearchState.get(); |
770 | var searchState = currentSearchState.get(); |
764 | var currentIndex = searchState.index; |
771 | var currentIndex = searchState.index; |
765 | var currentMatchIndex, nextIndex = currentIndex; |
772 | var currentMatchIndex, nextIndex = currentIndex; |
766 | forward = forward !== false; |
773 | forward = forward !== false; |
767 | var node = editor.getBody(); |
774 | var node = editor.getBody(); |
768 | var nodes = global$2.grep(global$2.toArray(node.getElementsByTagName('span')), isMatchSpan); |
775 | var nodes = global$1.grep(global$1.toArray(node.getElementsByTagName('span')), isMatchSpan); |
769 | for (var i = 0; i < nodes.length; i++) { |
776 | for (var i = 0; i < nodes.length; i++) { |
770 | var nodeIndex = getElmIndex(nodes[i]); |
777 | var nodeIndex = getElmIndex(nodes[i]); |
771 | var matchIndex = currentMatchIndex = parseInt(nodeIndex, 10); |
778 | var matchIndex = currentMatchIndex = parseInt(nodeIndex, 10); |
772 | if (all || matchIndex === searchState.index) { |
779 | if (all || matchIndex === searchState.index) { |
773 | if (text.length) { |
780 | if (text.length) { |
Line 804... | Line 811... | ||
804 | return !all && currentSearchState.get().count > 0; |
811 | return !all && currentSearchState.get().count > 0; |
805 | }; |
812 | }; |
806 | var done = function (editor, currentSearchState, keepEditorSelection) { |
813 | var done = function (editor, currentSearchState, keepEditorSelection) { |
807 | var startContainer, endContainer; |
814 | var startContainer, endContainer; |
808 | var searchState = currentSearchState.get(); |
815 | var searchState = currentSearchState.get(); |
809 | var nodes = global$2.toArray(editor.getBody().getElementsByTagName('span')); |
816 | var nodes = global$1.toArray(editor.getBody().getElementsByTagName('span')); |
810 | for (var i = 0; i < nodes.length; i++) { |
817 | for (var i = 0; i < nodes.length; i++) { |
811 | var nodeIndex = getElmIndex(nodes[i]); |
818 | var nodeIndex = getElmIndex(nodes[i]); |
812 | if (nodeIndex !== null && nodeIndex.length) { |
819 | if (nodeIndex !== null && nodeIndex.length) { |
813 | if (nodeIndex === searchState.index.toString()) { |
820 | if (nodeIndex === searchState.index.toString()) { |
814 | if (!startContainer) { |
821 | if (!startContainer) { |
Line 901... | Line 908... | ||
901 | return subject.get().each(f); |
908 | return subject.get().each(f); |
902 | }; |
909 | }; |
903 | return __assign(__assign({}, subject), { on: on }); |
910 | return __assign(__assign({}, subject), { on: on }); |
904 | }; |
911 | }; |
905 | 912 | ||
906 | var global = tinymce.util.Tools.resolve('tinymce.Env'); |
- | |
907 | - | ||
908 | var open = function (editor, currentSearchState) { |
913 | var open = function (editor, currentSearchState) { |
909 | var dialogApi = value(); |
914 | var dialogApi = value(); |
910 | editor.undoManager.add(); |
915 | editor.undoManager.add(); |
911 | var selectedText = global$2.trim(editor.selection.getContent({ format: 'text' })); |
916 | var selectedText = global$1.trim(editor.selection.getContent({ format: 'text' })); |
912 | var updateButtonStates = function (api) { |
917 | var updateButtonStates = function (api) { |
913 | var updateNext = hasNext(editor, currentSearchState) ? api.enable : api.disable; |
918 | var updateNext = hasNext(editor, currentSearchState) ? api.enable : api.disable; |
914 | updateNext('next'); |
919 | updateNext('next'); |
915 | var updatePrev = hasPrev(editor, currentSearchState) ? api.enable : api.disable; |
920 | var updatePrev = hasPrev(editor, currentSearchState) ? api.enable : api.disable; |
916 | updatePrev('prev'); |
921 | updatePrev('prev'); |
Line 938... | Line 943... | ||
938 | editor.windowManager.alert('Could not find the specified string.', function () { |
943 | editor.windowManager.alert('Could not find the specified string.', function () { |
939 | api.focus('findtext'); |
944 | api.focus('findtext'); |
940 | }); |
945 | }); |
941 | }; |
946 | }; |
942 | var focusButtonIfRequired = function (api, name) { |
947 | var focusButtonIfRequired = function (api, name) { |
943 | if (global.browser.isSafari() && global.deviceType.isTouch() && (name === 'find' || name === 'replace' || name === 'replaceall')) { |
948 | if (global$2.browser.isSafari() && global$2.deviceType.isTouch() && (name === 'find' || name === 'replace' || name === 'replaceall')) { |
944 | api.focus(name); |
949 | api.focus(name); |
945 | } |
950 | } |
946 | }; |
951 | }; |
947 | var reset = function (api) { |
952 | var reset = function (api) { |
948 | done(editor, currentSearchState, false); |
953 | done(editor, currentSearchState, false); |