@worktile/theia 2.4.2 → 2.4.3
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/bundles/worktile-theia.umd.js +164 -122
- package/bundles/worktile-theia.umd.js.map +1 -1
- package/esm2015/editor.component.js +3 -2
- package/esm2015/interfaces/editor.js +1 -1
- package/esm2015/plugins/indent/indent.editor.js +11 -13
- package/esm2015/plugins/indent/indent.plugin.js +15 -2
- package/esm2015/plugins/indent/on-keydown-indent.js +3 -5
- package/esm2015/plugins/quick-insert/components/quick-insert.component.js +6 -2
- package/esm2015/plugins/quick-insert/components/quick-toolbar/quick-toolbar.component.js +14 -15
- package/esm2015/plugins/quick-insert/quick-insert.editor.js +17 -27
- package/esm2015/plugins/quick-insert/quick-insert.plugin.js +14 -13
- package/esm2015/transforms/index.js +3 -2
- package/esm2015/transforms/insert-element-next.js +1 -1
- package/esm2015/transforms/insert-element-node.js +36 -0
- package/fesm2015/worktile-theia.js +160 -118
- package/fesm2015/worktile-theia.js.map +1 -1
- package/interfaces/editor.d.ts +7 -0
- package/package.json +1 -1
- package/plugins/indent/indent.plugin.d.ts +1 -0
- package/plugins/indent/on-keydown-indent.d.ts +1 -1
- package/plugins/quick-insert/components/quick-toolbar/quick-toolbar.component.d.ts +3 -4
- package/plugins/quick-insert/quick-insert.editor.d.ts +3 -4
- package/transforms/index.d.ts +2 -1
- package/transforms/insert-element-node.d.ts +2 -0
|
@@ -54,7 +54,7 @@ import { ThySharedModule } from 'ngx-tethys/shared';
|
|
|
54
54
|
import * as i1$6 from 'ngx-tethys';
|
|
55
55
|
import { coerceCssPixelValue } from '@angular/cdk/coercion';
|
|
56
56
|
import { PortalInjector, ComponentPortal } from '@angular/cdk/portal';
|
|
57
|
-
import * as
|
|
57
|
+
import * as i1$7 from 'ngx-tethys/list';
|
|
58
58
|
import { ThyListModule } from 'ngx-tethys/list';
|
|
59
59
|
import { ThyAutocompleteModule } from 'ngx-tethys/autocomplete';
|
|
60
60
|
import { ThyAvatarModule } from 'ngx-tethys/avatar';
|
|
@@ -1589,6 +1589,40 @@ function handleContinualInsertBreak(editor, lowestBlock, type) {
|
|
|
1589
1589
|
return false;
|
|
1590
1590
|
}
|
|
1591
1591
|
|
|
1592
|
+
const insertElementNode = (editor, node) => {
|
|
1593
|
+
if (Range.isExpanded(editor.selection)) {
|
|
1594
|
+
Editor.deleteFragment(editor);
|
|
1595
|
+
}
|
|
1596
|
+
const isBlockCardCursor$1 = isBlockCardCursor(editor);
|
|
1597
|
+
const containerBlocks = getContainerBlocks(editor);
|
|
1598
|
+
const isContainer = isNodeTypeIn(editor, containerBlocks, { at: editor.selection });
|
|
1599
|
+
const [anchorBlock, anchorBlockPath] = anchorBlockEntry(editor);
|
|
1600
|
+
const isEmpty = Editor.isEmpty(editor, anchorBlock);
|
|
1601
|
+
if (isContainer && !isBlockCardCursor$1) {
|
|
1602
|
+
const [, containerPath] = Editor.above(editor, {
|
|
1603
|
+
match: n => Editor.isBlock(editor, n) && containerBlocks.includes(n.type),
|
|
1604
|
+
at: editor.selection
|
|
1605
|
+
});
|
|
1606
|
+
Editor.withoutNormalizing(editor, () => {
|
|
1607
|
+
const containerPathFirstPath = anchorBlockPath.slice(0, containerPath.length + 1);
|
|
1608
|
+
Transforms.insertNodes(editor, node, { at: Path.next(containerPathFirstPath), select: true });
|
|
1609
|
+
if (isEmpty) {
|
|
1610
|
+
Transforms.removeNodes(editor, { at: anchorBlockPath });
|
|
1611
|
+
}
|
|
1612
|
+
});
|
|
1613
|
+
return;
|
|
1614
|
+
}
|
|
1615
|
+
const nextPath = Path.next([anchorBlockPath[0]]);
|
|
1616
|
+
Transforms.insertNodes(editor, node, { at: nextPath });
|
|
1617
|
+
if (isEmpty && anchorBlockPath.length === 1) {
|
|
1618
|
+
Transforms.delete(editor, { at: anchorBlockPath });
|
|
1619
|
+
Transforms.select(editor, Editor.start(editor, anchorBlockPath));
|
|
1620
|
+
}
|
|
1621
|
+
else {
|
|
1622
|
+
Transforms.select(editor, Editor.start(editor, nextPath));
|
|
1623
|
+
}
|
|
1624
|
+
};
|
|
1625
|
+
|
|
1592
1626
|
var index = /*#__PURE__*/Object.freeze({
|
|
1593
1627
|
__proto__: null,
|
|
1594
1628
|
setMarks: setMarks,
|
|
@@ -1608,7 +1642,8 @@ var index = /*#__PURE__*/Object.freeze({
|
|
|
1608
1642
|
setEndSelection: setEndSelection,
|
|
1609
1643
|
closeConversionHint: closeConversionHint,
|
|
1610
1644
|
handleContinualDeleteBackward: handleContinualDeleteBackward,
|
|
1611
|
-
handleContinualInsertBreak: handleContinualInsertBreak
|
|
1645
|
+
handleContinualInsertBreak: handleContinualInsertBreak,
|
|
1646
|
+
insertElementNode: insertElementNode
|
|
1612
1647
|
});
|
|
1613
1648
|
|
|
1614
1649
|
class TheConversionHintComponent {
|
|
@@ -11268,26 +11303,26 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImpo
|
|
|
11268
11303
|
}] } });
|
|
11269
11304
|
|
|
11270
11305
|
class TheQuickToolbarComponent extends mixinUnsubscribe(MixinBase) {
|
|
11271
|
-
constructor(
|
|
11306
|
+
constructor(elementRef, cdr) {
|
|
11272
11307
|
super();
|
|
11273
|
-
this.popoverRef = popoverRef;
|
|
11274
11308
|
this.elementRef = elementRef;
|
|
11309
|
+
this.cdr = cdr;
|
|
11275
11310
|
this.ToolbarItemMode = ToolbarItemMode;
|
|
11276
11311
|
this.ToolbarActionTypes = ToolbarActionTypes;
|
|
11277
11312
|
}
|
|
11278
11313
|
handleMouseDown(event) {
|
|
11279
11314
|
if (!this.elementRef.nativeElement.contains(event.target)) {
|
|
11280
|
-
QuickInsertEditor.
|
|
11315
|
+
QuickInsertEditor.closeQuickInsertToolbar(this.editor);
|
|
11281
11316
|
}
|
|
11282
11317
|
else {
|
|
11283
11318
|
event.preventDefault();
|
|
11284
11319
|
}
|
|
11285
11320
|
}
|
|
11286
11321
|
handleEnter() {
|
|
11287
|
-
QuickInsertEditor.
|
|
11322
|
+
QuickInsertEditor.closeQuickInsertToolbar(this.editor);
|
|
11288
11323
|
}
|
|
11289
11324
|
handleEsc() {
|
|
11290
|
-
QuickInsertEditor.
|
|
11325
|
+
QuickInsertEditor.closeQuickInsertToolbar(this.editor);
|
|
11291
11326
|
}
|
|
11292
11327
|
ngOnInit() {
|
|
11293
11328
|
this.editorElement = AngularEditor.toDOMNode(this.editor, this.editor);
|
|
@@ -11312,15 +11347,15 @@ class TheQuickToolbarComponent extends mixinUnsubscribe(MixinBase) {
|
|
|
11312
11347
|
super.ngOnDestroy();
|
|
11313
11348
|
}
|
|
11314
11349
|
}
|
|
11315
|
-
TheQuickToolbarComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TheQuickToolbarComponent, deps: [{ token:
|
|
11316
|
-
TheQuickToolbarComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.15", type: TheQuickToolbarComponent, selector: "the-quick-toolbar", inputs: { editor: "editor", quickToolbarItems: "quickToolbarItems" }, host: { listeners: { "document: mousedown": "handleMouseDown($event)", "document: keydown.enter": "handleEnter()", "document: keydown.escape": "handleEsc()" } }, usesInheritance: true, ngImport: i0, template: "<thy-selection-list\n class=\"the-quick-toolbar\"\n [thyBindKeyEventContainer]=\"editorElement\"\n (thySelectionChange)=\"selectionChange($event)\"\n [thyMultiple]=\"false\"\n>\n <ng-container *ngFor=\"let item of quickToolbarItems\">\n <ng-container *ngIf=\"item.key !== ToolbarActionTypes.split; else splitLine\">\n <thy-list-option [thyValue]=\"item?.key\" (mousedown)=\"stopPropagation($event)\">\n <the-toolbar-item [editor]=\"editor\" [item]=\"item\" [itemMode]=\"ToolbarItemMode.vertical\"></the-toolbar-item>\n </thy-list-option>\n </ng-container>\n </ng-container>\n</thy-selection-list>\n\n<ng-template #splitLine>\n <nav-split-line [mode]=\"ToolbarItemMode.horizontal\"></nav-split-line>\n</ng-template>\n", components: [{ type:
|
|
11350
|
+
TheQuickToolbarComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TheQuickToolbarComponent, deps: [{ token: i0.ElementRef }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
11351
|
+
TheQuickToolbarComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.15", type: TheQuickToolbarComponent, selector: "the-quick-toolbar", inputs: { editor: "editor", quickToolbarItems: "quickToolbarItems" }, host: { listeners: { "document: mousedown": "handleMouseDown($event)", "document: keydown.enter": "handleEnter()", "document: keydown.escape": "handleEsc()" } }, usesInheritance: true, ngImport: i0, template: "<thy-selection-list\n class=\"the-quick-toolbar\"\n [thyBindKeyEventContainer]=\"editorElement\"\n (thySelectionChange)=\"selectionChange($event)\"\n [thyMultiple]=\"false\"\n>\n <ng-container *ngFor=\"let item of quickToolbarItems\">\n <ng-container *ngIf=\"item.key !== ToolbarActionTypes.split; else splitLine\">\n <thy-list-option [thyValue]=\"item?.key\" (mousedown)=\"stopPropagation($event)\">\n <the-toolbar-item [editor]=\"editor\" [item]=\"item\" [itemMode]=\"ToolbarItemMode.vertical\"></the-toolbar-item>\n </thy-list-option>\n </ng-container>\n </ng-container>\n</thy-selection-list>\n\n<ng-template #splitLine>\n <nav-split-line [mode]=\"ToolbarItemMode.horizontal\"></nav-split-line>\n</ng-template>\n", components: [{ type: i1$7.ThySelectionListComponent, selector: "thy-selection-list,[thy-selection-list]", inputs: ["thyMultiple", "thyBindKeyEventContainer", "thyScrollContainer", "thyBeforeKeydown", "thyUniqueKey", "thyCompareWith", "thyLayout", "thyAutoActiveFirstItem", "thySize", "thySpaceKeyEnabled"], outputs: ["thySelectionChange"] }, { type: i5$2.ThyListOptionComponent, selector: "thy-list-option,[thy-list-option]", inputs: ["id", "thyValue", "thyDisabled"] }, { type: TheToolbarItemComponent, selector: "the-toolbar-item", inputs: ["editor", "item", "itemMode"] }, { type: NavSplitLineComponent, selector: "nav-split-line", inputs: ["mode"] }], directives: [{ type: i10.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i10.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
|
|
11317
11352
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TheQuickToolbarComponent, decorators: [{
|
|
11318
11353
|
type: Component,
|
|
11319
11354
|
args: [{
|
|
11320
11355
|
selector: 'the-quick-toolbar',
|
|
11321
11356
|
templateUrl: 'quick-toolbar.component.html'
|
|
11322
11357
|
}]
|
|
11323
|
-
}], ctorParameters: function () { return [{ type:
|
|
11358
|
+
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { editor: [{
|
|
11324
11359
|
type: Input
|
|
11325
11360
|
}], quickToolbarItems: [{
|
|
11326
11361
|
type: Input
|
|
@@ -11335,16 +11370,22 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImpo
|
|
|
11335
11370
|
args: ['document: keydown.escape']
|
|
11336
11371
|
}] } });
|
|
11337
11372
|
|
|
11338
|
-
const OperationTypes = ['insert_text', 'remove_node', 'merge_node'];
|
|
11339
11373
|
const QuickInsertEditor = {
|
|
11340
|
-
|
|
11374
|
+
openQuickInsertToolbar(editor, quickToolbarItems, origin) {
|
|
11375
|
+
if (QuickInsertEditor.isOpenedToolbar(editor)) {
|
|
11376
|
+
return;
|
|
11377
|
+
}
|
|
11378
|
+
if (!origin) {
|
|
11379
|
+
const rootNode = AngularEditor.toDOMNode(editor, Node.ancestor(editor, [editor.selection.anchor.path[0]]));
|
|
11380
|
+
origin = rootNode.querySelector('[data-slate-leaf="true"]');
|
|
11381
|
+
}
|
|
11341
11382
|
const overlay = editor.injector.get(Overlay);
|
|
11342
11383
|
const viewContainerRef = editor.injector.get(ViewContainerRef);
|
|
11343
11384
|
const thyPopover = editor.injector.get(ThyPopover);
|
|
11344
11385
|
const quickToolbarRef = thyPopover.open(TheQuickToolbarComponent, {
|
|
11345
11386
|
initialState: {
|
|
11346
11387
|
editor,
|
|
11347
|
-
quickToolbarItems
|
|
11388
|
+
quickToolbarItems
|
|
11348
11389
|
},
|
|
11349
11390
|
origin,
|
|
11350
11391
|
viewContainerRef: viewContainerRef,
|
|
@@ -11357,52 +11398,34 @@ const QuickInsertEditor = {
|
|
|
11357
11398
|
scrollStrategy: overlay.scrollStrategies.reposition(),
|
|
11358
11399
|
manualClosure: true
|
|
11359
11400
|
});
|
|
11401
|
+
quickToolbarRef.componentInstance.cdr.markForCheck();
|
|
11360
11402
|
THE_EDITOR_QUICK_TOOLBAR_REF.set(editor, quickToolbarRef);
|
|
11361
11403
|
},
|
|
11362
|
-
|
|
11404
|
+
closeQuickInsertToolbar(editor) {
|
|
11363
11405
|
const quickToolbarRef = THE_EDITOR_QUICK_TOOLBAR_REF.get(editor);
|
|
11364
11406
|
if (quickToolbarRef) {
|
|
11365
11407
|
quickToolbarRef.close();
|
|
11366
11408
|
THE_EDITOR_QUICK_TOOLBAR_REF.set(editor, null);
|
|
11367
11409
|
}
|
|
11368
11410
|
},
|
|
11369
|
-
|
|
11370
|
-
const
|
|
11371
|
-
|
|
11372
|
-
return false;
|
|
11373
|
-
}
|
|
11374
|
-
const block = Node.ancestor(editor, [editor.selection.anchor.path[0]]);
|
|
11375
|
-
const { undos } = editor.history;
|
|
11376
|
-
const lastBatch = undos[undos.length - 1];
|
|
11377
|
-
const lastOp = lastBatch && lastBatch[lastBatch.length - 1];
|
|
11378
|
-
if (lastOp &&
|
|
11379
|
-
block.children.length === 1 &&
|
|
11380
|
-
block.type === ElementKinds.paragraph &&
|
|
11381
|
-
Node.string(block) === QUICK_TOOLBAR_HOTKEY &&
|
|
11382
|
-
opTypes.includes(lastOp.type) &&
|
|
11383
|
-
(lastOp.text === QUICK_TOOLBAR_HOTKEY || lastOp.text === undefined)) {
|
|
11384
|
-
return true;
|
|
11385
|
-
}
|
|
11386
|
-
return false;
|
|
11411
|
+
isOpenedToolbar(editor) {
|
|
11412
|
+
const quickToolbarRef = THE_EDITOR_QUICK_TOOLBAR_REF.get(editor);
|
|
11413
|
+
return !!quickToolbarRef;
|
|
11387
11414
|
}
|
|
11388
11415
|
};
|
|
11389
11416
|
|
|
11390
11417
|
const withQuickInsert = (editor) => {
|
|
11391
11418
|
const { onKeydown, deleteBackward, onChange } = editor;
|
|
11419
|
+
let presseingQuickInsertHotkey = false;
|
|
11392
11420
|
editor.onKeydown = (event) => {
|
|
11393
11421
|
if (event.key === QUICK_TOOLBAR_HOTKEY && isCleanEmptyParagraph(editor)) {
|
|
11394
|
-
|
|
11395
|
-
const theEditorComponent = editor.injector.get(TheEditorComponent);
|
|
11396
|
-
const quickToolbars = theEditorComponent.quickToolbarItems;
|
|
11397
|
-
const leafElement = rootNode.querySelector('[data-slate-leaf="true"]');
|
|
11398
|
-
const origin = leafElement || rootNode;
|
|
11399
|
-
QuickInsertEditor.openQuickToolbar(editor, quickToolbars, origin);
|
|
11422
|
+
presseingQuickInsertHotkey = true;
|
|
11400
11423
|
}
|
|
11401
11424
|
onKeydown(event);
|
|
11402
11425
|
};
|
|
11403
11426
|
editor.deleteBackward = unit => {
|
|
11404
|
-
if (
|
|
11405
|
-
QuickInsertEditor.
|
|
11427
|
+
if (QuickInsertEditor.isOpenedToolbar(editor)) {
|
|
11428
|
+
QuickInsertEditor.closeQuickInsertToolbar(editor);
|
|
11406
11429
|
}
|
|
11407
11430
|
deleteBackward(unit);
|
|
11408
11431
|
};
|
|
@@ -11410,11 +11433,17 @@ const withQuickInsert = (editor) => {
|
|
|
11410
11433
|
var _a;
|
|
11411
11434
|
onChange();
|
|
11412
11435
|
if (editor.selection) {
|
|
11436
|
+
const block = Node.get(editor, [editor.selection.anchor.path[0]]);
|
|
11437
|
+
// quick insert plus
|
|
11413
11438
|
const editorComponent = editor.injector.get(TheEditorComponent);
|
|
11414
11439
|
(_a = editorComponent.quickInsertInstance) === null || _a === void 0 ? void 0 : _a.checkStatus();
|
|
11415
|
-
|
|
11416
|
-
|
|
11417
|
-
|
|
11440
|
+
if (presseingQuickInsertHotkey && Node.string(block) === QUICK_TOOLBAR_HOTKEY) {
|
|
11441
|
+
QuickInsertEditor.openQuickInsertToolbar(editor, editorComponent.quickToolbarItems);
|
|
11442
|
+
presseingQuickInsertHotkey = false;
|
|
11443
|
+
return;
|
|
11444
|
+
}
|
|
11445
|
+
if (QuickInsertEditor.isOpenedToolbar(editor) && !isCleanEmptyParagraph(editor) && Node.string(block) !== QUICK_TOOLBAR_HOTKEY) {
|
|
11446
|
+
QuickInsertEditor.closeQuickInsertToolbar(editor);
|
|
11418
11447
|
}
|
|
11419
11448
|
}
|
|
11420
11449
|
};
|
|
@@ -11709,6 +11738,78 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImpo
|
|
|
11709
11738
|
args: ['class.disabled']
|
|
11710
11739
|
}] } });
|
|
11711
11740
|
|
|
11741
|
+
const onKeydownTextIndent = (editor, event, kinds, textIndentDisabled) => {
|
|
11742
|
+
const { selection } = editor;
|
|
11743
|
+
const isExpanded = Range.isExpanded(selection);
|
|
11744
|
+
const nodes = Array.from(Editor.nodes(editor, {
|
|
11745
|
+
mode: 'highest',
|
|
11746
|
+
match: node => Element$1.isElement(node) && kinds.includes(node.type)
|
|
11747
|
+
}));
|
|
11748
|
+
const [startBlock] = nodes;
|
|
11749
|
+
if (!startBlock) {
|
|
11750
|
+
return false;
|
|
11751
|
+
}
|
|
11752
|
+
const [block, path] = startBlock;
|
|
11753
|
+
const isStart = Editor.isStart(editor, selection.anchor, path);
|
|
11754
|
+
if (isKeyHotkey('Tab', event)) {
|
|
11755
|
+
event.preventDefault();
|
|
11756
|
+
if (startBlock && (isExpanded || isStart)) {
|
|
11757
|
+
if (!editor.isVoid(block)) {
|
|
11758
|
+
let { textIndent, type } = block;
|
|
11759
|
+
// do not apply first-line indentation for lists
|
|
11760
|
+
if (!textIndent && !textIndentDisabled.includes(type)) {
|
|
11761
|
+
IndentEditor.setTextIndent(editor, kinds, 2);
|
|
11762
|
+
return true;
|
|
11763
|
+
}
|
|
11764
|
+
else {
|
|
11765
|
+
IndentEditor.setIndent(editor);
|
|
11766
|
+
return true;
|
|
11767
|
+
}
|
|
11768
|
+
}
|
|
11769
|
+
}
|
|
11770
|
+
else {
|
|
11771
|
+
editor.insertText(TAB_SPACE);
|
|
11772
|
+
return true;
|
|
11773
|
+
}
|
|
11774
|
+
}
|
|
11775
|
+
if (isKeyHotkey('shift+Tab', event)) {
|
|
11776
|
+
if (startBlock && (isExpanded || isStart)) {
|
|
11777
|
+
if (!editor.isVoid(block)) {
|
|
11778
|
+
return IndentEditor.cancelTextIntent(editor, event, block, kinds);
|
|
11779
|
+
}
|
|
11780
|
+
}
|
|
11781
|
+
}
|
|
11782
|
+
if (selection && Range.isCollapsed(selection) && hotkeys.isDeleteBackward(event)) {
|
|
11783
|
+
if (startBlock && isStart) {
|
|
11784
|
+
return IndentEditor.cancelTextIntent(editor, event, block, kinds);
|
|
11785
|
+
}
|
|
11786
|
+
}
|
|
11787
|
+
return false;
|
|
11788
|
+
};
|
|
11789
|
+
|
|
11790
|
+
const withIndent = (kinds) => (editor) => {
|
|
11791
|
+
const { onKeydown } = editor;
|
|
11792
|
+
editor.onKeydown = (event) => {
|
|
11793
|
+
var _a, _b, _c, _d;
|
|
11794
|
+
let indentTypes = kinds;
|
|
11795
|
+
let disableIndentTypes = [ElementKinds.bulletedList, ElementKinds.numberedList, ElementKinds.checkItem];
|
|
11796
|
+
if ((_b = (_a = editor.extraIndentOptions) === null || _a === void 0 ? void 0 : _a.indentTypes) === null || _b === void 0 ? void 0 : _b.length) {
|
|
11797
|
+
indentTypes = mergIndentTypes(kinds, editor.extraIndentOptions.indentTypes);
|
|
11798
|
+
}
|
|
11799
|
+
if ((_d = (_c = editor.extraIndentOptions) === null || _c === void 0 ? void 0 : _c.disabledIndentTypes) === null || _d === void 0 ? void 0 : _d.length) {
|
|
11800
|
+
disableIndentTypes = mergIndentTypes(disableIndentTypes, editor.extraIndentOptions.disabledIndentTypes);
|
|
11801
|
+
}
|
|
11802
|
+
const isContinue = !onKeydownTextIndent(editor, event, indentTypes, disableIndentTypes);
|
|
11803
|
+
if (isContinue) {
|
|
11804
|
+
onKeydown(event);
|
|
11805
|
+
}
|
|
11806
|
+
};
|
|
11807
|
+
return editor;
|
|
11808
|
+
};
|
|
11809
|
+
const mergIndentTypes = (defaultTypes, indentTypes) => {
|
|
11810
|
+
return Array.from(new Set([...defaultTypes, ...indentTypes]));
|
|
11811
|
+
};
|
|
11812
|
+
|
|
11712
11813
|
const MaxIndent = 11;
|
|
11713
11814
|
const includesIndentTypes = [
|
|
11714
11815
|
ElementKinds.checkItem,
|
|
@@ -11717,11 +11818,15 @@ const includesIndentTypes = [
|
|
|
11717
11818
|
ElementKinds.paragraph,
|
|
11718
11819
|
...HEADING_TYPES
|
|
11719
11820
|
];
|
|
11821
|
+
const getIndentTypes = editor => {
|
|
11822
|
+
let indentTypes = editor.extraIndentOptions ? editor.extraIndentOptions.indentTypes : [];
|
|
11823
|
+
return mergIndentTypes(includesIndentTypes, indentTypes);
|
|
11824
|
+
};
|
|
11720
11825
|
const IndentEditor = {
|
|
11721
11826
|
setIndent(editor) {
|
|
11722
11827
|
const nodes = Array.from(Editor.nodes(editor, {
|
|
11723
11828
|
mode: 'highest',
|
|
11724
|
-
match: n => Element$1.isElement(n) &&
|
|
11829
|
+
match: n => Element$1.isElement(n) && getIndentTypes(editor).includes(n.type)
|
|
11725
11830
|
}));
|
|
11726
11831
|
const [startBlock] = nodes;
|
|
11727
11832
|
if (startBlock) {
|
|
@@ -11731,7 +11836,7 @@ const IndentEditor = {
|
|
|
11731
11836
|
if (indent <= MaxIndent) {
|
|
11732
11837
|
Transforms.setNodes(editor, { indent }, {
|
|
11733
11838
|
mode: 'highest',
|
|
11734
|
-
match: n => Element$1.isElement(n) &&
|
|
11839
|
+
match: n => Element$1.isElement(n) && getIndentTypes(editor).includes(n.type)
|
|
11735
11840
|
});
|
|
11736
11841
|
}
|
|
11737
11842
|
}
|
|
@@ -11739,7 +11844,7 @@ const IndentEditor = {
|
|
|
11739
11844
|
cancelIndent(editor) {
|
|
11740
11845
|
const nodes = Array.from(Editor.nodes(editor, {
|
|
11741
11846
|
mode: 'highest',
|
|
11742
|
-
match: n => Element$1.isElement(n) &&
|
|
11847
|
+
match: n => Element$1.isElement(n) && getIndentTypes(editor).includes(n.type)
|
|
11743
11848
|
}));
|
|
11744
11849
|
const [startBlock] = nodes;
|
|
11745
11850
|
if (startBlock) {
|
|
@@ -11747,7 +11852,7 @@ const IndentEditor = {
|
|
|
11747
11852
|
indent = indent === 1 ? null : (indent -= 1);
|
|
11748
11853
|
Transforms.setNodes(editor, { indent }, {
|
|
11749
11854
|
mode: 'highest',
|
|
11750
|
-
match: n => Element$1.isElement(n) &&
|
|
11855
|
+
match: n => Element$1.isElement(n) && getIndentTypes(editor).includes(n.type)
|
|
11751
11856
|
});
|
|
11752
11857
|
}
|
|
11753
11858
|
},
|
|
@@ -11779,15 +11884,8 @@ const IndentEditor = {
|
|
|
11779
11884
|
},
|
|
11780
11885
|
isDisabled(editor) {
|
|
11781
11886
|
if (editor.selection) {
|
|
11782
|
-
const allowGroup = [
|
|
11783
|
-
ElementKinds.paragraph,
|
|
11784
|
-
ElementKinds.numberedList,
|
|
11785
|
-
ElementKinds.bulletedList,
|
|
11786
|
-
ElementKinds.checkItem,
|
|
11787
|
-
...HEADING_TYPES
|
|
11788
|
-
];
|
|
11789
11887
|
const anchorBlock$1 = anchorBlock(editor);
|
|
11790
|
-
return anchorBlock$1 && !
|
|
11888
|
+
return anchorBlock$1 && !getIndentTypes(editor).includes(anchorBlock$1 === null || anchorBlock$1 === void 0 ? void 0 : anchorBlock$1.type);
|
|
11791
11889
|
}
|
|
11792
11890
|
return false;
|
|
11793
11891
|
}
|
|
@@ -11817,67 +11915,6 @@ const IndentOptions = [
|
|
|
11817
11915
|
}
|
|
11818
11916
|
];
|
|
11819
11917
|
|
|
11820
|
-
const onKeydownTextIndent = (editor, event, kinds) => {
|
|
11821
|
-
const { selection } = editor;
|
|
11822
|
-
const isExpanded = Range.isExpanded(selection);
|
|
11823
|
-
const nodes = Array.from(Editor.nodes(editor, {
|
|
11824
|
-
mode: 'highest',
|
|
11825
|
-
match: node => Element$1.isElement(node) && kinds.includes(node.type)
|
|
11826
|
-
}));
|
|
11827
|
-
const [startBlock] = nodes;
|
|
11828
|
-
if (!startBlock) {
|
|
11829
|
-
return false;
|
|
11830
|
-
}
|
|
11831
|
-
const [block, path] = startBlock;
|
|
11832
|
-
const isStart = Editor.isStart(editor, selection.anchor, path);
|
|
11833
|
-
const textIndentDisable = [ElementKinds.bulletedList, ElementKinds.numberedList, ElementKinds.checkItem];
|
|
11834
|
-
if (isKeyHotkey('Tab', event)) {
|
|
11835
|
-
event.preventDefault();
|
|
11836
|
-
if (startBlock && (isExpanded || isStart)) {
|
|
11837
|
-
if (!editor.isVoid(block)) {
|
|
11838
|
-
let { textIndent, type } = block;
|
|
11839
|
-
// do not apply first-line indentation for lists
|
|
11840
|
-
if (!textIndent && !textIndentDisable.includes(type)) {
|
|
11841
|
-
IndentEditor.setTextIndent(editor, kinds, 2);
|
|
11842
|
-
return true;
|
|
11843
|
-
}
|
|
11844
|
-
else {
|
|
11845
|
-
IndentEditor.setIndent(editor);
|
|
11846
|
-
return true;
|
|
11847
|
-
}
|
|
11848
|
-
}
|
|
11849
|
-
}
|
|
11850
|
-
else {
|
|
11851
|
-
editor.insertText(TAB_SPACE);
|
|
11852
|
-
return true;
|
|
11853
|
-
}
|
|
11854
|
-
}
|
|
11855
|
-
if (isKeyHotkey('shift+Tab', event)) {
|
|
11856
|
-
if (startBlock && (isExpanded || isStart)) {
|
|
11857
|
-
if (!editor.isVoid(block)) {
|
|
11858
|
-
return IndentEditor.cancelTextIntent(editor, event, block, kinds);
|
|
11859
|
-
}
|
|
11860
|
-
}
|
|
11861
|
-
}
|
|
11862
|
-
if (selection && Range.isCollapsed(selection) && hotkeys.isDeleteBackward(event)) {
|
|
11863
|
-
if (startBlock && isStart) {
|
|
11864
|
-
return IndentEditor.cancelTextIntent(editor, event, block, kinds);
|
|
11865
|
-
}
|
|
11866
|
-
}
|
|
11867
|
-
return false;
|
|
11868
|
-
};
|
|
11869
|
-
|
|
11870
|
-
const withIndent = (kinds) => (editor) => {
|
|
11871
|
-
const { onKeydown } = editor;
|
|
11872
|
-
editor.onKeydown = (event) => {
|
|
11873
|
-
const isContinue = !onKeydownTextIndent(editor, event, kinds);
|
|
11874
|
-
if (isContinue) {
|
|
11875
|
-
onKeydown(event);
|
|
11876
|
-
}
|
|
11877
|
-
};
|
|
11878
|
-
return editor;
|
|
11879
|
-
};
|
|
11880
|
-
|
|
11881
11918
|
const internalPlugins = [
|
|
11882
11919
|
withTheHistory,
|
|
11883
11920
|
withAutoInsertData(),
|
|
@@ -12500,7 +12537,11 @@ class TheQuickInsertComponent {
|
|
|
12500
12537
|
handleClick(event) {
|
|
12501
12538
|
event.stopPropagation();
|
|
12502
12539
|
event.preventDefault();
|
|
12503
|
-
QuickInsertEditor.
|
|
12540
|
+
if (QuickInsertEditor.isOpenedToolbar(this.editor)) {
|
|
12541
|
+
QuickInsertEditor.closeQuickInsertToolbar(this.editor);
|
|
12542
|
+
return;
|
|
12543
|
+
}
|
|
12544
|
+
QuickInsertEditor.openQuickInsertToolbar(this.editor, this.quickToolbarItems, this.iconElement.nativeElement);
|
|
12504
12545
|
}
|
|
12505
12546
|
}
|
|
12506
12547
|
TheQuickInsertComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TheQuickInsertComponent, deps: [{ token: i0.Renderer2 }, { token: i0.ElementRef }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
@@ -12773,12 +12814,13 @@ class TheEditorComponent extends mixinUnsubscribe(MixinBase) {
|
|
|
12773
12814
|
super.ngOnDestroy();
|
|
12774
12815
|
}
|
|
12775
12816
|
initialize() {
|
|
12776
|
-
var _a, _b, _c;
|
|
12817
|
+
var _a, _b, _c, _d;
|
|
12777
12818
|
this.editor = withTheEditor(this.thePlugins, withHistory(withAngular(createEditor(), CLIPBOARD_FORMAT_KEY)));
|
|
12778
12819
|
this.generateDecorate();
|
|
12779
12820
|
this.editor.disabled = (_a = this.theOptions) === null || _a === void 0 ? void 0 : _a.disabled;
|
|
12780
12821
|
this.editor.extraElementOptions = (_b = this.theOptions) === null || _b === void 0 ? void 0 : _b.extraElementOptions;
|
|
12781
12822
|
this.editor.extraAutoFormatRules = (_c = this.theOptions) === null || _c === void 0 ? void 0 : _c.extraAutoFormatRules;
|
|
12823
|
+
this.editor.extraIndentOptions = (_d = this.theOptions) === null || _d === void 0 ? void 0 : _d.extraIndentOptions;
|
|
12782
12824
|
setEditorUUID(this.editor, idCreator());
|
|
12783
12825
|
this.theContextService.initialize({
|
|
12784
12826
|
theOptions: this.theOptions,
|