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: ForceBlocks.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 { Arr, Fun } from '@ephox/katamari'; import { Element } from '@ephox/sugar'; import Bookmarks from './bookmark/Bookmarks'; import NodeType from './dom/NodeType'; import Parents from './dom/Parents'; import EditorFocus from './focus/EditorFocus'; import Settings from './api/Settings'; import Editor from './api/Editor'; import { Node } from '@ephox/dom-globals'; /** * Makes sure that everything gets wrapped in paragraphs. * * @private * @class tinymce.ForceBlocks */ const isBlockElement = function (blockElements, node) { return blockElements.hasOwnProperty(node.nodeName); }; const isValidTarget = function (blockElements, node) { if (NodeType.isText(node)) { return true; } else if (NodeType.isElement(node)) { return !isBlockElement(blockElements, node) && !Bookmarks.isBookmarkNode(node); } else { return false; } }; const hasBlockParent = function (blockElements, root, node) { return Arr.exists(Parents.parents(Element.fromDom(node), Element.fromDom(root)), function (elm) { return isBlockElement(blockElements, elm.dom()); }); }; // const is const shouldRemoveTextNode = (blockElements, node) => { if (NodeType.isText(node)) { if (node.nodeValue.length === 0) { return true; } else if (/^\s+$/.test(node.nodeValue) && (!node.nextSibling || isBlockElement(blockElements, node.nextSibling))) { return true; } } return false; }; const addRootBlocks = function (editor: Editor) { const dom = editor.dom, selection = editor.selection; const schema = editor.schema, blockElements = schema.getBlockElements(); let node: Node = selection.getStart(); const rootNode = editor.getBody(); let rng; let startContainer, startOffset, endContainer, endOffset, rootBlockNode; let tempNode, wrapped, restoreSelection; let rootNodeName; const forcedRootBlock = Settings.getForcedRootBlock(editor); if (!node || !NodeType.isElement(node) || !forcedRootBlock) { return; } rootNodeName = rootNode.nodeName.toLowerCase(); if (!schema.isValidChild(rootNodeName, forcedRootBlock.toLowerCase()) || hasBlockParent(blockElements, rootNode, node)) { return; } // Get current selection rng = selection.getRng(); startContainer = rng.startContainer; startOffset = rng.startOffset; endContainer = rng.endContainer; endOffset = rng.endOffset; restoreSelection = EditorFocus.hasFocus(editor); // Wrap non block elements and text nodes node = rootNode.firstChild; while (node) { if (isValidTarget(blockElements, node)) { // Remove empty text nodes and nodes containing only whitespace if (shouldRemoveTextNode(blockElements, node)) { tempNode = node; node = node.nextSibling; dom.remove(tempNode); continue; } if (!rootBlockNode) { rootBlockNode = dom.create(forcedRootBlock, Settings.getForcedRootBlockAttrs(editor)); node.parentNode.insertBefore(rootBlockNode, node); wrapped = true; } tempNode = node; node = node.nextSibling; rootBlockNode.appendChild(tempNode); } else { rootBlockNode = null; node = node.nextSibling; } } if (wrapped && restoreSelection) { rng.setStart(startContainer, startOffset); rng.setEnd(endContainer, endOffset); selection.setRng(rng); editor.nodeChanged(); } }; const setup = function (editor: Editor) { if (Settings.getForcedRootBlock(editor)) { editor.on('NodeChange', Fun.curry(addRootBlocks, editor)); } }; export default { setup };