@worktile/theia 19.2.0-next.2 → 19.2.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.
@@ -8,4 +8,4 @@ export declare const DEFAULT_SCROLL_CONTAINER = ".the-editable-container";
8
8
  export declare const ELEMENT_UNIQUE_ID = "key";
9
9
  export declare const ZERO_WIDTH_CHAR = "\u200B";
10
10
  export declare const QUICK_INSERT_HOTKEY = "/";
11
- export declare const HIDDEN_CLASS = "slate-block-hidden";
11
+ export declare const BLOCK_HIDDEN_CLASS = "slate-block-hidden";
@@ -62,7 +62,7 @@ const DEFAULT_SCROLL_CONTAINER = '.the-editable-container';
62
62
  const ELEMENT_UNIQUE_ID = 'key';
63
63
  const ZERO_WIDTH_CHAR = '\u200B';
64
64
  const QUICK_INSERT_HOTKEY = '/';
65
- const HIDDEN_CLASS = 'slate-block-hidden';
65
+ const BLOCK_HIDDEN_CLASS = 'slate-block-hidden';
66
66
 
67
67
  var ElementKinds;
68
68
  (function (ElementKinds) {
@@ -1911,6 +1911,86 @@ const DefaultElementOptions = [
1911
1911
  }
1912
1912
  ];
1913
1913
 
1914
+ /** Converts CSS pixel values to numbers, eg "123px" to 123. Returns NaN for non pixel values. */
1915
+ function coercePixelsFromCssValue(cssValue) {
1916
+ const match = cssValue.match(/(\d+(\.\d+)?)px/);
1917
+ if (match) {
1918
+ return Number(match[1]);
1919
+ }
1920
+ }
1921
+ function getElementWidth(element) {
1922
+ // Optimization: Check style.width first as we probably set it already before reading
1923
+ // offsetWidth which triggers layout.
1924
+ return coercePixelsFromCssValue(element.style.width) || element.getBoundingClientRect().width;
1925
+ }
1926
+ function getElementHeight(element) {
1927
+ return coercePixelsFromCssValue(element.style.height) || element.getBoundingClientRect().height;
1928
+ }
1929
+ function getColsTotalWidth(cols) {
1930
+ return cols.reduce((total, col) => {
1931
+ return total + getElementWidth(col);
1932
+ }, 0);
1933
+ }
1934
+ function getRowsTotalHeight(rows) {
1935
+ return rows.reduce((total, row) => {
1936
+ return total + getElementHeight(row);
1937
+ }, 0);
1938
+ }
1939
+ function useElementStyle(el, element) {
1940
+ if (element.align) {
1941
+ el.style.textAlign = element.align || Alignment.left;
1942
+ }
1943
+ else if (el.style.textAlign) {
1944
+ el.style.removeProperty('text-align');
1945
+ }
1946
+ if (element.textIndent) {
1947
+ el.style.textIndent = element.textIndent + 'em';
1948
+ }
1949
+ else if (el.style.textIndent) {
1950
+ el.style.removeProperty('text-indent');
1951
+ }
1952
+ if (element.verticalAlign) {
1953
+ el.style.verticalAlign = element.verticalAlign;
1954
+ }
1955
+ else if (el.style.verticalAlign) {
1956
+ el.style.removeProperty('vertical-align');
1957
+ }
1958
+ }
1959
+ function getElementClassByPrefix(el, prefix) {
1960
+ let matchClass = null;
1961
+ el.classList.forEach((value, key) => {
1962
+ if (value.includes(prefix)) {
1963
+ matchClass = value;
1964
+ }
1965
+ });
1966
+ return matchClass;
1967
+ }
1968
+ function toggleHeadingRelatedElement(editor, element, isVisible) {
1969
+ const targetDom = NODE_TO_ELEMENT.get(element);
1970
+ if (!targetDom) {
1971
+ return;
1972
+ }
1973
+ const isBlockCard = editor.isBlockCard(element);
1974
+ if (isBlockCard) {
1975
+ const className = `slate-block-card`;
1976
+ const blockCardDom = targetDom.closest(`.${className}`);
1977
+ if (isVisible) {
1978
+ blockCardDom?.classList.contains(BLOCK_HIDDEN_CLASS) && blockCardDom?.classList.remove(BLOCK_HIDDEN_CLASS);
1979
+ }
1980
+ else {
1981
+ blockCardDom?.classList.add(BLOCK_HIDDEN_CLASS);
1982
+ }
1983
+ }
1984
+ else {
1985
+ if (isVisible) {
1986
+ targetDom.classList.contains(BLOCK_HIDDEN_CLASS) && targetDom.classList.remove(BLOCK_HIDDEN_CLASS);
1987
+ }
1988
+ else {
1989
+ targetDom.classList.add(BLOCK_HIDDEN_CLASS);
1990
+ }
1991
+ }
1992
+ }
1993
+
1914
1994
  class TheBaseElement extends BaseElementComponent {
1915
1995
  onContextChange() {
1916
1996
  super.onContextChange();
@@ -1935,8 +2015,16 @@ class TheBaseElement extends BaseElementComponent {
1935
2015
  this.nativeElement.classList.add(`slate-element-${this.element.type}`, blockClass);
1936
2016
  if (this.editor) {
1937
2017
  const isVisible = this.editor.isVisible(this.element);
2018
+ const isBlockCard = this.editor.isBlockCard(this.element);
1938
2019
  if (!isVisible) {
1939
- this.nativeElement.classList.add(HIDDEN_CLASS);
2020
+ if (isBlockCard) {
2021
+ setTimeout(() => {
2022
+ toggleHeadingRelatedElement(this.editor, this.element, isVisible);
2023
+ }, 0);
2024
+ }
2025
+ else {
2026
+ toggleHeadingRelatedElement(this.editor, this.element, isVisible);
2027
+ }
1940
2028
  }
1941
2029
  }
1942
2030
  }
@@ -1995,61 +2083,6 @@ function dataSerializing(mode, value) {
1995
2083
  return value;
1996
2084
  }
1997
2085
 
1998
- /** Converts CSS pixel values to numbers, eg "123px" to 123. Returns NaN for non pixel values. */
1999
- function coercePixelsFromCssValue(cssValue) {
2000
- const match = cssValue.match(/(\d+(\.\d+)?)px/);
2001
- if (match) {
2002
- return Number(match[1]);
2003
- }
2004
- }
2005
- function getElementWidth(element) {
2006
- // Optimization: Check style.width first as we probably set it already before reading
2007
- // offsetWidth which triggers layout.
2008
- return coercePixelsFromCssValue(element.style.width) || element.getBoundingClientRect().width;
2009
- }
2010
- function getElementHeight(element) {
2011
- return coercePixelsFromCssValue(element.style.height) || element.getBoundingClientRect().height;
2012
- }
2013
- function getColsTotalWidth(cols) {
2014
- return cols.reduce((total, col) => {
2015
- return total + getElementWidth(col);
2016
- }, 0);
2017
- }
2018
- function getRowsTotalHeight(rows) {
2019
- return rows.reduce((total, row) => {
2020
- return total + getElementHeight(row);
2021
- }, 0);
2022
- }
2023
- function useElementStyle(el, element) {
2024
- if (element.align) {
2025
- el.style.textAlign = element.align || Alignment.left;
2026
- }
2027
- else if (el.style.textAlign) {
2028
- el.style.removeProperty('text-align');
2029
- }
2030
- if (element.textIndent) {
2031
- el.style.textIndent = element.textIndent + 'em';
2032
- }
2033
- else if (el.style.textIndent) {
2034
- el.style.removeProperty('text-indent');
2035
- }
2036
- if (element.verticalAlign) {
2037
- el.style.verticalAlign = element.verticalAlign;
2038
- }
2039
- else if (el.style.verticalAlign) {
2040
- el.style.removeProperty('vertical-align');
2041
- }
2042
- }
2043
- function getElementClassByPrefix(el, prefix) {
2044
- let matchClass = null;
2045
- el.classList.forEach((value, key) => {
2046
- if (value.includes(prefix)) {
2047
- matchClass = value;
2048
- }
2049
- });
2050
- return matchClass;
2051
- }
2052
-
2053
2086
  const THE_EDITOR_UUID = new WeakMap();
2054
2087
  const THE_EDITOR_CONVERSION_HINT_REF = new WeakMap();
2055
2088
  const THE_PLUGIN_MENU_REF = new WeakMap();
@@ -8200,16 +8233,7 @@ class TheHeadingElement extends TheBaseElement {
8200
8233
  setTimeout(() => {
8201
8234
  followElements.forEach(el => {
8202
8235
  const isVisible = this.editor.isVisible(el);
8203
- const targetDom = NODE_TO_ELEMENT.get(el);
8204
- if (!targetDom) {
8205
- return;
8206
- }
8207
- if (isVisible) {
8208
- targetDom.classList.remove(HIDDEN_CLASS);
8209
- }
8210
- else {
8211
- targetDom.classList.add(HIDDEN_CLASS);
8212
- }
8236
+ toggleHeadingRelatedElement(this.editor, el, isVisible);
8213
8237
  });
8214
8238
  }, 0);
8215
8239
  }
@@ -8222,10 +8246,7 @@ class TheHeadingElement extends TheBaseElement {
8222
8246
  const followElements = getFollowElements(this.editor, this.element);
8223
8247
  // 处理删除后撤销场景
8224
8248
  followElements.forEach(el => {
8225
- const targetDom = NODE_TO_ELEMENT.get(el);
8226
- if (targetDom) {
8227
- targetDom.classList.add(HIDDEN_CLASS);
8228
- }
8249
+ toggleHeadingRelatedElement(this.editor, el, false);
8229
8250
  });
8230
8251
  }
8231
8252
  }
@@ -10814,8 +10835,7 @@ const cleanHeadingEffect = (editor, path) => {
10814
10835
  const followedElements = getFollowElements(editor, headingElement);
10815
10836
  if (headingElement.isCollapsed) {
10816
10837
  followedElements.forEach(el => {
10817
- const targetDom = AngularEditor.toDOMNode(editor, el);
10818
- targetDom.classList.contains(HIDDEN_CLASS) && targetDom.classList.remove(HIDDEN_CLASS);
10838
+ toggleHeadingRelatedElement(editor, el, true);
10819
10839
  });
10820
10840
  }
10821
10841
  };
@@ -18348,5 +18368,5 @@ const withTestPlugin = (plugins, initValue) => {
18348
18368
  * Generated bundle index. Do not edit.
18349
18369
  */
18350
18370
 
18351
- export { ALIGN_BLOCK_TYPES, A_TAG_REL_ATTR, AlignEditor, Alignment, BLOCK_DELETE_BACKWARD_TYPES, BasicTest, BlockquoteEditor, CLIPBOARD_FORMAT_KEY, CODEMIRROR_PADDING_TOP, CODE_MODES, CONTAINER_BLOCKS, CONTROL_KEY, CodeEditor, ColorEditor, ColumnResizeNotifierSource, ColumnResizingStore, DEFAULT_LANGUAGE, DEFAULT_SCROLL_CONTAINER, DISABLED_OPERATE_TYPES, DataTransferFaker, DefaultElementOptions, DefaultGlobalToolbarDefinition, DefaultInlineToolbarDefinition, DropdownMode, ELEMENT_UNIQUE_ID, EditorPresetConfigFactoryMock, ElementKinds, ErrorCodes, FontSizeTypes, FontSizes, HEADING_TYPES, HIDDEN_CLASS, HeaderLevelMap, HeadingEditor, HoveredCellInfo, HrEditor, IS_MAC, ImageEditor, IndentEditor, Indents, InlineCodeEditor, LINK_DEFAULT_TEXT, LIST_BLOCK_TYPES, LOWEST_TEXT_CONTAINER_TYPES, LayoutTypes, LinkEditor, ListEditor, MarkEditor, MarkProps, MarkTypes, MentionEditor, PICTURE_ACCEPTED_UPLOAD_MIME, PICTURE_ACCEPTED_UPLOAD_SIZE, PluginKeys, PluginMenuIcons, PluginMenuSvgs, Position, QUICK_INSERT_HOTKEY, QuickInsertEditor, ResizeRef, SLA_TABLE_CELL_SELECTOR, SLA_TABLE_SELECTOR, STANDARD_HEADING_TYPES, ScrollDirection, SpecialBackgroundColor, TAB_SPACE, THE_EDITOR_BG_COLOR, THE_EDITOR_COLOR, THE_EDITOR_CONVERSION_HINT_REF, THE_EDITOR_ORIGIN_ANCHOR, THE_EDITOR_POPOVER_REF, THE_EDITOR_PREVIOUS_SELECTION, THE_EDITOR_UUID, THE_I18N_DE_DE, THE_I18N_EN_US, THE_I18N_JA_JP, THE_I18N_LOCALE_ID, THE_I18N_RU_RU, THE_I18N_ZH_HANS, THE_I18N_ZH_HANT, THE_IMAGE_SERVICE_TOKEN, THE_LISTBOX_PARENT_GROUP_TOKEN, THE_LISTBOX_PARENT_OPTION_TOKEN, THE_LISTBOX_TOKEN, THE_MODE_PROVIDER, THE_MODE_TOKEN, THE_PLUGIN_MENU_REF, THE_PRESET_CONFIG_TOKEN, TableCellEventDispatcher, TableEditor, TableHeaderBackgroundColor, TablePosition, TheBaseElement, TheBaseSuggestion, TheBaseToolbarDropdown, TheBaseToolbarItem, TheColumnResizeDirective, TheColumnResizeOverlayHandle, TheContextMenu, TheContextService, TheConversionHint, TheDataMode, TheDefaultElement, TheEditor, TheEditorComponent, TheEditorModule, TheI18nService, TheImage, TheInlineToolbar, TheListboxDirective, TheListboxGroupDirective, TheListboxOptionDirective, TheLocaleType, TheMode, TheModeConfig, ThePluginMenu, ThePluginMenuComponent, ThePluginMenuItemType, ThePreventDefaultDirective, index$1 as TheQueries, TheQuickInsert, TheTableSelect, TheTemplate, TheText, TheToolbarComponent, TheToolbarDropdown, TheToolbarGroup, TheToolbarGroupToken, TheToolbarItem, TheToolbarService, index as TheTransforms, TodoItemEditor, ToolbarActionTypes, ToolbarAlignment, ToolbarItemType, ToolbarMoreGroup, VOID_BLOCK_TYPES, VerticalAlignEditor, VerticalAlignment, ZERO_WIDTH_CHAR, autoFocus, base64toBlob, bottomLeftPosition, buildPluginMenu, buildPluginMenuItemMap, buildQuickInsertMenus, calcPrintColumnWidth, calcSpanForColumn, calcSpanForRow, calculateHeaderRowHeight, calculateRowControls, coercePixelsFromCssValue, combinePlugins, copyNode, createCell, createEmptyContent, createEmptyParagraph, createMentionPlugin, createPluginFactory, createRow, createTable, createTablePosition, createTest1Plugin, createTestPlugin, createToolbar, createVerticalAlignPlugin, customPluginMock, customPluginMockKey, dataDeserialize, dataSerializing, deDeLocale, deleteElementKey, enUsLocale, errorImageUrlMock, expandPreviousHeadings, extractFragment, filterTextFormat, fixBlockWithoutParagraph, fixBlockWithoutText, flattenDeepPlugins, getCellPositionsFromRange, getCollapsedStandardHeadingAbove, getColsTotalWidth, getColumnsWidth, getDirtyElements, getEditorScrollContainer, getEditorUUID, getElementClassByPrefix, getElementHeight, getElementWidth, getEndBlock, getFollowElements, getGridColumns, getMode, getNextCell, getOriginCell, getPlugin, getPluginOptions, getPlugins, getPreviousRelatedHeadingElements, getRowsTotalHeight, getSelectCellNode, getSelectedCellPositions, getStartBlock, getTableByCell, getTableByRow, getTheDefaultPluginMenu, getToolbarClass, hasHeaderRow, headingOptions, htmlToTheia, idCreator, inValidTypes, initializeDefaultMenuIcons, injectTranslations, insertDataByInvalidType, internalPlugins, isCleanEmptyParagraph, isColorIndicator, isColorInput, isColorPanel, isDirectionKeydown, isHeadingElement, isInside, isMobileMode, isPrintMode, isPureEmptyParagraph, isRangeInTable, isRectangularInTableCells, isSelectedAllCell, isSelectionInTable, isStandardHeadingElement, isStandardHeadingElementByType, isUrl, isVirtualKey, jaJpLocale, matchOptions, mergeArray, mergeDeepPlugins, mergeElementOptions, mergeOptions, nestedStructureByKey, normalizeValue, originOptions, plainToTheia, pluginKey, pluginKey1, pluginsByKey, reSelection, recursionNodes, refocus, ruRuLocale, scrollIntoView, setClipboardDataByDom, setEditorUUID, theTethysIconRegistryFaker, topLeftPosition, uniqueCellPosition, updatePopoverPosition, useElementStyle, withMention, withTestPlugin, withTheia, zhHansLocale, zhHantLocale };
18371
+ export { ALIGN_BLOCK_TYPES, A_TAG_REL_ATTR, AlignEditor, Alignment, BLOCK_DELETE_BACKWARD_TYPES, BLOCK_HIDDEN_CLASS, BasicTest, BlockquoteEditor, CLIPBOARD_FORMAT_KEY, CODEMIRROR_PADDING_TOP, CODE_MODES, CONTAINER_BLOCKS, CONTROL_KEY, CodeEditor, ColorEditor, ColumnResizeNotifierSource, ColumnResizingStore, DEFAULT_LANGUAGE, DEFAULT_SCROLL_CONTAINER, DISABLED_OPERATE_TYPES, DataTransferFaker, DefaultElementOptions, DefaultGlobalToolbarDefinition, DefaultInlineToolbarDefinition, DropdownMode, ELEMENT_UNIQUE_ID, EditorPresetConfigFactoryMock, ElementKinds, ErrorCodes, FontSizeTypes, FontSizes, HEADING_TYPES, HeaderLevelMap, HeadingEditor, HoveredCellInfo, HrEditor, IS_MAC, ImageEditor, IndentEditor, Indents, InlineCodeEditor, LINK_DEFAULT_TEXT, LIST_BLOCK_TYPES, LOWEST_TEXT_CONTAINER_TYPES, LayoutTypes, LinkEditor, ListEditor, MarkEditor, MarkProps, MarkTypes, MentionEditor, PICTURE_ACCEPTED_UPLOAD_MIME, PICTURE_ACCEPTED_UPLOAD_SIZE, PluginKeys, PluginMenuIcons, PluginMenuSvgs, Position, QUICK_INSERT_HOTKEY, QuickInsertEditor, ResizeRef, SLA_TABLE_CELL_SELECTOR, SLA_TABLE_SELECTOR, STANDARD_HEADING_TYPES, ScrollDirection, SpecialBackgroundColor, TAB_SPACE, THE_EDITOR_BG_COLOR, THE_EDITOR_COLOR, THE_EDITOR_CONVERSION_HINT_REF, THE_EDITOR_ORIGIN_ANCHOR, THE_EDITOR_POPOVER_REF, THE_EDITOR_PREVIOUS_SELECTION, THE_EDITOR_UUID, THE_I18N_DE_DE, THE_I18N_EN_US, THE_I18N_JA_JP, THE_I18N_LOCALE_ID, THE_I18N_RU_RU, THE_I18N_ZH_HANS, THE_I18N_ZH_HANT, THE_IMAGE_SERVICE_TOKEN, THE_LISTBOX_PARENT_GROUP_TOKEN, THE_LISTBOX_PARENT_OPTION_TOKEN, THE_LISTBOX_TOKEN, THE_MODE_PROVIDER, THE_MODE_TOKEN, THE_PLUGIN_MENU_REF, THE_PRESET_CONFIG_TOKEN, TableCellEventDispatcher, TableEditor, TableHeaderBackgroundColor, TablePosition, TheBaseElement, TheBaseSuggestion, TheBaseToolbarDropdown, TheBaseToolbarItem, TheColumnResizeDirective, TheColumnResizeOverlayHandle, TheContextMenu, TheContextService, TheConversionHint, TheDataMode, TheDefaultElement, TheEditor, TheEditorComponent, TheEditorModule, TheI18nService, TheImage, TheInlineToolbar, TheListboxDirective, TheListboxGroupDirective, TheListboxOptionDirective, TheLocaleType, TheMode, TheModeConfig, ThePluginMenu, ThePluginMenuComponent, ThePluginMenuItemType, ThePreventDefaultDirective, index$1 as TheQueries, TheQuickInsert, TheTableSelect, TheTemplate, TheText, TheToolbarComponent, TheToolbarDropdown, TheToolbarGroup, TheToolbarGroupToken, TheToolbarItem, TheToolbarService, index as TheTransforms, TodoItemEditor, ToolbarActionTypes, ToolbarAlignment, ToolbarItemType, ToolbarMoreGroup, VOID_BLOCK_TYPES, VerticalAlignEditor, VerticalAlignment, ZERO_WIDTH_CHAR, autoFocus, base64toBlob, bottomLeftPosition, buildPluginMenu, buildPluginMenuItemMap, buildQuickInsertMenus, calcPrintColumnWidth, calcSpanForColumn, calcSpanForRow, calculateHeaderRowHeight, calculateRowControls, coercePixelsFromCssValue, combinePlugins, copyNode, createCell, createEmptyContent, createEmptyParagraph, createMentionPlugin, createPluginFactory, createRow, createTable, createTablePosition, createTest1Plugin, createTestPlugin, createToolbar, createVerticalAlignPlugin, customPluginMock, customPluginMockKey, dataDeserialize, dataSerializing, deDeLocale, deleteElementKey, enUsLocale, errorImageUrlMock, expandPreviousHeadings, extractFragment, filterTextFormat, fixBlockWithoutParagraph, fixBlockWithoutText, flattenDeepPlugins, getCellPositionsFromRange, getCollapsedStandardHeadingAbove, getColsTotalWidth, getColumnsWidth, getDirtyElements, getEditorScrollContainer, getEditorUUID, getElementClassByPrefix, getElementHeight, getElementWidth, getEndBlock, getFollowElements, getGridColumns, getMode, getNextCell, getOriginCell, getPlugin, getPluginOptions, getPlugins, getPreviousRelatedHeadingElements, getRowsTotalHeight, getSelectCellNode, getSelectedCellPositions, getStartBlock, getTableByCell, getTableByRow, getTheDefaultPluginMenu, getToolbarClass, hasHeaderRow, headingOptions, htmlToTheia, idCreator, inValidTypes, initializeDefaultMenuIcons, injectTranslations, insertDataByInvalidType, internalPlugins, isCleanEmptyParagraph, isColorIndicator, isColorInput, isColorPanel, isDirectionKeydown, isHeadingElement, isInside, isMobileMode, isPrintMode, isPureEmptyParagraph, isRangeInTable, isRectangularInTableCells, isSelectedAllCell, isSelectionInTable, isStandardHeadingElement, isStandardHeadingElementByType, isUrl, isVirtualKey, jaJpLocale, matchOptions, mergeArray, mergeDeepPlugins, mergeElementOptions, mergeOptions, nestedStructureByKey, normalizeValue, originOptions, plainToTheia, pluginKey, pluginKey1, pluginsByKey, reSelection, recursionNodes, refocus, ruRuLocale, scrollIntoView, setClipboardDataByDom, setEditorUUID, theTethysIconRegistryFaker, toggleHeadingRelatedElement, topLeftPosition, uniqueCellPosition, updatePopoverPosition, useElementStyle, withMention, withTestPlugin, withTheia, zhHansLocale, zhHantLocale };
18352
18372
  //# sourceMappingURL=worktile-theia.mjs.map