OXIESEC PANEL
- Current Dir:
/
/
var
/
www
/
reader
/
_backup
/
tinymce
/
tinymce
/
src
/
themes
/
mobile
/
main
/
ts
/
util
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
02/20/2020 06:45:48 AM
rwxr-xr-x
📄
CaptureBin.ts
733 bytes
02/20/2020 06:32:51 AM
rw-r--r--
📄
CssUrls.ts
758 bytes
02/20/2020 06:32:51 AM
rw-r--r--
📄
DataAttributes.ts
472 bytes
02/20/2020 06:32:52 AM
rw-r--r--
📄
FontSizes.ts
2.14 KB
02/20/2020 06:32:52 AM
rw-r--r--
📄
FormatChangers.ts
1.11 KB
02/20/2020 06:32:53 AM
rw-r--r--
📄
RangePreserver.ts
1002 bytes
02/20/2020 06:32:53 AM
rw-r--r--
📄
Rectangles.ts
1.78 KB
02/20/2020 06:32:54 AM
rw-r--r--
📄
SkinLoaded.ts
553 bytes
02/20/2020 06:32:54 AM
rw-r--r--
📄
StyleConversions.ts
1.46 KB
02/20/2020 06:32:55 AM
rw-r--r--
📄
StyleFormats.ts
3.07 KB
02/20/2020 06:32:55 AM
rw-r--r--
📄
TappingEvent.ts
1.09 KB
02/20/2020 06:32:56 AM
rw-r--r--
📄
Thor.ts
3 KB
02/20/2020 06:32:56 AM
rw-r--r--
📄
UiDomFactory.ts
676 bytes
02/20/2020 06:32:57 AM
rw-r--r--
Editing: Rectangles.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 { Awareness, Element, Selection, Traverse, WindowSelection } from '@ephox/sugar'; const COLLAPSED_WIDTH = 2; const collapsedRect = function (rect) { return { left: rect.left, top: rect.top, right: rect.right, bottom: rect.bottom, width: Fun.constant(COLLAPSED_WIDTH), height: rect.height }; }; const toRect = function (rawRect) { return { left: Fun.constant(rawRect.left), top: Fun.constant(rawRect.top), right: Fun.constant(rawRect.right), bottom: Fun.constant(rawRect.bottom), width: Fun.constant(rawRect.width), height: Fun.constant(rawRect.height) }; }; const getRectsFromRange = function (range) { if (! range.collapsed) { return Arr.map(range.getClientRects(), toRect); } else { const start = Element.fromDom(range.startContainer); return Traverse.parent(start).bind(function (parent) { const selection = Selection.exact(start, range.startOffset, parent, Awareness.getEnd(parent)); const optRect = WindowSelection.getFirstRect(range.startContainer.ownerDocument.defaultView, selection); return optRect.map(collapsedRect).map(Arr.pure); }).getOr([ ]); } }; const getRectangles = function (cWin) { const sel = cWin.getSelection(); // In the Android WebView for some reason cWin.getSelection returns undefined. // The undefined check it is to avoid throwing of a JS error. return sel !== undefined && sel.rangeCount > 0 ? getRectsFromRange(sel.getRangeAt(0)) : [ ]; }; export default { getRectangles };