@worktile/theia 17.2.2 → 17.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/column-resize/column-resize.directive.d.ts +5 -3
- package/components/column-resize/column-resize.scss +0 -7
- package/components/column-resize/overlay-handle.component.d.ts +4 -6
- package/components/column-resize/resizing.store.d.ts +0 -8
- package/components/inline-toolbar/inline-toolbar.component.d.ts +1 -1
- package/components/toolbar/toolbar.component.d.ts +0 -1
- package/constants/node-types.d.ts +0 -1
- package/core/utils/plugin-menu.d.ts +8 -0
- package/editor.component.d.ts +1 -1
- package/esm2022/components/column-resize/column-resize.directive.mjs +28 -9
- package/esm2022/components/column-resize/overlay-handle.component.mjs +12 -16
- package/esm2022/components/column-resize/resizing.store.mjs +3 -66
- package/esm2022/components/inline-toolbar/inline-toolbar.component.mjs +13 -22
- package/esm2022/components/plugin-menu/plugin-menu.component.mjs +6 -5
- package/esm2022/components/toolbar/toolbar.component.mjs +2 -7
- package/esm2022/constants/default.mjs +2 -2
- package/esm2022/constants/node-types.mjs +1 -2
- package/esm2022/core/utils/plugin-menu.mjs +34 -1
- package/esm2022/editor.component.mjs +13 -5
- package/esm2022/interfaces/plugins/plugin-menu.mjs +2 -2
- package/esm2022/interfaces/plugins/plugins.mjs +1 -1
- package/esm2022/plugins/common/block-card.plugin.mjs +12 -2
- package/esm2022/plugins/image/image.component.mjs +2 -2
- package/esm2022/plugins/image/image.editor.mjs +2 -3
- package/esm2022/plugins/image/image.plugin.mjs +2 -2
- package/esm2022/plugins/inline-code/inline-code.plugin.mjs +3 -2
- package/esm2022/plugins/link/link.plugin.mjs +4 -3
- package/esm2022/plugins/quick-insert/quick-insert.editor.mjs +4 -2
- package/esm2022/plugins/table/components/insert-mark/insert-mark.component.mjs +41 -17
- package/esm2022/plugins/table/components/row/row.component.mjs +2 -2
- package/esm2022/plugins/table/components/table.component.mjs +22 -26
- package/esm2022/plugins/table/components/td/td.component.mjs +47 -125
- package/esm2022/plugins/table/table.editor.mjs +2 -2
- package/esm2022/plugins/table/table.types.mjs +1 -1
- package/esm2022/plugins/table/utils/get-grid-columns.mjs +2 -2
- package/esm2022/plugins/table/utils/table-viewport.mjs +41 -0
- package/esm2022/plugins/vertical-align/toolbar-item.component.mjs +3 -5
- package/esm2022/queries/anchor-block-entry.mjs +3 -3
- package/esm2022/queries/anchor-block.mjs +3 -3
- package/esm2022/queries/get-block-card-cursor.mjs +6 -2
- package/esm2022/queries/is-block-card-cursor.mjs +7 -2
- package/esm2022/utils/index.mjs +2 -2
- package/esm2022/utils/scrolling.mjs +43 -0
- package/fesm2022/worktile-theia.mjs +294 -314
- package/fesm2022/worktile-theia.mjs.map +1 -1
- package/interfaces/editor.d.ts +2 -2
- package/interfaces/plugins/plugins.d.ts +2 -1
- package/package.json +1 -1
- package/plugins/table/components/insert-mark/insert-mark.component.d.ts +12 -4
- package/plugins/table/components/table.component.d.ts +1 -2
- package/plugins/table/components/table.component.scss +4 -18
- package/plugins/table/components/td/td.component.d.ts +9 -10
- package/plugins/table/table.types.d.ts +2 -2
- package/plugins/table/utils/table-viewport.d.ts +8 -0
- package/plugins/vertical-align/toolbar-item.component.d.ts +2 -3
- package/queries/anchor-block-entry.d.ts +2 -2
- package/queries/anchor-block.d.ts +2 -2
- package/queries/get-block-card-cursor.d.ts +2 -2
- package/queries/is-block-card-cursor.d.ts +2 -2
- package/styles/editor.scss +7 -0
- package/utils/index.d.ts +1 -1
- package/utils/{scroll-into-view.d.ts → scrolling.d.ts} +1 -0
- package/esm2022/utils/scroll-into-view.mjs +0 -38
package/interfaces/editor.d.ts
CHANGED
|
@@ -45,7 +45,7 @@ export declare const TheEditor: {
|
|
|
45
45
|
insertTextData(editor: AngularEditor, data: DataTransfer): boolean;
|
|
46
46
|
onKeydown(editor: AngularEditor, data: KeyboardEvent): void;
|
|
47
47
|
onClick(editor: AngularEditor, data: MouseEvent): void;
|
|
48
|
-
setFragmentData(editor: AngularEditor, data: DataTransfer, originEvent?: "
|
|
48
|
+
setFragmentData(editor: AngularEditor, data: DataTransfer, originEvent?: "copy" | "drag" | "cut"): void;
|
|
49
49
|
deleteCutData(editor: AngularEditor): void;
|
|
50
50
|
toDOMNode(editor: AngularEditor, node: Node): HTMLElement;
|
|
51
51
|
toDOMPoint(editor: AngularEditor, point: import("slate").BasePoint): import("slate-angular").DOMPoint;
|
|
@@ -61,7 +61,7 @@ export declare const TheEditor: {
|
|
|
61
61
|
exactMatch?: boolean;
|
|
62
62
|
suppressThrow: T_1;
|
|
63
63
|
}): T_1 extends true ? import("slate").BasePoint : import("slate").BasePoint;
|
|
64
|
-
toSlateRange<T_2 extends boolean>(editor: AngularEditor, domRange:
|
|
64
|
+
toSlateRange<T_2 extends boolean>(editor: AngularEditor, domRange: globalThis.Range | Selection | StaticRange, options?: {
|
|
65
65
|
exactMatch?: boolean;
|
|
66
66
|
suppressThrow: T_2;
|
|
67
67
|
}): T_2 extends true ? import("slate").BaseRange : import("slate").BaseRange;
|
|
@@ -2,14 +2,15 @@ import { CustomElementKinds } from '../../custom-types';
|
|
|
2
2
|
import { ToolbarItem } from '../toolbar';
|
|
3
3
|
import { NestedStructureByKey } from '../utility';
|
|
4
4
|
import { WithRequired } from '../utility/types';
|
|
5
|
-
import { ThePluginMenuItem } from './plugin-menu';
|
|
6
5
|
import { NoInfer } from './no-infer';
|
|
7
6
|
import { PluginKey, TheiaPluginKey } from './plugin-key';
|
|
7
|
+
import { ThePluginMenuItem } from './plugin-menu';
|
|
8
8
|
import { WithOverride } from './with-override';
|
|
9
9
|
export type ThePluginBaseOption = {
|
|
10
10
|
allowParentTypes?: (CustomElementKinds | string)[];
|
|
11
11
|
disabledOperateTypes?: CustomElementKinds[];
|
|
12
12
|
disabled?: boolean;
|
|
13
|
+
isInline?: boolean;
|
|
13
14
|
};
|
|
14
15
|
export type ThePluginOption<P> = NoInfer<{
|
|
15
16
|
[key: string]: any;
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ChangeDetectorRef, OnDestroy, OnInit, Renderer2 } from '@angular/core';
|
|
1
|
+
import { ChangeDetectorRef, ElementRef, OnDestroy, OnInit, Renderer2 } from '@angular/core';
|
|
2
2
|
import { Subject } from 'rxjs';
|
|
3
3
|
import { Editor } from 'slate';
|
|
4
4
|
import { TableStore } from '../../table.store';
|
|
@@ -6,24 +6,32 @@ import * as i0 from "@angular/core";
|
|
|
6
6
|
export declare class TheInsertMark implements OnInit, OnDestroy {
|
|
7
7
|
private cdr;
|
|
8
8
|
renderer2: Renderer2;
|
|
9
|
+
elementRef: ElementRef<HTMLElement>;
|
|
9
10
|
type: 'row' | 'column';
|
|
10
11
|
at: number;
|
|
11
12
|
tableStore: TableStore;
|
|
12
13
|
parentElement: HTMLElement;
|
|
13
|
-
|
|
14
|
+
insertWrapper: ElementRef<HTMLElement>;
|
|
15
|
+
insertLineStyle: {};
|
|
14
16
|
dotWrapperHovered: boolean;
|
|
15
17
|
destroy$: Subject<void>;
|
|
16
18
|
tooltipContent: string;
|
|
17
19
|
disabled: boolean;
|
|
18
20
|
get editor(): Editor;
|
|
19
|
-
constructor(cdr: ChangeDetectorRef, renderer2: Renderer2);
|
|
21
|
+
constructor(cdr: ChangeDetectorRef, renderer2: Renderer2, elementRef: ElementRef<HTMLElement>);
|
|
20
22
|
ngOnInit(): void;
|
|
21
23
|
ngOnDestroy(): void;
|
|
22
24
|
preventDefault(event: MouseEvent): void;
|
|
23
25
|
insert(event: MouseEvent): void;
|
|
24
26
|
onMouseEnter(event: MouseEvent): void;
|
|
25
27
|
onMouseLeave(event: MouseEvent): void;
|
|
26
|
-
|
|
28
|
+
getInsertLineStyle(): {
|
|
29
|
+
height: string;
|
|
30
|
+
width: string;
|
|
31
|
+
left: string;
|
|
32
|
+
top: string;
|
|
33
|
+
};
|
|
34
|
+
isLastColumn(): boolean;
|
|
27
35
|
static ɵfac: i0.ɵɵFactoryDeclaration<TheInsertMark, never>;
|
|
28
36
|
static ɵcmp: i0.ɵɵComponentDeclaration<TheInsertMark, "the-table-insert-mark", never, { "type": { "alias": "type"; "required": false; }; "at": { "alias": "at"; "required": false; }; "tableStore": { "alias": "tableStore"; "required": false; }; "parentElement": { "alias": "parentElement"; "required": false; }; }, {}, never, never, true, never>;
|
|
29
37
|
}
|
|
@@ -100,7 +100,7 @@ export declare class TheTable extends TheBaseElement<TableElement, Editor> imple
|
|
|
100
100
|
getIsInTable(): void;
|
|
101
101
|
initializeColumns(): void;
|
|
102
102
|
initializeRows(): void;
|
|
103
|
-
transformRowHeight(): void;
|
|
103
|
+
transformRowHeight(rowIndex: number): void;
|
|
104
104
|
transformColumnsWidth(): void;
|
|
105
105
|
onColMousedown(event: MouseEvent, index: number): void;
|
|
106
106
|
onRowMousedown(event: MouseEvent, index: number): void;
|
|
@@ -108,7 +108,6 @@ export declare class TheTable extends TheBaseElement<TableElement, Editor> imple
|
|
|
108
108
|
listenTableContextMenuEvent(): void;
|
|
109
109
|
listenOnSelectedCells(): void;
|
|
110
110
|
listenKeydownEvent(): void;
|
|
111
|
-
listenKeyupEvent(): void;
|
|
112
111
|
private listenSelectstartEvent;
|
|
113
112
|
setStickyRowPointerEvents(pointerEventsStyle: string): void;
|
|
114
113
|
listenTableWrapperScroll(): void;
|
|
@@ -301,8 +301,10 @@ $top-cell-z-index: 13;
|
|
|
301
301
|
}
|
|
302
302
|
}
|
|
303
303
|
}
|
|
304
|
+
}
|
|
304
305
|
|
|
305
|
-
|
|
306
|
+
.the-numbered-table {
|
|
307
|
+
.the-table-container .the-table-wrapper {
|
|
306
308
|
margin-left: -44px;
|
|
307
309
|
padding-left: 44px;
|
|
308
310
|
}
|
|
@@ -353,10 +355,6 @@ $top-cell-z-index: 13;
|
|
|
353
355
|
&:after {
|
|
354
356
|
left: 0;
|
|
355
357
|
}
|
|
356
|
-
|
|
357
|
-
.the-table-controls-insert-line[data-dot-type='column'] {
|
|
358
|
-
left: $dot-size;
|
|
359
|
-
}
|
|
360
358
|
}
|
|
361
359
|
}
|
|
362
360
|
|
|
@@ -609,21 +607,9 @@ $top-cell-z-index: 13;
|
|
|
609
607
|
}
|
|
610
608
|
|
|
611
609
|
.the-table-controls-insert-line {
|
|
612
|
-
position:
|
|
610
|
+
position: fixed;
|
|
613
611
|
z-index: $dot-z-index;
|
|
614
612
|
background-color: variables.$primary;
|
|
615
|
-
|
|
616
|
-
&[data-dot-type='column'] {
|
|
617
|
-
top: $dot-size;
|
|
618
|
-
left: $dot-shadow-top;
|
|
619
|
-
width: 1px;
|
|
620
|
-
}
|
|
621
|
-
|
|
622
|
-
&[data-dot-type='row'] {
|
|
623
|
-
bottom: $dot-shadow-top;
|
|
624
|
-
left: $dot-size;
|
|
625
|
-
height: 1px;
|
|
626
|
-
}
|
|
627
613
|
}
|
|
628
614
|
}
|
|
629
615
|
|
|
@@ -16,7 +16,7 @@ export declare const POSITION_MAP: {
|
|
|
16
16
|
[key: string]: ConnectedPosition;
|
|
17
17
|
};
|
|
18
18
|
export declare class TheTd extends TheBaseElement<TableCellElement, Editor> implements OnInit, AfterViewInit, OnDestroy {
|
|
19
|
-
elementRef: ElementRef
|
|
19
|
+
elementRef: ElementRef<HTMLTableCellElement>;
|
|
20
20
|
cdr: ChangeDetectorRef;
|
|
21
21
|
private renderer;
|
|
22
22
|
private ngZone;
|
|
@@ -37,7 +37,6 @@ export declare class TheTd extends TheBaseElement<TableCellElement, Editor> impl
|
|
|
37
37
|
get eventDispatcher(): TableCellEventDispatcher;
|
|
38
38
|
get resizeNotifier(): ColumnResizeNotifierSource;
|
|
39
39
|
get tableElement(): HTMLElement;
|
|
40
|
-
get scrollableElementTop(): number;
|
|
41
40
|
get scrollableElementBottom(): number;
|
|
42
41
|
get scrollableElementLeft(): number;
|
|
43
42
|
get isXAxisHover(): boolean;
|
|
@@ -51,7 +50,7 @@ export declare class TheTd extends TheBaseElement<TableCellElement, Editor> impl
|
|
|
51
50
|
display: string;
|
|
52
51
|
onContextChange(): void;
|
|
53
52
|
getOutletParent: () => any;
|
|
54
|
-
constructor(elementRef: ElementRef
|
|
53
|
+
constructor(elementRef: ElementRef<HTMLTableCellElement>, cdr: ChangeDetectorRef, renderer: Renderer2, ngZone: NgZone, injector: Injector, overlay: Overlay, resizingStore: ColumnResizingStore, scrollDispatcher: ScrollDispatcher);
|
|
55
54
|
ngOnInit(): void;
|
|
56
55
|
ngAfterViewInit(): void;
|
|
57
56
|
getInjectionService(): void;
|
|
@@ -71,20 +70,20 @@ export declare class TheTd extends TheBaseElement<TableCellElement, Editor> impl
|
|
|
71
70
|
private _createHandlePortal;
|
|
72
71
|
private _showHandleOverlay;
|
|
73
72
|
private updateOverlayHandleSizeAndOffset;
|
|
74
|
-
private updateOverlayHandleColumnSize;
|
|
75
|
-
private getIsStickyTopRow;
|
|
76
|
-
private updateOverlayHandleRowSize;
|
|
77
73
|
private applySize;
|
|
78
74
|
private _createOverlayForHandle;
|
|
79
75
|
private createPositionStrategy;
|
|
80
|
-
|
|
81
|
-
|
|
76
|
+
getOverlayHandleRect(): {
|
|
77
|
+
top: number;
|
|
78
|
+
left: number;
|
|
79
|
+
width: number;
|
|
80
|
+
height: number;
|
|
81
|
+
};
|
|
82
82
|
applyColumnSize(deltaX: number): void;
|
|
83
83
|
applyLeftCols(cols: HTMLTableColElement[], deltaX: number, colIndex: number): number;
|
|
84
84
|
applyRightCols(cols: HTMLTableColElement[], deltaX: number, colIndex: number): number;
|
|
85
85
|
applyRowSize(deltaY: number): void;
|
|
86
|
-
|
|
87
|
-
applyBottomRows(rows: HTMLTableRowElement[], deltaY: number, rowIndex: number): number;
|
|
86
|
+
applyTargetRow(rows: HTMLTableRowElement[], deltaY: number, rowIndex: number): void;
|
|
88
87
|
ngOnDestroy(): void;
|
|
89
88
|
static ɵfac: i0.ɵɵFactoryDeclaration<TheTd, never>;
|
|
90
89
|
static ɵcmp: i0.ɵɵComponentDeclaration<TheTd, "td[theTd]", never, {}, {}, never, never, true, never>;
|
|
@@ -5,7 +5,7 @@ import { ComponentType } from 'slate-angular';
|
|
|
5
5
|
import { ElementKinds } from '../../constants/node-types';
|
|
6
6
|
import { TableCellElement, TableElement } from '../../custom-types';
|
|
7
7
|
import { TheBaseElement } from '../../interfaces/view-base';
|
|
8
|
-
import
|
|
8
|
+
import { TheTable } from './components/table.component';
|
|
9
9
|
export declare const THE_TABLE_COMPONENT_TOKEN: InjectionToken<ComponentType<TheTable>>;
|
|
10
10
|
export declare const HEADER_CELL_CLASS = "the-header-cell";
|
|
11
11
|
export declare const STICKY_CELL_CLASS = "the-sticky-cell";
|
|
@@ -19,7 +19,7 @@ export interface TheTableBase extends TheBaseElement {
|
|
|
19
19
|
initializeColumns: () => void;
|
|
20
20
|
transformColumnsWidth: () => void;
|
|
21
21
|
initializeRows: () => void;
|
|
22
|
-
transformRowHeight: () => void;
|
|
22
|
+
transformRowHeight: (rowIndex: number) => void;
|
|
23
23
|
}
|
|
24
24
|
export declare const BASE_CELL_HEIGHT = 41;
|
|
25
25
|
export declare const BASE_FILL_HEIGHT: number;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { ElementRef,
|
|
1
|
+
import { ElementRef, TemplateRef, ViewContainerRef } from '@angular/core';
|
|
2
2
|
import { ThyPopover, ThyPopoverRef } from 'ngx-tethys/popover';
|
|
3
3
|
import { Editor } from 'slate';
|
|
4
4
|
import { TheBaseToolbarDropdown } from '../../core/toolbar-item/base-toolbar-item';
|
|
5
5
|
import { ToolbarItem } from '../../interfaces';
|
|
6
6
|
import * as i0 from "@angular/core";
|
|
7
|
-
export declare class TheVerticalToolbarItem extends TheBaseToolbarDropdown
|
|
7
|
+
export declare class TheVerticalToolbarItem extends TheBaseToolbarDropdown {
|
|
8
8
|
elementRef: ElementRef;
|
|
9
9
|
private thyPopover;
|
|
10
10
|
private viewContainerRef;
|
|
@@ -13,7 +13,6 @@ export declare class TheVerticalToolbarItem extends TheBaseToolbarDropdown imple
|
|
|
13
13
|
get isOpened(): boolean;
|
|
14
14
|
handleDocumentMouseDown(event: MouseEvent): void;
|
|
15
15
|
constructor(elementRef: ElementRef, thyPopover: ThyPopover, viewContainerRef: ViewContainerRef);
|
|
16
|
-
ngOnInit(): void;
|
|
17
16
|
menusActive(editor: Editor): ToolbarItem;
|
|
18
17
|
execute(event: MouseEvent): void;
|
|
19
18
|
itemMousedown(event: MouseEvent, item: ToolbarItem): void;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Editor, NodeEntry,
|
|
2
|
-
export declare const anchorBlockEntry: (editor: Editor, at?:
|
|
1
|
+
import { Editor, NodeEntry, Location, Element } from 'slate';
|
|
2
|
+
export declare const anchorBlockEntry: (editor: Editor, at?: Location) => NodeEntry<Element> | undefined;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Editor, Element } from 'slate';
|
|
2
|
-
export declare const anchorBlock: (editor: Editor) => Element;
|
|
1
|
+
import { Editor, Element, Location } from 'slate';
|
|
2
|
+
export declare const anchorBlock: (editor: Editor, at?: Location) => Element;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Editor } from 'slate';
|
|
2
|
-
export declare const getBlockCardCenterCursor: (editor: Editor) => import("slate").BasePoint;
|
|
1
|
+
import { Editor, Location } from 'slate';
|
|
2
|
+
export declare const getBlockCardCenterCursor: (editor: Editor, at?: Location) => import("slate").BasePoint;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Editor } from 'slate';
|
|
2
|
-
export declare const isBlockCardCursor: (editor: Editor) => boolean;
|
|
1
|
+
import { Editor, Location } from 'slate';
|
|
2
|
+
export declare const isBlockCardCursor: (editor: Editor, at?: Location) => boolean;
|
package/styles/editor.scss
CHANGED
|
@@ -238,4 +238,11 @@
|
|
|
238
238
|
.thy-color-picker:not(.disabled):focus {
|
|
239
239
|
border: none !important;
|
|
240
240
|
}
|
|
241
|
+
.thy-default-picker-active {
|
|
242
|
+
background-color: rgba(variables.$primary, 0.1);
|
|
243
|
+
border-radius: 0.25rem;
|
|
244
|
+
.thy-icon {
|
|
245
|
+
color: variables.$primary;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
241
248
|
}
|
package/utils/index.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export * from './is-clean-empty-paragraph';
|
|
|
16
16
|
export * from './lodash';
|
|
17
17
|
export * from './merge-element-options';
|
|
18
18
|
export * from './refocus';
|
|
19
|
-
export * from './
|
|
19
|
+
export * from './scrolling';
|
|
20
20
|
export * from './update-popover-position';
|
|
21
21
|
export * from './weak-maps';
|
|
22
22
|
export * from './normalize';
|
|
@@ -4,3 +4,4 @@ import { Editor } from 'slate';
|
|
|
4
4
|
* container coincides with the viewport position of the focus element
|
|
5
5
|
*/
|
|
6
6
|
export declare const scrollIntoView: (editor: Editor, scrollContainer?: string) => void;
|
|
7
|
+
export declare const getEditorScrollContainer: (editor: Editor, scrollContainerSelector?: string) => HTMLElement;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { AngularEditor } from 'slate-angular';
|
|
2
|
-
import { DEFAULT_SCROLL_CONTAINER } from '../constants';
|
|
3
|
-
import { getEditableElementHeight } from './get-editable-element-height';
|
|
4
|
-
let previousHeight = 0;
|
|
5
|
-
/**
|
|
6
|
-
* reset the sliding distance when the viewport position of the sliding
|
|
7
|
-
* container coincides with the viewport position of the focus element
|
|
8
|
-
*/
|
|
9
|
-
export const scrollIntoView = (editor, scrollContainer) => {
|
|
10
|
-
const isFocused = AngularEditor.isFocused(editor);
|
|
11
|
-
const nativeSelection = window.getSelection();
|
|
12
|
-
if (!isFocused || !nativeSelection?.focusNode) {
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
// fix the page scrolling problem when the associated page card and text status switch in the table
|
|
16
|
-
// the native selection area is abnormal, and the cursor automatically jumps to the left cursor of the block-level element (browser native behavior when switching display)
|
|
17
|
-
// temporary solution: Determine whether the DOM corresponding to the Slate selection area is equal to the DOM corresponding to the browser selection. If they are not equal, it means an abnormal situation, and automatic scrolling will no longer be performed
|
|
18
|
-
const domRange = AngularEditor.toDOMRange(editor, editor.selection);
|
|
19
|
-
if (domRange.startContainer !== nativeSelection.anchorNode) {
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
const currentNodeElement = nativeSelection.focusNode.parentElement;
|
|
23
|
-
const scrollContainerElement = currentNodeElement.closest(scrollContainer ?? DEFAULT_SCROLL_CONTAINER);
|
|
24
|
-
if (!scrollContainerElement) {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
const scrollContainerRect = scrollContainerElement.getBoundingClientRect();
|
|
28
|
-
const focusBlockRect = currentNodeElement.getBoundingClientRect();
|
|
29
|
-
const scrollHeight = scrollContainer ? window.innerHeight : scrollContainerRect.bottom;
|
|
30
|
-
const currentHeight = getEditableElementHeight(editor);
|
|
31
|
-
const scrollOffset = scrollHeight - focusBlockRect.bottom;
|
|
32
|
-
if (currentHeight && scrollOffset < 30) {
|
|
33
|
-
// 16 为底部间隔,防止紧贴底部
|
|
34
|
-
scrollContainerElement.scrollTop = scrollContainerElement.scrollTop - scrollOffset + 16;
|
|
35
|
-
}
|
|
36
|
-
previousHeight = currentHeight;
|
|
37
|
-
};
|
|
38
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2Nyb2xsLWludG8tdmlldy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3BhY2thZ2VzL3NyYy91dGlscy9zY3JvbGwtaW50by12aWV3LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNBLE9BQU8sRUFBRSxhQUFhLEVBQUUsTUFBTSxlQUFlLENBQUM7QUFDOUMsT0FBTyxFQUFFLHdCQUF3QixFQUFFLE1BQU0sY0FBYyxDQUFDO0FBQ3hELE9BQU8sRUFBRSx3QkFBd0IsRUFBRSxNQUFNLCtCQUErQixDQUFDO0FBRXpFLElBQUksY0FBYyxHQUFHLENBQUMsQ0FBQztBQUV2Qjs7O0dBR0c7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