@worktile/theia 2.1.12 → 2.2.1

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.
Files changed (45) hide show
  1. package/bundles/worktile-theia.umd.js +463 -233
  2. package/bundles/worktile-theia.umd.js.map +1 -1
  3. package/components/element/element.component.d.ts +1 -0
  4. package/constants/node-types.d.ts +6 -1
  5. package/custom-types.d.ts +1 -0
  6. package/editor.module.d.ts +44 -44
  7. package/esm2015/components/element/element.component.js +11 -4
  8. package/esm2015/components/text/text.component.js +2 -5
  9. package/esm2015/constants/node-types.js +7 -1
  10. package/esm2015/custom-types.js +1 -1
  11. package/esm2015/editor.component.js +1 -1
  12. package/esm2015/editor.module.js +6 -3
  13. package/esm2015/interfaces/editor.js +1 -1
  14. package/esm2015/plugins/common/block-card.plugin.js +2 -2
  15. package/esm2015/plugins/font-size/font-size.editor.js +2 -2
  16. package/esm2015/plugins/indent/indent.editor.js +81 -0
  17. package/esm2015/plugins/indent/indent.plugin.js +24 -3
  18. package/esm2015/plugins/indent/on-keydown-indent.js +40 -54
  19. package/esm2015/plugins/indent/options.js +26 -0
  20. package/esm2015/plugins/indent/toolbar-item.component.js +115 -0
  21. package/esm2015/plugins/index.js +5 -3
  22. package/esm2015/plugins/inline-code/inline-code.component.js +2 -2
  23. package/esm2015/plugins/list/components/bulleted-list.component.js +11 -14
  24. package/esm2015/plugins/list/components/numbered-list.component.js +12 -15
  25. package/esm2015/plugins/list/list.editor.js +8 -1
  26. package/esm2015/plugins/quick-insert/components/quick-toolbar/quick-toolbar.component.js +13 -6
  27. package/esm2015/plugins/todo-item/todo-item.component.js +8 -26
  28. package/esm2015/utils/is-clean-empty-paragraph.js +3 -1
  29. package/fesm2015/worktile-theia.js +441 -228
  30. package/fesm2015/worktile-theia.js.map +1 -1
  31. package/interfaces/editor.d.ts +1 -1
  32. package/package.json +1 -1
  33. package/plugins/indent/indent.editor.d.ts +10 -0
  34. package/plugins/indent/indent.plugin.d.ts +2 -1
  35. package/plugins/indent/on-keydown-indent.d.ts +1 -1
  36. package/plugins/indent/options.d.ts +2 -0
  37. package/plugins/indent/toolbar-item.component.d.ts +36 -0
  38. package/plugins/inline-code/inline-code.component.scss +2 -1
  39. package/plugins/list/components/bulleted-list.component.d.ts +2 -4
  40. package/plugins/list/components/numbered-list.component.d.ts +2 -4
  41. package/plugins/quick-insert/components/quick-toolbar/quick-toolbar.component.d.ts +1 -0
  42. package/plugins/todo-item/todo-item.component.d.ts +2 -3
  43. package/plugins/todo-item/todo-item.component.scss +0 -3
  44. package/styles/editor.scss +27 -0
  45. package/styles/typo.scss +0 -5
@@ -1,5 +1,5 @@
1
1
  import * as i0 from '@angular/core';
2
- import { InjectionToken, Component, ChangeDetectionStrategy, Input, HostListener, ViewContainerRef, ChangeDetectorRef, Injectable, Inject, ViewChild, Pipe, HostBinding, Directive, ElementRef, TemplateRef, EventEmitter, forwardRef, Output, NgModule } from '@angular/core';
2
+ import { InjectionToken, Component, ChangeDetectionStrategy, HostBinding, Input, HostListener, ViewContainerRef, ChangeDetectorRef, Injectable, Inject, ViewChild, Directive, ElementRef, TemplateRef, Pipe, EventEmitter, forwardRef, Output, NgModule } from '@angular/core';
3
3
  import * as i6 from '@angular/common';
4
4
  import { DOCUMENT, CommonModule } from '@angular/common';
5
5
  import * as i4$2 from '@angular/forms';
@@ -100,6 +100,7 @@ var ElementKinds;
100
100
  ElementKinds["link"] = "link";
101
101
  ElementKinds["default"] = "paragraph";
102
102
  ElementKinds["inlineCode"] = "inline-code";
103
+ ElementKinds["indent"] = "indent";
103
104
  })(ElementKinds || (ElementKinds = {}));
104
105
  var Alignment;
105
106
  (function (Alignment) {
@@ -141,6 +142,11 @@ const FontSizeTypes = [
141
142
  FontSizes.fontSize40,
142
143
  FontSizes.fontSize48
143
144
  ];
145
+ var Indents;
146
+ (function (Indents) {
147
+ Indents["indentRight"] = "indent-right";
148
+ Indents["indentLeft"] = "indent-left";
149
+ })(Indents || (Indents = {}));
144
150
  var MarkTypes;
145
151
  (function (MarkTypes) {
146
152
  MarkTypes["bold"] = "bold";
@@ -374,10 +380,7 @@ class TheTextComponent extends BaseTextComponent {
374
380
  }
375
381
  }
376
382
  const fontSize = this.text[MarkTypes.fontSize];
377
- if (fontSize) {
378
- const attr = `the-${MarkTypes.fontSize}`;
379
- this.renderer2.setAttribute(this.elementRef.nativeElement, attr, fontSize);
380
- }
383
+ this.renderer2.setAttribute(this.elementRef.nativeElement, `the-${MarkTypes.fontSize}`, fontSize ? fontSize : null);
381
384
  if (this.text[MarkTypes.color]) {
382
385
  this.renderer2.setStyle(this.elementRef.nativeElement, 'color', this.text[MarkTypes.color]);
383
386
  }
@@ -428,9 +431,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImpo
428
431
  }] });
429
432
 
430
433
  class TheDefaultElementComponent extends TheBaseElementComponent {
434
+ get indent() {
435
+ var _a;
436
+ return (_a = this.element) === null || _a === void 0 ? void 0 : _a.indent;
437
+ }
431
438
  }
432
439
  TheDefaultElementComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TheDefaultElementComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
433
- TheDefaultElementComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.15", type: TheDefaultElementComponent, selector: "[theDefaultElement]", usesInheritance: true, ngImport: i0, template: '<slate-children [children]="children" [context]="childrenContext" [viewContext]="viewContext"></slate-children>', isInline: true, components: [{ type: i1.SlateChildrenComponent, selector: "slate-children", inputs: ["children", "context", "viewContext"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
440
+ TheDefaultElementComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.15", type: TheDefaultElementComponent, selector: "[theDefaultElement]", host: { properties: { "attr.the-indent": "this.indent" } }, usesInheritance: true, ngImport: i0, template: '<slate-children [children]="children" [context]="childrenContext" [viewContext]="viewContext"></slate-children>', isInline: true, components: [{ type: i1.SlateChildrenComponent, selector: "slate-children", inputs: ["children", "context", "viewContext"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
434
441
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TheDefaultElementComponent, decorators: [{
435
442
  type: Component,
436
443
  args: [{
@@ -438,7 +445,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImpo
438
445
  template: '<slate-children [children]="children" [context]="childrenContext" [viewContext]="viewContext"></slate-children>',
439
446
  changeDetection: ChangeDetectionStrategy.OnPush
440
447
  }]
441
- }] });
448
+ }], propDecorators: { indent: [{
449
+ type: HostBinding,
450
+ args: ['attr.the-indent']
451
+ }] } });
442
452
 
