@univerjs/docs-ui 1.0.0-alpha.3 → 1.0.0-alpha.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 (89) hide show
  1. package/lib/cjs/index.js +418 -318
  2. package/lib/cjs/locale/ar-SA.js +1 -0
  3. package/lib/cjs/locale/ca-ES.js +1 -0
  4. package/lib/cjs/locale/de-DE.js +1 -0
  5. package/lib/cjs/locale/en-US.js +1 -0
  6. package/lib/cjs/locale/es-ES.js +1 -0
  7. package/lib/cjs/locale/fa-IR.js +1 -0
  8. package/lib/cjs/locale/fr-FR.js +1 -0
  9. package/lib/cjs/locale/id-ID.js +1 -0
  10. package/lib/cjs/locale/it-IT.js +1 -0
  11. package/lib/cjs/locale/ja-JP.js +1 -0
  12. package/lib/cjs/locale/ko-KR.js +1 -0
  13. package/lib/cjs/locale/pl-PL.js +1 -0
  14. package/lib/cjs/locale/pt-BR.js +1 -0
  15. package/lib/cjs/locale/ru-RU.js +1 -0
  16. package/lib/cjs/locale/sk-SK.js +1 -0
  17. package/lib/cjs/locale/vi-VN.js +1 -0
  18. package/lib/cjs/locale/zh-CN.js +1 -0
  19. package/lib/cjs/locale/zh-HK.js +1 -0
  20. package/lib/cjs/locale/zh-TW.js +1 -0
  21. package/lib/es/index.js +422 -319
  22. package/lib/es/locale/ar-SA.js +1 -0
  23. package/lib/es/locale/ca-ES.js +1 -0
  24. package/lib/es/locale/de-DE.js +1 -0
  25. package/lib/es/locale/en-US.js +1 -0
  26. package/lib/es/locale/es-ES.js +1 -0
  27. package/lib/es/locale/fa-IR.js +1 -0
  28. package/lib/es/locale/fr-FR.js +1 -0
  29. package/lib/es/locale/id-ID.js +1 -0
  30. package/lib/es/locale/it-IT.js +1 -0
  31. package/lib/es/locale/ja-JP.js +1 -0
  32. package/lib/es/locale/ko-KR.js +1 -0
  33. package/lib/es/locale/pl-PL.js +1 -0
  34. package/lib/es/locale/pt-BR.js +1 -0
  35. package/lib/es/locale/ru-RU.js +1 -0
  36. package/lib/es/locale/sk-SK.js +1 -0
  37. package/lib/es/locale/vi-VN.js +1 -0
  38. package/lib/es/locale/zh-CN.js +1 -0
  39. package/lib/es/locale/zh-HK.js +1 -0
  40. package/lib/es/locale/zh-TW.js +1 -0
  41. package/lib/index.js +422 -319
  42. package/lib/locale/ar-SA.js +1 -0
  43. package/lib/locale/ca-ES.js +1 -0
  44. package/lib/locale/de-DE.js +1 -0
  45. package/lib/locale/en-US.js +1 -0
  46. package/lib/locale/es-ES.js +1 -0
  47. package/lib/locale/fa-IR.js +1 -0
  48. package/lib/locale/fr-FR.js +1 -0
  49. package/lib/locale/id-ID.js +1 -0
  50. package/lib/locale/it-IT.js +1 -0
  51. package/lib/locale/ja-JP.js +1 -0
  52. package/lib/locale/ko-KR.js +1 -0
  53. package/lib/locale/pl-PL.js +1 -0
  54. package/lib/locale/pt-BR.js +1 -0
  55. package/lib/locale/ru-RU.js +1 -0
  56. package/lib/locale/sk-SK.js +1 -0
  57. package/lib/locale/vi-VN.js +1 -0
  58. package/lib/locale/zh-CN.js +1 -0
  59. package/lib/locale/zh-HK.js +1 -0
  60. package/lib/locale/zh-TW.js +1 -0
  61. package/lib/types/commands/commands/clipboard.inner.command.d.ts +1 -2
  62. package/lib/types/index.d.ts +1 -2
  63. package/lib/types/locale/en-US.d.ts +3 -0
  64. package/lib/types/plugin.d.ts +3 -4
  65. package/lib/types/services/float-menu.service.d.ts +1 -4
  66. package/lib/types/services/selection/doc-selection-render.service.d.ts +1 -0
  67. package/lib/types/views/float-toolbar/FloatToolbar.d.ts +1 -0
  68. package/lib/umd/index.js +9 -9
  69. package/lib/umd/locale/ar-SA.js +1 -1
  70. package/lib/umd/locale/ca-ES.js +1 -1
  71. package/lib/umd/locale/de-DE.js +1 -1
  72. package/lib/umd/locale/en-US.js +1 -1
  73. package/lib/umd/locale/es-ES.js +1 -1
  74. package/lib/umd/locale/fa-IR.js +1 -1
  75. package/lib/umd/locale/fr-FR.js +1 -1
  76. package/lib/umd/locale/id-ID.js +1 -1
  77. package/lib/umd/locale/it-IT.js +1 -1
  78. package/lib/umd/locale/ja-JP.js +1 -1
  79. package/lib/umd/locale/ko-KR.js +1 -1
  80. package/lib/umd/locale/pl-PL.js +1 -1
  81. package/lib/umd/locale/pt-BR.js +1 -1
  82. package/lib/umd/locale/ru-RU.js +1 -1
  83. package/lib/umd/locale/sk-SK.js +1 -1
  84. package/lib/umd/locale/vi-VN.js +1 -1
  85. package/lib/umd/locale/zh-CN.js +1 -1
  86. package/lib/umd/locale/zh-HK.js +1 -1
  87. package/lib/umd/locale/zh-TW.js +1 -1
  88. package/package.json +10 -10
  89. package/lib/types/basics/transform-position.d.ts +0 -18
package/lib/index.js CHANGED
@@ -1,13 +1,13 @@
1
- import { BaselineOffset, BlockType, BooleanNumber, BuildTextUtils, COLORS, ColorKit, ColumnSeparatorType, CommandType, CustomRangeType, DEFAULT_DOCUMENT_PARAGRAPH_LINE_SPACING, DEFAULT_DOCUMENT_PARAGRAPH_SPACE_ABOVE, DEFAULT_DOCUMENT_PARAGRAPH_SPACE_BELOW, DEFAULT_EMPTY_DOCUMENT_VALUE, DEFAULT_STYLES, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY, DOCS_NORMAL_EDITOR_UNIT_ID_KEY, DOC_RANGE_TYPE, DashStyleType, DataStreamTreeNodeType, DataStreamTreeTokenType, DeleteDirection, DependentOn, Direction, Disposable, DisposableCollection, DocumentBlockRangeType, DocumentBlockType, DocumentFlavor, DrawingTypeEnum, EDITOR_ACTIVATED, FOCUSING_COMMENT_EDITOR, FOCUSING_COMMON_DRAWINGS, FOCUSING_DOC, FOCUSING_EDITOR_STANDALONE, FOCUSING_UNIVER_EDITOR, HorizontalAlign, ICommandService, IConfigService, IConfirmService, IContextService, ILogService, IUndoRedoService, IUniverInstanceService, ImageSourceType, Inject, Injector, InterceptorManager, JSONX, LRUMap, LocaleService, MODERN_DOCUMENT_DEFAULT_MARGIN, MODERN_DOCUMENT_WIDTH, MemoryCursor, ModernDocumentWidthMode, NAMED_STYLE_MAP, NamedStyleType, ObjectRelativeFromH, ObjectRelativeFromV, Optional, PAGE_SIZE, PAPER_TYPES, PRESET_LIST_TYPE, PageOrientType, Plugin, PositionedObjectLayoutType, PresetListType, QuickListTypeMap, RANGE_DIRECTION, Rectangle, RedoCommand, RxDisposable, SHEET_EDITOR_UNITS, SectionType, SliceBodyType, SpacingRule, TableAlignmentType, TableRowHeightRule, TableSizeType, TableTextWrapType, TextX, TextXActionType, ThemeService, Tools, UndoCommand, UniverInstanceType, UpdateDocsAttributeType, VerticalAlign, checkForSubstrings, containsInteriorInsertionOffset, createIdentifier, createInterceptorKey, createInternalEditorID, createParagraphId, createSectionId, debounce, deepCompare, fromEventSubject, generateRandomId, getBlockRangeInterval, getBodySlice, getBodySliceForTextXAction, getParagraphContentStartOffset, getParagraphContentStartOffsets, getPlainText, getRichTextEditPath, getSectionHeaderFooterReferenceKey, getTableRangeInterval, isCommentEditorID, isInternalEditorID, isSafeUrl, merge, mergeOverrideWithDependencies, normalizeBody, remove, resolveDocumentParagraphStyle, resolveSectionHeaderFooterReference, resolveSectionHeaderFooterReferences, sequenceExecuteAsync, skipParseTagNames, toDisposable, touchDependencies } from "@univerjs/core";
2
- import { CreateHeaderFooterCommand, DeleteTextCommand, DocBlockMoveValidatorService, DocContentInsertService, DocInterceptorService, DocSelectionManagerService, DocSkeletonManagerService, DocStateEmitService, EMBED_DOCS_CUSTOM_BLOCK_DEFAULT_COMPONENT_KEY, HeaderFooterType, IDocStateChangeInterceptorService, InsertTextCommand, RichTextEditingMutation, SetSectionHeaderFooterLinkCommand, SetTextSelectionsOperation, UniverDocsPlugin, UpdateDocumentSectionCommand, UpdateTextCommand, consumeContentInsertRange, createDocsCustomBlockInsertMutation, createDocsCustomBlockRemoveMutation, createEmbedDocsCustomBlockData, createInsertCustomBlockActions, createRemoveCustomBlockActions, createSectionColumnProperties, generateParagraphs, getTopLevelSectionBreaks, isSheetLikeDocsCustomBlockChildType, isSheetLikeDocsCustomBlockChildType as isSheetLikeDocsCustomBlockChildType$1, resolveDocsCustomBlockSize, resolveDocsCustomBlockSize as resolveDocsCustomBlockSize$1, shouldUseInlineTextSelectionForDocsCustomBlockDrawing } from "@univerjs/docs";
1
+ import { BaselineOffset, BlockType, BooleanNumber, BuildTextUtils, COLORS, ColorKit, ColumnSeparatorType, CommandType, CustomRangeType, DEFAULT_DOCUMENT_PARAGRAPH_LINE_SPACING, DEFAULT_DOCUMENT_PARAGRAPH_SPACE_ABOVE, DEFAULT_DOCUMENT_PARAGRAPH_SPACE_BELOW, DEFAULT_EMPTY_DOCUMENT_VALUE, DEFAULT_STYLES, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY, DOCS_NORMAL_EDITOR_UNIT_ID_KEY, DOC_RANGE_TYPE, DashStyleType, DataStreamTreeNodeType, DataStreamTreeTokenType, DeleteDirection, DependentOn, Direction, Disposable, DisposableCollection, DocumentBlockRangeType, DocumentBlockType, DocumentFlavor, DrawingTypeEnum, EDITOR_ACTIVATED, FOCUSING_COMMENT_EDITOR, FOCUSING_COMMON_DRAWINGS, FOCUSING_DOC, FOCUSING_EDITOR_STANDALONE, FOCUSING_UNIVER_EDITOR, HorizontalAlign, ICommandService, IConfigService, IConfirmService, IContextService, ILogService, IUndoRedoService, IUniverInstanceService, ImageSourceType, Inject, Injector, InterceptorManager, JSONX, LRUMap, LocaleService, MODERN_DOCUMENT_DEFAULT_MARGIN, MODERN_DOCUMENT_WIDTH, MemoryCursor, ModernDocumentWidthMode, NAMED_STYLE_MAP, NamedStyleType, ObjectRelativeFromH, ObjectRelativeFromV, Optional, PAGE_SIZE, PAPER_TYPES, PRESET_LIST_TYPE, PageOrientType, Plugin, PositionedObjectLayoutType, PresetListType, QuickListTypeMap, RANGE_DIRECTION, Rectangle, RedoCommand, RxDisposable, SHEET_EDITOR_UNITS, SectionType, SliceBodyType, SpacingRule, TableAlignmentType, TableRowHeightRule, TableSizeType, TableTextWrapType, TextX, TextXActionType, ThemeService, Tools, UndoCommand, UniverInstanceType, UpdateDocsAttributeType, VerticalAlign, checkForSubstrings, containsInteriorInsertionOffset, createIdentifier, createInterceptorKey, createInternalEditorID, createParagraphId, createSectionId, debounce, deepCompare, fromEventSubject, generateRandomId, getBlockRangeInterval, getBodySlice, getBodySliceForTextXAction, getCustomBlockIdsInSelections, getParagraphContentStartOffset, getParagraphContentStartOffsets, getPlainText, getRichTextEditPath, getSectionHeaderFooterReferenceKey, getTableRangeInterval, isCommentEditorID, isInternalEditorID, isSafeUrl, merge, mergeOverrideWithDependencies, normalizeBody, remove, resolveDocumentParagraphStyle, resolveSectionHeaderFooterReference, resolveSectionHeaderFooterReferences, sequenceExecuteAsync, skipParseTagNames, toDisposable, touchDependencies } from "@univerjs/core";
2
+ import { CreateHeaderFooterCommand, DeleteTextCommand, DocBlockMoveValidatorService, DocContentInsertService, DocInterceptorService, DocSelectionManagerService, DocSkeletonManagerService, DocStateEmitService, EMBED_DOCS_CUSTOM_BLOCK_DEFAULT_COMPONENT_KEY, HeaderFooterType, IDocStateChangeInterceptorService, InsertTextCommand, RichTextEditingMutation, SetSectionHeaderFooterLinkCommand, SetTextSelectionsOperation, UniverDocsPlugin, UpdateDocumentSectionCommand, UpdateTextCommand, buildDocTransform, consumeContentInsertRange, createDocsCustomBlockInsertMutation, createDocsCustomBlockRemoveMutation, createEmbedDocsCustomBlockData, createInsertCustomBlockActions, createRemoveCustomBlockActions, createSectionColumnProperties, generateParagraphs, getTopLevelSectionBreaks, isSheetLikeDocsCustomBlockChildType, isSheetLikeDocsCustomBlockChildType as isSheetLikeDocsCustomBlockChildType$1, resolveDocsCustomBlockSize, resolveDocsCustomBlockSize as resolveDocsCustomBlockSize$1, shouldUseInlineTextSelectionForDocsCustomBlockDrawing } from "@univerjs/docs";
3
3
  import { CURSOR_TYPE, DeviceInputEventType, DocBackground, DocumentEditArea, DocumentSkeletonPageType, Documents, GlyphType, IRenderManagerService, Layer, LineType, Liquid, NORMAL_TEXT_SELECTION_PLUGIN_STYLE, PageLayoutType, Path, Rect, RegularPolygon, ScrollBar, ScrollTimer, Shape, TRANSFORM_CHANGE_OBSERVABLE_TYPE, UniverRenderEnginePlugin, Vector2, Viewport, compareDocumentSkeletonNestedPagePathOrder, documentSkeletonLineIterator, documentSkeletonTableIterator, getColor, getDocsTableRenderViewport, getDocumentSkeletonColumnPagePathInfo, getDocumentSkeletonNestedPageOffset, getLastColumn, getNextWheelZoomRatio, getNumberUnitValue, getOffsetRectForDom, getPageFromPath, getParagraphByGlyph, getSystemHighlightColor, getTableIdAndSliceIndex, hasListGlyph, isFirstGlyph, isIndentByGlyph, parseDataStreamToTree, pixelToPt, ptToPixel, pxToNum } from "@univerjs/engine-render";
