@worktile/theia 2.4.1 → 2.4.2
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 +837 -822
- 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 +3 -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/index.js +2 -3
- package/fesm2015/worktile-theia.js +544 -526
- package/fesm2015/worktile-theia.js.map +1 -1
- package/interfaces/auto-format.d.ts +1 -0
- package/interfaces/editor.d.ts +3 -0
- package/package.json +1 -1
- package/plugins/autoformat/autoformat.plugin.d.ts +1 -2
|
@@ -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.i2$3, 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, i2$3, 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);
|
|
@@ -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);
|
|
@@ -1992,456 +2017,19 @@
|
|
|
1992
2017
|
handleContinualInsertBreak: handleContinualInsertBreak
|
|
1993
2018
|
});
|
|
1994
2019
|
|
|
1995
|
-
var
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
var ListEditor = {
|
|
2000
|
-
isList: function (editor, element, type) {
|
|
2001
|
-
return slate.Editor.isBlock(editor, element) && element.type === type;
|
|
2002
|
-
},
|
|
2003
|
-
toggleList: function (editor, type, startIndex) {
|
|
2004
|
-
var _this = this;
|
|
2005
|
-
if (!editor.selection) {
|
|
2006
|
-
return;
|
|
2007
|
-
}
|
|
2008
|
-
if (!startIndex) {
|
|
2009
|
-
startIndex = 1;
|
|
2010
|
-
}
|
|
2011
|
-
var types = [exports.ElementKinds.bulletedList, exports.ElementKinds.numberedList];
|
|
2012
|
-
slate.Editor.withoutNormalizing(editor, function () {
|
|
2013
|
-
var _a = __read(slate.Editor.nodes(editor, {
|
|
2014
|
-
match: function (node) { return slate.Element.isElement(node) && node.type === exports.ElementKinds.listItem; },
|
|
2015
|
-
mode: 'lowest'
|
|
2016
|
-
})), listItems = _a.slice(0);
|
|
2017
|
-
var firstListItemPath = listItems.length && listItems[0][1];
|
|
2018
|
-
var activeListPath = listItems.length && slate.Path.parent(firstListItemPath);
|
|
2019
|
-
var activeListNode = listItems.length && slate.Node.get(editor, activeListPath);
|
|
2020
|
-
// 同级且类型相同:unwrap
|
|
2021
|
-
var isLowestActive = listItems.length &&
|
|
2022
|
-
listItems.every(function (_a) {
|
|
2023
|
-
var _b = __read(_a, 2), path = _b[1];
|
|
2024
|
-
return activeListNode.type === type && (slate.Path.isSibling(firstListItemPath, path) || slate.Path.equals(firstListItemPath, path));
|
|
2025
|
-
});
|
|
2026
|
-
if (isLowestActive) {
|
|
2027
|
-
var upListItem = slate.Path.parent(activeListPath);
|
|
2028
|
-
slate.Transforms.unwrapNodes(editor, {
|
|
2029
|
-
at: editor.selection,
|
|
2030
|
-
match: function (node) { return node === activeListNode; },
|
|
2031
|
-
split: true,
|
|
2032
|
-
mode: 'lowest'
|
|
2033
|
-
});
|
|
2034
|
-
if (upListItem && slate.Node.get(editor, upListItem).type === exports.ElementKinds.listItem) {
|
|
2035
|
-
slate.Transforms.moveNodes(editor, {
|
|
2036
|
-
at: editor.selection,
|
|
2037
|
-
to: slate.Path.next(upListItem),
|
|
2038
|
-
match: function (node) { return slate.Element.isElement(node) && node.type === exports.ElementKinds.listItem; }
|
|
2039
|
-
});
|
|
2040
|
-
}
|
|
2041
|
-
else {
|
|
2042
|
-
slate.Transforms.unwrapNodes(editor, {
|
|
2043
|
-
match: function (node) { return slate.Element.isElement(node) && node.type === exports.ElementKinds.listItem; }
|
|
2044
|
-
});
|
|
2045
|
-
}
|
|
2046
|
-
return;
|
|
2047
|
-
}
|
|
2048
|
-
// 跨级、同级且类型不同
|
|
2049
|
-
if (activeListNode && types.includes(activeListNode.type)) {
|
|
2050
|
-
slate.Transforms.setNodes(editor, { type: type }, { match: function (node) { return slate.Element.isElement(node) && node.type !== type && types.includes(node.type); } });
|
|
2051
|
-
return;
|
|
2052
|
-
}
|
|
2053
|
-
// wrap
|
|
2054
|
-
_this.buildListItem(editor);
|
|
2055
|
-
// Todo: types
|
|
2056
|
-
slate.Transforms.wrapNodes(editor, { type: type, children: [], start: startIndex }, {
|
|
2057
|
-
at: editor.selection,
|
|
2058
|
-
match: function (node) { return slate.Element.isElement(node) && node.type === exports.ElementKinds.listItem; }
|
|
2059
|
-
});
|
|
2060
|
-
});
|
|
2061
|
-
},
|
|
2062
|
-
unwrapList: function (editor) {
|
|
2063
|
-
slate.Editor.withoutNormalizing(editor, function () {
|
|
2064
|
-
unwrapNodesByType(editor, [exports.ElementKinds.bulletedList, exports.ElementKinds.numberedList], { split: true, mode: 'all' });
|
|
2065
|
-
unwrapNodesByType(editor, [exports.ElementKinds.listItem], { split: true, mode: 'all' });
|
|
2066
|
-
});
|
|
2067
|
-
},
|
|
2068
|
-
wrapList: function (editor, type) {
|
|
2069
|
-
slate.Editor.withoutNormalizing(editor, function () {
|
|
2070
|
-
var listItem = {
|
|
2071
|
-
type: exports.ElementKinds.listItem,
|
|
2072
|
-
children: []
|
|
2073
|
-
};
|
|
2074
|
-
var list = {
|
|
2075
|
-
type: type,
|
|
2076
|
-
children: []
|
|
2077
|
-
};
|
|
2078
|
-
slate.Transforms.wrapNodes(editor, list, { split: true });
|
|
2079
|
-
slate.Transforms.wrapNodes(editor, listItem, { split: true });
|
|
2080
|
-
});
|
|
2081
|
-
},
|
|
2082
|
-
isActive: function (editor, type) {
|
|
2083
|
-
var _a = __read(getNodesByType(editor, type), 1), match = _a[0];
|
|
2084
|
-
return !!match;
|
|
2085
|
-
},
|
|
2086
|
-
getActiveList: function (editor) {
|
|
2087
|
-
var _a = __read(getNodesByType(editor, LIST_BLOCK_TYPES), 1), match = _a[0];
|
|
2088
|
-
return match;
|
|
2089
|
-
},
|
|
2090
|
-
buildListItem: function (editor) {
|
|
2091
|
-
var e_1, _a;
|
|
2092
|
-
var nodes = slate.Editor.nodes(editor, {
|
|
2093
|
-
match: function (node) { return slate.Editor.isBlock(editor, node); },
|
|
2094
|
-
mode: 'lowest'
|
|
2095
|
-
});
|
|
2096
|
-
try {
|
|
2097
|
-
for (var nodes_1 = __values(nodes), nodes_1_1 = nodes_1.next(); !nodes_1_1.done; nodes_1_1 = nodes_1.next()) {
|
|
2098
|
-
var _b = __read(nodes_1_1.value, 2), node = _b[0], path = _b[1];
|
|
2099
|
-
if (!slate.Editor.isVoid(editor, node) && slate.Element.isElement(node) && node.type !== exports.ElementKinds.paragraph) {
|
|
2100
|
-
slate.Transforms.setNodes(editor, { type: exports.ElementKinds.paragraph, checked: undefined }, // todo remove checked
|
|
2101
|
-
{ at: path });
|
|
2102
|
-
}
|
|
2103
|
-
else if (slate.Element.isElement(node) && node.type === exports.ElementKinds.paragraph) {
|
|
2104
|
-
var textIndent = node.textIndent;
|
|
2105
|
-
if (textIndent) {
|
|
2106
|
-
slate.Transforms.setNodes(editor, { textIndent: undefined, indent: undefined }, // remove indent
|
|
2107
|
-
{ at: path });
|
|
2108
|
-
}
|
|
2109
|
-
}
|
|
2110
|
-
if (slate.Node.parent(editor, path).type !== exports.ElementKinds.listItem) {
|
|
2111
|
-
slate.Transforms.wrapNodes(editor, { type: exports.ElementKinds.listItem, children: [] }, {
|
|
2112
|
-
at: path,
|
|
2113
|
-
split: true
|
|
2114
|
-
});
|
|
2115
|
-
}
|
|
2116
|
-
}
|
|
2117
|
-
}
|
|
2118
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
2119
|
-
finally {
|
|
2120
|
-
try {
|
|
2121
|
-
if (nodes_1_1 && !nodes_1_1.done && (_a = nodes_1.return)) _a.call(nodes_1);
|
|
2122
|
-
}
|
|
2123
|
-
finally { if (e_1) throw e_1.error; }
|
|
2124
|
-
}
|
|
2125
|
-
},
|
|
2126
|
-
buildInsertDataChildren: function (node) {
|
|
2127
|
-
var children = node.children;
|
|
2128
|
-
var listItem = children[0];
|
|
2129
|
-
if (isNodeTypeList(node) && slate.Element.isElement(listItem) && listItem.children[0].type === exports.ElementKinds.paragraph) {
|
|
2130
|
-
return node;
|
|
2131
|
-
}
|
|
2132
|
-
return this.buildInsertDataChildren(listItem);
|
|
2020
|
+
var TheConversionHintComponent = /** @class */ (function () {
|
|
2021
|
+
function TheConversionHintComponent() {
|
|
2022
|
+
this.duration = 10000;
|
|
2023
|
+
this.pauseOnHover = true;
|
|
2133
2024
|
}
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
isActive: function (editor) {
|
|
2138
|
-
var _a = __read(getNodesByType(editor, exports.ElementKinds.checkItem), 1), match = _a[0];
|
|
2139
|
-
return !!match;
|
|
2140
|
-
},
|
|
2141
|
-
insertTodoItem: function (editor) {
|
|
2142
|
-
if (!editor.selection) {
|
|
2143
|
-
return;
|
|
2025
|
+
TheConversionHintComponent.prototype.mouseenter = function () {
|
|
2026
|
+
if (this.pauseOnHover) {
|
|
2027
|
+
this.clearCloseTimer();
|
|
2144
2028
|
}
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
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
|
-
}
|
|
2162
|
-
};
|
|
2163
|
-
|
|
2164
|
-
var BlockquoteEditor = {
|
|
2165
|
-
toggleBlockquote: function (editor) {
|
|
2166
|
-
if (!isParagraph(editor)) {
|
|
2167
|
-
slate.Transforms.insertNodes(editor, {
|
|
2168
|
-
type: exports.ElementKinds.paragraph,
|
|
2169
|
-
mode: 'text',
|
|
2170
|
-
children: [
|
|
2171
|
-
{
|
|
2172
|
-
text: ''
|
|
2173
|
-
}
|
|
2174
|
-
]
|
|
2175
|
-
});
|
|
2176
|
-
}
|
|
2177
|
-
var isActive = isBlockActive(editor, exports.ElementKinds.blockquote);
|
|
2178
|
-
if (!isActive) {
|
|
2179
|
-
slate.Transforms.wrapNodes(editor, { type: exports.ElementKinds.blockquote, children: [] }, {
|
|
2180
|
-
mode: 'lowest'
|
|
2181
|
-
});
|
|
2182
|
-
}
|
|
2183
|
-
else {
|
|
2184
|
-
slate.Transforms.unwrapNodes(editor, { match: function (n) { return slate.Element.isElement(n) && n.type === exports.ElementKinds.blockquote; } });
|
|
2185
|
-
}
|
|
2186
|
-
}
|
|
2187
|
-
};
|
|
2188
|
-
|
|
2189
|
-
var InlineCodeEditor = {
|
|
2190
|
-
toggleInlineCode: function (editor, text) {
|
|
2191
|
-
var isActive = InlineCodeEditor.isInlineCodeActive(editor);
|
|
2192
|
-
if (isActive) {
|
|
2193
|
-
InlineCodeEditor.unwrapInlineCode(editor);
|
|
2194
|
-
return;
|
|
2195
|
-
}
|
|
2196
|
-
if (slate.Range.isCollapsed(editor.selection)) {
|
|
2197
|
-
InlineCodeEditor.wrapInlineCode(editor, text);
|
|
2198
|
-
}
|
|
2199
|
-
else {
|
|
2200
|
-
var fragment = slate.Node.fragment(editor, editor.selection)[0];
|
|
2201
|
-
var selectNode = slate.Node.get(fragment, []);
|
|
2202
|
-
var selectText = slate.Node.string(selectNode);
|
|
2203
|
-
InlineCodeEditor.wrapInlineCode(editor, selectText);
|
|
2204
|
-
}
|
|
2205
|
-
},
|
|
2206
|
-
wrapInlineCode: function (editor, text) {
|
|
2207
|
-
if (text === void 0) { text = ''; }
|
|
2208
|
-
if (InlineCodeEditor.isInlineCodeActive(editor)) {
|
|
2209
|
-
InlineCodeEditor.unwrapInlineCode(editor);
|
|
2210
|
-
}
|
|
2211
|
-
var selection = editor.selection;
|
|
2212
|
-
var isCollapsed = selection && slate.Range.isCollapsed(selection);
|
|
2213
|
-
var inlineCode = {
|
|
2214
|
-
type: exports.ElementKinds.inlineCode,
|
|
2215
|
-
children: isCollapsed ? [{ text: text ? text : ZERO_WIDTH_CHAR }] : []
|
|
2216
|
-
};
|
|
2217
|
-
if (isCollapsed) {
|
|
2218
|
-
slate.Transforms.insertNodes(editor, inlineCode);
|
|
2219
|
-
}
|
|
2220
|
-
else {
|
|
2221
|
-
slate.Transforms.wrapNodes(editor, inlineCode, { split: true });
|
|
2222
|
-
}
|
|
2223
|
-
},
|
|
2224
|
-
unwrapInlineCode: function (editor) {
|
|
2225
|
-
slate.Transforms.unwrapNodes(editor, { match: function (n) { return slate.Element.isElement(n) && n.type === exports.ElementKinds.inlineCode; } });
|
|
2226
|
-
},
|
|
2227
|
-
isInlineCodeActive: function (editor, path) {
|
|
2228
|
-
var _a;
|
|
2229
|
-
var _b = __read(slate.Editor.nodes(editor, {
|
|
2230
|
-
at: path ? path : (_a = editor.selection) === null || _a === void 0 ? void 0 : _a.anchor.path,
|
|
2231
|
-
match: function (n) { return slate.Element.isElement(n) && n.type === exports.ElementKinds.inlineCode; }
|
|
2232
|
-
}), 1), inlineCode = _b[0];
|
|
2233
|
-
return !!inlineCode;
|
|
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();
|
|
2029
|
+
};
|
|
2030
|
+
TheConversionHintComponent.prototype.mouseleave = function () {
|
|
2031
|
+
if (this.pauseOnHover) {
|
|
2032
|
+
this.creatCloseTimer();
|
|
2445
2033
|
}
|
|
2446
2034
|
};
|
|
2447
2035
|
TheConversionHintComponent.prototype.ngOnInit = function () {
|
|
@@ -3537,6 +3125,10 @@
|
|
|
3537
3125
|
return listItemNode.children.length === 1 && type === exports.ElementKinds.paragraph;
|
|
3538
3126
|
};
|
|
3539
3127
|
|
|
3128
|
+
var isNodeTypeList = function (n) {
|
|
3129
|
+
return [exports.ElementKinds.bulletedList, exports.ElementKinds.numberedList].includes(n.type);
|
|
3130
|
+
};
|
|
3131
|
+
|
|
3540
3132
|
/**
|
|
3541
3133
|
* list 中 是否是单个listItem,且listItem没有子列表
|
|
3542
3134
|
*/
|
|
@@ -4564,385 +4156,807 @@
|
|
|
4564
4156
|
if (blockCardElement) {
|
|
4565
4157
|
blockCardElement.classList.add("slate-block-card-" + _this.element.type);
|
|
4566
4158
|
}
|
|
4567
|
-
});
|
|
4159
|
+
});
|
|
4160
|
+
};
|
|
4161
|
+
return TheHrComponent;
|
|
4162
|
+
}(TheBaseElementComponent));
|
|
4163
|
+
TheHrComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TheHrComponent, deps: [{ token: i0__namespace.ElementRef }, { token: i0__namespace.ChangeDetectorRef }], target: i0__namespace.ɵɵFactoryTarget.Component });
|
|
4164
|
+
TheHrComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.15", type: TheHrComponent, selector: "the-hr, [theHr]", usesInheritance: true, ngImport: i0__namespace, template: "\n <div class=\"the-hr\" contenteditable=\"false\" [ngClass]=\"{ active: selection }\">\n <hr class=\"the-hr\" />\n <slate-children [children]=\"children\" [context]=\"childrenContext\" [viewContext]=\"viewContext\"></slate-children>\n </div>\n ", isInline: true, components: [{ type: i1__namespace.SlateChildrenComponent, selector: "slate-children", inputs: ["children", "context", "viewContext"] }], directives: [{ type: i10__namespace.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }] });
|
|
4165
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TheHrComponent, decorators: [{
|
|
4166
|
+
type: i0.Component,
|
|
4167
|
+
args: [{
|
|
4168
|
+
selector: 'the-hr, [theHr]',
|
|
4169
|
+
template: "\n <div class=\"the-hr\" contenteditable=\"false\" [ngClass]=\"{ active: selection }\">\n <hr class=\"the-hr\" />\n <slate-children [children]=\"children\" [context]=\"childrenContext\" [viewContext]=\"viewContext\"></slate-children>\n </div>\n "
|
|
4170
|
+
}]
|
|
4171
|
+
}], ctorParameters: function () { return [{ type: i0__namespace.ElementRef }, { type: i0__namespace.ChangeDetectorRef }]; } });
|
|
4172
|
+
|
|
4173
|
+
var withHr = function (editor) {
|
|
4174
|
+
var isVoid = editor.isVoid, isBlockCard = editor.isBlockCard, renderElement = editor.renderElement;
|
|
4175
|
+
editor.isVoid = function (element) {
|
|
4176
|
+
return element.type === exports.ElementKinds.hr || isVoid(element);
|
|
4177
|
+
};
|
|
4178
|
+
editor.isBlockCard = function (element) {
|
|
4179
|
+
if (element.type === exports.ElementKinds.hr) {
|
|
4180
|
+
return true;
|
|
4181
|
+
}
|
|
4182
|
+
return isBlockCard(element);
|
|
4183
|
+
};
|
|
4184
|
+
editor.renderElement = function (element) {
|
|
4185
|
+
if (element.type === exports.ElementKinds.hr) {
|
|
4186
|
+
return TheHrComponent;
|
|
4187
|
+
}
|
|
4188
|
+
return renderElement(element);
|
|
4189
|
+
};
|
|
4190
|
+
return editor;
|
|
4191
|
+
};
|
|
4192
|
+
|
|
4193
|
+
var withAlign = function (editor) {
|
|
4194
|
+
var deleteBackward = editor.deleteBackward;
|
|
4195
|
+
editor.deleteBackward = function (unit) {
|
|
4196
|
+
var anchor = editor.selection.anchor;
|
|
4197
|
+
var node = anchorBlock(editor);
|
|
4198
|
+
var isVoid = slate.Editor.isVoid(editor, node);
|
|
4199
|
+
var alignTypes = [exports.Alignment.center, exports.Alignment.right];
|
|
4200
|
+
var startLine = slate.Editor.start(editor, anchor.path);
|
|
4201
|
+
var startLineRange = { anchor: anchor, focus: startLine };
|
|
4202
|
+
var beforeText = slate.Editor.string(editor, startLineRange);
|
|
4203
|
+
if (!isVoid && node && node.align && alignTypes.includes(node.align) && beforeText === '') {
|
|
4204
|
+
var align = alignTypes.indexOf(node.align) ? exports.Alignment.center : undefined;
|
|
4205
|
+
return slate.Transforms.setNodes(editor, { align: align });
|
|
4206
|
+
}
|
|
4207
|
+
deleteBackward(unit);
|
|
4208
|
+
};
|
|
4209
|
+
return editor;
|
|
4210
|
+
};
|
|
4211
|
+
|
|
4212
|
+
var withHeading = function (editor) {
|
|
4213
|
+
var insertBreak = editor.insertBreak;
|
|
4214
|
+
editor.insertBreak = function () {
|
|
4215
|
+
var selection = editor.selection;
|
|
4216
|
+
var anchorBlock = getAnchorBlockEntry(editor);
|
|
4217
|
+
if (anchorBlock && slate.Range.isCollapsed(selection) && anchorBlock[0].type.startsWith('heading')) {
|
|
4218
|
+
if (slate.Editor.isStart(editor, selection.anchor, anchorBlock[1])) {
|
|
4219
|
+
insertBreak();
|
|
4220
|
+
slate.Transforms.setNodes(editor, { type: exports.ElementKinds.paragraph }, {
|
|
4221
|
+
at: selection
|
|
4222
|
+
});
|
|
4223
|
+
return;
|
|
4224
|
+
}
|
|
4225
|
+
if (slate.Editor.isEnd(editor, selection.focus, anchorBlock[1])) {
|
|
4226
|
+
insertBreak();
|
|
4227
|
+
slate.Transforms.setNodes(editor, { type: exports.ElementKinds.paragraph });
|
|
4228
|
+
return;
|
|
4229
|
+
}
|
|
4230
|
+
}
|
|
4231
|
+
insertBreak();
|
|
4232
|
+
};
|
|
4233
|
+
return editor;
|
|
4234
|
+
};
|
|
4235
|
+
|
|
4236
|
+
var withMark = function () { return function (editor) {
|
|
4237
|
+
var e = editor;
|
|
4238
|
+
e.removeMark = function (key, shouldChange) {
|
|
4239
|
+
if (shouldChange === void 0) { shouldChange = true; }
|
|
4240
|
+
var selection = e.selection;
|
|
4241
|
+
if (selection) {
|
|
4242
|
+
if (slate.Range.isExpanded(selection)) {
|
|
4243
|
+
slate.Transforms.unsetNodes(e, key, {
|
|
4244
|
+
match: slate.Text.isText,
|
|
4245
|
+
split: true
|
|
4246
|
+
});
|
|
4247
|
+
}
|
|
4248
|
+
else {
|
|
4249
|
+
var marks = Object.assign({}, (slate.Editor.marks(e) || {}));
|
|
4250
|
+
delete marks[key];
|
|
4251
|
+
editor.marks = marks;
|
|
4252
|
+
var text = slate.Editor.string(e, selection.anchor.path);
|
|
4253
|
+
if (text !== '') {
|
|
4254
|
+
slate.Editor.setNormalizing(editor, false);
|
|
4255
|
+
e.insertText('');
|
|
4256
|
+
editor.marks = marks;
|
|
4257
|
+
slate.Editor.setNormalizing(editor, true);
|
|
4258
|
+
}
|
|
4259
|
+
else {
|
|
4260
|
+
slate.Transforms.unsetNodes(e, key, { at: selection.anchor.path });
|
|
4261
|
+
}
|
|
4262
|
+
if (shouldChange) {
|
|
4263
|
+
editor.onChange();
|
|
4264
|
+
}
|
|
4265
|
+
}
|
|
4266
|
+
}
|
|
4267
|
+
};
|
|
4268
|
+
e.addMark = function (key, value) {
|
|
4269
|
+
var _a, _b, _c;
|
|
4270
|
+
var selection = editor.selection;
|
|
4271
|
+
if (selection) {
|
|
4272
|
+
if (slate.Range.isExpanded(selection)) {
|
|
4273
|
+
slate.Transforms.setNodes(e, (_a = {}, _a[key] = value, _a), { match: slate.Text.isText, split: true });
|
|
4274
|
+
}
|
|
4275
|
+
else {
|
|
4276
|
+
var marks = Object.assign(Object.assign({}, (slate.Editor.marks(e) || {})), (_b = {}, _b[key] = value, _b));
|
|
4277
|
+
editor.marks = marks;
|
|
4278
|
+
var text = slate.Editor.string(e, selection.anchor.path);
|
|
4279
|
+
if (text !== '') {
|
|
4280
|
+
slate.Editor.setNormalizing(editor, false);
|
|
4281
|
+
e.insertText('');
|
|
4282
|
+
editor.marks = marks;
|
|
4283
|
+
slate.Editor.setNormalizing(editor, true);
|
|
4284
|
+
}
|
|
4285
|
+
else {
|
|
4286
|
+
slate.Transforms.setNodes(e, (_c = {}, _c[key] = value, _c), { at: selection.anchor.path });
|
|
4287
|
+
}
|
|
4288
|
+
}
|
|
4289
|
+
}
|
|
4290
|
+
};
|
|
4291
|
+
return e;
|
|
4292
|
+
}; };
|
|
4293
|
+
|
|
4294
|
+
var withNodeID = function (_a) {
|
|
4295
|
+
var _b = _a === void 0 ? {} : _a, _c = _b.idKey, idKey = _c === void 0 ? 'id' : _c, _d = _b.idCreator, idCreator = _d === void 0 ? function () { return Date.now(); } : _d, _e = _b.filterText, filterText = _e === void 0 ? true : _e, _f = _b.filter, filter = _f === void 0 ? function () { return true; } : _f;
|
|
4296
|
+
return function (e) {
|
|
4297
|
+
var editor = e;
|
|
4298
|
+
var apply = editor.apply, getFragment = editor.getFragment;
|
|
4299
|
+
var idPropsCreator = function () {
|
|
4300
|
+
var _a;
|
|
4301
|
+
return (_a = {}, _a[idKey] = idCreator(), _a);
|
|
4302
|
+
};
|
|
4303
|
+
editor.removedIDs = new Set();
|
|
4304
|
+
editor.apply = function (operation) {
|
|
4305
|
+
var _a;
|
|
4306
|
+
if (operation.type === 'insert_node') {
|
|
4307
|
+
var newFilter = function (entry) {
|
|
4308
|
+
var _a = __read(entry, 1), _node = _a[0];
|
|
4309
|
+
return filter(entry) && filterText ? slate.Element.isElement(_node) : isDescendant(_node);
|
|
4310
|
+
};
|
|
4311
|
+
// fix can not find path by orign node
|
|
4312
|
+
var node = operation.node;
|
|
4313
|
+
if (!Object.isExtensible(node)) {
|
|
4314
|
+
node = _.cloneDeep(node);
|
|
4315
|
+
}
|
|
4316
|
+
// it will not overwrite ids once it's set as it's read-only
|
|
4317
|
+
mergeDeepToNodes({
|
|
4318
|
+
node: node,
|
|
4319
|
+
source: idPropsCreator,
|
|
4320
|
+
query: {
|
|
4321
|
+
filter: newFilter,
|
|
4322
|
+
}
|
|
4323
|
+
});
|
|
4324
|
+
return apply(Object.assign(Object.assign({}, operation), { node: node }));
|
|
4325
|
+
}
|
|
4326
|
+
if (operation.type === 'split_node' && (!filterText || operation.properties.type)) {
|
|
4327
|
+
var id = operation.properties[idKey];
|
|
4328
|
+
if (editor.removedIDs.has(id)) {
|
|
4329
|
+
editor.removedIDs.delete(id);
|
|
4330
|
+
}
|
|
4331
|
+
else {
|
|
4332
|
+
id = idCreator();
|
|
4333
|
+
}
|
|
4334
|
+
return apply(Object.assign(Object.assign({}, operation), { properties: Object.assign(Object.assign({}, operation.properties), (_a = {}, _a[idKey] = id, _a)) }));
|
|
4335
|
+
}
|
|
4336
|
+
if (operation.type === 'merge_node' && (!filterText || operation.properties.type)) {
|
|
4337
|
+
editor.removedIDs.add(operation.properties[idKey]);
|
|
4338
|
+
}
|
|
4339
|
+
return apply(operation);
|
|
4340
|
+
};
|
|
4341
|
+
editor.getFragment = function () {
|
|
4342
|
+
var fragment = _.cloneDeep(getFragment());
|
|
4343
|
+
return deleteElementKey(fragment, idKey);
|
|
4344
|
+
};
|
|
4345
|
+
return editor;
|
|
4568
4346
|
};
|
|
4569
|
-
|
|
4570
|
-
}(TheBaseElementComponent));
|
|
4571
|
-
TheHrComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TheHrComponent, deps: [{ token: i0__namespace.ElementRef }, { token: i0__namespace.ChangeDetectorRef }], target: i0__namespace.ɵɵFactoryTarget.Component });
|
|
4572
|
-
TheHrComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.15", type: TheHrComponent, selector: "the-hr, [theHr]", usesInheritance: true, ngImport: i0__namespace, template: "\n <div class=\"the-hr\" contenteditable=\"false\" [ngClass]=\"{ active: selection }\">\n <hr class=\"the-hr\" />\n <slate-children [children]=\"children\" [context]=\"childrenContext\" [viewContext]=\"viewContext\"></slate-children>\n </div>\n ", isInline: true, components: [{ type: i1__namespace.SlateChildrenComponent, selector: "slate-children", inputs: ["children", "context", "viewContext"] }], directives: [{ type: i10__namespace.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }] });
|
|
4573
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TheHrComponent, decorators: [{
|
|
4574
|
-
type: i0.Component,
|
|
4575
|
-
args: [{
|
|
4576
|
-
selector: 'the-hr, [theHr]',
|
|
4577
|
-
template: "\n <div class=\"the-hr\" contenteditable=\"false\" [ngClass]=\"{ active: selection }\">\n <hr class=\"the-hr\" />\n <slate-children [children]=\"children\" [context]=\"childrenContext\" [viewContext]=\"viewContext\"></slate-children>\n </div>\n "
|
|
4578
|
-
}]
|
|
4579
|
-
}], ctorParameters: function () { return [{ type: i0__namespace.ElementRef }, { type: i0__namespace.ChangeDetectorRef }]; } });
|
|
4347
|
+
};
|
|
4580
4348
|
|
|
4581
|
-
var
|
|
4582
|
-
var
|
|
4583
|
-
editor
|
|
4584
|
-
|
|
4585
|
-
|
|
4586
|
-
|
|
4587
|
-
|
|
4588
|
-
|
|
4589
|
-
|
|
4590
|
-
|
|
4591
|
-
|
|
4592
|
-
|
|
4593
|
-
if (element.type === exports.ElementKinds.hr) {
|
|
4594
|
-
return TheHrComponent;
|
|
4595
|
-
}
|
|
4596
|
-
return renderElement(element);
|
|
4597
|
-
};
|
|
4598
|
-
return editor;
|
|
4349
|
+
var autoFormatBlock = function (editor, type, at, _a, markups) {
|
|
4350
|
+
var preFormat = _a.preFormat, format = _a.format;
|
|
4351
|
+
slate.Transforms.delete(editor, { at: at });
|
|
4352
|
+
if (preFormat) {
|
|
4353
|
+
preFormat(editor);
|
|
4354
|
+
}
|
|
4355
|
+
if (!format) {
|
|
4356
|
+
slate.Transforms.setNodes(editor, { type: type }, { match: function (n) { return slate.Editor.isBlock(editor, n); } });
|
|
4357
|
+
}
|
|
4358
|
+
else {
|
|
4359
|
+
format(editor, markups);
|
|
4360
|
+
}
|
|
4599
4361
|
};
|
|
4600
4362
|
|
|
4601
|
-
var
|
|
4602
|
-
var
|
|
4603
|
-
|
|
4604
|
-
|
|
4605
|
-
|
|
4606
|
-
|
|
4607
|
-
|
|
4608
|
-
|
|
4609
|
-
|
|
4610
|
-
|
|
4611
|
-
if (!
|
|
4612
|
-
|
|
4613
|
-
return slate.Transforms.setNodes(editor, { align: align });
|
|
4363
|
+
var autoFormatInline = function (editor, _a) {
|
|
4364
|
+
var type = _a.type, between = _a.between, markup = _a.markup, ignoreTrim = _a.ignoreTrim, format = _a.format;
|
|
4365
|
+
var selection = editor.selection;
|
|
4366
|
+
var startMarkup = between ? between[0] : markup;
|
|
4367
|
+
var endMarkup = between ? between[1] : '';
|
|
4368
|
+
var endMarkupPointBefore = selection.anchor;
|
|
4369
|
+
if (endMarkup) {
|
|
4370
|
+
endMarkupPointBefore = getPointBefore(editor, selection, {
|
|
4371
|
+
matchString: endMarkup
|
|
4372
|
+
});
|
|
4373
|
+
if (!endMarkupPointBefore) {
|
|
4374
|
+
return false;
|
|
4614
4375
|
}
|
|
4615
|
-
|
|
4376
|
+
}
|
|
4377
|
+
var startMarkupPointAfter = getPointBefore(editor, endMarkupPointBefore, {
|
|
4378
|
+
matchString: startMarkup,
|
|
4379
|
+
skipInvalid: true,
|
|
4380
|
+
afterMatch: true
|
|
4381
|
+
});
|
|
4382
|
+
if (!startMarkupPointAfter) {
|
|
4383
|
+
return false;
|
|
4384
|
+
}
|
|
4385
|
+
// found
|
|
4386
|
+
var markupRange = {
|
|
4387
|
+
anchor: startMarkupPointAfter,
|
|
4388
|
+
focus: endMarkupPointBefore
|
|
4616
4389
|
};
|
|
4617
|
-
|
|
4390
|
+
if (!ignoreTrim) {
|
|
4391
|
+
var markupText = getText(editor, markupRange);
|
|
4392
|
+
if (markupText.trim() !== markupText) {
|
|
4393
|
+
return false;
|
|
4394
|
+
}
|
|
4395
|
+
}
|
|
4396
|
+
// delete end markup
|
|
4397
|
+
if (endMarkup) {
|
|
4398
|
+
endMarkupPointBefore = getPointBefore(editor, selection, {
|
|
4399
|
+
matchString: endMarkup
|
|
4400
|
+
});
|
|
4401
|
+
slate.Transforms.delete(editor, {
|
|
4402
|
+
at: {
|
|
4403
|
+
anchor: endMarkupPointBefore,
|
|
4404
|
+
focus: selection.anchor
|
|
4405
|
+
}
|
|
4406
|
+
});
|
|
4407
|
+
}
|
|
4408
|
+
var startMarkupPointBefore = getPointBefore(editor, selection, {
|
|
4409
|
+
matchString: startMarkup,
|
|
4410
|
+
skipInvalid: true
|
|
4411
|
+
});
|
|
4412
|
+
if (format) {
|
|
4413
|
+
var markupText = getText(editor, markupRange);
|
|
4414
|
+
format(editor, markupText);
|
|
4415
|
+
// delete start to end selection
|
|
4416
|
+
slate.Transforms.delete(editor, {
|
|
4417
|
+
at: {
|
|
4418
|
+
anchor: startMarkupPointBefore,
|
|
4419
|
+
focus: selection.anchor
|
|
4420
|
+
}
|
|
4421
|
+
});
|
|
4422
|
+
}
|
|
4423
|
+
else {
|
|
4424
|
+
// add mark to the text between the markups
|
|
4425
|
+
slate.Transforms.select(editor, markupRange);
|
|
4426
|
+
editor.addMark(type, true);
|
|
4427
|
+
slate.Transforms.collapse(editor, { edge: 'end' });
|
|
4428
|
+
editor.removeMark(type, false);
|
|
4429
|
+
// delete start markup
|
|
4430
|
+
slate.Transforms.delete(editor, {
|
|
4431
|
+
at: {
|
|
4432
|
+
anchor: startMarkupPointBefore,
|
|
4433
|
+
focus: startMarkupPointAfter
|
|
4434
|
+
}
|
|
4435
|
+
});
|
|
4436
|
+
}
|
|
4437
|
+
return true;
|
|
4618
4438
|
};
|
|
4619
4439
|
|
|
4620
|
-
var
|
|
4621
|
-
|
|
4622
|
-
|
|
4623
|
-
|
|
4624
|
-
|
|
4625
|
-
|
|
4626
|
-
|
|
4627
|
-
|
|
4628
|
-
|
|
4629
|
-
|
|
4440
|
+
var ListEditor = {
|
|
4441
|
+
isList: function (editor, element, type) {
|
|
4442
|
+
return slate.Editor.isBlock(editor, element) && element.type === type;
|
|
4443
|
+
},
|
|
4444
|
+
toggleList: function (editor, type, startIndex) {
|
|
4445
|
+
var _this = this;
|
|
4446
|
+
if (!editor.selection) {
|
|
4447
|
+
return;
|
|
4448
|
+
}
|
|
4449
|
+
if (!startIndex) {
|
|
4450
|
+
startIndex = 1;
|
|
4451
|
+
}
|
|
4452
|
+
var types = [exports.ElementKinds.bulletedList, exports.ElementKinds.numberedList];
|
|
4453
|
+
slate.Editor.withoutNormalizing(editor, function () {
|
|
4454
|
+
var _a = __read(slate.Editor.nodes(editor, {
|
|
4455
|
+
match: function (node) { return slate.Element.isElement(node) && node.type === exports.ElementKinds.listItem; },
|
|
4456
|
+
mode: 'lowest'
|
|
4457
|
+
})), listItems = _a.slice(0);
|
|
4458
|
+
var firstListItemPath = listItems.length && listItems[0][1];
|
|
4459
|
+
var activeListPath = listItems.length && slate.Path.parent(firstListItemPath);
|
|
4460
|
+
var activeListNode = listItems.length && slate.Node.get(editor, activeListPath);
|
|
4461
|
+
// 同级且类型相同:unwrap
|
|
4462
|
+
var isLowestActive = listItems.length &&
|
|
4463
|
+
listItems.every(function (_a) {
|
|
4464
|
+
var _b = __read(_a, 2), path = _b[1];
|
|
4465
|
+
return activeListNode.type === type && (slate.Path.isSibling(firstListItemPath, path) || slate.Path.equals(firstListItemPath, path));
|
|
4466
|
+
});
|
|
4467
|
+
if (isLowestActive) {
|
|
4468
|
+
var upListItem = slate.Path.parent(activeListPath);
|
|
4469
|
+
slate.Transforms.unwrapNodes(editor, {
|
|
4470
|
+
at: editor.selection,
|
|
4471
|
+
match: function (node) { return node === activeListNode; },
|
|
4472
|
+
split: true,
|
|
4473
|
+
mode: 'lowest'
|
|
4630
4474
|
});
|
|
4475
|
+
if (upListItem && slate.Node.get(editor, upListItem).type === exports.ElementKinds.listItem) {
|
|
4476
|
+
slate.Transforms.moveNodes(editor, {
|
|
4477
|
+
at: editor.selection,
|
|
4478
|
+
to: slate.Path.next(upListItem),
|
|
4479
|
+
match: function (node) { return slate.Element.isElement(node) && node.type === exports.ElementKinds.listItem; }
|
|
4480
|
+
});
|
|
4481
|
+
}
|
|
4482
|
+
else {
|
|
4483
|
+
slate.Transforms.unwrapNodes(editor, {
|
|
4484
|
+
match: function (node) { return slate.Element.isElement(node) && node.type === exports.ElementKinds.listItem; }
|
|
4485
|
+
});
|
|
4486
|
+
}
|
|
4631
4487
|
return;
|
|
4632
4488
|
}
|
|
4633
|
-
|
|
4634
|
-
|
|
4635
|
-
slate.Transforms.setNodes(editor, { type:
|
|
4489
|
+
// 跨级、同级且类型不同
|
|
4490
|
+
if (activeListNode && types.includes(activeListNode.type)) {
|
|
4491
|
+
slate.Transforms.setNodes(editor, { type: type }, { match: function (node) { return slate.Element.isElement(node) && node.type !== type && types.includes(node.type); } });
|
|
4636
4492
|
return;
|
|
4637
4493
|
}
|
|
4638
|
-
|
|
4639
|
-
|
|
4640
|
-
|
|
4641
|
-
|
|
4642
|
-
|
|
4643
|
-
|
|
4644
|
-
|
|
4645
|
-
|
|
4646
|
-
|
|
4647
|
-
|
|
4648
|
-
|
|
4649
|
-
|
|
4650
|
-
|
|
4651
|
-
|
|
4652
|
-
|
|
4653
|
-
|
|
4654
|
-
|
|
4655
|
-
|
|
4656
|
-
|
|
4657
|
-
|
|
4658
|
-
|
|
4659
|
-
|
|
4660
|
-
|
|
4661
|
-
|
|
4662
|
-
|
|
4663
|
-
|
|
4664
|
-
|
|
4665
|
-
|
|
4494
|
+
// wrap
|
|
4495
|
+
_this.buildListItem(editor);
|
|
4496
|
+
// Todo: types
|
|
4497
|
+
slate.Transforms.wrapNodes(editor, { type: type, children: [], start: startIndex }, {
|
|
4498
|
+
at: editor.selection,
|
|
4499
|
+
match: function (node) { return slate.Element.isElement(node) && node.type === exports.ElementKinds.listItem; }
|
|
4500
|
+
});
|
|
4501
|
+
});
|
|
4502
|
+
},
|
|
4503
|
+
unwrapList: function (editor) {
|
|
4504
|
+
slate.Editor.withoutNormalizing(editor, function () {
|
|
4505
|
+
unwrapNodesByType(editor, [exports.ElementKinds.bulletedList, exports.ElementKinds.numberedList], { split: true, mode: 'all' });
|
|
4506
|
+
unwrapNodesByType(editor, [exports.ElementKinds.listItem], { split: true, mode: 'all' });
|
|
4507
|
+
});
|
|
4508
|
+
},
|
|
4509
|
+
wrapList: function (editor, type) {
|
|
4510
|
+
slate.Editor.withoutNormalizing(editor, function () {
|
|
4511
|
+
var listItem = {
|
|
4512
|
+
type: exports.ElementKinds.listItem,
|
|
4513
|
+
children: []
|
|
4514
|
+
};
|
|
4515
|
+
var list = {
|
|
4516
|
+
type: type,
|
|
4517
|
+
children: []
|
|
4518
|
+
};
|
|
4519
|
+
slate.Transforms.wrapNodes(editor, list, { split: true });
|
|
4520
|
+
slate.Transforms.wrapNodes(editor, listItem, { split: true });
|
|
4521
|
+
});
|
|
4522
|
+
},
|
|
4523
|
+
isActive: function (editor, type) {
|
|
4524
|
+
var _a = __read(getNodesByType(editor, type), 1), match = _a[0];
|
|
4525
|
+
return !!match;
|
|
4526
|
+
},
|
|
4527
|
+
getActiveList: function (editor) {
|
|
4528
|
+
var _a = __read(getNodesByType(editor, LIST_BLOCK_TYPES), 1), match = _a[0];
|
|
4529
|
+
return match;
|
|
4530
|
+
},
|
|
4531
|
+
buildListItem: function (editor) {
|
|
4532
|
+
var e_1, _a;
|
|
4533
|
+
var nodes = slate.Editor.nodes(editor, {
|
|
4534
|
+
match: function (node) { return slate.Editor.isBlock(editor, node); },
|
|
4535
|
+
mode: 'lowest'
|
|
4536
|
+
});
|
|
4537
|
+
try {
|
|
4538
|
+
for (var nodes_1 = __values(nodes), nodes_1_1 = nodes_1.next(); !nodes_1_1.done; nodes_1_1 = nodes_1.next()) {
|
|
4539
|
+
var _b = __read(nodes_1_1.value, 2), node = _b[0], path = _b[1];
|
|
4540
|
+
if (!slate.Editor.isVoid(editor, node) && slate.Element.isElement(node) && node.type !== exports.ElementKinds.paragraph) {
|
|
4541
|
+
slate.Transforms.setNodes(editor, { type: exports.ElementKinds.paragraph, checked: undefined }, // todo remove checked
|
|
4542
|
+
{ at: path });
|
|
4666
4543
|
}
|
|
4667
|
-
else {
|
|
4668
|
-
|
|
4544
|
+
else if (slate.Element.isElement(node) && node.type === exports.ElementKinds.paragraph) {
|
|
4545
|
+
var textIndent = node.textIndent;
|
|
4546
|
+
if (textIndent) {
|
|
4547
|
+
slate.Transforms.setNodes(editor, { textIndent: undefined, indent: undefined }, // remove indent
|
|
4548
|
+
{ at: path });
|
|
4549
|
+
}
|
|
4669
4550
|
}
|
|
4670
|
-
if (
|
|
4671
|
-
editor.
|
|
4551
|
+
if (slate.Node.parent(editor, path).type !== exports.ElementKinds.listItem) {
|
|
4552
|
+
slate.Transforms.wrapNodes(editor, { type: exports.ElementKinds.listItem, children: [] }, {
|
|
4553
|
+
at: path,
|
|
4554
|
+
split: true
|
|
4555
|
+
});
|
|
4672
4556
|
}
|
|
4673
4557
|
}
|
|
4674
4558
|
}
|
|
4675
|
-
|
|
4676
|
-
|
|
4677
|
-
|
|
4678
|
-
|
|
4679
|
-
if (selection) {
|
|
4680
|
-
if (slate.Range.isExpanded(selection)) {
|
|
4681
|
-
slate.Transforms.setNodes(e, (_a = {}, _a[key] = value, _a), { match: slate.Text.isText, split: true });
|
|
4682
|
-
}
|
|
4683
|
-
else {
|
|
4684
|
-
var marks = Object.assign(Object.assign({}, (slate.Editor.marks(e) || {})), (_b = {}, _b[key] = value, _b));
|
|
4685
|
-
editor.marks = marks;
|
|
4686
|
-
var text = slate.Editor.string(e, selection.anchor.path);
|
|
4687
|
-
if (text !== '') {
|
|
4688
|
-
slate.Editor.setNormalizing(editor, false);
|
|
4689
|
-
e.insertText('');
|
|
4690
|
-
editor.marks = marks;
|
|
4691
|
-
slate.Editor.setNormalizing(editor, true);
|
|
4692
|
-
}
|
|
4693
|
-
else {
|
|
4694
|
-
slate.Transforms.setNodes(e, (_c = {}, _c[key] = value, _c), { at: selection.anchor.path });
|
|
4695
|
-
}
|
|
4559
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
4560
|
+
finally {
|
|
4561
|
+
try {
|
|
4562
|
+
if (nodes_1_1 && !nodes_1_1.done && (_a = nodes_1.return)) _a.call(nodes_1);
|
|
4696
4563
|
}
|
|
4564
|
+
finally { if (e_1) throw e_1.error; }
|
|
4697
4565
|
}
|
|
4698
|
-
}
|
|
4699
|
-
|
|
4700
|
-
|
|
4566
|
+
},
|
|
4567
|
+
buildInsertDataChildren: function (node) {
|
|
4568
|
+
var children = node.children;
|
|
4569
|
+
var listItem = children[0];
|
|
4570
|
+
if (isNodeTypeList(node) && slate.Element.isElement(listItem) && listItem.children[0].type === exports.ElementKinds.paragraph) {
|
|
4571
|
+
return node;
|
|
4572
|
+
}
|
|
4573
|
+
return this.buildInsertDataChildren(listItem);
|
|
4574
|
+
}
|
|
4575
|
+
};
|
|
4701
4576
|
|
|
4702
|
-
var
|
|
4703
|
-
|
|
4704
|
-
|
|
4705
|
-
|
|
4706
|
-
|
|
4707
|
-
|
|
4708
|
-
|
|
4709
|
-
return
|
|
4710
|
-
}
|
|
4711
|
-
|
|
4712
|
-
|
|
4713
|
-
|
|
4714
|
-
|
|
4715
|
-
|
|
4716
|
-
|
|
4717
|
-
|
|
4718
|
-
|
|
4719
|
-
|
|
4720
|
-
|
|
4721
|
-
|
|
4722
|
-
node = _.cloneDeep(node);
|
|
4723
|
-
}
|
|
4724
|
-
// it will not overwrite ids once it's set as it's read-only
|
|
4725
|
-
mergeDeepToNodes({
|
|
4726
|
-
node: node,
|
|
4727
|
-
source: idPropsCreator,
|
|
4728
|
-
query: {
|
|
4729
|
-
filter: newFilter,
|
|
4730
|
-
}
|
|
4731
|
-
});
|
|
4732
|
-
return apply(Object.assign(Object.assign({}, operation), { node: node }));
|
|
4733
|
-
}
|
|
4734
|
-
if (operation.type === 'split_node' && (!filterText || operation.properties.type)) {
|
|
4735
|
-
var id = operation.properties[idKey];
|
|
4736
|
-
if (editor.removedIDs.has(id)) {
|
|
4737
|
-
editor.removedIDs.delete(id);
|
|
4738
|
-
}
|
|
4739
|
-
else {
|
|
4740
|
-
id = idCreator();
|
|
4741
|
-
}
|
|
4742
|
-
return apply(Object.assign(Object.assign({}, operation), { properties: Object.assign(Object.assign({}, operation.properties), (_a = {}, _a[idKey] = id, _a)) }));
|
|
4743
|
-
}
|
|
4744
|
-
if (operation.type === 'merge_node' && (!filterText || operation.properties.type)) {
|
|
4745
|
-
editor.removedIDs.add(operation.properties[idKey]);
|
|
4577
|
+
var TodoItemEditor = {
|
|
4578
|
+
isActive: function (editor) {
|
|
4579
|
+
var _a = __read(getNodesByType(editor, exports.ElementKinds.checkItem), 1), match = _a[0];
|
|
4580
|
+
return !!match;
|
|
4581
|
+
},
|
|
4582
|
+
insertTodoItem: function (editor) {
|
|
4583
|
+
if (!editor.selection) {
|
|
4584
|
+
return;
|
|
4585
|
+
}
|
|
4586
|
+
var isActive = this.isActive(editor);
|
|
4587
|
+
var isNumberedList = ListEditor.isActive(editor, exports.ElementKinds.numberedList);
|
|
4588
|
+
var isBulletedList = ListEditor.isActive(editor, exports.ElementKinds.bulletedList);
|
|
4589
|
+
if (isActive) {
|
|
4590
|
+
slate.Transforms.setNodes(editor, {
|
|
4591
|
+
type: exports.ElementKinds.paragraph
|
|
4592
|
+
});
|
|
4593
|
+
}
|
|
4594
|
+
else {
|
|
4595
|
+
if (isNumberedList || isBulletedList) {
|
|
4596
|
+
ListEditor.unwrapList(editor);
|
|
4746
4597
|
}
|
|
4747
|
-
|
|
4748
|
-
|
|
4749
|
-
|
|
4750
|
-
|
|
4751
|
-
|
|
4752
|
-
};
|
|
4753
|
-
return editor;
|
|
4754
|
-
};
|
|
4598
|
+
slate.Transforms.setNodes(editor, {
|
|
4599
|
+
type: exports.ElementKinds.checkItem
|
|
4600
|
+
});
|
|
4601
|
+
}
|
|
4602
|
+
}
|
|
4755
4603
|
};
|
|
4756
4604
|
|
|
4757
|
-
var
|
|
4758
|
-
|
|
4759
|
-
|
|
4760
|
-
|
|
4761
|
-
|
|
4605
|
+
var BlockquoteEditor = {
|
|
4606
|
+
toggleBlockquote: function (editor) {
|
|
4607
|
+
if (!isParagraph(editor)) {
|
|
4608
|
+
slate.Transforms.insertNodes(editor, {
|
|
4609
|
+
type: exports.ElementKinds.paragraph,
|
|
4610
|
+
mode: 'text',
|
|
4611
|
+
children: [
|
|
4612
|
+
{
|
|
4613
|
+
text: ''
|
|
4614
|
+
}
|
|
4615
|
+
]
|
|
4616
|
+
});
|
|
4617
|
+
}
|
|
4618
|
+
var isActive = isBlockActive(editor, exports.ElementKinds.blockquote);
|
|
4619
|
+
if (!isActive) {
|
|
4620
|
+
slate.Transforms.wrapNodes(editor, { type: exports.ElementKinds.blockquote, children: [] }, {
|
|
4621
|
+
mode: 'lowest'
|
|
4622
|
+
});
|
|
4623
|
+
}
|
|
4624
|
+
else {
|
|
4625
|
+
slate.Transforms.unwrapNodes(editor, { match: function (n) { return slate.Element.isElement(n) && n.type === exports.ElementKinds.blockquote; } });
|
|
4626
|
+
}
|
|
4762
4627
|
}
|
|
4763
|
-
|
|
4764
|
-
|
|
4628
|
+
};
|
|
4629
|
+
|
|
4630
|
+
var InlineCodeEditor = {
|
|
4631
|
+
toggleInlineCode: function (editor, text) {
|
|
4632
|
+
var isActive = InlineCodeEditor.isInlineCodeActive(editor);
|
|
4633
|
+
if (isActive) {
|
|
4634
|
+
InlineCodeEditor.unwrapInlineCode(editor);
|
|
4635
|
+
return;
|
|
4636
|
+
}
|
|
4637
|
+
if (slate.Range.isCollapsed(editor.selection)) {
|
|
4638
|
+
InlineCodeEditor.wrapInlineCode(editor, text);
|
|
4639
|
+
}
|
|
4640
|
+
else {
|
|
4641
|
+
var fragment = slate.Node.fragment(editor, editor.selection)[0];
|
|
4642
|
+
var selectNode = slate.Node.get(fragment, []);
|
|
4643
|
+
var selectText = slate.Node.string(selectNode);
|
|
4644
|
+
InlineCodeEditor.wrapInlineCode(editor, selectText);
|
|
4645
|
+
}
|
|
4646
|
+
},
|
|
4647
|
+
wrapInlineCode: function (editor, text) {
|
|
4648
|
+
if (text === void 0) { text = ''; }
|
|
4649
|
+
if (InlineCodeEditor.isInlineCodeActive(editor)) {
|
|
4650
|
+
InlineCodeEditor.unwrapInlineCode(editor);
|
|
4651
|
+
}
|
|
4652
|
+
var selection = editor.selection;
|
|
4653
|
+
var isCollapsed = selection && slate.Range.isCollapsed(selection);
|
|
4654
|
+
var inlineCode = {
|
|
4655
|
+
type: exports.ElementKinds.inlineCode,
|
|
4656
|
+
children: isCollapsed ? [{ text: text ? text : ZERO_WIDTH_CHAR }] : []
|
|
4657
|
+
};
|
|
4658
|
+
if (isCollapsed) {
|
|
4659
|
+
slate.Transforms.insertNodes(editor, inlineCode);
|
|
4660
|
+
}
|
|
4661
|
+
else {
|
|
4662
|
+
slate.Transforms.wrapNodes(editor, inlineCode, { split: true });
|
|
4663
|
+
}
|
|
4664
|
+
},
|
|
4665
|
+
unwrapInlineCode: function (editor) {
|
|
4666
|
+
slate.Transforms.unwrapNodes(editor, { match: function (n) { return slate.Element.isElement(n) && n.type === exports.ElementKinds.inlineCode; } });
|
|
4667
|
+
},
|
|
4668
|
+
isInlineCodeActive: function (editor, path) {
|
|
4669
|
+
var _a;
|
|
4670
|
+
var _b = __read(slate.Editor.nodes(editor, {
|
|
4671
|
+
at: path ? path : (_a = editor.selection) === null || _a === void 0 ? void 0 : _a.anchor.path,
|
|
4672
|
+
match: function (n) { return slate.Element.isElement(n) && n.type === exports.ElementKinds.inlineCode; }
|
|
4673
|
+
}), 1), inlineCode = _b[0];
|
|
4674
|
+
return !!inlineCode;
|
|
4765
4675
|
}
|
|
4766
|
-
|
|
4767
|
-
|
|
4676
|
+
};
|
|
4677
|
+
|
|
4678
|
+
var HeadingEditor = {
|
|
4679
|
+
setHeading: function (editor, heading) {
|
|
4680
|
+
slate.Editor.withoutNormalizing(editor, function () {
|
|
4681
|
+
var _a;
|
|
4682
|
+
var types = [exports.ElementKinds.bulletedList, exports.ElementKinds.numberedList, exports.ElementKinds.listItem];
|
|
4683
|
+
slate.Transforms.unwrapNodes(editor, {
|
|
4684
|
+
at: editor.selection,
|
|
4685
|
+
match: function (n) { return slate.Element.isElement(n) && types.includes(n.type); },
|
|
4686
|
+
mode: 'all',
|
|
4687
|
+
split: true
|
|
4688
|
+
});
|
|
4689
|
+
slate.Transforms.setNodes(editor, { type: heading });
|
|
4690
|
+
var entry = anchorBlockEntry(editor);
|
|
4691
|
+
var unMarks = (_a = {},
|
|
4692
|
+
_a[exports.MarkTypes.fontSize] = null,
|
|
4693
|
+
_a);
|
|
4694
|
+
if (entry) {
|
|
4695
|
+
setMarks(editor, unMarks, entry[1]);
|
|
4696
|
+
return;
|
|
4697
|
+
}
|
|
4698
|
+
setMarks(editor, unMarks, editor.selection);
|
|
4699
|
+
});
|
|
4700
|
+
},
|
|
4701
|
+
isHeadingActive: function (editor, heading) {
|
|
4702
|
+
var _a = __read(slate.Editor.nodes(editor, {
|
|
4703
|
+
match: function (n) { return slate.Element.isElement(n) && n.type === heading; },
|
|
4704
|
+
universal: true
|
|
4705
|
+
}), 1), match = _a[0];
|
|
4706
|
+
return !!match;
|
|
4768
4707
|
}
|
|
4769
4708
|
};
|
|
4770
4709
|
|
|
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;
|
|
4710
|
+
var defaultAutoFormatRules = [
|
|
4711
|
+
{
|
|
4712
|
+
type: exports.ElementKinds.heading_1,
|
|
4713
|
+
markup: '#',
|
|
4714
|
+
format: function (editor) {
|
|
4715
|
+
HeadingEditor.setHeading(editor, exports.ElementKinds.heading_1);
|
|
4783
4716
|
}
|
|
4784
|
-
}
|
|
4785
|
-
|
|
4786
|
-
|
|
4787
|
-
|
|
4788
|
-
|
|
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;
|
|
4717
|
+
},
|
|
4718
|
+
{
|
|
4719
|
+
type: exports.ElementKinds.heading_2,
|
|
4720
|
+
markup: '##',
|
|
4721
|
+
format: function (editor) {
|
|
4722
|
+
HeadingEditor.setHeading(editor, exports.ElementKinds.heading_2);
|
|
4802
4723
|
}
|
|
4803
|
-
}
|
|
4804
|
-
|
|
4805
|
-
|
|
4806
|
-
|
|
4807
|
-
|
|
4808
|
-
|
|
4809
|
-
|
|
4810
|
-
|
|
4811
|
-
|
|
4812
|
-
|
|
4813
|
-
|
|
4814
|
-
|
|
4815
|
-
|
|
4816
|
-
|
|
4817
|
-
|
|
4818
|
-
|
|
4819
|
-
|
|
4820
|
-
|
|
4821
|
-
|
|
4822
|
-
|
|
4823
|
-
|
|
4824
|
-
|
|
4825
|
-
|
|
4826
|
-
|
|
4827
|
-
|
|
4828
|
-
|
|
4829
|
-
|
|
4830
|
-
|
|
4831
|
-
|
|
4832
|
-
|
|
4833
|
-
|
|
4834
|
-
|
|
4835
|
-
|
|
4836
|
-
|
|
4837
|
-
|
|
4838
|
-
|
|
4839
|
-
|
|
4840
|
-
|
|
4841
|
-
|
|
4724
|
+
},
|
|
4725
|
+
{
|
|
4726
|
+
type: exports.ElementKinds.heading_3,
|
|
4727
|
+
markup: '###',
|
|
4728
|
+
format: function (editor) {
|
|
4729
|
+
HeadingEditor.setHeading(editor, exports.ElementKinds.heading_3);
|
|
4730
|
+
}
|
|
4731
|
+
},
|
|
4732
|
+
{
|
|
4733
|
+
type: exports.ElementKinds.heading_4,
|
|
4734
|
+
markup: '####',
|
|
4735
|
+
format: function (editor) {
|
|
4736
|
+
HeadingEditor.setHeading(editor, exports.ElementKinds.heading_4);
|
|
4737
|
+
}
|
|
4738
|
+
},
|
|
4739
|
+
{
|
|
4740
|
+
type: exports.ElementKinds.heading_5,
|
|
4741
|
+
markup: '#####',
|
|
4742
|
+
format: function (editor) {
|
|
4743
|
+
HeadingEditor.setHeading(editor, exports.ElementKinds.heading_5);
|
|
4744
|
+
}
|
|
4745
|
+
},
|
|
4746
|
+
{
|
|
4747
|
+
type: exports.ElementKinds.heading_6,
|
|
4748
|
+
markup: '######',
|
|
4749
|
+
format: function (editor) {
|
|
4750
|
+
HeadingEditor.setHeading(editor, exports.ElementKinds.heading_6);
|
|
4751
|
+
}
|
|
4752
|
+
},
|
|
4753
|
+
{
|
|
4754
|
+
type: exports.ElementKinds.blockquote,
|
|
4755
|
+
markup: ['>'],
|
|
4756
|
+
format: function (editor) {
|
|
4757
|
+
BlockquoteEditor.toggleBlockquote(editor);
|
|
4758
|
+
}
|
|
4759
|
+
},
|
|
4760
|
+
{
|
|
4761
|
+
type: exports.MarkTypes.bold,
|
|
4762
|
+
between: ['**', '**'],
|
|
4763
|
+
mode: 'inline',
|
|
4764
|
+
insertTrigger: true
|
|
4765
|
+
},
|
|
4766
|
+
{
|
|
4767
|
+
type: exports.MarkTypes.bold,
|
|
4768
|
+
between: ['__', '__'],
|
|
4769
|
+
mode: 'inline',
|
|
4770
|
+
insertTrigger: true
|
|
4771
|
+
},
|
|
4772
|
+
{
|
|
4773
|
+
type: exports.MarkTypes.italic,
|
|
4774
|
+
between: ['*', '*'],
|
|
4775
|
+
mode: 'inline',
|
|
4776
|
+
insertTrigger: true
|
|
4777
|
+
},
|
|
4778
|
+
{
|
|
4779
|
+
type: exports.MarkTypes.italic,
|
|
4780
|
+
between: ['_', '_'],
|
|
4781
|
+
mode: 'inline',
|
|
4782
|
+
insertTrigger: true
|
|
4783
|
+
},
|
|
4784
|
+
{
|
|
4785
|
+
type: exports.ElementKinds.inlineCode,
|
|
4786
|
+
between: ['`', '`'],
|
|
4787
|
+
mode: 'inline',
|
|
4788
|
+
format: function (editor, text) {
|
|
4789
|
+
InlineCodeEditor.toggleInlineCode(editor, text);
|
|
4790
|
+
slate.Transforms.select(editor, slate.Editor.after(editor, editor.selection));
|
|
4791
|
+
}
|
|
4792
|
+
},
|
|
4793
|
+
{
|
|
4794
|
+
type: exports.MarkTypes.strike,
|
|
4795
|
+
between: ['~~', '~~'],
|
|
4796
|
+
mode: 'inline',
|
|
4797
|
+
insertTrigger: true
|
|
4798
|
+
},
|
|
4799
|
+
{
|
|
4800
|
+
type: exports.ElementKinds.code,
|
|
4801
|
+
markup: '```',
|
|
4802
|
+
insertTrigger: true
|
|
4803
|
+
},
|
|
4804
|
+
{
|
|
4805
|
+
type: exports.ElementKinds.listItem,
|
|
4806
|
+
markup: [],
|
|
4807
|
+
match: function (editor) {
|
|
4808
|
+
return isParagraph(editor) ? ['*', '-', '+'] : [];
|
|
4809
|
+
},
|
|
4810
|
+
format: function (editor) {
|
|
4811
|
+
ListEditor.toggleList(editor, exports.ElementKinds.bulletedList);
|
|
4812
|
+
}
|
|
4813
|
+
},
|
|
4814
|
+
{
|
|
4815
|
+
type: exports.ElementKinds.listItem,
|
|
4816
|
+
key: exports.ElementKinds.numberedList,
|
|
4817
|
+
markup: [],
|
|
4818
|
+
match: function (editor, textFromBlockStart) {
|
|
4819
|
+
return isParagraph(editor) && /^-?\d+(\.|\))$/.test(textFromBlockStart) ? [textFromBlockStart] : [];
|
|
4820
|
+
},
|
|
4821
|
+
format: function (editor, markup) {
|
|
4822
|
+
var startIndex = 1;
|
|
4823
|
+
if (markup) {
|
|
4824
|
+
startIndex = markup[0].split('.')[0];
|
|
4825
|
+
if (startIndex === 0) {
|
|
4826
|
+
startIndex = 1;
|
|
4827
|
+
}
|
|
4842
4828
|
}
|
|
4843
|
-
|
|
4829
|
+
ListEditor.toggleList(editor, exports.ElementKinds.numberedList, startIndex);
|
|
4830
|
+
}
|
|
4831
|
+
},
|
|
4832
|
+
{
|
|
4833
|
+
type: exports.ElementKinds.checkItem,
|
|
4834
|
+
markup: [],
|
|
4835
|
+
match: function (editor) {
|
|
4836
|
+
return isParagraph(editor) ? ['[]'] : [];
|
|
4837
|
+
},
|
|
4838
|
+
format: function (editor) {
|
|
4839
|
+
TodoItemEditor.insertTodoItem(editor);
|
|
4840
|
+
}
|
|
4841
|
+
},
|
|
4842
|
+
{
|
|
4843
|
+
type: exports.ElementKinds.hr,
|
|
4844
|
+
markup: '---',
|
|
4845
|
+
insertTrigger: true
|
|
4844
4846
|
}
|
|
4845
|
-
|
|
4846
|
-
};
|
|
4847
|
+
];
|
|
4847
4848
|
|
|
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";
|
|
4849
|
+
var withAutoFormat = function () { return function (editor) {
|
|
4850
|
+
var insertText = editor.insertText;
|
|
4851
|
+
editor.insertText = function (text) {
|
|
4852
|
+
var e_1, _d;
|
|
4853
|
+
var _a, _b;
|
|
4854
|
+
var autoFormatRules = defaultAutoFormatRules;
|
|
4855
|
+
if ((_a = editor.extraAutoFormatRules) === null || _a === void 0 ? void 0 : _a.length) {
|
|
4856
|
+
var extraRules = mergAutoFormateRules(editor.extraAutoFormatRules);
|
|
4857
|
+
autoFormatRules = Object.values(extraRules);
|
|
4858
|
+
}
|
|
4859
|
+
if (!isCollapsed(editor.selection)) {
|
|
4860
|
+
return insertText(text);
|
|
4861
|
+
}
|
|
4862
|
+
var _loop_1 = function (_c) {
|
|
4863
|
+
var query = _c.query, rule = __rest(_c, ["query"]);
|
|
4864
|
+
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;
|
|
4865
|
+
if (query && !query(editor, rule))
|
|
4866
|
+
return "continue";
|
|
4867
|
+
var triggers = castArray(trigger);
|
|
4868
|
+
// Check trigger
|
|
4869
|
+
if (!triggers.includes(text))
|
|
4870
|
+
return "continue";
|
|
4871
|
+
var valid = function () { return insertTrigger && insertText(text); };
|
|
4872
|
+
if (mode === 'block') {
|
|
4873
|
+
var markups = castArray(markup);
|
|
4874
|
+
var markupRange = void 0;
|
|
4875
|
+
if (triggerAtBlockStart) {
|
|
4876
|
+
markupRange = getRangeFromBlockStart(editor);
|
|
4877
|
+
// Don't autoformat if there is void nodes.
|
|
4878
|
+
var hasVoidNode = someNode(editor, {
|
|
4879
|
+
at: markupRange,
|
|
4880
|
+
match: function (n) { return slate.Editor.isVoid(editor, n); }
|
|
4881
|
+
});
|
|
4882
|
+
if (hasVoidNode)
|
|
4883
|
+
return "continue";
|
|
4884
|
+
var textFromBlockStart = getText(editor, markupRange);
|
|
4885
|
+
if (match) {
|
|
4886
|
+
markups = match(editor, textFromBlockStart);
|
|
4907
4887
|
}
|
|
4908
|
-
|
|
4909
|
-
|
|
4910
|
-
preFormat: preFormat,
|
|
4911
|
-
format: format
|
|
4912
|
-
}, markups);
|
|
4913
|
-
return { value: valid() };
|
|
4888
|
+
if (!markups.includes(textFromBlockStart))
|
|
4889
|
+
return "continue";
|
|
4914
4890
|
}
|
|
4915
|
-
|
|
4916
|
-
|
|
4917
|
-
|
|
4918
|
-
|
|
4919
|
-
|
|
4920
|
-
|
|
4921
|
-
|
|
4922
|
-
|
|
4923
|
-
|
|
4891
|
+
else {
|
|
4892
|
+
markupRange = getRangeBefore(editor, editor.selection, {
|
|
4893
|
+
matchString: markup,
|
|
4894
|
+
skipInvalid: true
|
|
4895
|
+
});
|
|
4896
|
+
if (!markupRange)
|
|
4897
|
+
return "continue";
|
|
4898
|
+
var blockAbovePath = (_b = getBlockAbove(editor)) === null || _b === void 0 ? void 0 : _b[1];
|
|
4899
|
+
if (!blockAbovePath)
|
|
4900
|
+
return "continue";
|
|
4901
|
+
// If the markup is not at the start, insert break before autoformatting.
|
|
4902
|
+
if (!slate.Editor.isStart(editor, markupRange.anchor, blockAbovePath)) {
|
|
4903
|
+
editor.insertBreak();
|
|
4924
4904
|
}
|
|
4925
4905
|
}
|
|
4926
|
-
|
|
4927
|
-
|
|
4928
|
-
|
|
4929
|
-
|
|
4930
|
-
|
|
4931
|
-
|
|
4932
|
-
|
|
4933
|
-
|
|
4934
|
-
|
|
4935
|
-
|
|
4936
|
-
|
|
4937
|
-
|
|
4938
|
-
|
|
4906
|
+
if (!allowSameTypeAbove) {
|
|
4907
|
+
// Don't autoformat if already in a block of the same type.
|
|
4908
|
+
var isBelowSameBlockType = someNode(editor, { match: { type: type } });
|
|
4909
|
+
if (isBelowSameBlockType)
|
|
4910
|
+
return "continue";
|
|
4911
|
+
}
|
|
4912
|
+
// Start of the block
|
|
4913
|
+
autoFormatBlock(editor, type, markupRange, {
|
|
4914
|
+
preFormat: preFormat,
|
|
4915
|
+
format: format
|
|
4916
|
+
}, markups);
|
|
4917
|
+
return { value: valid() };
|
|
4918
|
+
}
|
|
4919
|
+
if (mode === 'inline') {
|
|
4920
|
+
if (autoFormatInline(editor, {
|
|
4921
|
+
type: type,
|
|
4922
|
+
between: between,
|
|
4923
|
+
ignoreTrim: ignoreTrim,
|
|
4924
|
+
format: format,
|
|
4925
|
+
markup: Array.isArray(markup) ? markup[0] : markup
|
|
4926
|
+
})) {
|
|
4927
|
+
return { value: valid() };
|
|
4939
4928
|
}
|
|
4940
|
-
finally { if (e_1) throw e_1.error; }
|
|
4941
4929
|
}
|
|
4942
|
-
insertText(text);
|
|
4943
4930
|
};
|
|
4944
|
-
|
|
4931
|
+
try {
|
|
4932
|
+
for (var autoFormatRules_1 = __values(autoFormatRules), autoFormatRules_1_1 = autoFormatRules_1.next(); !autoFormatRules_1_1.done; autoFormatRules_1_1 = autoFormatRules_1.next()) {
|
|
4933
|
+
var _c = autoFormatRules_1_1.value;
|
|
4934
|
+
var state_1 = _loop_1(_c);
|
|
4935
|
+
if (typeof state_1 === "object")
|
|
4936
|
+
return state_1.value;
|
|
4937
|
+
}
|
|
4938
|
+
}
|
|
4939
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
4940
|
+
finally {
|
|
4941
|
+
try {
|
|
4942
|
+
if (autoFormatRules_1_1 && !autoFormatRules_1_1.done && (_d = autoFormatRules_1.return)) _d.call(autoFormatRules_1);
|
|
4943
|
+
}
|
|
4944
|
+
finally { if (e_1) throw e_1.error; }
|
|
4945
|
+
}
|
|
4946
|
+
insertText(text);
|
|
4945
4947
|
};
|
|
4948
|
+
return editor;
|
|
4949
|
+
}; };
|
|
4950
|
+
var mergAutoFormateRules = function (extraAutoFormatRules) {
|
|
4951
|
+
var combinationData = __spreadArray(__spreadArray([], __read(defaultAutoFormatRules)), __read(extraAutoFormatRules));
|
|
4952
|
+
var dataInfo = {};
|
|
4953
|
+
combinationData.forEach(function (item) {
|
|
4954
|
+
if (!dataInfo[item.type + item.key]) {
|
|
4955
|
+
dataInfo[item.type + item.key] = Object.assign({}, item);
|
|
4956
|
+
}
|
|
4957
|
+
dataInfo[item.type + item.key] = Object.assign(Object.assign({}, dataInfo[item.type + item.key]), item);
|
|
4958
|
+
});
|
|
4959
|
+
return dataInfo;
|
|
4946
4960
|
};
|
|
4947
4961
|
|
|
4948
4962
|
var withTransforms = function () { return function (editor) {
|
|
@@ -12759,7 +12773,7 @@
|
|
|
12759
12773
|
}),
|
|
12760
12774
|
withBlockquote,
|
|
12761
12775
|
withNodeID({ idKey: ELEMENT_UNIQUE_ID, idCreator: idCreator }),
|
|
12762
|
-
withAutoFormat(
|
|
12776
|
+
withAutoFormat(),
|
|
12763
12777
|
withTransforms(),
|
|
12764
12778
|
withTrailingNode({ type: exports.ElementKinds.paragraph, level: 0 }),
|
|
12765
12779
|
withMoveSelection,
|
|
@@ -13700,11 +13714,12 @@
|
|
|
13700
13714
|
};
|
|
13701
13715
|
TheEditorComponent.prototype.initialize = function () {
|
|
13702
13716
|
var _this = this;
|
|
13703
|
-
var _a, _b;
|
|
13717
|
+
var _a, _b, _c;
|
|
13704
13718
|
this.editor = withTheEditor(this.thePlugins, slateHistory.withHistory(i1.withAngular(slate.createEditor(), CLIPBOARD_FORMAT_KEY)));
|
|
13705
13719
|
this.generateDecorate();
|
|
13706
13720
|
this.editor.disabled = (_a = this.theOptions) === null || _a === void 0 ? void 0 : _a.disabled;
|
|
13707
13721
|
this.editor.extraElementOptions = (_b = this.theOptions) === null || _b === void 0 ? void 0 : _b.extraElementOptions;
|
|
13722
|
+
this.editor.extraAutoFormatRules = (_c = this.theOptions) === null || _c === void 0 ? void 0 : _c.extraAutoFormatRules;
|
|
13708
13723
|
setEditorUUID(this.editor, idCreator());
|
|
13709
13724
|
this.theContextService.initialize({
|
|
13710
13725
|
theOptions: this.theOptions,
|