OXIESEC PANEL
- Current Dir:
/
/
var
/
www
/
reader
/
_backup
/
tinymce
/
tinymce
/
src
/
core
/
main
/
ts
/
content
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
02/20/2020 05:44:43 AM
rwxr-xr-x
📄
EditorContent.ts
524 bytes
02/20/2020 05:42:39 AM
rw-r--r--
📄
GetContent.ts
2.37 KB
02/20/2020 05:42:39 AM
rw-r--r--
📄
InsertContent.ts
11.61 KB
02/20/2020 05:42:41 AM
rw-r--r--
📄
InsertList.ts
5.85 KB
02/20/2020 05:42:41 AM
rw-r--r--
📄
NbspTrim.ts
1.88 KB
02/20/2020 05:42:42 AM
rw-r--r--
📄
SetContent.ts
4.45 KB
02/20/2020 05:42:42 AM
rw-r--r--
Editing: NbspTrim.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, Range } from '@ephox/dom-globals'; import NodeType from '../dom/NodeType'; const isAfterNbsp = (container: Node, offset: number) => { return NodeType.isText(container) && container.nodeValue[offset - 1] === '\u00a0'; }; const trimOrPadLeftRight = (rng: Range, html: string): string => { let container, offset; container = rng.startContainer; offset = rng.startOffset; const hasSiblingText = function (siblingName) { return container[siblingName] && container[siblingName].nodeType === 3; }; if (container.nodeType === 3) { if (offset > 0) { html = html.replace(/^ /, ' '); } else if (!hasSiblingText('previousSibling')) { html = html.replace(/^ /, ' '); } if (offset < container.length) { html = html.replace(/ (<br>|)$/, ' '); } else if (!hasSiblingText('nextSibling')) { html = html.replace(/( | )(<br>|)$/, ' '); } } return html; }; // Removes from a [b] c -> a c -> a c const trimNbspAfterDeleteAndPadValue = (rng: Range, value: string): string => { let container, offset; container = rng.startContainer; offset = rng.startOffset; if (container.nodeType === 3 && rng.collapsed) { if (container.data[offset] === '\u00a0') { container.deleteData(offset, 1); if (!/[\u00a0| ]$/.test(value)) { value += ' '; } } else if (container.data[offset - 1] === '\u00a0') { container.deleteData(offset - 1, 1); if (!/[\u00a0| ]$/.test(value)) { value = ' ' + value; } } } return value; }; export { isAfterNbsp, trimNbspAfterDeleteAndPadValue, trimOrPadLeftRight };