@worktile/theia 3.0.0-next.1 → 3.0.0-next.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/bundles/worktile-theia.umd.js +201 -210
  2. package/bundles/worktile-theia.umd.js.map +1 -1
  3. package/core/utils/combine-plugins.d.ts +2 -0
  4. package/core/utils/get-plugin-by-key.d.ts +2 -0
  5. package/core/utils/index.d.ts +5 -2
  6. package/core/utils/merge-deep-plugins.d.ts +2 -0
  7. package/core/utils/merge-options.d.ts +1 -1
  8. package/core/utils/nested-structure-by-key.d.ts +2 -0
  9. package/core/utils/plugins-by-key.d.ts +2 -0
  10. package/esm2015/core/create-plugin.js +2 -4
  11. package/esm2015/core/utils/combine-plugins.js +10 -0
  12. package/esm2015/core/utils/flatten-deep-plugins.js +2 -20
  13. package/esm2015/core/utils/get-plugin-by-key.js +8 -0
  14. package/esm2015/core/utils/get-plugin.js +3 -3
  15. package/esm2015/core/utils/index.js +6 -3
  16. package/esm2015/core/utils/merge-deep-plugins.js +16 -0
  17. package/esm2015/core/utils/merge-options.js +5 -5
  18. package/esm2015/core/utils/nested-structure-by-key.js +11 -0
  19. package/esm2015/core/utils/plugins-by-key.js +10 -0
  20. package/esm2015/core/with-theia.js +9 -22
  21. package/esm2015/editor.component.js +2 -3
  22. package/esm2015/interfaces/editor.js +1 -1
  23. package/esm2015/plugins/autoformat/autoformat.plugin.js +11 -11
  24. package/esm2015/plugins/blockquote/blockquote.editor.js +8 -8
  25. package/esm2015/plugins/code/code.editor.js +3 -3
  26. package/esm2015/plugins/hr/hr.editor.js +2 -2
  27. package/esm2015/plugins/list/list.editor.js +1 -2
  28. package/esm2015/plugins/quick-insert/quick-insert.plugin.js +4 -4
  29. package/esm2015/plugins/table/transforms/insert-table.js +2 -2
  30. package/esm2015/plugins/todo-item/todo-item.component.js +8 -9
  31. package/esm2015/plugins/todo-item/todo-item.plugin.js +3 -2
  32. package/esm2015/transforms/index.js +3 -4
  33. package/esm2015/transforms/insert-elements.js +40 -0
  34. package/fesm2015/worktile-theia.js +189 -203
  35. package/fesm2015/worktile-theia.js.map +1 -1
  36. package/interfaces/editor.d.ts +1 -7
  37. package/package.json +1 -1
  38. package/plugins/autoformat/autoformat.plugin.d.ts +5 -1
  39. package/plugins/quick-insert/quick-insert.plugin.d.ts +2 -0
  40. package/plugins/todo-item/todo-item.component.d.ts +1 -0
  41. package/plugins/todo-item/todo-item.plugin.d.ts +4 -1
  42. package/transforms/index.d.ts +2 -3
  43. package/transforms/insert-elements.d.ts +2 -0
  44. package/core/utils/get-plugins-by-key.d.ts +0 -2
  45. package/core/utils/override-plugins-by-key.d.ts +0 -5
  46. package/esm2015/core/utils/get-plugins-by-key.js +0 -8
  47. package/esm2015/core/utils/override-plugins-by-key.js +0 -27
  48. package/esm2015/transforms/insert-element-next.js +0 -40
  49. package/esm2015/transforms/insert-element.js +0 -2
  50. package/transforms/insert-element-next.d.ts +0 -2
  51. package/transforms/insert-element.d.ts +0 -3
@@ -19,10 +19,10 @@ import * as i5 from 'ngx-tethys/input';
19
19
  import { ThyInputModule } from 'ngx-tethys/input';
20
20
  import { TheiaConverter } from '@atinc/selene';
21
21
  import * as _lodash from 'lodash';
22
- import { __rest, __awaiter } from 'tslib';
23
22
  import * as i2 from '@angular/cdk/overlay';
24
23
  import { Overlay, OverlayModule } from '@angular/cdk/overlay';
25
24
  import marked from 'marked';
25
+ import { __rest, __awaiter } from 'tslib';
26
26
  import * as i1$2 from 'ngx-tethys/alert';
27
27
  import { ThyAlertModule } from 'ngx-tethys/alert';
28
28
  import { map, takeUntil, take, delay, startWith, distinctUntilChanged, skip, share, filter, mapTo, debounceTime, pairwise } from 'rxjs/operators';
