OXIESEC PANEL
- Current Dir:
/
/
var
/
www
/
reader
/
_backup
/
tinymce
/
tinymce
/
src
/
core
/
main
/
ts
/
selection
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
02/20/2020 05:44:43 AM
rwxr-xr-x
📄
CaretRangeFromPoint.ts
2.6 KB
02/20/2020 05:44:11 AM
rw-r--r--
📄
DetailsElement.ts
1.19 KB
02/20/2020 05:44:11 AM
rw-r--r--
📄
ElementSelection.ts
4.83 KB
02/20/2020 05:44:12 AM
rw-r--r--
📄
EventProcessRanges.ts
593 bytes
02/20/2020 05:44:12 AM
rw-r--r--
📄
FragmentReader.ts
3.82 KB
02/20/2020 05:44:13 AM
rw-r--r--
📄
GetSelectionContent.ts
2.12 KB
02/20/2020 05:44:15 AM
rw-r--r--
📄
MultiClickSelection.ts
1.64 KB
02/20/2020 05:44:16 AM
rw-r--r--
📄
MultiRange.ts
955 bytes
02/20/2020 05:44:17 AM
rw-r--r--
📄
NormalizeRange.ts
10.02 KB
02/20/2020 05:44:17 AM
rw-r--r--
📄
RangeCompare.ts
580 bytes
02/20/2020 05:44:18 AM
rw-r--r--
📄
RangeInsertNode.ts
1.52 KB
02/20/2020 05:44:18 AM
rw-r--r--
📄
RangeNodes.ts
946 bytes
02/20/2020 05:44:19 AM
rw-r--r--
📄
RangeNormalizer.ts
1.69 KB
02/20/2020 05:44:19 AM
rw-r--r--
📄
RangeWalk.ts
4.38 KB
02/20/2020 05:44:20 AM
rw-r--r--
📄
SelectionBookmark.ts
3.36 KB
02/20/2020 05:44:20 AM
rw-r--r--
📄
SelectionRestore.ts
1.98 KB
02/20/2020 05:44:21 AM
rw-r--r--
📄
SelectionUtils.ts
3.65 KB
02/20/2020 05:44:21 AM
rw-r--r--
📄
SetSelectionContent.ts
2.44 KB
02/20/2020 05:44:22 AM
rw-r--r--
📄
SimpleTableModel.ts
4.08 KB
02/20/2020 05:44:22 AM
rw-r--r--
📄
SplitRange.ts
1.94 KB
02/20/2020 05:44:23 AM
rw-r--r--
📄
TableCellSelection.ts
1.25 KB
02/20/2020 05:44:24 AM
rw-r--r--
📄
WordSelection.ts
1.47 KB
02/20/2020 05:44:24 AM
rw-r--r--
Editing: RangeNormalizer.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 CaretFinder from '../caret/CaretFinder'; import CaretPosition from '../caret/CaretPosition'; import * as CaretUtils from '../caret/CaretUtils'; import { Node, Range, document } from '@ephox/dom-globals'; const createRange = (sc: Node, so: number, ec: Node, eo: number): Range => { const rng = document.createRange(); rng.setStart(sc, so); rng.setEnd(ec, eo); return rng; }; // If you triple click a paragraph in this case: // <blockquote><p>a</p></blockquote><p>b</p> // It would become this range in webkit: // <blockquote><p>[a</p></blockquote><p>]b</p> // We would want it to be: // <blockquote><p>[a]</p></blockquote><p>b</p> // Since it would otherwise produces spans out of thin air on insertContent for example. const normalizeBlockSelectionRange = (rng: Range): Range => { const startPos = CaretPosition.fromRangeStart(rng); const endPos = CaretPosition.fromRangeEnd(rng); const rootNode = rng.commonAncestorContainer; return CaretFinder.fromPosition(false, rootNode, endPos) .map(function (newEndPos) { if (!CaretUtils.isInSameBlock(startPos, endPos, rootNode) && CaretUtils.isInSameBlock(startPos, newEndPos, rootNode)) { return createRange(startPos.container(), startPos.offset(), newEndPos.container(), newEndPos.offset()); } else { return rng; } }).getOr(rng); }; const normalize = (rng: Range): Range => rng.collapsed ? rng : normalizeBlockSelectionRange(rng); export default { normalize };