4
4
  import { BuiltInUIPart, COLOR_PICKER_COMPONENT, COMMON_LABEL_COMPONENT, ComponentManager, ContextMenuGroup, ContextMenuPanel, ContextMenuPosition, CopyCommand, CutCommand, FILE_PNG_CLIPBOARD_MIME_TYPE, FILE__BMP_CLIPBOARD_MIME_TYPE, FILE__JPEG_CLIPBOARD_MIME_TYPE, FILE__WEBP_CLIPBOARD_MIME_TYPE, FONT_FAMILY_COMPONENT, FONT_FAMILY_ITEM_COMPONENT, FONT_SIZE_COMPONENT, FONT_SIZE_LIST, HEADING_ITEM_COMPONENT, HEADING_LIST, HTML_CLIPBOARD_MIME_TYPE, ICanvasPopupService, IClipboardInterfaceService, IContextMenuService, ILayoutService, IMenuManagerService, IShortcutService, ISidebarService, IUIPartsService, IconManager, KeyCode, MenuItemType, MenuManagerPosition, MetaKeys, PLAIN_TEXT_CLIPBOARD_MIME_TYPE, PasteCommand, RectPopup, RibbonInsertGroup, RibbonStartGroup, Slider, ToolbarItem, connectInjector, getMenuHiddenObservable, imageMimeTypeSet, useConfigValue, useDependency, useEvent, useObservable } from "@univerjs/ui";
5
- import { BehaviorSubject, Observable, Subject, animationFrameScheduler, combineLatest, distinctUntilChanged, filter, first, fromEvent, map, merge as merge$1, of, switchMap, take, takeUntil, throttleTime } from "rxjs";
5
+ import { BehaviorSubject, Observable, Subject, animationFrameScheduler, combineLatest, debounceTime, distinctUntilChanged, filter, first, fromEvent, map, merge as merge$1, startWith, switchMap, take, takeUntil, throttleTime } from "rxjs";
6
6
  import { bufferTime, filter as filter$1, map as map$1 } from "rxjs/operators";
7
7
  import { Button, Checkbox, InputNumber, Select, Tooltip, borderClassName, clsx, scrollbarClassName } from "@univerjs/design";
8
8
  import { forwardRef, useCallback, useEffect, useId, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState } from "react";
9
9
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
10
- import { AddImageIcon, AlignTextBothIcon, BoldIcon, CatalogueIcon, CopyDoubleIcon, CutIcon, DeleteColumnDoubleIcon, DeleteIcon, DeleteRowDoubleIcon, DocSettingIcon, FontColorDoubleIcon, GridIcon, H1Icon, H2Icon, H3Icon, H4Icon, H5Icon, HeaderFooterIcon, HorizontallyIcon, InsertDoubleIcon, InsertRowAboveDoubleIcon, InsertRowBelowDoubleIcon, ItalicIcon, KeyboardIcon, LeftInsertColumnDoubleIcon, LeftJustifyingIcon, LineIndentDecreaseIcon, LineIndentIncreaseIcon, MenuIcon, MoreLeftIcon, MoreRightIcon, NoColorDoubleIcon, OrderIcon, PaintBucketDoubleIcon, PasteSpecialDoubleIcon, ReduceDoubleIcon, ReduceIcon, RightInsertColumnDoubleIcon, RightJustifyingIcon, ShapeIcon, StrikethroughIcon, SubscriptIcon, SuperscriptIcon, TextTypeIcon, TodoListDoubleIcon, UnderlineIcon, UnorderIcon } from "@univerjs/icons";
10
+ import { AddImageIcon, AlignTextBothIcon, BoldIcon, CatalogueIcon, CopyDoubleIcon, CutIcon, DeleteColumnDoubleIcon, DeleteIcon, DeleteRowDoubleIcon, DeleteTableDoubleIcon, DocSettingIcon, FontColorDoubleIcon, GridIcon, H1Icon, H2Icon, H3Icon, H4Icon, H5Icon, HeaderFooterIcon, HorizontallyIcon, InsertDoubleIcon, InsertRowAboveDoubleIcon, InsertRowBelowDoubleIcon, ItalicIcon, KeyboardIcon, LeftInsertColumnDoubleIcon, LeftJustifyingIcon, LineIndentDecreaseIcon, LineIndentIncreaseIcon, MenuIcon, MoreLeftIcon, MoreRightIcon, NoColorDoubleIcon, OrderIcon, PaintBucketDoubleIcon, PasteSpecialDoubleIcon, ReduceDoubleIcon, ReduceIcon, RightInsertColumnDoubleIcon, RightJustifyingIcon, ShapeIcon, StrikethroughIcon, SubscriptIcon, SuperscriptIcon, TextTypeIcon, TodoListDoubleIcon, UnderlineIcon, UnorderIcon } from "@univerjs/icons";
11
11
 
12
12
  //#region src/basics/docs-view-key.ts