443
453
  const TheEditor = Object.assign({}, AngularEditor);
444
454
  var TheDataMode;
@@ -1671,6 +1681,13 @@ const ListEditor = {
1671
1681
  Transforms.setNodes(editor, { type: ElementKinds.paragraph, checked: undefined }, // todo remove checked
1672
1682
  { at: path });
1673
1683
  }
1684
+ else if (Element$1.isElement(node) && node.type === ElementKinds.paragraph) {
1685
+ let { textIndent } = node;
1686
+ if (textIndent) {
1687
+ Transforms.setNodes(editor, { textIndent: undefined }, // remove textIndent
1688
+ { at: path });
1689
+ }
1690
+ }
1674
1691
  if (Node.parent(editor, path).type !== ElementKinds.listItem) {
1675
1692
  Transforms.wrapNodes(editor, { type: ElementKinds.listItem, children: [] }, {
1676
1693
  at: path,
@@ -2064,12 +2081,14 @@ const isCleanEmptyParagraph = (editor) => {
2064
2081
  const align = 'align';
2065
2082
  const hasTextIndent = block[textIndent];
2066
2083
  const hasAlign = block[align];
2084
+ const hasIndent = block[ElementKinds.indent];
2067
2085
  if (Node.string(block) === '' &&
2068
2086
  Element$1.isElement(block) &&
2069
2087
  block.type === ElementKinds.paragraph &&
2070
2088
  block.children.length === 1 &&
2071
2089
  Text.isText(block.children[0]) &&
2072
2090
  !Editor.isVoid(editor, block) &&
2091
+ !hasIndent &&
2073
2092
  !hasTextIndent &&
2074
2093
  !hasAlign) {
2075
2094
  return true;
@@ -2671,86 +2690,6 @@ const withImage = (editor) => {
2671
2690
  return editor;
2672
2691
  };
2673
2692
 
2674
- const onKeydownIndent = (editor, event, kinds) => {
2675
- const { selection } = editor;
2676
- if (event.key === 'Tab') {
2677
- event.preventDefault();
2678
- const isExpanded = Range.isExpanded(selection);
2679
- const nodes = Array.from(Editor.nodes(editor, {
2680
- mode: 'highest',
2681
- match: indentNodeMatch(kinds)
2682
- }));
2683
- const startBlock = nodes[0];
2684
- if (startBlock && (isExpanded || Editor.isStart(editor, selection.anchor, [startBlock[1][0]]))) {
2685
- if (!editor.isVoid(startBlock[0])) {
2686
- if (event.shiftKey) {
2687
- return cancelTextIntent(editor, startBlock[0], kinds);
2688
- }
2689
- let { textIndent } = startBlock[0];
2690
- textIndent = textIndent ? textIndent : 0;
2691
- textIndent += 2;
2692
- if (textIndent < 50) {
2693
- Transforms.setNodes(editor, { textIndent }, {
2694
- mode: 'highest',
2695
- match: indentNodeMatch(kinds)
2696
- });
2697
- return true;
2698
- }
2699
- }
2700
- }
2701
- else {
2702
- editor.insertText(TAB_SPACE);
2703
- return true;
2704
- }
2705
- }
2706
- if (selection && Range.isCollapsed(selection) && event.key === 'Backspace') {
2707
- const nodes = Array.from(Editor.nodes(editor, {
2708
- mode: 'highest',
2709
- match: indentNodeMatch(kinds)
2710
- }));
2711
- const startBlock = nodes[0];
2712
- if (startBlock && Editor.isStart(editor, selection.anchor, [startBlock[1][0]])) {
2713
- return cancelTextIntent(editor, startBlock[0], kinds);
2714
- }
2715
- }
2716
- return false;
2717
- };
2718
- const indentNodeMatch = (kinds) => node => Element$1.isElement(node) && kinds.includes(node.type);
2719
- function cancelTextIntent(editor, anchorBlock, kinds) {
2720
- let { textIndent } = anchorBlock;
2721
- if (textIndent > 2) {
2722
- // prevent deleteBackward function
2723
- event.preventDefault();
2724
- textIndent -= 2;
2725
- Transforms.setNodes(editor, { textIndent }, {
2726
- mode: 'highest',
2727
- match: indentNodeMatch(kinds)
2728
- });
2729
- return true;
2730
- }
2731
- if (textIndent === 2) {
2732
- // prevent deleteBackward function
2733
- event.preventDefault();
2734
- Transforms.setNodes(editor, { textIndent: null }, {
2735
- mode: 'highest',
2736
- match: node => Element$1.isElement(node) && kinds.includes(node.type)
2737
- });
2738
- return true;
2739
- }
2740
- return false;
2741
- }
2742
-
2743
- const withIndent = (kinds) => (editor) => {
2744
- const { onKeydown } = editor;
2745
- editor.onKeydown = (event) => {
2746
- const isContinue = !onKeydownIndent(editor, event, kinds);
2747
- if (isContinue) {
2748
- onKeydown(event);
2749
- }
2750
- };
2751
- return editor;
2752
- };
2753
-
2754
2693
  const isList = (n) => {
2755
2694
  return [...LIST_BLOCK_TYPES].includes(n.type);
2756
2695
  };
@@ -3310,57 +3249,18 @@ function onKeyDownList(e, editor) {
3310
3249
  }
3311
3250
  }
3312
3251
 
3313
- class ElementStylePipe {
3314
- transform(element, align) {
3315
- const style = {};
3316
- if (element.align || align) {
3317
- style.textAlign = element.align || align || Alignment.left;
3318
- }
3319
- if (element.textIndent) {
3320
- style.textIndent = element.textIndent + 'em';
3321
- }
3322
- return style;
3323
- }
3324
- }
3325
- ElementStylePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ElementStylePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
3326
- ElementStylePipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ElementStylePipe, name: "elementStyle" });
3327
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ElementStylePipe, decorators: [{
3328
- type: Pipe,
3329
- args: [{
3330
- name: 'elementStyle'
3331
- }]
3332
- }] });
3333
- class ElementClassPipe {
3334
- transform(element) {
3335
- let classStr = '';
3336
- const prefix = 'indent';
3337
- if (element.textIndent) {
3338
- classStr += `${prefix}-${element.textIndent}`;
3339
- }
3340
- return classStr;
3341
- }
3342
- }
3343
- ElementClassPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ElementClassPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
3344
- ElementClassPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ElementClassPipe, name: "elementClass" });
3345
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ElementClassPipe, decorators: [{
3346
- type: Pipe,
3347
- args: [{
3348
- name: 'elementClass'
3349
- }]
3350
- }] });
3351
-
3352
3252
  class TheNumberedListComponent extends TheBaseElementComponent {
3353
- constructor(elementRef, cdr, elementClassPipe) {
3253
+ constructor(elementRef, cdr) {
3354
3254
  super(elementRef, cdr);
3355
3255
  this.elementRef = elementRef;
3356
3256
  this.cdr = cdr;
3357
- this.elementClassPipe = elementClassPipe;
3358
3257
  }
3359
3258
  get start() {
3360
3259
  return this.element.start;
3361
3260
  }
3362
- get class() {
3363
- return this.elementClassPipe.transform(this.element);
3261
+ get level() {
3262
+ var _a;
3263
+ return (_a = this.element) === null || _a === void 0 ? void 0 : _a.indent;
3364
3264
  }
3365
3265
  ngOnInit() {
3366
3266
  super.ngOnInit();
@@ -3369,32 +3269,31 @@ class TheNumberedListComponent extends TheBaseElementComponent {
3369
3269
  super.ngOnDestroy();
3370
3270
  }
3371
3271
  }
3372
- TheNumberedListComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TheNumberedListComponent, deps: [{ token: i0.ElementRef }, { token: i0.ChangeDetectorRef }, { token: ElementClassPipe }], target: i0.ɵɵFactoryTarget.Component });
3373
- TheNumberedListComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.15", type: TheNumberedListComponent, selector: "ol[theOl]", host: { properties: { "attr.start": "this.start", "class": "this.class" } }, providers: [ElementClassPipe], usesInheritance: true, ngImport: i0, template: `<slate-children [children]="children" [context]="childrenContext" [viewContext]="viewContext"></slate-children>`, isInline: true, components: [{ type: i1.SlateChildrenComponent, selector: "slate-children", inputs: ["children", "context", "viewContext"] }] });
3272
+ TheNumberedListComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TheNumberedListComponent, deps: [{ token: i0.ElementRef }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
3273
+ TheNumberedListComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.15", type: TheNumberedListComponent, selector: "ol[theOl]", host: { properties: { "attr.start": "this.start", "attr.the-level": "this.level" } }, usesInheritance: true, ngImport: i0, template: `<slate-children [children]="children" [context]="childrenContext" [viewContext]="viewContext"></slate-children>`, isInline: true, components: [{ type: i1.SlateChildrenComponent, selector: "slate-children", inputs: ["children", "context", "viewContext"] }] });
3374
3274
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TheNumberedListComponent, decorators: [{
3375
3275
  type: Component,
3376
3276
  args: [{
3377
3277
  selector: 'ol[theOl]',
3378
- template: `<slate-children [children]="children" [context]="childrenContext" [viewContext]="viewContext"></slate-children>`,
3379
- providers: [ElementClassPipe]
3278
+ template: `<slate-children [children]="children" [context]="childrenContext" [viewContext]="viewContext"></slate-children>`
3380
3279
  }]
3381
- }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.ChangeDetectorRef }, { type: ElementClassPipe }]; }, propDecorators: { start: [{
3280
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { start: [{
3382
3281
  type: HostBinding,
3383
3282
  args: ['attr.start']
3384
- }], class: [{
3283
+ }], level: [{
3385
3284
  type: HostBinding,
3386
- args: ['class']
3285
+ args: ['attr.the-level']
3387
3286
  }] } });
3388
3287
 
3389
3288
  class TheBulletedListComponent extends TheBaseElementComponent {
3390
- constructor(elementRef, cdr, elementClassPipe) {
3289
+ constructor(elementRef, cdr) {
3391
3290
  super(elementRef, cdr);
3392
3291
  this.elementRef = elementRef;
3393
3292
  this.cdr = cdr;
3394
- this.elementClassPipe = elementClassPipe;
3395
3293
  }
3396
- get class() {
3397
- return this.elementClassPipe.transform(this.element);
3294
+ get level() {
3295
+ var _a;
3296
+ return (_a = this.element) === null || _a === void 0 ? void 0 : _a.indent;
3398
3297
  }
3399
3298
  ngOnInit() {
3400
3299
  super.ngOnInit();
@@ -3403,18 +3302,17 @@ class TheBulletedListComponent extends TheBaseElementComponent {
3403
3302
  super.ngOnDestroy();
3404
3303
  }
3405
3304
  }
3406
- TheBulletedListComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TheBulletedListComponent, deps: [{ token: i0.ElementRef }, { token: i0.ChangeDetectorRef }, { token: ElementClassPipe }], target: i0.ɵɵFactoryTarget.Component });
3407
- TheBulletedListComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.15", type: TheBulletedListComponent, selector: "ul[theUl]", host: { properties: { "class": "this.class" } }, providers: [ElementClassPipe], usesInheritance: true, ngImport: i0, template: `<slate-children [children]="children" [context]="childrenContext" [viewContext]="viewContext"></slate-children>`, isInline: true, components: [{ type: i1.SlateChildrenComponent, selector: "slate-children", inputs: ["children", "context", "viewContext"] }] });
3305
+ TheBulletedListComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TheBulletedListComponent, deps: [{ token: i0.ElementRef }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
3306
+ TheBulletedListComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.15", type: TheBulletedListComponent, selector: "ul[theUl]", host: { properties: { "attr.the-level": "this.level" } }, usesInheritance: true, ngImport: i0, template: `<slate-children [children]="children" [context]="childrenContext" [viewContext]="viewContext"></slate-children>`, isInline: true, components: [{ type: i1.SlateChildrenComponent, selector: "slate-children", inputs: ["children", "context", "viewContext"] }] });
3408
3307
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TheBulletedListComponent, decorators: [{
3409
3308
  type: Component,
3410
3309
  args: [{
3411
3310
  selector: 'ul[theUl]',
3412
- template: `<slate-children [children]="children" [context]="childrenContext" [viewContext]="viewContext"></slate-children>`,
3413
- providers: [ElementClassPipe]
3311
+ template: `<slate-children [children]="children" [context]="childrenContext" [viewContext]="viewContext"></slate-children>`
3414
3312
  }]
3415
- }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.ChangeDetectorRef }, { type: ElementClassPipe }]; }, propDecorators: { class: [{
3313
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { level: [{
3416
3314
  type: HostBinding,
3417
- args: ['class']
3315
+ args: ['attr.the-level']
3418
3316
  }] } });
3419
3317
 
3420
3318
  class TheListItemComponent extends TheBaseElementComponent {
@@ -3730,52 +3628,6 @@ const withList = ({ validLiChildrenTypes } = {}) => (editor) => {
3730
3628
  return editor;
3731
3629
  };
3732
3630
 
3733
- /** Converts CSS pixel values to numbers, eg "123px" to 123. Returns NaN for non pixel values. */
3734
- function coercePixelsFromCssValue(cssValue) {
3735
- const match = cssValue.match(/(\d+)px/);
3736
- if (match) {
3737
- return Number(match[1]);
3738
- }
3739
- }
3740
- function getElementWidth(element) {
3741
- // Optimization: Check style.width first as we probably set it already before reading
3742
- // offsetWidth which triggers layout.
3743
- return coercePixelsFromCssValue(element.style.width) || element.offsetWidth;
3744
- }
3745
- function getElementHeight(element) {
3746
- return Math.round(element.getBoundingClientRect().height);
3747
- }
3748
- function getColsTotalWidth(cols) {
3749
- return cols.reduce((total, col) => {
3750
- return total + getElementWidth(col);
3751
- }, 0);
3752
- }
3753
- function getRowsTotalHeight(rows) {
3754
- return rows.reduce((total, row) => {
3755
- return total + getElementHeight(row);
3756
- }, 0);
3757
- }
3758
- function useElementStyle(el, element) {
3759
- if (element.align) {
3760
- el.style.textAlign = element.align || Alignment.left;
3761
- }
3762
- if (element.textIndent) {
3763
- el.style.textIndent = element.textIndent + 'em';
3764
- }
3765
- if (element.verticalAlign) {
3766
- el.style.verticalAlign = element.verticalAlign;
3767
- }
3768
- }
3769
- function getElementClassByPrefix(el, prefix) {
3770
- let matchClass = null;
3771
- el.classList.forEach((value, key) => {
3772
- if (value.includes(prefix)) {
3773
- matchClass = value;
3774
- }
3775
- });
3776
- return matchClass;
3777
- }
3778
-
3779
3631
  class TheTodoItemComponent extends TheBaseElementComponent {
3780
3632
  constructor(elementRef, cdr) {
3781
3633
  super(elementRef, cdr);
@@ -3783,15 +3635,12 @@ class TheTodoItemComponent extends TheBaseElementComponent {
3783
3635
  this.cdr = cdr;
3784
3636
  this.checkItemClass = true;
3785
3637
  }
3786
- onContextChange() {
3787
- super.onContextChange();
3788
- if (this.initialized) {
3789
- this.useIndentClass(this.elementRef.nativeElement, this.element);
3790
- }
3638
+ get level() {
3639
+ var _a;
3640
+ return (_a = this.element) === null || _a === void 0 ? void 0 : _a.indent;
3791
3641
  }
3792
3642
  ngOnInit() {
3793
3643
  super.ngOnInit();
3794
- this.useIndentClass(this.elementRef.nativeElement, this.element);
3795
3644
  }
3796
3645
  onCheck(checked) {
3797
3646
  if (this.readonly) {
@@ -3799,26 +3648,9 @@ class TheTodoItemComponent extends TheBaseElementComponent {
3799
3648
  }
3800
3649
  setNode(this.editor, { checked }, this.element);
3801
3650
  }
3802
- useIndentClass(el, element) {
3803
- const prefix = 'indent';
3804
- if (element.textIndent) {
3805
- const oldClass = getElementClassByPrefix(el, prefix);
3806
- if (oldClass) {
3807
- el.classList.remove(oldClass);
3808
- }
3809
- const newClassName = `${prefix}-${element.textIndent}`;
3810
- el.classList.add(newClassName);
3811
- }
3812
- else {
3813
- const oldClass = getElementClassByPrefix(el, prefix);
3814
- if (oldClass) {
3815
- el.classList.remove(oldClass);
3816
- }
3817
- }
3818
- }
3819
3651
  }
3820
3652
  TheTodoItemComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TheTodoItemComponent, deps: [{ token: i0.ElementRef }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
3821
- TheTodoItemComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.15", type: TheTodoItemComponent, selector: "div[theTodoItem]", host: { properties: { "class.the-check-item": "this.checkItemClass" } }, usesInheritance: true, ngImport: i0, template: `
3653
+ TheTodoItemComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.15", type: TheTodoItemComponent, selector: "div[theTodoItem]", host: { properties: { "class.the-check-item": "this.checkItemClass", "attr.the-level": "this.level" } }, usesInheritance: true, ngImport: i0, template: `
3822
3654
  <span contenteditable="false" class="todo-item-status">
3823
3655
  <input #checkbox type="checkbox" [checked]="element.checked" (click)="onCheck(checkbox.checked)" />
3824
3656
  </span>
@@ -3838,6 +3670,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImpo
3838
3670
  }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { checkItemClass: [{
3839
3671
  type: HostBinding,
3840
3672
  args: ['class.the-check-item']
3673
+ }], level: [{
3674
+ type: HostBinding,
3675
+ args: ['attr.the-level']
3841
3676
  }] } });
3842
3677
 
3843
3678
  const withTodoItem = (editor) => {
@@ -4450,7 +4285,7 @@ const withBlockCard = (editor) => {
4450
4285
  return;
4451
4286
  }
4452
4287
  // → + right-block-card
4453
- if ((isMoveForward && !isCardLeftCursor)) {
4288
+ if (isMoveForward && !isCardLeftCursor) {
4454
4289
  nativeEvent.preventDefault();
4455
4290
  const [, path] = AngularEditor.toSlateCardEntry(editor, anchorNode);
4456
4291
  const nextPath = Path.next(path);
@@ -8016,6 +7851,52 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImpo
8016
7851
  type: Injectable
8017
7852
  }], ctorParameters: function () { return []; } });
8018
7853
 
7854
+ /** Converts CSS pixel values to numbers, eg "123px" to 123. Returns NaN for non pixel values. */
7855
+ function coercePixelsFromCssValue(cssValue) {
7856
+ const match = cssValue.match(/(\d+)px/);
7857
+ if (match) {
7858
+ return Number(match[1]);
7859
+ }
7860
+ }
7861
+ function getElementWidth(element) {
7862
+ // Optimization: Check style.width first as we probably set it already before reading
7863
+ // offsetWidth which triggers layout.
7864
+ return coercePixelsFromCssValue(element.style.width) || element.offsetWidth;
7865
+ }
7866
+ function getElementHeight(element) {
7867
+ return Math.round(element.getBoundingClientRect().height);
7868
+ }
7869
+ function getColsTotalWidth(cols) {
7870
+ return cols.reduce((total, col) => {
7871
+ return total + getElementWidth(col);
7872
+ }, 0);
7873
+ }
7874
+ function getRowsTotalHeight(rows) {
7875
+ return rows.reduce((total, row) => {
7876
+ return total + getElementHeight(row);
7877
+ }, 0);
7878
+ }
7879
+ function useElementStyle(el, element) {
7880
+ if (element.align) {
7881
+ el.style.textAlign = element.align || Alignment.left;
7882
+ }
7883
+ if (element.textIndent) {
7884
+ el.style.textIndent = element.textIndent + 'em';
7885
+ }
7886
+ if (element.verticalAlign) {
7887
+ el.style.verticalAlign = element.verticalAlign;
7888
+ }
7889
+ }
7890
+ function getElementClassByPrefix(el, prefix) {
7891
+ let matchClass = null;
7892
+ el.classList.forEach((value, key) => {
7893
+ if (value.includes(prefix)) {
7894
+ matchClass = value;
7895
+ }
7896
+ });
7897
+ return matchClass;
7898
+ }
7899
+
8019
7900
  function splitCell(editor) {
8020
7901
  const opts = new TableOptions$1();
8021
7902
  const { anchor } = editor.selection;
@@ -11007,14 +10888,17 @@ class TheQuickToolbarComponent extends mixinUnsubscribe(MixinBase) {
11007
10888
  }
11008
10889
  handleMouseDown(event) {
11009
10890
  if (!this.elementRef.nativeElement.contains(event.target)) {
11010
- this.popoverRef.close();
10891
+ QuickInsertEditor.closeQuickToolbar(this.editor);
11011
10892
  }
11012
10893
  else {
11013
10894
  event.preventDefault();
11014
10895
  }
11015
10896
  }
11016
10897
  handleEnter() {
11017
- this.popoverRef.close();
10898
+ QuickInsertEditor.closeQuickToolbar(this.editor);
10899
+ }
10900
+ handleEsc() {
10901
+ QuickInsertEditor.closeQuickToolbar(this.editor);
11018
10902
  }
11019
10903
  ngOnInit() {
11020
10904
  this.editorElement = AngularEditor.toDOMNode(this.editor, this.editor);
@@ -11031,7 +10915,7 @@ class TheQuickToolbarComponent extends mixinUnsubscribe(MixinBase) {
11031
10915
  }
11032
10916
  removeHotKey() {
11033
10917
  const node = Node.get(this.editor, this.editor.selection.anchor.path);
11034
- if (node && Text.equals({ text: QUICK_TOOLBAR_HOTKEY }, node)) {
10918
+ if (node && QUICK_TOOLBAR_HOTKEY === node.text) {
11035
10919
  Editor.deleteBackward(this.editor);
11036
10920
  }
11037
10921
  }
@@ -11040,7 +10924,7 @@ class TheQuickToolbarComponent extends mixinUnsubscribe(MixinBase) {
11040
10924
  }
11041
10925
  }
11042
10926
  TheQuickToolbarComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TheQuickToolbarComponent, deps: [{ token: i1$3.ThyPopoverRef }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
11043
- 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()" } }, 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: i2$2.ThySelectionListComponent, selector: "thy-selection-list,[thy-selection-list]", inputs: ["thyMultiple", "thyBindKeyEventContainer", "thyScrollContainer", "thyBeforeKeydown", "thyUniqueKey", "thyCompareWith", "thyLayout", "thyAutoActiveFirstItem", "thySize", "thySpaceKeyEnabled"], outputs: ["thySelectionChange"] }, { type: i5$3.ThyListOptionComponent, selector: "thy-list-option,[thy-list-option]", inputs: ["id", "thyValue", "thyDisabled"] }, { type: TheToolbarItemComponent, selector: "the-toolbar-item", inputs: ["item", "editor", "itemMode"] }, { type: NavSplitLineComponent, selector: "nav-split-line", inputs: ["mode"] }], directives: [{ type: i6.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i6.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
10927
+ 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: i2$2.ThySelectionListComponent, selector: "thy-selection-list,[thy-selection-list]", inputs: ["thyMultiple", "thyBindKeyEventContainer", "thyScrollContainer", "thyBeforeKeydown", "thyUniqueKey", "thyCompareWith", "thyLayout", "thyAutoActiveFirstItem", "thySize", "thySpaceKeyEnabled"], outputs: ["thySelectionChange"] }, { type: i5$3.ThyListOptionComponent, selector: "thy-list-option,[thy-list-option]", inputs: ["id", "thyValue", "thyDisabled"] }, { type: TheToolbarItemComponent, selector: "the-toolbar-item", inputs: ["item", "editor", "itemMode"] }, { type: NavSplitLineComponent, selector: "nav-split-line", inputs: ["mode"] }], directives: [{ type: i6.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i6.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
11044
10928
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TheQuickToolbarComponent, decorators: [{
11045
10929
  type: Component,
11046
10930
  args: [{
@@ -11057,6 +10941,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImpo
11057
10941
  }], handleEnter: [{
11058
10942
  type: HostListener,
11059
10943
  args: ['document: keydown.enter']
10944
+ }], handleEsc: [{
10945
+ type: HostListener,
10946
+ args: ['document: keydown.escape']
11060
10947
  }] } });
11061
10948
 
11062
10949
  const OperationTypes = ['insert_text', 'remove_node', 'merge_node'];
@@ -11170,7 +11057,7 @@ const FontSizeEditor = {
11170
11057
  return;
11171
11058
  }
11172
11059
  // unset fontSize
11173
- if (isDefaultFontSize && Number(defaultFontSize) === fontSizeMark) {
11060
+ if (isDefaultFontSize) {
11174
11061
  FontSizeEditor.unsetFontSize(editor, size);
11175
11062
  return;
11176
11063
  }
@@ -11269,7 +11156,7 @@ class TheInlineCodeComponent extends TheBaseElementComponent {
11269
11156
  super(...arguments);
11270
11157
  // Put this at the start and end of an inline component to work around this Chromium bug:
11271
11158
  // https://bugs.chromium.org/p/chromium/issues/detail?id=1249405
11272
- this.inlineChromiumBugfix = '$' + String.fromCodePoint(160);
11159
+ this.inlineChromiumBugfix = String.fromCodePoint(160);
11273
11160
  }
11274
11161
  }
11275
11162
  TheInlineCodeComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TheInlineCodeComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
@@ -11327,6 +11214,290 @@ const withInlineCode = (editor) => {
11327
11214
  return editor;
11328
11215
  };
11329
11216
 
11217
+ class TheIndentToolbarComponent extends TheToolbarBaseItemComponent {
11218
+ constructor(elementRef, thyPopover, viewContainerRef, overlay) {
11219
+ super();
11220
+ this.elementRef = elementRef;
11221
+ this.thyPopover = thyPopover;
11222
+ this.viewContainerRef = viewContainerRef;
11223
+ this.overlay = overlay;
11224
+ this.mode = DropdownMode.text;
11225
+ this.dropdownMode = DropdownMode;
11226
+ this.disabled = false;
11227
+ }
11228
+ get isOpen() {
11229
+ return this.dropdownPopoverRef && this.dropdownPopoverRef.getOverlayRef() && this.dropdownPopoverRef.getOverlayRef().hasAttached();
11230
+ }
11231
+ toggleDropdown(event) {
11232
+ var _a;
11233
+ super.execute(event);
11234
+ if (((_a = this.editor) === null || _a === void 0 ? void 0 : _a.disabled) || this.disabled) {
11235
+ return;
11236
+ }
11237
+ this.openDropdownPopover();
11238
+ }
11239
+ handleDocumentMouseDown(event) {
11240
+ if (!this.elementRef.nativeElement.contains(event.target)) {
11241
+ this.closeDropdownPopover();
11242
+ }
11243
+ }
11244
+ get disabledState() {
11245
+ return this.disabled;
11246
+ }
11247
+ ngOnInit() {
11248
+ var _a;
11249
+ if (!this.activeMenu) {
11250
+ this.activeMenu = this.menus[0];
11251
+ }
11252
+ if (this.toolbarItem) {
11253
+ this.elementRef.nativeElement.classList.add(`${(_a = this.toolbarItem) === null || _a === void 0 ? void 0 : _a.key}`);
11254
+ }
11255
+ }
11256
+ statusChange(editor) {
11257
+ var _a, _b;
11258
+ this.disabled = ((_a = this.toolbarItem) === null || _a === void 0 ? void 0 : _a.disable) ? (_b = this.toolbarItem) === null || _b === void 0 ? void 0 : _b.disable(editor) : false;
11259
+ }
11260
+ itemMousedown(event, item) {
11261
+ super.execute(event);
11262
+ this.closeDropdownPopover();
11263
+ if (item === null || item === void 0 ? void 0 : item.execute) {
11264
+ item === null || item === void 0 ? void 0 : item.execute(this.editor);
11265
+ }
11266
+ }
11267
+ openDropdownPopover() {
11268
+ var _a;
11269
+ this.dropdownPopoverRef = this.thyPopover.open(this.dropdownTemplate, {
11270
+ origin: this.elementRef,
11271
+ panelClass: ['the-toolbar-dropdown-popover', (_a = this.toolbarItem) === null || _a === void 0 ? void 0 : _a.key],
11272
+ placement: 'bottomLeft',
11273
+ insideClosable: false,
11274
+ backdropClosable: true,
11275
+ hasBackdrop: false,
11276
+ offset: 10,
11277
+ viewContainerRef: this.viewContainerRef,
11278
+ scrollStrategy: this.overlay.scrollStrategies.reposition()
11279
+ });
11280
+ }
11281
+ closeDropdownPopover() {
11282
+ var _a;
11283
+ if (this.dropdownPopoverRef) {
11284
+ (_a = this.dropdownPopoverRef) === null || _a === void 0 ? void 0 : _a.close();
11285
+ }
11286
+ }
11287
+ }
11288
+ TheIndentToolbarComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TheIndentToolbarComponent, deps: [{ token: i0.ElementRef }, { token: i1$3.ThyPopover }, { token: i0.ViewContainerRef }, { token: i2.Overlay }], target: i0.ɵɵFactoryTarget.Component });
11289
+ TheIndentToolbarComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.15", type: TheIndentToolbarComponent, selector: "the-indent-toolbar-item", inputs: { toolbarItem: "toolbarItem", menus: "menus", mode: "mode", item: "item" }, host: { listeners: { "mousedown": "toggleDropdown($event)", "document: mousedown": "handleDocumentMouseDown($event)" }, properties: { "class.disabled": "this.disabledState" }, classAttribute: "the-toolbar-dropdown-container" }, viewQueries: [{ propertyName: "dropdownTemplate", first: true, predicate: ["dropdownTemplate"], descendants: true, static: true }], usesInheritance: true, ngImport: i0, template: "<a thyIconNavLink class=\"icon-mode link-with-down\" [thyTooltip]=\"activeMenu?.name\" thyTooltipPlacement=\"top\">\n <thy-icon [thyIconName]=\"activeMenu?.icon\"></thy-icon>\n <thy-icon class=\"caret-down-icon font-size-sm text-desc\" thyIconName=\"caret-down\"></thy-icon>\n</a>\n\n<ng-template #dropdownTemplate>\n <thy-action-menu class=\"dropdown-menu\">\n <ng-container *ngFor=\"let menu of menus\">\n <a thyActionMenuItem href=\"javascript:;\" (mousedown)=\"itemMousedown($event, menu)\">\n <span thyActionMenuItemIcon>\n <thy-icon [thyIconName]=\"menu.icon\"></thy-icon>\n </span>\n <span thyActionMenuItemName>{{ menu.name }}</span>\n </a>\n </ng-container>\n </thy-action-menu>\n</ng-template>\n", components: [{ type: i3.ThyIconNavLinkComponent, selector: "[thyIconNavLink]", inputs: ["thyIconNavLinkIcon", "thyIconNavLinkActive"] }, { type: i4$1.ThyIconComponent, selector: "thy-icon", inputs: ["thyIconType", "thyTwotoneColor", "thyIconName", "thyIconRotate", "thyIconSet", "thyIconLegging", "thyIconLinearGradient"] }, { type: i5$2.ThyActionMenuComponent, selector: "thy-action-menu", inputs: ["thyTheme", "thyWidth"] }], directives: [{ type: i5$1.ThyTooltipDirective, selector: "[thyTooltip],[thy-tooltip]", inputs: ["thyTooltip", "thyTooltipPlacement", "thyTooltipClass", "thyTooltipShowDelay", "thyTooltipHideDelay", "thyTooltipTrigger", "thyTooltipDisabled", "thyTooltipTemplateContext", "thyTooltipOffset", "thyTooltipPin"], exportAs: ["thyTooltip"] }, { type: i6.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i5$2.ThyActionMenuItemDirective, selector: "[thyActionMenuItem]", inputs: ["thyDisabled", "thyType"] }, { type: i5$2.ThyActionMenuItemIconDirective, selector: "[thyActionMenuItemIcon]" }, { type: i5$2.ThyActionMenuItemNameDirective, selector: "[thyActionMenuItemName]" }] });
11290
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: TheIndentToolbarComponent, decorators: [{
11291
+ type: Component,
11292
+ args: [{
11293
+ selector: 'the-indent-toolbar-item',
11294
+ templateUrl: './toolbar-item.component.html',
11295
+ host: {
11296
+ class: 'the-toolbar-dropdown-container'
11297
+ }
11298
+ }]
11299
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i1$3.ThyPopover }, { type: i0.ViewContainerRef }, { type: i2.Overlay }]; }, propDecorators: { toolbarItem: [{
11300
+ type: Input
11301
+ }], menus: [{
11302
+ type: Input
11303
+ }], mode: [{
11304
+ type: Input
11305
+ }], item: [{
11306
+ type: Input
11307
+ }], dropdownTemplate: [{
11308
+ type: ViewChild,
11309
+ args: ['dropdownTemplate', { static: true }]
11310
+ }], toggleDropdown: [{
11311
+ type: HostListener,
11312
+ args: ['mousedown', ['$event']]
11313
+ }], handleDocumentMouseDown: [{
11314
+ type: HostListener,
11315
+ args: ['document: mousedown', ['$event']]
11316
+ }], disabledState: [{
11317
+ type: HostBinding,
11318
+ args: ['class.disabled']
11319
+ }] } });
11320
+
11321
+ const MaxIndent = 13;
11322
+ const includesIndentTypes = [
11323
+ ElementKinds.checkItem,
11324
+ ElementKinds.numberedList,
11325
+ ElementKinds.bulletedList,
11326
+ ElementKinds.paragraph,
11327
+ ...HEADING_TYPES
11328
+ ];
11329
+ const IndentEditor = {
11330
+ setIndent(editor) {
11331
+ const nodes = Array.from(Editor.nodes(editor, {
11332
+ mode: 'highest',
11333
+ match: n => Element$1.isElement(n) && includesIndentTypes.includes(n.type)
11334
+ }));
11335
+ const [startBlock] = nodes;
11336
+ if (startBlock) {
11337
+ let [{ indent }] = startBlock;
11338
+ indent = indent ? indent : 0;
11339
+ indent += 1;
11340
+ if (indent <= MaxIndent) {
11341
+ Transforms.setNodes(editor, { indent }, {
11342
+ mode: 'highest',
11343
+ match: n => Element$1.isElement(n) && includesIndentTypes.includes(n.type)
11344
+ });
11345
+ }
11346
+ }
11347
+ },
11348
+ cancelIndent(editor) {
11349
+ const nodes = Array.from(Editor.nodes(editor, {
11350
+ mode: 'highest',
11351
+ match: n => Element$1.isElement(n) && includesIndentTypes.includes(n.type)
11352
+ }));
11353
+ const [startBlock] = nodes;
11354
+ if (startBlock) {
11355
+ let [{ indent }] = startBlock;
11356
+ indent = indent === 1 ? null : (indent -= 1);
11357
+ Transforms.setNodes(editor, { indent }, {
11358
+ mode: 'highest',
11359
+ match: n => Element$1.isElement(n) && includesIndentTypes.includes(n.type)
11360
+ });
11361
+ }
11362
+ },
11363
+ setTextIndent(editor, kinds, textIndent) {
11364
+ Transforms.setNodes(editor, { textIndent }, {
11365
+ mode: 'highest',
11366
+ match: node => Element$1.isElement(node) && kinds.includes(node.type)
11367
+ });
11368
+ },
11369
+ cancelTextIntent(editor, event, anchorBlock, kinds) {
11370
+ let { textIndent, indent } = anchorBlock;
11371
+ if (indent) {
11372
+ event.preventDefault();
11373
+ IndentEditor.cancelIndent(editor);
11374
+ return true;
11375
+ }
11376
+ if (!indent && textIndent > 2) {
11377
+ event.preventDefault();
11378
+ textIndent -= 2;
11379
+ IndentEditor.setTextIndent(editor, kinds, textIndent);
11380
+ return true;
11381
+ }
11382
+ if (!indent && textIndent === 2) {
11383
+ event.preventDefault();
11384
+ IndentEditor.setTextIndent(editor, kinds, null);
11385
+ return true;
11386
+ }
11387
+ return false;
11388
+ },
11389
+ isDisabled(editor) {
11390
+ if (editor.selection) {
11391
+ const disableGroup = HEADING_TYPES;
11392
+ const anchorBlock$1 = anchorBlock(editor);
11393
+ return anchorBlock$1 && disableGroup.includes(anchorBlock$1 === null || anchorBlock$1 === void 0 ? void 0 : anchorBlock$1.type);
11394
+ }
11395
+ return false;
11396
+ }
11397
+ };
11398
+
11399
+ const IndentOptions = [
11400
+ {
11401
+ key: ElementKinds.indent,
11402
+ includes: [Indents.indentRight, Indents.indentLeft],
11403
+ iconComponent: TheIndentToolbarComponent,
11404
+ disable: editor => IndentEditor.isDisabled(editor)
11405
+ },
11406
+ {
11407
+ key: Indents.indentRight,
11408
+ name: '增加缩进',
11409
+ icon: 'float-left',
11410
+ execute: editor => IndentEditor.setIndent(editor)
11411
+ },
11412
+ {
11413
+ key: Indents.indentLeft,
11414
+ name: '减少缩进',
11415
+ icon: 'float-right',
11416
+ type: ToolbarItemType.toolDropdown,
11417
+ execute: editor => IndentEditor.cancelIndent(editor)
11418
+ }
11419
+ ];
11420
+
11421
+ const onKeydownTextIndent = (editor, event, kinds) => {
11422
+ const { selection } = editor;
11423
+ const isExpanded = Range.isExpanded(selection);
11424
+ const nodes = Array.from(Editor.nodes(editor, {
11425
+ mode: 'highest',
11426
+ match: node => Element$1.isElement(node) && kinds.includes(node.type)
11427
+ }));
11428
+ const [startBlock] = nodes;
11429
+ if (!startBlock) {
11430
+ return false;
11431
+ }
11432
+ const [block, path] = startBlock;
11433
+ const currentPath = [path[0]];
11434
+ const isStart = Editor.isStart(editor, selection.anchor, currentPath);
11435
+ const textIndentDisable = [ElementKinds.bulletedList, ElementKinds.numberedList, ElementKinds.checkItem];
11436
+ if (isHotkey('Tab', event)) {
11437
+ event.preventDefault();
11438
+ if (startBlock && (isExpanded || isStart)) {
11439
+ if (!editor.isVoid(block)) {
11440
+ let { textIndent, type } = block;
11441
+ // do not apply first-line indentation for lists
11442
+ if (!textIndent && !textIndentDisable.includes(type)) {
11443
+ IndentEditor.setTextIndent(editor, kinds, 2);
11444
+ return true;
11445
+ }
11446
+ else {
11447
+ IndentEditor.setIndent(editor);
11448
+ return true;
11449
+ }
11450
+ }
11451
+ }
11452
+ else {
11453
+ editor.insertText(TAB_SPACE);
11454
+ return true;
11455
+ }
11456
+ }
11457
+ if (isHotkey('shift+Tab', event)) {
11458
+ if (startBlock && (isExpanded || isStart)) {
11459
+ if (!editor.isVoid(block)) {
11460
+ return IndentEditor.cancelTextIntent(editor, event, block, kinds);
11461
+ }
11462
+ }
11463
+ }
11464
+ if (selection && Range.isCollapsed(selection) && hotkeys.isDeleteBackward(event)) {
11465
+ if (startBlock && isStart) {
11466
+ return IndentEditor.cancelTextIntent(editor, event, block, kinds);
11467
+ }
11468
+ }
11469
+ return false;
11470
+ };
11471
+
11472
+ const withIndent = (kinds) => (editor) => {
11473
+ const { onKeydown } = editor;
11474
+ editor.onKeydown = (event) => {
11475
+ const HOTKEYS = {
11476
+ 'mod+]': Indents.indentRight,
11477
+ 'mod+[': Indents.indentLeft
11478
+ };
11479
+ for (const hotkey in HOTKEYS) {
11480
+ if (isHotkey(hotkey, event)) {
11481
+ event.preventDefault();
11482
+ const mark = HOTKEYS[hotkey];
11483
+ switch (mark) {
11484
+ case Indents.indentRight:
11485
+ IndentEditor.setIndent(editor);
11486
+ break;
11487
+ case Indents.indentLeft:
11488
+ IndentEditor.cancelIndent(editor);
11489
+ break;
11490
+ }
11491
+ }
11492
+ }
11493
+ const isContinue = !onKeydownTextIndent(editor, event, kinds);
11494
+ if (isContinue) {
11495
+ onKeydown(event);
11496
+ }
11497
+ };
11498
+ return editor;
11499
+ };
11500
+
11330
11501
  const internalPlugins = [
11331
11502
  withTheHistory,
11332
11503
  withAutoInsertData(),
@@ -11385,7 +11556,8 @@ const internalToolbarItems = [
11385
11556
  ...TableOptions,
11386
11557
  ...VerticalAlignOptions,
11387
11558
  ...PaintFormatOptions,
11388
- ...InlineCodeOptions
11559
+ ...InlineCodeOptions,
11560
+ ...IndentOptions
11389
11561
  ];
11390
11562
  const toolbarCompose = (toolbarItems = []) => {
11391
11563
  return [...internalToolbarItems, ...toolbarItems];
@@ -11962,6 +12134,45 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImpo
11962
12134
  args: ['mousedown', ['$event']]
11963
12135
  }] } });
