@worktile/theia 2.4.1 → 2.4.4

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 (42) hide show
  1. package/bundles/worktile-theia.umd.js +1117 -1034
  2. package/bundles/worktile-theia.umd.js.map +1 -1
  3. package/constants/auto-format-rules.d.ts +1 -1
  4. package/editor.module.d.ts +2 -1
  5. package/esm2015/constants/auto-format-rules.js +3 -2
  6. package/esm2015/editor.component.js +5 -2
  7. package/esm2015/interfaces/auto-format.js +1 -1
  8. package/esm2015/interfaces/editor.js +1 -1
  9. package/esm2015/plugins/autoformat/autoformat.plugin.js +23 -6
  10. package/esm2015/plugins/indent/indent.editor.js +11 -13
  11. package/esm2015/plugins/indent/indent.plugin.js +15 -2
  12. package/esm2015/plugins/indent/on-keydown-indent.js +3 -5
  13. package/esm2015/plugins/index.js +2 -3
  14. package/esm2015/plugins/quick-insert/components/quick-insert.component.js +6 -2
  15. package/esm2015/plugins/quick-insert/components/quick-toolbar/quick-toolbar.component.js +14 -15
  16. package/esm2015/plugins/quick-insert/quick-insert.editor.js +18 -27
  17. package/esm2015/plugins/quick-insert/quick-insert.plugin.js +33 -15
  18. package/esm2015/plugins/table/components/insert-mark/insert-mark.component.js +4 -4
  19. package/esm2015/plugins/table/components/table.component.js +2 -2
  20. package/esm2015/plugins/table/components/td/td.component.js +5 -7
  21. package/esm2015/plugins/table/table.service.js +6 -6
  22. package/esm2015/plugins/todo-item/todo-item.component.js +15 -7
  23. package/esm2015/transforms/index.js +3 -2
  24. package/esm2015/transforms/insert-element-next.js +1 -1
  25. package/esm2015/transforms/insert-element-node.js +36 -0
  26. package/esm2015/utils/is-clean-empty-paragraph.js +4 -1
  27. package/fesm2015/worktile-theia.js +1054 -969
  28. package/fesm2015/worktile-theia.js.map +1 -1
  29. package/interfaces/auto-format.d.ts +1 -0
  30. package/interfaces/editor.d.ts +14 -1
  31. package/package.json +1 -1
  32. package/plugins/autoformat/autoformat.plugin.d.ts +1 -2
  33. package/plugins/indent/indent.plugin.d.ts +1 -0
  34. package/plugins/indent/on-keydown-indent.d.ts +1 -1
  35. package/plugins/quick-insert/components/quick-toolbar/quick-toolbar.component.d.ts +3 -4
  36. package/plugins/quick-insert/quick-insert.editor.d.ts +3 -4
  37. package/plugins/quick-insert/quick-insert.plugin.d.ts +2 -0
  38. package/plugins/table/components/table.component.scss +43 -42
  39. package/plugins/todo-item/todo-item.component.d.ts +3 -1
  40. package/transforms/index.d.ts +2 -1
  41. package/transforms/insert-element-node.d.ts +2 -0
  42. package/utils/is-clean-empty-paragraph.d.ts +2 -1
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('@angular/forms'), require('slate-angular'), require('ngx-tethys/core'), require('is-hotkey'), require('slate'), require('slate-history'), require('lodash'), require('marked'), require('@atinc/selene'), require('ngx-tethys/popover'), require('@angular/cdk/overlay'), require('ngx-tethys/alert'), require('rxjs/operators'), require('ngx-tethys/uploader'), require('rxjs'), require('@angular/platform-browser'), require('ngx-tethys/progress'), require('ngx-tethys/icon'), require('ngx-tethys/nav'), require('ngx-tethys/tooltip'), require('ngx-tethys/input'), require('ng-codemirror'), require('ngx-tethys/notify'), require('ngx-tethys/action-menu'), require('ngx-tethys/switch'), require('ngx-tethys/resizable'), require('is-url'), require('ngx-tethys/button'), require('ngx-tethys/form'), require('ngx-tethys/shared'), require('ngx-tethys'), require('@angular/cdk/coercion'), require('@angular/cdk/portal'), require('ngx-tethys/list'), require('ngx-tethys/autocomplete'), require('ngx-tethys/avatar'), require('ngx-tethys/select')) :
3
- typeof define === 'function' && define.amd ? define('@worktile/theia', ['exports', '@angular/core', '@angular/common', '@angular/forms', 'slate-angular', 'ngx-tethys/core', 'is-hotkey', 'slate', 'slate-history', 'lodash', 'marked', '@atinc/selene', 'ngx-tethys/popover', '@angular/cdk/overlay', 'ngx-tethys/alert', 'rxjs/operators', 'ngx-tethys/uploader', 'rxjs', '@angular/platform-browser', 'ngx-tethys/progress', 'ngx-tethys/icon', 'ngx-tethys/nav', 'ngx-tethys/tooltip', 'ngx-tethys/input', 'ng-codemirror', 'ngx-tethys/notify', 'ngx-tethys/action-menu', 'ngx-tethys/switch', 'ngx-tethys/resizable', 'is-url', 'ngx-tethys/button', 'ngx-tethys/form', 'ngx-tethys/shared', 'ngx-tethys', '@angular/cdk/coercion', '@angular/cdk/portal', 'ngx-tethys/list', 'ngx-tethys/autocomplete', 'ngx-tethys/avatar', 'ngx-tethys/select'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.worktile = global.worktile || {}, global.worktile.theia = {}), global.ng.core, global.ng.common, global.ng.forms, global.i1, global.core, global.isHotkey, global.slate, global.slateHistory, global._lodash, global.marked, global.selene, global.i1$2, global.ng.cdk.overlay, global.i1$1, global.rxjs.operators, global.uploader, global.rxjs, global.ng.platformBrowser, global.i6, global.i3, global.i3$1, global.i5, global.i5$1, global.i8, global.i1$4, global.i2$1, global.i6$1, global.i9, global.isUrl, global.i1$5, global.i2$2, global.i5$2, global.i1$6, global.ng.cdk.coercion, global.ng.cdk.portal, global.i2$3, global.autocomplete, global.avatar, global.select));
5
- })(this, (function (exports, i0, i10, i4, i1, core, isHotkey, slate, slateHistory, _lodash, marked, selene, i1$2, i2, i1$1, operators, uploader, rxjs, i1$3, i6, i3, i3$1, i5, i5$1, i8, i1$4, i2$1, i6$1, i9, isUrl, i1$5, i2$2, i5$2, i1$6, coercion, portal, i2$3, autocomplete, avatar, select) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('@angular/forms'), require('slate-angular'), require('ngx-tethys/core'), require('is-hotkey'), require('slate'), require('slate-history'), require('marked'), require('@atinc/selene'), require('ngx-tethys/popover'), require('lodash'), require('@angular/cdk/overlay'), require('ngx-tethys/alert'), require('rxjs/operators'), require('ngx-tethys/uploader'), require('rxjs'), require('@angular/platform-browser'), require('ngx-tethys/progress'), require('ngx-tethys/icon'), require('ngx-tethys/nav'), require('ngx-tethys/tooltip'), require('ngx-tethys/input'), require('ng-codemirror'), require('ngx-tethys/notify'), require('ngx-tethys/action-menu'), require('ngx-tethys/switch'), require('ngx-tethys/resizable'), require('is-url'), require('ngx-tethys/button'), require('ngx-tethys/form'), require('ngx-tethys/shared'), require('ngx-tethys'), require('@angular/cdk/coercion'), require('@angular/cdk/portal'), require('ngx-tethys/list'), require('ngx-tethys/autocomplete'), require('ngx-tethys/avatar'), require('ngx-tethys/select')) :
3
+ typeof define === 'function' && define.amd ? define('@worktile/theia', ['exports', '@angular/core', '@angular/common', '@angular/forms', 'slate-angular', 'ngx-tethys/core', 'is-hotkey', 'slate', 'slate-history', 'marked', '@atinc/selene', 'ngx-tethys/popover', 'lodash', '@angular/cdk/overlay', 'ngx-tethys/alert', 'rxjs/operators', 'ngx-tethys/uploader', 'rxjs', '@angular/platform-browser', 'ngx-tethys/progress', 'ngx-tethys/icon', 'ngx-tethys/nav', 'ngx-tethys/tooltip', 'ngx-tethys/input', 'ng-codemirror', 'ngx-tethys/notify', 'ngx-tethys/action-menu', 'ngx-tethys/switch', 'ngx-tethys/resizable', 'is-url', 'ngx-tethys/button', 'ngx-tethys/form', 'ngx-tethys/shared', 'ngx-tethys', '@angular/cdk/coercion', '@angular/cdk/portal', 'ngx-tethys/list', 'ngx-tethys/autocomplete', 'ngx-tethys/avatar', 'ngx-tethys/select'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.worktile = global.worktile || {}, global.worktile.theia = {}), global.ng.core, global.ng.common, global.ng.forms, global.i1, global.core, global.isHotkey, global.slate, global.slateHistory, global.marked, global.selene, global.i1$2, global._lodash, global.ng.cdk.overlay, global.i1$1, global.rxjs.operators, global.uploader, global.rxjs, global.ng.platformBrowser, global.i6, global.i3, global.i3$1, global.i5, global.i5$1, global.i8, global.i1$4, global.i2$1, global.i6$1, global.i9, global.isUrl, global.i1$5, global.i2$2, global.i5$2, global.i1$6, global.ng.cdk.coercion, global.ng.cdk.portal, global.i1$7, global.autocomplete, global.avatar, global.select));
5
+ })(this, (function (exports, i0, i10, i4, i1, core, isHotkey, slate, slateHistory, marked, selene, i1$2, _lodash, i2, i1$1, operators, uploader, rxjs, i1$3, i6, i3, i3$1, i5, i5$1, i8, i1$4, i2$1, i6$1, i9, isUrl, i1$5, i2$2, i5$2, i1$6, coercion, portal, i1$7, autocomplete, avatar, select) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
@@ -29,9 +29,9 @@
29
29
  var i4__namespace = /*#__PURE__*/_interopNamespace(i4);
30
30
  var i1__namespace = /*#__PURE__*/_interopNamespace(i1);
31
31
  var isHotkey__default = /*#__PURE__*/_interopDefaultLegacy(isHotkey);
32
- var _lodash__namespace = /*#__PURE__*/_interopNamespace(_lodash);
33
32
  var marked__default = /*#__PURE__*/_interopDefaultLegacy(marked);
34
33
  var i1__namespace$3 = /*#__PURE__*/_interopNamespace(i1$2);
34
+ var _lodash__namespace = /*#__PURE__*/_interopNamespace(_lodash);
35
35
  var i2__namespace = /*#__PURE__*/_interopNamespace(i2);
36
36
  var i1__namespace$1 = /*#__PURE__*/_interopNamespace(i1$1);
37
37
  var i1__namespace$2 = /*#__PURE__*/_interopNamespace(i1$3);
@@ -50,7 +50,7 @@
50
50
  var i2__namespace$2 = /*#__PURE__*/_interopNamespace(i2$2);
51
51
  var i5__namespace$2 = /*#__PURE__*/_interopNamespace(i5$2);
52
52
  var i1__namespace$6 = /*#__PURE__*/_interopNamespace(i1$6);
53
- var i2__namespace$3 = /*#__PURE__*/_interopNamespace(i2$3);
53
+ var i1__namespace$7 = /*#__PURE__*/_interopNamespace(i1$7);
54
54
 
55
55
  /*! *****************************************************************************
56
56
  Copyright (c) Microsoft Corporation.
@@ -853,6 +853,61 @@
853
853
  return key;
854
854
  }
855
855
 
856
+ var UNDOING = new WeakMap();
857
+ var REDOING = new WeakMap();
858
+ var withTheHistory = function (editor) {
859
+ var undo = editor.undo, redo = editor.redo;
860
+ editor.undo = function () {
861
+ UNDOING.set(editor, true);
862
+ undo();
863
+ UNDOING.set(editor, false);
864
+ };
865
+ editor.redo = function () {
866
+ REDOING.set(editor, true);
867
+ redo();
868
+ REDOING.set(editor, false);
869
+ };
870
+ return editor;
871
+ };
872
+ var TheHistoryEditor = {
873
+ isUndoing: function (editor) {
874
+ return UNDOING.get(editor);
875
+ },
876
+ isRedoing: function (editor) {
877
+ return REDOING.get(editor);
878
+ }
879
+ };
880
+
881
+ var setMarks = function (editor, marks, at) {
882
+ slate.Transforms.setNodes(editor, marks, {
883
+ at: at,
884
+ match: slate.Text.isText,
885
+ split: true
886
+ });
887
+ };
888
+
889
+ var clearMarks = function (editor) {
890
+ var selection = editor.selection;
891
+ if (!selection) {
892
+ return;
893
+ }
894
+ if (slate.Range.isCollapsed(selection)) {
895
+ var marks = slate.Editor.marks(editor);
896
+ for (var key in marks) {
897
+ slate.Editor.removeMark(editor, key);
898
+ }
899
+ }
900
+ else {
901
+ var unsetMarks_1 = {};
902
+ MarkProps.forEach(function (key) {
903
+ unsetMarks_1[key] = null;
904
+ });
905
+ setMarks(editor, unsetMarks_1);
906
+ }
907
+ };
908
+
909
+ var insertElement = function (editor, element) { return editor.insertElement(element); };
910
+
856
911
  var isAncestor = function (node) { return slate.Element.isElement(node) || slate.Editor.isEditor(node); };
857
912
 
858
913
  var getLastChild$1 = function (node, level) {
@@ -1720,36 +1775,6 @@
1720
1775
  someNode: someNode
1721
1776
  });
1722
1777
 
1723
- var setMarks = function (editor, marks, at) {
1724
- slate.Transforms.setNodes(editor, marks, {
1725
- at: at,
1726
- match: slate.Text.isText,
1727
- split: true
1728
- });
1729
- };
1730
-
1731
- var clearMarks = function (editor) {
1732
- var selection = editor.selection;
1733
- if (!selection) {
1734
- return;
1735
- }
1736
- if (slate.Range.isCollapsed(selection)) {
1737
- var marks = slate.Editor.marks(editor);
1738
- for (var key in marks) {
1739
- slate.Editor.removeMark(editor, key);
1740
- }
1741
- }
1742
- else {
1743
- var unsetMarks_1 = {};
1744
- MarkProps.forEach(function (key) {
1745
- unsetMarks_1[key] = null;
1746
- });
1747
- setMarks(editor, unsetMarks_1);
1748
- }
1749
- };
1750
-
1751
- var insertElement = function (editor, element) { return editor.insertElement(element); };
1752
-
1753
1778
  var insertElementNext = function (editor, node) {
1754
1779
  if (slate.Range.isExpanded(editor.selection)) {
1755
1780
  slate.Editor.deleteFragment(editor);
@@ -1970,6 +1995,40 @@
1970
1995
  return false;
1971
1996
  }
1972
1997
 
1998
+ var insertElementNode = function (editor, node) {
1999
+ if (slate.Range.isExpanded(editor.selection)) {
2000
+ slate.Editor.deleteFragment(editor);
2001
+ }
2002
+ var isBlockCardCursor$1 = isBlockCardCursor(editor);
2003
+ var containerBlocks = getContainerBlocks(editor);
2004
+ var isContainer = isNodeTypeIn(editor, containerBlocks, { at: editor.selection });
2005
+ var _a = __read(anchorBlockEntry(editor), 2), anchorBlock = _a[0], anchorBlockPath = _a[1];
2006
+ var isEmpty = slate.Editor.isEmpty(editor, anchorBlock);
2007
+ if (isContainer && !isBlockCardCursor$1) {
2008
+ var _b = __read(slate.Editor.above(editor, {
2009
+ match: function (n) { return slate.Editor.isBlock(editor, n) && containerBlocks.includes(n.type); },
2010
+ at: editor.selection
2011
+ }), 2), containerPath_1 = _b[1];
2012
+ slate.Editor.withoutNormalizing(editor, function () {
2013
+ var containerPathFirstPath = anchorBlockPath.slice(0, containerPath_1.length + 1);
2014
+ slate.Transforms.insertNodes(editor, node, { at: slate.Path.next(containerPathFirstPath), select: true });
2015
+ if (isEmpty) {
2016
+ slate.Transforms.removeNodes(editor, { at: anchorBlockPath });
2017
+ }
2018
+ });
2019
+ return;
2020
+ }
2021
+ var nextPath = slate.Path.next([anchorBlockPath[0]]);
2022
+ slate.Transforms.insertNodes(editor, node, { at: nextPath });
2023
+ if (isEmpty && anchorBlockPath.length === 1) {
2024
+ slate.Transforms.delete(editor, { at: anchorBlockPath });
2025
+ slate.Transforms.select(editor, slate.Editor.start(editor, anchorBlockPath));
2026
+ }
2027
+ else {
2028
+ slate.Transforms.select(editor, slate.Editor.start(editor, nextPath));
2029
+ }
2030
+ };
2031
+
1973
2032
  var index = /*#__PURE__*/Object.freeze({
1974
2033
  __proto__: null,
1975
2034
  setMarks: setMarks,
@@ -1989,591 +2048,158 @@
1989
2048
  setEndSelection: setEndSelection,
1990
2049
  closeConversionHint: closeConversionHint,
1991
2050
  handleContinualDeleteBackward: handleContinualDeleteBackward,
1992
- handleContinualInsertBreak: handleContinualInsertBreak
2051
+ handleContinualInsertBreak: handleContinualInsertBreak,
2052
+ insertElementNode: insertElementNode
1993
2053
  });
1994
2054
 
1995
- var isNodeTypeList = function (n) {
1996
- return [exports.ElementKinds.bulletedList, exports.ElementKinds.numberedList].includes(n.type);
1997
- };
1998
-
1999
- var ListEditor = {
2000
- isList: function (editor, element, type) {
2001
- return slate.Editor.isBlock(editor, element) && element.type === type;
2002
- },
2003
- toggleList: function (editor, type, startIndex) {
2004
- var _this = this;
2005
- if (!editor.selection) {
2006
- return;
2055
+ var TheConversionHintComponent = /** @class */ (function () {
2056
+ function TheConversionHintComponent() {
2057
+ this.duration = 10000;
2058
+ this.pauseOnHover = true;
2059
+ }
2060
+ TheConversionHintComponent.prototype.mouseenter = function () {
2061
+ if (this.pauseOnHover) {
2062
+ this.clearCloseTimer();
2007
2063
  }
2008
- if (!startIndex) {
2009
- startIndex = 1;
2064
+ };
2065
+ TheConversionHintComponent.prototype.mouseleave = function () {
2066
+ if (this.pauseOnHover) {
2067
+ this.creatCloseTimer();
2010
2068
  }
2011
- var types = [exports.ElementKinds.bulletedList, exports.ElementKinds.numberedList];
2012
- slate.Editor.withoutNormalizing(editor, function () {
2013
- var _a = __read(slate.Editor.nodes(editor, {
2014
- match: function (node) { return slate.Element.isElement(node) && node.type === exports.ElementKinds.listItem; },
2015
- mode: 'lowest'
2016
- })), listItems = _a.slice(0);
2017
- var firstListItemPath = listItems.length && listItems[0][1];
2018
- var activeListPath = listItems.length && slate.Path.parent(firstListItemPath);
2019
- var activeListNode = listItems.length && slate.Node.get(editor, activeListPath);
2020
- // 同级且类型相同:unwrap
2021
- var isLowestActive = listItems.length &&
2022
- listItems.every(function (_a) {
2023
- var _b = __read(_a, 2), path = _b[1];
2024
- return activeListNode.type === type && (slate.Path.isSibling(firstListItemPath, path) || slate.Path.equals(firstListItemPath, path));
2025
- });
2026
- if (isLowestActive) {
2027
- var upListItem = slate.Path.parent(activeListPath);
2028
- slate.Transforms.unwrapNodes(editor, {
2029
- at: editor.selection,
2030
- match: function (node) { return node === activeListNode; },
2031
- split: true,
2032
- mode: 'lowest'
2033
- });
2034
- if (upListItem && slate.Node.get(editor, upListItem).type === exports.ElementKinds.listItem) {
2035
- slate.Transforms.moveNodes(editor, {
2036
- at: editor.selection,
2037
- to: slate.Path.next(upListItem),
2038
- match: function (node) { return slate.Element.isElement(node) && node.type === exports.ElementKinds.listItem; }
2039
- });
2040
- }
2041
- else {
2042
- slate.Transforms.unwrapNodes(editor, {
2043
- match: function (node) { return slate.Element.isElement(node) && node.type === exports.ElementKinds.listItem; }
2044
- });
2069
+ };
2070
+ TheConversionHintComponent.prototype.ngOnInit = function () {
2071
+ this.creatCloseTimer();
2072
+ };
2073
+ TheConversionHintComponent.prototype.ngOnDestroy = function () {
2074
+ this.clearCloseTimer();
2075
+ };
2076
+ TheConversionHintComponent.prototype.creatCloseTimer = function () {
2077
+ var _this = this;
2078
+ this.closeTimer = setInterval(function () {
2079
+ clearInterval(_this.closeTimer);
2080
+ closeConversionHint(_this.editor);
2081
+ }, this.duration);
2082
+ };
2083
+ TheConversionHintComponent.prototype.clearCloseTimer = function () {
2084
+ clearInterval(this.closeTimer);
2085
+ };
2086
+ return TheConversionHintComponent;
2087
+ }());
2088
+ TheConversionHintComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TheConversionHintComponent, deps: [], target: i0__namespace.ɵɵFactoryTarget.Component });
2089
+ TheConversionHintComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.15", type: TheConversionHintComponent, selector: "the-conversion-hint", inputs: { editor: "editor", conversion: "conversion" }, host: { listeners: { "mouseenter": "mouseenter()", "mouseleave": "mouseleave()" }, classAttribute: "the-conversion-hint" }, ngImport: i0__namespace, template: "<ng-container>\n <thy-alert\n thyType=\"primary-weak\"\n thyIcon=\"info-circle-fill\"\n thyCloseable=\"true\"\n thyMessage=\"\u68C0\u6D4B\u5230\u7C98\u8D34\u5185\u5BB9\u7B26\u5408Markdown\u8BED\u6CD5\"\n >\n <ng-template #operation>\n <a href=\"javascript:;\" thyAlertActionItem (click)=\"conversion()\">\n \u7ACB\u5373\u8F6C\u6362\n </a>\n </ng-template>\n </thy-alert>\n</ng-container>\n", components: [{ type: i1__namespace$1.ThyAlertComponent, selector: "thy-alert", inputs: ["thyType", "thyMessage", "thyIcon", "thyCloseable"] }], directives: [{ type: i1__namespace$1.ThyAlertActionItemDirective, selector: "[thyAlertActionItem]" }], changeDetection: i0__namespace.ChangeDetectionStrategy.OnPush });
2090
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TheConversionHintComponent, decorators: [{
2091
+ type: i0.Component,
2092
+ args: [{
2093
+ selector: 'the-conversion-hint',
2094
+ templateUrl: 'conversion-hint.component.html',
2095
+ host: {
2096
+ class: 'the-conversion-hint'
2097
+ },
2098
+ changeDetection: i0.ChangeDetectionStrategy.OnPush
2099
+ }]
2100
+ }], propDecorators: { editor: [{
2101
+ type: i0.Input
2102
+ }], conversion: [{
2103
+ type: i0.Input
2104
+ }], mouseenter: [{
2105
+ type: i0.HostListener,
2106
+ args: ['mouseenter']
2107
+ }], mouseleave: [{
2108
+ type: i0.HostListener,
2109
+ args: ['mouseleave']
2110
+ }] } });
2111
+
2112
+ function plainToTheia(text) {
2113
+ if (typeof text !== 'string') {
2114
+ return text;
2115
+ }
2116
+ return text.split('\n').map(function (i) {
2117
+ return {
2118
+ type: exports.ElementKinds.paragraph,
2119
+ children: [
2120
+ {
2121
+ text: i
2045
2122
  }
2046
- return;
2047
- }
2048
- // 跨级、同级且类型不同
2049
- if (activeListNode && types.includes(activeListNode.type)) {
2050
- slate.Transforms.setNodes(editor, { type: type }, { match: function (node) { return slate.Element.isElement(node) && node.type !== type && types.includes(node.type); } });
2051
- return;
2052
- }
2053
- // wrap
2054
- _this.buildListItem(editor);
2055
- // Todo: types
2056
- slate.Transforms.wrapNodes(editor, { type: type, children: [], start: startIndex }, {
2057
- at: editor.selection,
2058
- match: function (node) { return slate.Element.isElement(node) && node.type === exports.ElementKinds.listItem; }
2059
- });
2060
- });
2061
- },
2062
- unwrapList: function (editor) {
2063
- slate.Editor.withoutNormalizing(editor, function () {
2064
- unwrapNodesByType(editor, [exports.ElementKinds.bulletedList, exports.ElementKinds.numberedList], { split: true, mode: 'all' });
2065
- unwrapNodesByType(editor, [exports.ElementKinds.listItem], { split: true, mode: 'all' });
2066
- });
2067
- },
2068
- wrapList: function (editor, type) {
2069
- slate.Editor.withoutNormalizing(editor, function () {
2070
- var listItem = {
2071
- type: exports.ElementKinds.listItem,
2072
- children: []
2073
- };
2074
- var list = {
2075
- type: type,
2076
- children: []
2077
- };
2078
- slate.Transforms.wrapNodes(editor, list, { split: true });
2079
- slate.Transforms.wrapNodes(editor, listItem, { split: true });
2080
- });
2081
- },
2082
- isActive: function (editor, type) {
2083
- var _a = __read(getNodesByType(editor, type), 1), match = _a[0];
2084
- return !!match;
2085
- },
2086
- getActiveList: function (editor) {
2087
- var _a = __read(getNodesByType(editor, LIST_BLOCK_TYPES), 1), match = _a[0];
2088
- return match;
2089
- },
2090
- buildListItem: function (editor) {
2091
- var e_1, _a;
2092
- var nodes = slate.Editor.nodes(editor, {
2093
- match: function (node) { return slate.Editor.isBlock(editor, node); },
2094
- mode: 'lowest'
2095
- });
2096
- try {
2097
- for (var nodes_1 = __values(nodes), nodes_1_1 = nodes_1.next(); !nodes_1_1.done; nodes_1_1 = nodes_1.next()) {
2098
- var _b = __read(nodes_1_1.value, 2), node = _b[0], path = _b[1];
2099
- if (!slate.Editor.isVoid(editor, node) && slate.Element.isElement(node) && node.type !== exports.ElementKinds.paragraph) {
2100
- slate.Transforms.setNodes(editor, { type: exports.ElementKinds.paragraph, checked: undefined }, // todo remove checked
2101
- { at: path });
2102
- }
2103
- else if (slate.Element.isElement(node) && node.type === exports.ElementKinds.paragraph) {
2104
- var textIndent = node.textIndent;
2105
- if (textIndent) {
2106
- slate.Transforms.setNodes(editor, { textIndent: undefined, indent: undefined }, // remove indent
2107
- { at: path });
2108
- }
2109
- }
2110
- if (slate.Node.parent(editor, path).type !== exports.ElementKinds.listItem) {
2111
- slate.Transforms.wrapNodes(editor, { type: exports.ElementKinds.listItem, children: [] }, {
2112
- at: path,
2113
- split: true
2114
- });
2115
- }
2116
- }
2117
- }
2118
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
2119
- finally {
2120
- try {
2121
- if (nodes_1_1 && !nodes_1_1.done && (_a = nodes_1.return)) _a.call(nodes_1);
2122
- }
2123
- finally { if (e_1) throw e_1.error; }
2124
- }
2125
- },
2126
- buildInsertDataChildren: function (node) {
2127
- var children = node.children;
2128
- var listItem = children[0];
2129
- if (isNodeTypeList(node) && slate.Element.isElement(listItem) && listItem.children[0].type === exports.ElementKinds.paragraph) {
2130
- return node;
2131
- }
2132
- return this.buildInsertDataChildren(listItem);
2123
+ ]
2124
+ };
2125
+ });
2126
+ }
2127
+ function htmlToTheia(value) {
2128
+ if (typeof value === 'string') {
2129
+ var htmlDom = new DOMParser().parseFromString(value, 'text/html');
2130
+ return selene.TheiaConverter.convertToTheia(Array.from(htmlDom.body.children));
2133
2131
  }
2134
- };
2135
-
2136
- var TodoItemEditor = {
2137
- isActive: function (editor) {
2138
- var _a = __read(getNodesByType(editor, exports.ElementKinds.checkItem), 1), match = _a[0];
2139
- return !!match;
2140
- },
2141
- insertTodoItem: function (editor) {
2142
- if (!editor.selection) {
2143
- return;
2144
- }
2145
- var isActive = this.isActive(editor);
2146
- var isNumberedList = ListEditor.isActive(editor, exports.ElementKinds.numberedList);
2147
- var isBulletedList = ListEditor.isActive(editor, exports.ElementKinds.bulletedList);
2148
- if (isActive) {
2149
- slate.Transforms.setNodes(editor, {
2150
- type: exports.ElementKinds.paragraph
2151
- });
2132
+ return value;
2133
+ }
2134
+ function dataDeserialize(mode, value) {
2135
+ if (!value) {
2136
+ return [createEmptyParagraph()];
2137
+ }
2138
+ if (mode === exports.TheDataMode.html) {
2139
+ if (typeof value !== 'string') {
2140
+ return value;
2152
2141
  }
2153
- else {
2154
- if (isNumberedList || isBulletedList) {
2155
- ListEditor.unwrapList(editor);
2156
- }
2157
- slate.Transforms.setNodes(editor, {
2158
- type: exports.ElementKinds.checkItem
2159
- });
2142
+ if (/<[^>]+>/.test(value)) {
2143
+ return htmlToTheia(value);
2160
2144
  }
2145
+ return plainToTheia(value);
2146
+ }
2147
+ return value || [createEmptyParagraph()];
2148
+ }
2149
+ function dataSerializing(mode, value) {
2150
+ if (mode === exports.TheDataMode.html) {
2151
+ return selene.TheiaConverter.convertToHtml(value);
2161
2152
  }
2153
+ return value;
2154
+ }
2155
+
2156
+ var getEditorUUID = function (editor) {
2157
+ return THE_EDITOR_UUID.get(editor);
2158
+ };
2159
+ var setEditorUUID = function (editor, uuid) {
2160
+ THE_EDITOR_UUID.set(editor, uuid);
2162
2161
  };
2163
2162
 
2164
- var BlockquoteEditor = {
2165
- toggleBlockquote: function (editor) {
2166
- if (!isParagraph(editor)) {
2167
- slate.Transforms.insertNodes(editor, {
2168
- type: exports.ElementKinds.paragraph,
2169
- mode: 'text',
2170
- children: [
2171
- {
2172
- text: ''
2173
- }
2174
- ]
2175
- });
2176
- }
2177
- var isActive = isBlockActive(editor, exports.ElementKinds.blockquote);
2178
- if (!isActive) {
2179
- slate.Transforms.wrapNodes(editor, { type: exports.ElementKinds.blockquote, children: [] }, {
2180
- mode: 'lowest'
2181
- });
2182
- }
2183
- else {
2184
- slate.Transforms.unwrapNodes(editor, { match: function (n) { return slate.Element.isElement(n) && n.type === exports.ElementKinds.blockquote; } });
2185
- }
2186
- }
2163
+ var getToolbarClass = function (editor) {
2164
+ var uuid = getEditorUUID(editor);
2165
+ return "the-toolbar-" + uuid;
2187
2166
  };
2188
2167
 
2189
- var InlineCodeEditor = {
2190
- toggleInlineCode: function (editor, text) {
2191
- var isActive = InlineCodeEditor.isInlineCodeActive(editor);
2192
- if (isActive) {
2193
- InlineCodeEditor.unwrapInlineCode(editor);
2194
- return;
2195
- }
2196
- if (slate.Range.isCollapsed(editor.selection)) {
2197
- InlineCodeEditor.wrapInlineCode(editor, text);
2198
- }
2199
- else {
2200
- var fragment = slate.Node.fragment(editor, editor.selection)[0];
2201
- var selectNode = slate.Node.get(fragment, []);
2202
- var selectText = slate.Node.string(selectNode);
2203
- InlineCodeEditor.wrapInlineCode(editor, selectText);
2204
- }
2205
- },
2206
- wrapInlineCode: function (editor, text) {
2207
- if (text === void 0) { text = ''; }
2208
- if (InlineCodeEditor.isInlineCodeActive(editor)) {
2209
- InlineCodeEditor.unwrapInlineCode(editor);
2210
- }
2211
- var selection = editor.selection;
2212
- var isCollapsed = selection && slate.Range.isCollapsed(selection);
2213
- var inlineCode = {
2214
- type: exports.ElementKinds.inlineCode,
2215
- children: isCollapsed ? [{ text: text ? text : ZERO_WIDTH_CHAR }] : []
2216
- };
2217
- if (isCollapsed) {
2218
- slate.Transforms.insertNodes(editor, inlineCode);
2219
- }
2220
- else {
2221
- slate.Transforms.wrapNodes(editor, inlineCode, { split: true });
2222
- }
2223
- },
2224
- unwrapInlineCode: function (editor) {
2225
- slate.Transforms.unwrapNodes(editor, { match: function (n) { return slate.Element.isElement(n) && n.type === exports.ElementKinds.inlineCode; } });
2226
- },
2227
- isInlineCodeActive: function (editor, path) {
2228
- var _a;
2229
- var _b = __read(slate.Editor.nodes(editor, {
2230
- at: path ? path : (_a = editor.selection) === null || _a === void 0 ? void 0 : _a.anchor.path,
2231
- match: function (n) { return slate.Element.isElement(n) && n.type === exports.ElementKinds.inlineCode; }
2232
- }), 1), inlineCode = _b[0];
2233
- return !!inlineCode;
2168
+ var IS_MAC = typeof window != 'undefined' && /Mac|iPod|iPhone|iPad/.test(window.navigator.platform);
2169
+ var CONTROL_KEY = IS_MAC ? '⌘' : 'Ctrl';
2170
+
2171
+ /**
2172
+ * whether the current node is a clean paragraph
2173
+ * @param editor
2174
+ * @param text
2175
+ * @returns boolean
2176
+ */
2177
+ var isCleanEmptyParagraph = function (editor) {
2178
+ var isCollapsedCursor = TheEditor.isFocused(editor) && editor.selection && slate.Range.isCollapsed(editor.selection);
2179
+ if (!isCollapsedCursor) {
2180
+ return false;
2234
2181
  }
2182
+ var block = slate.Node.ancestor(editor, [editor.selection.anchor.path[0]]);
2183
+ return isPureEmptyParagraph(editor, block);
2235
2184
  };
2236
-
2237
- var HeadingEditor = {
2238
- setHeading: function (editor, heading) {
2239
- slate.Editor.withoutNormalizing(editor, function () {
2240
- var _a;
2241
- var types = [exports.ElementKinds.bulletedList, exports.ElementKinds.numberedList, exports.ElementKinds.listItem];
2242
- slate.Transforms.unwrapNodes(editor, {
2243
- at: editor.selection,
2244
- match: function (n) { return slate.Element.isElement(n) && types.includes(n.type); },
2245
- mode: 'all',
2246
- split: true
2247
- });
2248
- slate.Transforms.setNodes(editor, { type: heading });
2249
- var entry = anchorBlockEntry(editor);
2250
- var unMarks = (_a = {},
2251
- _a[exports.MarkTypes.fontSize] = null,
2252
- _a);
2253
- if (entry) {
2254
- setMarks(editor, unMarks, entry[1]);
2255
- return;
2256
- }
2257
- setMarks(editor, unMarks, editor.selection);
2258
- });
2259
- },
2260
- isHeadingActive: function (editor, heading) {
2261
- var _a = __read(slate.Editor.nodes(editor, {
2262
- match: function (n) { return slate.Element.isElement(n) && n.type === heading; },
2263
- universal: true
2264
- }), 1), match = _a[0];
2265
- return !!match;
2185
+ var isPureEmptyParagraph = function (editor, block) {
2186
+ var textIndent = 'textIndent';
2187
+ var align = 'align';
2188
+ var hasTextIndent = block[textIndent];
2189
+ var alignValue = block[align];
2190
+ var hasIndent = block[exports.ElementKinds.indent];
2191
+ if (slate.Node.string(block) === '' &&
2192
+ slate.Element.isElement(block) &&
2193
+ block.type === exports.ElementKinds.paragraph &&
2194
+ block.children.length === 1 &&
2195
+ slate.Text.isText(block.children[0]) &&
2196
+ !slate.Editor.isVoid(editor, block) &&
2197
+ !hasIndent &&
2198
+ !hasTextIndent &&
2199
+ (!alignValue || alignValue === exports.Alignment.left)) {
2200
+ return true;
2266
2201
  }
2267
- };
2268
-
2269
- var autoFormatRules = [
2270
- {
2271
- type: exports.ElementKinds.heading_1,
2272
- markup: '#',
2273
- format: function (editor) {
2274
- HeadingEditor.setHeading(editor, exports.ElementKinds.heading_1);
2275
- }
2276
- },
2277
- {
2278
- type: exports.ElementKinds.heading_2,
2279
- markup: '##',
2280
- format: function (editor) {
2281
- HeadingEditor.setHeading(editor, exports.ElementKinds.heading_2);
2282
- }
2283
- },
2284
- {
2285
- type: exports.ElementKinds.heading_3,
2286
- markup: '###',
2287
- format: function (editor) {
2288
- HeadingEditor.setHeading(editor, exports.ElementKinds.heading_3);
2289
- }
2290
- },
2291
- {
2292
- type: exports.ElementKinds.heading_4,
2293
- markup: '####',
2294
- format: function (editor) {
2295
- HeadingEditor.setHeading(editor, exports.ElementKinds.heading_4);
2296
- }
2297
- },
2298
- {
2299
- type: exports.ElementKinds.heading_5,
2300
- markup: '#####',
2301
- format: function (editor) {
2302
- HeadingEditor.setHeading(editor, exports.ElementKinds.heading_5);
2303
- }
2304
- },
2305
- {
2306
- type: exports.ElementKinds.heading_6,
2307
- markup: '######',
2308
- format: function (editor) {
2309
- HeadingEditor.setHeading(editor, exports.ElementKinds.heading_6);
2310
- }
2311
- },
2312
- {
2313
- type: exports.ElementKinds.blockquote,
2314
- markup: ['>'],
2315
- format: function (editor) {
2316
- BlockquoteEditor.toggleBlockquote(editor);
2317
- }
2318
- },
2319
- {
2320
- type: exports.MarkTypes.bold,
2321
- between: ['**', '**'],
2322
- mode: 'inline',
2323
- insertTrigger: true
2324
- },
2325
- {
2326
- type: exports.MarkTypes.bold,
2327
- between: ['__', '__'],
2328
- mode: 'inline',
2329
- insertTrigger: true
2330
- },
2331
- {
2332
- type: exports.MarkTypes.italic,
2333
- between: ['*', '*'],
2334
- mode: 'inline',
2335
- insertTrigger: true
2336
- },
2337
- {
2338
- type: exports.MarkTypes.italic,
2339
- between: ['_', '_'],
2340
- mode: 'inline',
2341
- insertTrigger: true
2342
- },
2343
- {
2344
- type: exports.ElementKinds.inlineCode,
2345
- between: ['`', '`'],
2346
- mode: 'inline',
2347
- format: function (editor, text) {
2348
- InlineCodeEditor.toggleInlineCode(editor, text);
2349
- slate.Transforms.select(editor, slate.Editor.after(editor, editor.selection));
2350
- }
2351
- },
2352
- {
2353
- type: exports.MarkTypes.strike,
2354
- between: ['~~', '~~'],
2355
- mode: 'inline',
2356
- insertTrigger: true
2357
- },
2358
- {
2359
- type: exports.ElementKinds.code,
2360
- markup: '```',
2361
- insertTrigger: true
2362
- },
2363
- {
2364
- type: exports.ElementKinds.listItem,
2365
- markup: [],
2366
- match: function (editor) {
2367
- return isParagraph(editor) ? ['*', '-', '+'] : [];
2368
- },
2369
- format: function (editor) {
2370
- ListEditor.toggleList(editor, exports.ElementKinds.bulletedList);
2371
- }
2372
- },
2373
- {
2374
- type: exports.ElementKinds.listItem,
2375
- markup: [],
2376
- match: function (editor, textFromBlockStart) {
2377
- return isParagraph(editor) && /^-?\d+(\.|\))$/.test(textFromBlockStart) ? [textFromBlockStart] : [];
2378
- },
2379
- format: function (editor, markup) {
2380
- var startIndex = 1;
2381
- if (markup) {
2382
- startIndex = markup[0].split('.')[0];
2383
- if (startIndex === 0) {
2384
- startIndex = 1;
2385
- }
2386
- }
2387
- ListEditor.toggleList(editor, exports.ElementKinds.numberedList, startIndex);
2388
- }
2389
- },
2390
- {
2391
- type: exports.ElementKinds.checkItem,
2392
- markup: [],
2393
- match: function (editor) {
2394
- return isParagraph(editor) ? ['[]'] : [];
2395
- },
2396
- format: function (editor) {
2397
- TodoItemEditor.insertTodoItem(editor);
2398
- }
2399
- },
2400
- {
2401
- type: exports.ElementKinds.hr,
2402
- markup: '---',
2403
- insertTrigger: true
2404
- }
2405
- ];
2406
-
2407
- var UNDOING = new WeakMap();
2408
- var REDOING = new WeakMap();
2409
- var withTheHistory = function (editor) {
2410
- var undo = editor.undo, redo = editor.redo;
2411
- editor.undo = function () {
2412
- UNDOING.set(editor, true);
2413
- undo();
2414
- UNDOING.set(editor, false);
2415
- };
2416
- editor.redo = function () {
2417
- REDOING.set(editor, true);
2418
- redo();
2419
- REDOING.set(editor, false);
2420
- };
2421
- return editor;
2422
- };
2423
- var TheHistoryEditor = {
2424
- isUndoing: function (editor) {
2425
- return UNDOING.get(editor);
2426
- },
2427
- isRedoing: function (editor) {
2428
- return REDOING.get(editor);
2429
- }
2430
- };
2431
-
2432
- var TheConversionHintComponent = /** @class */ (function () {
2433
- function TheConversionHintComponent() {
2434
- this.duration = 10000;
2435
- this.pauseOnHover = true;
2436
- }
2437
- TheConversionHintComponent.prototype.mouseenter = function () {
2438
- if (this.pauseOnHover) {
2439
- this.clearCloseTimer();
2440
- }
2441
- };
2442
- TheConversionHintComponent.prototype.mouseleave = function () {
2443
- if (this.pauseOnHover) {
2444
- this.creatCloseTimer();
2445
- }
2446
- };
2447
- TheConversionHintComponent.prototype.ngOnInit = function () {
2448
- this.creatCloseTimer();
2449
- };
2450
- TheConversionHintComponent.prototype.ngOnDestroy = function () {
2451
- this.clearCloseTimer();
2452
- };
2453
- TheConversionHintComponent.prototype.creatCloseTimer = function () {
2454
- var _this = this;
2455
- this.closeTimer = setInterval(function () {
2456
- clearInterval(_this.closeTimer);
2457
- closeConversionHint(_this.editor);
2458
- }, this.duration);
2459
- };
2460
- TheConversionHintComponent.prototype.clearCloseTimer = function () {
2461
- clearInterval(this.closeTimer);
2462
- };
2463
- return TheConversionHintComponent;
2464
- }());
2465
- TheConversionHintComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TheConversionHintComponent, deps: [], target: i0__namespace.ɵɵFactoryTarget.Component });
2466
- TheConversionHintComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.15", type: TheConversionHintComponent, selector: "the-conversion-hint", inputs: { editor: "editor", conversion: "conversion" }, host: { listeners: { "mouseenter": "mouseenter()", "mouseleave": "mouseleave()" }, classAttribute: "the-conversion-hint" }, ngImport: i0__namespace, template: "<ng-container>\n <thy-alert\n thyType=\"primary-weak\"\n thyIcon=\"info-circle-fill\"\n thyCloseable=\"true\"\n thyMessage=\"\u68C0\u6D4B\u5230\u7C98\u8D34\u5185\u5BB9\u7B26\u5408Markdown\u8BED\u6CD5\"\n >\n <ng-template #operation>\n <a href=\"javascript:;\" thyAlertActionItem (click)=\"conversion()\">\n \u7ACB\u5373\u8F6C\u6362\n </a>\n </ng-template>\n </thy-alert>\n</ng-container>\n", components: [{ type: i1__namespace$1.ThyAlertComponent, selector: "thy-alert", inputs: ["thyType", "thyMessage", "thyIcon", "thyCloseable"] }], directives: [{ type: i1__namespace$1.ThyAlertActionItemDirective, selector: "[thyAlertActionItem]" }], changeDetection: i0__namespace.ChangeDetectionStrategy.OnPush });
2467
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TheConversionHintComponent, decorators: [{
2468
- type: i0.Component,
2469
- args: [{
2470
- selector: 'the-conversion-hint',
2471
- templateUrl: 'conversion-hint.component.html',
2472
- host: {
2473
- class: 'the-conversion-hint'
2474
- },
2475
- changeDetection: i0.ChangeDetectionStrategy.OnPush
2476
- }]
2477
- }], propDecorators: { editor: [{
2478
- type: i0.Input
2479
- }], conversion: [{
2480
- type: i0.Input
2481
- }], mouseenter: [{
2482
- type: i0.HostListener,
2483
- args: ['mouseenter']
2484
- }], mouseleave: [{
2485
- type: i0.HostListener,
2486
- args: ['mouseleave']
2487
- }] } });
2488
-
2489
- function plainToTheia(text) {
2490
- if (typeof text !== 'string') {
2491
- return text;
2492
- }
2493
- return text.split('\n').map(function (i) {
2494
- return {
2495
- type: exports.ElementKinds.paragraph,
2496
- children: [
2497
- {
2498
- text: i
2499
- }
2500
- ]
2501
- };
2502
- });
2503
- }
2504
- function htmlToTheia(value) {
2505
- if (typeof value === 'string') {
2506
- var htmlDom = new DOMParser().parseFromString(value, 'text/html');
2507
- return selene.TheiaConverter.convertToTheia(Array.from(htmlDom.body.children));
2508
- }
2509
- return value;
2510
- }
2511
- function dataDeserialize(mode, value) {
2512
- if (!value) {
2513
- return [createEmptyParagraph()];
2514
- }
2515
- if (mode === exports.TheDataMode.html) {
2516
- if (typeof value !== 'string') {
2517
- return value;
2518
- }
2519
- if (/<[^>]+>/.test(value)) {
2520
- return htmlToTheia(value);
2521
- }
2522
- return plainToTheia(value);
2523
- }
2524
- return value || [createEmptyParagraph()];
2525
- }
2526
- function dataSerializing(mode, value) {
2527
- if (mode === exports.TheDataMode.html) {
2528
- return selene.TheiaConverter.convertToHtml(value);
2529
- }
2530
- return value;
2531
- }
2532
-
2533
- var getEditorUUID = function (editor) {
2534
- return THE_EDITOR_UUID.get(editor);
2535
- };
2536
- var setEditorUUID = function (editor, uuid) {
2537
- THE_EDITOR_UUID.set(editor, uuid);
2538
- };
2539
-
2540
- var getToolbarClass = function (editor) {
2541
- var uuid = getEditorUUID(editor);
2542
- return "the-toolbar-" + uuid;
2543
- };
2544
-
2545
- var IS_MAC = typeof window != 'undefined' && /Mac|iPod|iPhone|iPad/.test(window.navigator.platform);
2546
- var CONTROL_KEY = IS_MAC ? '⌘' : 'Ctrl';
2547
-
2548
- /**
2549
- * whether the current node is a clean paragraph
2550
- * @param editor
2551
- * @param text
2552
- * @returns boolean
2553
- */
2554
- var isCleanEmptyParagraph = function (editor) {
2555
- var isCollapsedCursor = TheEditor.isFocused(editor) && editor.selection && slate.Range.isCollapsed(editor.selection);
2556
- if (!isCollapsedCursor) {
2557
- return false;
2558
- }
2559
- var block = slate.Node.ancestor(editor, [editor.selection.anchor.path[0]]);
2560
- var textIndent = 'textIndent';
2561
- var align = 'align';
2562
- var hasTextIndent = block[textIndent];
2563
- var alignValue = block[align];
2564
- var hasIndent = block[exports.ElementKinds.indent];
2565
- if (slate.Node.string(block) === '' &&
2566
- slate.Element.isElement(block) &&
2567
- block.type === exports.ElementKinds.paragraph &&
2568
- block.children.length === 1 &&
2569
- slate.Text.isText(block.children[0]) &&
2570
- !slate.Editor.isVoid(editor, block) &&
2571
- !hasIndent &&
2572
- !hasTextIndent &&
2573
- (!alignValue || alignValue === exports.Alignment.left)) {
2574
- return true;
2575
- }
2576
- return false;
2202
+ return false;
2577
2203
  };
2578
2204
 
2579
2205
  var mergeElementOptions = function (elementOptions) {
@@ -3537,6 +3163,10 @@
3537
3163
  return listItemNode.children.length === 1 && type === exports.ElementKinds.paragraph;
3538
3164
  };
3539
3165
 
3166
+ var isNodeTypeList = function (n) {
3167
+ return [exports.ElementKinds.bulletedList, exports.ElementKinds.numberedList].includes(n.type);
3168
+ };
3169
+
3540
3170
  /**
3541
3171
  * list 中 是否是单个listItem,且listItem没有子列表
3542
3172
  */
@@ -4452,10 +4082,11 @@
4452
4082
 
4453
4083
  var TheTodoItemComponent = /** @class */ (function (_super) {
4454
4084
  __extends(TheTodoItemComponent, _super);
4455
- function TheTodoItemComponent(elementRef, cdr) {
4085
+ function TheTodoItemComponent(elementRef, cdr, ctxService) {
4456
4086
  var _this = _super.call(this, elementRef, cdr) || this;
4457
4087
  _this.elementRef = elementRef;
4458
4088
  _this.cdr = cdr;
4089
+ _this.ctxService = ctxService;
4459
4090
  _this.checkItemClass = true;
4460
4091
  return _this;
4461
4092
  }
@@ -4471,14 +4102,19 @@
4471
4102
  _super.prototype.ngOnInit.call(this);
4472
4103
  };
4473
4104
  TheTodoItemComponent.prototype.onCheck = function (checked) {
4474
- if (this.readonly) {
4105
+ var options = this.ctxService.getTheOptions();
4106
+ var noBindReadonly = options.noBindReadonlyPlugins && options.noBindReadonlyPlugins.includes(exports.ElementKinds.checkItem);
4107
+ if (!noBindReadonly && this.readonly) {
4475
4108
  return false;
4476
4109
  }
4110
+ else {
4111
+ setNode(this.editor, { checked: checked }, this.element);
4112
+ }
4477
4113
  setNode(this.editor, { checked: checked }, this.element);
4478
4114
  };
4479
4115
  return TheTodoItemComponent;
4480
4116
  }(TheBaseElementComponent));
4481
- TheTodoItemComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TheTodoItemComponent, deps: [{ token: i0__namespace.ElementRef }, { token: i0__namespace.ChangeDetectorRef }], target: i0__namespace.ɵɵFactoryTarget.Component });
4117
+ TheTodoItemComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TheTodoItemComponent, deps: [{ token: i0__namespace.ElementRef }, { token: i0__namespace.ChangeDetectorRef }, { token: TheContextService }], target: i0__namespace.ɵɵFactoryTarget.Component });
4482
4118
  TheTodoItemComponent.ɵcmp = i0__namespace.ɵɵ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__namespace, template: "\n <span contenteditable=\"false\" class=\"todo-item-status\">\n <input #checkbox type=\"checkbox\" [checked]=\"element.checked\" (click)=\"onCheck(checkbox.checked)\" />\n </span>\n <span><slate-children [children]=\"children\" [context]=\"childrenContext\" [viewContext]=\"viewContext\"></slate-children></span>\n ", isInline: true, components: [{ type: i1__namespace.SlateChildrenComponent, selector: "slate-children", inputs: ["children", "context", "viewContext"] }] });