13
13
  /**
@@ -199,34 +199,6 @@ function getCustomDecorationAtPosition(customDecorations, position) {
199
199
  return customDecorations.filter((customDecoration) => position > customDecoration.startIndex && position <= customDecoration.endIndex);
200
200
  }
201
201
 
202
- //#endregion
203
- //#region src/basics/transform-position.ts
204
- function docDrawingPositionToTransform(position) {
205
- return {
206
- left: position.positionH.posOffset,
207
- top: position.positionV.posOffset,
208
- width: position.size.width,
209
- height: position.size.height
210
- };
211
- }
212
- function transformToDocDrawingPosition(transform, marginLeft = 0, marginTop = 0) {
213
- return {
214
- size: {
215
- width: transform.width,
216
- height: transform.height
217
- },
218
- positionH: {
219
- relativeFrom: ObjectRelativeFromH.MARGIN,
220
- posOffset: (transform.left || 0) - marginLeft
221
- },
222
- positionV: {
223
- relativeFrom: ObjectRelativeFromV.PAGE,
224
- posOffset: (transform.top || 0) - marginTop
225
- },
226
- angle: transform.angle || 0
227
- };
228
- }
229
-
230
202
  //#endregion
231
203
  //#region \0@oxc-project+runtime@0.137.0/helpers/esm/typeof.js
232
204
  function _typeof(o) {
@@ -1098,19 +1070,6 @@ function getCellOffsets(viewModel, range, position) {
1098
1070
 
1099
1071
  //#endregion
1100
1072
  //#region src/commands/commands/clipboard.inner.command.ts
1101
- function getCustomBlockIdsInSelections(body, selections) {
1102
- const customBlockIds = [];
1103
- const { customBlocks = [] } = body;
1104
- for (const selection of selections) {
1105
- const { startOffset, endOffset } = selection;
1106
- if (startOffset == null || endOffset == null) continue;
1107
- for (const customBlock of customBlocks) {
1108
- const { startIndex } = customBlock;
1109
- if (startIndex >= startOffset && startIndex < endOffset) customBlockIds.push(customBlock.blockId);
1110
- }
1111
- }
1112
- return customBlockIds;
1113
- }
1114
1073
  function hasRangeInTable(ranges) {
1115
1074
  return ranges.some((range) => {
1116
1075
  const { startNodePosition } = range;
@@ -2283,21 +2242,7 @@ var HtmlToUDMService = class HtmlToUDMService {
2283
2242
  height,
2284
2243
  left: 0
2285
2244
  },
2286
- docTransform: {
2287
- size: {
2288
- width: docTransformWidth,
2289
- height: docTransformHeight
2290
- },
2291
- angle: 0,
2292
- positionH: {
2293
- relativeFrom: ObjectRelativeFromH.PAGE,
2294
- posOffset: 0
2295
- },
2296
- positionV: {
2297
- relativeFrom: ObjectRelativeFromV.PARAGRAPH,
2298
- posOffset: 0
2299
- }
2300
- },
2245
+ docTransform: buildDocTransform(docTransformWidth, docTransformHeight),
2301
2246
  layoutType: PositionedObjectLayoutType.INLINE,
2302
2247
  drawingType: DrawingTypeEnum.DRAWING_IMAGE,
2303
2248
  unitId: doc.id || "",
@@ -4570,9 +4515,9 @@ const DocSelectAllCommand = {
4570
4515
  if (body == null) return false;
4571
4516
  const { dataStream } = body;
4572
4517
  if (dataStream === "\r\n") return true;
4573
- const wholeDocRanges = getWholeDocumentRanges(body);
4574
- const scopedRange = getScopedSelectAllRange(body, activeRange);
4575
- const textRanges = scopedRange && !isSameRanges(docRanges, scopedRange) ? scopedRange : wholeDocRanges;
4518
+ const scopes = getSelectAllScopes(body, activeRange);
4519
+ const currentScopeIndex = scopes.findIndex((scope) => isSameRanges(docRanges, scope));
4520
+ const textRanges = scopes[Math.min(currentScopeIndex + 1, scopes.length - 1)];
4576
4521
  docSelectionManagerService.replaceDocRanges(textRanges, {
4577
4522
  unitId,
4578
4523
  subUnitId: unitId
@@ -4581,17 +4526,39 @@ const DocSelectAllCommand = {
4581
4526
  }
4582
4527
  };
4583
4528
  function getWholeDocumentRanges(body) {
4529
+ return getRangesForOffsets(body, 0, body.dataStream.length - 2);
4530
+ }
4531
+ function getRangesForOffsets(body, startOffset, endOffset) {
4532
+ var _body$columnGroups;
4533
+ const columnGroups = [...(_body$columnGroups = body.columnGroups) !== null && _body$columnGroups !== void 0 ? _body$columnGroups : []].sort((left, right) => left.startIndex - right.startIndex);
4534
+ const ranges = [];
4535
+ let offset = startOffset;
4536
+ for (const columnGroup of columnGroups) {
4537
+ if (columnGroup.endIndex < startOffset || columnGroup.startIndex > endOffset) continue;
4538
+ if (offset < columnGroup.startIndex) ranges.push(...getRangesWithTables(body, offset, Math.min(endOffset, columnGroup.startIndex - 1)));
4539
+ for (const column of getColumnRanges(body, columnGroup)) {
4540
+ const start = Math.max(startOffset, column.startOffset);
4541
+ const end = Math.min(endOffset, column.endOffset);
4542
+ if (start <= end) ranges.push(...getRangesWithTables(body, start, end));
4543
+ }
4544
+ offset = columnGroup.endIndex + 1;
4545
+ }
4546
+ if (offset <= endOffset) ranges.push(...getRangesWithTables(body, offset, endOffset));
4547
+ return ranges;
4548
+ }
4549
+ function getRangesWithTables(body, startOffset, endOffset) {
4584
4550
  var _body$tables;
4585
- const textRanges = [];
4586
- let offset = 0;
4587
- for (const table of (_body$tables = body.tables) !== null && _body$tables !== void 0 ? _body$tables : []) {
4551
+ const ranges = [];
4552
+ let offset = startOffset;
4553
+ for (const table of [...(_body$tables = body.tables) !== null && _body$tables !== void 0 ? _body$tables : []].sort((left, right) => left.startIndex - right.startIndex)) {
4588
4554
  const { startIndex, endIndex } = table;
4589
- if (offset !== startIndex) textRanges.push(...getTextRangesByParagraphs(body, offset, startIndex - 1));
4590
- textRanges.push(getTableRectRange(table));
4555
+ if (startIndex < startOffset || endIndex > endOffset) continue;
4556
+ if (offset !== startIndex) ranges.push(...getTextRangesByParagraphs(body, offset, startIndex - 1));
4557
+ ranges.push(getTableRectRange(table));
4591
4558
  offset = endIndex;
4592
4559
  }
4593
- if (offset !== body.dataStream.length - 2) textRanges.push(...getTextRangesByParagraphs(body, offset, body.dataStream.length - 2));
4594
- return textRanges;
4560
+ if (offset <= endOffset) ranges.push(...getTextRangesByParagraphs(body, offset, endOffset));
4561
+ return ranges;
4595
4562
  }
4596
4563
  function getTextRangesByParagraphs(body, startOffset, endOffset) {
4597
4564
  var _body$paragraphs;
@@ -4616,30 +4583,62 @@ function getTextRangesByParagraphs(body, startOffset, endOffset) {
4616
4583
  });
4617
4584
  return ranges;
4618
4585
  }
4619
- function getScopedSelectAllRange(body, activeRange) {
4620
- var _body$tables2, _body$customBlocks, _body$blockRanges, _body$tables3;
4586
+ function getSelectAllScopes(body, activeRange) {
4587
+ var _body$tables2, _body$customBlocks, _body$blockRanges, _body$columnGroups2;
4588
+ const scopes = [];
4589
+ const addScope = (scope) => {
4590
+ if ((scope === null || scope === void 0 ? void 0 : scope.length) && !scopes.some((existing) => isSameRanges(existing, scope))) scopes.push(scope);
4591
+ };
4621
4592
  const startOffset = activeRange.startOffset;
4622
4593
  const endOffset = activeRange.endOffset;
4623
- if (startOffset == null || endOffset == null) return null;
4594
+ if (startOffset == null || endOffset == null) return [getWholeDocumentRanges(body)];
4624
4595
  const table = ((_body$tables2 = body.tables) !== null && _body$tables2 !== void 0 ? _body$tables2 : []).find((item) => isRangeInside(startOffset, endOffset, item.startIndex, item.endIndex));
4625
- if (table) return [getTableRectRange(table)];
4626
4596
  const customBlock = ((_body$customBlocks = body.customBlocks) !== null && _body$customBlocks !== void 0 ? _body$customBlocks : []).find((item) => item.startIndex >= startOffset && item.startIndex <= endOffset);
4627
- if (customBlock) return [{
4597
+ const blockRange = ((_body$blockRanges = body.blockRanges) !== null && _body$blockRanges !== void 0 ? _body$blockRanges : []).find((item) => isRangeInside(startOffset, endOffset, item.startIndex, item.endIndex));
4598
+ if (table) addScope([getTableRectRange(table)]);
4599
+ else if (customBlock) addScope([{
4628
4600
  endOffset: customBlock.startIndex,
4629
4601
  rangeType: DOC_RANGE_TYPE.TEXT,
4630
4602
  startOffset: customBlock.startIndex
4631
- }];
4632
- const blockRange = ((_body$blockRanges = body.blockRanges) !== null && _body$blockRanges !== void 0 ? _body$blockRanges : []).find((item) => isRangeInside(startOffset, endOffset, item.startIndex, item.endIndex));
4633
- if (blockRange) return [{
4603
+ }]);
4604
+ else if (blockRange) addScope([{
4634
4605
  endOffset: Math.max(blockRange.startIndex + 1, blockRange.endIndex - 1),
4635
4606
  rangeType: DOC_RANGE_TYPE.TEXT,
4636
4607
  startOffset: blockRange.startIndex + 1
4637
- }];
4638
- const paragraphRange = clampParagraphRangeByTables(getParagraphRangeAtOffset(body, startOffset), (_body$tables3 = body.tables) !== null && _body$tables3 !== void 0 ? _body$tables3 : [], startOffset);
4639
- return paragraphRange ? [{
4640
- ...paragraphRange,
4641
- rangeType: DOC_RANGE_TYPE.TEXT
4642
- }] : null;
4608
+ }]);
4609
+ else {
4610
+ var _body$tables3;
4611
+ const paragraphRange = clampParagraphRangeByTables(getParagraphRangeAtOffset(body, startOffset), (_body$tables3 = body.tables) !== null && _body$tables3 !== void 0 ? _body$tables3 : [], startOffset);
4612
+ addScope(paragraphRange ? [{
4613
+ ...paragraphRange,
4614
+ rangeType: DOC_RANGE_TYPE.TEXT
4615
+ }] : null);
4616
+ }
4617
+ const columnGroup = ((_body$columnGroups2 = body.columnGroups) !== null && _body$columnGroups2 !== void 0 ? _body$columnGroups2 : []).find((item) => isRangeInside(startOffset, endOffset, item.startIndex, item.endIndex));
4618
+ if (columnGroup) {
4619
+ const column = getColumnRanges(body, columnGroup).find((item) => isRangeInside(startOffset, endOffset, item.startOffset, item.endOffset));
4620
+ if (column) addScope(getRangesForOffsets(body, column.startOffset, column.endOffset));
4621
+ addScope(getRangesForOffsets(body, columnGroup.startIndex, columnGroup.endIndex));
4622
+ }
4623
+ addScope(getWholeDocumentRanges(body));
4624
+ return scopes;
4625
+ }
4626
+ function getColumnRanges(body, columnGroup) {
4627
+ const ranges = [];
4628
+ let startOffset;
4629
+ for (let index = columnGroup.startIndex; index <= columnGroup.endIndex; index++) {
4630
+ const token = body.dataStream[index];
4631
+ if (token === DataStreamTreeTokenType.COLUMN_START) startOffset = index + 1;
4632
+ else if (token === DataStreamTreeTokenType.COLUMN_END && startOffset != null) {
4633
+ ranges.push({
4634
+ startOffset,
4635
+ endOffset: index - 1,
4636
+ rangeType: DOC_RANGE_TYPE.TEXT
4637
+ });
4638
+ startOffset = void 0;
4639
+ }
4640
+ }
4641
+ return ranges;
4643
4642
  }
4644
4643
  function clampParagraphRangeByTables(paragraphRange, tables, activeOffset) {
4645
4644
  if (!paragraphRange) return null;
@@ -4676,7 +4675,9 @@ function isSameRanges(currentRanges, nextRanges) {
4676
4675
  if (currentRanges.length !== nextRanges.length) return isSameTextRangeCoverage(currentRanges, nextRanges);
4677
4676
  return currentRanges.every((currentRange, index) => {
4678
4677
  const nextRange = nextRanges[index];
4679
- return currentRange.startOffset === nextRange.startOffset && currentRange.endOffset === nextRange.endOffset && getRangeType(currentRange) === getRangeType(nextRange);
4678
+ const sameType = getRangeType(currentRange) === getRangeType(nextRange);
4679
+ const sameTextEnd = sameType && getRangeType(nextRange) === DOC_RANGE_TYPE.TEXT && !currentRange.collapsed && currentRange.endOffset + 1 === nextRange.endOffset;
4680
+ return currentRange.startOffset === nextRange.startOffset && (currentRange.endOffset === nextRange.endOffset || sameTextEnd) && sameType;
4680
4681
  });
4681
4682
  }
4682
4683
  function isSameTextRangeCoverage(currentRanges, nextRanges) {
@@ -7451,7 +7452,14 @@ const RECT_RANGE_KEY_PREFIX = "__DocTableRectRange__";
7451
7452
  const ID_LENGTH = 6;
7452
7453
  function convertPositionsToRectRanges(scene, document, docSkeleton, anchorNodePosition, focusNodePosition, style = NORMAL_TEXT_SELECTION_PLUGIN_STYLE, segmentId = "", segmentPage = -1) {
7453
7454
  const nodePositionGroup = new NodePositionConvertToRectRange(document.getOffsetConfig(), docSkeleton).getNodePositionGroup(anchorNodePosition, focusNodePosition);
7454
- return (nodePositionGroup !== null && nodePositionGroup !== void 0 ? nodePositionGroup : []).map((position) => new RectRange(scene, document, docSkeleton, position.anchor, position.focus, style, segmentId, segmentPage));
7455
+ const ranges = [];
7456
+ try {
7457
+ for (const position of nodePositionGroup !== null && nodePositionGroup !== void 0 ? nodePositionGroup : []) ranges.push(new RectRange(scene, document, docSkeleton, position.anchor, position.focus, style, segmentId, segmentPage));
7458
+ return ranges;
7459
+ } catch (error) {
7460
+ ranges.forEach((range) => range.dispose());
7461
+ throw error;
7462
+ }
7455
7463
  }
7456
7464
  var RectRange = class {
7457
7465
  constructor(_scene, _document, _docSkeleton, anchorNodePosition, focusNodePosition, style = NORMAL_TEXT_SELECTION_PLUGIN_STYLE, _segmentId = "", _segmentPage = -1) {
@@ -7609,10 +7617,29 @@ var RectRange = class {
7609
7617
 
7610
7618
  //#endregion
7611
7619
  //#region src/services/selection/selection-utils.ts
7620
+ function disposeRangeList({ textRanges, rectRanges }) {
7621
+ textRanges.forEach((range) => range.dispose());
7622
+ rectRanges.forEach((range) => range.dispose());
7623
+ }
7624
+ function isCompatibleTextRange(start, end) {
7625
+ if (start == null || end == null || start.pageType !== end.pageType) return false;
7626
+ if ((start.pageType === DocumentSkeletonPageType.HEADER || start.pageType === DocumentSkeletonPageType.FOOTER) && start.segmentPage !== end.segmentPage) return false;
7627
+ const startColumn = getDocumentSkeletonColumnPagePathInfo(start);
7628
+ const endColumn = getDocumentSkeletonColumnPagePathInfo(end);
7629
+ if (startColumn == null || endColumn == null) return startColumn == null && endColumn == null;
7630
+ return startColumn.pageIndex === endColumn.pageIndex && startColumn.columnGroupId === endColumn.columnGroupId && startColumn.columnIndex === endColumn.columnIndex;
7631
+ }
7632
+ function getDescendantTables(node) {
7633
+ if (node.nodeType === DataStreamTreeNodeType.TABLE) return [node];
7634
+ return node.children.flatMap(getDescendantTables);
7635
+ }
7612
7636
  function isInSameColumnPage(anchorPosition, focusPosition) {
7637
+ var _anchorPosition$path$, _anchorPosition$path, _focusPosition$path$i, _focusPosition$path;
7613
7638
  const anchorColumnInfo = getDocumentSkeletonColumnPagePathInfo(anchorPosition);
7614
7639
  const focusColumnInfo = getDocumentSkeletonColumnPagePathInfo(focusPosition);
7615
- return !!anchorColumnInfo && !!focusColumnInfo && anchorColumnInfo.pageIndex === focusColumnInfo.pageIndex && anchorColumnInfo.columnGroupId === focusColumnInfo.columnGroupId && anchorColumnInfo.columnIndex === focusColumnInfo.columnIndex;
7640
+ const anchorPageIndex = (_anchorPosition$path$ = (_anchorPosition$path = anchorPosition.path) === null || _anchorPosition$path === void 0 ? void 0 : _anchorPosition$path.indexOf("page")) !== null && _anchorPosition$path$ !== void 0 ? _anchorPosition$path$ : -1;
7641
+ const focusPageIndex = (_focusPosition$path$i = (_focusPosition$path = focusPosition.path) === null || _focusPosition$path === void 0 ? void 0 : _focusPosition$path.indexOf("page")) !== null && _focusPosition$path$i !== void 0 ? _focusPosition$path$i : -1;
7642
+ return anchorPageIndex >= 0 && focusPageIndex >= 0 && anchorPageIndex === anchorPosition.path.length - 1 && focusPageIndex === focusPosition.path.length - 1 && !!anchorColumnInfo && !!focusColumnInfo && anchorColumnInfo.pageIndex === focusColumnInfo.pageIndex && anchorColumnInfo.columnGroupId === focusColumnInfo.columnGroupId && anchorColumnInfo.columnIndex === focusColumnInfo.columnIndex;
7616
7643
  }
7617
7644
  function getColumnInputBoundaryCollapsedPosition(anchorPosition, focusPosition, skeleton) {
7618
7645
  const anchorColumnInfo = getDocumentSkeletonColumnPagePathInfo(anchorPosition);
@@ -7662,13 +7689,6 @@ function getRangeListFromSelection(anchorPosition, focusPosition, scene, documen
7662
7689
  rectRanges
7663
7690
  };
7664
7691
  }
7665
- if (isInSameColumnPage(anchorPosition, focusPosition)) {
7666
- textRanges.push(new TextRange(...rangeParams));
7667
- return {
7668
- textRanges,
7669
- rectRanges
7670
- };
7671
- }
7672
7692
  if (isInSameTableCellData(skeleton, anchorPosition, focusPosition)) if (isInSameTableCell(anchorPosition, focusPosition)) {
7673
7693
  textRanges.push(new TextRange(...rangeParams));
7674
7694
  return {
@@ -7691,6 +7711,13 @@ function getRangeListFromSelection(anchorPosition, focusPosition, scene, documen
7691
7711
  rectRanges
7692
7712
  };
7693
7713
  }
7714
+ if (isInSameColumnPage(anchorPosition, focusPosition)) {
7715
+ textRanges.push(new TextRange(...rangeParams));
7716
+ return {
7717
+ textRanges,
7718
+ rectRanges
7719
+ };
7720
+ }
7694
7721
  const viewModel = skeleton.getViewModel().getSelfOrHeaderFooterViewModel(segmentId);
7695
7722
  const anchorOffset = skeleton.findCharIndexByPosition(anchorPosition);
7696
7723
  const focusOffset = skeleton.findCharIndexByPosition(focusPosition);
@@ -7707,64 +7734,158 @@ function getRangeListFromSelection(anchorPosition, focusPosition, scene, documen
7707
7734
  var _skeleton$findNodePos2;
7708
7735
  return (_skeleton$findNodePos2 = skeleton.findNodePositionByCharIndex(charIndex, isBack, segmentId, segmentPage)) !== null && _skeleton$findNodePos2 !== void 0 ? _skeleton$findNodePos2 : charIndex === endOffset ? originRange.end : void 0;
7709
7736
  };
7737
+ const appendTextRange = (rangeStart, rangeEnd, endIsBack = true) => {
7738
+ if (rangeStart > rangeEnd) return true;
7739
+ const sp = findStartNodePositionByCharIndex(rangeStart, true);
7740
+ const ep = findEndNodePositionByCharIndex(rangeEnd, endIsBack);
7741
+ const ap = direction === RANGE_DIRECTION.FORWARD ? sp : ep;
7742
+ const fp = direction === RANGE_DIRECTION.FORWARD ? ep : sp;
7743
+ if (!isCompatibleTextRange(ap, fp)) return false;
7744
+ textRanges.push(new TextRange(scene, document, skeleton, ap, fp, style, segmentId, segmentPage));
7745
+ return true;
7746
+ };
7747
+ const appendTableRange = (table, rangeStart, rangeEnd) => {
7748
+ const { startIndex: tableStart, endIndex: tableEnd, children: rows } = table;
7749
+ const startRow = rows.find((row) => row.startIndex <= rangeStart && row.endIndex >= rangeStart);
7750
+ const endRow = rows.find((row) => row.startIndex <= rangeEnd && row.endIndex >= rangeEnd);
7751
+ const tableStartOffset = rangeStart > tableStart && rangeStart < tableEnd ? (startRow === null || startRow === void 0 ? void 0 : startRow.startIndex) == null ? void 0 : startRow.startIndex + 2 : tableStart + 3;
7752
+ const tableEndOffset = rangeEnd > tableStart && rangeEnd < tableEnd ? (endRow === null || endRow === void 0 ? void 0 : endRow.endIndex) == null ? void 0 : endRow.endIndex - 3 : tableEnd - 4;
7753
+ if (tableStartOffset == null || tableEndOffset == null) return false;
7754
+ const startPosition = skeleton.findNodePositionByCharIndex(tableStartOffset, true, segmentId, segmentPage);
7755
+ const endPosition = skeleton.findNodePositionByCharIndex(tableEndOffset, true, segmentId, segmentPage);
7756
+ if (startPosition == null || endPosition == null) return false;
7757
+ const ap = direction === RANGE_DIRECTION.FORWARD ? startPosition : endPosition;
7758
+ const fp = direction === RANGE_DIRECTION.FORWARD ? endPosition : startPosition;
7759
+ rectRanges.push(...convertPositionsToRectRanges(scene, document, skeleton, ap, fp, style, segmentId, segmentPage));
7760
+ return true;
7761
+ };
7762
+ const appendColumnRanges = (column, rangeStart, rangeEnd) => {
7763
+ let offset = rangeStart;
7764
+ const tables = getDescendantTables(column).sort((left, right) => left.startIndex - right.startIndex);
7765
+ for (const table of tables) {
7766
+ if (table.endIndex < rangeStart || table.startIndex > rangeEnd) continue;
7767
+ if (!appendTextRange(offset, Math.min(rangeEnd, table.startIndex - 1), false) || !appendTableRange(table, Math.max(rangeStart, table.startIndex), Math.min(rangeEnd, table.endIndex))) return false;
7768
+ offset = table.endIndex + 1;
7769
+ }
7770
+ return appendTextRange(offset, rangeEnd);
7771
+ };
7710
7772
  let start = startOffset;
7711
7773
  let end = endOffset;
7712
- for (const section of viewModel.getChildren()) for (const paragraph of section.children) {
7713
- const { startIndex, endIndex, children } = paragraph;
7714
- const paragraphIndex = section.children.indexOf(paragraph);
7715
- const nextParagraph = section.children[paragraphIndex + 1];
7716
- const table = children[0];
7717
- let endInTable = false;
7718
- if (table) {
7719
- const { startIndex: tableStart, endIndex: tableEnd, children } = table;
7720
- let tableStartPosition = null;
7721
- let tableEndPosition = null;
7722
- const startRow = children.find((row) => row.startIndex <= startOffset && row.endIndex >= startOffset);
7723
- const endRow = children.find((row) => row.startIndex <= endOffset && row.endIndex >= endOffset);
7724
- if (startOffset > tableStart && startOffset < tableEnd) {
7725
- tableStartPosition = skeleton.findNodePositionByCharIndex(startRow.startIndex + 2, true, segmentId, segmentPage);
7726
- tableEndPosition = skeleton.findNodePositionByCharIndex(tableEnd - 4, true, segmentId, segmentPage);
7727
- start = tableEnd + 1;
7728
- } else if (endOffset > tableStart && endOffset < tableEnd) {
7729
- tableStartPosition = skeleton.findNodePositionByCharIndex(tableStart + 3, true, segmentId, segmentPage);
7730
- tableEndPosition = skeleton.findNodePositionByCharIndex(endRow.endIndex - 3, true, segmentId, segmentPage);
7731
- end = tableStart - 1;
7732
- endInTable = true;
7733
- } else if (tableStart > startOffset && tableEnd < endOffset) {
7734
- tableStartPosition = skeleton.findNodePositionByCharIndex(tableStart + 3, true, segmentId, segmentPage);
7735
- tableEndPosition = skeleton.findNodePositionByCharIndex(tableEnd - 4, true, segmentId, segmentPage);
7736
- if (start <= tableStart - 1) {
7737
- const sp = findStartNodePositionByCharIndex(start, true);
7738
- const ep = findEndNodePositionByCharIndex(tableStart - 1, false);
7739
- const ap = direction === RANGE_DIRECTION.FORWARD ? sp : ep;
7740
- const fp = direction === RANGE_DIRECTION.FORWARD ? ep : sp;
7741
- textRanges.push(new TextRange(scene, document, skeleton, ap, fp, style, segmentId, segmentPage));
7774
+ try {
7775
+ for (const section of viewModel.getChildren()) for (const paragraph of section.children) {
7776
+ const { startIndex, endIndex, children } = paragraph;
7777
+ if (paragraph.nodeType === DataStreamTreeNodeType.COLUMN_GROUP && start <= endIndex && end >= startIndex) {
7778
+ if (start < startIndex && !appendTextRange(start, Math.min(end, startIndex - 1), false)) {
7779
+ disposeRangeList({
7780
+ textRanges,
7781
+ rectRanges
7782
+ });
7783
+ return;
7784
+ }
7785
+ for (const column of children.filter((child) => child.nodeType === DataStreamTreeNodeType.COLUMN)) {
7786
+ const columnStart = Math.max(start, column.startIndex + 1);
7787
+ const columnEnd = Math.min(end, column.endIndex - 1);
7788
+ if (columnStart <= columnEnd && !appendColumnRanges(column, columnStart, columnEnd)) {
7789
+ disposeRangeList({
7790
+ textRanges,
7791
+ rectRanges
7792
+ });
7793
+ return;
7794
+ }
7795
+ }
7796
+ start = endIndex + 1;
7797
+ continue;
7798
+ }
7799
+ const paragraphIndex = section.children.indexOf(paragraph);
7800
+ const nextParagraph = section.children[paragraphIndex + 1];
7801
+ const table = children.find((child) => child.nodeType === DataStreamTreeNodeType.TABLE);
7802
+ const nextTable = nextParagraph === null || nextParagraph === void 0 ? void 0 : nextParagraph.children.find((child) => child.nodeType === DataStreamTreeNodeType.TABLE);
7803
+ let endInTable = false;
7804
+ if (table) {
7805
+ const { startIndex: tableStart, endIndex: tableEnd, children } = table;
7806
+ let tableStartPosition = null;
7807
+ let tableEndPosition = null;
7808
+ if (startOffset > tableStart && startOffset < tableEnd) {
7809
+ const startRow = children.find((row) => row.startIndex <= startOffset && row.endIndex >= startOffset);
7810
+ if (startRow == null) {
7811
+ disposeRangeList({
7812
+ textRanges,
7813
+ rectRanges
7814
+ });
7815
+ return;
7816
+ }
7817
+ tableStartPosition = skeleton.findNodePositionByCharIndex(startRow.startIndex + 2, true, segmentId, segmentPage);
7818
+ tableEndPosition = skeleton.findNodePositionByCharIndex(tableEnd - 4, true, segmentId, segmentPage);
7819
+ start = tableEnd + 1;
7820
+ } else if (endOffset > tableStart && endOffset < tableEnd) {
7821
+ const endRow = children.find((row) => row.startIndex <= endOffset && row.endIndex >= endOffset);
7822
+ if (endRow == null) {
7823
+ disposeRangeList({
7824
+ textRanges,
7825
+ rectRanges
7826
+ });
7827
+ return;
7828
+ }
7829
+ tableStartPosition = skeleton.findNodePositionByCharIndex(tableStart + 3, true, segmentId, segmentPage);
7830
+ tableEndPosition = skeleton.findNodePositionByCharIndex(endRow.endIndex - 3, true, segmentId, segmentPage);
7831
+ end = tableStart - 1;
7832
+ endInTable = true;
7833
+ } else if (tableStart > startOffset && tableEnd < endOffset) {
7834
+ tableStartPosition = skeleton.findNodePositionByCharIndex(tableStart + 3, true, segmentId, segmentPage);
7835
+ tableEndPosition = skeleton.findNodePositionByCharIndex(tableEnd - 4, true, segmentId, segmentPage);
7836
+ if (start <= tableStart - 1) {
7837
+ const sp = findStartNodePositionByCharIndex(start, true);
7838
+ const ep = findEndNodePositionByCharIndex(tableStart - 1, false);
7839
+ const ap = direction === RANGE_DIRECTION.FORWARD ? sp : ep;
7840
+ const fp = direction === RANGE_DIRECTION.FORWARD ? ep : sp;
7841
+ if (!isCompatibleTextRange(ap, fp)) {
7842
+ disposeRangeList({
7843
+ textRanges,
7844
+ rectRanges
7845
+ });
7846
+ return;
7847
+ }
7848
+ textRanges.push(new TextRange(scene, document, skeleton, ap, fp, style, segmentId, segmentPage));
7849
+ }
7850
+ start = tableEnd + 1;
7851
+ }
7852
+ if (tableStartPosition && tableEndPosition) {
7853
+ const ap = direction === RANGE_DIRECTION.FORWARD ? tableStartPosition : tableEndPosition;
7854
+ const fp = direction === RANGE_DIRECTION.FORWARD ? tableEndPosition : tableStartPosition;
7855
+ rectRanges.push(...convertPositionsToRectRanges(scene, document, skeleton, ap, fp, style, segmentId, segmentPage));
7742
7856
  }
7743
- start = tableEnd + 1;
7744
7857
  }
7745
- if (tableStartPosition && tableEndPosition) {
7746
- const ap = direction === RANGE_DIRECTION.FORWARD ? tableStartPosition : tableEndPosition;
7747
- const fp = direction === RANGE_DIRECTION.FORWARD ? tableEndPosition : tableStartPosition;
7748
- rectRanges.push(...convertPositionsToRectRanges(scene, document, skeleton, ap, fp, style, segmentId, segmentPage));
7858
+ if (end === endIndex + 1 && !endInTable && nextTable) {
7859
+ end = endIndex;
7860
+ endInTable = true;
7861
+ }
7862
+ if (end >= startIndex && end <= endIndex || endInTable) {
7863
+ const sp = findStartNodePositionByCharIndex(start, true);
7864
+ const ep = findEndNodePositionByCharIndex(end, !endInTable);
7865
+ const ap = direction === RANGE_DIRECTION.FORWARD ? sp : ep;
7866
+ const fp = direction === RANGE_DIRECTION.FORWARD ? ep : sp;
7867
+ if (rectRanges.length && Tools.diffValue(ap, fp)) continue;
7868
+ if (!isCompatibleTextRange(ap, fp)) {
7869
+ disposeRangeList({
7870
+ textRanges,
7871
+ rectRanges
7872
+ });
7873
+ return;
7874
+ }
7875
+ textRanges.push(new TextRange(scene, document, skeleton, ap, fp, style, segmentId, segmentPage));
7749
7876
  }
7750
7877
  }
7751
- if (end === endIndex + 1 && !endInTable && nextParagraph && nextParagraph.children.length) {
7752
- end = endIndex;
7753
- endInTable = true;
7754
- }
7755
- if (end >= startIndex && end <= endIndex || endInTable) {
7756
- const sp = findStartNodePositionByCharIndex(start, true);
7757
- const ep = findEndNodePositionByCharIndex(end, !endInTable);
7758
- const ap = direction === RANGE_DIRECTION.FORWARD ? sp : ep;
7759
- const fp = direction === RANGE_DIRECTION.FORWARD ? ep : sp;
7760
- if (rectRanges.length && Tools.diffValue(ap, fp)) continue;
7761
- textRanges.push(new TextRange(scene, document, skeleton, ap, fp, style, segmentId, segmentPage));
7762
- }
7878
+ return {
7879
+ textRanges,
7880
+ rectRanges
7881
+ };
7882
+ } catch (error) {
7883
+ disposeRangeList({
7884
+ textRanges,
7885
+ rectRanges
7886
+ });
7887
+ throw error;
7763
7888
  }
7764
- return {
7765
- textRanges,
7766
- rectRanges
7767
- };
7768
7889
  }
7769
7890
  function getCanvasOffsetByEngine(engine) {
7770
7891
  const canvas = engine === null || engine === void 0 ? void 0 : engine.getCanvasElement();
@@ -8174,9 +8295,9 @@ let DocSelectionRenderService = class DocSelectionRenderService extends RxDispos
8174
8295
  const { offsetX: moveOffsetX, offsetY: moveOffsetY } = moveEvt;
8175
8296
  scene.setCursor(CURSOR_TYPE.TEXT);
8176
8297
  if (Math.sqrt((moveOffsetX - preMoveOffsetX) ** 2 + (moveOffsetY - preMoveOffsetY) ** 2) < 3) return;
8177
- this._moving(moveOffsetX, moveOffsetY);
8298
+ this._tryMoving(moveOffsetX, moveOffsetY);
8178
8299
  scrollTimer.scrolling(moveOffsetX, moveOffsetY, () => {
8179
- this._moving(moveOffsetX, moveOffsetY);
8300
+ this._tryMoving(moveOffsetX, moveOffsetY);
8180
8301
  });
8181
8302
  preMoveOffsetX = moveOffsetX;
8182
8303
  preMoveOffsetY = moveOffsetY;
@@ -8471,6 +8592,13 @@ let DocSelectionRenderService = class DocSelectionRenderService extends RxDispos
8471
8592
  canvasTop += y;
8472
8593
  this.activate(canvasLeft, canvasTop, forceFocus);
8473
8594
  }
8595
+ _tryMoving(moveOffsetX, moveOffsetY) {
8596
+ try {
8597
+ this._moving(moveOffsetX, moveOffsetY);
8598
+ } catch (error) {
8599
+ this._logService.error("[DocSelectionRenderService] Failed to update moving selection", error);
8600
+ }
8601
+ }
8474
8602
  _moving(moveOffsetX, moveOffsetY) {
8475
8603
  var _this$_context$scene2;
8476
8604
  const { _currentSegmentId: segmentId, _currentSegmentPage: segmentPage } = this;
@@ -11451,7 +11579,7 @@ function DeleteTableMenuItemFactory(accessor) {
11451
11579
  id: DocTableDeleteTableCommand.id,
11452
11580
  type: MenuItemType.BUTTON,
11453
11581
  title: "docs-ui.table.deleteTable",
11454
- icon: "GridIcon",
11582
+ icon: "DeleteTableDoubleIcon",
11455
11583
  disabled$: getDisableWhenSelectionNotInTableObservable(accessor),
11456
11584
  hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC)
11457
11585
  };
@@ -13345,6 +13473,10 @@ const menuSchema = {
13345
13473
  order: 8,
13346
13474
  menuItemFactory: BulletListMenuItemFactory
13347
13475
  },
13476
+ [CheckListCommand.id]: {
13477
+ order: 9,
13478
+ menuItemFactory: CheckListMenuItemFactory
13479
+ },
13348
13480
  [OpenHeaderFooterPanelCommand.id]: {
13349
13481
  order: 10,
13350
13482
  menuItemFactory: HeaderFooterMenuItemFactory
@@ -13366,10 +13498,6 @@ const menuSchema = {
13366
13498
  [HorizontalLineCommand.id]: {
13367
13499
  order: 3,
13368
13500
  menuItemFactory: HorizontalLineFactory
13369
- },
13370
- [CheckListCommand.id]: {
13371
- order: 4,
13372
- menuItemFactory: CheckListMenuItemFactory
13373
13501
  }
13374
13502
  },
13375
13503
  [ContextMenuPosition.MAIN_AREA]: {
@@ -14075,23 +14203,13 @@ const DOC_ZOOM_RANGE = [10, 400];
14075
14203
  function ZoomSlider() {
14076
14204
  const commandService = useDependency(ICommandService);
14077
14205
  const univerInstanceService = useDependency(IUniverInstanceService);
14078
- const [documentDataModel, setDocumentDataModel] = useState(null);
14079
- const [zoom, setZoom] = useState(100);
14206
+ const documentDataModel = useObservable(() => univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_DOC).pipe(filter((documentDataModel) => documentDataModel != null)), null, false, [univerInstanceService]);
14080
14207
  const getCurrentZoom = useCallback((docModel = documentDataModel) => {
14081
14208
  if (!docModel) return 100;
14082
14209
  return Math.round(getDocEffectiveZoomRatio(docModel) * 100);
14083
14210
  }, [documentDataModel]);
14084
- useEffect(() => {
14085
- const subscription = univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_DOC).subscribe((doc) => {
14086
- if (doc) {
14087
- setDocumentDataModel(doc);
14088
- setZoom(getCurrentZoom(doc));
14089
- }
14090
- });
14091
- return () => {
14092
- subscription.unsubscribe();
14093
- };
14094
- }, [univerInstanceService, getCurrentZoom]);
14211
+ const [zoom, setZoom] = useState(100);
14212
+ useEffect(() => setZoom(getCurrentZoom(documentDataModel)), [documentDataModel, getCurrentZoom]);
14095
14213
  useEffect(() => {
14096
14214
  return commandService.onCommandExecuted((commandInfo) => {
14097
14215
  if (commandInfo.id === SetDocZoomRatioOperation.id) setZoom(getCurrentZoom());
@@ -15258,23 +15376,28 @@ function DocSideMenu() {
15258
15376
  return null;
15259
15377
  }
15260
15378
  function DocSideMenuContent() {
15261
- var _currentDoc$getBody$d, _currentDoc$getBody, _currentDoc$getUnitId, _renderer$mainCompone, _renderer$mainCompone2, _renderer$engine$heig, _renderer$scene$scale, _currentDoc$getBody$p, _currentDoc$getBody2;
15262
- const commandService = useDependency(ICommandService);
15379
+ var _documentData$body$da, _documentData$body, _currentDoc$getUnitId, _documentData$body$pa, _documentData$body2;
15263
15380
  const instanceService = useDependency(IUniverInstanceService);
15264
15381
  const currentDoc = useObservable(useMemo(() => instanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_DOC), []));
15265
15382
  const renderManagerService = useDependency(IRenderManagerService);
15266
- const fullDataStream = (_currentDoc$getBody$d = currentDoc === null || currentDoc === void 0 || (_currentDoc$getBody = currentDoc.getBody()) === null || _currentDoc$getBody === void 0 ? void 0 : _currentDoc$getBody.dataStream) !== null && _currentDoc$getBody$d !== void 0 ? _currentDoc$getBody$d : "";
15267
- const [_updateKey, setUpdateKey] = useState(0);
15383
+ const documentData = useObservable(currentDoc ? () => currentDoc.change$.pipe(debounceTime(100), map(() => currentDoc.getSnapshot())) : null, currentDoc === null || currentDoc === void 0 ? void 0 : currentDoc.getSnapshot(), false, [currentDoc]);
15384
+ const fullDataStream = (_documentData$body$da = documentData === null || documentData === void 0 || (_documentData$body = documentData.body) === null || _documentData$body === void 0 ? void 0 : _documentData$body.dataStream) !== null && _documentData$body$da !== void 0 ? _documentData$body$da : "";
15268
15385
  const [activeId, setActiveId] = useState(void 0);
15269
15386
  const unitId = (_currentDoc$getUnitId = currentDoc === null || currentDoc === void 0 ? void 0 : currentDoc.getUnitId()) !== null && _currentDoc$getUnitId !== void 0 ? _currentDoc$getUnitId : "";
15270
15387
  const renderer = renderManagerService.getRenderById(unitId);
15271
- const title = currentDoc === null || currentDoc === void 0 ? void 0 : currentDoc.getTitle();
15388
+ const title = documentData === null || documentData === void 0 ? void 0 : documentData.title;
15272
15389
  const docEventManagerService = renderer === null || renderer === void 0 ? void 0 : renderer.with(DocEventManagerService);
15273
15390
  const paragraphBounds = docEventManagerService === null || docEventManagerService === void 0 ? void 0 : docEventManagerService.paragraphBounds;
15274
- const left = (_renderer$mainCompone = renderer === null || renderer === void 0 || (_renderer$mainCompone2 = renderer.mainComponent) === null || _renderer$mainCompone2 === void 0 ? void 0 : _renderer$mainCompone2.left) !== null && _renderer$mainCompone !== void 0 ? _renderer$mainCompone : 0;
15275
- const canvasHeight = (_renderer$engine$heig = renderer === null || renderer === void 0 ? void 0 : renderer.engine.height) !== null && _renderer$engine$heig !== void 0 ? _renderer$engine$heig : 0;
15276
- const scaleY = (_renderer$scene$scale = renderer === null || renderer === void 0 ? void 0 : renderer.scene.scaleY) !== null && _renderer$scene$scale !== void 0 ? _renderer$scene$scale : 1;
15277
- const paragraphs = (_currentDoc$getBody$p = currentDoc === null || currentDoc === void 0 || (_currentDoc$getBody2 = currentDoc.getBody()) === null || _currentDoc$getBody2 === void 0 ? void 0 : _currentDoc$getBody2.paragraphs) !== null && _currentDoc$getBody$p !== void 0 ? _currentDoc$getBody$p : [];
15391
+ const readLayout = () => {
15392
+ var _renderer$mainCompone, _renderer$mainCompone2, _renderer$engine$heig, _renderer$scene$scale;
15393
+ return {
15394
+ left: (_renderer$mainCompone = renderer === null || renderer === void 0 || (_renderer$mainCompone2 = renderer.mainComponent) === null || _renderer$mainCompone2 === void 0 ? void 0 : _renderer$mainCompone2.left) !== null && _renderer$mainCompone !== void 0 ? _renderer$mainCompone : 0,
15395
+ canvasHeight: (_renderer$engine$heig = renderer === null || renderer === void 0 ? void 0 : renderer.engine.height) !== null && _renderer$engine$heig !== void 0 ? _renderer$engine$heig : 0,
15396
+ scaleY: (_renderer$scene$scale = renderer === null || renderer === void 0 ? void 0 : renderer.scene.scaleY) !== null && _renderer$scene$scale !== void 0 ? _renderer$scene$scale : 1
15397
+ };
15398
+ };
15399
+ const { left, canvasHeight, scaleY } = useObservable((renderer === null || renderer === void 0 ? void 0 : renderer.engine.onTransformChange$) ? () => fromEventSubject(renderer.engine.onTransformChange$).pipe(throttleTime(33), map(readLayout), startWith(readLayout())) : null, readLayout(), false, [renderer]);
15400
+ const paragraphs = (_documentData$body$pa = documentData === null || documentData === void 0 || (_documentData$body2 = documentData.body) === null || _documentData$body2 === void 0 ? void 0 : _documentData$body2.paragraphs) !== null && _documentData$body$pa !== void 0 ? _documentData$body$pa : [];
15278
15401
  const paragraphMap = useMemo(() => {
15279
15402
  const map = /* @__PURE__ */ new Map();