@@ -1072,24 +1072,7 @@ const flattenDeepPlugins = (editor, plugins) => {
1072
1072
  p.options = {};
1073
1073
  if (!p.nestedStructureByKey)
1074
1074
  p.nestedStructureByKey = {};
1075
- // 如果有 key 重复则进行覆盖
1076
- for (const key in p.nestedStructureByKey) {
1077
- if (!editor.nestedStructureByKey[key]) {
1078
- editor.nestedStructureByKey[key] = p.nestedStructureByKey[key];
1079
- }
1080
- }
1081
- if (!editor.pluginsByKey[p.key]) {
1082
- editor.plugins.push(p);
1083
- editor.pluginsByKey[p.key] = p;
1084
- }
1085
- else {
1086
- const index = editor.plugins.indexOf(editor.pluginsByKey[p.key]);
1087
- const mergedPlugin = _.defaultsDeep(p, editor.pluginsByKey[p.key]);
1088
- if (index >= 0) {
1089
- editor.plugins[index] = mergedPlugin;
1090
- }
1091
- editor.pluginsByKey[p.key] = mergedPlugin;
1092
- }
1075
+ editor.plugins.push(p);
1093
1076
  flattenDeepPlugins(editor, p.plugins);
1094
1077
  });
1095
1078
  };
@@ -1099,7 +1082,7 @@ const getPlugins = (editor) => {
1099
1082
  return (_a = editor === null || editor === void 0 ? void 0 : editor.plugins) !== null && _a !== void 0 ? _a : [];
1100
1083
  };
1101
1084
 