11964
12136
 
12137
+ class ElementStylePipe {
12138
+ transform(element, align) {
12139
+ const style = {};
12140
+ if (element.align || align) {
12141
+ style.textAlign = element.align || align || Alignment.left;
12142
+ }
12143
+ if (element.textIndent) {
12144
+ style.textIndent = element.textIndent + 'em';
12145
+ }
12146
+ return style;
12147
+ }
12148
+ }
12149
+ ElementStylePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ElementStylePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
12150
+ ElementStylePipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ElementStylePipe, name: "elementStyle" });
12151
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ElementStylePipe, decorators: [{
12152
+ type: Pipe,
12153
+ args: [{
12154
+ name: 'elementStyle'
12155
+ }]
12156
+ }] });
12157
+ class ElementClassPipe {
12158
+ transform(element) {
12159
+ let classStr = '';
12160
+ const prefix = 'indent';
12161
+ if (element.textIndent) {
12162
+ classStr += `${prefix}-${element.textIndent}`;
12163
+ }
12164
+ return classStr;
12165
+ }
12166
+ }
12167
+ ElementClassPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ElementClassPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
12168
+ ElementClassPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ElementClassPipe, name: "elementClass" });
12169
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ElementClassPipe, decorators: [{
12170
+ type: Pipe,
12171
+ args: [{
12172
+ name: 'elementClass'
12173
+ }]
12174
+ }] });
12175
+
11965
12176
  class TheTemplateComponent {
11966
12177
  constructor() {
11967
12178
  this.renderElement = (element) => {
@@ -12597,7 +12808,8 @@ const COMPONENTS = [
12597
12808
  TheTableSelectComponent,
12598
12809
  TheTableToolbarItemComponent,
12599
12810
  TheConversionHintComponent,
12600
- TheVerticalToolbarItemComponent
12811
+ TheVerticalToolbarItemComponent,
12812
+ TheIndentToolbarComponent
12601
12813
  ];
12602
12814
  const PLUGIN_COMPONENTS = [
12603
12815
  TheImageComponent,
@@ -12640,7 +12852,8 @@ TheEditorModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version
12640
12852
  TheTableSelectComponent,
12641
12853
  TheTableToolbarItemComponent,
12642
12854
  TheConversionHintComponent,
12643
- TheVerticalToolbarItemComponent, TheImageComponent,
12855
+ TheVerticalToolbarItemComponent,
12856
+ TheIndentToolbarComponent, TheImageComponent,
12644
12857
  TheTemplateComponent,
12645
12858
  TheHrComponent,
12646
12859
  TheBlockquoteComponent,
@@ -12706,5 +12919,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImpo
12706
12919
  * Generated bundle index. Do not edit.
12707
12920
  */
12708
12921
 
12709
- export { ALIGN_BLOCK_TYPES, A_TAG_REL_ATTR, AlignEditor, Alignment, BLOCK_DELETEBACKWARD_TYPES, BlockquoteEditor, CLIPBOARD_FORMAT_KEY, CODEMIRROR_PADDING_TOP, CODE_MODES, COMPONENTS, CONTAINER_BLOCKS, CONTROL_KEY, CodeEditor, CodeMode, ColorEditor, DEFAULT_LANGUAGE, DEFAULT_SCROLL_CONTAINER, DefaultElementOptions, DefaultGlobalToolbarDefinition, DefaultInlineToolbarDefinition, DefaultQuickToolbarDefinition, DropdownMode, ELEMENT_UNIQUE_ID, ElementKinds, ErrorCodes, FontSizeTypes, FontSizes, HEADING_TYPES, HeadingEditor, HrEditor, IS_MAC, ImageEditor, LINK_DEFAULT_TEXT, LIST_BLOCK_TYPES, LinkEditor, ListEditor, MarkEditor, MarkProps, MarkTypes, PICTURE_ACCEPTED_UPLOAD_MIME, PICTURE_ACCEPTED_UPLOAD_SIZE, PLUGIN_COMPONENTS, QUICK_TOOLBAR_HOTKEY, QuickInsertEditor, STANDARD_HEADING_TYPES, TAB_SPACE, THE_CODE_MODE_PROVIDER, THE_CODE_MODE_TOKEN, THE_EDITOR_CONVERSION_HINT_REF, THE_EDITOR_QUICK_TOOLBAR_REF, THE_EDITOR_UUID, THE_INLINE_TOOLBAR_TYPES, THE_UPLOAD_SERVICE_TOKEN, TableEditor, TheBaseElementComponent, TheCodeConfig, TheContextService, TheDataMode, TheDefaultElementComponent, TheEditor, TheEditorComponent, TheEditorModule, TheImageComponent, TheMode, index$1 as TheQueries, TheToolbarBaseItemComponent, TheToolbarComponent, TheToolbarDropdownComponent, TheToolbarGroupComponent, TheToolbarGroupToken, TheToolbarItemComponent, TheToolbarService, index as TheTransforms, TodoItemEditor, ToolbarActionTypes, ToolbarAlignment, ToolbarItemMode, ToolbarItemType, ToolbarMoreGroup, VOID_BLOCK_TYPES, VerticalAlignEditor, VerticalAlignment, ZERO_WIDTH_CHAR, createEmptyParagraph, dataDeserialize, dataSerializing, getToolbarClass, htmlToTheia, inValidTypes, isCleanEmptyParagraph, plainToTheia, toolbarCompose, withTheEditor };
12922
+ export { ALIGN_BLOCK_TYPES, A_TAG_REL_ATTR, AlignEditor, Alignment, BLOCK_DELETEBACKWARD_TYPES, BlockquoteEditor, CLIPBOARD_FORMAT_KEY, CODEMIRROR_PADDING_TOP, CODE_MODES, COMPONENTS, CONTAINER_BLOCKS, CONTROL_KEY, CodeEditor, CodeMode, ColorEditor, DEFAULT_LANGUAGE, DEFAULT_SCROLL_CONTAINER, DefaultElementOptions, DefaultGlobalToolbarDefinition, DefaultInlineToolbarDefinition, DefaultQuickToolbarDefinition, DropdownMode, ELEMENT_UNIQUE_ID, ElementKinds, ErrorCodes, FontSizeTypes, FontSizes, HEADING_TYPES, HeadingEditor, HrEditor, IS_MAC, ImageEditor, Indents, LINK_DEFAULT_TEXT, LIST_BLOCK_TYPES, LinkEditor, ListEditor, MarkEditor, MarkProps, MarkTypes, PICTURE_ACCEPTED_UPLOAD_MIME, PICTURE_ACCEPTED_UPLOAD_SIZE, PLUGIN_COMPONENTS, QUICK_TOOLBAR_HOTKEY, QuickInsertEditor, STANDARD_HEADING_TYPES, TAB_SPACE, THE_CODE_MODE_PROVIDER, THE_CODE_MODE_TOKEN, THE_EDITOR_CONVERSION_HINT_REF, THE_EDITOR_QUICK_TOOLBAR_REF, THE_EDITOR_UUID, THE_INLINE_TOOLBAR_TYPES, THE_UPLOAD_SERVICE_TOKEN, TableEditor, TheBaseElementComponent, TheCodeConfig, TheContextService, TheDataMode, TheDefaultElementComponent, TheEditor, TheEditorComponent, TheEditorModule, TheImageComponent, TheMode, index$1 as TheQueries, TheToolbarBaseItemComponent, TheToolbarComponent, TheToolbarDropdownComponent, TheToolbarGroupComponent, TheToolbarGroupToken, TheToolbarItemComponent, TheToolbarService, index as TheTransforms, TodoItemEditor, ToolbarActionTypes, ToolbarAlignment, ToolbarItemMode, ToolbarItemType, ToolbarMoreGroup, VOID_BLOCK_TYPES, VerticalAlignEditor, VerticalAlignment, ZERO_WIDTH_CHAR, createEmptyParagraph, dataDeserialize, dataSerializing, getToolbarClass, htmlToTheia, inValidTypes, isCleanEmptyParagraph, plainToTheia, toolbarCompose, withTheEditor };
12710
12923
  //# sourceMappingURL=worktile-theia.js.map