@worktile/theia 2.4.0 → 2.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/worktile-theia.umd.js +979 -921
- package/bundles/worktile-theia.umd.js.map +1 -1
- package/constants/auto-format-rules.d.ts +1 -1
- package/esm2015/constants/auto-format-rules.js +3 -2
- package/esm2015/editor.component.js +4 -2
- package/esm2015/interfaces/auto-format.js +1 -1
- package/esm2015/interfaces/editor.js +1 -1
- package/esm2015/plugins/autoformat/autoformat.plugin.js +23 -6
- package/esm2015/plugins/indent/indent.editor.js +11 -13
- package/esm2015/plugins/indent/indent.plugin.js +15 -2
- package/esm2015/plugins/indent/on-keydown-indent.js +3 -5
- package/esm2015/plugins/index.js +2 -3
- package/esm2015/plugins/quick-insert/components/quick-insert.component.js +6 -2
- package/esm2015/plugins/quick-insert/components/quick-toolbar/quick-toolbar.component.js +14 -15
- package/esm2015/plugins/quick-insert/quick-insert.editor.js +17 -27
- package/esm2015/plugins/quick-insert/quick-insert.plugin.js +14 -13
- package/esm2015/plugins/table/components/table.component.js +3 -2
- package/esm2015/transforms/index.js +3 -2
- package/esm2015/transforms/insert-element-next.js +1 -1
- package/esm2015/transforms/insert-element-node.js +36 -0
- package/fesm2015/worktile-theia.js +1014 -953
- package/fesm2015/worktile-theia.js.map +1 -1
- package/interfaces/auto-format.d.ts +1 -0
- package/interfaces/editor.d.ts +10 -0
- package/package.json +1 -1
- package/plugins/autoformat/autoformat.plugin.d.ts +1 -2
- package/plugins/indent/indent.plugin.d.ts +1 -0
- package/plugins/indent/on-keydown-indent.d.ts +1 -1
- package/plugins/quick-insert/components/quick-toolbar/quick-toolbar.component.d.ts +3 -4
- package/plugins/quick-insert/quick-insert.editor.d.ts +3 -4
- package/plugins/table/components/table.component.scss +20 -17
- package/transforms/index.d.ts +2 -1
- package/transforms/insert-element-node.d.ts +2 -0
|
@@ -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('
|
|
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', '
|
|
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.
|
|
5
|
-
})(this, (function (exports, i0, i10, i4, i1, core, isHotkey, slate, slateHistory,
|
|
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
|
|
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,610 +2048,174 @@
|
|
|
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
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
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
|
-
|
|
2009
|
-
|
|
2064
|
+
};
|
|
2065
|
+
TheConversionHintComponent.prototype.mouseleave = function () {
|
|
2066
|
+
if (this.pauseOnHover) {
|
|
2067
|
+
this.creatCloseTimer();
|
|
2010
2068
|
}
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
}
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
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
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
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; }
|
|
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));
|
|
2131
|
+
}
|
|
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;
|
|
2124
2141
|
}
|
|
2125
|
-
|
|
2126
|
-
|
|
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;
|
|
2142
|
+
if (/<[^>]+>/.test(value)) {
|
|
2143
|
+
return htmlToTheia(value);
|
|
2131
2144
|
}
|
|
2132
|
-
return
|
|
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);
|
|
2133
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);
|
|
2134
2161
|
};
|
|
2135
2162
|
|
|
2136
|
-
var
|
|
2137
|
-
|
|
2138
|
-
|
|
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
|
-
});
|
|
2152
|
-
}
|
|
2153
|
-
else {
|
|
2154
|
-
if (isNumberedList || isBulletedList) {
|
|
2155
|
-
ListEditor.unwrapList(editor);
|
|
2156
|
-
}
|
|
2157
|
-
slate.Transforms.setNodes(editor, {
|
|
2158
|
-
type: exports.ElementKinds.checkItem
|
|
2159
|
-
});
|
|
2160
|
-
}
|
|
2161
|
-
}
|
|
2163
|
+
var getToolbarClass = function (editor) {
|
|
2164
|
+
var uuid = getEditorUUID(editor);
|
|
2165
|
+
return "the-toolbar-" + uuid;
|
|
2162
2166
|
};
|
|
2163
2167
|
|
|
2164
|
-
var
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
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;
|
|
2181
|
+
}
|
|
2182
|
+
var block = slate.Node.ancestor(editor, [editor.selection.anchor.path[0]]);
|
|
2183
|
+
var textIndent = 'textIndent';
|
|
2184
|
+
var align = 'align';
|
|
2185
|
+
var hasTextIndent = block[textIndent];
|
|
2186
|
+
var alignValue = block[align];
|
|
2187
|
+
var hasIndent = block[exports.ElementKinds.indent];
|
|
2188
|
+
if (slate.Node.string(block) === '' &&
|
|
2189
|
+
slate.Element.isElement(block) &&
|
|
2190
|
+
block.type === exports.ElementKinds.paragraph &&
|
|
2191
|
+
block.children.length === 1 &&
|
|
2192
|
+
slate.Text.isText(block.children[0]) &&
|
|
2193
|
+
!slate.Editor.isVoid(editor, block) &&
|
|
2194
|
+
!hasIndent &&
|
|
2195
|
+
!hasTextIndent &&
|
|
2196
|
+
(!alignValue || alignValue === exports.Alignment.left)) {
|
|
2197
|
+
return true;
|
|
2186
2198
|
}
|
|
2199
|
+
return false;
|
|
2187
2200
|
};
|
|
2188
2201
|
|
|
2189
|
-
var
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
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 });
|
|
2202
|
+
var mergeElementOptions = function (elementOptions) {
|
|
2203
|
+
elementOptions = elementOptions.filter(function (item) { return item.inValidChildrenTypes.length > 0; });
|
|
2204
|
+
var combinationData = __spreadArray(__spreadArray([], __read(DefaultElementOptions)), __read(elementOptions));
|
|
2205
|
+
var dataInfo = {};
|
|
2206
|
+
combinationData.forEach(function (item) {
|
|
2207
|
+
var type = item.type, inValidChildrenTypes = item.inValidChildrenTypes, isIndivisible = item.isIndivisible, isSecondaryContainer = item.isSecondaryContainer;
|
|
2208
|
+
if (!dataInfo[type]) {
|
|
2209
|
+
dataInfo[type] = {
|
|
2210
|
+
type: type,
|
|
2211
|
+
inValidChildrenTypes: inValidChildrenTypes,
|
|
2212
|
+
isIndivisible: isIndivisible,
|
|
2213
|
+
isSecondaryContainer: isSecondaryContainer
|
|
2214
|
+
};
|
|
2222
2215
|
}
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
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;
|
|
2234
|
-
}
|
|
2235
|
-
};
|
|
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;
|
|
2266
|
-
}
|
|
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;
|
|
2577
|
-
};
|
|
2578
|
-
|
|
2579
|
-
var mergeElementOptions = function (elementOptions) {
|
|
2580
|
-
elementOptions = elementOptions.filter(function (item) { return item.inValidChildrenTypes.length > 0; });
|
|
2581
|
-
var combinationData = __spreadArray(__spreadArray([], __read(DefaultElementOptions)), __read(elementOptions));
|
|
2582
|
-
var dataInfo = {};
|
|
2583
|
-
combinationData.forEach(function (item) {
|
|
2584
|
-
var type = item.type, inValidChildrenTypes = item.inValidChildrenTypes, isIndivisible = item.isIndivisible, isSecondaryContainer = item.isSecondaryContainer;
|
|
2585
|
-
if (!dataInfo[type]) {
|
|
2586
|
-
dataInfo[type] = {
|
|
2587
|
-
type: type,
|
|
2588
|
-
inValidChildrenTypes: inValidChildrenTypes,
|
|
2589
|
-
isIndivisible: isIndivisible,
|
|
2590
|
-
isSecondaryContainer: isSecondaryContainer
|
|
2591
|
-
};
|
|
2592
|
-
}
|
|
2593
|
-
dataInfo[type].inValidChildrenTypes = Array.from(new Set(__spreadArray(__spreadArray([], __read(inValidChildrenTypes)), __read(dataInfo[type].inValidChildrenTypes))));
|
|
2594
|
-
});
|
|
2595
|
-
return dataInfo;
|
|
2216
|
+
dataInfo[type].inValidChildrenTypes = Array.from(new Set(__spreadArray(__spreadArray([], __read(inValidChildrenTypes)), __read(dataInfo[type].inValidChildrenTypes))));
|
|
2217
|
+
});
|
|
2218
|
+
return dataInfo;
|
|
2596
2219
|
};
|
|
2597
2220
|
|
|
2598
2221
|
/** Converts CSS pixel values to numbers, eg "123px" to 123. Returns NaN for non pixel values. */
|
|
@@ -3537,6 +3160,10 @@
|
|
|
3537
3160
|
return listItemNode.children.length === 1 && type === exports.ElementKinds.paragraph;
|
|
3538
3161
|
};
|
|
3539
3162
|
|
|
3163
|
+
var isNodeTypeList = function (n) {
|
|
3164
|
+
return [exports.ElementKinds.bulletedList, exports.ElementKinds.numberedList].includes(n.type);
|
|
3165
|
+
};
|
|
3166
|
+
|
|
3540
3167
|
/**
|
|
3541
3168
|
* list 中 是否是单个listItem,且listItem没有子列表
|
|
3542
3169
|
*/
|
|
@@ -4744,205 +4371,627 @@
|
|
|
4744
4371
|
if (operation.type === 'merge_node' && (!filterText || operation.properties.type)) {
|
|
4745
4372
|
editor.removedIDs.add(operation.properties[idKey]);
|
|
4746
4373
|
}
|
|
4747
|
-
return apply(operation);
|
|
4748
|
-
};
|
|
4749
|
-
editor.getFragment = function () {
|
|
4750
|
-
var fragment = _.cloneDeep(getFragment());
|
|
4751
|
-
return deleteElementKey(fragment, idKey);
|
|
4752
|
-
};
|
|
4753
|
-
return editor;
|
|
4754
|
-
};
|
|
4374
|
+
return apply(operation);
|
|
4375
|
+
};
|
|
4376
|
+
editor.getFragment = function () {
|
|
4377
|
+
var fragment = _.cloneDeep(getFragment());
|
|
4378
|
+
return deleteElementKey(fragment, idKey);
|
|
4379
|
+
};
|
|
4380
|
+
return editor;
|
|
4381
|
+
};
|
|
4382
|
+
};
|
|
4383
|
+
|
|
4384
|
+
var autoFormatBlock = function (editor, type, at, _a, markups) {
|
|
4385
|
+
var preFormat = _a.preFormat, format = _a.format;
|
|
4386
|
+
slate.Transforms.delete(editor, { at: at });
|
|
4387
|
+
if (preFormat) {
|
|
4388
|
+
preFormat(editor);
|
|
4389
|
+
}
|
|
4390
|
+
if (!format) {
|
|
4391
|
+
slate.Transforms.setNodes(editor, { type: type }, { match: function (n) { return slate.Editor.isBlock(editor, n); } });
|
|
4392
|
+
}
|
|
4393
|
+
else {
|
|
4394
|
+
format(editor, markups);
|
|
4395
|
+
}
|
|
4396
|
+
};
|
|
4397
|
+
|
|
4398
|
+
var autoFormatInline = function (editor, _a) {
|
|
4399
|
+
var type = _a.type, between = _a.between, markup = _a.markup, ignoreTrim = _a.ignoreTrim, format = _a.format;
|
|
4400
|
+
var selection = editor.selection;
|
|
4401
|
+
var startMarkup = between ? between[0] : markup;
|
|
4402
|
+
var endMarkup = between ? between[1] : '';
|
|
4403
|
+
var endMarkupPointBefore = selection.anchor;
|
|
4404
|
+
if (endMarkup) {
|
|
4405
|
+
endMarkupPointBefore = getPointBefore(editor, selection, {
|
|
4406
|
+
matchString: endMarkup
|
|
4407
|
+
});
|
|
4408
|
+
if (!endMarkupPointBefore) {
|
|
4409
|
+
return false;
|
|
4410
|
+
}
|
|
4411
|
+
}
|
|
4412
|
+
var startMarkupPointAfter = getPointBefore(editor, endMarkupPointBefore, {
|
|
4413
|
+
matchString: startMarkup,
|
|
4414
|
+
skipInvalid: true,
|
|
4415
|
+
afterMatch: true
|
|
4416
|
+
});
|
|
4417
|
+
if (!startMarkupPointAfter) {
|
|
4418
|
+
return false;
|
|
4419
|
+
}
|
|
4420
|
+
// found
|
|
4421
|
+
var markupRange = {
|
|
4422
|
+
anchor: startMarkupPointAfter,
|
|
4423
|
+
focus: endMarkupPointBefore
|
|
4424
|
+
};
|
|
4425
|
+
if (!ignoreTrim) {
|
|
4426
|
+
var markupText = getText(editor, markupRange);
|
|
4427
|
+
if (markupText.trim() !== markupText) {
|
|
4428
|
+
return false;
|
|
4429
|
+
}
|
|
4430
|
+
}
|
|
4431
|
+
// delete end markup
|
|
4432
|
+
if (endMarkup) {
|
|
4433
|
+
endMarkupPointBefore = getPointBefore(editor, selection, {
|
|
4434
|
+
matchString: endMarkup
|
|
4435
|
+
});
|
|
4436
|
+
slate.Transforms.delete(editor, {
|
|
4437
|
+
at: {
|
|
4438
|
+
anchor: endMarkupPointBefore,
|
|
4439
|
+
focus: selection.anchor
|
|
4440
|
+
}
|
|
4441
|
+
});
|
|
4442
|
+
}
|
|
4443
|
+
var startMarkupPointBefore = getPointBefore(editor, selection, {
|
|
4444
|
+
matchString: startMarkup,
|
|
4445
|
+
skipInvalid: true
|
|
4446
|
+
});
|
|
4447
|
+
if (format) {
|
|
4448
|
+
var markupText = getText(editor, markupRange);
|
|
4449
|
+
format(editor, markupText);
|
|
4450
|
+
// delete start to end selection
|
|
4451
|
+
slate.Transforms.delete(editor, {
|
|
4452
|
+
at: {
|
|
4453
|
+
anchor: startMarkupPointBefore,
|
|
4454
|
+
focus: selection.anchor
|
|
4455
|
+
}
|
|
4456
|
+
});
|
|
4457
|
+
}
|
|
4458
|
+
else {
|
|
4459
|
+
// add mark to the text between the markups
|
|
4460
|
+
slate.Transforms.select(editor, markupRange);
|
|
4461
|
+
editor.addMark(type, true);
|
|
4462
|
+
slate.Transforms.collapse(editor, { edge: 'end' });
|
|
4463
|
+
editor.removeMark(type, false);
|
|
4464
|
+
// delete start markup
|
|
4465
|
+
slate.Transforms.delete(editor, {
|
|
4466
|
+
at: {
|
|
4467
|
+
anchor: startMarkupPointBefore,
|
|
4468
|
+
focus: startMarkupPointAfter
|
|
4469
|
+
}
|
|
4470
|
+
});
|
|
4471
|
+
}
|
|
4472
|
+
return true;
|
|
4473
|
+
};
|
|
4474
|
+
|
|
4475
|
+
var ListEditor = {
|
|
4476
|
+
isList: function (editor, element, type) {
|
|
4477
|
+
return slate.Editor.isBlock(editor, element) && element.type === type;
|
|
4478
|
+
},
|
|
4479
|
+
toggleList: function (editor, type, startIndex) {
|
|
4480
|
+
var _this = this;
|
|
4481
|
+
if (!editor.selection) {
|
|
4482
|
+
return;
|
|
4483
|
+
}
|
|
4484
|
+
if (!startIndex) {
|
|
4485
|
+
startIndex = 1;
|
|
4486
|
+
}
|
|
4487
|
+
var types = [exports.ElementKinds.bulletedList, exports.ElementKinds.numberedList];
|
|
4488
|
+
slate.Editor.withoutNormalizing(editor, function () {
|
|
4489
|
+
var _a = __read(slate.Editor.nodes(editor, {
|
|
4490
|
+
match: function (node) { return slate.Element.isElement(node) && node.type === exports.ElementKinds.listItem; },
|
|
4491
|
+
mode: 'lowest'
|
|
4492
|
+
})), listItems = _a.slice(0);
|
|
4493
|
+
var firstListItemPath = listItems.length && listItems[0][1];
|
|
4494
|
+
var activeListPath = listItems.length && slate.Path.parent(firstListItemPath);
|
|
4495
|
+
var activeListNode = listItems.length && slate.Node.get(editor, activeListPath);
|
|
4496
|
+
// 同级且类型相同:unwrap
|
|
4497
|
+
var isLowestActive = listItems.length &&
|
|
4498
|
+
listItems.every(function (_a) {
|
|
4499
|
+
var _b = __read(_a, 2), path = _b[1];
|
|
4500
|
+
return activeListNode.type === type && (slate.Path.isSibling(firstListItemPath, path) || slate.Path.equals(firstListItemPath, path));
|
|
4501
|
+
});
|
|
4502
|
+
if (isLowestActive) {
|
|
4503
|
+
var upListItem = slate.Path.parent(activeListPath);
|
|
4504
|
+
slate.Transforms.unwrapNodes(editor, {
|
|
4505
|
+
at: editor.selection,
|
|
4506
|
+
match: function (node) { return node === activeListNode; },
|
|
4507
|
+
split: true,
|
|
4508
|
+
mode: 'lowest'
|
|
4509
|
+
});
|
|
4510
|
+
if (upListItem && slate.Node.get(editor, upListItem).type === exports.ElementKinds.listItem) {
|
|
4511
|
+
slate.Transforms.moveNodes(editor, {
|
|
4512
|
+
at: editor.selection,
|
|
4513
|
+
to: slate.Path.next(upListItem),
|
|
4514
|
+
match: function (node) { return slate.Element.isElement(node) && node.type === exports.ElementKinds.listItem; }
|
|
4515
|
+
});
|
|
4516
|
+
}
|
|
4517
|
+
else {
|
|
4518
|
+
slate.Transforms.unwrapNodes(editor, {
|
|
4519
|
+
match: function (node) { return slate.Element.isElement(node) && node.type === exports.ElementKinds.listItem; }
|
|
4520
|
+
});
|
|
4521
|
+
}
|
|
4522
|
+
return;
|
|
4523
|
+
}
|
|
4524
|
+
// 跨级、同级且类型不同
|
|
4525
|
+
if (activeListNode && types.includes(activeListNode.type)) {
|
|
4526
|
+
slate.Transforms.setNodes(editor, { type: type }, { match: function (node) { return slate.Element.isElement(node) && node.type !== type && types.includes(node.type); } });
|
|
4527
|
+
return;
|
|
4528
|
+
}
|
|
4529
|
+
// wrap
|
|
4530
|
+
_this.buildListItem(editor);
|
|
4531
|
+
// Todo: types
|
|
4532
|
+
slate.Transforms.wrapNodes(editor, { type: type, children: [], start: startIndex }, {
|
|
4533
|
+
at: editor.selection,
|
|
4534
|
+
match: function (node) { return slate.Element.isElement(node) && node.type === exports.ElementKinds.listItem; }
|
|
4535
|
+
});
|
|
4536
|
+
});
|
|
4537
|
+
},
|
|
4538
|
+
unwrapList: function (editor) {
|
|
4539
|
+
slate.Editor.withoutNormalizing(editor, function () {
|
|
4540
|
+
unwrapNodesByType(editor, [exports.ElementKinds.bulletedList, exports.ElementKinds.numberedList], { split: true, mode: 'all' });
|
|
4541
|
+
unwrapNodesByType(editor, [exports.ElementKinds.listItem], { split: true, mode: 'all' });
|
|
4542
|
+
});
|
|
4543
|
+
},
|
|
4544
|
+
wrapList: function (editor, type) {
|
|
4545
|
+
slate.Editor.withoutNormalizing(editor, function () {
|
|
4546
|
+
var listItem = {
|
|
4547
|
+
type: exports.ElementKinds.listItem,
|
|
4548
|
+
children: []
|
|
4549
|
+
};
|
|
4550
|
+
var list = {
|
|
4551
|
+
type: type,
|
|
4552
|
+
children: []
|
|
4553
|
+
};
|
|
4554
|
+
slate.Transforms.wrapNodes(editor, list, { split: true });
|
|
4555
|
+
slate.Transforms.wrapNodes(editor, listItem, { split: true });
|
|
4556
|
+
});
|
|
4557
|
+
},
|
|
4558
|
+
isActive: function (editor, type) {
|
|
4559
|
+
var _a = __read(getNodesByType(editor, type), 1), match = _a[0];
|
|
4560
|
+
return !!match;
|
|
4561
|
+
},
|
|
4562
|
+
getActiveList: function (editor) {
|
|
4563
|
+
var _a = __read(getNodesByType(editor, LIST_BLOCK_TYPES), 1), match = _a[0];
|
|
4564
|
+
return match;
|
|
4565
|
+
},
|
|
4566
|
+
buildListItem: function (editor) {
|
|
4567
|
+
var e_1, _a;
|
|
4568
|
+
var nodes = slate.Editor.nodes(editor, {
|
|
4569
|
+
match: function (node) { return slate.Editor.isBlock(editor, node); },
|
|
4570
|
+
mode: 'lowest'
|
|
4571
|
+
});
|
|
4572
|
+
try {
|
|
4573
|
+
for (var nodes_1 = __values(nodes), nodes_1_1 = nodes_1.next(); !nodes_1_1.done; nodes_1_1 = nodes_1.next()) {
|
|
4574
|
+
var _b = __read(nodes_1_1.value, 2), node = _b[0], path = _b[1];
|
|
4575
|
+
if (!slate.Editor.isVoid(editor, node) && slate.Element.isElement(node) && node.type !== exports.ElementKinds.paragraph) {
|
|
4576
|
+
slate.Transforms.setNodes(editor, { type: exports.ElementKinds.paragraph, checked: undefined }, // todo remove checked
|
|
4577
|
+
{ at: path });
|
|
4578
|
+
}
|
|
4579
|
+
else if (slate.Element.isElement(node) && node.type === exports.ElementKinds.paragraph) {
|
|
4580
|
+
var textIndent = node.textIndent;
|
|
4581
|
+
if (textIndent) {
|
|
4582
|
+
slate.Transforms.setNodes(editor, { textIndent: undefined, indent: undefined }, // remove indent
|
|
4583
|
+
{ at: path });
|
|
4584
|
+
}
|
|
4585
|
+
}
|
|
4586
|
+
if (slate.Node.parent(editor, path).type !== exports.ElementKinds.listItem) {
|
|
4587
|
+
slate.Transforms.wrapNodes(editor, { type: exports.ElementKinds.listItem, children: [] }, {
|
|
4588
|
+
at: path,
|
|
4589
|
+
split: true
|
|
4590
|
+
});
|
|
4591
|
+
}
|
|
4592
|
+
}
|
|
4593
|
+
}
|
|
4594
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
4595
|
+
finally {
|
|
4596
|
+
try {
|
|
4597
|
+
if (nodes_1_1 && !nodes_1_1.done && (_a = nodes_1.return)) _a.call(nodes_1);
|
|
4598
|
+
}
|
|
4599
|
+
finally { if (e_1) throw e_1.error; }
|
|
4600
|
+
}
|
|
4601
|
+
},
|
|
4602
|
+
buildInsertDataChildren: function (node) {
|
|
4603
|
+
var children = node.children;
|
|
4604
|
+
var listItem = children[0];
|
|
4605
|
+
if (isNodeTypeList(node) && slate.Element.isElement(listItem) && listItem.children[0].type === exports.ElementKinds.paragraph) {
|
|
4606
|
+
return node;
|
|
4607
|
+
}
|
|
4608
|
+
return this.buildInsertDataChildren(listItem);
|
|
4609
|
+
}
|
|
4610
|
+
};
|
|
4611
|
+
|
|
4612
|
+
var TodoItemEditor = {
|
|
4613
|
+
isActive: function (editor) {
|
|
4614
|
+
var _a = __read(getNodesByType(editor, exports.ElementKinds.checkItem), 1), match = _a[0];
|
|
4615
|
+
return !!match;
|
|
4616
|
+
},
|
|
4617
|
+
insertTodoItem: function (editor) {
|
|
4618
|
+
if (!editor.selection) {
|
|
4619
|
+
return;
|
|
4620
|
+
}
|
|
4621
|
+
var isActive = this.isActive(editor);
|
|
4622
|
+
var isNumberedList = ListEditor.isActive(editor, exports.ElementKinds.numberedList);
|
|
4623
|
+
var isBulletedList = ListEditor.isActive(editor, exports.ElementKinds.bulletedList);
|
|
4624
|
+
if (isActive) {
|
|
4625
|
+
slate.Transforms.setNodes(editor, {
|
|
4626
|
+
type: exports.ElementKinds.paragraph
|
|
4627
|
+
});
|
|
4628
|
+
}
|
|
4629
|
+
else {
|
|
4630
|
+
if (isNumberedList || isBulletedList) {
|
|
4631
|
+
ListEditor.unwrapList(editor);
|
|
4632
|
+
}
|
|
4633
|
+
slate.Transforms.setNodes(editor, {
|
|
4634
|
+
type: exports.ElementKinds.checkItem
|
|
4635
|
+
});
|
|
4636
|
+
}
|
|
4637
|
+
}
|
|
4755
4638
|
};
|
|
4756
4639
|
|
|
4757
|
-
var
|
|
4758
|
-
|
|
4759
|
-
|
|
4760
|
-
|
|
4761
|
-
|
|
4762
|
-
|
|
4763
|
-
|
|
4764
|
-
|
|
4765
|
-
|
|
4766
|
-
|
|
4767
|
-
|
|
4640
|
+
var BlockquoteEditor = {
|
|
4641
|
+
toggleBlockquote: function (editor) {
|
|
4642
|
+
if (!isParagraph(editor)) {
|
|
4643
|
+
slate.Transforms.insertNodes(editor, {
|
|
4644
|
+
type: exports.ElementKinds.paragraph,
|
|
4645
|
+
mode: 'text',
|
|
4646
|
+
children: [
|
|
4647
|
+
{
|
|
4648
|
+
text: ''
|
|
4649
|
+
}
|
|
4650
|
+
]
|
|
4651
|
+
});
|
|
4652
|
+
}
|
|
4653
|
+
var isActive = isBlockActive(editor, exports.ElementKinds.blockquote);
|
|
4654
|
+
if (!isActive) {
|
|
4655
|
+
slate.Transforms.wrapNodes(editor, { type: exports.ElementKinds.blockquote, children: [] }, {
|
|
4656
|
+
mode: 'lowest'
|
|
4657
|
+
});
|
|
4658
|
+
}
|
|
4659
|
+
else {
|
|
4660
|
+
slate.Transforms.unwrapNodes(editor, { match: function (n) { return slate.Element.isElement(n) && n.type === exports.ElementKinds.blockquote; } });
|
|
4661
|
+
}
|
|
4768
4662
|
}
|
|
4769
4663
|
};
|
|
4770
4664
|
|
|
4771
|
-
var
|
|
4772
|
-
|
|
4773
|
-
|
|
4774
|
-
|
|
4775
|
-
|
|
4776
|
-
|
|
4777
|
-
if (endMarkup) {
|
|
4778
|
-
endMarkupPointBefore = getPointBefore(editor, selection, {
|
|
4779
|
-
matchString: endMarkup
|
|
4780
|
-
});
|
|
4781
|
-
if (!endMarkupPointBefore) {
|
|
4782
|
-
return false;
|
|
4665
|
+
var InlineCodeEditor = {
|
|
4666
|
+
toggleInlineCode: function (editor, text) {
|
|
4667
|
+
var isActive = InlineCodeEditor.isInlineCodeActive(editor);
|
|
4668
|
+
if (isActive) {
|
|
4669
|
+
InlineCodeEditor.unwrapInlineCode(editor);
|
|
4670
|
+
return;
|
|
4783
4671
|
}
|
|
4784
|
-
|
|
4785
|
-
|
|
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;
|
|
4672
|
+
if (slate.Range.isCollapsed(editor.selection)) {
|
|
4673
|
+
InlineCodeEditor.wrapInlineCode(editor, text);
|
|
4802
4674
|
}
|
|
4675
|
+
else {
|
|
4676
|
+
var fragment = slate.Node.fragment(editor, editor.selection)[0];
|
|
4677
|
+
var selectNode = slate.Node.get(fragment, []);
|
|
4678
|
+
var selectText = slate.Node.string(selectNode);
|
|
4679
|
+
InlineCodeEditor.wrapInlineCode(editor, selectText);
|
|
4680
|
+
}
|
|
4681
|
+
},
|
|
4682
|
+
wrapInlineCode: function (editor, text) {
|
|
4683
|
+
if (text === void 0) { text = ''; }
|
|
4684
|
+
if (InlineCodeEditor.isInlineCodeActive(editor)) {
|
|
4685
|
+
InlineCodeEditor.unwrapInlineCode(editor);
|
|
4686
|
+
}
|
|
4687
|
+
var selection = editor.selection;
|
|
4688
|
+
var isCollapsed = selection && slate.Range.isCollapsed(selection);
|
|
4689
|
+
var inlineCode = {
|
|
4690
|
+
type: exports.ElementKinds.inlineCode,
|
|
4691
|
+
children: isCollapsed ? [{ text: text ? text : ZERO_WIDTH_CHAR }] : []
|
|
4692
|
+
};
|
|
4693
|
+
if (isCollapsed) {
|
|
4694
|
+
slate.Transforms.insertNodes(editor, inlineCode);
|
|
4695
|
+
}
|
|
4696
|
+
else {
|
|
4697
|
+
slate.Transforms.wrapNodes(editor, inlineCode, { split: true });
|
|
4698
|
+
}
|
|
4699
|
+
},
|
|
4700
|
+
unwrapInlineCode: function (editor) {
|
|
4701
|
+
slate.Transforms.unwrapNodes(editor, { match: function (n) { return slate.Element.isElement(n) && n.type === exports.ElementKinds.inlineCode; } });
|
|
4702
|
+
},
|
|
4703
|
+
isInlineCodeActive: function (editor, path) {
|
|
4704
|
+
var _a;
|
|
4705
|
+
var _b = __read(slate.Editor.nodes(editor, {
|
|
4706
|
+
at: path ? path : (_a = editor.selection) === null || _a === void 0 ? void 0 : _a.anchor.path,
|
|
4707
|
+
match: function (n) { return slate.Element.isElement(n) && n.type === exports.ElementKinds.inlineCode; }
|
|
4708
|
+
}), 1), inlineCode = _b[0];
|
|
4709
|
+
return !!inlineCode;
|
|
4803
4710
|
}
|
|
4804
|
-
|
|
4805
|
-
|
|
4806
|
-
|
|
4807
|
-
|
|
4808
|
-
|
|
4809
|
-
|
|
4810
|
-
|
|
4811
|
-
|
|
4812
|
-
|
|
4813
|
-
|
|
4814
|
-
|
|
4815
|
-
|
|
4816
|
-
|
|
4817
|
-
|
|
4818
|
-
|
|
4819
|
-
|
|
4820
|
-
|
|
4821
|
-
|
|
4822
|
-
|
|
4823
|
-
|
|
4824
|
-
|
|
4825
|
-
at: {
|
|
4826
|
-
anchor: startMarkupPointBefore,
|
|
4827
|
-
focus: selection.anchor
|
|
4711
|
+
};
|
|
4712
|
+
|
|
4713
|
+
var HeadingEditor = {
|
|
4714
|
+
setHeading: function (editor, heading) {
|
|
4715
|
+
slate.Editor.withoutNormalizing(editor, function () {
|
|
4716
|
+
var _a;
|
|
4717
|
+
var types = [exports.ElementKinds.bulletedList, exports.ElementKinds.numberedList, exports.ElementKinds.listItem];
|
|
4718
|
+
slate.Transforms.unwrapNodes(editor, {
|
|
4719
|
+
at: editor.selection,
|
|
4720
|
+
match: function (n) { return slate.Element.isElement(n) && types.includes(n.type); },
|
|
4721
|
+
mode: 'all',
|
|
4722
|
+
split: true
|
|
4723
|
+
});
|
|
4724
|
+
slate.Transforms.setNodes(editor, { type: heading });
|
|
4725
|
+
var entry = anchorBlockEntry(editor);
|
|
4726
|
+
var unMarks = (_a = {},
|
|
4727
|
+
_a[exports.MarkTypes.fontSize] = null,
|
|
4728
|
+
_a);
|
|
4729
|
+
if (entry) {
|
|
4730
|
+
setMarks(editor, unMarks, entry[1]);
|
|
4731
|
+
return;
|
|
4828
4732
|
}
|
|
4733
|
+
setMarks(editor, unMarks, editor.selection);
|
|
4829
4734
|
});
|
|
4735
|
+
},
|
|
4736
|
+
isHeadingActive: function (editor, heading) {
|
|
4737
|
+
var _a = __read(slate.Editor.nodes(editor, {
|
|
4738
|
+
match: function (n) { return slate.Element.isElement(n) && n.type === heading; },
|
|
4739
|
+
universal: true
|
|
4740
|
+
}), 1), match = _a[0];
|
|
4741
|
+
return !!match;
|
|
4830
4742
|
}
|
|
4831
|
-
|
|
4832
|
-
|
|
4833
|
-
|
|
4834
|
-
|
|
4835
|
-
|
|
4836
|
-
|
|
4837
|
-
|
|
4838
|
-
|
|
4839
|
-
|
|
4840
|
-
|
|
4841
|
-
|
|
4743
|
+
};
|
|
4744
|
+
|
|
4745
|
+
var defaultAutoFormatRules = [
|
|
4746
|
+
{
|
|
4747
|
+
type: exports.ElementKinds.heading_1,
|
|
4748
|
+
markup: '#',
|
|
4749
|
+
format: function (editor) {
|
|
4750
|
+
HeadingEditor.setHeading(editor, exports.ElementKinds.heading_1);
|
|
4751
|
+
}
|
|
4752
|
+
},
|
|
4753
|
+
{
|
|
4754
|
+
type: exports.ElementKinds.heading_2,
|
|
4755
|
+
markup: '##',
|
|
4756
|
+
format: function (editor) {
|
|
4757
|
+
HeadingEditor.setHeading(editor, exports.ElementKinds.heading_2);
|
|
4758
|
+
}
|
|
4759
|
+
},
|
|
4760
|
+
{
|
|
4761
|
+
type: exports.ElementKinds.heading_3,
|
|
4762
|
+
markup: '###',
|
|
4763
|
+
format: function (editor) {
|
|
4764
|
+
HeadingEditor.setHeading(editor, exports.ElementKinds.heading_3);
|
|
4765
|
+
}
|
|
4766
|
+
},
|
|
4767
|
+
{
|
|
4768
|
+
type: exports.ElementKinds.heading_4,
|
|
4769
|
+
markup: '####',
|
|
4770
|
+
format: function (editor) {
|
|
4771
|
+
HeadingEditor.setHeading(editor, exports.ElementKinds.heading_4);
|
|
4772
|
+
}
|
|
4773
|
+
},
|
|
4774
|
+
{
|
|
4775
|
+
type: exports.ElementKinds.heading_5,
|
|
4776
|
+
markup: '#####',
|
|
4777
|
+
format: function (editor) {
|
|
4778
|
+
HeadingEditor.setHeading(editor, exports.ElementKinds.heading_5);
|
|
4779
|
+
}
|
|
4780
|
+
},
|
|
4781
|
+
{
|
|
4782
|
+
type: exports.ElementKinds.heading_6,
|
|
4783
|
+
markup: '######',
|
|
4784
|
+
format: function (editor) {
|
|
4785
|
+
HeadingEditor.setHeading(editor, exports.ElementKinds.heading_6);
|
|
4786
|
+
}
|
|
4787
|
+
},
|
|
4788
|
+
{
|
|
4789
|
+
type: exports.ElementKinds.blockquote,
|
|
4790
|
+
markup: ['>'],
|
|
4791
|
+
format: function (editor) {
|
|
4792
|
+
BlockquoteEditor.toggleBlockquote(editor);
|
|
4793
|
+
}
|
|
4794
|
+
},
|
|
4795
|
+
{
|
|
4796
|
+
type: exports.MarkTypes.bold,
|
|
4797
|
+
between: ['**', '**'],
|
|
4798
|
+
mode: 'inline',
|
|
4799
|
+
insertTrigger: true
|
|
4800
|
+
},
|
|
4801
|
+
{
|
|
4802
|
+
type: exports.MarkTypes.bold,
|
|
4803
|
+
between: ['__', '__'],
|
|
4804
|
+
mode: 'inline',
|
|
4805
|
+
insertTrigger: true
|
|
4806
|
+
},
|
|
4807
|
+
{
|
|
4808
|
+
type: exports.MarkTypes.italic,
|
|
4809
|
+
between: ['*', '*'],
|
|
4810
|
+
mode: 'inline',
|
|
4811
|
+
insertTrigger: true
|
|
4812
|
+
},
|
|
4813
|
+
{
|
|
4814
|
+
type: exports.MarkTypes.italic,
|
|
4815
|
+
between: ['_', '_'],
|
|
4816
|
+
mode: 'inline',
|
|
4817
|
+
insertTrigger: true
|
|
4818
|
+
},
|
|
4819
|
+
{
|
|
4820
|
+
type: exports.ElementKinds.inlineCode,
|
|
4821
|
+
between: ['`', '`'],
|
|
4822
|
+
mode: 'inline',
|
|
4823
|
+
format: function (editor, text) {
|
|
4824
|
+
InlineCodeEditor.toggleInlineCode(editor, text);
|
|
4825
|
+
slate.Transforms.select(editor, slate.Editor.after(editor, editor.selection));
|
|
4826
|
+
}
|
|
4827
|
+
},
|
|
4828
|
+
{
|
|
4829
|
+
type: exports.MarkTypes.strike,
|
|
4830
|
+
between: ['~~', '~~'],
|
|
4831
|
+
mode: 'inline',
|
|
4832
|
+
insertTrigger: true
|
|
4833
|
+
},
|
|
4834
|
+
{
|
|
4835
|
+
type: exports.ElementKinds.code,
|
|
4836
|
+
markup: '```',
|
|
4837
|
+
insertTrigger: true
|
|
4838
|
+
},
|
|
4839
|
+
{
|
|
4840
|
+
type: exports.ElementKinds.listItem,
|
|
4841
|
+
markup: [],
|
|
4842
|
+
match: function (editor) {
|
|
4843
|
+
return isParagraph(editor) ? ['*', '-', '+'] : [];
|
|
4844
|
+
},
|
|
4845
|
+
format: function (editor) {
|
|
4846
|
+
ListEditor.toggleList(editor, exports.ElementKinds.bulletedList);
|
|
4847
|
+
}
|
|
4848
|
+
},
|
|
4849
|
+
{
|
|
4850
|
+
type: exports.ElementKinds.listItem,
|
|
4851
|
+
key: exports.ElementKinds.numberedList,
|
|
4852
|
+
markup: [],
|
|
4853
|
+
match: function (editor, textFromBlockStart) {
|
|
4854
|
+
return isParagraph(editor) && /^-?\d+(\.|\))$/.test(textFromBlockStart) ? [textFromBlockStart] : [];
|
|
4855
|
+
},
|
|
4856
|
+
format: function (editor, markup) {
|
|
4857
|
+
var startIndex = 1;
|
|
4858
|
+
if (markup) {
|
|
4859
|
+
startIndex = markup[0].split('.')[0];
|
|
4860
|
+
if (startIndex === 0) {
|
|
4861
|
+
startIndex = 1;
|
|
4862
|
+
}
|
|
4842
4863
|
}
|
|
4843
|
-
|
|
4864
|
+
ListEditor.toggleList(editor, exports.ElementKinds.numberedList, startIndex);
|
|
4865
|
+
}
|
|
4866
|
+
},
|
|
4867
|
+
{
|
|
4868
|
+
type: exports.ElementKinds.checkItem,
|
|
4869
|
+
markup: [],
|
|
4870
|
+
match: function (editor) {
|
|
4871
|
+
return isParagraph(editor) ? ['[]'] : [];
|
|
4872
|
+
},
|
|
4873
|
+
format: function (editor) {
|
|
4874
|
+
TodoItemEditor.insertTodoItem(editor);
|
|
4875
|
+
}
|
|
4876
|
+
},
|
|
4877
|
+
{
|
|
4878
|
+
type: exports.ElementKinds.hr,
|
|
4879
|
+
markup: '---',
|
|
4880
|
+
insertTrigger: true
|
|
4844
4881
|
}
|
|
4845
|
-
|
|
4846
|
-
};
|
|
4882
|
+
];
|
|
4847
4883
|
|
|
4848
|
-
var withAutoFormat = function (
|
|
4849
|
-
var
|
|
4850
|
-
|
|
4851
|
-
var
|
|
4852
|
-
|
|
4853
|
-
|
|
4854
|
-
|
|
4855
|
-
|
|
4856
|
-
|
|
4857
|
-
|
|
4858
|
-
|
|
4859
|
-
|
|
4860
|
-
|
|
4861
|
-
|
|
4862
|
-
|
|
4863
|
-
|
|
4864
|
-
|
|
4865
|
-
|
|
4866
|
-
|
|
4867
|
-
|
|
4868
|
-
|
|
4869
|
-
|
|
4870
|
-
|
|
4871
|
-
|
|
4872
|
-
|
|
4873
|
-
|
|
4874
|
-
|
|
4875
|
-
|
|
4876
|
-
|
|
4877
|
-
|
|
4878
|
-
|
|
4879
|
-
|
|
4880
|
-
|
|
4881
|
-
|
|
4882
|
-
|
|
4883
|
-
|
|
4884
|
-
|
|
4885
|
-
|
|
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";
|
|
4884
|
+
var withAutoFormat = function () { return function (editor) {
|
|
4885
|
+
var insertText = editor.insertText;
|
|
4886
|
+
editor.insertText = function (text) {
|
|
4887
|
+
var e_1, _d;
|
|
4888
|
+
var _a, _b;
|
|
4889
|
+
var autoFormatRules = defaultAutoFormatRules;
|
|
4890
|
+
if ((_a = editor.extraAutoFormatRules) === null || _a === void 0 ? void 0 : _a.length) {
|
|
4891
|
+
var extraRules = mergAutoFormateRules(editor.extraAutoFormatRules);
|
|
4892
|
+
autoFormatRules = Object.values(extraRules);
|
|
4893
|
+
}
|
|
4894
|
+
if (!isCollapsed(editor.selection)) {
|
|
4895
|
+
return insertText(text);
|
|
4896
|
+
}
|
|
4897
|
+
var _loop_1 = function (_c) {
|
|
4898
|
+
var query = _c.query, rule = __rest(_c, ["query"]);
|
|
4899
|
+
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;
|
|
4900
|
+
if (query && !query(editor, rule))
|
|
4901
|
+
return "continue";
|
|
4902
|
+
var triggers = castArray(trigger);
|
|
4903
|
+
// Check trigger
|
|
4904
|
+
if (!triggers.includes(text))
|
|
4905
|
+
return "continue";
|
|
4906
|
+
var valid = function () { return insertTrigger && insertText(text); };
|
|
4907
|
+
if (mode === 'block') {
|
|
4908
|
+
var markups = castArray(markup);
|
|
4909
|
+
var markupRange = void 0;
|
|
4910
|
+
if (triggerAtBlockStart) {
|
|
4911
|
+
markupRange = getRangeFromBlockStart(editor);
|
|
4912
|
+
// Don't autoformat if there is void nodes.
|
|
4913
|
+
var hasVoidNode = someNode(editor, {
|
|
4914
|
+
at: markupRange,
|
|
4915
|
+
match: function (n) { return slate.Editor.isVoid(editor, n); }
|
|
4916
|
+
});
|
|
4917
|
+
if (hasVoidNode)
|
|
4918
|
+
return "continue";
|
|
4919
|
+
var textFromBlockStart = getText(editor, markupRange);
|
|
4920
|
+
if (match) {
|
|
4921
|
+
markups = match(editor, textFromBlockStart);
|
|
4907
4922
|
}
|
|
4908
|
-
|
|
4909
|
-
|
|
4910
|
-
preFormat: preFormat,
|
|
4911
|
-
format: format
|
|
4912
|
-
}, markups);
|
|
4913
|
-
return { value: valid() };
|
|
4923
|
+
if (!markups.includes(textFromBlockStart))
|
|
4924
|
+
return "continue";
|
|
4914
4925
|
}
|
|
4915
|
-
|
|
4916
|
-
|
|
4917
|
-
|
|
4918
|
-
|
|
4919
|
-
|
|
4920
|
-
|
|
4921
|
-
|
|
4922
|
-
|
|
4923
|
-
|
|
4926
|
+
else {
|
|
4927
|
+
markupRange = getRangeBefore(editor, editor.selection, {
|
|
4928
|
+
matchString: markup,
|
|
4929
|
+
skipInvalid: true
|
|
4930
|
+
});
|
|
4931
|
+
if (!markupRange)
|
|
4932
|
+
return "continue";
|
|
4933
|
+
var blockAbovePath = (_b = getBlockAbove(editor)) === null || _b === void 0 ? void 0 : _b[1];
|
|
4934
|
+
if (!blockAbovePath)
|
|
4935
|
+
return "continue";
|
|
4936
|
+
// If the markup is not at the start, insert break before autoformatting.
|
|
4937
|
+
if (!slate.Editor.isStart(editor, markupRange.anchor, blockAbovePath)) {
|
|
4938
|
+
editor.insertBreak();
|
|
4924
4939
|
}
|
|
4925
4940
|
}
|
|
4926
|
-
|
|
4927
|
-
|
|
4928
|
-
|
|
4929
|
-
|
|
4930
|
-
|
|
4931
|
-
|
|
4932
|
-
|
|
4933
|
-
|
|
4934
|
-
|
|
4935
|
-
|
|
4936
|
-
|
|
4937
|
-
|
|
4938
|
-
|
|
4941
|
+
if (!allowSameTypeAbove) {
|
|
4942
|
+
// Don't autoformat if already in a block of the same type.
|
|
4943
|
+
var isBelowSameBlockType = someNode(editor, { match: { type: type } });
|
|
4944
|
+
if (isBelowSameBlockType)
|
|
4945
|
+
return "continue";
|
|
4946
|
+
}
|
|
4947
|
+
// Start of the block
|
|
4948
|
+
autoFormatBlock(editor, type, markupRange, {
|
|
4949
|
+
preFormat: preFormat,
|
|
4950
|
+
format: format
|
|
4951
|
+
}, markups);
|
|
4952
|
+
return { value: valid() };
|
|
4953
|
+
}
|
|
4954
|
+
if (mode === 'inline') {
|
|
4955
|
+
if (autoFormatInline(editor, {
|
|
4956
|
+
type: type,
|
|
4957
|
+
between: between,
|
|
4958
|
+
ignoreTrim: ignoreTrim,
|
|
4959
|
+
format: format,
|
|
4960
|
+
markup: Array.isArray(markup) ? markup[0] : markup
|
|
4961
|
+
})) {
|
|
4962
|
+
return { value: valid() };
|
|
4939
4963
|
}
|
|
4940
|
-
finally { if (e_1) throw e_1.error; }
|
|
4941
4964
|
}
|
|
4942
|
-
insertText(text);
|
|
4943
4965
|
};
|
|
4944
|
-
|
|
4966
|
+
try {
|
|
4967
|
+
for (var autoFormatRules_1 = __values(autoFormatRules), autoFormatRules_1_1 = autoFormatRules_1.next(); !autoFormatRules_1_1.done; autoFormatRules_1_1 = autoFormatRules_1.next()) {
|
|
4968
|
+
var _c = autoFormatRules_1_1.value;
|
|
4969
|
+
var state_1 = _loop_1(_c);
|
|
4970
|
+
if (typeof state_1 === "object")
|
|
4971
|
+
return state_1.value;
|
|
4972
|
+
}
|
|
4973
|
+
}
|
|
4974
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
4975
|
+
finally {
|
|
4976
|
+
try {
|
|
4977
|
+
if (autoFormatRules_1_1 && !autoFormatRules_1_1.done && (_d = autoFormatRules_1.return)) _d.call(autoFormatRules_1);
|
|
4978
|
+
}
|
|
4979
|
+
finally { if (e_1) throw e_1.error; }
|
|
4980
|
+
}
|
|
4981
|
+
insertText(text);
|
|
4945
4982
|
};
|
|
4983
|
+
return editor;
|
|
4984
|
+
}; };
|
|
4985
|
+
var mergAutoFormateRules = function (extraAutoFormatRules) {
|
|
4986
|
+
var combinationData = __spreadArray(__spreadArray([], __read(defaultAutoFormatRules)), __read(extraAutoFormatRules));
|
|
4987
|
+
var dataInfo = {};
|
|
4988
|
+
combinationData.forEach(function (item) {
|
|
4989
|
+
if (!dataInfo[item.type + item.key]) {
|
|
4990
|
+
dataInfo[item.type + item.key] = Object.assign({}, item);
|
|
4991
|
+
}
|
|
4992
|
+
dataInfo[item.type + item.key] = Object.assign(Object.assign({}, dataInfo[item.type + item.key]), item);
|
|
4993
|
+
});
|
|
4994
|
+
return dataInfo;
|
|
4946
4995
|
};
|
|
4947
4996
|
|
|
4948
4997
|
var withTransforms = function () { return function (editor) {
|
|
@@ -9962,8 +10011,9 @@
|
|
|
9962
10011
|
setNode(this.editor, { columns: columns }, this.element);
|
|
9963
10012
|
};
|
|
9964
10013
|
TheTableComponent.prototype.onRowMouseDown = function (event, index) {
|
|
10014
|
+
if (this.readonly)
|
|
10015
|
+
return;
|
|
9965
10016
|
event.stopPropagation();
|
|
9966
|
-
event.preventDefault();
|
|
9967
10017
|
if (!this.isInTable) {
|
|
9968
10018
|
var path = TheEditor.findPath(this.editor, this.element);
|
|
9969
10019
|
slate.Transforms.select(this.editor, path);
|
|
@@ -12103,27 +12153,27 @@
|
|
|
12103
12153
|
|
|
12104
12154
|
var TheQuickToolbarComponent = /** @class */ (function (_super) {
|
|
12105
12155
|
__extends(TheQuickToolbarComponent, _super);
|
|
12106
|
-
function TheQuickToolbarComponent(
|
|
12156
|
+
function TheQuickToolbarComponent(elementRef, cdr) {
|
|
12107
12157
|
var _this = _super.call(this) || this;
|
|
12108
|
-
_this.popoverRef = popoverRef;
|
|
12109
12158
|
_this.elementRef = elementRef;
|
|
12159
|
+
_this.cdr = cdr;
|
|
12110
12160
|
_this.ToolbarItemMode = exports.ToolbarItemMode;
|
|
12111
12161
|
_this.ToolbarActionTypes = exports.ToolbarActionTypes;
|
|
12112
12162
|
return _this;
|
|
12113
12163
|
}
|
|
12114
12164
|
TheQuickToolbarComponent.prototype.handleMouseDown = function (event) {
|
|
12115
12165
|
if (!this.elementRef.nativeElement.contains(event.target)) {
|
|
12116
|
-
QuickInsertEditor.
|
|
12166
|
+
QuickInsertEditor.closeQuickInsertToolbar(this.editor);
|
|
12117
12167
|
}
|
|
12118
12168
|
else {
|
|
12119
12169
|
event.preventDefault();
|
|
12120
12170
|
}
|
|
12121
12171
|
};
|
|
12122
12172
|
TheQuickToolbarComponent.prototype.handleEnter = function () {
|
|
12123
|
-
QuickInsertEditor.
|
|
12173
|
+
QuickInsertEditor.closeQuickInsertToolbar(this.editor);
|
|
12124
12174
|
};
|
|
12125
12175
|
TheQuickToolbarComponent.prototype.handleEsc = function () {
|
|
12126
|
-
QuickInsertEditor.
|
|
12176
|
+
QuickInsertEditor.closeQuickInsertToolbar(this.editor);
|
|
12127
12177
|
};
|
|
12128
12178
|
TheQuickToolbarComponent.prototype.ngOnInit = function () {
|
|
12129
12179
|
this.editorElement = i1.AngularEditor.toDOMNode(this.editor, this.editor);
|
|
@@ -12149,15 +12199,15 @@
|
|
|
12149
12199
|
};
|
|
12150
12200
|
return TheQuickToolbarComponent;
|
|
12151
12201
|
}(core.mixinUnsubscribe(core.MixinBase)));
|
|
12152
|
-
TheQuickToolbarComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TheQuickToolbarComponent, deps: [{ token:
|
|
12153
|
-
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:
|
|
12202
|
+
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 });
|
|
12203
|
+
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"] }] });
|
|
12154
12204
|
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TheQuickToolbarComponent, decorators: [{
|
|
12155
12205
|
type: i0.Component,
|
|
12156
12206
|
args: [{
|
|
12157
12207
|
selector: 'the-quick-toolbar',
|
|
12158
12208
|
templateUrl: 'quick-toolbar.component.html'
|
|
12159
12209
|
}]
|
|
12160
|
-
}], ctorParameters: function () { return [{ type:
|
|
12210
|
+
}], ctorParameters: function () { return [{ type: i0__namespace.ElementRef }, { type: i0__namespace.ChangeDetectorRef }]; }, propDecorators: { editor: [{
|
|
12161
12211
|
type: i0.Input
|
|
12162
12212
|
}], quickToolbarItems: [{
|
|
12163
12213
|
type: i0.Input
|
|
@@ -12172,16 +12222,22 @@
|
|
|
12172
12222
|
args: ['document: keydown.escape']
|
|
12173
12223
|
}] } });
|
|
12174
12224
|
|
|
12175
|
-
var OperationTypes = ['insert_text', 'remove_node', 'merge_node'];
|
|
12176
12225
|
var QuickInsertEditor = {
|
|
12177
|
-
|
|
12226
|
+
openQuickInsertToolbar: function (editor, quickToolbarItems, origin) {
|
|
12227
|
+
if (QuickInsertEditor.isOpenedToolbar(editor)) {
|
|
12228
|
+
return;
|
|
12229
|
+
}
|
|
12230
|
+
if (!origin) {
|
|
12231
|
+
var rootNode = i1.AngularEditor.toDOMNode(editor, slate.Node.ancestor(editor, [editor.selection.anchor.path[0]]));
|
|
12232
|
+
origin = rootNode.querySelector('[data-slate-leaf="true"]');
|
|
12233
|
+
}
|
|
12178
12234
|
var overlay = editor.injector.get(i2.Overlay);
|
|
12179
12235
|
var viewContainerRef = editor.injector.get(i0.ViewContainerRef);
|
|
12180
12236
|
var thyPopover = editor.injector.get(i1$2.ThyPopover);
|
|
12181
12237
|
var quickToolbarRef = thyPopover.open(TheQuickToolbarComponent, {
|
|
12182
12238
|
initialState: {
|
|
12183
12239
|
editor: editor,
|
|
12184
|
-
quickToolbarItems:
|
|
12240
|
+
quickToolbarItems: quickToolbarItems
|
|
12185
12241
|
},
|
|
12186
12242
|
origin: origin,
|
|
12187
12243
|
viewContainerRef: viewContainerRef,
|
|
@@ -12194,53 +12250,34 @@
|
|
|
12194
12250
|
scrollStrategy: overlay.scrollStrategies.reposition(),
|
|
12195
12251
|
manualClosure: true
|
|
12196
12252
|
});
|
|
12253
|
+
quickToolbarRef.componentInstance.cdr.markForCheck();
|
|
12197
12254
|
THE_EDITOR_QUICK_TOOLBAR_REF.set(editor, quickToolbarRef);
|
|
12198
12255
|
},
|
|
12199
|
-
|
|
12256
|
+
closeQuickInsertToolbar: function (editor) {
|
|
12200
12257
|
var quickToolbarRef = THE_EDITOR_QUICK_TOOLBAR_REF.get(editor);
|
|
12201
12258
|
if (quickToolbarRef) {
|
|
12202
12259
|
quickToolbarRef.close();
|
|
12203
12260
|
THE_EDITOR_QUICK_TOOLBAR_REF.set(editor, null);
|
|
12204
12261
|
}
|
|
12205
12262
|
},
|
|
12206
|
-
|
|
12207
|
-
|
|
12208
|
-
|
|
12209
|
-
if (!isCollapsedCursor) {
|
|
12210
|
-
return false;
|
|
12211
|
-
}
|
|
12212
|
-
var block = slate.Node.ancestor(editor, [editor.selection.anchor.path[0]]);
|
|
12213
|
-
var undos = editor.history.undos;
|
|
12214
|
-
var lastBatch = undos[undos.length - 1];
|
|
12215
|
-
var lastOp = lastBatch && lastBatch[lastBatch.length - 1];
|
|
12216
|
-
if (lastOp &&
|
|
12217
|
-
block.children.length === 1 &&
|
|
12218
|
-
block.type === exports.ElementKinds.paragraph &&
|
|
12219
|
-
slate.Node.string(block) === QUICK_TOOLBAR_HOTKEY &&
|
|
12220
|
-
opTypes.includes(lastOp.type) &&
|
|
12221
|
-
(lastOp.text === QUICK_TOOLBAR_HOTKEY || lastOp.text === undefined)) {
|
|
12222
|
-
return true;
|
|
12223
|
-
}
|
|
12224
|
-
return false;
|
|
12263
|
+
isOpenedToolbar: function (editor) {
|
|
12264
|
+
var quickToolbarRef = THE_EDITOR_QUICK_TOOLBAR_REF.get(editor);
|
|
12265
|
+
return !!quickToolbarRef;
|
|
12225
12266
|
}
|
|
12226
12267
|
};
|
|
12227
12268
|
|
|
12228
12269
|
var withQuickInsert = function (editor) {
|
|
12229
12270
|
var onKeydown = editor.onKeydown, deleteBackward = editor.deleteBackward, onChange = editor.onChange;
|
|
12271
|
+
var presseingQuickInsertHotkey = false;
|
|
12230
12272
|
editor.onKeydown = function (event) {
|
|
12231
12273
|
if (event.key === QUICK_TOOLBAR_HOTKEY && isCleanEmptyParagraph(editor)) {
|
|
12232
|
-
|
|
12233
|
-
var theEditorComponent = editor.injector.get(TheEditorComponent);
|
|
12234
|
-
var quickToolbars = theEditorComponent.quickToolbarItems;
|
|
12235
|
-
var leafElement = rootNode.querySelector('[data-slate-leaf="true"]');
|
|
12236
|
-
var origin = leafElement || rootNode;
|
|
12237
|
-
QuickInsertEditor.openQuickToolbar(editor, quickToolbars, origin);
|
|
12274
|
+
presseingQuickInsertHotkey = true;
|
|
12238
12275
|
}
|
|
12239
12276
|
onKeydown(event);
|
|
12240
12277
|
};
|
|
12241
12278
|
editor.deleteBackward = function (unit) {
|
|
12242
|
-
if (
|
|
12243
|
-
QuickInsertEditor.
|
|
12279
|
+
if (QuickInsertEditor.isOpenedToolbar(editor)) {
|
|
12280
|
+
QuickInsertEditor.closeQuickInsertToolbar(editor);
|
|
12244
12281
|
}
|
|
12245
12282
|
deleteBackward(unit);
|
|
12246
12283
|
};
|
|
@@ -12248,11 +12285,17 @@
|
|
|
12248
12285
|
var _a;
|
|
12249
12286
|
onChange();
|
|
12250
12287
|
if (editor.selection) {
|
|
12288
|
+
var block = slate.Node.get(editor, [editor.selection.anchor.path[0]]);
|
|
12289
|
+
// quick insert plus
|
|
12251
12290
|
var editorComponent = editor.injector.get(TheEditorComponent);
|
|
12252
12291
|
(_a = editorComponent.quickInsertInstance) === null || _a === void 0 ? void 0 : _a.checkStatus();
|
|
12253
|
-
|
|
12254
|
-
|
|
12255
|
-
|
|
12292
|
+
if (presseingQuickInsertHotkey && slate.Node.string(block) === QUICK_TOOLBAR_HOTKEY) {
|
|
12293
|
+
QuickInsertEditor.openQuickInsertToolbar(editor, editorComponent.quickToolbarItems);
|
|
12294
|
+
presseingQuickInsertHotkey = false;
|
|
12295
|
+
return;
|
|
12296
|
+
}
|
|
12297
|
+
if (QuickInsertEditor.isOpenedToolbar(editor) && !isCleanEmptyParagraph(editor) && slate.Node.string(block) !== QUICK_TOOLBAR_HOTKEY) {
|
|
12298
|
+
QuickInsertEditor.closeQuickInsertToolbar(editor);
|
|
12256
12299
|
}
|
|
12257
12300
|
}
|
|
12258
12301
|
};
|
|
@@ -12561,6 +12604,78 @@
|
|
|
12561
12604
|
args: ['class.disabled']
|
|
12562
12605
|
}] } });
|
|
12563
12606
|
|
|
12607
|
+
var onKeydownTextIndent = function (editor, event, kinds, textIndentDisabled) {
|
|
12608
|
+
var selection = editor.selection;
|
|
12609
|
+
var isExpanded = slate.Range.isExpanded(selection);
|
|
12610
|
+
var nodes = Array.from(slate.Editor.nodes(editor, {
|
|
12611
|
+
mode: 'highest',
|
|
12612
|
+
match: function (node) { return slate.Element.isElement(node) && kinds.includes(node.type); }
|
|
12613
|
+
}));
|
|
12614
|
+
var _a = __read(nodes, 1), startBlock = _a[0];
|
|
12615
|
+
if (!startBlock) {
|
|
12616
|
+
return false;
|
|
12617
|
+
}
|
|
12618
|
+
var _b = __read(startBlock, 2), block = _b[0], path = _b[1];
|
|
12619
|
+
var isStart = slate.Editor.isStart(editor, selection.anchor, path);
|
|
12620
|
+
if (isHotkey.isKeyHotkey('Tab', event)) {
|
|
12621
|
+
event.preventDefault();
|
|
12622
|
+
if (startBlock && (isExpanded || isStart)) {
|
|
12623
|
+
if (!editor.isVoid(block)) {
|
|
12624
|
+
var textIndent = block.textIndent, type = block.type;
|
|
12625
|
+
// do not apply first-line indentation for lists
|
|
12626
|
+
if (!textIndent && !textIndentDisabled.includes(type)) {
|
|
12627
|
+
IndentEditor.setTextIndent(editor, kinds, 2);
|
|
12628
|
+
return true;
|
|
12629
|
+
}
|
|
12630
|
+
else {
|
|
12631
|
+
IndentEditor.setIndent(editor);
|
|
12632
|
+
return true;
|
|
12633
|
+
}
|
|
12634
|
+
}
|
|
12635
|
+
}
|
|
12636
|
+
else {
|
|
12637
|
+
editor.insertText(TAB_SPACE);
|
|
12638
|
+
return true;
|
|
12639
|
+
}
|
|
12640
|
+
}
|
|
12641
|
+
if (isHotkey.isKeyHotkey('shift+Tab', event)) {
|
|
12642
|
+
if (startBlock && (isExpanded || isStart)) {
|
|
12643
|
+
if (!editor.isVoid(block)) {
|
|
12644
|
+
return IndentEditor.cancelTextIntent(editor, event, block, kinds);
|
|
12645
|
+
}
|
|
12646
|
+
}
|
|
12647
|
+
}
|
|
12648
|
+
if (selection && slate.Range.isCollapsed(selection) && i1.hotkeys.isDeleteBackward(event)) {
|
|
12649
|
+
if (startBlock && isStart) {
|
|
12650
|
+
return IndentEditor.cancelTextIntent(editor, event, block, kinds);
|
|
12651
|
+
}
|
|
12652
|
+
}
|
|
12653
|
+
return false;
|
|
12654
|
+
};
|
|
12655
|
+
|
|
12656
|
+
var withIndent = function (kinds) { return function (editor) {
|
|
12657
|
+
var onKeydown = editor.onKeydown;
|
|
12658
|
+
editor.onKeydown = function (event) {
|
|
12659
|
+
var _a, _b, _c, _d;
|
|
12660
|
+
var indentTypes = kinds;
|
|
12661
|
+
var disableIndentTypes = [exports.ElementKinds.bulletedList, exports.ElementKinds.numberedList, exports.ElementKinds.checkItem];
|
|
12662
|
+
if ((_b = (_a = editor.extraIndentOptions) === null || _a === void 0 ? void 0 : _a.indentTypes) === null || _b === void 0 ? void 0 : _b.length) {
|
|
12663
|
+
indentTypes = mergIndentTypes(kinds, editor.extraIndentOptions.indentTypes);
|
|
12664
|
+
}
|
|
12665
|
+
if ((_d = (_c = editor.extraIndentOptions) === null || _c === void 0 ? void 0 : _c.disabledIndentTypes) === null || _d === void 0 ? void 0 : _d.length) {
|
|
12666
|
+
disableIndentTypes = mergIndentTypes(disableIndentTypes, editor.extraIndentOptions.disabledIndentTypes);
|
|
12667
|
+
}
|
|
12668
|
+
var isContinue = !onKeydownTextIndent(editor, event, indentTypes, disableIndentTypes);
|
|
12669
|
+
if (isContinue) {
|
|
12670
|
+
onKeydown(event);
|
|
12671
|
+
}
|
|
12672
|
+
};
|
|
12673
|
+
return editor;
|
|
12674
|
+
}; };
|
|
12675
|
+
var mergIndentTypes = function (defaultTypes, indentTypes) {
|
|
12676
|
+
return Array.from(new Set(__spreadArray(__spreadArray([], __read(defaultTypes)), __read(indentTypes))));
|
|
12677
|
+
};
|
|
12678
|
+
|
|
12564
12679
|
var MaxIndent = 11;
|
|
12565
12680
|
var includesIndentTypes = __spreadArray([
|
|
12566
12681
|
exports.ElementKinds.checkItem,
|
|
@@ -12568,11 +12683,15 @@
|
|
|
12568
12683
|
exports.ElementKinds.bulletedList,
|
|
12569
12684
|
exports.ElementKinds.paragraph
|
|
12570
12685
|
], __read(HEADING_TYPES));
|
|
12686
|
+
var getIndentTypes = function (editor) {
|
|
12687
|
+
var indentTypes = editor.extraIndentOptions ? editor.extraIndentOptions.indentTypes : [];
|
|
12688
|
+
return mergIndentTypes(includesIndentTypes, indentTypes);
|
|
12689
|
+
};
|
|
12571
12690
|
var IndentEditor = {
|
|
12572
12691
|
setIndent: function (editor) {
|
|
12573
12692
|
var nodes = Array.from(slate.Editor.nodes(editor, {
|
|
12574
12693
|
mode: 'highest',
|
|
12575
|
-
match: function (n) { return slate.Element.isElement(n) &&
|
|
12694
|
+
match: function (n) { return slate.Element.isElement(n) && getIndentTypes(editor).includes(n.type); }
|
|
12576
12695
|
}));
|
|
12577
12696
|
var _a = __read(nodes, 1), startBlock = _a[0];
|
|
12578
12697
|
if (startBlock) {
|
|
@@ -12582,7 +12701,7 @@
|
|
|
12582
12701
|
if (indent <= MaxIndent) {
|
|
12583
12702
|
slate.Transforms.setNodes(editor, { indent: indent }, {
|
|
12584
12703
|
mode: 'highest',
|
|
12585
|
-
match: function (n) { return slate.Element.isElement(n) &&
|
|
12704
|
+
match: function (n) { return slate.Element.isElement(n) && getIndentTypes(editor).includes(n.type); }
|
|
12586
12705
|
});
|
|
12587
12706
|
}
|
|
12588
12707
|
}
|
|
@@ -12590,7 +12709,7 @@
|
|
|
12590
12709
|
cancelIndent: function (editor) {
|
|
12591
12710
|
var nodes = Array.from(slate.Editor.nodes(editor, {
|
|
12592
12711
|
mode: 'highest',
|
|
12593
|
-
match: function (n) { return slate.Element.isElement(n) &&
|
|
12712
|
+
match: function (n) { return slate.Element.isElement(n) && getIndentTypes(editor).includes(n.type); }
|
|
12594
12713
|
}));
|
|
12595
12714
|
var _a = __read(nodes, 1), startBlock = _a[0];
|
|
12596
12715
|
if (startBlock) {
|
|
@@ -12598,7 +12717,7 @@
|
|
|
12598
12717
|
indent = indent === 1 ? null : (indent -= 1);
|
|
12599
12718
|
slate.Transforms.setNodes(editor, { indent: indent }, {
|
|
12600
12719
|
mode: 'highest',
|
|
12601
|
-
match: function (n) { return slate.Element.isElement(n) &&
|
|
12720
|
+
match: function (n) { return slate.Element.isElement(n) && getIndentTypes(editor).includes(n.type); }
|
|
12602
12721
|
});
|
|
12603
12722
|
}
|
|
12604
12723
|
},
|
|
@@ -12630,14 +12749,8 @@
|
|
|
12630
12749
|
},
|
|
12631
12750
|
isDisabled: function (editor) {
|
|
12632
12751
|
if (editor.selection) {
|
|
12633
|
-
var allowGroup = __spreadArray([
|
|
12634
|
-
exports.ElementKinds.paragraph,
|
|
12635
|
-
exports.ElementKinds.numberedList,
|
|
12636
|
-
exports.ElementKinds.bulletedList,
|
|
12637
|
-
exports.ElementKinds.checkItem
|
|
12638
|
-
], __read(HEADING_TYPES));
|
|
12639
12752
|
var anchorBlock$1 = anchorBlock(editor);
|
|
12640
|
-
return anchorBlock$1 && !
|
|
12753
|
+
return anchorBlock$1 && !getIndentTypes(editor).includes(anchorBlock$1 === null || anchorBlock$1 === void 0 ? void 0 : anchorBlock$1.type);
|
|
12641
12754
|
}
|
|
12642
12755
|
return false;
|
|
12643
12756
|
}
|
|
@@ -12667,67 +12780,6 @@
|
|
|
12667
12780
|
}
|
|
12668
12781
|
];
|
|
12669
12782
|
|
|
12670
|
-
var onKeydownTextIndent = function (editor, event, kinds) {
|
|
12671
|
-
var selection = editor.selection;
|
|
12672
|
-
var isExpanded = slate.Range.isExpanded(selection);
|
|
12673
|
-
var nodes = Array.from(slate.Editor.nodes(editor, {
|
|
12674
|
-
mode: 'highest',
|
|
12675
|
-
match: function (node) { return slate.Element.isElement(node) && kinds.includes(node.type); }
|
|
12676
|
-
}));
|
|
12677
|
-
var _a = __read(nodes, 1), startBlock = _a[0];
|
|
12678
|
-
if (!startBlock) {
|
|
12679
|
-
return false;
|
|
12680
|
-
}
|
|
12681
|
-
var _b = __read(startBlock, 2), block = _b[0], path = _b[1];
|
|
12682
|
-
var isStart = slate.Editor.isStart(editor, selection.anchor, path);
|
|
12683
|
-
var textIndentDisable = [exports.ElementKinds.bulletedList, exports.ElementKinds.numberedList, exports.ElementKinds.checkItem];
|
|
12684
|
-
if (isHotkey.isKeyHotkey('Tab', event)) {
|
|
12685
|
-
event.preventDefault();
|
|
12686
|
-
if (startBlock && (isExpanded || isStart)) {
|
|
12687
|
-
if (!editor.isVoid(block)) {
|
|
12688
|
-
var textIndent = block.textIndent, type = block.type;
|
|
12689
|
-
// do not apply first-line indentation for lists
|
|
12690
|
-
if (!textIndent && !textIndentDisable.includes(type)) {
|
|
12691
|
-
IndentEditor.setTextIndent(editor, kinds, 2);
|
|
12692
|
-
return true;
|
|
12693
|
-
}
|
|
12694
|
-
else {
|
|
12695
|
-
IndentEditor.setIndent(editor);
|
|
12696
|
-
return true;
|
|
12697
|
-
}
|
|
12698
|
-
}
|
|
12699
|
-
}
|
|
12700
|
-
else {
|
|
12701
|
-
editor.insertText(TAB_SPACE);
|
|
12702
|
-
return true;
|
|
12703
|
-
}
|
|
12704
|
-
}
|
|
12705
|
-
if (isHotkey.isKeyHotkey('shift+Tab', event)) {
|
|
12706
|
-
if (startBlock && (isExpanded || isStart)) {
|
|
12707
|
-
if (!editor.isVoid(block)) {
|
|
12708
|
-
return IndentEditor.cancelTextIntent(editor, event, block, kinds);
|
|
12709
|
-
}
|
|
12710
|
-
}
|
|
12711
|
-
}
|
|
12712
|
-
if (selection && slate.Range.isCollapsed(selection) && i1.hotkeys.isDeleteBackward(event)) {
|
|
12713
|
-
if (startBlock && isStart) {
|
|
12714
|
-
return IndentEditor.cancelTextIntent(editor, event, block, kinds);
|
|
12715
|
-
}
|
|
12716
|
-
}
|
|
12717
|
-
return false;
|
|
12718
|
-
};
|
|
12719
|
-
|
|
12720
|
-
var withIndent = function (kinds) { return function (editor) {
|
|
12721
|
-
var onKeydown = editor.onKeydown;
|
|
12722
|
-
editor.onKeydown = function (event) {
|
|
12723
|
-
var isContinue = !onKeydownTextIndent(editor, event, kinds);
|
|
12724
|
-
if (isContinue) {
|
|
12725
|
-
onKeydown(event);
|
|
12726
|
-
}
|
|
12727
|
-
};
|
|
12728
|
-
return editor;
|
|
12729
|
-
}; };
|
|
12730
|
-
|
|
12731
12783
|
var internalPlugins = [
|
|
12732
12784
|
withTheHistory,
|
|
12733
12785
|
withAutoInsertData(),
|
|
@@ -12758,7 +12810,7 @@
|
|
|
12758
12810
|
}),
|
|
12759
12811
|
withBlockquote,
|
|
12760
12812
|
withNodeID({ idKey: ELEMENT_UNIQUE_ID, idCreator: idCreator }),
|
|
12761
|
-
withAutoFormat(
|
|
12813
|
+
withAutoFormat(),
|
|
12762
12814
|
withTransforms(),
|
|
12763
12815
|
withTrailingNode({ type: exports.ElementKinds.paragraph, level: 0 }),
|
|
12764
12816
|
withMoveSelection,
|
|
@@ -13402,7 +13454,11 @@
|
|
|
13402
13454
|
TheQuickInsertComponent.prototype.handleClick = function (event) {
|
|
13403
13455
|
event.stopPropagation();
|
|
13404
13456
|
event.preventDefault();
|
|
13405
|
-
QuickInsertEditor.
|
|
13457
|
+
if (QuickInsertEditor.isOpenedToolbar(this.editor)) {
|
|
13458
|
+
QuickInsertEditor.closeQuickInsertToolbar(this.editor);
|
|
13459
|
+
return;
|
|
13460
|
+
}
|
|
13461
|
+
QuickInsertEditor.openQuickInsertToolbar(this.editor, this.quickToolbarItems, this.iconElement.nativeElement);
|
|
13406
13462
|
};
|
|
13407
13463
|
return TheQuickInsertComponent;
|
|
13408
13464
|
}());
|
|
@@ -13699,11 +13755,13 @@
|
|
|
13699
13755
|
};
|
|
13700
13756
|
TheEditorComponent.prototype.initialize = function () {
|
|
13701
13757
|
var _this = this;
|
|
13702
|
-
var _a, _b;
|
|
13758
|
+
var _a, _b, _c, _d;
|
|
13703
13759
|
this.editor = withTheEditor(this.thePlugins, slateHistory.withHistory(i1.withAngular(slate.createEditor(), CLIPBOARD_FORMAT_KEY)));
|
|
13704
13760
|
this.generateDecorate();
|
|
13705
13761
|
this.editor.disabled = (_a = this.theOptions) === null || _a === void 0 ? void 0 : _a.disabled;
|
|
13706
13762
|
this.editor.extraElementOptions = (_b = this.theOptions) === null || _b === void 0 ? void 0 : _b.extraElementOptions;
|
|
13763
|
+
this.editor.extraAutoFormatRules = (_c = this.theOptions) === null || _c === void 0 ? void 0 : _c.extraAutoFormatRules;
|
|
13764
|
+
this.editor.extraIndentOptions = (_d = this.theOptions) === null || _d === void 0 ? void 0 : _d.extraIndentOptions;
|
|
13707
13765
|
setEditorUUID(this.editor, idCreator());
|
|
13708
13766
|
this.theContextService.initialize({
|
|
13709
13767
|
theOptions: this.theOptions,
|
|
@@ -14128,7 +14186,7 @@
|
|
|
14128
14186
|
i3$1.ThyNavModule,
|
|
14129
14187
|
i2$2.ThyFormModule,
|
|
14130
14188
|
i5$2.ThySharedModule,
|
|
14131
|
-
|
|
14189
|
+
i1$7.ThyListModule,
|
|
14132
14190
|
i5.ThyTooltipModule,
|
|
14133
14191
|
i6.ThyProgressModule,
|
|
14134
14192
|
autocomplete.ThyAutocompleteModule,
|
|
@@ -14229,7 +14287,7 @@
|
|
|
14229
14287
|
i3$1.ThyNavModule,
|
|
14230
14288
|
i2$2.ThyFormModule,
|
|
14231
14289
|
i5$2.ThySharedModule,
|
|
14232
|
-
|
|
14290
|
+
i1$7.ThyListModule,
|
|
14233
14291
|
i5.ThyTooltipModule,
|
|
14234
14292
|
i6.ThyProgressModule,
|
|
14235
14293
|
autocomplete.ThyAutocompleteModule,
|