OXIESEC PANEL
- Current Dir:
/
/
var
/
www
/
reader
/
_backup
/
tinymce
/
tinymce
/
src
/
core
/
main
/
ts
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
02/20/2020 05:40:27 AM
rwxr-xr-x
📄
DragDropOverrides.ts
7.64 KB
02/20/2020 05:40:30 AM
rw-r--r--
📄
EditorRemove.ts
2.73 KB
02/20/2020 05:40:30 AM
rw-r--r--
📄
EditorSettings.ts
7.92 KB
02/20/2020 05:40:32 AM
rw-r--r--
📄
EditorView.ts
2.47 KB
02/20/2020 05:40:32 AM
rw-r--r--
📄
ErrorReporter.ts
2.43 KB
02/20/2020 05:40:33 AM
rw-r--r--
📄
ForceBlocks.ts
3.71 KB
02/20/2020 05:40:33 AM
rw-r--r--
📄
Mode.ts
4.53 KB
02/20/2020 05:40:34 AM
rw-r--r--
📄
NodeChange.ts
5.19 KB
02/20/2020 05:40:34 AM
rw-r--r--
📄
SelectionOverrides.ts
16.08 KB
02/20/2020 05:40:35 AM
rw-r--r--
📁
annotate
-
02/20/2020 05:41:49 AM
rwxr-xr-x
📁
api
-
02/20/2020 06:12:10 AM
rwxr-xr-x
📁
bookmark
-
02/20/2020 05:42:16 AM
rwxr-xr-x
📁
caret
-
02/20/2020 05:42:30 AM
rwxr-xr-x
📁
commands
-
02/20/2020 05:42:34 AM
rwxr-xr-x
📁
content
-
02/20/2020 05:42:42 AM
rwxr-xr-x
📁
delete
-
02/20/2020 05:42:54 AM
rwxr-xr-x
📁
dom
-
02/20/2020 05:43:08 AM
rwxr-xr-x
📁
file
-
02/20/2020 05:43:14 AM
rwxr-xr-x
📁
fmt
-
02/20/2020 05:43:26 AM
rwxr-xr-x
📁
focus
-
02/20/2020 05:43:32 AM
rwxr-xr-x
📁
geom
-
02/20/2020 05:43:36 AM
rwxr-xr-x
📁
html
-
02/20/2020 05:43:38 AM
rwxr-xr-x
📁
init
-
02/20/2020 05:43:46 AM
rwxr-xr-x
📁
keyboard
-
02/20/2020 05:44:00 AM
rwxr-xr-x
📁
newline
-
02/20/2020 05:44:07 AM
rwxr-xr-x
📁
selection
-
02/20/2020 05:44:24 AM
rwxr-xr-x
📁
text
-
02/20/2020 05:44:30 AM
rwxr-xr-x
📁
ui
-
02/20/2020 05:44:34 AM
rwxr-xr-x
📁
undo
-
02/20/2020 05:44:41 AM
rwxr-xr-x
📁
util
-
02/20/2020 05:44:48 AM
rwxr-xr-x
Editing: NodeChange.ts
Close
/** * Copyright (c) Tiny Technologies, Inc. All rights reserved. * Licensed under the LGPL or a commercial license. * For LGPL see License.txt in the project root for license information. * For commercial licenses see https://www.tiny.cloud/ */ import Env from './api/Env'; import RangeCompare from './selection/RangeCompare'; import Delay from './api/util/Delay'; import { hasAnyRanges } from './selection/SelectionUtils'; import Editor from './api/Editor'; /** * This class handles the nodechange event dispatching both manual and through selection change events. * * @class tinymce.NodeChange * @private */ class NodeChange { private readonly editor: Editor; private lastPath = []; constructor (editor: Editor) { this.editor = editor; let lastRng; const self = this; // Gecko doesn't support the "selectionchange" event if (!('onselectionchange' in editor.getDoc())) { editor.on('NodeChange click mouseup keyup focus', function (e) { let nativeRng, fakeRng; // Since DOM Ranges mutate on modification // of the DOM we need to clone it's contents nativeRng = editor.selection.getRng(); fakeRng = { startContainer: nativeRng.startContainer, startOffset: nativeRng.startOffset, endContainer: nativeRng.endContainer, endOffset: nativeRng.endOffset }; // Always treat nodechange as a selectionchange since applying // formatting to the current range wouldn't update the range but it's parent if (e.type === 'nodechange' || !RangeCompare.isEq(fakeRng, lastRng)) { editor.fire('SelectionChange'); } lastRng = fakeRng; }); } // IE has a bug where it fires a selectionchange on right click that has a range at the start of the body // When the contextmenu event fires the selection is located at the right location editor.on('contextmenu', function () { editor.fire('SelectionChange'); }); // Selection change is delayed ~200ms on IE when you click inside the current range editor.on('SelectionChange', function () { const startElm = editor.selection.getStart(true); // When focusout from after cef element to other input element the startelm can be undefined. // IE 8 will fire a selectionchange event with an incorrect selection // when focusing out of table cells. Click inside cell -> toolbar = Invalid SelectionChange event if (!startElm || (!Env.range && editor.selection.isCollapsed())) { return; } if (hasAnyRanges(editor) && !self.isSameElementPath(startElm) && editor.dom.isChildOf(startElm, editor.getBody())) { editor.nodeChanged({ selectionChange: true }); } }); // Fire an extra nodeChange on mouseup for compatibility reasons editor.on('mouseup', function (e) { if (!e.isDefaultPrevented() && hasAnyRanges(editor)) { // Delay nodeChanged call for WebKit edge case issue where the range // isn't updated until after you click outside a selected image if (editor.selection.getNode().nodeName === 'IMG') { Delay.setEditorTimeout(editor, function () { editor.nodeChanged(); }); } else { editor.nodeChanged(); } } }); } /** * Dispatches out a onNodeChange event to all observers. This method should be called when you * need to update the UI states or element path etc. * * @method nodeChanged * @param {Object} args Optional args to pass to NodeChange event handlers. */ public nodeChanged (args?) { const selection = this.editor.selection; let node, parents, root; // Fix for bug #1896577 it seems that this can not be fired while the editor is loading if (this.editor.initialized && selection && !this.editor.settings.disable_nodechange && !this.editor.readonly) { // Get start node root = this.editor.getBody(); node = selection.getStart(true) || root; // Make sure the node is within the editor root or is the editor root if (node.ownerDocument !== this.editor.getDoc() || !this.editor.dom.isChildOf(node, root)) { node = root; } // Get parents and add them to object parents = []; this.editor.dom.getParent(node, function (node) { if (node === root) { return true; } parents.push(node); }); args = args || {}; args.element = node; args.parents = parents; this.editor.fire('NodeChange', args); } } /** * Returns true/false if the current element path has been changed or not. * * @private * @return {Boolean} True if the element path is the same false if it's not. */ private isSameElementPath (startElm) { let i, currentPath; currentPath = this.editor.$(startElm).parentsUntil(this.editor.getBody()).add(startElm); if (currentPath.length === this.lastPath.length) { for (i = currentPath.length; i >= 0; i--) { if (currentPath[i] !== this.lastPath[i]) { break; } } if (i === -1) { this.lastPath = currentPath; return true; } } this.lastPath = currentPath; return false; } } export { NodeChange };