@worktile/theia 19.1.6 → 19.1.7

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.
@@ -77,7 +77,7 @@ export declare class TheListboxDirective implements AfterContentInit {
77
77
  setPreviousLineActive(): void;
78
78
  enterNextGroup(): void;
79
79
  enterPreviousGroup(): void;
80
- setActiveItem(previous: TheListboxOptionDirective | null, option: TheListboxOptionDirective, type: TheListboxChangeEventType): void;
80
+ setActiveItem(previous: TheListboxOptionDirective | null, option: TheListboxOptionDirective, type: TheListboxChangeEventType, triggerFrom?: 'mouse' | 'keyboard'): void;
81
81
  getOption(key: ThePluginMenuItemKey): TheListboxOptionDirective;
82
82
  clearActiveItem(): void;
83
83
  static ɵfac: i0.ɵɵFactoryDeclaration<TheListboxDirective, never>;
@@ -1,7 +1,8 @@
1
1
  import { ChangeDetectorRef, DestroyRef, ElementRef, EventEmitter, Injector, NgZone, OnChanges, OnDestroy, OnInit, SimpleChanges, ViewContainerRef } from '@angular/core';
2
2
  import { ThyIconRegistry } from 'ngx-tethys/icon';
3
3
  import { Descendant, Editor, Element, NodeEntry, Range, Text } from 'slate';
4
- import { DOMRange, SlateError } from 'slate-angular';
4
+ import { SlateError } from 'slate-angular';
5
+ import { DOMRange } from 'slate-dom';
5
6
  import { TheTemplate, TheText, TheToolbarComponent } from './components';
6
7
  import { TheEditor, TheOptions, ThePresetConfig, ThePlugin, ToolbarEntity, DomEventDataInfo } from './interfaces';
7
8
  import { TheContextService } from './services/context.service';
@@ -10,8 +10,9 @@ import { cloneDeep, map, assign, defaults, groupBy, uniq, isEqual } from 'lodash
10
10
  export { assign, cloneDeep, debounce, defaults, groupBy, isEqual, map, uniq } from 'lodash';
11
11
  import { Editor, Element, Span, Range, Path, Node, Point, Text, Transforms, Operation, createEditor } from 'slate';
12
12
  import * as i4 from 'slate-angular';
13
- import { FAKE_LEFT_BLOCK_CARD_OFFSET, FAKE_RIGHT_BLOCK_CARD_OFFSET, NODE_TO_PARENT, NODE_TO_INDEX, getClipboardData, AngularEditor, hotkeys, getPlainText as getPlainText$1, createClipboardData, setClipboardData, isClipboardWriteSupported, BaseElementComponent, IS_SAFARI, ELEMENT_TO_COMPONENT, NODE_TO_ELEMENT, BaseTextComponent, SlateModule, hasBlockCard, isCardLeft, SlateChildrenOutlet, EDITOR_TO_ELEMENT, defaultScrollSelectionIntoView, getDataTransferClipboard, withAngular } from 'slate-angular';
13
+ import { FAKE_LEFT_BLOCK_CARD_OFFSET, FAKE_RIGHT_BLOCK_CARD_OFFSET, getClipboardData, AngularEditor, hotkeys, getPlainText as getPlainText$1, createClipboardData, setClipboardData, isClipboardWriteSupported, BaseElementComponent, IS_SAFARI, ELEMENT_TO_COMPONENT, BaseTextComponent, SlateModule, hasBlockCard, isCardLeft, SlateChildrenOutlet, defaultScrollSelectionIntoView, getDataTransferClipboard, withAngular } from 'slate-angular';
14
14
  import { HistoryEditor, withHistory } from 'slate-history';
15
+ import { NODE_TO_PARENT, NODE_TO_INDEX, NODE_TO_ELEMENT, EDITOR_TO_ELEMENT } from 'slate-dom';
15
16
  import { TheiaConverter } from '@atinc/selene';
16
17
  import { isObject, isArray, isString, isUndefined } from 'ngx-tethys/util';
17
18
  import * as i1 from 'ngx-tethys/popover';
@@ -4324,12 +4325,15 @@ class TheListboxDirective {
4324
4325
  }
4325
4326
  this.setActiveItem(this.activeOption, groups[newGroupIndex].getLast(), 'turn');
4326
4327
  }
