@worktile/theia 15.0.19 → 15.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/esm2020/interfaces/editor.mjs +1 -1
  2. package/esm2020/interfaces/plugins/plugin-key.mjs +2 -2
  3. package/esm2020/interfaces/valid-children-types.mjs +7 -7
  4. package/esm2020/plugins/common/insert-data-by-invalid-type.mjs +23 -0
  5. package/esm2020/plugins/deserialize/deserialize-html.plugin.mjs +53 -0
  6. package/esm2020/plugins/deserialize/deserialize-md.plugin.mjs +130 -0
  7. package/esm2020/plugins/index.mjs +5 -5
  8. package/esm2020/plugins/mention/mention.plugin.mjs +3 -2
  9. package/esm2020/plugins/mention/mention.type.mjs +1 -1
  10. package/esm2020/utils/index.mjs +2 -1
  11. package/esm2020/utils/insert-data-by-invalid-type.mjs +62 -0
  12. package/esm2020/utils/merge-element-options.mjs +5 -5
  13. package/fesm2015/worktile-theia.mjs +82 -70
  14. package/fesm2015/worktile-theia.mjs.map +1 -1
  15. package/fesm2020/worktile-theia.mjs +81 -69
  16. package/fesm2020/worktile-theia.mjs.map +1 -1
  17. package/interfaces/plugins/plugin-key.d.ts +1 -1
  18. package/interfaces/valid-children-types.d.ts +1 -1
  19. package/package.json +1 -1
  20. package/plugins/common/insert-data-by-invalid-type.d.ts +2 -0
  21. package/plugins/mention/mention.type.d.ts +3 -1
  22. package/utils/index.d.ts +1 -0
  23. package/utils/insert-data-by-invalid-type.d.ts +1 -0
  24. package/esm2020/plugins/common/auto-insert-data.mjs +0 -75
  25. package/esm2020/plugins/deserializers/deserialize-html.plugin.mjs +0 -48
  26. package/esm2020/plugins/deserializers/deserialize-md.plugin.mjs +0 -130
  27. package/plugins/common/auto-insert-data.d.ts +0 -2
  28. /package/plugins/{deserializers → deserialize}/deserialize-html.plugin.d.ts +0 -0
  29. /package/plugins/{deserializers → deserialize}/deserialize-md.plugin.d.ts +0 -0
