OXIESEC PANEL
- Current Dir:
/
/
var
/
www
/
reader
/
_backup
/
tinymce
/
tinymce
/
src
/
core
/
main
/
ts
/
dom
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
02/20/2020 05:44:43 AM
rwxr-xr-x
📄
Dimensions.ts
1.28 KB
02/20/2020 05:42:59 AM
rw-r--r--
📄
DomSerializer.ts
4.65 KB
02/20/2020 05:42:59 AM
rw-r--r--
📄
DomSerializerFilters.ts
6.91 KB
02/20/2020 05:43:00 AM
rw-r--r--
📄
DomSerializerPreProcess.ts
1.81 KB
02/20/2020 05:43:00 AM
rw-r--r--
📄
ElementType.ts
2.39 KB
02/20/2020 05:43:01 AM
rw-r--r--
📄
Empty.ts
2.18 KB
02/20/2020 05:43:02 AM
rw-r--r--
📄
MousePosition.ts
2.37 KB
02/20/2020 05:43:03 AM
rw-r--r--
📄
NodePath.ts
970 bytes
02/20/2020 05:43:03 AM
rw-r--r--
📄
NodeType.ts
3.37 KB
02/20/2020 05:43:04 AM
rw-r--r--
📄
PaddingBr.ts
1.7 KB
02/20/2020 05:43:04 AM
rw-r--r--
📄
Parents.ts
1020 bytes
02/20/2020 05:43:05 AM
rw-r--r--
📄
Position.ts
2.9 KB
02/20/2020 05:43:05 AM
rw-r--r--
📄
RangePoint.ts
639 bytes
02/20/2020 05:43:06 AM
rw-r--r--
📄
ScrollIntoView.ts
3.27 KB
02/20/2020 05:43:07 AM
rw-r--r--
📄
StyleSheetLoader.ts
6.49 KB
02/20/2020 05:43:08 AM
rw-r--r--
📄
TrimHtml.ts
1.62 KB
02/20/2020 05:43:08 AM
rw-r--r--
📄
TrimNode.ts
2.58 KB
02/20/2020 05:43:09 AM
rw-r--r--
Editing: ScrollIntoView.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 { HTMLElement, Element, Range } from '@ephox/dom-globals'; import { Arr } from '@ephox/katamari'; import NodeType from './NodeType'; import Editor from '../api/Editor'; import { getOverflow } from '../geom/ClientRect'; import { CaretPosition } from '../caret/CaretPosition'; const getPos = function (elm: HTMLElement) { let x = 0, y = 0; let offsetParent = elm; while (offsetParent && offsetParent.nodeType) { x += offsetParent.offsetLeft || 0; y += offsetParent.offsetTop || 0; offsetParent = offsetParent.offsetParent as HTMLElement; } return { x, y }; }; const fireScrollIntoViewEvent = function (editor: Editor, elm: Element, alignToTop: boolean) { const scrollEvent: any = { elm, alignToTop }; editor.fire('ScrollIntoView', scrollEvent); return scrollEvent.isDefaultPrevented(); }; const scrollElementIntoView = function (editor: Editor, elm: HTMLElement, alignToTop: boolean) { let y, viewPort; const dom = editor.dom; const root = dom.getRoot(); let viewPortY, viewPortH, offsetY = 0; if (fireScrollIntoViewEvent(editor, elm, alignToTop)) { return; } if (!NodeType.isElement(elm)) { return; } if (alignToTop === false) { offsetY = elm.offsetHeight; } if (root.nodeName !== 'BODY') { const scrollContainer = editor.selection.getScrollContainer(); if (scrollContainer) { y = getPos(elm).y - getPos(scrollContainer).y + offsetY; viewPortH = scrollContainer.clientHeight; viewPortY = scrollContainer.scrollTop; if (y < viewPortY || y + 25 > viewPortY + viewPortH) { scrollContainer.scrollTop = y < viewPortY ? y : y - viewPortH + 25; } return; } } viewPort = dom.getViewPort(editor.getWin()); y = dom.getPos(elm).y + offsetY; viewPortY = viewPort.y; viewPortH = viewPort.h; if (y < viewPort.y || y + 25 > viewPortY + viewPortH) { editor.getWin().scrollTo(0, y < viewPortY ? y : y - viewPortH + 25); } }; const getViewPortRect = (editor: Editor) => { if (editor.inline) { return editor.getBody().getBoundingClientRect(); } else { const win = editor.getWin(); return { left: 0, right: win.innerWidth, top: 0, bottom: win.innerHeight, width: win.innerWidth, height: win.innerHeight }; } }; const scrollBy = (editor: Editor, dx: number, dy: number) => { if (editor.inline) { editor.getBody().scrollLeft += dx; editor.getBody().scrollTop += dy; } else { editor.getWin().scrollBy(dx, dy); } }; const scrollRangeIntoView = (editor: Editor, rng: Range) => { Arr.head(CaretPosition.fromRangeStart(rng).getClientRects()).each((rngRect) => { const bodyRect = getViewPortRect(editor); const overflow = getOverflow(bodyRect, rngRect); const margin = 4; const dx = overflow.x > 0 ? overflow.x + margin : overflow.x - margin; const dy = overflow.y > 0 ? overflow.y + margin : overflow.y - margin; scrollBy(editor, overflow.x !== 0 ? dx : 0, overflow.y !== 0 ? dy : 0); }); }; export default { scrollElementIntoView, scrollRangeIntoView };