4327
- setActiveItem(previous, option, type) {
4328
+ setActiveItem(previous, option, type, triggerFrom = 'keyboard') {
4328
4329
  if (previous) {
4329
4330
  previous.setActive(false);
4330
4331
  }
4331
4332
  option.setActive(true);
4332
4333
  this.activeOption = option;
4334
+ if (triggerFrom === 'mouse' && type === 'turn') {
4335
+ return;
4336
+ }
4333
4337
  this.theListboxChange.emit({ option, type });
4334
4338
  }
4335
4339
  getOption(key) {
@@ -7988,7 +7992,7 @@ class ThePluginMenuComponent {
7988
7992
  if (listBox) {
7989
7993
  const activeOption = listBox.activeOption;
7990
7994
  const newActiveOption = listBox.getOption(menu?.key);
7991
- listBox.setActiveItem(activeOption, newActiveOption, 'turn');
7995
+ listBox.setActiveItem(activeOption, newActiveOption, 'turn', 'mouse');
7992
7996
  }
7993
7997
  }
7994
7998
  listBoxOptionMouseleave(e, menu) {
@@ -8469,12 +8473,12 @@ const closeConversionHint = (editor) => {
8469
8473
  }
8470
8474
  };
8471
8475
  const withDeserializeMd = (editor) => {
8472
- const { insertFragmentData, onKeydown } = editor;
8476
+ const { customInsertFragmentData, onKeydown } = editor;
8473
8477
  editor.onKeydown = (event) => {
8474
8478
  closeConversionHint(editor);
8475
8479
  onKeydown(event);
8476
8480
  };
8477
- editor.insertFragmentData = async (data) => {
8481
+ editor.customInsertFragmentData = async (data) => {
8478
8482
  const popover = editor.injector.get(ThyPopover);
8479
8483
  const viewContainerRef = editor.injector.get(ViewContainerRef);
8480
8484
  const cdr = editor.injector.get(ChangeDetectorRef);
@@ -8545,7 +8549,7 @@ const withDeserializeMd = (editor) => {
8545
8549
  cdr.markForCheck();
8546
8550
  });
8547
8551
  }
8548
- return insertFragmentData(data);
8552
+ return customInsertFragmentData(data);
8549
8553
  };
8550
8554
  return editor;
8551
8555
  };
@@ -10394,8 +10398,8 @@ const createTheHistoryPlugin = createPluginFactory({
10394
10398
  });
10395
10399
 
10396
10400
  const withInsertDataByInvalidType = (editor) => {
10397
- const { insertFragmentData } = editor;
10398
- editor.insertFragmentData = async (data) => {
10401
+ const { customInsertFragmentData } = editor;
10402
+ editor.customInsertFragmentData = async (data) => {
10399
10403
  const fragment = await extractFragment(data);
10400
10404
  if (fragment) {
10401
10405
  const isContinue = insertDataByInvalidType(editor, fragment);
@@ -10403,7 +10407,7 @@ const withInsertDataByInvalidType = (editor) => {
10403
10407
  return true;
10404
10408
  }
10405
10409
  }
10406
- return insertFragmentData(data);
10410
+ return customInsertFragmentData(data);
10407
10411
  };
10408
10412
  return editor;
10409
10413
  };
@@ -10425,7 +10429,7 @@ const withMoveSelection = (editor) => {
10425
10429
  editor.onClick = (event) => {
10426
10430
  const domSelection = window.getSelection();
10427
10431
  if (domSelection && !domSelection.isCollapsed && event.detail >= 2 && editor.selection) {
10428
- const slateSelection = AngularEditor.toSlateRange(editor, domSelection);
10432
+ const slateSelection = AngularEditor.toSlateRange(editor, domSelection, { exactMatch: false, suppressThrow: false });
10429
10433
  const isNextStart = slateSelection.focus.offset === 0;
10430
10434
  if (Range.isExpanded(slateSelection) && Range.isForward(slateSelection) && isNextStart) {
10431
10435
  const beforePoint = Editor.before(editor, slateSelection.focus);
@@ -10655,24 +10659,24 @@ const createResetTypePlugin = createPluginFactory({
10655
10659
  });
10656
10660
 
10657
10661
  const withDeserializeHTML = (editor) => {
10658
- const { insertFragmentData } = editor;
10659
- editor.insertFragmentData = async (data) => {
10662
+ const { customInsertFragmentData } = editor;
10663
+ editor.customInsertFragmentData = async (data) => {
10660
10664
  const clipboardData = await getClipboardData(data);
10661
10665
  if (!clipboardData?.elements && clipboardData?.html) {
10662
10666
  const htmlDom = new DOMParser().parseFromString(clipboardData?.html, 'text/html');
10663
10667
  const fragment = TheiaConverter.convertToTheia(Array.from(htmlDom.body.children));
10664
10668
  // 识别粘贴的 HTML 只有纯链接, 跳至 link
10665
10669
  if (fragment.length === 1 && fragment.every(block => isUrl(block?.children?.[0]?.['text']))) {
10666
- return insertFragmentData(data);
10670
+ return customInsertFragmentData(data);
10667
10671
  }
10668
10672
  // 无法识别HTML内容时后退一下:识别纯文本
10669
10673
  if (fragment.every(block => block.type === ElementKinds.paragraph && isLogicEmptyParagraphElement(editor, block))) {
10670
- return insertFragmentData(data);
10674
+ return customInsertFragmentData(data);
10671
10675
  }
10672
10676
  // 识出纯图片并且粘贴板中存在文件则不进行处理, hook 直接右键复制图片的场景,流转到上传图片流程
10673
10677
  // 后续需要做识别html图片后自动上传处理
10674
10678
  if (fragment.length === 1 && fragment[0].type === ElementKinds.image && data.files.length > 0) {
10675
- return insertFragmentData(data);
10679
+ return customInsertFragmentData(data);
10676
10680
  }
10677
10681
  // 过滤 text 节点的 color/background-color 属性
10678
10682
  fragment.forEach(node => filterTextFormat(node));
@@ -10696,7 +10700,7 @@ const withDeserializeHTML = (editor) => {
10696
10700
  Transforms.insertFragment(editor, fragment);
10697
10701
  return true;
10698
10702
  }
10699
- return insertFragmentData(data);
10703
+ return customInsertFragmentData(data);
10700
10704
  };
10701
10705
  return editor;
10702
10706
  };
@@ -11585,11 +11589,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImpo
11585
11589
  }] } });
11586
11590
 
11587
11591
  const withImage = (editor) => {
11588
- const { insertFragmentData, isVoid, renderElement, isBlockCard, mousedown } = editor;
11592
+ const { customInsertFragmentData, isVoid, renderElement, isBlockCard, mousedown } = editor;
11589
11593
  editor.isVoid = (element) => {
11590
11594
  return element.type === ElementKinds.image || isVoid(element);
11591
11595
  };
11592
- editor.insertFragmentData = async (data) => {
11596
+ editor.customInsertFragmentData = async (data) => {
11593
11597
  const clipboardData = await getClipboardData(data);
11594
11598
  if (clipboardData?.files?.length) {
11595
11599
  const imageFiles = [];
@@ -11604,7 +11608,7 @@ const withImage = (editor) => {
11604
11608
  return true;
11605
11609
  }
11606
11610
  }
11607
- return insertFragmentData(data);
11611
+ return customInsertFragmentData(data);
11608
11612
  };
11609
11613
  editor.renderElement = (element) => {
11610
11614
  if (element.type === ElementKinds.image) {
@@ -12152,7 +12156,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImpo
12152
12156
  }] } });
12153
12157
 
12154
12158
  const withLink = (editor) => {
12155
- const { insertText, isInline, insertFragmentData, renderElement } = editor;
12159
+ const { insertText, isInline, customInsertFragmentData, renderElement } = editor;
12156
12160
  editor.isInline = (element) => {
12157
12161
  return element.type === ElementKinds.link ? true : isInline(element);
12158
12162
  };
@@ -12165,7 +12169,7 @@ const withLink = (editor) => {
12165
12169
  insertText(text);
12166
12170
  }
12167
12171
  };
12168
- editor.insertFragmentData = async (data) => {
12172
+ editor.customInsertFragmentData = async (data) => {
12169
12173
  const clipboardData = await getClipboardData(data);
12170
12174
  const text = clipboardData?.text;
12171
12175
  if (!clipboardData?.elements && text && isUrl(text)) {
@@ -12186,7 +12190,7 @@ const withLink = (editor) => {
12186
12190
  return true;
12187
12191
  }
12188
12192
  }
12189
- return insertFragmentData(data);
12193
+ return customInsertFragmentData(data);
12190
12194
  };
12191
12195
  editor.renderElement = (element) => {
12192
12196
  if (element.type === ElementKinds.link) {
@@ -12943,7 +12947,7 @@ const unwrapList = (editor) => {
12943
12947
  };
12944
12948
 
12945
12949
  const withList = (editor) => {
12946
- const { insertBreak, deleteBackward, onKeydown, insertFragmentData, setFragmentData, renderElement } = editor;
12950
+ const { insertBreak, deleteBackward, onKeydown, customInsertFragmentData, setFragmentData, renderElement } = editor;
12947
12951
  const validLiChildrenTypes = getPluginOptions(editor, PluginKeys.list)?.validLiChildrenTypes ?? [];
12948
12952
  const resetBlockTypesListRule = {
12949
12953
  types: [ElementKinds.listItem],
@@ -13110,7 +13114,7 @@ const withList = (editor) => {
13110
13114
  }
13111
13115
  deleteBackward(unit);
13112
13116
  };
13113
- editor.insertFragmentData = async (data) => {
13117
+ editor.customInsertFragmentData = async (data) => {
13114
13118
  const fragment = await extractFragment(data);
13115
13119
  if (fragment) {
13116
13120
  const aboveEntry = Editor.above(editor, {
@@ -13126,7 +13130,7 @@ const withList = (editor) => {
13126
13130
  return true;
13127
13131
  }
13128
13132
  }
13129
- return insertFragmentData(data);
13133
+ return customInsertFragmentData(data);
13130
13134
  };
13131
13135
  editor.onKeydown = (event) => {
13132
13136
  const isContinue = !onKeyDownList(event, editor);
@@ -14099,7 +14103,7 @@ class TableStore {
14099
14103
  }
14100
14104
  selectCellOngoing(cell, editor, event) {
14101
14105
  const pos = createTablePosition(editor);
14102
- if (AngularEditor.isReadonly(editor) || !editor.selection || !pos?.table) {
14106
+ if (AngularEditor.isReadOnly(editor) || !editor.selection || !pos?.table) {
14103
14107
  return;
14104
14108
  }
14105
14109
  let isChanged;
@@ -14263,7 +14267,7 @@ class TableStore {
14263
14267
  * @param cellElement 单元格元素
14264
14268
  */
14265
14269
  setAreaSelectionCells(cellElement, event) {
14266
- if (AngularEditor.isReadonly(this.editor) || !this.editor.selection || !this.isPrepareSelecting) {
14270
+ if (AngularEditor.isReadOnly(this.editor) || !this.editor.selection || !this.isPrepareSelecting) {
14267
14271
  return;
14268
14272
  }
14269
14273
  const currentCellPath = AngularEditor.findPath(this.editor, cellElement);
@@ -15002,7 +15006,7 @@ class TableService {
15002
15006
  * @param editor 编辑器对象
15003
15007
  */
15004
15008
  selectStartPreventDefault(e) {
15005
- const isReadonly = AngularEditor.isReadonly(this.tableStore.editor);
15009
+ const isReadonly = AngularEditor.isReadOnly(this.tableStore.editor);
15006
15010
  const cells = this.tableStore.getSelectedCellPositions();
15007
15011
  if (!isReadonly && e.shiftKey && cells.length > 1) {
15008
15012
  e.preventDefault();
@@ -16881,7 +16885,7 @@ const normalizeTable = (table) => {
16881
16885
  };
16882
16886
 
16883
16887
  const withTable = (editor) => {
16884
- const { deleteBackward, deleteForward, onKeydown, setFragmentData, insertFragmentData, normalizeNode, isBlockCard, renderElement, deleteCutData, isContainer, onChange, onClick, mousedown } = editor;
16888
+ const { deleteBackward, deleteForward, onKeydown, setFragmentData, customInsertFragmentData, normalizeNode, isBlockCard, renderElement, deleteCutData, isContainer, onChange, onClick, mousedown } = editor;
16885
16889
  editor.deleteBackward = unit => {
16886
16890
  const opts = new TableOptions();
16887
16891
  if (!isSelectionInTable(opts, editor)) {
@@ -16919,7 +16923,7 @@ const withTable = (editor) => {
16919
16923
  const isMergedCell = isSelectedCellMerged(editor);
16920
16924
  const domSelection = window.getSelection();
16921
16925
  if (domSelection && !domSelection.isCollapsed && editor.selection) {
16922
- const slateSelection = AngularEditor.toSlateRange(editor, domSelection);
16926
+ const slateSelection = AngularEditor.toSlateRange(editor, domSelection, { exactMatch: false, suppressThrow: false });
16923
16927
  const opts = new TableOptions();
16924
16928
  const startPosition = TablePosition.create(opts, editor, slateSelection.anchor.path);
16925
16929
  const endPosition = TablePosition.create(opts, editor, slateSelection.focus.path);
@@ -17134,7 +17138,7 @@ const withTable = (editor) => {
17134
17138
  }
17135
17139
  setFragmentData(data, originEvent);
17136
17140
  };
17137
- editor.insertFragmentData = async (data) => {
17141
+ editor.customInsertFragmentData = async (data) => {
17138
17142
  const fragment = await extractFragment(data);
17139
17143
  if (fragment) {
17140
17144
  const opts = new TableOptions();
@@ -17207,9 +17211,9 @@ const withTable = (editor) => {
17207
17211
  });
17208
17212
  });
17209
17213
  }
17210
- return insertFragmentData(data);
17214
+ return customInsertFragmentData(data);
17211
17215
  }
17212
- return insertFragmentData(data);
17216
+ return customInsertFragmentData(data);
17213
17217
  };
17214
17218
  editor.normalizeNode = ([node, path]) => {
17215
17219
  if (Element.isElement(node) && node.type === ElementKinds.table) {