15280
15403
  paragraphs.forEach((p) => {
@@ -15282,7 +15405,6 @@ function DocSideMenuContent() {
15282
15405
  });
15283
15406
  return map;
15284
15407
  }, [paragraphs]);
15285
- useObservable(useMemo(() => (renderer === null || renderer === void 0 ? void 0 : renderer.engine.onTransformChange$) ? fromEventSubject(renderer === null || renderer === void 0 ? void 0 : renderer.engine.onTransformChange$).pipe(throttleTime(33)) : of(null), [renderer === null || renderer === void 0 ? void 0 : renderer.engine.onTransformChange$]));
15286
15408
  const mode = left < 180 ? "float" : "side-bar";
15287
15409
  let minLevel = Infinity;
15288
15410
  const paragraphMenus = paragraphs === null || paragraphs === void 0 ? void 0 : paragraphs.filter((p) => {
@@ -15314,17 +15436,6 @@ function DocSideMenuContent() {
15314
15436
  isTitle: true
15315
15437
  }] : [], ...paragraphMenus !== null && paragraphMenus !== void 0 ? paragraphMenus : []].filter(Boolean);
15316
15438
  const [open, setOpen] = useState(true);
15317
- useEffect(() => {
15318
- const debounceUpdater = debounce(setUpdateKey, 100);
15319
- const sub = commandService.onCommandExecuted((commandInfo) => {
15320
- if (commandInfo.id === RichTextEditingMutation.id) {
15321
- if (commandInfo.params.unitId === (currentDoc === null || currentDoc === void 0 ? void 0 : currentDoc.getUnitId())) debounceUpdater((prev) => prev + 1);
15322
- }
15323
- });
15324
- return () => {
15325
- sub.dispose();
15326
- };
15327
- }, [commandService, currentDoc]);
15328
15439
  useEffect(() => {
15329
15440
  const viewport = renderer === null || renderer === void 0 ? void 0 : renderer.scene.getViewport("viewMain");
15330
15441
  if (!viewport) return;
@@ -15724,7 +15835,7 @@ function resolveDocsCustomBlockRenderViewport(params) {
15724
15835
  //#endregion
15725
15836
  //#region package.json
15726
15837
  var name = "@univerjs/docs-ui";
15727
- var version = "1.0.0-alpha.3";
15838
+ var version = "1.0.0-alpha.4";
15728
15839
 
15729
15840
  //#endregion
15730
15841
  //#region src/commands/commands/doc-paragraph-setting.command.ts
@@ -15789,6 +15900,67 @@ const DocParagraphSettingCommand = {
15789
15900
  }
15790
15901
  };
15791
15902
 
15903
+ //#endregion
15904
+ //#region src/views/float-toolbar/FloatToolbar.tsx
15905
+ const FLOAT_MENU_COMPONENT_KEY = "univer.doc.float-menu";
15906
+ const DEFAULT_AVALIABLE_MENUS = [
15907
+ FLOAT_TEXT_STYLE_MENU_ID,
15908
+ SetInlineFormatFontSizeCommand.id,
15909
+ SetInlineFormatBoldCommand.id,
15910
+ SetInlineFormatItalicCommand.id,
15911
+ SetInlineFormatUnderlineCommand.id,
15912
+ SetInlineFormatStrikethroughCommand.id,
15913
+ SetInlineFormatSubscriptCommand.id,
15914
+ SetInlineFormatSuperscriptCommand.id,
15915
+ SetInlineFormatTextColorCommand.id,
15916
+ SetInlineFormatTextBackgroundColorCommand.id
15917
+ ];
15918
+ function resolveFloatToolbarMenus(menuManagerService, avaliableMenus) {
15919
+ const floatToolbarMenus = menuManagerService.getMenuByPositionKey(FLOAT_TOOLBAR_MENU_POSITION);
15920
+ const flatMenus = [...menuManagerService.getFlatMenuByPositionKey(FLOAT_TOOLBAR_MENU_POSITION), ...menuManagerService.getFlatMenuByPositionKey(MenuManagerPosition.RIBBON)];
15921
+ const menus = [];
15922
+ for (const key of avaliableMenus) {
15923
+ const item = flatMenus.find((item) => item.key === key);
15924
+ if (item) menus.push(item);
15925
+ }
15926
+ return {
15927
+ menus,
15928
+ extraMenus: floatToolbarMenus.filter((item) => item.item && !avaliableMenus.includes(item.key))
15929
+ };
15930
+ }
15931
+ function FloatToolbar(props) {
15932
+ const { avaliableMenus = DEFAULT_AVALIABLE_MENUS } = props;
15933
+ const menuManagerService = useDependency(IMenuManagerService);
15934
+ const [menus, setMenus] = useState([]);
15935
+ const [extraMenus, setExtraMenus] = useState([]);
15936
+ useEffect(() => {
15937
+ function getRibbon() {
15938
+ const { menus, extraMenus } = resolveFloatToolbarMenus(menuManagerService, avaliableMenus);
15939
+ setMenus(menus);
15940
+ setExtraMenus(extraMenus);
15941
+ }
15942
+ getRibbon();
15943
+ const subscription = menuManagerService.menuChanged$.subscribe(getRibbon);
15944
+ return () => {
15945
+ subscription.unsubscribe();
15946
+ };
15947
+ }, [avaliableMenus, menuManagerService]);
15948
+ return /* @__PURE__ */ jsxs("div", {
15949
+ className: clsx("univer-box-border univer-flex univer-rounded univer-bg-white univer-py-1.5 univer-shadow-sm dark:!univer-border-gray-700 dark:!univer-bg-gray-900", borderClassName),
15950
+ children: [
15951
+ menus.map((groupItem) => groupItem.item && /* @__PURE__ */ jsx("div", {
15952
+ className: "univer-flex univer-flex-nowrap univer-gap-2 univer-px-2",
15953
+ children: /* @__PURE__ */ jsx(ToolbarItem, { ...groupItem.item }, groupItem.key)
15954
+ }, groupItem.key)),
15955
+ extraMenus.length > 0 && /* @__PURE__ */ jsx("div", { className: "univer-my-1 univer-w-px univer-bg-gray-200 dark:univer-bg-gray-700" }),
15956
+ extraMenus.map((groupItem) => groupItem.item && /* @__PURE__ */ jsx("div", {
15957
+ className: "univer-flex univer-flex-nowrap univer-gap-2 univer-px-2",
15958
+ children: /* @__PURE__ */ jsx(ToolbarItem, { ...groupItem.item }, groupItem.key)
15959
+ }, groupItem.key))
15960
+ ]
15961
+ });
15962
+ }
15963
+
15792
15964
  //#endregion
15793
15965
  //#region src/utils/section-header-footer.ts
15794
15966
  function getDocPageSectionContext(snapshot, page) {
@@ -16029,20 +16201,9 @@ const DocHeaderFooterPanel = () => {
16029
16201
  const renderManagerService = useDependency(IRenderManagerService);
16030
16202
  const unitId = useDependency(IUniverInstanceService).getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC).getUnitId();
16031
16203
  const viewModel = ((_renderManagerService = renderManagerService.getRenderUnitById(unitId)) === null || _renderManagerService === void 0 ? void 0 : _renderManagerService.with(DocSkeletonManagerService)).getViewModel();
16032
- const [isEditHeaderFooter, setIsEditHeaderFooter] = useState(true);
16033
- useEffect(() => {
16034
- setIsEditHeaderFooter(viewModel.getEditArea() !== DocumentEditArea.BODY);
16035
- const subscription = viewModel.editAreaChange$.subscribe((editArea) => {
16036
- if (editArea == null) return;
16037
- setIsEditHeaderFooter(editArea !== DocumentEditArea.BODY);
16038
- });
16039
- return () => {
16040
- subscription.unsubscribe();
16041
- };
16042
- }, []);
16043
16204
  return /* @__PURE__ */ jsx("div", {
16044
16205
  className: "univer-text-sm",
16045
- children: isEditHeaderFooter ? /* @__PURE__ */ jsx(DocHeaderFooterOptions, { unitId }) : /* @__PURE__ */ jsx("div", {
16206
+ children: useObservable(() => viewModel.editAreaChange$.pipe(filter((editArea) => editArea != null), map((editArea) => editArea !== DocumentEditArea.BODY)), viewModel.getEditArea() !== DocumentEditArea.BODY, false, [viewModel]) ? /* @__PURE__ */ jsx(DocHeaderFooterOptions, { unitId }) : /* @__PURE__ */ jsx("div", {
16046
16207
  className: "univer-text-gray-400",
16047
16208
  children: localeService.t("docs-ui.headerFooter.disableText")
16048
16209
  })
@@ -16176,8 +16337,7 @@ function createTextColorSwatchIcon(color) {
16176
16337
  function createBackgroundColorSwatchIcon(index) {
16177
16338
  return function DocParagraphBackgroundColorSwatchIcon(props) {
16178
16339
  const themeService = useDependency(ThemeService);
16179
- useObservable(themeService.currentTheme$);
16180
- const color = getHighlightBackgroundColor(themeService, index);
16340
+ const color = useObservable(() => themeService.currentTheme$.pipe(map(() => getHighlightBackgroundColor(themeService, index))), getHighlightBackgroundColor(themeService, index), false, [index, themeService]);
16181
16341
  return /* @__PURE__ */ jsx(BackgroundColorSwatchIcon, {
16182
16342
  ...props,
16183
16343
  color
@@ -16731,69 +16891,8 @@ function ParagraphSettingIndex() {
16731
16891
  return /* @__PURE__ */ jsx(ParagraphSetting, {}, key);
16732
16892
  }
16733
16893
 
16734
- //#endregion
16735
- //#region src/views/float-toolbar/FloatToolbar.tsx
16736
- const DEFAULT_AVALIABLE_MENUS = [
16737
- FLOAT_TEXT_STYLE_MENU_ID,
16738
- SetInlineFormatFontSizeCommand.id,
16739
- SetInlineFormatBoldCommand.id,
16740
- SetInlineFormatItalicCommand.id,
16741
- SetInlineFormatUnderlineCommand.id,
16742
- SetInlineFormatStrikethroughCommand.id,
16743
- SetInlineFormatSubscriptCommand.id,
16744
- SetInlineFormatSuperscriptCommand.id,
16745
- SetInlineFormatTextColorCommand.id,
16746
- SetInlineFormatTextBackgroundColorCommand.id
16747
- ];
16748
- function resolveFloatToolbarMenus(menuManagerService, avaliableMenus) {
16749
- const floatToolbarMenus = menuManagerService.getMenuByPositionKey(FLOAT_TOOLBAR_MENU_POSITION);
16750
- const flatMenus = [...menuManagerService.getFlatMenuByPositionKey(FLOAT_TOOLBAR_MENU_POSITION), ...menuManagerService.getFlatMenuByPositionKey(MenuManagerPosition.RIBBON)];
16751
- const menus = [];
16752
- for (const key of avaliableMenus) {
16753
- const item = flatMenus.find((item) => item.key === key);
16754
- if (item) menus.push(item);
16755
- }
16756
- return {
16757
- menus,
16758
- extraMenus: floatToolbarMenus.filter((item) => item.item && !avaliableMenus.includes(item.key))
16759
- };
16760
- }
16761
- function FloatToolbar(props) {
16762
- const { avaliableMenus = DEFAULT_AVALIABLE_MENUS } = props;
16763
- const menuManagerService = useDependency(IMenuManagerService);
16764
- const [menus, setMenus] = useState([]);
16765
- const [extraMenus, setExtraMenus] = useState([]);
16766
- useEffect(() => {
16767
- function getRibbon() {
16768
- const { menus, extraMenus } = resolveFloatToolbarMenus(menuManagerService, avaliableMenus);
16769
- setMenus(menus);
16770
- setExtraMenus(extraMenus);
16771
- }
16772
- getRibbon();
16773
- const subscription = menuManagerService.menuChanged$.subscribe(getRibbon);
16774
- return () => {
16775
- subscription.unsubscribe();
16776
- };
16777
- }, [avaliableMenus, menuManagerService]);
16778
- return /* @__PURE__ */ jsxs("div", {
16779
- className: clsx("univer-box-border univer-flex univer-rounded univer-bg-white univer-py-1.5 univer-shadow-sm dark:!univer-border-gray-700 dark:!univer-bg-gray-900", borderClassName),
16780
- children: [
16781
- menus.map((groupItem) => groupItem.item && /* @__PURE__ */ jsx("div", {
16782
- className: "univer-flex univer-flex-nowrap univer-gap-2 univer-px-2",
16783
- children: /* @__PURE__ */ jsx(ToolbarItem, { ...groupItem.item }, groupItem.key)
16784
- }, groupItem.key)),
16785
- extraMenus.length > 0 && /* @__PURE__ */ jsx("div", { className: "univer-my-1 univer-w-px univer-bg-gray-200 dark:univer-bg-gray-700" }),
16786
- extraMenus.map((groupItem) => groupItem.item && /* @__PURE__ */ jsx("div", {
16787
- className: "univer-flex univer-flex-nowrap univer-gap-2 univer-px-2",
16788
- children: /* @__PURE__ */ jsx(ToolbarItem, { ...groupItem.item }, groupItem.key)
16789
- }, groupItem.key))
16790
- ]
16791
- });
16792
- }
16793
-
16794
16894
  //#endregion
16795
16895
  //#region src/services/float-menu.service.ts
16796
- const FLOAT_MENU_COMPONENT_KEY = "univer.doc.float-menu";
16797
16896
  function isInSameLine(startNodePosition, endNodePosition) {
16798
16897
  if (startNodePosition == null || endNodePosition == null) return false;
16799
16898
  const { glyph: _startGlyph, ...startRest } = startNodePosition;
@@ -16802,17 +16901,15 @@ function isInSameLine(startNodePosition, endNodePosition) {
16802
16901
  }
16803
16902
  const SKIP_SYMBOLS = [DataStreamTreeTokenType.CUSTOM_BLOCK, DataStreamTreeTokenType.PARAGRAPH];
16804
16903
  let DocFloatMenuService = class DocFloatMenuService extends Disposable {
16805
- constructor(_context, _docSelectionManagerService, _docCanvasPopManagerService, _componentManager, _univerInstanceService, _docSelectionRenderService) {
16904
+ constructor(_context, _docSelectionManagerService, _docCanvasPopManagerService, _univerInstanceService, _docSelectionRenderService) {
16806
16905
  super();
16807
16906
  this._context = _context;
16808
16907
  this._docSelectionManagerService = _docSelectionManagerService;
16809
16908
  this._docCanvasPopManagerService = _docCanvasPopManagerService;
16810
- this._componentManager = _componentManager;
16811
16909
  this._univerInstanceService = _univerInstanceService;
16812
16910
  this._docSelectionRenderService = _docSelectionRenderService;
16813
16911
  _defineProperty(this, "_floatMenu", null);
16814
16912
  if (isInternalEditorID(this._context.unitId)) return;
16815
- this._registerFloatMenu();
16816
16913
  this._initSelectionChange();
16817
16914
  this.disposeWithMe(() => {
16818
16915
  this._hideFloatMenu();
@@ -16824,9 +16921,6 @@ let DocFloatMenuService = class DocFloatMenuService extends Disposable {
16824
16921
  hideFloatMenu() {
16825
16922
  this._hideFloatMenu();
16826
16923
  }
16827
- _registerFloatMenu() {
16828
- this.disposeWithMe(this._componentManager.register(FLOAT_MENU_COMPONENT_KEY, FloatToolbar));
16829
- }
16830
16924
  _initSelectionChange() {
16831
16925
  this.disposeWithMe(this._docSelectionRenderService.onSelectionStart$.subscribe(() => {
16832
16926
  this._hideFloatMenu();
@@ -16874,9 +16968,8 @@ let DocFloatMenuService = class DocFloatMenuService extends Disposable {
16874
16968
  DocFloatMenuService = __decorate([
16875
16969
  __decorateParam(1, Inject(DocSelectionManagerService)),
16876
16970
  __decorateParam(2, Inject(DocCanvasPopManagerService)),
16877
- __decorateParam(3, Inject(ComponentManager)),
16878
- __decorateParam(4, Inject(IUniverInstanceService)),
16879
- __decorateParam(5, Inject(DocSelectionRenderService))
16971
+ __decorateParam(3, Inject(IUniverInstanceService)),
16972
+ __decorateParam(4, Inject(DocSelectionRenderService))
16880
16973
  ], DocFloatMenuService);
16881
16974
  function isRangeInCodeBlock(documentDataModel, range) {
16882
16975
  var _documentDataModel$ge3, _documentDataModel$ge4;
@@ -18325,8 +18418,8 @@ function ParagraphMenuBase({ popup, tableBlockOnly = false }) {
18325
18418
  children: [/* @__PURE__ */ jsx(TargetIcon, {}), (currentActiveTarget === null || currentActiveTarget === void 0 ? void 0 : currentActiveTarget.draggable) && /* @__PURE__ */ jsx("button", {
18326
18419
  type: "button",
18327
18420
  className: "univer-group univer-flex univer-h-4 univer-w-2.5 univer-cursor-grab univer-items-center univer-justify-center univer-border-none univer-bg-transparent univer-p-0 active:univer-cursor-grabbing",
18328
- "aria-label": "Drag block",
18329
- title: "Drag block",
18421
+ "aria-label": localeService.t("docs-ui.doc.blockMenu.dragBlock"),
18422
+ title: localeService.t("docs-ui.doc.blockMenu.dragBlock"),
18330
18423
  onPointerDown: (event) => {
18331
18424
  var _docParagraphMenuServ4, _event$currentTarget$, _event$currentTarget;
18332
18425
  const latestTarget = (_docParagraphMenuServ4 = docParagraphMenuService === null || docParagraphMenuService === void 0 ? void 0 : docParagraphMenuService.activeTarget) !== null && _docParagraphMenuServ4 !== void 0 ? _docParagraphMenuServ4 : activeTarget;
@@ -18580,10 +18673,8 @@ function useSectionSetting() {
18580
18673
  const instanceService = useDependency(IUniverInstanceService);
18581
18674
  const selectionManager = useDependency(DocSelectionManagerService);
18582
18675
  const documentDataModel = useObservable(useMemo(() => instanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_DOC), [instanceService]));
18583
- useObservable(selectionManager.textSelection$);
18584
- useObservable(documentDataModel === null || documentDataModel === void 0 ? void 0 : documentDataModel.change$);
18585
- const ranges = selectionManager.getDocRanges();
18586
- const sections = (documentDataModel === null || documentDataModel === void 0 ? void 0 : documentDataModel.getDocumentStyle().documentFlavor) === DocumentFlavor.TRADITIONAL ? getSelectedSections(documentDataModel, ranges) : [];
18676
+ const resolveSections = () => (documentDataModel === null || documentDataModel === void 0 ? void 0 : documentDataModel.getDocumentStyle().documentFlavor) === DocumentFlavor.TRADITIONAL ? getSelectedSections(documentDataModel, selectionManager.getDocRanges()) : [];
18677
+ const sections = useObservable(documentDataModel ? () => combineLatest([selectionManager.textSelection$.pipe(startWith(void 0)), documentDataModel.change$.pipe(startWith(void 0))]).pipe(map(resolveSections)) : null, resolveSections(), false, [documentDataModel, selectionManager]);
18587
18678
  const values = getSectionSettingValues(sections);
18588
18679
  const update = (updates) => {
18589
18680
  if (!documentDataModel || updates.length === 0) return Promise.resolve(false);
@@ -18636,6 +18727,24 @@ function SectionSetting() {
18636
18727
  const localeService = useDependency(LocaleService);
18637
18728
  const controller = useDependency(DocSectionSettingController);
18638
18729
  const setting = useSectionSetting();
18730
+ const labels = useMemo(() => ({
18731
+ selectedSections: localeService.t("docs-ui.doc.sectionSetting.selectedSections", String(setting.selectedCount)),
18732
+ columnCount: localeService.t("docs-ui.doc.sectionSetting.columnCount"),
18733
+ columnGap: `${localeService.t("docs-ui.doc.sectionSetting.columnGap")}(px)`,
18734
+ columnSeparator: localeService.t("docs-ui.doc.sectionSetting.columnSeparator"),
18735
+ none: localeService.t("docs-ui.doc.sectionSetting.none"),
18736
+ betweenColumns: localeService.t("docs-ui.doc.sectionSetting.betweenColumns"),
18737
+ sectionStart: localeService.t("docs-ui.doc.sectionSetting.sectionStart"),
18738
+ unspecified: localeService.t("docs-ui.doc.sectionSetting.unspecified"),
18739
+ continuous: localeService.t("docs-ui.doc.sectionSetting.continuous"),
18740
+ nextPage: localeService.t("docs-ui.doc.sectionSetting.nextPage"),
18741
+ evenPage: localeService.t("docs-ui.doc.sectionSetting.evenPage"),
18742
+ oddPage: localeService.t("docs-ui.doc.sectionSetting.oddPage")
18743
+ }), [
18744
+ useObservable(localeService.currentLocale$),
18745
+ localeService,
18746
+ setting.selectedCount
18747
+ ]);
18639
18748
  useEffect(() => {
18640
18749
  if (!setting.valid) controller.closePanel();
18641
18750
  }, [controller, setting.valid]);
@@ -18644,12 +18753,12 @@ function SectionSetting() {
18644
18753
  className: "univer-box-border univer-w-full",
18645
18754
  children: [setting.selectedCount > 1 && /* @__PURE__ */ jsx("div", {
18646
18755
  className: "univer-mb-4 univer-text-xs univer-text-gray-600 dark:!univer-text-gray-300",
18647
- children: localeService.t("docs-ui.doc.sectionSetting.selectedSections", String(setting.selectedCount))
18756
+ children: labels.selectedSections
18648
18757
  }), /* @__PURE__ */ jsxs("div", {
18649
18758
  className: "univer-grid univer-gap-3",
18650
18759
  children: [
18651
18760
  /* @__PURE__ */ jsx(SettingRow, {
18652
- label: localeService.t("docs-ui.doc.sectionSetting.columnCount"),
18761
+ label: labels.columnCount,
18653
18762
  children: /* @__PURE__ */ jsx(InputNumber, {
18654
18763
  className: "univer-w-full",
18655
18764
  min: 1,
@@ -18661,7 +18770,7 @@ function SectionSetting() {
18661
18770
  })
18662
18771
  }),
18663
18772
  /* @__PURE__ */ jsx(SettingRow, {
18664
- label: `${localeService.t("docs-ui.doc.sectionSetting.columnGap")}(px)`,
18773
+ label: labels.columnGap,
18665
18774
  children: /* @__PURE__ */ jsx(InputNumber, {
18666
18775
  className: "univer-w-full",
18667
18776
  min: 0,
@@ -18673,44 +18782,44 @@ function SectionSetting() {
18673
18782
  })
18674
18783
  }),
18675
18784
  /* @__PURE__ */ jsx(SettingRow, {
18676
- label: localeService.t("docs-ui.doc.sectionSetting.columnSeparator"),
18785
+ label: labels.columnSeparator,
18677
18786
  children: /* @__PURE__ */ jsx(Select, {
18678
18787
  className: "univer-w-full",
18679
18788
  value: setting.separatorType == null ? "" : String(setting.separatorType),
18680
18789
  options: [{
18681
- label: localeService.t("docs-ui.doc.sectionSetting.none"),
18790
+ label: labels.none,
18682
18791
  value: String(ColumnSeparatorType.NONE)
18683
18792
  }, {
18684
- label: localeService.t("docs-ui.doc.sectionSetting.betweenColumns"),
18793
+ label: labels.betweenColumns,
18685
18794
  value: String(ColumnSeparatorType.BETWEEN_EACH_COLUMN)
18686
18795
  }],
18687
18796
  onChange: (value) => setting.setSeparatorType(Number(value))
18688
18797
  })
18689
18798
  }),
18690
18799
  /* @__PURE__ */ jsx(SettingRow, {
18691
- label: localeService.t("docs-ui.doc.sectionSetting.sectionStart"),
18800
+ label: labels.sectionStart,
18692
18801
  children: /* @__PURE__ */ jsx(Select, {
18693
18802
  className: "univer-w-full",
18694
18803
  value: setting.sectionType == null ? "" : String(setting.sectionType),
18695
18804
  options: [
18696
18805
  {
18697
- label: localeService.t("docs-ui.doc.sectionSetting.unspecified"),
18806
+ label: labels.unspecified,
18698
18807
  value: String(SectionType.SECTION_TYPE_UNSPECIFIED)
18699
18808
  },
18700
18809
  {
18701
- label: localeService.t("docs-ui.doc.sectionSetting.continuous"),
18810
+ label: labels.continuous,
18702
18811
  value: String(SectionType.CONTINUOUS)
18703
18812
  },
18704
18813
  {
18705
- label: localeService.t("docs-ui.doc.sectionSetting.nextPage"),
18814
+ label: labels.nextPage,
18706
18815
  value: String(SectionType.NEXT_PAGE)
18707
18816
  },
18708
18817
  {
18709
- label: localeService.t("docs-ui.doc.sectionSetting.evenPage"),
18818
+ label: labels.evenPage,
18710
18819
  value: String(SectionType.EVEN_PAGE)
18711
18820
  },
18712
18821
  {
18713
- label: localeService.t("docs-ui.doc.sectionSetting.oddPage"),
18822
+ label: labels.oddPage,
18714
18823
  value: String(SectionType.ODD_PAGE)
18715
18824
  }
18716
18825
  ],
@@ -18726,7 +18835,6 @@ function SectionSetting() {
18726
18835
  //#region src/views/section-setting/index.tsx
18727
18836
  function SectionSettingIndex() {
18728
18837
  const commandService = useDependency(ICommandService);
18729
- useObservable(useDependency(LocaleService).currentLocale$);
18730
18838
  const [key, setKey] = useState(() => generateRandomId(4));
18731
18839
  useEffect(() => {
18732
18840
  const disposable = commandService.onCommandExecuted((info) => {
@@ -18825,6 +18933,7 @@ let ComponentsController = class ComponentsController extends Disposable {
18825
18933
  DeleteColumnDoubleIcon,
18826
18934
  DeleteIcon,
18827
18935
  DeleteRowDoubleIcon,
18936
+ DeleteTableDoubleIcon,
18828
18937
  DocSettingIcon,
18829
18938
  FontColorDoubleIcon,
18830
18939
  GridIcon,
@@ -18901,6 +19010,7 @@ let ComponentsController = class ComponentsController extends Disposable {
18901
19010
  [ORDER_LIST_TYPE_COMPONENT, OrderListTypePicker],
18902
19011
  [DOC_PARAGRAPH_MENU_COMPONENT_KEY, ParagraphMenu],
18903
19012
  [DOC_TABLE_BLOCK_MENU_COMPONENT_KEY, TableBlockMenu],
19013
+ [FLOAT_MENU_COMPONENT_KEY, FloatToolbar],
18904
19014
  [PAGE_SETTING_COMPONENT_ID, PageSettings]
18905
19015
  ].forEach(([key, comp]) => {
18906
19016
  this.disposeWithMe(this._componentManager.register(key, comp));
@@ -21164,13 +21274,12 @@ const H5HeadingShortcut = headingShortcut(H5HeadingCommand.id, KeyCode.Digit5);
21164
21274
  //#endregion
21165
21275
  //#region src/plugin.ts
21166
21276
  let UniverDocsUIPlugin = class UniverDocsUIPlugin extends Plugin {
21167
- constructor(_config = defaultPluginConfig, _injector, _renderManagerSrv, _commandService, _logService, _configService) {
21277
+ constructor(_config = defaultPluginConfig, _injector, _renderManagerSrv, _commandService, _configService) {
21168
21278
  super();
21169
21279
  this._config = _config;
21170
21280
  this._injector = _injector;
21171
21281
  this._renderManagerSrv = _renderManagerSrv;
21172
21282
  this._commandService = _commandService;
21173
- this._logService = _logService;
21174
21283
  this._configService = _configService;
21175
21284
  const { menu, ...rest } = merge({}, defaultPluginConfig, this._config);
21176
21285
  if (menu) this._configService.setConfig("menu", menu, { merge: true });
@@ -21181,7 +21290,7 @@ let UniverDocsUIPlugin = class UniverDocsUIPlugin extends Plugin {
21181
21290
  }
21182
21291
  onReady() {
21183
21292
  this._initRenderBasics();
21184
- this._markDocAsFocused();
21293
+ this._initAutoFocus();
21185
21294
  touchDependencies(this._injector, [[DocsRenderService]]);
21186
21295
  }
21187
21296
  onRendered() {
@@ -21361,19 +21470,14 @@ let UniverDocsUIPlugin = class UniverDocsUIPlugin extends Plugin {
21361
21470
  [DocMenuStyleService]
21362
21471
  ], this._config.override).forEach((d) => injector.add(d));
21363
21472
  }
21364
- _markDocAsFocused() {
21473
+ _initAutoFocus() {
21365
21474
  const currentService = this._injector.get(IUniverInstanceService);
21366
21475
  const editorService = this._injector.get(IEditorService);
21367
- try {
21368
- const doc = currentService.getCurrentUnitOfType(UniverInstanceType.UNIVER_DOC);
21476
+ this.disposeWithMe(currentService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_DOC).subscribe((doc) => {
21369
21477
  if (!doc) return;
21370
21478
  const id = doc.getUnitId();
21371
- const createOptions = currentService.getUnitCreateOptions(id);
21372
- if ((createOptions === null || createOptions === void 0 ? void 0 : createOptions.makeCurrent) === false) return;
21373
- if (!editorService.isEditor(id)) currentService.focusUnit(doc.getUnitId());
21374
- } catch (err) {
21375
- this._logService.warn(err);
21376
- }
21479
+ if (!editorService.isEditor(id)) currentService.focusUnit(id);
21480
+ }));
21377
21481
  }
21378
21482
  _initRenderBasics() {
21379
21483
  [
@@ -21418,8 +21522,7 @@ UniverDocsUIPlugin = __decorate([
21418
21522
  __decorateParam(1, Inject(Injector)),
21419
21523
  __decorateParam(2, IRenderManagerService),
21420
21524
  __decorateParam(3, ICommandService),
21421
- __decorateParam(4, ILogService),
21422
- __decorateParam(5, IConfigService)
21525
+ __decorateParam(4, IConfigService)
21423
21526
  ], UniverDocsUIPlugin);
21424
21527
 
21425
21528
  //#endregion
@@ -21875,6 +21978,7 @@ const useResize = (editor, isSingle = true, autoScrollbar, autoScroll) => {
21875
21978
  //#endregion
21876
21979
  //#region src/views/RichTextEditor.tsx
21877
21980
  const RichTextEditor = (props) => {
21981
+ var _docSelectionRenderSe3;
21878
21982
  const { className, autoFocus, onFocusChange: _onFocusChange, initialValue, onClickOutside: _onClickOutside, keyboardEventConfig, moveCursor = true, style, isSingle, editorId: propsEditorId, onHeightChange, onChange: _onChange, defaultHeight = 32, maxHeight = 32, icon, editorRef, placeholder, noStyle } = props;
21879
21983
  useDependency(IEditorService);
21880
21984
  const commandService = useDependency(ICommandService);
@@ -21892,12 +21996,22 @@ const RichTextEditor = (props) => {
21892
21996
  isSingle
21893
21997
  });
21894
21998
  const renderer = useDependency(IRenderManagerService).getRenderById(editorId);
21895
- const isFocusing = useIsFocusing(editorId);
21999
+ const selectionIsFocusing = useIsFocusing(editorId);
22000
+ const docSelectionRenderService = renderer === null || renderer === void 0 ? void 0 : renderer.with(DocSelectionRenderService);
22001
+ const editorFocused = useObservable(editor ? () => {
22002
+ var _docSelectionRenderSe2;
22003
+ return merge$1(editor.focus$, editor.blur$).pipe(map(() => {
22004
+ var _docSelectionRenderSe;
22005
+ return (_docSelectionRenderSe = docSelectionRenderService === null || docSelectionRenderService === void 0 ? void 0 : docSelectionRenderService.isFocusing) !== null && _docSelectionRenderSe !== void 0 ? _docSelectionRenderSe : false;
22006
+ }), startWith((_docSelectionRenderSe2 = docSelectionRenderService === null || docSelectionRenderService === void 0 ? void 0 : docSelectionRenderService.isFocusing) !== null && _docSelectionRenderSe2 !== void 0 ? _docSelectionRenderSe2 : false));
22007
+ } : null, (_docSelectionRenderSe3 = docSelectionRenderService === null || docSelectionRenderService === void 0 ? void 0 : docSelectionRenderService.isFocusing) !== null && _docSelectionRenderSe3 !== void 0 ? _docSelectionRenderSe3 : false, false, [docSelectionRenderService, editor]);
22008
+ const isFocusing = selectionIsFocusing && editorFocused;
21896
22009
  const sheetEmbeddingRef = useRef(null);
21897
- const [showPlaceholder, setShowPlaceholder] = useState(() => {
22010
+ const resolveShowPlaceholder = () => {
21898
22011
  var _editor$getDocumentDa, _editor$getDocumentDa2;
21899
22012
  return !BuildTextUtils.transform.getPlainText((_editor$getDocumentDa = editor === null || editor === void 0 || (_editor$getDocumentDa2 = editor.getDocumentData().body) === null || _editor$getDocumentDa2 === void 0 ? void 0 : _editor$getDocumentDa2.dataStream) !== null && _editor$getDocumentDa !== void 0 ? _editor$getDocumentDa : "");
21900
- });
22013
+ };
22014
+ const showPlaceholder = useObservable(editor ? () => editor.selectionChange$.pipe(map(resolveShowPlaceholder), startWith(resolveShowPlaceholder())) : null, resolveShowPlaceholder(), false, [editor]);
21901
22015
  const { checkScrollBar } = useResize(editor, isSingle, true, true);
21902
22016
  useLayoutEffect(() => {
21903
22017
  if (!editorRef || !editor) return;
@@ -21918,17 +22032,6 @@ const RichTextEditor = (props) => {
21918
22032
  _onChange === null || _onChange === void 0 || _onChange(data, getPlainText((_data$body$dataStream = (_data$body = data.body) === null || _data$body === void 0 ? void 0 : _data$body.dataStream) !== null && _data$body$dataStream !== void 0 ? _data$body$dataStream : ""));
21919
22033
  checkScrollBar();
21920
22034
  });
21921
- useEffect(() => {
21922
- var _editor$getDocumentDa3, _editor$getDocumentDa4;
21923
- setShowPlaceholder(!BuildTextUtils.transform.getPlainText((_editor$getDocumentDa3 = editor === null || editor === void 0 || (_editor$getDocumentDa4 = editor.getDocumentData().body) === null || _editor$getDocumentDa4 === void 0 ? void 0 : _editor$getDocumentDa4.dataStream) !== null && _editor$getDocumentDa3 !== void 0 ? _editor$getDocumentDa3 : ""));
21924
- const sub = editor === null || editor === void 0 ? void 0 : editor.selectionChange$.subscribe(() => {
21925
- var _editor$getDocumentDa5, _editor$getDocumentDa6;
21926
- setShowPlaceholder(!BuildTextUtils.transform.getPlainText((_editor$getDocumentDa5 = editor === null || editor === void 0 || (_editor$getDocumentDa6 = editor.getDocumentData().body) === null || _editor$getDocumentDa6 === void 0 ? void 0 : _editor$getDocumentDa6.dataStream) !== null && _editor$getDocumentDa5 !== void 0 ? _editor$getDocumentDa5 : ""));
21927
- });
21928
- return () => sub === null || sub === void 0 ? void 0 : sub.unsubscribe();
21929
- }, [editor]);
21930
- useObservable(editor === null || editor === void 0 ? void 0 : editor.blur$);
21931
- useObservable(editor === null || editor === void 0 ? void 0 : editor.focus$);
21932
22035
  useEffect(() => {
21933
22036
  var _data$body$dataStream2, _data$body2;
21934
22037
  const data = editor === null || editor === void 0 ? void 0 : editor.getDocumentData();
@@ -21979,4 +22082,4 @@ const RichTextEditor = (props) => {
21979
22082
  };
21980
22083
 
21981
22084
  //#endregion
21982
- export { AfterSpaceCommand, AlignCenterCommand, AlignJustifyCommand, AlignLeftCommand, AlignMenuItemFactory, AlignOperationCommand, AlignRightCommand, BackgroundColorSelectorMenuItemFactory, BoldMenuItemFactory, BreakLineCommand, BulletListCommand, ChangeListNestingLevelCommand, ChangeListNestingLevelType, ChangeListTypeCommand, CheckListCommand, CoverContentCommand, CreateDocTableCommand, CutContentCommand, DEFAULT_DOC_FIT_TO_WIDTH_OPTIONS, DOCS_COMPONENT_BACKGROUND_LAYER_INDEX, DOCS_COMPONENT_DEFAULT_Z_INDEX, DOCS_COMPONENT_HEADER_LAYER_INDEX, DOCS_COMPONENT_MAIN_LAYER_INDEX, DOCS_UI_PLUGIN_CONFIG_KEY, DOCS_VIEW_KEY, DOC_CONTENT_INSERT_MENU_ID, DOC_EMBED_INTERACTION_BOUNDARY_OWNER_ATTRIBUTE, DOC_PARAGRAPH_T_ALIGN_MENU_ID, DOC_PARAGRAPH_T_COLORS_MENU_ID, DOC_PARAGRAPH_T_DIVIDER_MENU_ID, DOC_PARAGRAPH_T_EDIT_MENU_ID, DOC_PARAGRAPH_T_INSERT_BELOW_MENU_ID, DOC_PARAGRAPH_T_INSERT_MENU_ID, DOC_TABLE_BLOCK_MENU_ID, DOC_VERTICAL_PADDING, DeleteCurrentParagraphCommand, DeleteCustomBlockCommand, DeleteLeftCommand, DeleteRightCommand, DocAutoFormatService, DocBackScrollRenderController, DocCanvasPopManagerService, DocClipboardPasteAdapterService, DocCopyCommand, DocCreateTableOperation, DocCutCommand, DocEventManagerService, DocFloatMenuService, DocHtmlExportService, DocIMEInputManagerService, DocPageLayoutService, DocParagraphMenuService, DocParagraphPlaceholderRenderController, DocPasteCommand, DocPrintInterceptorService, DocRenderController, DocSelectAllCommand, DocSelectionRenderService, DocTableDeleteColumnsCommand, DocTableDeleteRowsCommand, DocTableDeleteTableCommand, DocTableInsertColumnCommand, DocTableInsertColumnLeftCommand, DocTableInsertColumnRightCommand, DocTableInsertRowAboveCommand, DocTableInsertRowBellowCommand, DocTableInsertRowCommand, DocTableTabCommand, DocUIController, DocViewScaleService, DocsRenderService, menuSchema as DocsUIMenuSchema, EMBED_DOCS_CUSTOM_BLOCK_DEFAULT_COMPONENT_KEY, EMPTY_PARAGRAPH_MENU_ID, Editor, EditorService, EnterCommand, FLOAT_TEXT_STYLE_MENU_ID, FLOAT_TOOLBAR_MENU_POSITION, FloatTextStyleMenuItemFactory, FontFamilySelectorMenuItemFactory, FontSizeSelectorMenuItemFactory, HorizontalLineCommand, IDocClipboardPasteAdapterService, IDocClipboardService, IDocEmbedInteractionBoundaryService, IDocEmbedRuntimeFocusCoordinator, IEditorService, IMEInputCommand, INSERT_BELLOW_MENU_ID, InnerPasteCommand, InsertCustomRangeCommand, ItalicMenuItemFactory, ListOperationCommand, MergeTwoParagraphCommand, MoveCursorOperation, MoveDocBlockCommand, MoveSelectionOperation, NORMAL_TEXT_SELECTION_PLUGIN_NAME, NodePositionConvertToCursor, NodePositionConvertToRectRange, OrderListCommand, ParagraphMenuInsertBelowSubmenuItemFactory, LarkPastePlugin as PastePluginLark, UniverPastePlugin as PastePluginUniver, WordPastePlugin as PastePluginWord, QuickListCommand, RectRange, ReplaceContentCommand, ReplaceSelectionCommand, ReplaceSnapshotCommand, ReplaceTextRunsCommand, ResetInlineFormatTextBackgroundColorCommand, ResetInlineFormatTextColorCommand, RichTextEditor, SetDocZoomRatioCommand, SetDocZoomRatioOperation, SetInlineFormatBoldCommand, SetInlineFormatCommand, SetInlineFormatFontFamilyCommand, SetInlineFormatFontSizeCommand, SetInlineFormatItalicCommand, SetInlineFormatStrikethroughCommand, SetInlineFormatSubscriptCommand, SetInlineFormatSuperscriptCommand, SetInlineFormatTextBackgroundColorCommand, SetInlineFormatTextColorCommand, SetInlineFormatTextFillCommand, SetInlineFormatUnderlineCommand, SetParagraphNamedStyleCommand, StrikeThroughMenuItemFactory, SwitchDocModeCommand, TEXT_RANGE_LAYER_INDEX, TabCommand, TextColorSelectorMenuItemFactory, TextRange, ToggleCheckListCommand, UnderlineMenuItemFactory, UniverDocsUIPlugin, VIEWPORT_KEY, addCustomDecorationBySelectionFactory, addCustomDecorationFactory, buildMoveDocBlockActions, calcDocFitToWidthScale, calcDocRangePositions, collectDocsTableLikeEmbedChildUnitIds, convertBodyToHtml, convertPositionsToRectRanges, createDefaultDocsTableLikeCustomBlockBleedViewport, createDocsCustomBlockInsertMutation, createDocsCustomBlockRemoveMutation, createDocsCustomBlockSizeRefreshScheduler, createEditorUndoRedoKeyboardConfig, createEmbedDocsCustomBlockData, createInsertCustomBlockActions, createRemoveCustomBlockActions, deleteCustomDecorationFactory, disableMenuWhenHeaderFooterEditing, docDrawingPositionToTransform, executeEditorUndoRedoCommand, genTableSource, generateParagraphs, getAnchorBounding, getCanvasOffsetByEngine, getCommandSkeleton, getCursorWhenDelete, getCustomBlockIdsInSelections, getCutActionsFromDocRanges, getDocBlockRangeMenuId, getDocObject, getDocObjectById, getEmptyTableCell, getEmptyTableRow, getLineBounding, getListMarkerFallbackBound, getListParagraphContextMenuHit, getOneTextSelectionRange, getStyleInTextRange, getTableColumn, hasParagraphInTable, hideMenuWhenSelectionInBlockRange, isInSameTableCell, isSheetLikeDocsCustomBlockChildType, isTextRangeInAnyBlockRange, isValidRectRange, neoGetDocObject, normalizeDocFitToWidthOptions, resolveDocFitBaseWidth, resolveDocViewScale, resolveDocsCustomBlockRenderViewport, resolveDocsCustomBlockSize, resolveDocsTableLikeCustomBlockBleedViewport, resolveDocsTableLikeCustomBlockContentHeight, resolveDocsTableLikeCustomBlockContentWidth, scrollDocsTableLikeCustomBlockLive, shouldRefreshDocsCustomBlockSizeForCommand, transformToDocDrawingPosition, useEditor, useEditorClickOutside, useIsFocusing, useKeyboardEvent, useLeftAndRightArrow, useOnChange, useResize, whenDocAndEditorFocused };
22085
+ export { AfterSpaceCommand, AlignCenterCommand, AlignJustifyCommand, AlignLeftCommand, AlignMenuItemFactory, AlignOperationCommand, AlignRightCommand, BackgroundColorSelectorMenuItemFactory, BoldMenuItemFactory, BreakLineCommand, BulletListCommand, ChangeListNestingLevelCommand, ChangeListNestingLevelType, ChangeListTypeCommand, CheckListCommand, CoverContentCommand, CreateDocTableCommand, CutContentCommand, DEFAULT_DOC_FIT_TO_WIDTH_OPTIONS, DOCS_COMPONENT_BACKGROUND_LAYER_INDEX, DOCS_COMPONENT_DEFAULT_Z_INDEX, DOCS_COMPONENT_HEADER_LAYER_INDEX, DOCS_COMPONENT_MAIN_LAYER_INDEX, DOCS_UI_PLUGIN_CONFIG_KEY, DOCS_VIEW_KEY, DOC_CONTENT_INSERT_MENU_ID, DOC_EMBED_INTERACTION_BOUNDARY_OWNER_ATTRIBUTE, DOC_PARAGRAPH_T_ALIGN_MENU_ID, DOC_PARAGRAPH_T_COLORS_MENU_ID, DOC_PARAGRAPH_T_DIVIDER_MENU_ID, DOC_PARAGRAPH_T_EDIT_MENU_ID, DOC_PARAGRAPH_T_INSERT_BELOW_MENU_ID, DOC_PARAGRAPH_T_INSERT_MENU_ID, DOC_TABLE_BLOCK_MENU_ID, DOC_VERTICAL_PADDING, DeleteCurrentParagraphCommand, DeleteCustomBlockCommand, DeleteLeftCommand, DeleteRightCommand, DocAutoFormatService, DocBackScrollRenderController, DocCanvasPopManagerService, DocClipboardPasteAdapterService, DocCopyCommand, DocCreateTableOperation, DocCutCommand, DocEventManagerService, DocFloatMenuService, DocHtmlExportService, DocIMEInputManagerService, DocPageLayoutService, DocParagraphMenuService, DocParagraphPlaceholderRenderController, DocPasteCommand, DocPrintInterceptorService, DocRenderController, DocSelectAllCommand, DocSelectionRenderService, DocTableDeleteColumnsCommand, DocTableDeleteRowsCommand, DocTableDeleteTableCommand, DocTableInsertColumnCommand, DocTableInsertColumnLeftCommand, DocTableInsertColumnRightCommand, DocTableInsertRowAboveCommand, DocTableInsertRowBellowCommand, DocTableInsertRowCommand, DocTableTabCommand, DocUIController, DocViewScaleService, DocsRenderService, menuSchema as DocsUIMenuSchema, EMBED_DOCS_CUSTOM_BLOCK_DEFAULT_COMPONENT_KEY, EMPTY_PARAGRAPH_MENU_ID, Editor, EditorService, EnterCommand, FLOAT_TEXT_STYLE_MENU_ID, FLOAT_TOOLBAR_MENU_POSITION, FloatTextStyleMenuItemFactory, FontFamilySelectorMenuItemFactory, FontSizeSelectorMenuItemFactory, HorizontalLineCommand, IDocClipboardPasteAdapterService, IDocClipboardService, IDocEmbedInteractionBoundaryService, IDocEmbedRuntimeFocusCoordinator, IEditorService, IMEInputCommand, INSERT_BELLOW_MENU_ID, InnerPasteCommand, InsertCustomRangeCommand, ItalicMenuItemFactory, ListOperationCommand, MergeTwoParagraphCommand, MoveCursorOperation, MoveDocBlockCommand, MoveSelectionOperation, NORMAL_TEXT_SELECTION_PLUGIN_NAME, NodePositionConvertToCursor, NodePositionConvertToRectRange, OrderListCommand, ParagraphMenuInsertBelowSubmenuItemFactory, LarkPastePlugin as PastePluginLark, UniverPastePlugin as PastePluginUniver, WordPastePlugin as PastePluginWord, QuickListCommand, RectRange, ReplaceContentCommand, ReplaceSelectionCommand, ReplaceSnapshotCommand, ReplaceTextRunsCommand, ResetInlineFormatTextBackgroundColorCommand, ResetInlineFormatTextColorCommand, RichTextEditor, SetDocZoomRatioCommand, SetDocZoomRatioOperation, SetInlineFormatBoldCommand, SetInlineFormatCommand, SetInlineFormatFontFamilyCommand, SetInlineFormatFontSizeCommand, SetInlineFormatItalicCommand, SetInlineFormatStrikethroughCommand, SetInlineFormatSubscriptCommand, SetInlineFormatSuperscriptCommand, SetInlineFormatTextBackgroundColorCommand, SetInlineFormatTextColorCommand, SetInlineFormatTextFillCommand, SetInlineFormatUnderlineCommand, SetParagraphNamedStyleCommand, StrikeThroughMenuItemFactory, SwitchDocModeCommand, TEXT_RANGE_LAYER_INDEX, TabCommand, TextColorSelectorMenuItemFactory, TextRange, ToggleCheckListCommand, UnderlineMenuItemFactory, UniverDocsUIPlugin, VIEWPORT_KEY, addCustomDecorationBySelectionFactory, addCustomDecorationFactory, buildMoveDocBlockActions, calcDocFitToWidthScale, calcDocRangePositions, collectDocsTableLikeEmbedChildUnitIds, convertBodyToHtml, convertPositionsToRectRanges, createDefaultDocsTableLikeCustomBlockBleedViewport, createDocsCustomBlockInsertMutation, createDocsCustomBlockRemoveMutation, createDocsCustomBlockSizeRefreshScheduler, createEditorUndoRedoKeyboardConfig, createEmbedDocsCustomBlockData, createInsertCustomBlockActions, createRemoveCustomBlockActions, deleteCustomDecorationFactory, disableMenuWhenHeaderFooterEditing, executeEditorUndoRedoCommand, genTableSource, generateParagraphs, getAnchorBounding, getCanvasOffsetByEngine, getCommandSkeleton, getCursorWhenDelete, getCutActionsFromDocRanges, getDocBlockRangeMenuId, getDocObject, getDocObjectById, getEmptyTableCell, getEmptyTableRow, getLineBounding, getListMarkerFallbackBound, getListParagraphContextMenuHit, getOneTextSelectionRange, getStyleInTextRange, getTableColumn, hasParagraphInTable, hideMenuWhenSelectionInBlockRange, isInSameTableCell, isSheetLikeDocsCustomBlockChildType, isTextRangeInAnyBlockRange, isValidRectRange, neoGetDocObject, normalizeDocFitToWidthOptions, resolveDocFitBaseWidth, resolveDocViewScale, resolveDocsCustomBlockRenderViewport, resolveDocsCustomBlockSize, resolveDocsTableLikeCustomBlockBleedViewport, resolveDocsTableLikeCustomBlockContentHeight, resolveDocsTableLikeCustomBlockContentWidth, scrollDocsTableLikeCustomBlockLive, shouldRefreshDocsCustomBlockSizeForCommand, useEditor, useEditorClickOutside, useIsFocusing, useKeyboardEvent, useLeftAndRightArrow, useOnChange, useResize, whenDocAndEditorFocused };