@worktile/theia 16.2.0 → 16.2.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.
@@ -1,11 +1,11 @@
1
1
  import * as i2 from '@angular/common';
2
2
  import { DOCUMENT, CommonModule } from '@angular/common';
3
3
  import * as i0 from '@angular/core';
4
- import { InjectionToken, Component, ChangeDetectionStrategy, HostBinding, Pipe, TemplateRef, ViewChild, Directive, Input, HostListener, ViewContainerRef, Inject, Injectable, ElementRef, ChangeDetectorRef, Optional, SkipSelf, ContentChildren, forwardRef, EventEmitter, Output, ViewChildren, NgModule } from '@angular/core';
4
+ import { Component, ChangeDetectionStrategy, HostBinding, InjectionToken, Pipe, TemplateRef, ViewChild, Directive, Input, HostListener, ViewContainerRef, Inject, Injectable, ElementRef, ChangeDetectorRef, Optional, SkipSelf, ContentChildren, forwardRef, EventEmitter, Output, ViewChildren, NgModule } from '@angular/core';
5
5
  import * as i2$2 from '@angular/forms';
6
6
  import { NG_VALUE_ACCESSOR, FormsModule } from '@angular/forms';
7
7
  import * as i1 from 'slate-angular';
8
- import { AngularEditor, BaseElementComponent, BaseTextComponent, NODE_TO_PARENT, NODE_TO_INDEX, hotkeys, IS_SAFARI, ELEMENT_TO_COMPONENT, hasBlockCard, isCardLeft, FAKE_RIGHT_BLOCK_CARD_OFFSET, getPlainText as getPlainText$1, EDITOR_TO_ELEMENT, defaultScrollSelectionIntoView, withAngular, SlateModule } from 'slate-angular';
8
+ import { BaseElementComponent, BaseTextComponent, NODE_TO_PARENT, NODE_TO_INDEX, AngularEditor, hotkeys, IS_SAFARI, ELEMENT_TO_COMPONENT, hasBlockCard, isCardLeft, FAKE_RIGHT_BLOCK_CARD_OFFSET, getPlainText as getPlainText$1, EDITOR_TO_ELEMENT, defaultScrollSelectionIntoView, withAngular, SlateModule } from 'slate-angular';
9
9
  import { Range, Editor, Span, Path, Node, Element as Element$1, Point, Text, Transforms, Operation, createEditor } from 'slate';
10
10
  import { map, cloneDeep, assign, defaults, groupBy, uniq, isEqual } from 'lodash';
11
11
  import { isObject, isArray, isString, isUndefined } from 'ngx-tethys/util';
@@ -76,37 +76,7 @@ const isGlobalCollapsed = (editor) => {
76
76
  return editor && editor.selection && Range.isCollapsed(editor.selection);
77
77
  };
78
78
 
