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: ContentEndpointNavigation.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 Editor from '../api/Editor'; import CaretPosition from '../caret/CaretPosition'; import { Fun, Arr } from '@ephox/katamari'; import { Insert, Element, Compare, PredicateFind, Node, Attr } from '@ephox/sugar'; import Settings from '../api/Settings'; import { document } from '@ephox/dom-globals'; import * as ElementType from '../dom/ElementType'; import { isAtLastLine, isAtFirstLine } from '../caret/LineReader'; const isTarget = (node: Element) => Arr.contains(['figcaption'], Node.name(node)); const rangeBefore = (target: Element) => { const rng = document.createRange(); rng.setStartBefore(target.dom()); rng.setEndBefore(target.dom()); return rng; }; const insertElement = (root: Element, elm: Element, forward: boolean) => { if (forward) { Insert.append(root, elm); } else { Insert.prepend(root, elm); } }; const insertBr = (root: Element, forward: boolean) => { const br = Element.fromTag('br'); insertElement(root, br, forward); return rangeBefore(br); }; const insertBlock = (root: Element, forward: boolean, blockName: string, attrs: Record<string, string>) => { const block = Element.fromTag(blockName); const br = Element.fromTag('br'); Attr.setAll(block, attrs); Insert.append(block, br); insertElement(root, block, forward); return rangeBefore(br); }; const insertEmptyLine = (root: Element, rootBlockName: string, attrs: Record<string, string>, forward: boolean) => { if (rootBlockName === '') { return insertBr(root, forward); } else { return insertBlock(root, forward, rootBlockName, attrs); } }; const getClosestTargetBlock = (pos: CaretPosition, root: Element) => { const isRoot = Fun.curry(Compare.eq, root); return PredicateFind.closest(Element.fromDom(pos.container()), ElementType.isBlock, isRoot).filter(isTarget); }; const isAtFirstOrLastLine = (root: Element, forward: boolean, pos: CaretPosition) => { return forward ? isAtLastLine(root.dom(), pos) : isAtFirstLine(root.dom(), pos); }; const moveCaretToNewEmptyLine = (editor: Editor, forward: boolean) => { const root = Element.fromDom(editor.getBody()); const pos = CaretPosition.fromRangeStart(editor.selection.getRng()); const rootBlock = Settings.getForcedRootBlock(editor); const rootBlockAttrs = Settings.getForcedRootBlockAttrs(editor); return getClosestTargetBlock(pos, root).exists(() => { if (isAtFirstOrLastLine(root, forward, pos)) { const rng = insertEmptyLine(root, rootBlock, rootBlockAttrs, forward); editor.selection.setRng(rng); return true; } else { return false; } }); }; const moveV = (editor: Editor, forward: boolean) => () => { if (editor.selection.isCollapsed()) { return moveCaretToNewEmptyLine(editor, forward); } else { return false; } }; export { moveV };