@@ -2019,28 +2019,28 @@ const inValidTypes = [
2019
2019
  const DefaultElementOptions = [
2020
2020
  {
2021
2021
  type: ElementKinds.bulletedList,
2022
- inValidChildrenTypes: [...inValidTypes, ...HEADING_TYPES]
2022
+ invalidChildrenTypes: [...inValidTypes, ...HEADING_TYPES]
2023
2023
  },
2024
2024
  {
2025
2025
  type: ElementKinds.numberedList,
2026
- inValidChildrenTypes: [...inValidTypes, ...HEADING_TYPES]
2026
+ invalidChildrenTypes: [...inValidTypes, ...HEADING_TYPES]
2027
2027
  },
2028
2028
  {
2029
2029
  type: ElementKinds.listItem,
2030
- inValidChildrenTypes: [...inValidTypes, ...HEADING_TYPES]
2030
+ invalidChildrenTypes: [...inValidTypes, ...HEADING_TYPES]
2031
2031
  },
2032
2032
  {
2033
2033
  type: ElementKinds.blockquote,
2034
- inValidChildrenTypes: inValidTypes
2034
+ invalidChildrenTypes: inValidTypes
2035
2035
  },
2036
2036
  {
2037
2037
  type: ElementKinds.table,
2038
- inValidChildrenTypes: [ElementKinds.table]
2038
+ invalidChildrenTypes: [ElementKinds.table]
2039
2039
  },
2040
2040
  {
2041
2041
  type: ElementKinds.tableCell,
2042
2042
  isSecondaryContainer: true,
2043
- inValidChildrenTypes: [ElementKinds.table, ElementKinds.tableCell]
2043
+ invalidChildrenTypes: [ElementKinds.table, ElementKinds.tableCell]
2044
2044
  }
2045
2045
  ];
2046
2046
 
@@ -2071,7 +2071,7 @@ var PluginKeys;
2071
2071
  PluginKeys["removeVoid"] = "remove-void";
2072
2072
  PluginKeys["removeEmpty"] = "remove-empty";
2073
2073
  PluginKeys["theHistory"] = "the-history";
2074
- PluginKeys["autoInsertData"] = "auto-insert-data";
2074
+ PluginKeys["insertDataByInvalidType"] = "insert-data-by-invalid-type";
2075
2075
  PluginKeys["autoFormat"] = "auto-format";
2076
2076
  PluginKeys["transforms"] = "transforms";
2077
2077
  PluginKeys["moveSelection"] = "move-selection";
@@ -2217,19 +2217,19 @@ const isPureEmptyParagraph = (editor, block) => {
2217
2217
  };
2218
2218
 
2219
2219
  const mergeElementOptions = (elementOptions) => {
2220
- elementOptions = elementOptions.filter(item => item.inValidChildrenTypes.length > 0);
2220
+ elementOptions = elementOptions.filter(item => item.invalidChildrenTypes.length > 0);
2221
2221
  const combinationData = [...DefaultElementOptions, ...elementOptions];
2222
2222
  const dataInfo = {};
2223
2223
  combinationData.forEach(item => {
2224
- const { type, inValidChildrenTypes, isSecondaryContainer } = item;
2224
+ const { type, invalidChildrenTypes, isSecondaryContainer } = item;
2225
2225
  if (!dataInfo[type]) {
2226
2226
  dataInfo[type] = {
2227
2227
  type,
2228
- inValidChildrenTypes,
2228
+ invalidChildrenTypes,
2229
2229
  isSecondaryContainer
2230
2230
  };
2231
2231
  }
2232
- dataInfo[type].inValidChildrenTypes = Array.from(new Set([...inValidChildrenTypes, ...dataInfo[type].inValidChildrenTypes]));
2232
+ dataInfo[type].invalidChildrenTypes = Array.from(new Set([...invalidChildrenTypes, ...dataInfo[type].invalidChildrenTypes]));
2233
2233
  });
2234
2234
  return dataInfo;
2235
2235
  };
@@ -2436,6 +2436,62 @@ const refocus = (editor) => {
2436
2436
  AngularEditor.focus(editor);
2437
2437
  };
2438
2438
 
2439
+ function insertDataByInvalidType(editor, fragment) {
2440
+ if (fragment) {
2441
+ let allElementOptions = DefaultElementOptions;
2442
+ if (editor.extraElementOptions?.length) {
2443
+ const extraInfo = mergeElementOptions(editor.extraElementOptions);
2444
+ allElementOptions = Object.values(extraInfo);
2445
+ }
2446
+ if (isAcrossBlocks(editor, fragment) || Editor.isVoid(editor, fragment[0])) {
2447
+ const { selection } = editor;
2448
+ const [start] = Editor.edges(editor, selection);
2449
+ // query whether there is a node to be verified
2450
+ const tryVerifyNode = allElementOptions.find(item => getAboveByType(editor, item.type, { at: start, mode: 'lowest' }));
2451
+ if (tryVerifyNode) {
2452
+ // is exist invalid element type in fragment
2453
+ const invalidIndex = fragment.findIndex(item => tryVerifyNode.invalidChildrenTypes.includes(item.type));
2454
+ if (invalidIndex > -1) {
2455
+ const invalidFragmentData = fragment.slice(invalidIndex, fragment.length);
2456
+ const allowParentTypes = getPluginOptions(editor, invalidFragmentData[0].type)?.allowParentTypes || [];
2457
+ const insertNodePath = getInsertElementsPath(editor, allowParentTypes);
2458
+ if (insertNodePath) {
2459
+ Editor.withoutNormalizing(editor, () => {
2460
+ Transforms.insertNodes(editor, fragment, { at: insertNodePath });
2461
+ Transforms.select(editor, Editor.start(editor, insertNodePath));
2462
+ });
2463
+ return false;
2464
+ }
2465
+ const [, anchorBlockPath] = anchorBlockEntry(editor);
2466
+ const nextPath = Path.next([anchorBlockPath[0]]);
2467
+ Transforms.insertNodes(editor, fragment, { at: nextPath });
2468
+ Transforms.select(editor, Editor.start(editor, nextPath));
2469
+ return false;
2470
+ }
2471
+ }
2472
+ Editor.withoutNormalizing(editor, () => {
2473
+ const isEmptyParagraph$1 = isEmptyParagraph(editor, editor.selection.anchor);
2474
+ const emptyPath = Path.parent(editor.selection.anchor.path);
2475
+ Transforms.insertNodes(editor, fragment);
2476
+ if (isEmptyParagraph$1) {
2477
+ Transforms.delete(editor, { at: emptyPath });
2478
+ const lastPath = emptyPath.pop();
2479
+ Transforms.select(editor, [...emptyPath, lastPath + fragment.length - 1]);
2480
+ }
2481
+ else {
2482
+ const lastPath = emptyPath.pop();
2483
+ Transforms.select(editor, [...emptyPath, lastPath + fragment.length]);
2484
+ }
2485
+ AngularEditor.focus(editor);
2486
+ Transforms.collapse(editor, { edge: 'end' });
2487
+ });
2488
+ return false;
2489
+ }
2490
+ return true;
2491
+ }
2492
+ return true;
2493
+ }
2494
+
2439
2495
  const toolbarInitialize = (toolbarItems, global = DefaultGlobalToolbarDefinition, inline = DefaultInlineToolbarDefinition) => {
2440
2496
  const toolbarDefinition = {
2441
2497
  global,
@@ -5217,7 +5273,8 @@ const withMention = (editor) => {
5217
5273
  else {
5218
5274
  const mentions = getPluginOptions(editor, PluginKeys.mention)?.mentions;
5219
5275
  const currentMention = mentions?.find(m => m?.trigger === text);
5220
- if (editor.selection && currentMention) {
5276
+ const isDisabledTrigger = currentMention && currentMention.disableTrigger ? currentMention?.disableTrigger(editor) : false;
5277
+ if (editor.selection && currentMention && !isDisabledTrigger) {
5221
5278
  MentionEditor.openSuggestion(editor, currentMention.type);
5222
5279
  }
5223
5280
  const searchInfo = MentionEditor.getSearchInfo(editor);
@@ -7321,62 +7378,13 @@ const createColorPlugin = createPluginFactory({
7321
7378
  }
7322
7379
  });
7323
7380
 
7324
- const withAutoInsertData = (editor) => {
7381
+ const withInsertDataByInvalidType = (editor) => {
7325
7382
  const { insertData } = editor;
7326
- let allElementOptions = DefaultElementOptions;
7327
- // if (validChildren?.length) {
7328
- // const validInfo = mergeElementOptions(validChildren);
7329
- // allElementOptions = Object.values(validInfo);
7330
- // }
7331
7383
  editor.insertData = (data) => {
7332
- if (editor.extraElementOptions?.length) {
7333
- const extraInfo = mergeElementOptions(editor.extraElementOptions);
7334
- allElementOptions = Object.values(extraInfo);
7335
- }
7336
7384
  const fragment = extractFragment(data);
7337
7385
  if (fragment) {
7338
- if (isAcrossBlocks(editor, fragment) || Editor.isVoid(editor, fragment[0])) {
7339
- const { selection } = editor;
7340
- const [start] = Editor.edges(editor, selection);
7341
- // query whether there is a node to be verified
7342
- const tryVerifyNode = allElementOptions.find(item => getAboveByType(editor, item.type, { at: start, mode: 'lowest' }));
7343
- if (tryVerifyNode) {
7344
- // is exist invalid element type in fragment
7345
- const invalidIndex = fragment.findIndex(item => tryVerifyNode.inValidChildrenTypes.includes(item.type));
7346
- if (invalidIndex > -1) {
7347
- const invalidFragmentData = fragment.slice(invalidIndex, fragment.length);
7348
- const allowParentTypes = getPluginOptions(editor, invalidFragmentData[0].type)?.allowParentTypes || [];
7349
- const insertNodePath = getInsertElementsPath(editor, allowParentTypes);
7350
- if (insertNodePath) {
7351
- Editor.withoutNormalizing(editor, () => {
7352
- Transforms.insertNodes(editor, fragment, { at: insertNodePath });
7353
- Transforms.select(editor, Editor.start(editor, insertNodePath));
7354
- });
7355
- return;
7356
- }
7357
- const [, anchorBlockPath] = anchorBlockEntry(editor);
7358
- const nextPath = Path.next([anchorBlockPath[0]]);
7359
- Transforms.insertNodes(editor, fragment, { at: nextPath });
7360
- Transforms.select(editor, Editor.start(editor, nextPath));
7361
- return;
7362
- }
7363
- }
7364
- Editor.withoutNormalizing(editor, () => {
7365
- const isEmptyParagraph$1 = isEmptyParagraph(editor, editor.selection.anchor);
7366
- const emptyPath = Path.parent(editor.selection.anchor.path);
7367
- Transforms.insertNodes(editor, fragment);
7368
- if (isEmptyParagraph$1) {
7369
- Transforms.delete(editor, { at: emptyPath });
7370
- const lastPath = emptyPath.pop();
7371
- Transforms.select(editor, [...emptyPath, lastPath + fragment.length - 1]);
7372
- }
7373
- else {
7374
- const lastPath = emptyPath.pop();
7375
- Transforms.select(editor, [...emptyPath, lastPath + fragment.length]);
7376
- }
7377
- AngularEditor.focus(editor);
7378
- Transforms.collapse(editor, { edge: 'end' });
7379
- });
7386
+ const isContinue = insertDataByInvalidType(editor, fragment);
7387
+ if (!isContinue) {
7380
7388
  return;
7381
7389
  }
7382
7390
  }
@@ -7384,9 +7392,9 @@ const withAutoInsertData = (editor) => {
7384
7392
  };
7385
7393
  return editor;
7386
7394
  };
7387
- const createAutoInsertDataPlugin = createPluginFactory({
7388
- key: PluginKeys.autoInsertData,
7389
- withOverrides: withAutoInsertData
7395
+ const createInsertDataByInvalidTypePlugin = createPluginFactory({
7396
+ key: PluginKeys.insertDataByInvalidType,
7397
+ withOverrides: withInsertDataByInvalidType
7390
7398
  });
7391
7399
 
7392
7400
  const withBlockCard = (editor) => {
@@ -8012,6 +8020,10 @@ const withDeserializeHTML = (editor) => {
8012
8020
  ImageEditor.handleBase64ImageElement(editor, node);
8013
8021
  }
8014
8022
  });
8023
+ const isContinue = insertDataByInvalidType(editor, fragment);
8024
+ if (!isContinue) {
8025
+ return;
8026
+ }
8015
8027
  Transforms.insertFragment(editor, fragment);
8016
8028
  return;
8017
8029
  }
@@ -15560,7 +15572,7 @@ const createTodoItemPlugin = createPluginFactory({
15560
15572
  const internalPlugins = () => [
15561
15573
  createTheHistoryPlugin(),
15562
15574
  createCommonPlugin(),
15563
- createAutoInsertDataPlugin(),
15575
+ createInsertDataByInvalidTypePlugin(),
15564
15576
  createRemoveEmptyPlugin(),
15565
15577
  createRemoveVoidPlugin(),
15566
15578
  createBlockCardPlugin(),
@@ -16531,5 +16543,5 @@ const withTestPlugin = (plugins, initValue) => {
16531
16543
  * Generated bundle index. Do not edit.
16532
16544
  */
16533
16545
 
16534
- export { ALIGN_BLOCK_TYPES, A_TAG_REL_ATTR, AlignEditor, Alignment, BLOCK_DELETE_BACKWARD_TYPES, BackgroundColors, BlockquoteEditor, CLIPBOARD_FORMAT_KEY, CODEMIRROR_PADDING_TOP, CODE_MODES, COMPONENTS, CONTAINER_BLOCKS, CONTROL_KEY, CodeEditor, ColorEditor, Colors, ColumnResizeNotifierSource, DEFAULT_LANGUAGE, DEFAULT_SCROLL_CONTAINER, DISABLED_OPERATE_TYPES, DefaultElementOptions, DefaultGlobalToolbarDefinition, DefaultInlineToolbarDefinition, DefaultPluginMenu, DropdownMode, ELEMENT_UNIQUE_ID, ElementKinds, ErrorCodes, FontSizeTypes, FontSizes, HEADING_TYPES, HeadingEditor, HoveredCellInfo, HrEditor, IS_MAC, ImageEditor, IndentEditor, Indents, InlineCodeEditor, LINK_DEFAULT_TEXT, LIST_BLOCK_TYPES, LayoutTypes, LinkEditor, ListEditor, MarkEditor, MarkProps, MarkTypes, MentionEditor, PICTURE_ACCEPTED_UPLOAD_MIME, PICTURE_ACCEPTED_UPLOAD_SIZE, PLUGIN_COMPONENTS, PluginKeys, PluginMenuIcons, PluginMenuSvgs, Position, QuickInsertEditor, STANDARD_HEADING_TYPES, ScrollDirection, SpecialBackgroundColor, SpecialTextColor, TAB_SPACE, THE_EDITOR_CONVERSION_HINT_REF, THE_EDITOR_ORIGIN_ANCHOR, THE_EDITOR_POPOVER_REF, THE_EDITOR_PREVIOUS_SELECTION, THE_EDITOR_UUID, THE_INLINE_TOOLBAR_TYPES, THE_LISTBOX_PARENT_GROUP_TOKEN, THE_LISTBOX_PARENT_OPTION_TOKEN, THE_LISTBOX_TOKEN, THE_MODE_PROVIDER, THE_MODE_TOKEN, THE_PLUGIN_MENU_REF, THE_UPLOAD_SERVICE_TOKEN, TableCellEventDispatcher, TableEditor, TableHeaderBackgroundColor, TheBaseElementComponent, TheBaseSuggestion, TheBaseToolbarDropdown, TheBaseToolbarItem, TheContextService, TheDataMode, TheDefaultElementComponent, TheEditor, TheEditorComponent, TheEditorModule, TheImageComponent, TheListboxDirective, TheListboxGroupDirective, TheListboxOptionDirective, TheMode, TheModeConfig, ThePluginMenu, ThePluginMenuComponent, ThePluginMenuItemType, ThePreventDefaultDirective, index$1 as TheQueries, TheToolbarComponent, TheToolbarDropdownComponent, TheToolbarGroupComponent, TheToolbarGroupToken, TheToolbarItemComponent, TheToolbarService, index as TheTransforms, TodoItemEditor, ToolbarActionTypes, ToolbarAlignment, ToolbarItemType, ToolbarMoreGroup, VOID_BLOCK_TYPES, VerticalAlignEditor, VerticalAlignment, ZERO_WIDTH_CHAR, autoFocus, base64toBlob, buildPluginMenu, buildPluginMenuItemMap, coercePixelsFromCssValue, combinePlugins, copyNode, copyNodeForSafari, createEmptyParagraph, createMentionPlugin, createPluginFactory, createToolbar, createVerticalAlignPlugin, dataDeserialize, dataSerializing, deleteElementKey, extractFragment, filterTextFormat, flattenDeepPlugins, getColsTotalWidth, getEditorUUID, getElementClassByPrefix, getElementHeight, getElementWidth, getEndBlock, getPlugin, getPluginOptions, getPlugins, getRowsTotalHeight, getStartBlock, getToolbarClass, headingOptions, htmlToTheia, idCreator, inValidTypes, initializeDefaultMenuIcons, internalPlugins, isCleanEmptyParagraph, isDirectionKeydown, isPureEmptyParagraph, mergeArray, mergeDeepPlugins, mergeElementOptions, mergeOptions, nestedStructureByKey, plainToTheia, pluginsByKey, reSelection, recursionNodes, refocus, scrollIntoView, setEditorUUID, useElementStyle, withMention, withTestPlugin, withTheia };
16546
+ export { ALIGN_BLOCK_TYPES, A_TAG_REL_ATTR, AlignEditor, Alignment, BLOCK_DELETE_BACKWARD_TYPES, BackgroundColors, BlockquoteEditor, CLIPBOARD_FORMAT_KEY, CODEMIRROR_PADDING_TOP, CODE_MODES, COMPONENTS, CONTAINER_BLOCKS, CONTROL_KEY, CodeEditor, ColorEditor, Colors, ColumnResizeNotifierSource, DEFAULT_LANGUAGE, DEFAULT_SCROLL_CONTAINER, DISABLED_OPERATE_TYPES, DefaultElementOptions, DefaultGlobalToolbarDefinition, DefaultInlineToolbarDefinition, DefaultPluginMenu, DropdownMode, ELEMENT_UNIQUE_ID, ElementKinds, ErrorCodes, FontSizeTypes, FontSizes, HEADING_TYPES, HeadingEditor, HoveredCellInfo, HrEditor, IS_MAC, ImageEditor, IndentEditor, Indents, InlineCodeEditor, LINK_DEFAULT_TEXT, LIST_BLOCK_TYPES, LayoutTypes, LinkEditor, ListEditor, MarkEditor, MarkProps, MarkTypes, MentionEditor, PICTURE_ACCEPTED_UPLOAD_MIME, PICTURE_ACCEPTED_UPLOAD_SIZE, PLUGIN_COMPONENTS, PluginKeys, PluginMenuIcons, PluginMenuSvgs, Position, QuickInsertEditor, STANDARD_HEADING_TYPES, ScrollDirection, SpecialBackgroundColor, SpecialTextColor, TAB_SPACE, THE_EDITOR_CONVERSION_HINT_REF, THE_EDITOR_ORIGIN_ANCHOR, THE_EDITOR_POPOVER_REF, THE_EDITOR_PREVIOUS_SELECTION, THE_EDITOR_UUID, THE_INLINE_TOOLBAR_TYPES, THE_LISTBOX_PARENT_GROUP_TOKEN, THE_LISTBOX_PARENT_OPTION_TOKEN, THE_LISTBOX_TOKEN, THE_MODE_PROVIDER, THE_MODE_TOKEN, THE_PLUGIN_MENU_REF, THE_UPLOAD_SERVICE_TOKEN, TableCellEventDispatcher, TableEditor, TableHeaderBackgroundColor, TheBaseElementComponent, TheBaseSuggestion, TheBaseToolbarDropdown, TheBaseToolbarItem, TheContextService, TheDataMode, TheDefaultElementComponent, TheEditor, TheEditorComponent, TheEditorModule, TheImageComponent, TheListboxDirective, TheListboxGroupDirective, TheListboxOptionDirective, TheMode, TheModeConfig, ThePluginMenu, ThePluginMenuComponent, ThePluginMenuItemType, ThePreventDefaultDirective, index$1 as TheQueries, TheToolbarComponent, TheToolbarDropdownComponent, TheToolbarGroupComponent, TheToolbarGroupToken, TheToolbarItemComponent, TheToolbarService, index as TheTransforms, TodoItemEditor, ToolbarActionTypes, ToolbarAlignment, ToolbarItemType, ToolbarMoreGroup, VOID_BLOCK_TYPES, VerticalAlignEditor, VerticalAlignment, ZERO_WIDTH_CHAR, autoFocus, base64toBlob, buildPluginMenu, buildPluginMenuItemMap, coercePixelsFromCssValue, combinePlugins, copyNode, copyNodeForSafari, createEmptyParagraph, createMentionPlugin, createPluginFactory, createToolbar, createVerticalAlignPlugin, dataDeserialize, dataSerializing, deleteElementKey, extractFragment, filterTextFormat, flattenDeepPlugins, getColsTotalWidth, getEditorUUID, getElementClassByPrefix, getElementHeight, getElementWidth, getEndBlock, getPlugin, getPluginOptions, getPlugins, getRowsTotalHeight, getStartBlock, getToolbarClass, headingOptions, htmlToTheia, idCreator, inValidTypes, initializeDefaultMenuIcons, insertDataByInvalidType, internalPlugins, isCleanEmptyParagraph, isDirectionKeydown, isPureEmptyParagraph, mergeArray, mergeDeepPlugins, mergeElementOptions, mergeOptions, nestedStructureByKey, plainToTheia, pluginsByKey, reSelection, recursionNodes, refocus, scrollIntoView, setEditorUUID, useElementStyle, withMention, withTestPlugin, withTheia };
16535
16547
  //# sourceMappingURL=worktile-theia.mjs.map