4483
4119
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TheTodoItemComponent, decorators: [{
4484
4120
  type: i0.Component,
@@ -4486,7 +4122,7 @@
4486
4122
  selector: 'div[theTodoItem]',
4487
4123
  template: "\n <span contenteditable=\"false\" class=\"todo-item-status\">\n <input #checkbox type=\"checkbox\" [checked]=\"element.checked\" (click)=\"onCheck(checkbox.checked)\" />\n </span>\n <span><slate-children [children]=\"children\" [context]=\"childrenContext\" [viewContext]=\"viewContext\"></slate-children></span>\n "
4488
4124
  }]
4489
- }], ctorParameters: function () { return [{ type: i0__namespace.ElementRef }, { type: i0__namespace.ChangeDetectorRef }]; }, propDecorators: { checkItemClass: [{
4125
+ }], ctorParameters: function () { return [{ type: i0__namespace.ElementRef }, { type: i0__namespace.ChangeDetectorRef }, { type: TheContextService }]; }, propDecorators: { checkItemClass: [{
4490
4126
  type: i0.HostBinding,
4491
4127
  args: ['class.the-check-item']
4492
4128
  }], level: [{
@@ -4617,332 +4253,754 @@
4617
4253
  return editor;
4618
4254
  };
4619
4255
 
4620
- var withHeading = function (editor) {
4621
- var insertBreak = editor.insertBreak;
4622
- editor.insertBreak = function () {
4623
- var selection = editor.selection;
4624
- var anchorBlock = getAnchorBlockEntry(editor);
4625
- if (anchorBlock && slate.Range.isCollapsed(selection) && anchorBlock[0].type.startsWith('heading')) {
4626
- if (slate.Editor.isStart(editor, selection.anchor, anchorBlock[1])) {
4627
- insertBreak();
4628
- slate.Transforms.setNodes(editor, { type: exports.ElementKinds.paragraph }, {
4629
- at: selection
4256
+ var withHeading = function (editor) {
4257
+ var insertBreak = editor.insertBreak;
4258
+ editor.insertBreak = function () {
4259
+ var selection = editor.selection;
4260
+ var anchorBlock = getAnchorBlockEntry(editor);
4261
+ if (anchorBlock && slate.Range.isCollapsed(selection) && anchorBlock[0].type.startsWith('heading')) {
4262
+ if (slate.Editor.isStart(editor, selection.anchor, anchorBlock[1])) {
4263
+ insertBreak();
4264
+ slate.Transforms.setNodes(editor, { type: exports.ElementKinds.paragraph }, {
4265
+ at: selection
4266
+ });
4267
+ return;
4268
+ }
4269
+ if (slate.Editor.isEnd(editor, selection.focus, anchorBlock[1])) {
4270
+ insertBreak();
4271
+ slate.Transforms.setNodes(editor, { type: exports.ElementKinds.paragraph });
4272
+ return;
4273
+ }
4274
+ }
4275
+ insertBreak();
4276
+ };
4277
+ return editor;
4278
+ };
4279
+
4280
+ var withMark = function () { return function (editor) {
4281
+ var e = editor;
4282
+ e.removeMark = function (key, shouldChange) {
4283
+ if (shouldChange === void 0) { shouldChange = true; }
4284
+ var selection = e.selection;
4285
+ if (selection) {
4286
+ if (slate.Range.isExpanded(selection)) {
4287
+ slate.Transforms.unsetNodes(e, key, {
4288
+ match: slate.Text.isText,
4289
+ split: true
4290
+ });
4291
+ }
4292
+ else {
4293
+ var marks = Object.assign({}, (slate.Editor.marks(e) || {}));
4294
+ delete marks[key];
4295
+ editor.marks = marks;
4296
+ var text = slate.Editor.string(e, selection.anchor.path);
4297
+ if (text !== '') {
4298
+ slate.Editor.setNormalizing(editor, false);
4299
+ e.insertText('');
4300
+ editor.marks = marks;
4301
+ slate.Editor.setNormalizing(editor, true);
4302
+ }
4303
+ else {
4304
+ slate.Transforms.unsetNodes(e, key, { at: selection.anchor.path });
4305
+ }
4306
+ if (shouldChange) {
4307
+ editor.onChange();
4308
+ }
4309
+ }
4310
+ }
4311
+ };
4312
+ e.addMark = function (key, value) {
4313
+ var _a, _b, _c;
4314
+ var selection = editor.selection;
4315
+ if (selection) {
4316
+ if (slate.Range.isExpanded(selection)) {
4317
+ slate.Transforms.setNodes(e, (_a = {}, _a[key] = value, _a), { match: slate.Text.isText, split: true });
4318
+ }
4319
+ else {
4320
+ var marks = Object.assign(Object.assign({}, (slate.Editor.marks(e) || {})), (_b = {}, _b[key] = value, _b));
4321
+ editor.marks = marks;
4322
+ var text = slate.Editor.string(e, selection.anchor.path);
4323
+ if (text !== '') {
4324
+ slate.Editor.setNormalizing(editor, false);
4325
+ e.insertText('');
4326
+ editor.marks = marks;
4327
+ slate.Editor.setNormalizing(editor, true);
4328
+ }
4329
+ else {
4330
+ slate.Transforms.setNodes(e, (_c = {}, _c[key] = value, _c), { at: selection.anchor.path });
4331
+ }
4332
+ }
4333
+ }
4334
+ };
4335
+ return e;
4336
+ }; };
4337
+
4338
+ var withNodeID = function (_a) {
4339
+ var _b = _a === void 0 ? {} : _a, _c = _b.idKey, idKey = _c === void 0 ? 'id' : _c, _d = _b.idCreator, idCreator = _d === void 0 ? function () { return Date.now(); } : _d, _e = _b.filterText, filterText = _e === void 0 ? true : _e, _f = _b.filter, filter = _f === void 0 ? function () { return true; } : _f;
4340
+ return function (e) {
4341
+ var editor = e;
4342
+ var apply = editor.apply, getFragment = editor.getFragment;
4343
+ var idPropsCreator = function () {
4344
+ var _a;
4345
+ return (_a = {}, _a[idKey] = idCreator(), _a);
4346
+ };
4347
+ editor.removedIDs = new Set();
4348
+ editor.apply = function (operation) {
4349
+ var _a;
4350
+ if (operation.type === 'insert_node') {
4351
+ var newFilter = function (entry) {
4352
+ var _a = __read(entry, 1), _node = _a[0];
4353
+ return filter(entry) && filterText ? slate.Element.isElement(_node) : isDescendant(_node);
4354
+ };
4355
+ // fix can not find path by orign node
4356
+ var node = operation.node;
4357
+ if (!Object.isExtensible(node)) {
4358
+ node = _.cloneDeep(node);
4359
+ }
4360
+ // it will not overwrite ids once it's set as it's read-only
4361
+ mergeDeepToNodes({
4362
+ node: node,
4363
+ source: idPropsCreator,
4364
+ query: {
4365
+ filter: newFilter,
4366
+ }
4367
+ });
4368
+ return apply(Object.assign(Object.assign({}, operation), { node: node }));
4369
+ }
4370
+ if (operation.type === 'split_node' && (!filterText || operation.properties.type)) {
4371
+ var id = operation.properties[idKey];
4372
+ if (editor.removedIDs.has(id)) {
4373
+ editor.removedIDs.delete(id);
4374
+ }
4375
+ else {
4376
+ id = idCreator();
4377
+ }
4378
+ return apply(Object.assign(Object.assign({}, operation), { properties: Object.assign(Object.assign({}, operation.properties), (_a = {}, _a[idKey] = id, _a)) }));
4379
+ }
4380
+ if (operation.type === 'merge_node' && (!filterText || operation.properties.type)) {
4381
+ editor.removedIDs.add(operation.properties[idKey]);
4382
+ }
4383
+ return apply(operation);
4384
+ };
4385
+ editor.getFragment = function () {
4386
+ var fragment = _.cloneDeep(getFragment());
4387
+ return deleteElementKey(fragment, idKey);
4388
+ };
4389
+ return editor;
4390
+ };
4391
+ };
4392
+
4393
+ var autoFormatBlock = function (editor, type, at, _a, markups) {
4394
+ var preFormat = _a.preFormat, format = _a.format;
4395
+ slate.Transforms.delete(editor, { at: at });
4396
+ if (preFormat) {
4397
+ preFormat(editor);
4398
+ }
4399
+ if (!format) {
4400
+ slate.Transforms.setNodes(editor, { type: type }, { match: function (n) { return slate.Editor.isBlock(editor, n); } });
4401
+ }
4402
+ else {
4403
+ format(editor, markups);
4404
+ }
4405
+ };
4406
+
4407
+ var autoFormatInline = function (editor, _a) {
4408
+ var type = _a.type, between = _a.between, markup = _a.markup, ignoreTrim = _a.ignoreTrim, format = _a.format;
4409
+ var selection = editor.selection;
4410
+ var startMarkup = between ? between[0] : markup;
4411
+ var endMarkup = between ? between[1] : '';
4412
+ var endMarkupPointBefore = selection.anchor;
4413
+ if (endMarkup) {
4414
+ endMarkupPointBefore = getPointBefore(editor, selection, {
4415
+ matchString: endMarkup
4416
+ });
4417
+ if (!endMarkupPointBefore) {
4418
+ return false;
4419
+ }
4420
+ }
4421
+ var startMarkupPointAfter = getPointBefore(editor, endMarkupPointBefore, {
4422
+ matchString: startMarkup,
4423
+ skipInvalid: true,
4424
+ afterMatch: true
4425
+ });
4426
+ if (!startMarkupPointAfter) {
4427
+ return false;
4428
+ }
4429
+ // found
4430
+ var markupRange = {
4431
+ anchor: startMarkupPointAfter,
4432
+ focus: endMarkupPointBefore
4433
+ };
4434
+ if (!ignoreTrim) {
4435
+ var markupText = getText(editor, markupRange);
4436
+ if (markupText.trim() !== markupText) {
4437
+ return false;
4438
+ }
4439
+ }
4440
+ // delete end markup
4441
+ if (endMarkup) {
4442
+ endMarkupPointBefore = getPointBefore(editor, selection, {
4443
+ matchString: endMarkup
4444
+ });
4445
+ slate.Transforms.delete(editor, {
4446
+ at: {
4447
+ anchor: endMarkupPointBefore,
4448
+ focus: selection.anchor
4449
+ }
4450
+ });
4451
+ }
4452
+ var startMarkupPointBefore = getPointBefore(editor, selection, {
4453
+ matchString: startMarkup,
4454
+ skipInvalid: true
4455
+ });
4456
+ if (format) {
4457
+ var markupText = getText(editor, markupRange);
4458
+ format(editor, markupText);
4459
+ // delete start to end selection
4460
+ slate.Transforms.delete(editor, {
4461
+ at: {
4462
+ anchor: startMarkupPointBefore,
4463
+ focus: selection.anchor
4464
+ }
4465
+ });
4466
+ }
4467
+ else {
4468
+ // add mark to the text between the markups
4469
+ slate.Transforms.select(editor, markupRange);
4470
+ editor.addMark(type, true);
4471
+ slate.Transforms.collapse(editor, { edge: 'end' });
4472
+ editor.removeMark(type, false);
4473
+ // delete start markup
4474
+ slate.Transforms.delete(editor, {
4475
+ at: {
4476
+ anchor: startMarkupPointBefore,
4477
+ focus: startMarkupPointAfter
4478
+ }
4479
+ });
4480
+ }
4481
+ return true;
4482
+ };
4483
+
4484
+ var ListEditor = {
4485
+ isList: function (editor, element, type) {
4486
+ return slate.Editor.isBlock(editor, element) && element.type === type;
4487
+ },
4488
+ toggleList: function (editor, type, startIndex) {
4489
+ var _this = this;
4490
+ if (!editor.selection) {
4491
+ return;
4492
+ }
4493
+ if (!startIndex) {
4494
+ startIndex = 1;
4495
+ }
4496
+ var types = [exports.ElementKinds.bulletedList, exports.ElementKinds.numberedList];
4497
+ slate.Editor.withoutNormalizing(editor, function () {
4498
+ var _a = __read(slate.Editor.nodes(editor, {
4499
+ match: function (node) { return slate.Element.isElement(node) && node.type === exports.ElementKinds.listItem; },
4500
+ mode: 'lowest'
4501
+ })), listItems = _a.slice(0);
4502
+ var firstListItemPath = listItems.length && listItems[0][1];
4503
+ var activeListPath = listItems.length && slate.Path.parent(firstListItemPath);
4504
+ var activeListNode = listItems.length && slate.Node.get(editor, activeListPath);
4505
+ // 同级且类型相同:unwrap
4506
+ var isLowestActive = listItems.length &&
4507
+ listItems.every(function (_a) {
4508
+ var _b = __read(_a, 2), path = _b[1];
4509
+ return activeListNode.type === type && (slate.Path.isSibling(firstListItemPath, path) || slate.Path.equals(firstListItemPath, path));
4510
+ });
4511
+ if (isLowestActive) {
4512
+ var upListItem = slate.Path.parent(activeListPath);
4513
+ slate.Transforms.unwrapNodes(editor, {
4514
+ at: editor.selection,
4515
+ match: function (node) { return node === activeListNode; },
4516
+ split: true,
4517
+ mode: 'lowest'
4630
4518
  });
4519
+ if (upListItem && slate.Node.get(editor, upListItem).type === exports.ElementKinds.listItem) {
4520
+ slate.Transforms.moveNodes(editor, {
4521
+ at: editor.selection,
4522
+ to: slate.Path.next(upListItem),
4523
+ match: function (node) { return slate.Element.isElement(node) && node.type === exports.ElementKinds.listItem; }
4524
+ });
4525
+ }
4526
+ else {
4527
+ slate.Transforms.unwrapNodes(editor, {
4528
+ match: function (node) { return slate.Element.isElement(node) && node.type === exports.ElementKinds.listItem; }
4529
+ });
4530
+ }
4631
4531
  return;
4632
4532
  }
4633
- if (slate.Editor.isEnd(editor, selection.focus, anchorBlock[1])) {
4634
- insertBreak();
4635
- slate.Transforms.setNodes(editor, { type: exports.ElementKinds.paragraph });
4533
+ // 跨级、同级且类型不同
4534
+ if (activeListNode && types.includes(activeListNode.type)) {
4535
+ slate.Transforms.setNodes(editor, { type: type }, { match: function (node) { return slate.Element.isElement(node) && node.type !== type && types.includes(node.type); } });
4636
4536
  return;
4637
4537
  }
4638
- }
4639
- insertBreak();
4640
- };
4641
- return editor;
4642
- };
4643
-
4644
- var withMark = function () { return function (editor) {
4645
- var e = editor;
4646
- e.removeMark = function (key, shouldChange) {
4647
- if (shouldChange === void 0) { shouldChange = true; }
4648
- var selection = e.selection;
4649
- if (selection) {
4650
- if (slate.Range.isExpanded(selection)) {
4651
- slate.Transforms.unsetNodes(e, key, {
4652
- match: slate.Text.isText,
4653
- split: true
4654
- });
4655
- }
4656
- else {
4657
- var marks = Object.assign({}, (slate.Editor.marks(e) || {}));
4658
- delete marks[key];
4659
- editor.marks = marks;
4660
- var text = slate.Editor.string(e, selection.anchor.path);
4661
- if (text !== '') {
4662
- slate.Editor.setNormalizing(editor, false);
4663
- e.insertText('');
4664
- editor.marks = marks;
4665
- slate.Editor.setNormalizing(editor, true);
4538
+ // wrap
4539
+ _this.buildListItem(editor);
4540
+ // Todo: types
4541
+ slate.Transforms.wrapNodes(editor, { type: type, children: [], start: startIndex }, {
4542
+ at: editor.selection,
4543
+ match: function (node) { return slate.Element.isElement(node) && node.type === exports.ElementKinds.listItem; }
4544
+ });
4545
+ });
4546
+ },
4547
+ unwrapList: function (editor) {
4548
+ slate.Editor.withoutNormalizing(editor, function () {
4549
+ unwrapNodesByType(editor, [exports.ElementKinds.bulletedList, exports.ElementKinds.numberedList], { split: true, mode: 'all' });
4550
+ unwrapNodesByType(editor, [exports.ElementKinds.listItem], { split: true, mode: 'all' });
4551
+ });
4552
+ },
4553
+ wrapList: function (editor, type) {
4554
+ slate.Editor.withoutNormalizing(editor, function () {
4555
+ var listItem = {
4556
+ type: exports.ElementKinds.listItem,
4557
+ children: []
4558
+ };
4559
+ var list = {
4560
+ type: type,
4561
+ children: []
4562
+ };
4563
+ slate.Transforms.wrapNodes(editor, list, { split: true });
4564
+ slate.Transforms.wrapNodes(editor, listItem, { split: true });
4565
+ });
4566
+ },
4567
+ isActive: function (editor, type) {
4568
+ var _a = __read(getNodesByType(editor, type), 1), match = _a[0];
4569
+ return !!match;
4570
+ },
4571
+ getActiveList: function (editor) {
4572
+ var _a = __read(getNodesByType(editor, LIST_BLOCK_TYPES), 1), match = _a[0];
4573
+ return match;
4574
+ },
4575
+ buildListItem: function (editor) {
4576
+ var e_1, _a;
4577
+ var nodes = slate.Editor.nodes(editor, {
4578
+ match: function (node) { return slate.Editor.isBlock(editor, node); },
4579
+ mode: 'lowest'
4580
+ });
4581
+ try {
4582
+ for (var nodes_1 = __values(nodes), nodes_1_1 = nodes_1.next(); !nodes_1_1.done; nodes_1_1 = nodes_1.next()) {
4583
+ var _b = __read(nodes_1_1.value, 2), node = _b[0], path = _b[1];
4584
+ if (!slate.Editor.isVoid(editor, node) && slate.Element.isElement(node) && node.type !== exports.ElementKinds.paragraph) {
4585
+ slate.Transforms.setNodes(editor, { type: exports.ElementKinds.paragraph, checked: undefined }, // todo remove checked
4586
+ { at: path });
4666
4587
  }
4667
- else {
4668
- slate.Transforms.unsetNodes(e, key, { at: selection.anchor.path });
4588
+ else if (slate.Element.isElement(node) && node.type === exports.ElementKinds.paragraph) {
4589
+ var textIndent = node.textIndent;
4590
+ if (textIndent) {
4591
+ slate.Transforms.setNodes(editor, { textIndent: undefined, indent: undefined }, // remove indent
4592
+ { at: path });
4593
+ }
4669
4594
  }
4670
- if (shouldChange) {
4671
- editor.onChange();
4595
+ if (slate.Node.parent(editor, path).type !== exports.ElementKinds.listItem) {
4596
+ slate.Transforms.wrapNodes(editor, { type: exports.ElementKinds.listItem, children: [] }, {
4597
+ at: path,
4598
+ split: true
4599
+ });
4672
4600
  }
4673
4601
  }
4674
4602
  }
4675
- };
4676
- e.addMark = function (key, value) {
4677
- var _a, _b, _c;
4678
- var selection = editor.selection;
4679
- if (selection) {
4680
- if (slate.Range.isExpanded(selection)) {
4681
- slate.Transforms.setNodes(e, (_a = {}, _a[key] = value, _a), { match: slate.Text.isText, split: true });
4682
- }
4683
- else {
4684
- var marks = Object.assign(Object.assign({}, (slate.Editor.marks(e) || {})), (_b = {}, _b[key] = value, _b));
4685
- editor.marks = marks;
4686
- var text = slate.Editor.string(e, selection.anchor.path);
4687
- if (text !== '') {
4688
- slate.Editor.setNormalizing(editor, false);
4689
- e.insertText('');
4690
- editor.marks = marks;
4691
- slate.Editor.setNormalizing(editor, true);
4692
- }
4693
- else {
4694
- slate.Transforms.setNodes(e, (_c = {}, _c[key] = value, _c), { at: selection.anchor.path });
4695
- }
4603
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
4604
+ finally {
4605
+ try {
4606
+ if (nodes_1_1 && !nodes_1_1.done && (_a = nodes_1.return)) _a.call(nodes_1);
4696
4607
  }
4608
+ finally { if (e_1) throw e_1.error; }
4697
4609
  }
4698
- };
4699
- return e;
4700
- }; };
4610
+ },
4611
+ buildInsertDataChildren: function (node) {
4612
+ var children = node.children;
4613
+ var listItem = children[0];
4614
+ if (isNodeTypeList(node) && slate.Element.isElement(listItem) && listItem.children[0].type === exports.ElementKinds.paragraph) {
4615
+ return node;
4616
+ }
4617
+ return this.buildInsertDataChildren(listItem);
4618
+ }
4619
+ };
4701
4620
 
4702
- var withNodeID = function (_a) {
4703
- var _b = _a === void 0 ? {} : _a, _c = _b.idKey, idKey = _c === void 0 ? 'id' : _c, _d = _b.idCreator, idCreator = _d === void 0 ? function () { return Date.now(); } : _d, _e = _b.filterText, filterText = _e === void 0 ? true : _e, _f = _b.filter, filter = _f === void 0 ? function () { return true; } : _f;
4704
- return function (e) {
4705
- var editor = e;
4706
- var apply = editor.apply, getFragment = editor.getFragment;
4707
- var idPropsCreator = function () {
4708
- var _a;
4709
- return (_a = {}, _a[idKey] = idCreator(), _a);
4710
- };
4711
- editor.removedIDs = new Set();
4712
- editor.apply = function (operation) {
4713
- var _a;
4714
- if (operation.type === 'insert_node') {
4715
- var newFilter = function (entry) {
4716
- var _a = __read(entry, 1), _node = _a[0];
4717
- return filter(entry) && filterText ? slate.Element.isElement(_node) : isDescendant(_node);
4718
- };
4719
- // fix can not find path by orign node
4720
- var node = operation.node;
4721
- if (!Object.isExtensible(node)) {
4722
- node = _.cloneDeep(node);
4723
- }
4724
- // it will not overwrite ids once it's set as it's read-only
4725
- mergeDeepToNodes({
4726
- node: node,
4727
- source: idPropsCreator,
4728
- query: {
4729
- filter: newFilter,
4730
- }
4731
- });
4732
- return apply(Object.assign(Object.assign({}, operation), { node: node }));
4733
- }
4734
- if (operation.type === 'split_node' && (!filterText || operation.properties.type)) {
4735
- var id = operation.properties[idKey];
4736
- if (editor.removedIDs.has(id)) {
4737
- editor.removedIDs.delete(id);
4738
- }
4739
- else {
4740
- id = idCreator();
4741
- }
4742
- return apply(Object.assign(Object.assign({}, operation), { properties: Object.assign(Object.assign({}, operation.properties), (_a = {}, _a[idKey] = id, _a)) }));
4743
- }
4744
- if (operation.type === 'merge_node' && (!filterText || operation.properties.type)) {
4745
- editor.removedIDs.add(operation.properties[idKey]);
4621
+ var TodoItemEditor = {
4622
+ isActive: function (editor) {
4623
+ var _a = __read(getNodesByType(editor, exports.ElementKinds.checkItem), 1), match = _a[0];
4624
+ return !!match;
4625
+ },
4626
+ insertTodoItem: function (editor) {
4627
+ if (!editor.selection) {
4628
+ return;
4629
+ }
4630
+ var isActive = this.isActive(editor);
4631
+ var isNumberedList = ListEditor.isActive(editor, exports.ElementKinds.numberedList);
4632
+ var isBulletedList = ListEditor.isActive(editor, exports.ElementKinds.bulletedList);
4633
+ if (isActive) {
4634
+ slate.Transforms.setNodes(editor, {
4635
+ type: exports.ElementKinds.paragraph
4636
+ });
4637
+ }
4638
+ else {
4639
+ if (isNumberedList || isBulletedList) {
4640
+ ListEditor.unwrapList(editor);
4746
4641
  }
4747
- return apply(operation);
4748
- };
4749
- editor.getFragment = function () {
4750
- var fragment = _.cloneDeep(getFragment());
4751
- return deleteElementKey(fragment, idKey);
4752
- };
4753
- return editor;
4754
- };
4642
+ slate.Transforms.setNodes(editor, {
4643
+ type: exports.ElementKinds.checkItem
4644
+ });
4645
+ }
4646
+ }
4755
4647
  };
4756
4648
 
4757
- var autoFormatBlock = function (editor, type, at, _a, markups) {
4758
- var preFormat = _a.preFormat, format = _a.format;
4759
- slate.Transforms.delete(editor, { at: at });
4760
- if (preFormat) {
4761
- preFormat(editor);
4762
- }
4763
- if (!format) {
4764
- slate.Transforms.setNodes(editor, { type: type }, { match: function (n) { return slate.Editor.isBlock(editor, n); } });
4765
- }
4766
- else {
4767
- format(editor, markups);
4649
+ var BlockquoteEditor = {
4650
+ toggleBlockquote: function (editor) {
4651
+ if (!isParagraph(editor)) {
4652
+ slate.Transforms.insertNodes(editor, {
4653
+ type: exports.ElementKinds.paragraph,
4654
+ mode: 'text',
4655
+ children: [
4656
+ {
4657
+ text: ''
4658
+ }
4659
+ ]
4660
+ });
4661
+ }
4662
+ var isActive = isBlockActive(editor, exports.ElementKinds.blockquote);
4663
+ if (!isActive) {
4664
+ slate.Transforms.wrapNodes(editor, { type: exports.ElementKinds.blockquote, children: [] }, {
4665
+ mode: 'lowest'
4666
+ });
4667
+ }
4668
+ else {
4669
+ slate.Transforms.unwrapNodes(editor, { match: function (n) { return slate.Element.isElement(n) && n.type === exports.ElementKinds.blockquote; } });
4670
+ }
4768
4671
  }
4769
4672
  };
4770
4673
 
4771
- var autoFormatInline = function (editor, _a) {
4772
- var type = _a.type, between = _a.between, markup = _a.markup, ignoreTrim = _a.ignoreTrim, format = _a.format;
4773
- var selection = editor.selection;
4774
- var startMarkup = between ? between[0] : markup;
4775
- var endMarkup = between ? between[1] : '';
4776
- var endMarkupPointBefore = selection.anchor;
4777
- if (endMarkup) {
4778
- endMarkupPointBefore = getPointBefore(editor, selection, {
4779
- matchString: endMarkup
4780
- });
4781
- if (!endMarkupPointBefore) {
4782
- return false;
4674
+ var InlineCodeEditor = {
4675
+ toggleInlineCode: function (editor, text) {
4676
+ var isActive = InlineCodeEditor.isInlineCodeActive(editor);
4677
+ if (isActive) {
4678
+ InlineCodeEditor.unwrapInlineCode(editor);
4679
+ return;
4783
4680
  }
4784
- }
4785
- var startMarkupPointAfter = getPointBefore(editor, endMarkupPointBefore, {
4786
- matchString: startMarkup,
4787
- skipInvalid: true,
4788
- afterMatch: true
4789
- });
4790
- if (!startMarkupPointAfter) {
4791
- return false;
4792
- }
4793
- // found
4794
- var markupRange = {
4795
- anchor: startMarkupPointAfter,
4796
- focus: endMarkupPointBefore
4797
- };
4798
- if (!ignoreTrim) {
4799
- var markupText = getText(editor, markupRange);
4800
- if (markupText.trim() !== markupText) {
4801
- return false;
4681
+ if (slate.Range.isCollapsed(editor.selection)) {
4682
+ InlineCodeEditor.wrapInlineCode(editor, text);
4802
4683
  }
4684
+ else {
4685
+ var fragment = slate.Node.fragment(editor, editor.selection)[0];
4686
+ var selectNode = slate.Node.get(fragment, []);
4687
+ var selectText = slate.Node.string(selectNode);
4688
+ InlineCodeEditor.wrapInlineCode(editor, selectText);
4689
+ }
4690
+ },
4691
+ wrapInlineCode: function (editor, text) {
4692
+ if (text === void 0) { text = ''; }
4693
+ if (InlineCodeEditor.isInlineCodeActive(editor)) {
4694
+ InlineCodeEditor.unwrapInlineCode(editor);
4695
+ }
4696
+ var selection = editor.selection;
4697
+ var isCollapsed = selection && slate.Range.isCollapsed(selection);
4698
+ var inlineCode = {
4699
+ type: exports.ElementKinds.inlineCode,
4700
+ children: isCollapsed ? [{ text: text ? text : ZERO_WIDTH_CHAR }] : []
4701
+ };
4702
+ if (isCollapsed) {
4703
+ slate.Transforms.insertNodes(editor, inlineCode);
4704
+ }
4705
+ else {
4706
+ slate.Transforms.wrapNodes(editor, inlineCode, { split: true });
4707
+ }
4708
+ },
4709
+ unwrapInlineCode: function (editor) {
4710
+ slate.Transforms.unwrapNodes(editor, { match: function (n) { return slate.Element.isElement(n) && n.type === exports.ElementKinds.inlineCode; } });
4711
+ },
4712
+ isInlineCodeActive: function (editor, path) {
4713
+ var _a;
4714
+ var _b = __read(slate.Editor.nodes(editor, {
4715
+ at: path ? path : (_a = editor.selection) === null || _a === void 0 ? void 0 : _a.anchor.path,
4716
+ match: function (n) { return slate.Element.isElement(n) && n.type === exports.ElementKinds.inlineCode; }
4717
+ }), 1), inlineCode = _b[0];
4718
+ return !!inlineCode;
4803
4719
  }
4804
- // delete end markup
4805
- if (endMarkup) {
4806
- endMarkupPointBefore = getPointBefore(editor, selection, {
4807
- matchString: endMarkup
4808
- });
4809
- slate.Transforms.delete(editor, {
4810
- at: {
4811
- anchor: endMarkupPointBefore,
4812
- focus: selection.anchor
4813
- }
4814
- });
4815
- }
4816
- var startMarkupPointBefore = getPointBefore(editor, selection, {
4817
- matchString: startMarkup,
4818
- skipInvalid: true
4819
- });
4820
- if (format) {
4821
- var markupText = getText(editor, markupRange);
4822
- format(editor, markupText);
4823
- // delete start to end selection
4824
- slate.Transforms.delete(editor, {
4825
- at: {
4826
- anchor: startMarkupPointBefore,
4827
- focus: selection.anchor
4720
+ };
4721
+
4722
+ var HeadingEditor = {
4723
+ setHeading: function (editor, heading) {
4724
+ slate.Editor.withoutNormalizing(editor, function () {
4725
+ var _a;
4726
+ var types = [exports.ElementKinds.bulletedList, exports.ElementKinds.numberedList, exports.ElementKinds.listItem];
4727
+ slate.Transforms.unwrapNodes(editor, {
4728
+ at: editor.selection,
4729
+ match: function (n) { return slate.Element.isElement(n) && types.includes(n.type); },
4730
+ mode: 'all',
4731
+ split: true
4732
+ });
4733
+ slate.Transforms.setNodes(editor, { type: heading });
4734
+ var entry = anchorBlockEntry(editor);
4735
+ var unMarks = (_a = {},
4736
+ _a[exports.MarkTypes.fontSize] = null,
4737
+ _a);
4738
+ if (entry) {
4739
+ setMarks(editor, unMarks, entry[1]);
4740
+ return;
4828
4741
  }
4742
+ setMarks(editor, unMarks, editor.selection);
4829
4743
  });
4744
+ },
4745
+ isHeadingActive: function (editor, heading) {
4746
+ var _a = __read(slate.Editor.nodes(editor, {
4747
+ match: function (n) { return slate.Element.isElement(n) && n.type === heading; },
4748
+ universal: true
4749
+ }), 1), match = _a[0];
4750
+ return !!match;
4830
4751
  }
4831
- else {
4832
- // add mark to the text between the markups
4833
- slate.Transforms.select(editor, markupRange);
4834
- editor.addMark(type, true);
4835
- slate.Transforms.collapse(editor, { edge: 'end' });
4836
- editor.removeMark(type, false);
4837
- // delete start markup
4838
- slate.Transforms.delete(editor, {
4839
- at: {
4840
- anchor: startMarkupPointBefore,
4841
- focus: startMarkupPointAfter
4752
+ };
4753
+
4754
+ var defaultAutoFormatRules = [
4755
+ {
4756
+ type: exports.ElementKinds.heading_1,
4757
+ markup: '#',
4758
+ format: function (editor) {
4759
+ HeadingEditor.setHeading(editor, exports.ElementKinds.heading_1);
4760
+ }
4761
+ },
4762
+ {
4763
+ type: exports.ElementKinds.heading_2,
4764
+ markup: '##',
4765
+ format: function (editor) {
4766
+ HeadingEditor.setHeading(editor, exports.ElementKinds.heading_2);
4767
+ }
4768
+ },
4769
+ {
4770
+ type: exports.ElementKinds.heading_3,
4771
+ markup: '###',
4772
+ format: function (editor) {
4773
+ HeadingEditor.setHeading(editor, exports.ElementKinds.heading_3);
4774
+ }
4775
+ },
4776
+ {
4777
+ type: exports.ElementKinds.heading_4,
4778
+ markup: '####',
4779
+ format: function (editor) {
4780
+ HeadingEditor.setHeading(editor, exports.ElementKinds.heading_4);
4781
+ }
4782
+ },
4783
+ {
4784
+ type: exports.ElementKinds.heading_5,
4785
+ markup: '#####',
4786
+ format: function (editor) {
4787
+ HeadingEditor.setHeading(editor, exports.ElementKinds.heading_5);
4788
+ }
4789
+ },
4790
+ {
4791
+ type: exports.ElementKinds.heading_6,
4792
+ markup: '######',
4793
+ format: function (editor) {
4794
+ HeadingEditor.setHeading(editor, exports.ElementKinds.heading_6);
4795
+ }
4796
+ },
4797
+ {
4798
+ type: exports.ElementKinds.blockquote,
4799
+ markup: ['>'],
4800
+ format: function (editor) {
4801
+ BlockquoteEditor.toggleBlockquote(editor);
4802
+ }
4803
+ },
4804
+ {
4805
+ type: exports.MarkTypes.bold,
4806
+ between: ['**', '**'],
4807
+ mode: 'inline',
4808
+ insertTrigger: true
4809
+ },
4810
+ {
4811
+ type: exports.MarkTypes.bold,
4812
+ between: ['__', '__'],
4813
+ mode: 'inline',
4814
+ insertTrigger: true
4815
+ },
4816
+ {
4817
+ type: exports.MarkTypes.italic,
4818
+ between: ['*', '*'],
4819
+ mode: 'inline',
4820
+ insertTrigger: true
4821
+ },
4822
+ {
4823
+ type: exports.MarkTypes.italic,
4824
+ between: ['_', '_'],
4825
+ mode: 'inline',
4826
+ insertTrigger: true
4827
+ },
4828
+ {
4829
+ type: exports.ElementKinds.inlineCode,
4830
+ between: ['`', '`'],
4831
+ mode: 'inline',
4832
+ format: function (editor, text) {
4833
+ InlineCodeEditor.toggleInlineCode(editor, text);
4834
+ slate.Transforms.select(editor, slate.Editor.after(editor, editor.selection));
4835
+ }
4836
+ },
4837
+ {
4838
+ type: exports.MarkTypes.strike,
4839
+ between: ['~~', '~~'],
4840
+ mode: 'inline',
4841
+ insertTrigger: true
4842
+ },
4843
+ {
4844
+ type: exports.ElementKinds.code,
4845
+ markup: '```',
4846
+ insertTrigger: true
4847
+ },
4848
+ {
4849
+ type: exports.ElementKinds.listItem,
4850
+ markup: [],
4851
+ match: function (editor) {
4852
+ return isParagraph(editor) ? ['*', '-', '+'] : [];
4853
+ },
4854
+ format: function (editor) {
4855
+ ListEditor.toggleList(editor, exports.ElementKinds.bulletedList);
4856
+ }
4857
+ },
4858
+ {
4859
+ type: exports.ElementKinds.listItem,
4860
+ key: exports.ElementKinds.numberedList,
4861
+ markup: [],
4862
+ match: function (editor, textFromBlockStart) {
4863
+ return isParagraph(editor) && /^-?\d+(\.|\))$/.test(textFromBlockStart) ? [textFromBlockStart] : [];
4864
+ },
4865
+ format: function (editor, markup) {
4866
+ var startIndex = 1;
4867
+ if (markup) {
4868
+ startIndex = markup[0].split('.')[0];
4869
+ if (startIndex === 0) {
4870
+ startIndex = 1;
4871
+ }
4842
4872
  }
4843
- });
4873
+ ListEditor.toggleList(editor, exports.ElementKinds.numberedList, startIndex);
4874
+ }
4875
+ },
4876
+ {
4877
+ type: exports.ElementKinds.checkItem,
4878
+ markup: [],
4879
+ match: function (editor) {
4880
+ return isParagraph(editor) ? ['[]'] : [];
4881
+ },
4882
+ format: function (editor) {
4883
+ TodoItemEditor.insertTodoItem(editor);
4884
+ }
4885
+ },
4886
+ {
4887
+ type: exports.ElementKinds.hr,
4888
+ markup: '---',
4889
+ insertTrigger: true
4844
4890
  }
4845
- return true;
4846
- };
4891
+ ];
4847
4892
 
4848
- var withAutoFormat = function (_c) {
4849
- var rules = _c.rules;
4850
- return function (editor) {
4851
- var insertText = editor.insertText;
4852
- editor.insertText = function (text) {
4853
- var e_1, _c;
4854
- var _a;
4855
- if (!isCollapsed(editor.selection)) {
4856
- return insertText(text);
4857
- }
4858
- var _loop_1 = function (_b) {
4859
- var query = _b.query, rule = __rest(_b, ["query"]);
4860
- var _d = rule.trigger, trigger = _d === void 0 ? ' ' : _d, _e = rule.mode, mode = _e === void 0 ? 'block' : _e, type = rule.type, markup = rule.markup, preFormat = rule.preFormat, format = rule.format, match = rule.match, between = rule.between, ignoreTrim = rule.ignoreTrim, insertTrigger = rule.insertTrigger, _f = rule.allowSameTypeAbove, allowSameTypeAbove = _f === void 0 ? false : _f, _g = rule.triggerAtBlockStart, triggerAtBlockStart = _g === void 0 ? true : _g;
4861
- if (query && !query(editor, rule))
4862
- return "continue";
4863
- var triggers = castArray(trigger);
4864
- // Check trigger
4865
- if (!triggers.includes(text))
4866
- return "continue";
4867
- var valid = function () { return insertTrigger && insertText(text); };
4868
- if (mode === 'block') {
4869
- var markups = castArray(markup);
4870
- var markupRange = void 0;
4871
- if (triggerAtBlockStart) {
4872
- markupRange = getRangeFromBlockStart(editor);
4873
- // Don't autoformat if there is void nodes.
4874
- var hasVoidNode = someNode(editor, {
4875
- at: markupRange,
4876
- match: function (n) { return slate.Editor.isVoid(editor, n); }
4877
- });
4878
- if (hasVoidNode)
4879
- return "continue";
4880
- var textFromBlockStart = getText(editor, markupRange);
4881
- if (match) {
4882
- markups = match(editor, textFromBlockStart);
4883
- }
4884
- if (!markups.includes(textFromBlockStart))
4885
- return "continue";
4886
- }
4887
- else {
4888
- markupRange = getRangeBefore(editor, editor.selection, {
4889
- matchString: markup,
4890
- skipInvalid: true
4891
- });
4892
- if (!markupRange)
4893
- return "continue";
4894
- var blockAbovePath = (_a = getBlockAbove(editor)) === null || _a === void 0 ? void 0 : _a[1];
4895
- if (!blockAbovePath)
4896
- return "continue";
4897
- // If the markup is not at the start, insert break before autoformatting.
4898
- if (!slate.Editor.isStart(editor, markupRange.anchor, blockAbovePath)) {
4899
- editor.insertBreak();
4900
- }
4901
- }
4902
- if (!allowSameTypeAbove) {
4903
- // Don't autoformat if already in a block of the same type.
4904
- var isBelowSameBlockType = someNode(editor, { match: { type: type } });
4905
- if (isBelowSameBlockType)
4906
- return "continue";
4893
+ var withAutoFormat = function () { return function (editor) {
4894
+ var insertText = editor.insertText;
4895
+ editor.insertText = function (text) {
4896
+ var e_1, _d;
4897
+ var _a, _b;
4898
+ var autoFormatRules = defaultAutoFormatRules;
4899
+ if ((_a = editor.extraAutoFormatRules) === null || _a === void 0 ? void 0 : _a.length) {
4900
+ var extraRules = mergAutoFormateRules(editor.extraAutoFormatRules);
4901
+ autoFormatRules = Object.values(extraRules);
4902
+ }
4903
+ if (!isCollapsed(editor.selection)) {
4904
+ return insertText(text);
4905
+ }
4906
+ var _loop_1 = function (_c) {
4907
+ var query = _c.query, rule = __rest(_c, ["query"]);
4908
+ var _e = rule.trigger, trigger = _e === void 0 ? ' ' : _e, _f = rule.mode, mode = _f === void 0 ? 'block' : _f, type = rule.type, markup = rule.markup, preFormat = rule.preFormat, format = rule.format, match = rule.match, between = rule.between, ignoreTrim = rule.ignoreTrim, insertTrigger = rule.insertTrigger, _g = rule.allowSameTypeAbove, allowSameTypeAbove = _g === void 0 ? false : _g, _h = rule.triggerAtBlockStart, triggerAtBlockStart = _h === void 0 ? true : _h;
4909
+ if (query && !query(editor, rule))
4910
+ return "continue";
4911
+ var triggers = castArray(trigger);
4912
+ // Check trigger
4913
+ if (!triggers.includes(text))
4914
+ return "continue";
4915
+ var valid = function () { return insertTrigger && insertText(text); };
4916
+ if (mode === 'block') {
4917
+ var markups = castArray(markup);
4918
+ var markupRange = void 0;
4919
+ if (triggerAtBlockStart) {
4920
+ markupRange = getRangeFromBlockStart(editor);
4921
+ // Don't autoformat if there is void nodes.
4922
+ var hasVoidNode = someNode(editor, {
4923
+ at: markupRange,
4924
+ match: function (n) { return slate.Editor.isVoid(editor, n); }
4925
+ });
4926
+ if (hasVoidNode)
4927
+ return "continue";
4928
+ var textFromBlockStart = getText(editor, markupRange);
4929
+ if (match) {
4930
+ markups = match(editor, textFromBlockStart);
4907
4931
  }
4908
- // Start of the block
4909
- autoFormatBlock(editor, type, markupRange, {
4910
- preFormat: preFormat,
4911
- format: format
4912
- }, markups);
4913
- return { value: valid() };
4932
+ if (!markups.includes(textFromBlockStart))
4933
+ return "continue";
4914
4934
  }
4915
- if (mode === 'inline') {
4916
- if (autoFormatInline(editor, {
4917
- type: type,
4918
- between: between,
4919
- ignoreTrim: ignoreTrim,
4920
- format: format,
4921
- markup: Array.isArray(markup) ? markup[0] : markup
4922
- })) {
4923
- return { value: valid() };
4935
+ else {
4936
+ markupRange = getRangeBefore(editor, editor.selection, {
4937
+ matchString: markup,
4938
+ skipInvalid: true
4939
+ });
4940
+ if (!markupRange)
4941
+ return "continue";
4942
+ var blockAbovePath = (_b = getBlockAbove(editor)) === null || _b === void 0 ? void 0 : _b[1];
4943
+ if (!blockAbovePath)
4944
+ return "continue";
4945
+ // If the markup is not at the start, insert break before autoformatting.
4946
+ if (!slate.Editor.isStart(editor, markupRange.anchor, blockAbovePath)) {
4947
+ editor.insertBreak();
4924
4948
  }
4925
4949
  }
4926
- };
4927
- try {
4928
- for (var rules_1 = __values(rules), rules_1_1 = rules_1.next(); !rules_1_1.done; rules_1_1 = rules_1.next()) {
4929
- var _b = rules_1_1.value;
4930
- var state_1 = _loop_1(_b);
4931
- if (typeof state_1 === "object")
4932
- return state_1.value;
4933
- }
4934
- }
4935
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
4936
- finally {
4937
- try {
4938
- if (rules_1_1 && !rules_1_1.done && (_c = rules_1.return)) _c.call(rules_1);
4950
+ if (!allowSameTypeAbove) {
4951
+ // Don't autoformat if already in a block of the same type.
4952
+ var isBelowSameBlockType = someNode(editor, { match: { type: type } });
4953
+ if (isBelowSameBlockType)
4954
+ return "continue";
4955
+ }
4956
+ // Start of the block
4957
+ autoFormatBlock(editor, type, markupRange, {
4958
+ preFormat: preFormat,
4959
+ format: format
4960
+ }, markups);
4961
+ return { value: valid() };
4962
+ }
4963
+ if (mode === 'inline') {
4964
+ if (autoFormatInline(editor, {
4965
+ type: type,
4966
+ between: between,
4967
+ ignoreTrim: ignoreTrim,
4968
+ format: format,
4969
+ markup: Array.isArray(markup) ? markup[0] : markup
4970
+ })) {
4971
+ return { value: valid() };
4939
4972
  }
4940
- finally { if (e_1) throw e_1.error; }
4941
4973
  }
4942
- insertText(text);
4943
4974
  };
4944
- return editor;
4975
+ try {
4976
+ for (var autoFormatRules_1 = __values(autoFormatRules), autoFormatRules_1_1 = autoFormatRules_1.next(); !autoFormatRules_1_1.done; autoFormatRules_1_1 = autoFormatRules_1.next()) {
4977
+ var _c = autoFormatRules_1_1.value;
4978
+ var state_1 = _loop_1(_c);
4979
+ if (typeof state_1 === "object")
4980
+ return state_1.value;
4981
+ }
4982
+ }
4983
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
4984
+ finally {
4985
+ try {
4986
+ if (autoFormatRules_1_1 && !autoFormatRules_1_1.done && (_d = autoFormatRules_1.return)) _d.call(autoFormatRules_1);
4987
+ }
4988
+ finally { if (e_1) throw e_1.error; }
4989
+ }
4990
+ insertText(text);
4945
4991
  };
4992
+ return editor;
4993
+ }; };
4994
+ var mergAutoFormateRules = function (extraAutoFormatRules) {
4995
+ var combinationData = __spreadArray(__spreadArray([], __read(defaultAutoFormatRules)), __read(extraAutoFormatRules));
4996
+ var dataInfo = {};
4997
+ combinationData.forEach(function (item) {
4998
+ if (!dataInfo[item.type + item.key]) {
4999
+ dataInfo[item.type + item.key] = Object.assign({}, item);
5000
+ }
5001
+ dataInfo[item.type + item.key] = Object.assign(Object.assign({}, dataInfo[item.type + item.key]), item);
5002
+ });
5003
+ return dataInfo;
4946
5004
  };
4947
5005
 
4948
5006
  var withTransforms = function () { return function (editor) {
@@ -9387,7 +9445,7 @@
9387
9445
  offset: this.offset,
9388
9446
  hasBackdrop: this.hasBackdrop,
9389
9447
  insideClosable: this.insideClosable,
9390
- panelClass: 'the-table-toolbar-wrap',
9448
+ panelClass: 'the-temp-table-toolbar-wrap',
9391
9449
  scrollStrategy: this.overlay.scrollStrategies.reposition(),
9392
9450
  manualClosure: true
9393
9451
  });
@@ -9397,15 +9455,15 @@
9397
9455
  if (origin instanceof HTMLTableCellElement && origin.tagName !== 'TH') {
9398
9456
  var _a = this.tableStore, selectedRowsIndex = _a.selectedRowsIndex, selectedColumnsIndex = _a.selectedColumnsIndex, focusCellPath = _a.focusCellPath, isSelectedTable = _a.isSelectedTable, focusCellElement = _a.focusCellElement;
9399
9457
  var _b = __read(focusCellPath.slice(-2), 2), row = _b[0], col = _b[1];
9400
- var tableElement = focusCellElement.closest('.the-table-container');
9458
+ var tableElement = focusCellElement.closest('.the-temp-table-container');
9401
9459
  if (isSelectedTable && col === 0 && row === 0) {
9402
- return tableElement.querySelector('.the-table-corner-controls');
9460
+ return tableElement.querySelector('.the-temp-table-corner-controls');
9403
9461
  }
9404
9462
  if (selectedColumnsIndex.length > 0 && row === 0) {
9405
- return tableElement.querySelectorAll('.the-table-col-controls')[col];
9463
+ return tableElement.querySelectorAll('.the-temp-table-col-controls')[col];
9406
9464
  }
9407
9465
  if (selectedRowsIndex.length > 0 && col === 0) {
9408
- return tableElement.querySelectorAll('.the-table-row-controls-button-wrap')[row];
9466
+ return tableElement.querySelectorAll('.the-temp-table-row-controls-button-wrap')[row];
9409
9467
  }
9410
9468
  }
9411
9469
  return origin;
@@ -9517,13 +9575,13 @@
9517
9575
  var tableWrapper = tableComponent.tableWrapper.nativeElement;
9518
9576
  var tableElement = tableComponent.theTableElement.nativeElement;
9519
9577
  var result = 0;
9520
- var rowControl = tableComponent.nativeElement.querySelector('.the-table-row-controls');
9578
+ var rowControl = tableComponent.nativeElement.querySelector('.the-temp-table-row-controls');
9521
9579
  var rowControlWidth = 11;
9522
9580
  if (rowControl) {
9523
9581
  rowControlWidth = rowControl.getBoundingClientRect().width;
9524
9582
  }
9525
9583
  if (this.type === 'row') {
9526
- result = tableWrapper.offsetWidth + rowControlWidth;
9584
+ result = tableWrapper.offsetWidth + rowControlWidth - 2;
9527
9585
  }
9528
9586
  else {
9529
9587
  result = tableElement.offsetHeight - 1;
@@ -9535,7 +9593,7 @@
9535
9593
  return TheInsertMarkComponent;
9536
9594
  }());
9537
9595
  TheInsertMarkComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TheInsertMarkComponent, deps: [{ token: i0__namespace.ChangeDetectorRef }], target: i0__namespace.ɵɵFactoryTarget.Component });
9538
- TheInsertMarkComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.15", type: TheInsertMarkComponent, selector: "the-table-insert-mark", inputs: { type: "type", at: "at", tableStore: "tableStore" }, ngImport: i0__namespace, template: "<div\n [thyTooltip]=\"!disabled && tooltipContent\"\n class=\"the-table-controls-insert-wrapper\"\n [ngClass]=\"{ disabled: disabled }\"\n contenteditable=\"false\"\n (mousedown)=\"onMouseDown($event)\"\n (mouseenter)=\"onMouseEnter($event)\"\n (mouseleave)=\"onMouseLeave($event)\"\n>\n <div\n class=\"the-table-controls-insert-line\"\n *ngIf=\"dotWrapperHovered\"\n [attr.data-dot-type]=\"type\"\n [ngStyle]=\"{ height: type === 'column' && insertLength, width: type === 'row' && insertLength }\"\n ></div>\n</div>\n", directives: [{ type: i5__namespace.ThyTooltipDirective, selector: "[thyTooltip],[thy-tooltip]", inputs: ["thyTooltip", "thyTooltipPlacement", "thyTooltipClass", "thyTooltipShowDelay", "thyTooltipHideDelay", "thyTooltipTrigger", "thyTooltipDisabled", "thyTooltipTemplateContext", "thyTooltipOffset", "thyTooltipPin"], exportAs: ["thyTooltip"] }, { type: i10__namespace.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i10__namespace.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i10__namespace.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }] });
9596
+ TheInsertMarkComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.15", type: TheInsertMarkComponent, selector: "the-table-insert-mark", inputs: { type: "type", at: "at", tableStore: "tableStore" }, ngImport: i0__namespace, template: "<div\n [thyTooltip]=\"!disabled && tooltipContent\"\n class=\"the-temp-table-controls-insert-wrapper\"\n [ngClass]=\"{ disabled: disabled }\"\n contenteditable=\"false\"\n (mousedown)=\"onMouseDown($event)\"\n (mouseenter)=\"onMouseEnter($event)\"\n (mouseleave)=\"onMouseLeave($event)\"\n>\n <div\n class=\"the-temp-table-controls-insert-line\"\n *ngIf=\"dotWrapperHovered\"\n [attr.data-dot-type]=\"type\"\n [ngStyle]=\"{ height: type === 'column' && insertLength, width: type === 'row' && insertLength }\"\n ></div>\n</div>\n", directives: [{ type: i5__namespace.ThyTooltipDirective, selector: "[thyTooltip],[thy-tooltip]", inputs: ["thyTooltip", "thyTooltipPlacement", "thyTooltipClass", "thyTooltipShowDelay", "thyTooltipHideDelay", "thyTooltipTrigger", "thyTooltipDisabled", "thyTooltipTemplateContext", "thyTooltipOffset", "thyTooltipPin"], exportAs: ["thyTooltip"] }, { type: i10__namespace.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i10__namespace.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i10__namespace.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }] });
9539
9597
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TheInsertMarkComponent, decorators: [{
9540
9598
  type: i0.Component,
9541
9599
  args: [{
@@ -10049,7 +10107,7 @@
10049
10107
  provide: TheTableToken,
10050
10108
  useExisting: TheTableComponent
10051
10109
  }
10052
- ], viewQueries: [{ propertyName: "tableWrapper", first: true, predicate: ["tableWrapper"], descendants: true, read: i0.ElementRef, static: true }, { propertyName: "theTableElement", first: true, predicate: ["theTable"], descendants: true, read: i0.ElementRef, static: true }, { propertyName: "tbodyElement", first: true, predicate: ["tbody"], descendants: true, read: i0.ElementRef, static: true }], usesInheritance: true, ngImport: i0__namespace, template: "<div\n class=\"the-table-container\"\n theColumnResize\n [ngClass]=\"{\n 'the-table-with-controls': isInTable,\n 'the-numbered-column-container': element?.options?.numberedColumn,\n 'the-table-selection-hide': tableStore.isCellSelecting || tableStore.isRightClicking\n }\"\n>\n <div\n class=\"the-table-row-controls-wrapper\"\n [ngClass]=\"{\n 'the-table-focus': isInTable\n }\"\n >\n <div\n class=\"the-table-corner-controls\"\n [ngClass]=\"{\n visible: !readonly && isInTable,\n active: isSelectedAllCell,\n dangerous: tableStore.isSelectedTable && tableStore.dangerousCells.length > 0\n }\"\n >\n <div class=\"the-table-corner-button\" (mousedown)=\"onSelectTable($event)\"></div>\n <div class=\"the-table-corner-controls-insert-row-marker\">\n <the-table-insert-mark type=\"row\" [at]=\"0\" [tableStore]=\"tableStore\"></the-table-insert-mark>\n </div>\n <div class=\"the-table-corner-controls-insert-column-marker\">\n <the-table-insert-mark type=\"column\" [at]=\"0\" [tableStore]=\"tableStore\"></the-table-insert-mark>\n </div>\n </div>\n <div class=\"the-table-row-controls\">\n <div class=\"the-table-row-controls-inner\">\n <div\n class=\"the-table-row-controls-button-wrap\"\n *ngFor=\"let control of rowControls; let i = index; trackBy: trackByFnRowCotrols\"\n [ngClass]=\"{\n active: tableStore.selectedRowsIndex.includes(control.rowIndex),\n dangerous: tableStore.dangerousRowsIndex.includes(control.rowIndex) && tableStore.dangerousCells.length > 0\n }\"\n >\n <ng-container *ngIf=\"!readonly && isInTable && !element?.options?.numberedColumn\">\n <button\n (mousedown)=\"onRowMouseDown($event, control.rowIndex)\"\n type=\"button\"\n [ngStyle]=\"{ height: control.height + 1 + 'px' }\"\n class=\"the-table-row-controls-button the-table-controls-button\"\n ></button>\n </ng-container>\n <ng-container *ngIf=\"element?.options?.numberedColumn\">\n <div\n [contentEditable]=\"false\"\n contenteditable=\"false\"\n (mousedown)=\"onRowMouseDown($event, control.rowIndex)\"\n class=\"the-table-numbered-controls-button\"\n [ngStyle]=\"{ height: control.height + 1 + 'px' }\"\n >\n <p class=\"row-number d-flex align-items-center\">{{ i + 1 }}</p>\n </div>\n </ng-container>\n <the-table-insert-mark type=\"row\" [at]=\"control.rowIndex + 1\" [tableStore]=\"tableStore\"> </the-table-insert-mark>\n </div>\n </div>\n </div>\n </div>\n <div class=\"the-table-wrapper\" #tableWrapper [ngClass]=\"{ 'the-table-numbered': element?.options?.numberedColumn }\">\n <table class=\"the-table\" #theTable [ngClass]=\"{ 'the-table-with-controls': isInTable }\">\n <colgroup *ngIf=\"columns\">\n <col *ngFor=\"let col of columns\" [ngStyle]=\"{ width: col.width + 'px' }\" />\n </colgroup>\n <thead>\n <tr class=\"the-table-col-controls-wrapper\">\n <th\n class=\"the-table-col-controls\"\n [ngClass]=\"{\n active: tableStore.selectedColumnsIndex.includes(i),\n dangerous: tableStore.dangerousColumnsIndex.includes(i) && tableStore.dangerousCells.length > 0\n }\"\n (mousedown)=\"onColMouseDown($event, i)\"\n *ngFor=\"let control of colControls; let i = index; trackBy: trackByFnColCotrols\"\n >\n <the-table-insert-mark *ngIf=\"isInTable\" type=\"column\" [at]=\"i + 1\" [tableStore]=\"tableStore\">\n </the-table-insert-mark>\n </th>\n </tr>\n </thead>\n <tbody #tbody>\n <slate-children [children]=\"children\" [context]=\"childrenContext\" [viewContext]=\"viewContext\"> </slate-children>\n </tbody>\n </table>\n </div>\n</div>\n", components: [{ type: TheInsertMarkComponent, selector: "the-table-insert-mark", inputs: ["type", "at", "tableStore"] }, { type: i1__namespace.SlateChildrenComponent, selector: "slate-children", inputs: ["children", "context", "viewContext"] }], directives: [{ type: TheColumnResizeDirective, selector: "div[theColumnResize]" }, { type: i10__namespace.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i10__namespace.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i10__namespace.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i10__namespace.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }] });
10110
+ ], viewQueries: [{ propertyName: "tableWrapper", first: true, predicate: ["tableWrapper"], descendants: true, read: i0.ElementRef, static: true }, { propertyName: "theTableElement", first: true, predicate: ["theTable"], descendants: true, read: i0.ElementRef, static: true }, { propertyName: "tbodyElement", first: true, predicate: ["tbody"], descendants: true, read: i0.ElementRef, static: true }], usesInheritance: true, ngImport: i0__namespace, template: "<!-- \u7C7B\u540D the-temp-*: \u4E34\u65F6\u89E3\u51B3\u56E0\u53D7portal\u5F71\u54CD\u8868\u683C\u6837\u5F0F\u95EE\u9898\uFF0C\u540E\u671F\u6539\u56DEthe-* -->\n<div\n class=\"the-temp-table-container\"\n theColumnResize\n [ngClass]=\"{\n 'the-temp-table-with-controls': isInTable,\n 'the-temp-numbered-column-container': element?.options?.numberedColumn,\n 'the-temp-table-selection-hide': tableStore.isCellSelecting || tableStore.isRightClicking\n }\"\n>\n <div\n class=\"the-temp-table-row-controls-wrapper\"\n [ngClass]=\"{\n 'the-temp-table-focus': isInTable\n }\"\n >\n <div\n class=\"the-temp-table-corner-controls\"\n [ngClass]=\"{\n visible: !readonly && isInTable,\n active: isSelectedAllCell,\n dangerous: tableStore.isSelectedTable && tableStore.dangerousCells.length > 0\n }\"\n >\n <div class=\"the-temp-table-corner-button\" (mousedown)=\"onSelectTable($event)\"></div>\n <div class=\"the-temp-table-corner-controls-insert-row-marker\">\n <the-table-insert-mark type=\"row\" [at]=\"0\" [tableStore]=\"tableStore\"></the-table-insert-mark>\n </div>\n <div class=\"the-temp-table-corner-controls-insert-column-marker\">\n <the-table-insert-mark type=\"column\" [at]=\"0\" [tableStore]=\"tableStore\"></the-table-insert-mark>\n </div>\n </div>\n <div class=\"the-temp-table-row-controls\">\n <div class=\"the-temp-table-row-controls-inner\">\n <div\n class=\"the-temp-table-row-controls-button-wrap\"\n *ngFor=\"let control of rowControls; let i = index; trackBy: trackByFnRowCotrols\"\n [ngClass]=\"{\n active: tableStore.selectedRowsIndex.includes(control.rowIndex),\n dangerous: tableStore.dangerousRowsIndex.includes(control.rowIndex) && tableStore.dangerousCells.length > 0\n }\"\n >\n <ng-container *ngIf=\"!readonly && isInTable && !element?.options?.numberedColumn\">\n <button\n (mousedown)=\"onRowMouseDown($event, control.rowIndex)\"\n type=\"button\"\n [ngStyle]=\"{ height: control.height + 1 + 'px' }\"\n class=\"the-temp-table-row-controls-button the-temp-table-controls-button\"\n ></button>\n </ng-container>\n <ng-container *ngIf=\"element?.options?.numberedColumn\">\n <div\n [contentEditable]=\"false\"\n contenteditable=\"false\"\n (mousedown)=\"onRowMouseDown($event, control.rowIndex)\"\n class=\"the-temp-table-numbered-controls-button\"\n [ngStyle]=\"{ height: control.height + 1 + 'px' }\"\n >\n <p class=\"row-number d-flex align-items-center\">{{ i + 1 }}</p>\n </div>\n </ng-container>\n <the-table-insert-mark type=\"row\" [at]=\"control.rowIndex + 1\" [tableStore]=\"tableStore\"> </the-table-insert-mark>\n </div>\n </div>\n </div>\n </div>\n <div class=\"the-temp-table-wrapper\" #tableWrapper [ngClass]=\"{ 'the-temp-table-numbered': element?.options?.numberedColumn }\">\n <table class=\"the-temp-table\" #theTable [ngClass]=\"{ 'the-temp-table-with-controls': isInTable }\">\n <colgroup *ngIf=\"columns\">\n <col *ngFor=\"let col of columns\" [ngStyle]=\"{ width: col.width + 'px' }\" />\n </colgroup>\n <thead>\n <tr class=\"the-temp-table-col-controls-wrapper\">\n <th\n class=\"the-temp-table-col-controls\"\n [ngClass]=\"{\n active: tableStore.selectedColumnsIndex.includes(i),\n dangerous: tableStore.dangerousColumnsIndex.includes(i) && tableStore.dangerousCells.length > 0\n }\"\n (mousedown)=\"onColMouseDown($event, i)\"\n *ngFor=\"let control of colControls; let i = index; trackBy: trackByFnColCotrols\"\n >\n <the-table-insert-mark *ngIf=\"isInTable\" type=\"column\" [at]=\"i + 1\" [tableStore]=\"tableStore\">\n </the-table-insert-mark>\n </th>\n </tr>\n </thead>\n <tbody #tbody>\n <slate-children [children]=\"children\" [context]=\"childrenContext\" [viewContext]=\"viewContext\"> </slate-children>\n </tbody>\n </table>\n </div>\n</div>\n", components: [{ type: TheInsertMarkComponent, selector: "the-table-insert-mark", inputs: ["type", "at", "tableStore"] }, { type: i1__namespace.SlateChildrenComponent, selector: "slate-children", inputs: ["children", "context", "viewContext"] }], directives: [{ type: TheColumnResizeDirective, selector: "div[theColumnResize]" }, { type: i10__namespace.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i10__namespace.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i10__namespace.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i10__namespace.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }] });
10053
10111
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TheTableComponent, decorators: [{
10054
10112
  type: i0.Component,
10055
10113
  args: [{
@@ -10992,12 +11050,12 @@
10992
11050
  };
10993
11051
  TheTdComponent.prototype.updateOverlayHandleRowSize = function () {
10994
11052
  var tableElement = this.tableComponent.nativeElement;
10995
- var rowControl = tableElement.querySelector('.the-table-row-controls');
11053
+ var rowControl = tableElement.querySelector('.the-temp-table-row-controls');
10996
11054
  var rowControlWidth = 11;
10997
11055
  if (rowControl) {
10998
11056
  rowControlWidth = rowControl.getBoundingClientRect().width;
10999
11057
  }
11000
- var width = this.tableComponent.tableWrapper.nativeElement.offsetWidth + rowControlWidth;
11058
+ var width = this.tableComponent.tableWrapper.nativeElement.offsetWidth + rowControlWidth - 2;
11001
11059
  this.overlayRef.addPanelClass(this.rowResizeClass);
11002
11060
  this.overlayRef.updateSize({ width: width, height: OVERLAY_INIT_SIZE });
11003
11061
  };
@@ -11190,8 +11248,7 @@
11190
11248
  TheTdComponent.prototype.applyTopRows = function (rows, deltaY, rowIndex) {
11191
11249
  while (deltaY < 0 && rows[rowIndex]) {
11192
11250
  var rowOffsetHeight = getElementHeight(rows[rowIndex]);
11193
- var rowStyleHeight = coercePixelsFromCssValue(rows[rowIndex].style.height);
11194
- if (rowOffsetHeight > this.tableOptions.minHeightPx && rowOffsetHeight === rowStyleHeight) {
11251
+ if (rowOffsetHeight > this.tableOptions.minHeightPx) {
11195
11252
  if (this.resizingStore.isResizing(deltaY, this.isXAxisHover)) {
11196
11253
  this.resizingStore.storeResizingRow(rows[rowIndex]);
11197
11254
  }
@@ -11211,8 +11268,7 @@
11211
11268
  TheTdComponent.prototype.applyBottomRows = function (rows, deltaY, rowIndex) {
11212
11269
  while (rows[rowIndex] && deltaY > 0) {
11213
11270
  var rowOffsetHeight = getElementHeight(rows[rowIndex]);
11214
- var rowStyleHeight = coercePixelsFromCssValue(rows[rowIndex].style.height);
11215
- if (rowOffsetHeight > this.tableOptions.minHeightPx && rowOffsetHeight === rowStyleHeight) {
11271
+ if (rowOffsetHeight > this.tableOptions.minHeightPx) {
11216
11272
  if (this.resizingStore.isResizing(deltaY, this.isXAxisHover)) {
11217
11273
  this.resizingStore.storeResizingRow(rows[rowIndex]);
11218
11274
  }
@@ -12104,27 +12160,27 @@
12104
12160
 
12105
12161
  var TheQuickToolbarComponent = /** @class */ (function (_super) {
12106
12162
  __extends(TheQuickToolbarComponent, _super);
12107
- function TheQuickToolbarComponent(popoverRef, elementRef) {
12163
+ function TheQuickToolbarComponent(elementRef, cdr) {
12108
12164
  var _this = _super.call(this) || this;
12109
- _this.popoverRef = popoverRef;
12110
12165
  _this.elementRef = elementRef;
12166
+ _this.cdr = cdr;
12111
12167
  _this.ToolbarItemMode = exports.ToolbarItemMode;
12112
12168
  _this.ToolbarActionTypes = exports.ToolbarActionTypes;
12113
12169
  return _this;
12114
12170
  }
12115
12171
  TheQuickToolbarComponent.prototype.handleMouseDown = function (event) {
12116
12172
  if (!this.elementRef.nativeElement.contains(event.target)) {
12117
- QuickInsertEditor.closeQuickToolbar(this.editor);
12173
+ QuickInsertEditor.closeQuickInsertToolbar(this.editor);
12118
12174
  }
12119
12175
  else {
12120
12176
  event.preventDefault();
12121
12177
  }
12122
12178
  };
12123
12179
  TheQuickToolbarComponent.prototype.handleEnter = function () {
12124
- QuickInsertEditor.closeQuickToolbar(this.editor);
12180
+ QuickInsertEditor.closeQuickInsertToolbar(this.editor);
12125
12181
  };
12126
12182
  TheQuickToolbarComponent.prototype.handleEsc = function () {
12127
- QuickInsertEditor.closeQuickToolbar(this.editor);
12183
+ QuickInsertEditor.closeQuickInsertToolbar(this.editor);
12128
12184
  };
12129
12185
  TheQuickToolbarComponent.prototype.ngOnInit = function () {
12130
12186
  this.editorElement = i1.AngularEditor.toDOMNode(this.editor, this.editor);
@@ -12150,15 +12206,15 @@
12150
12206
  };
12151
12207
  return TheQuickToolbarComponent;
12152
12208
  }(core.mixinUnsubscribe(core.MixinBase)));
12153
- TheQuickToolbarComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TheQuickToolbarComponent, deps: [{ token: i1__namespace$3.ThyPopoverRef }, { token: i0__namespace.ElementRef }], target: i0__namespace.ɵɵFactoryTarget.Component });
12154
- TheQuickToolbarComponent.ɵcmp = i0__namespace.ɵɵ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__namespace, 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__namespace$3.ThySelectionListComponent, selector: "thy-selection-list,[thy-selection-list]", inputs: ["thyMultiple", "thyBindKeyEventContainer", "thyScrollContainer", "thyBeforeKeydown", "thyUniqueKey", "thyCompareWith", "thyLayout", "thyAutoActiveFirstItem", "thySize", "thySpaceKeyEnabled"], outputs: ["thySelectionChange"] }, { type: i5__namespace$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__namespace.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i10__namespace.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
12209
+ TheQuickToolbarComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TheQuickToolbarComponent, deps: [{ token: i0__namespace.ElementRef }, { token: i0__namespace.ChangeDetectorRef }], target: i0__namespace.ɵɵFactoryTarget.Component });
12210
+ TheQuickToolbarComponent.ɵcmp = i0__namespace.ɵɵ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__namespace, 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__namespace$7.ThySelectionListComponent, selector: "thy-selection-list,[thy-selection-list]", inputs: ["thyMultiple", "thyBindKeyEventContainer", "thyScrollContainer", "thyBeforeKeydown", "thyUniqueKey", "thyCompareWith", "thyLayout", "thyAutoActiveFirstItem", "thySize", "thySpaceKeyEnabled"], outputs: ["thySelectionChange"] }, { type: i5__namespace$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__namespace.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i10__namespace.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
12155
12211
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TheQuickToolbarComponent, decorators: [{
12156
12212
  type: i0.Component,
12157
12213
  args: [{
12158
12214
  selector: 'the-quick-toolbar',
12159
12215
  templateUrl: 'quick-toolbar.component.html'
12160
12216
  }]
12161
- }], ctorParameters: function () { return [{ type: i1__namespace$3.ThyPopoverRef }, { type: i0__namespace.ElementRef }]; }, propDecorators: { editor: [{
12217
+ }], ctorParameters: function () { return [{ type: i0__namespace.ElementRef }, { type: i0__namespace.ChangeDetectorRef }]; }, propDecorators: { editor: [{
12162
12218
  type: i0.Input
12163
12219
  }], quickToolbarItems: [{
12164
12220
  type: i0.Input
@@ -12173,16 +12229,23 @@
12173
12229
  args: ['document: keydown.escape']
12174
12230
  }] } });
12175
12231
 
12176
- var OperationTypes = ['insert_text', 'remove_node', 'merge_node'];
12177
12232
  var QuickInsertEditor = {
12178
- openQuickToolbar: function (editor, toolbarItems, origin) {
12233
+ openQuickInsertToolbar: function (editor, quickToolbarItems, origin) {
12234
+ if (QuickInsertEditor.isOpenedToolbar(editor)) {
12235
+ return;
12236
+ }
12237
+ if (!origin) {
12238
+ var _a = __read(getBlockAbove(editor), 1), block = _a[0];
12239
+ var rootNode = i1.AngularEditor.toDOMNode(editor, block);
12240
+ origin = rootNode.querySelector('[data-slate-leaf="true"]');
12241
+ }
12179
12242
  var overlay = editor.injector.get(i2.Overlay);
12180
12243
  var viewContainerRef = editor.injector.get(i0.ViewContainerRef);
12181
12244
  var thyPopover = editor.injector.get(i1$2.ThyPopover);
12182
12245
  var quickToolbarRef = thyPopover.open(TheQuickToolbarComponent, {
12183
12246
  initialState: {
12184
12247
  editor: editor,
12185
- quickToolbarItems: toolbarItems
12248
+ quickToolbarItems: quickToolbarItems
12186
12249
  },
12187
12250
  origin: origin,
12188
12251
  viewContainerRef: viewContainerRef,
@@ -12195,53 +12258,39 @@
12195
12258
  scrollStrategy: overlay.scrollStrategies.reposition(),
12196
12259
  manualClosure: true
12197
12260
  });
12261
+ quickToolbarRef.componentInstance.cdr.markForCheck();
12198
12262
  THE_EDITOR_QUICK_TOOLBAR_REF.set(editor, quickToolbarRef);
12199
12263
  },
12200
- closeQuickToolbar: function (editor) {
12264
+ closeQuickInsertToolbar: function (editor) {
12201
12265
  var quickToolbarRef = THE_EDITOR_QUICK_TOOLBAR_REF.get(editor);
12202
12266
  if (quickToolbarRef) {
12203
12267
  quickToolbarRef.close();
12204
12268
  THE_EDITOR_QUICK_TOOLBAR_REF.set(editor, null);
12205
12269
  }
12206
12270
  },
12207
- isOpenToolbar: function (editor, opTypes) {
12208
- if (opTypes === void 0) { opTypes = OperationTypes; }
12209
- var isCollapsedCursor = TheEditor.isFocused(editor) && editor.selection && slate.Range.isCollapsed(editor.selection);
12210
- if (!isCollapsedCursor) {
12211
- return false;
12212
- }
12213
- var block = slate.Node.ancestor(editor, [editor.selection.anchor.path[0]]);
12214
- var undos = editor.history.undos;
12215
- var lastBatch = undos[undos.length - 1];
12216
- var lastOp = lastBatch && lastBatch[lastBatch.length - 1];
12217
- if (lastOp &&
12218
- block.children.length === 1 &&
12219
- block.type === exports.ElementKinds.paragraph &&
12220
- slate.Node.string(block) === QUICK_TOOLBAR_HOTKEY &&
12221
- opTypes.includes(lastOp.type) &&
12222
- (lastOp.text === QUICK_TOOLBAR_HOTKEY || lastOp.text === undefined)) {
12223
- return true;
12224
- }
12225
- return false;
12271
+ isOpenedToolbar: function (editor) {
12272
+ var quickToolbarRef = THE_EDITOR_QUICK_TOOLBAR_REF.get(editor);
12273
+ return !!quickToolbarRef;
12226
12274
  }
12227
12275
  };
12228
12276
 
12229
12277
  var withQuickInsert = function (editor) {
12230
12278
  var onKeydown = editor.onKeydown, deleteBackward = editor.deleteBackward, onChange = editor.onChange;
12279
+ var presseingQuickInsertHotkey = false;
12231
12280
  editor.onKeydown = function (event) {
12232
- if (event.key === QUICK_TOOLBAR_HOTKEY && isCleanEmptyParagraph(editor)) {
12233
- var rootNode = i1.AngularEditor.toDOMNode(editor, slate.Node.ancestor(editor, [editor.selection.anchor.path[0]]));
12234
- var theEditorComponent = editor.injector.get(TheEditorComponent);
12235
- var quickToolbars = theEditorComponent.quickToolbarItems;
12236
- var leafElement = rootNode.querySelector('[data-slate-leaf="true"]');
12237
- var origin = leafElement || rootNode;
12238
- QuickInsertEditor.openQuickToolbar(editor, quickToolbars, origin);
12281
+ var _a;
12282
+ if (event.key === QUICK_TOOLBAR_HOTKEY) {
12283
+ var types = __spreadArray([], __read((((_a = editor.options) === null || _a === void 0 ? void 0 : _a.triggerQuickToolbarTypes) || [])));
12284
+ var _b = __read(getBlockAbove(editor), 1), block = _b[0];
12285
+ if (isPureEmptyParagraph(editor, block) && allowOpenQuickToolbar(editor, types)) {
12286
+ presseingQuickInsertHotkey = true;
12287
+ }
12239
12288
  }
12240
12289
  onKeydown(event);
12241
12290
  };
12242
12291
  editor.deleteBackward = function (unit) {
12243
- if (!QuickInsertEditor.isOpenToolbar(editor, ['remove_text'])) {
12244
- QuickInsertEditor.closeQuickToolbar(editor);
12292
+ if (QuickInsertEditor.isOpenedToolbar(editor)) {
12293
+ QuickInsertEditor.closeQuickInsertToolbar(editor);
12245
12294
  }
12246
12295
  deleteBackward(unit);
12247
12296
  };
@@ -12249,16 +12298,33 @@
12249
12298
  var _a;
12250
12299
  onChange();
12251
12300
  if (editor.selection) {
12301
+ var _b = __read(getBlockAbove(editor), 2), block = _b[0], path = _b[1];
12302
+ // quick insert plus
12252
12303
  var editorComponent = editor.injector.get(TheEditorComponent);
12253
12304
  (_a = editorComponent.quickInsertInstance) === null || _a === void 0 ? void 0 : _a.checkStatus();
12254
- var block = slate.Node.ancestor(editor, [editor.selection.anchor.path[0]]);
12255
- if (!isCleanEmptyParagraph(editor) && slate.Node.string(block) !== QUICK_TOOLBAR_HOTKEY) {
12256
- QuickInsertEditor.closeQuickToolbar(editor);
12305
+ if (presseingQuickInsertHotkey && slate.Node.string(block) === QUICK_TOOLBAR_HOTKEY) {
12306
+ QuickInsertEditor.openQuickInsertToolbar(editor, editorComponent.quickToolbarItems);
12307
+ presseingQuickInsertHotkey = false;
12308
+ return;
12309
+ }
12310
+ else {
12311
+ presseingQuickInsertHotkey = false;
12312
+ }
12313
+ if (QuickInsertEditor.isOpenedToolbar(editor) && !isPureEmptyParagraph(editor, block) && slate.Node.string(block) !== QUICK_TOOLBAR_HOTKEY) {
12314
+ QuickInsertEditor.closeQuickInsertToolbar(editor);
12257
12315
  }
12258
12316
  }
12259
12317
  };
12260
12318
  return editor;
12261
12319
  };
12320
+ var allowOpenQuickToolbar = function (editor, allowTypes) {
12321
+ var _b = __read(getBlockAbove(editor), 2), block = _b[0], path = _b[1];
12322
+ var parentNode = slate.Node.parent(editor, path);
12323
+ if (path.length === 1 || (parentNode && allowTypes.includes(parentNode.type))) {
12324
+ return true;
12325
+ }
12326
+ return false;
12327
+ };
12262
12328
 
12263
12329
  var withSoftBreak = function (options) {
12264
12330
  if (options === void 0) { options = { rules: [{ hotkey: 'shift+enter' }] }; }
@@ -12562,6 +12628,78 @@
12562
12628
  args: ['class.disabled']
12563
12629
  }] } });
12564
12630
 
12631
+ var onKeydownTextIndent = function (editor, event, kinds, textIndentDisabled) {
12632
+ var selection = editor.selection;
12633
+ var isExpanded = slate.Range.isExpanded(selection);
12634
+ var nodes = Array.from(slate.Editor.nodes(editor, {
12635
+ mode: 'highest',
12636
+ match: function (node) { return slate.Element.isElement(node) && kinds.includes(node.type); }
12637
+ }));
12638
+ var _a = __read(nodes, 1), startBlock = _a[0];
12639
+ if (!startBlock) {
12640
+ return false;
12641
+ }
12642
+ var _b = __read(startBlock, 2), block = _b[0], path = _b[1];
12643
+ var isStart = slate.Editor.isStart(editor, selection.anchor, path);
12644
+ if (isHotkey.isKeyHotkey('Tab', event)) {
12645
+ event.preventDefault();
12646
+ if (startBlock && (isExpanded || isStart)) {
12647
+ if (!editor.isVoid(block)) {
12648
+ var textIndent = block.textIndent, type = block.type;
12649
+ // do not apply first-line indentation for lists
12650
+ if (!textIndent && !textIndentDisabled.includes(type)) {
12651
+ IndentEditor.setTextIndent(editor, kinds, 2);
12652
+ return true;
12653
+ }
12654
+ else {
12655
+ IndentEditor.setIndent(editor);
12656
+ return true;
12657
+ }
12658
+ }
12659
+ }
12660
+ else {
12661
+ editor.insertText(TAB_SPACE);
12662
+ return true;
12663
+ }
12664
+ }
12665
+ if (isHotkey.isKeyHotkey('shift+Tab', event)) {
12666
+ if (startBlock && (isExpanded || isStart)) {
12667
+ if (!editor.isVoid(block)) {
12668
+ return IndentEditor.cancelTextIntent(editor, event, block, kinds);
12669
+ }
12670
+ }
12671
+ }
12672
+ if (selection && slate.Range.isCollapsed(selection) && i1.hotkeys.isDeleteBackward(event)) {
12673
+ if (startBlock && isStart) {
12674
+ return IndentEditor.cancelTextIntent(editor, event, block, kinds);
12675
+ }
12676
+ }
12677
+ return false;
12678
+ };
12679
+
12680
+ var withIndent = function (kinds) { return function (editor) {
12681
+ var onKeydown = editor.onKeydown;
12682
+ editor.onKeydown = function (event) {
12683
+ var _a, _b, _c, _d;
12684
+ var indentTypes = kinds;
12685
+ var disableIndentTypes = [exports.ElementKinds.bulletedList, exports.ElementKinds.numberedList, exports.ElementKinds.checkItem];
12686
+ if ((_b = (_a = editor.extraIndentOptions) === null || _a === void 0 ? void 0 : _a.indentTypes) === null || _b === void 0 ? void 0 : _b.length) {
12687
+ indentTypes = mergIndentTypes(kinds, editor.extraIndentOptions.indentTypes);
12688
+ }
12689
+ if ((_d = (_c = editor.extraIndentOptions) === null || _c === void 0 ? void 0 : _c.disabledIndentTypes) === null || _d === void 0 ? void 0 : _d.length) {
12690
+ disableIndentTypes = mergIndentTypes(disableIndentTypes, editor.extraIndentOptions.disabledIndentTypes);
12691
+ }
12692
+ var isContinue = !onKeydownTextIndent(editor, event, indentTypes, disableIndentTypes);
12693
+ if (isContinue) {
12694
+ onKeydown(event);
12695
+ }
12696
+ };
12697
+ return editor;
12698
+ }; };
12699
+ var mergIndentTypes = function (defaultTypes, indentTypes) {
12700
+ return Array.from(new Set(__spreadArray(__spreadArray([], __read(defaultTypes)), __read(indentTypes))));
12701
+ };
12702
+
12565
12703
  var MaxIndent = 11;
12566
12704
  var includesIndentTypes = __spreadArray([
12567
12705
  exports.ElementKinds.checkItem,
@@ -12569,11 +12707,15 @@
12569
12707
  exports.ElementKinds.bulletedList,
12570
12708
  exports.ElementKinds.paragraph
12571
12709
  ], __read(HEADING_TYPES));
12710
+ var getIndentTypes = function (editor) {
12711
+ var indentTypes = editor.extraIndentOptions ? editor.extraIndentOptions.indentTypes : [];
12712
+ return mergIndentTypes(includesIndentTypes, indentTypes);
12713
+ };
12572
12714
  var IndentEditor = {
12573
12715
  setIndent: function (editor) {
12574
12716
  var nodes = Array.from(slate.Editor.nodes(editor, {
12575
12717
  mode: 'highest',
12576
- match: function (n) { return slate.Element.isElement(n) && includesIndentTypes.includes(n.type); }
12718
+ match: function (n) { return slate.Element.isElement(n) && getIndentTypes(editor).includes(n.type); }
12577
12719
  }));
12578
12720
  var _a = __read(nodes, 1), startBlock = _a[0];
12579
12721
  if (startBlock) {
@@ -12583,7 +12725,7 @@
12583
12725
  if (indent <= MaxIndent) {
12584
12726
  slate.Transforms.setNodes(editor, { indent: indent }, {
12585
12727
  mode: 'highest',
12586
- match: function (n) { return slate.Element.isElement(n) && includesIndentTypes.includes(n.type); }
12728
+ match: function (n) { return slate.Element.isElement(n) && getIndentTypes(editor).includes(n.type); }
12587
12729
  });
12588
12730
  }
12589
12731
  }
@@ -12591,7 +12733,7 @@
12591
12733
  cancelIndent: function (editor) {
12592
12734
  var nodes = Array.from(slate.Editor.nodes(editor, {
12593
12735
  mode: 'highest',
12594
- match: function (n) { return slate.Element.isElement(n) && includesIndentTypes.includes(n.type); }
12736
+ match: function (n) { return slate.Element.isElement(n) && getIndentTypes(editor).includes(n.type); }
12595
12737
  }));
12596
12738
  var _a = __read(nodes, 1), startBlock = _a[0];
12597
12739
  if (startBlock) {
@@ -12599,7 +12741,7 @@
12599
12741
  indent = indent === 1 ? null : (indent -= 1);
12600
12742
  slate.Transforms.setNodes(editor, { indent: indent }, {
12601
12743
  mode: 'highest',
12602
- match: function (n) { return slate.Element.isElement(n) && includesIndentTypes.includes(n.type); }
12744
+ match: function (n) { return slate.Element.isElement(n) && getIndentTypes(editor).includes(n.type); }
12603
12745
  });
12604
12746
  }
12605
12747
  },
@@ -12631,14 +12773,8 @@
12631
12773
  },
12632
12774
  isDisabled: function (editor) {
12633
12775
  if (editor.selection) {
12634
- var allowGroup = __spreadArray([
12635
- exports.ElementKinds.paragraph,
12636
- exports.ElementKinds.numberedList,
12637
- exports.ElementKinds.bulletedList,
12638
- exports.ElementKinds.checkItem
12639
- ], __read(HEADING_TYPES));
12640
12776
  var anchorBlock$1 = anchorBlock(editor);
12641
- return anchorBlock$1 && !allowGroup.includes(anchorBlock$1 === null || anchorBlock$1 === void 0 ? void 0 : anchorBlock$1.type);
12777
+ return anchorBlock$1 && !getIndentTypes(editor).includes(anchorBlock$1 === null || anchorBlock$1 === void 0 ? void 0 : anchorBlock$1.type);
12642
12778
  }
12643
12779
  return false;
12644
12780
  }
@@ -12668,67 +12804,6 @@
12668
12804
  }
12669
12805
  ];
12670
12806
 
12671
- var onKeydownTextIndent = function (editor, event, kinds) {
12672
- var selection = editor.selection;
12673
- var isExpanded = slate.Range.isExpanded(selection);
12674
- var nodes = Array.from(slate.Editor.nodes(editor, {
12675
- mode: 'highest',
12676
- match: function (node) { return slate.Element.isElement(node) && kinds.includes(node.type); }
12677
- }));
12678
- var _a = __read(nodes, 1), startBlock = _a[0];
12679
- if (!startBlock) {
12680
- return false;
12681
- }
12682
- var _b = __read(startBlock, 2), block = _b[0], path = _b[1];
12683
- var isStart = slate.Editor.isStart(editor, selection.anchor, path);
12684
- var textIndentDisable = [exports.ElementKinds.bulletedList, exports.ElementKinds.numberedList, exports.ElementKinds.checkItem];
12685
- if (isHotkey.isKeyHotkey('Tab', event)) {
12686
- event.preventDefault();
12687
- if (startBlock && (isExpanded || isStart)) {
12688
- if (!editor.isVoid(block)) {
12689
- var textIndent = block.textIndent, type = block.type;
12690
- // do not apply first-line indentation for lists
12691
- if (!textIndent && !textIndentDisable.includes(type)) {
12692
- IndentEditor.setTextIndent(editor, kinds, 2);
12693
- return true;
12694
- }
12695
- else {
12696
- IndentEditor.setIndent(editor);
12697
- return true;
12698
- }
12699
- }
12700
- }
12701
- else {
12702
- editor.insertText(TAB_SPACE);
12703
- return true;
12704
- }
12705
- }
12706
- if (isHotkey.isKeyHotkey('shift+Tab', event)) {
12707
- if (startBlock && (isExpanded || isStart)) {
12708
- if (!editor.isVoid(block)) {
12709
- return IndentEditor.cancelTextIntent(editor, event, block, kinds);
12710
- }
12711
- }
12712
- }
12713
- if (selection && slate.Range.isCollapsed(selection) && i1.hotkeys.isDeleteBackward(event)) {
12714
- if (startBlock && isStart) {
12715
- return IndentEditor.cancelTextIntent(editor, event, block, kinds);
12716
- }
12717
- }
12718
- return false;
12719
- };
12720
-
12721
- var withIndent = function (kinds) { return function (editor) {
12722
- var onKeydown = editor.onKeydown;
12723
- editor.onKeydown = function (event) {
12724
- var isContinue = !onKeydownTextIndent(editor, event, kinds);
12725
- if (isContinue) {
12726
- onKeydown(event);
12727
- }
12728
- };
12729
- return editor;
12730
- }; };
12731
-
12732
12807
  var internalPlugins = [
12733
12808
  withTheHistory,
12734
12809
  withAutoInsertData(),
@@ -12759,7 +12834,7 @@
12759
12834
  }),
12760
12835
  withBlockquote,
12761
12836
  withNodeID({ idKey: ELEMENT_UNIQUE_ID, idCreator: idCreator }),
12762
- withAutoFormat({ rules: autoFormatRules }),
12837
+ withAutoFormat(),
12763
12838
  withTransforms(),
12764
12839
  withTrailingNode({ type: exports.ElementKinds.paragraph, level: 0 }),
12765
12840
  withMoveSelection,
@@ -13403,7 +13478,11 @@
13403
13478
  TheQuickInsertComponent.prototype.handleClick = function (event) {
13404
13479
  event.stopPropagation();
13405
13480
  event.preventDefault();
13406
- QuickInsertEditor.openQuickToolbar(this.editor, this.quickToolbarItems, this.iconElement.nativeElement);
13481
+ if (QuickInsertEditor.isOpenedToolbar(this.editor)) {
13482
+ QuickInsertEditor.closeQuickInsertToolbar(this.editor);
13483
+ return;
13484
+ }
13485
+ QuickInsertEditor.openQuickInsertToolbar(this.editor, this.quickToolbarItems, this.iconElement.nativeElement);
13407
13486
  };
13408
13487
  return TheQuickInsertComponent;
13409
13488
  }());
@@ -13700,11 +13779,14 @@
13700
13779
  };
13701
13780
  TheEditorComponent.prototype.initialize = function () {
13702
13781
  var _this = this;
13703
- var _a, _b;
13782
+ var _a, _b, _c, _d;
13704
13783
  this.editor = withTheEditor(this.thePlugins, slateHistory.withHistory(i1.withAngular(slate.createEditor(), CLIPBOARD_FORMAT_KEY)));
13705
13784
  this.generateDecorate();
13706
13785
  this.editor.disabled = (_a = this.theOptions) === null || _a === void 0 ? void 0 : _a.disabled;
13707
13786
  this.editor.extraElementOptions = (_b = this.theOptions) === null || _b === void 0 ? void 0 : _b.extraElementOptions;
13787
+ this.editor.extraAutoFormatRules = (_c = this.theOptions) === null || _c === void 0 ? void 0 : _c.extraAutoFormatRules;
13788
+ this.editor.extraIndentOptions = (_d = this.theOptions) === null || _d === void 0 ? void 0 : _d.extraIndentOptions;
13789
+ this.editor.options = this.theOptions;
13708
13790
  setEditorUUID(this.editor, idCreator());
13709
13791
  this.theContextService.initialize({
13710
13792
  theOptions: this.theOptions,
@@ -14129,7 +14211,7 @@
14129
14211
  i3$1.ThyNavModule,
14130
14212
  i2$2.ThyFormModule,
14131
14213
  i5$2.ThySharedModule,
14132
- i2$3.ThyListModule,
14214
+ i1$7.ThyListModule,
14133
14215
  i5.ThyTooltipModule,
14134
14216
  i6.ThyProgressModule,
14135
14217
  autocomplete.ThyAutocompleteModule,
@@ -14230,7 +14312,7 @@
14230
14312
  i3$1.ThyNavModule,
14231
14313
  i2$2.ThyFormModule,
14232
14314
  i5$2.ThySharedModule,
14233
- i2$3.ThyListModule,
14315
+ i1$7.ThyListModule,
14234
14316
  i5.ThyTooltipModule,
14235
14317
  i6.ThyProgressModule,
14236
14318
  autocomplete.ThyAutocompleteModule,
@@ -14357,6 +14439,7 @@
14357
14439
  exports.htmlToTheia = htmlToTheia;
14358
14440
  exports.inValidTypes = inValidTypes;
14359
14441
  exports.isCleanEmptyParagraph = isCleanEmptyParagraph;
14442
+ exports.isPureEmptyParagraph = isPureEmptyParagraph;
14360
14443
  exports.mergeElementOptions = mergeElementOptions;
14361
14444
  exports.plainToTheia = plainToTheia;
14362
14445
  exports.toolbarCompose = toolbarCompose;