79
- const TheEditor = {
80
- ...AngularEditor
81
- };
82
- var TheDataMode;
83
- (function (TheDataMode) {
84
- TheDataMode["json"] = "json";
85
- TheDataMode["html"] = "html";
86
- })(TheDataMode || (TheDataMode = {}));
87
- var TheMode;
88
- (function (TheMode) {
89
- TheMode["default"] = "default";
90
- TheMode["print"] = "print";
91
- TheMode["mobile"] = "mobile";
92
- })(TheMode || (TheMode = {}));
93
- class TheModeConfig {
94
- }
95
- const THE_MODE_TOKEN = new InjectionToken('the-mode');
96
- const THE_MODE_PROVIDER = {
97
- provide: THE_MODE_TOKEN,
98
- useValue: {
99
- mode: TheMode.default
100
- }
101
- };
102
-
103
79
  class TheBaseElementComponent extends BaseElementComponent {
104
- get isMobileMode() {
105
- return this.modeConfig && this.modeConfig.mode === TheMode.mobile;
106
- }
107
- get isPrintMode() {
108
- return this.modeConfig && this.modeConfig.mode === TheMode.print;
109
- }
110
80
  onContextChange() {
111
81
  super.onContextChange();
112
82
  if (this.selection && this.editor && this.editor.isVoid(this.element)) {
@@ -122,7 +92,6 @@ class TheBaseElementComponent extends BaseElementComponent {
122
92
  this.nativeElement.classList.remove(`slate-selected-element`);
123
93
  this.nativeElement.classList.remove(`slate-focus-element`);
124
94
  }
125
- this.modeConfig = this.editor && this.editor.injector.get(THE_MODE_TOKEN);
126
95
  }
127
96
  ngOnInit() {
128
97
  this.context.attributes['data-slate-key'] = this.context.element.key;
@@ -1686,6 +1655,30 @@ const createPluginFactory = (defaultPlugin) => (override, overrideByKey = {}) =>
1686
1655
  return cloneDeep(defaultPlugin);
1687
1656
  };
1688
1657
 
1658
+ const TheEditor = {
1659
+ ...AngularEditor
1660
+ };
1661
+ var TheDataMode;
1662
+ (function (TheDataMode) {
1663
+ TheDataMode["json"] = "json";
1664
+ TheDataMode["html"] = "html";
1665
+ })(TheDataMode || (TheDataMode = {}));
1666
+ var TheMode;
1667
+ (function (TheMode) {
1668
+ TheMode["default"] = "default";
1669
+ TheMode["print"] = "print";
1670
+ TheMode["mobile"] = "mobile";
1671
+ })(TheMode || (TheMode = {}));
1672
+ class TheModeConfig {
1673
+ }
1674
+ const THE_MODE_TOKEN = new InjectionToken('the-mode');
1675
+ const THE_MODE_PROVIDER = {
1676
+ provide: THE_MODE_TOKEN,
1677
+ useValue: {
1678
+ mode: TheMode.default
1679
+ }
1680
+ };
1681
+
1689
1682
  var ToolbarItemType;
1690
1683
  (function (ToolbarItemType) {
1691
1684
  ToolbarItemType["default"] = "default";
@@ -2270,6 +2263,19 @@ const isColorInput = (element) => {
2270
2263
  return element.closest('.thy-color-inputs');
2271
2264
  };
2272
2265
 
2266
+ const getMode = (editor) => {
2267
+ const modeConfig = editor && editor.injector?.get(THE_MODE_TOKEN);
2268
+ return modeConfig && modeConfig.mode;
2269
+ };
2270
+ const isMobileMode = (editor) => {
2271
+ const mode = getMode(editor);
2272
+ return mode === TheMode.mobile;
2273
+ };
2274
+ const isPrintMode = (editor) => {
2275
+ const mode = getMode(editor);
2276
+ return mode === TheMode.print;
2277
+ };
2278
+
2273
2279
  const toolbarInitialize = (toolbarItems, global = DefaultGlobalToolbarDefinition, inline = DefaultInlineToolbarDefinition) => {
2274
2280
  const toolbarDefinition = {
2275
2281
  global,
@@ -5429,7 +5435,7 @@ const withMention = (editor) => {
5429
5435
  if (text === ' ') {
5430
5436
  MentionEditor.close(editor);
5431
5437
  }
5432
- else {
5438
+ else if (!isMobileMode(editor)) {
5433
5439
  const mentions = getPluginOptions(editor, PluginKeys.mention)?.mentions;
5434
5440
  const currentMention = mentions?.find(m => m?.trigger === text);
5435
5441
  const isDisabledTrigger = currentMention && currentMention.disableTrigger ? currentMention?.disableTrigger(editor) : false;
@@ -6520,6 +6526,11 @@ const TableEditor = {
6520
6526
  setMarks(editor, unsetMarks, cellRange);
6521
6527
  });
6522
6528
  },
6529
+ formatBrush(editor, marks) {
6530
+ return TableEditor.handleSelectedCells(editor, (cellPath, cellRange) => {
6531
+ setMarks(editor, marks, cellRange);
6532
+ });
6533
+ },
6523
6534
  handleSelectedCells(editor, handle) {
6524
6535
  const cells = TableEditor.getSelectedCells(editor);
6525
6536
  if (cells) {
@@ -7150,7 +7161,7 @@ class TheCodeComponent extends TheBaseElementComponent {
7150
7161
  this.overlay = overlay;
7151
7162
  this.startRenderCodemirror = false;
7152
7163
  this.dropdownMode = DropdownMode;
7153
- this.maxHeight = this.isPrintMode ? 0 : 350 - CODEMIRROR_PADDING_TOP * 2;
7164
+ this.maxHeight = isPrintMode(this.editor) ? 0 : 350 - CODEMIRROR_PADDING_TOP * 2;
7154
7165
  this.menus = CODE_MODES.map(item => {
7155
7166
  return { key: item.value, name: item.showName };
7156
7167
  });
@@ -7163,7 +7174,7 @@ class TheCodeComponent extends TheBaseElementComponent {
7163
7174
  readOnly: false,
7164
7175
  autofocus: false,
7165
7176
  lineWiseCopyCut: true,
7166
- lineWrapping: this.isPrintMode,
7177
+ lineWrapping: isPrintMode(this.editor),
7167
7178
  cursorBlinkRate: 500
7168
7179
  };
7169
7180
  this.activeLanguage = this.menus[0];
@@ -7176,7 +7187,7 @@ class TheCodeComponent extends TheBaseElementComponent {
7176
7187
  }
7177
7188
  onContextChange() {
7178
7189
  super.onContextChange();
7179
- if (this.isCollapsedAndNonReadonly && !this.isMobileMode) {
7190
+ if (this.isCollapsedAndNonReadonly && !isMobileMode(this.editor)) {
7180
7191
  this.openToolbar();
7181
7192
  }
7182
7193
  else {
@@ -7317,7 +7328,7 @@ class TheCodeComponent extends TheBaseElementComponent {
7317
7328
  this.options = { ...this.options, lineWrapping: this.element.autoWrap || false };
7318
7329
  }
7319
7330
  useHeight() {
7320
- if (this.element.height && !this.isPrintMode) {
7331
+ if (this.element.height && !isPrintMode(this.editor)) {
7321
7332
  this.resizeHeight = this.element.height;
7322
7333
  this.maxHeight = this.element.height;
7323
7334
  }
@@ -8793,7 +8804,7 @@ class TheImageComponent extends TheBaseElementComponent {
8793
8804
  }
8794
8805
  onContextChange() {
8795
8806
  super.onContextChange();
8796
- if (this.initialized && !this.isMobileMode) {
8807
+ if (this.initialized && !isMobileMode(this.editor)) {
8797
8808
  if (this.isShouldOpen()) {
8798
8809
  this.openLayoutToolbar();
8799
8810
  }
@@ -9488,7 +9499,7 @@ class TheBaseLinkComponent extends TheBaseElementComponent {
9488
9499
  }
9489
9500
  }
9490
9501
  mousedownHandle(event) {
9491
- if (!this.readonly && !this.editor.disabled && !this.isMobileMode) {
9502
+ if (!this.readonly && !this.editor.disabled && !isMobileMode(this.editor)) {
9492
9503
  this.openLinkHover();
9493
9504
  }
9494
9505
  }
@@ -10902,23 +10913,17 @@ const createTrailingNodePlugin = createPluginFactory({
10902
10913
  });
10903
10914
 
10904
10915
  const PaintFormatEditor = {
10905
- formatBrush(editor) {
10906
- const contextService = editor.injector.get(TheContextService);
10907
- const obj = {};
10908
- for (const key of MarkProps) {
10909
- const k = contextService.paintFormatStatus.marks[key];
10910
- obj[key] = k || null;
10911
- }
10916
+ formatBrush(editor, marks) {
10912
10917
  const block = anchorBlock(editor);
10913
10918
  if (block && Range.isCollapsed(editor.selection)) {
10914
10919
  // TODO:: 在撤销时有bug, 临时使用withoutSaving处理
10915
10920
  HistoryEditor.withoutSaving(editor, () => {
10916
10921
  const path = TheEditor.findPath(editor, block);
10917
- setMarks(editor, obj, path);
10922
+ setMarks(editor, marks, path);
10918
10923
  });
10919
10924
  }
10920
10925
  else {
10921
- setMarks(editor, obj);
10926
+ setMarks(editor, marks);
10922
10927
  }
10923
10928
  PaintFormatEditor.cancelFormatBrushStatus(editor);
10924
10929
  },
@@ -10942,7 +10947,16 @@ const PaintFormatEditor = {
10942
10947
  .pipe(filter(event => element.contains(event.target)), take(1))
10943
10948
  .subscribe((event) => {
10944
10949
  if (contextService.paintFormatStatus.isActive) {
10945
- PaintFormatEditor.formatBrush(editor);
10950
+ const contextService = editor.injector.get(TheContextService);
10951
+ const marks = {};
10952
+ for (const key of MarkProps) {
10953
+ marks[key] = contextService.paintFormatStatus.marks[key] || null;
10954
+ }
10955
+ if (TableEditor.formatBrush(editor, marks)) {
10956
+ PaintFormatEditor.cancelFormatBrushStatus(editor);
10957
+ return;
10958
+ }
10959
+ PaintFormatEditor.formatBrush(editor, marks);
10946
10960
  }
10947
10961
  });
10948
10962
  editor.onChange();
@@ -11034,8 +11048,7 @@ const withQuickInsert = (editor) => {
11034
11048
  const { hotkey, allowHotkeyInTypes } = options;
11035
11049
  // 基于插入内容对比,避免 keydown 判断时无法区分中文「、」和英文「/」热键
11036
11050
  if (text === hotkey) {
11037
- const modeConfig = editor?.injector && editor.injector.get(THE_MODE_TOKEN);
11038
- if (modeConfig?.mode !== TheMode.mobile) {
11051
+ if (!isMobileMode(editor)) {
11039
11052
  const types = [...(allowHotkeyInTypes || [])];
11040
11053
  if (isPureEmptyParagraph(editor, block) && allowOpenInsertMenu(editor, types)) {
11041
11054
  setTimeout(() => {
@@ -13123,6 +13136,7 @@ class TheTableComponent extends TheBaseElementComponent {
13123
13136
  }
13124
13137
  ngOnInit() {
13125
13138
  super.ngOnInit();
13139
+ this.isMobileMode = isMobileMode(this.editor);
13126
13140
  this.getColControls();
13127
13141
  this.getIsInTable();
13128
13142
  this.tablePluginOptions = getPluginOptions(this.editor, PluginKeys.table);
@@ -14401,6 +14415,7 @@ class TheTdComponent extends TheBaseElementComponent {
14401
14415
  }
14402
14416
  ngOnInit() {
14403
14417
  super.ngOnInit();
14418
+ this.isMobileMode = isMobileMode(this.editor);
14404
14419
  this.useState();
14405
14420
  }
14406
14421
  ngAfterViewInit() {
@@ -16187,6 +16202,8 @@ class TheEditorComponent extends mixinUnsubscribe(MixinBase) {
16187
16202
  }
16188
16203
  ngOnInit() {
16189
16204
  this.initialize();
16205
+ const modeConfig = this.injector.get(THE_MODE_TOKEN);
16206
+ this.isMobileMode = modeConfig && modeConfig.mode === TheMode.mobile;
16190
16207
  this.initializeEvents();
16191
16208
  initializeDefaultMenuIcons(this.iconRegistry);
16192
16209
  this.theContextService.uploadingStatus$.subscribe(isUploading => {
@@ -16200,8 +16217,6 @@ class TheEditorComponent extends mixinUnsubscribe(MixinBase) {
16200
16217
  }
16201
16218
  });
16202
16219
  this.onErrorHandler();
16203
- const modeConfig = this.injector.get(THE_MODE_TOKEN);
16204
- this.isMobileMode = modeConfig.mode === TheMode.mobile;
16205
16220
  }
16206
16221
  ngOnChanges(changes) {
16207
16222
  const options = changes.theOptions;
@@ -16746,5 +16761,5 @@ const withTestPlugin = (plugins, initValue) => {
16746
16761
  * Generated bundle index. Do not edit.
16747
16762
  */
16748
16763
 
16749
- export { ALIGN_BLOCK_TYPES, A_TAG_REL_ATTR, AlignEditor, Alignment, BLOCK_DELETE_BACKWARD_TYPES, BlockquoteEditor, CLIPBOARD_FORMAT_KEY, CODEMIRROR_PADDING_TOP, CODE_MODES, COMPONENTS, CONTAINER_BLOCKS, CONTROL_KEY, CodeEditor, ColorEditor, 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, 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, isColorIndicator, isColorInput, isColorPanel, isDirectionKeydown, isPureEmptyParagraph, mergeArray, mergeDeepPlugins, mergeElementOptions, mergeOptions, nestedStructureByKey, plainToTheia, pluginsByKey, reSelection, recursionNodes, refocus, scrollIntoView, setEditorUUID, useElementStyle, withMention, withTestPlugin, withTheia };
16764
+ export { ALIGN_BLOCK_TYPES, A_TAG_REL_ATTR, AlignEditor, Alignment, BLOCK_DELETE_BACKWARD_TYPES, BlockquoteEditor, CLIPBOARD_FORMAT_KEY, CODEMIRROR_PADDING_TOP, CODE_MODES, COMPONENTS, CONTAINER_BLOCKS, CONTROL_KEY, CodeEditor, ColorEditor, 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, 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, getMode, getPlugin, getPluginOptions, getPlugins, getRowsTotalHeight, getStartBlock, getToolbarClass, headingOptions, htmlToTheia, idCreator, inValidTypes, initializeDefaultMenuIcons, insertDataByInvalidType, internalPlugins, isCleanEmptyParagraph, isColorIndicator, isColorInput, isColorPanel, isDirectionKeydown, isMobileMode, isPrintMode, isPureEmptyParagraph, mergeArray, mergeDeepPlugins, mergeElementOptions, mergeOptions, nestedStructureByKey, plainToTheia, pluginsByKey, reSelection, recursionNodes, refocus, scrollIntoView, setEditorUUID, useElementStyle, withMention, withTestPlugin, withTheia };
16750
16765
  //# sourceMappingURL=worktile-theia.mjs.map