1102
- const getPluginsByKey = (editor) => {
1085
+ const getPluginByKey = (editor) => {
1103
1086
  const plugins = {};
1104
1087
  if (editor === null || editor === void 0 ? void 0 : editor.pluginsByKey) {
1105
1088
  return editor.pluginsByKey;
@@ -1107,47 +1090,178 @@ const getPluginsByKey = (editor) => {
1107
1090
  return plugins;
1108
1091
  };
1109
1092
 
1110
- const getPlugin = (editor, key) => getPluginsByKey(editor)[key];
1093
+ const getPlugin = (editor, key) => getPluginByKey(editor)[key];
1111
1094
 
1112
1095
  const getPluginOptions = (editor, key) => { var _a; return (_a = getPlugin(editor, key).options) !== null && _a !== void 0 ? _a : {}; };
1113
1096
 
1114
- const mergeOptions = (plugin, overrideByKey = {}) => {
1115
- const { options } = overrideByKey[plugin.key];
1097
+ const mergeOptions = (plugin, override) => {
1098
+ const { options } = plugin;
1116
1099
  const newOptions = {};
1117
1100
  for (let option in options) {
1118
1101
  if (Array.isArray(options[option])) {
1119
- newOptions[option] = _.union(options[option], plugin.options[option]);
1102
+ newOptions[option] = _.union(options[option], override.options[option]);
1120
1103
  continue;
1121
1104
  }
1122
- newOptions[option] = _.defaultsDeep(options[option], plugin.options[option]);
1105
+ newOptions[option] = options[option];
1123
1106
  }
1124
1107
  plugin.options = newOptions;
1125
1108
  return plugin;
1126
1109
  };
1127
1110
 
1128
- /**
1129
- * 将每个 plugin 从 `overrideByKey` 递归深度合并到具有相同 key 的 plugin(plugin > plugin.plugins)。
1130
- */
1131
- const overridePluginsByKey = (plugin, overrideByKey = {}, nested) => {
1132
- if (overrideByKey[plugin.key]) {
1133
- plugin = mergeOptions(plugin, overrideByKey);
1134
- const _a = overrideByKey[plugin.key], { plugins: pluginOverridesPlugins } = _a, pluginOverrides = __rest(_a, ["plugins"]);
1135
- plugin = _.defaultsDeep(pluginOverrides, plugin);
1136
- if (!nested) {
1137
- pluginOverridesPlugins === null || pluginOverridesPlugins === void 0 ? void 0 : pluginOverridesPlugins.forEach(pOverrides => {
1138
- if (!plugin.plugins)
1139
- plugin.plugins = [];
1140
- const found = plugin.plugins.find(p => p.key === pOverrides.key);
1141
- if (!found)
1142
- plugin.plugins.push(pOverrides);
1111
+ const combinePlugins = (editor) => {
1112
+ // withOverrides
1113
+ editor.plugins.forEach((plugin) => {
1114
+ if (plugin.withOverrides) {
1115
+ editor = plugin.withOverrides(editor, plugin);
1116
+ }
1117
+ });
1118
+ return editor;
1119
+ };
1120
+
1121
+ const mergeDeepPlugins = (editor, _plugins) => {
1122
+ _plugins.forEach(plugin => {
1123
+ if (plugin.overrideByKey) {
1124
+ const newPlugins = _plugins.filter(p => plugin.overrideByKey[p.key]);
1125
+ newPlugins.forEach(p => {
1126
+ if (editor.pluginsByKey[p.key]) {
1127
+ p = mergeOptions(p, plugin.overrideByKey[p.key]);
1128
+ editor.pluginsByKey[p.key] = _.defaultsDeep(p, plugin.overrideByKey[p.key]);
1129
+ }
1143
1130
  });
1144
1131
  }
1132
+ });
1133
+ };
1134
+
1135
+ const nestedStructureByKey = (editor, plugins) => {
1136
+ // 如果有 key 重复则进行覆盖
1137
+ plugins.forEach((p) => {
1138
+ for (const key in p.nestedStructureByKey) {
1139
+ if (!editor.nestedStructureByKey[key]) {
1140
+ editor.nestedStructureByKey[key] = p.nestedStructureByKey[key];
1141
+ }
1142
+ }
1143
+ });
1144
+ };
1145
+
1146
+ const pluginsByKey = (editor, plugins) => {
1147
+ if (!plugins)
1148
+ return;
1149
+ plugins.forEach((p) => {
1150
+ if (!editor.pluginsByKey[p.key]) {
1151
+ editor.pluginsByKey[p.key] = p;
1152
+ }
1153
+ });
1154
+ };
1155
+
1156
+ const withTheia = (editor, plugins = []) => {
1157
+ let e = editor;
1158
+ e.renderElement = (element) => null;
1159
+ e.renderLeaf = (text) => null;
1160
+ e.isContainer = (value) => false;
1161
+ e.extraElementOptions = [];
1162
+ e.disabled = false;
1163
+ e.plugins = [];
1164
+ e.pluginsByKey = {};
1165
+ e.nestedStructureByKey = {};
1166
+ // withOverridesByKey
1167
+ flattenDeepPlugins(e, plugins);
1168
+ // mount pluginsByKey
1169
+ pluginsByKey(e, plugins);
1170
+ // mount nestedStructureByKey
1171
+ nestedStructureByKey(e, e.plugins);
1172
+ // merge plugin to pluginByKey
1173
+ mergeDeepPlugins(e, e.plugins);
1174
+ e = combinePlugins(e);
1175
+ return e;
1176
+ };
1177
+
1178
+ const createPluginFactory = (defaultPlugin) => (override, overrideByKey = {}) => {
1179
+ return defaultPlugin;
1180
+ };
1181
+
1182
+ const toolbarInitialize = (toolbarItems, global = DefaultGlobalToolbarDefinition, inline = DefaultInlineToolbarDefinition, quick = DefaultQuickToolbarDefinition) => {
1183
+ const toolbarDefinition = {
1184
+ global,
1185
+ inline,
1186
+ quick
1187
+ };
1188
+ const toolbarOperations = new Map();
1189
+ toolbarItems.forEach(i => toolbarOperations.set(i.key, i));
1190
+ const toolbarEntity = nextToolbarEntity(toolbarDefinition, toolbarOperations);
1191
+ return {
1192
+ toolbarDefinition,
1193
+ toolbarOperations,
1194
+ toolbarEntity
1195
+ };
1196
+ };
1197
+ const nextToolbarEntity = (toolbarDefinition, toolbarItems) => {
1198
+ const entity = {};
1199
+ for (const defKey in toolbarDefinition) {
1200
+ entity[defKey] = getToolbarItemByKeys(toolbarDefinition[defKey], toolbarItems);
1145
1201
  }
1146
- if (plugin.plugins) {
1147
- plugin.plugins = plugin.plugins.map(p => overridePluginsByKey(p, overrideByKey, true));
1202
+ return entity;
1203
+ };
1204
+ const getToolbarItemByKeys = (keys, toolbarItems) => {
1205
+ const items = [];
1206
+ keys.forEach((key) => {
1207
+ if (key === `split`) {
1208
+ items.push({ key: `split` });
1209
+ return;
1210
+ }
1211
+ const item = toolbarItems.get(key);
1212
+ if (item && item.includes) {
1213
+ items.push(Object.assign(Object.assign({}, item), { includes: getToolbarItemByKeys(item.includes, toolbarItems) }));
1214
+ return;
1215
+ }
1216
+ if (item) {
1217
+ items.push(item);
1218
+ }
1219
+ });
1220
+ return items;
1221
+ };
1222
+ const createToolbar = (editor, toolbar) => {
1223
+ const toolbarItems = editor === null || editor === void 0 ? void 0 : editor.plugins.reduce((prevItems, nextPlugin) => {
1224
+ var _a;
1225
+ prevItems.push(...((_a = nextPlugin === null || nextPlugin === void 0 ? void 0 : nextPlugin.toolbarItems) !== null && _a !== void 0 ? _a : []));
1226
+ return prevItems;
1227
+ }, []);
1228
+ const toolbarOption = toolbarInitialize(toolbarItems, toolbar === null || toolbar === void 0 ? void 0 : toolbar.global, toolbar === null || toolbar === void 0 ? void 0 : toolbar.inline, toolbar === null || toolbar === void 0 ? void 0 : toolbar.quick);
1229
+ const globalToolbarClass = ['the-global-toolbar', getToolbarClass(editor)];
1230
+ const toolbarEntity = toolbarOption.toolbarEntity;
1231
+ return {
1232
+ globalToolbarClass,
1233
+ toolbarEntity
1234
+ };
1235
+ };
1236
+
1237
+ const UNDOING = new WeakMap();
1238
+ const REDOING = new WeakMap();
1239
+ const withTheHistory = (editor) => {
1240
+ const { undo, redo } = editor;
1241
+ editor.undo = () => {
1242
+ UNDOING.set(editor, true);
1243
+ undo();
1244
+ UNDOING.set(editor, false);
1245
+ };
1246
+ editor.redo = () => {
1247
+ REDOING.set(editor, true);
1248
+ redo();
1249
+ REDOING.set(editor, false);
1250
+ };
1251
+ return editor;
1252
+ };
1253
+ const TheHistoryEditor = {
1254
+ isUndoing(editor) {
1255
+ return UNDOING.get(editor);
1256
+ },
1257
+ isRedoing(editor) {
1258
+ return REDOING.get(editor);
1148
1259
  }
1149
- return plugin;
1150
1260
  };
1261
+ const createTheHistoryPlugin = createPluginFactory({
1262
+ key: PluginKeys.theHistory,
1263
+ withOverrides: withTheHistory
1264
+ });
1151
1265
 
1152
1266
  const setMarks = (editor, marks, at) => {
1153
1267
  Transforms.setNodes(editor, marks, {
@@ -1177,8 +1291,6 @@ const clearMarks = (editor) => {
1177
1291
  }
1178
1292
  };
1179
1293
 
1180
- const insertElement = (editor, element) => editor.insertElement(element);
1181
-
1182
1294
  const isAncestor = (node) => Element$1.isElement(node) || Editor.isEditor(node);
1183
1295
 
1184
1296
  const getLastChild$1 = (node, level) => {
@@ -1936,7 +2048,7 @@ var index$1 = /*#__PURE__*/Object.freeze({
1936
2048
  someNode: someNode
1937
2049
  });
1938
2050
 
1939
- const insertElementNext = (editor, element) => {
2051
+ const insertElements = (editor, element) => {
1940
2052
  var _a;
1941
2053
  if (Range.isExpanded(editor.selection)) {
1942
2054
  Editor.deleteFragment(editor);
@@ -2157,8 +2269,7 @@ var index = /*#__PURE__*/Object.freeze({
2157
2269
  __proto__: null,
2158
2270
  setMarks: setMarks,
2159
2271
  clearMarks: clearMarks,
2160
- insertElement: insertElement,
2161
- insertElementNext: insertElementNext,
2272
+ insertElements: insertElements,
2162
2273
  insertParagraph: insertParagraph,
2163
2274
  setNode: setNode,
2164
2275
  unwrapNodesByType: unwrapNodesByType,
@@ -2175,129 +2286,6 @@ var index = /*#__PURE__*/Object.freeze({
2175
2286
  handleContinualInsertBreak: handleContinualInsertBreak
2176
2287
  });
2177
2288
 
2178
- const withTheia = (editor, plugins = []) => {
2179
- let e = editor;
2180
- e.renderElement = (element) => null;
2181
- e.renderLeaf = (text) => null;
2182
- e.insertElement = (element) => insertElementNext(e, element);
2183
- e.isContainer = (value) => false;
2184
- e.extraElementOptions = [];
2185
- e.disabled = false;
2186
- e.plugins = [];
2187
- e.pluginsByKey = {};
2188
- e.nestedStructureByKey = {};
2189
- // withOverridesByKey
2190
- flattenDeepPlugins(e, plugins);
2191
- // 如果 plugin.overrideByKey 存在,则把 plugin.overrideByKey 中的所有 key 覆盖到 editor.pluginsByKey 中
2192
- editor.plugins.forEach(plugin => {
2193
- if (plugin.overrideByKey) {
2194
- const newPlugins = editor.plugins.map(p => {
2195
- return overridePluginsByKey(p, plugin.overrideByKey);
2196
- });
2197
- editor.plugins = [];
2198
- editor.pluginsByKey = {};
2199
- // 再次扁平化覆盖
2200
- flattenDeepPlugins(editor, newPlugins);
2201
- }
2202
- });
2203
- // withOverrides
2204
- e.plugins.forEach((plugin) => {
2205
- if (plugin.withOverrides) {
2206
- e = plugin.withOverrides(e, plugin);
2207
- }
2208
- });
2209
- return e;
2210
- };
2211
-
2212
- const createPluginFactory = (defaultPlugin) => (override, overrideByKey = {}) => {
2213
- overrideByKey[defaultPlugin.key] = override;
2214
- return overridePluginsByKey(Object.assign({}, defaultPlugin), overrideByKey);
2215
- };
2216
-
2217
- const toolbarInitialize = (toolbarItems, global = DefaultGlobalToolbarDefinition, inline = DefaultInlineToolbarDefinition, quick = DefaultQuickToolbarDefinition) => {
2218
- const toolbarDefinition = {
2219
- global,
2220
- inline,
2221
- quick
2222
- };
2223
- const toolbarOperations = new Map();
2224
- toolbarItems.forEach(i => toolbarOperations.set(i.key, i));
2225
- const toolbarEntity = nextToolbarEntity(toolbarDefinition, toolbarOperations);
2226
- return {
2227
- toolbarDefinition,
2228
- toolbarOperations,
2229
- toolbarEntity
2230
- };
2231
- };
2232
- const nextToolbarEntity = (toolbarDefinition, toolbarItems) => {
2233
- const entity = {};
2234
- for (const defKey in toolbarDefinition) {
2235
- entity[defKey] = getToolbarItemByKeys(toolbarDefinition[defKey], toolbarItems);
2236
- }
2237
- return entity;
2238
- };
2239
- const getToolbarItemByKeys = (keys, toolbarItems) => {
2240
- const items = [];
2241
- keys.forEach((key) => {
2242
- if (key === `split`) {
2243
- items.push({ key: `split` });
2244
- return;
2245
- }
2246
- const item = toolbarItems.get(key);
2247
- if (item && item.includes) {
2248
- items.push(Object.assign(Object.assign({}, item), { includes: getToolbarItemByKeys(item.includes, toolbarItems) }));
2249
- return;
2250
- }
2251
- if (item) {
2252
- items.push(item);
2253
- }
2254
- });
2255
- return items;
2256
- };
2257
- const createToolbar = (editor, toolbar) => {
2258
- const toolbarItems = editor === null || editor === void 0 ? void 0 : editor.plugins.reduce((prevItems, nextPlugin) => {
2259
- var _a;
2260
- prevItems.push(...((_a = nextPlugin === null || nextPlugin === void 0 ? void 0 : nextPlugin.toolbarItems) !== null && _a !== void 0 ? _a : []));
2261
- return prevItems;
2262
- }, []);
2263
- const toolbarOption = toolbarInitialize(toolbarItems, toolbar === null || toolbar === void 0 ? void 0 : toolbar.global, toolbar === null || toolbar === void 0 ? void 0 : toolbar.inline, toolbar === null || toolbar === void 0 ? void 0 : toolbar.quick);
2264
- const globalToolbarClass = ['the-global-toolbar', getToolbarClass(editor)];
2265
- const toolbarEntity = toolbarOption.toolbarEntity;
2266
- return {
2267
- globalToolbarClass,
2268
- toolbarEntity
2269
- };
2270
- };
2271
-
2272
- const UNDOING = new WeakMap();
2273
- const REDOING = new WeakMap();
2274
- const withTheHistory = (editor) => {
2275
- const { undo, redo } = editor;
2276
- editor.undo = () => {
2277
- UNDOING.set(editor, true);
2278
- undo();
2279
- UNDOING.set(editor, false);
2280
- };
2281
- editor.redo = () => {
2282
- REDOING.set(editor, true);
2283
- redo();
2284
- REDOING.set(editor, false);
2285
- };
2286
- return editor;
2287
- };
2288
- const TheHistoryEditor = {
2289
- isUndoing(editor) {
2290
- return UNDOING.get(editor);
2291
- },
2292
- isRedoing(editor) {
2293
- return REDOING.get(editor);
2294
- }
2295
- };
2296
- const createTheHistoryPlugin = createPluginFactory({
2297
- key: PluginKeys.theHistory,
2298
- withOverrides: withTheHistory
2299
- });
2300
-
2301
2289
  class TheConversionHintComponent {
2302
2290
  constructor() {
2303
2291
  this.duration = 10000;
@@ -3884,7 +3872,6 @@ const ListEditor = {
3884
3872
  }
3885
3873
  // wrap
3886
3874
  ListEditor.buildListItem(editor);
3887
- // Todo: types
3888
3875
  Transforms.wrapNodes(editor, { type, children: [], start: startIndex }, {
3889
3876
  at: editor.selection,
3890
3877
  match: node => Element$1.isElement(node) && node.type === ElementKinds.listItem
@@ -4219,18 +4206,17 @@ class TheTodoItemComponent extends TheBaseElementComponent {
4219
4206
  var _a;
4220
4207
  return (_a = this.element) === null || _a === void 0 ? void 0 : _a.indent;
4221
4208
  }
4209
+ get editableWithReadonly() {
4210
+ var _a;
4211
+ return (_a = getPluginOptions(this.editor, PluginKeys.checkItem)) === null || _a === void 0 ? void 0 : _a.editableWithReadonly;
4212
+ }
4222
4213
  ngOnInit() {
4223
4214
  super.ngOnInit();
4224
4215
  }
4225
4216
  onCheck(checked) {
4226
- const options = this.ctxService.getTheOptions();
4227
- const noBindReadonly = options.noBindReadonlyPlugins && options.noBindReadonlyPlugins.includes(ElementKinds.checkItem);
4228
- if (!noBindReadonly && this.readonly) {
4217
+ if (this.readonly && !this.editableWithReadonly) {
4229
4218
  return false;
4230
4219
  }
4231
- else {
4232
- setNode(this.editor, { checked }, this.element);
4233
- }
4234
4220
  setNode(this.editor, { checked }, this.element);
4235
4221
  }
4236
4222
  }
@@ -4355,7 +4341,8 @@ const createTodoItemPlugin = createPluginFactory({
4355
4341
  }
4356
4342
  ],
4357
4343
  options: {
4358
- allowParentTypes: [ElementKinds.tableCell, ElementKinds.blockquote]
4344
+ allowParentTypes: [ElementKinds.tableCell, ElementKinds.blockquote],
4345
+ editableWithReadonly: false
4359
4346
  }
4360
4347
  });
4361
4348
 
@@ -4396,7 +4383,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImpo
4396
4383
 
4397
4384
  const HrEditor = {
4398
4385
  insertHr(editor) {
4399
- insertElement(editor, { type: ElementKinds.hr, children: [{ text: '' }] });
4386
+ insertElements(editor, { type: ElementKinds.hr, children: [{ text: '' }] });
4400
4387
  }
4401
4388
  };
4402
4389
 
@@ -4979,7 +4966,7 @@ function insertTable(opts, editor, rows = 3, columns = 3, getCellContent) {
4979
4966
  }
4980
4967
  // Create the table node
4981
4968
  const table = createTable(opts, columns, rows, getCellContent);
4982
- insertElement(editor, table);
4969
+ insertElements(editor, table);
4983
4970
  }
4984
4971
 
4985
4972
  /**
@@ -5826,13 +5813,13 @@ const autoFormatInline = (editor, { type, between, markup, ignoreTrim, format })
5826
5813
 
5827
5814
  const BlockquoteEditor = {
5828
5815
  toggleBlockquote(editor) {
5816
+ var _a;
5829
5817
  const isActive = isBlockActive(editor, ElementKinds.blockquote);
5818
+ const allowParentTypes = ((_a = getPluginOptions(editor, PluginKeys.blockquote)) === null || _a === void 0 ? void 0 : _a.allowParentTypes) || [];
5830
5819
  if (!isActive) {
5831
- const blockquoteElement = {
5832
- type: ElementKinds.blockquote,
5833
- children: [createEmptyParagraph()]
5834
- };
5835
- insertElement(editor, blockquoteElement);
5820
+ Transforms.wrapNodes(editor, { type: ElementKinds.blockquote, children: [] }, {
5821
+ mode: 'lowest'
5822
+ });
5836
5823
  }
5837
5824
  else {
5838
5825
  Transforms.unwrapNodes(editor, { match: n => Element$1.isElement(n) && n.type === ElementKinds.blockquote });
@@ -5917,7 +5904,7 @@ const CodeEditor = {
5917
5904
  language: DEFAULT_LANGUAGE.value,
5918
5905
  children: [{ text: '' }]
5919
5906
  };
5920
- insertElement(editor, codeElement);
5907
+ insertElements(editor, codeElement);
5921
5908
  }
5922
5909
  else {
5923
5910
  const codeElement = {
@@ -5926,7 +5913,7 @@ const CodeEditor = {
5926
5913
  language: DEFAULT_LANGUAGE.value,
5927
5914
  children: [{ text: '' }]
5928
5915
  };
5929
- insertElement(editor, codeElement);
5916
+ insertElements(editor, codeElement);
5930
5917
  }
5931
5918
  }
5932
5919
  };
@@ -6072,10 +6059,9 @@ const defaultAutoFormatRules = [
6072
6059
  }
6073
6060
  ];
6074
6061
 
6075
- const mergAutoFormateRules = (extraAutoFormatRules) => {
6076
- const combinationData = [...defaultAutoFormatRules, ...extraAutoFormatRules];
6062
+ const mergAutoFormateRules = (rules) => {
6077
6063
  const dataInfo = {};
6078
- combinationData.forEach(item => {
6064
+ rules.forEach(item => {
6079
6065
  if (!dataInfo[item.type + item.key]) {
6080
6066
  dataInfo[item.type + item.key] = Object.assign({}, item);
6081
6067
  }
@@ -6087,11 +6073,9 @@ const withAutoFormat = (editor) => {
6087
6073
  const { insertText } = editor;
6088
6074
  editor.insertText = text => {
6089
6075
  var _a, _b;
6090
- let autoFormatRules = defaultAutoFormatRules;
6091
- if ((_a = editor.extraAutoFormatRules) === null || _a === void 0 ? void 0 : _a.length) {
6092
- const extraRules = mergAutoFormateRules(editor.extraAutoFormatRules);
6093
- autoFormatRules = Object.values(extraRules);
6094
- }
6076
+ let autoFormatRules = (_a = getPluginOptions(editor, PluginKeys.autoFormat)) === null || _a === void 0 ? void 0 : _a.autoFormatRules;
6077
+ const extraRules = mergAutoFormateRules(autoFormatRules);
6078
+ autoFormatRules = Object.values(extraRules);
6095
6079
  if (!isCollapsed(editor.selection)) {
6096
6080
  return insertText(text);
6097
6081
  }
@@ -6170,7 +6154,10 @@ const withAutoFormat = (editor) => {
6170
6154
  };
6171
6155
  const createAutoFormatPlugin = createPluginFactory({
6172
6156
  key: PluginKeys.autoFormat,
6173
- withOverrides: withAutoFormat
6157
+ withOverrides: withAutoFormat,
6158
+ options: {
6159
+ autoFormatRules: defaultAutoFormatRules
6160
+ }
6174
6161
  });
6175
6162
 
6176
6163
  const withTransforms = (editor) => {
@@ -11472,10 +11459,10 @@ const withQuickInsert = (editor) => {
11472
11459
  const { onKeydown, deleteBackward, onChange } = editor;
11473
11460
  let presseingQuickInsertHotkey = false;
11474
11461
  editor.onKeydown = (event) => {
11475
- var _a, _b;
11476
- const hotkey = (_a = getPluginOptions(editor, PluginKeys.quickInsert)) === null || _a === void 0 ? void 0 : _a.hotkey;
11462
+ const options = getPluginOptions(editor, PluginKeys.quickInsert);
11463
+ const { hotkey, allowHotkeyInTypes } = options;
11477
11464
  if (event.key === hotkey) {
11478
- const types = [...(((_b = editor.options) === null || _b === void 0 ? void 0 : _b.allowContainerOperateTypes) || [])];
11465
+ const types = [...(allowHotkeyInTypes || [])];
11479
11466
  const [block] = getBlockAbove(editor);
11480
11467
  if (isPureEmptyParagraph(editor, block) && allowOpenQuickToolbar(editor, types)) {
11481
11468
  presseingQuickInsertHotkey = true;
@@ -13231,13 +13218,12 @@ class TheEditorComponent extends mixinUnsubscribe(MixinBase) {
13231
13218
  super.ngOnDestroy();
13232
13219
  }
13233
13220
  initialize() {
13234
- var _a, _b, _c;
13221
+ var _a, _b;
13235
13222
  const plugins = [...internalPlugins, ...this.thePlugins];
13236
13223
  this.editor = withTheia(withHistory(withAngular(createEditor(), CLIPBOARD_FORMAT_KEY)), plugins);
13237
13224
  this.generateDecorate();
13238
13225
  this.editor.disabled = (_a = this.theOptions) === null || _a === void 0 ? void 0 : _a.disabled;
13239
13226
  this.editor.extraElementOptions = (_b = this.theOptions) === null || _b === void 0 ? void 0 : _b.extraElementOptions;
13240
- this.editor.extraAutoFormatRules = (_c = this.theOptions) === null || _c === void 0 ? void 0 : _c.extraAutoFormatRules;
13241
13227
  this.editor.options = this.theOptions;
13242
13228
  setEditorUUID(this.editor, idCreator());
13243
13229
  this.theContextService.initialize({
@@ -13818,5 +13804,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImpo
13818
13804
  * Generated bundle index. Do not edit.
13819
13805
  */
13820
13806
 
13821
- export { ALIGN_BLOCK_TYPES, A_TAG_REL_ATTR, AlignEditor, Alignment, BLOCK_DELETEBACKWARD_TYPES, BlockquoteEditor, CLIPBOARD_FORMAT_KEY, CODEMIRROR_PADDING_TOP, CODE_MODES, COMPONENTS, CONTAINER_BLOCKS, CONTROL_KEY, CodeEditor, ColorEditor, DEFAULT_LANGUAGE, DEFAULT_SCROLL_CONTAINER, DefaultElementOptions, DefaultGlobalToolbarDefinition, DefaultInlineToolbarDefinition, DefaultQuickToolbarDefinition, DropdownMode, ELEMENT_UNIQUE_ID, ElementKinds, ErrorCodes, FontSizeTypes, FontSizes, HEADING_TYPES, HeadingEditor, HrEditor, IS_MAC, ImageEditor, IndentEditor, Indents, LINK_DEFAULT_TEXT, LIST_BLOCK_TYPES, LayoutTypes, LinkEditor, ListEditor, MarkEditor, MarkProps, MarkTypes, PICTURE_ACCEPTED_UPLOAD_MIME, PICTURE_ACCEPTED_UPLOAD_SIZE, PLUGIN_COMPONENTS, PluginKeys, QuickInsertEditor, STANDARD_HEADING_TYPES, TAB_SPACE, THE_EDITOR_CONVERSION_HINT_REF, THE_EDITOR_QUICK_TOOLBAR_REF, THE_EDITOR_UUID, THE_INLINE_TOOLBAR_TYPES, THE_MODE_PROVIDER, THE_MODE_TOKEN, THE_UPLOAD_SERVICE_TOKEN, TableEditor, TheBaseElementComponent, TheContextService, TheDataMode, TheDefaultElementComponent, TheEditor, TheEditorComponent, TheEditorModule, TheImageComponent, TheIndentToolbarComponent, TheMode, TheModeConfig, index$1 as TheQueries, TheToolbarBaseItemComponent, TheToolbarComponent, TheToolbarDropdownComponent, TheToolbarGroupComponent, TheToolbarGroupToken, TheToolbarItemComponent, TheToolbarService, index as TheTransforms, TodoItemEditor, ToolbarActionTypes, ToolbarAlignment, ToolbarItemMode, ToolbarItemType, ToolbarMoreGroup, VOID_BLOCK_TYPES, VerticalAlignEditor, VerticalAlignment, ZERO_WIDTH_CHAR, autoFocus, autoScrollViewHandle, coercePixelsFromCssValue, createEmptyParagraph, createPluginFactory, createToolbar, createVerticalAlignPlugin, dataDeserialize, dataSerializing, deleteColorAndBackgroundColorOfText, deleteElementKey, extractFragment, flattenDeepPlugins, getColsTotalWidth, getEditorUUID, getElementClassByPrefix, getElementHeight, getElementWidth, getEndBlock, getPlugin, getPluginOptions, getPlugins, getPluginsByKey, getRowsTotalHeight, getStartBlock, getToolbarClass, headingOptions, htmlToTheia, idCreator, inValidTypes, internalPlugins, isCleanEmptyParagraph, isPureEmptyParagraph, mergeElementOptions, mergeOptions, overridePluginsByKey, plainToTheia, setEditorUUID, useElementStyle, withTheia };
13807
+ export { ALIGN_BLOCK_TYPES, A_TAG_REL_ATTR, AlignEditor, Alignment, BLOCK_DELETEBACKWARD_TYPES, BlockquoteEditor, CLIPBOARD_FORMAT_KEY, CODEMIRROR_PADDING_TOP, CODE_MODES, COMPONENTS, CONTAINER_BLOCKS, CONTROL_KEY, CodeEditor, ColorEditor, DEFAULT_LANGUAGE, DEFAULT_SCROLL_CONTAINER, DefaultElementOptions, DefaultGlobalToolbarDefinition, DefaultInlineToolbarDefinition, DefaultQuickToolbarDefinition, DropdownMode, ELEMENT_UNIQUE_ID, ElementKinds, ErrorCodes, FontSizeTypes, FontSizes, HEADING_TYPES, HeadingEditor, HrEditor, IS_MAC, ImageEditor, IndentEditor, Indents, LINK_DEFAULT_TEXT, LIST_BLOCK_TYPES, LayoutTypes, LinkEditor, ListEditor, MarkEditor, MarkProps, MarkTypes, PICTURE_ACCEPTED_UPLOAD_MIME, PICTURE_ACCEPTED_UPLOAD_SIZE, PLUGIN_COMPONENTS, PluginKeys, QuickInsertEditor, STANDARD_HEADING_TYPES, TAB_SPACE, THE_EDITOR_CONVERSION_HINT_REF, THE_EDITOR_QUICK_TOOLBAR_REF, THE_EDITOR_UUID, THE_INLINE_TOOLBAR_TYPES, THE_MODE_PROVIDER, THE_MODE_TOKEN, THE_UPLOAD_SERVICE_TOKEN, TableEditor, TheBaseElementComponent, TheContextService, TheDataMode, TheDefaultElementComponent, TheEditor, TheEditorComponent, TheEditorModule, TheImageComponent, TheIndentToolbarComponent, TheMode, TheModeConfig, index$1 as TheQueries, TheToolbarBaseItemComponent, TheToolbarComponent, TheToolbarDropdownComponent, TheToolbarGroupComponent, TheToolbarGroupToken, TheToolbarItemComponent, TheToolbarService, index as TheTransforms, TodoItemEditor, ToolbarActionTypes, ToolbarAlignment, ToolbarItemMode, ToolbarItemType, ToolbarMoreGroup, VOID_BLOCK_TYPES, VerticalAlignEditor, VerticalAlignment, ZERO_WIDTH_CHAR, autoFocus, autoScrollViewHandle, coercePixelsFromCssValue, combinePlugins, createEmptyParagraph, createPluginFactory, createToolbar, createVerticalAlignPlugin, dataDeserialize, dataSerializing, deleteColorAndBackgroundColorOfText, deleteElementKey, extractFragment, flattenDeepPlugins, getColsTotalWidth, getEditorUUID, getElementClassByPrefix, getElementHeight, getElementWidth, getEndBlock, getPlugin, getPluginByKey, getPluginOptions, getPlugins, getRowsTotalHeight, getStartBlock, getToolbarClass, headingOptions, htmlToTheia, idCreator, inValidTypes, internalPlugins, isCleanEmptyParagraph, isPureEmptyParagraph, mergeDeepPlugins, mergeElementOptions, mergeOptions, nestedStructureByKey, plainToTheia, pluginsByKey, setEditorUUID, useElementStyle, withTheia };
13822
13808
  //# sourceMappingURL=worktile-theia.js.map