OXIESEC PANEL
- Current Dir:
/
/
var
/
www
/
reader
/
_backup
/
tinymce
/
tinymce
/
src
/
core
/
main
/
ts
/
keyboard
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
02/20/2020 05:44:43 AM
rwxr-xr-x
📄
ArrowKeys.ts
2.28 KB
02/20/2020 05:43:50 AM
rw-r--r--
📄
BoundaryCaret.ts
2.59 KB
02/20/2020 05:43:50 AM
rw-r--r--
📄
BoundaryLocation.ts
6.56 KB
02/20/2020 05:43:51 AM
rw-r--r--
📄
BoundarySelection.ts
4.54 KB
02/20/2020 05:43:52 AM
rw-r--r--
📄
CefNavigation.ts
9.07 KB
02/20/2020 05:43:52 AM
rw-r--r--
📄
CefUtils.ts
2.54 KB
02/20/2020 05:43:53 AM
rw-r--r--
📄
ContentEndpointNavigation.ts
2.99 KB
02/20/2020 05:43:54 AM
rw-r--r--
📄
DeleteBackspaceKeys.ts
3.49 KB
02/20/2020 05:43:54 AM
rw-r--r--
📄
EnterKey.ts
1.29 KB
02/20/2020 05:43:55 AM
rw-r--r--
📄
FormatShortcuts.ts
886 bytes
02/20/2020 05:43:55 AM
rw-r--r--
📄
HomeEndKeys.ts
980 bytes
02/20/2020 05:43:56 AM
rw-r--r--
📄
InlineUtils.ts
3.26 KB
02/20/2020 05:43:56 AM
rw-r--r--
📄
InputKeys.ts
1.55 KB
02/20/2020 05:43:57 AM
rw-r--r--
📄
InsertSpace.ts
2.3 KB
02/20/2020 05:43:57 AM
rw-r--r--
📄
KeyboardOverrides.ts
1011 bytes
02/20/2020 05:43:58 AM
rw-r--r--
📄
MatchKeys.ts
1.64 KB
02/20/2020 05:43:58 AM
rw-r--r--
📄
Nbsps.ts
5.95 KB
02/20/2020 05:43:59 AM
rw-r--r--
📄
SpaceKey.ts
1 KB
02/20/2020 05:43:59 AM
rw-r--r--
📄
TableNavigation.ts
6.86 KB
02/20/2020 05:44:00 AM
rw-r--r--
Editing: BoundarySelection.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 { Node, HTMLElement, Text } from '@ephox/dom-globals'; import { Arr, Cell, Fun } from '@ephox/katamari'; import CaretContainerRemove from '../caret/CaretContainerRemove'; import CaretPosition from '../caret/CaretPosition'; import BoundaryCaret from './BoundaryCaret'; import BoundaryLocation from './BoundaryLocation'; import InlineUtils from './InlineUtils'; import WordSelection from '../selection/WordSelection'; import Editor from '../api/Editor'; import DOMUtils from '../api/dom/DOMUtils'; const setCaretPosition = function (editor: Editor, pos: CaretPosition) { const rng = editor.dom.createRng(); rng.setStart(pos.container(), pos.offset()); rng.setEnd(pos.container(), pos.offset()); editor.selection.setRng(rng); }; type NodePredicate = (node: Node) => boolean; const isFeatureEnabled = function (editor: Editor) { return editor.settings.inline_boundaries !== false; }; const setSelected = function (state: boolean, elm: HTMLElement) { if (state) { elm.setAttribute('data-mce-selected', 'inline-boundary'); } else { elm.removeAttribute('data-mce-selected'); } }; const renderCaretLocation = function (editor: Editor, caret: Cell<Text>, location) { return BoundaryCaret.renderCaret(caret, location).map(function (pos) { setCaretPosition(editor, pos); return location; }); }; const findLocation = function (editor: Editor, caret: Cell<Text>, forward: boolean) { const rootNode = editor.getBody(); const from = CaretPosition.fromRangeStart(editor.selection.getRng()); const isInlineTarget = Fun.curry(InlineUtils.isInlineTarget, editor); const location = BoundaryLocation.findLocation(forward, isInlineTarget, rootNode, from); return location.bind(function (location) { return renderCaretLocation(editor, caret, location); }); }; const toggleInlines = function (isInlineTarget: NodePredicate, dom: DOMUtils, elms: Node[]) { const selectedInlines = Arr.filter(dom.select('*[data-mce-selected="inline-boundary"]'), isInlineTarget); const targetInlines = Arr.filter(elms, isInlineTarget); Arr.each(Arr.difference(selectedInlines, targetInlines), Fun.curry(setSelected, false)); Arr.each(Arr.difference(targetInlines, selectedInlines), Fun.curry(setSelected, true)); }; const safeRemoveCaretContainer = function (editor: Editor, caret: Cell<Text>) { if (editor.selection.isCollapsed() && editor.composing !== true && caret.get()) { const pos = CaretPosition.fromRangeStart(editor.selection.getRng()); if (CaretPosition.isTextPosition(pos) && InlineUtils.isAtZwsp(pos) === false) { setCaretPosition(editor, CaretContainerRemove.removeAndReposition(caret.get(), pos)); caret.set(null); } } }; const renderInsideInlineCaret = function (isInlineTarget: NodePredicate, editor: Editor, caret: Cell<Text>, elms: Node[]) { if (editor.selection.isCollapsed()) { const inlines = Arr.filter(elms, isInlineTarget); Arr.each(inlines, function (inline) { const pos = CaretPosition.fromRangeStart(editor.selection.getRng()); BoundaryLocation.readLocation(isInlineTarget, editor.getBody(), pos).bind(function (location) { return renderCaretLocation(editor, caret, location); }); }); } }; const move = function (editor: Editor, caret: Cell<Text>, forward: boolean) { return function () { return isFeatureEnabled(editor) ? findLocation(editor, caret, forward).isSome() : false; }; }; const moveWord = function (forward: boolean, editor: Editor, caret: Cell<Text>) { return function () { return isFeatureEnabled(editor) ? WordSelection.moveByWord(forward, editor) : false; }; }; const setupSelectedState = function (editor: Editor): Cell<Text> { const caret = Cell(null); const isInlineTarget: NodePredicate = Fun.curry(InlineUtils.isInlineTarget, editor); editor.on('NodeChange', function (e) { if (isFeatureEnabled(editor)) { toggleInlines(isInlineTarget, editor.dom, e.parents); safeRemoveCaretContainer(editor, caret); renderInsideInlineCaret(isInlineTarget, editor, caret, e.parents); } }); return caret; }; type MoveWordFn = (editor: Editor, caret: Cell<Text>) => () => boolean; const moveNextWord = Fun.curry(moveWord, true) as MoveWordFn; const movePrevWord = Fun.curry(moveWord, false) as MoveWordFn; export default { move, moveNextWord, movePrevWord, setupSelectedState, setCaretPosition };