@univerjs/docs-ui 0.2.7 → 0.2.9

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 (69) hide show
  1. package/lib/cjs/index.js +5 -5
  2. package/lib/es/index.js +586 -482
  3. package/lib/types/basics/interfaces/component-config/i-doc-ui-plugin-config.d.ts +0 -1
  4. package/lib/types/basics/transform-position.d.ts +0 -1
  5. package/lib/types/commands/commands/clipboard.command.d.ts +0 -1
  6. package/lib/types/commands/commands/doc-header-footer.command.d.ts +0 -1
  7. package/lib/types/commands/commands/doc-paragraph-setting.command.d.ts +0 -1
  8. package/lib/types/commands/operations/doc-create-table.operation.d.ts +0 -1
  9. package/lib/types/commands/operations/doc-header-footer-panel.operation.d.ts +0 -1
  10. package/lib/types/commands/operations/doc-paragraph-setting-panel.operation.d.ts +0 -1
  11. package/lib/types/components/list-type-picker/picker.d.ts +0 -1
  12. package/lib/types/controllers/app-ui-controller.d.ts +0 -1
  13. package/lib/types/controllers/clipboard.controller.d.ts +0 -1
  14. package/lib/types/controllers/doc-auto-format.controller.d.ts +0 -1
  15. package/lib/types/controllers/doc-container-ui-controller.d.ts +0 -1
  16. package/lib/types/controllers/doc-editor-bridge.controller.d.ts +0 -1
  17. package/lib/types/controllers/doc-header-footer.controller.d.ts +0 -1
  18. package/lib/types/controllers/doc-paragraph-setting.controller.d.ts +0 -1
  19. package/lib/types/controllers/doc-table.controller.d.ts +0 -1
  20. package/lib/types/controllers/doc-ui.controller.d.ts +0 -1
  21. package/lib/types/controllers/menu/context-menu.d.ts +0 -1
  22. package/lib/types/controllers/menu/menu.d.ts +0 -1
  23. package/lib/types/controllers/render-controllers/back-scroll.render-controller.d.ts +0 -1
  24. package/lib/types/controllers/render-controllers/contextmenu.render-controller.d.ts +0 -1
  25. package/lib/types/controllers/render-controllers/doc-checklist.render-controller.d.ts +5 -5
  26. package/lib/types/controllers/render-controllers/doc-resize.render-controller.d.ts +0 -1
  27. package/lib/types/controllers/render-controllers/doc.render-controller.d.ts +0 -1
  28. package/lib/types/controllers/render-controllers/text-selection.render-controller.d.ts +0 -1
  29. package/lib/types/controllers/render-controllers/zoom.render-controller.d.ts +0 -1
  30. package/lib/types/docs-ui-plugin.d.ts +0 -2
  31. package/lib/types/index.d.ts +1 -1
  32. package/lib/types/locale/en-US.d.ts +0 -1
  33. package/lib/types/locale/ru-RU.d.ts +0 -1
  34. package/lib/types/locale/vi-VN.d.ts +0 -1
  35. package/lib/types/locale/zh-TW.d.ts +0 -1
  36. package/lib/types/services/clipboard/clipboard.service.d.ts +0 -1
  37. package/lib/types/services/clipboard/copy-content-cache.d.ts +0 -1
  38. package/lib/types/services/clipboard/html-to-udm/converter.d.ts +0 -1
  39. package/lib/types/services/clipboard/html-to-udm/parse-node-style.d.ts +0 -1
  40. package/lib/types/services/clipboard/html-to-udm/paste-plugins/plugin-lark.d.ts +0 -1
  41. package/lib/types/services/clipboard/html-to-udm/paste-plugins/plugin-univer.d.ts +0 -1
  42. package/lib/types/services/clipboard/html-to-udm/paste-plugins/plugin-word.d.ts +0 -1
  43. package/lib/types/services/clipboard/html-to-udm/paste-plugins/type.d.ts +0 -1
  44. package/lib/types/services/clipboard/html-to-udm/utils.d.ts +0 -1
  45. package/lib/types/services/clipboard/udm-to-html/convertor.d.ts +0 -1
  46. package/lib/types/services/doc-event-manager.service.d.ts +52 -0
  47. package/lib/types/services/doc-page-layout.service.d.ts +0 -1
  48. package/lib/types/services/doc-popup-manager.service.d.ts +9 -5
  49. package/lib/types/services/docs-render.service.d.ts +0 -1
  50. package/lib/types/shortcuts/core-editing.shortcut.d.ts +0 -1
  51. package/lib/types/shortcuts/cursor.shortcut.d.ts +0 -1
  52. package/lib/types/shortcuts/format.shortcut.d.ts +0 -1
  53. package/lib/types/shortcuts/toolbar.shortcut.d.ts +0 -1
  54. package/lib/types/shortcuts/utils.d.ts +0 -1
  55. package/lib/types/views/count-bar/CountBar.d.ts +0 -1
  56. package/lib/types/views/count-bar/ZoomSlider.d.ts +0 -1
  57. package/lib/types/views/doc-container/DocContainer.d.ts +0 -1
  58. package/lib/types/views/doc-footer/DocFooter.d.ts +0 -1
  59. package/lib/types/views/header-footer/panel/DocHeaderFooterOptions.d.ts +0 -1
  60. package/lib/types/views/header-footer/panel/DocHeaderFooterPanel.d.ts +0 -1
  61. package/lib/types/views/header-footer/text-bubble.d.ts +0 -1
  62. package/lib/types/views/paragraph-setting/hook/utils.d.ts +0 -1
  63. package/lib/types/views/paragraph-setting/index.d.ts +0 -1
  64. package/lib/types/views/table/create/TableCreate.d.ts +0 -1
  65. package/lib/umd/index.js +5 -5
  66. package/package.json +14 -14
  67. package/lib/types/commands/commands/doc-tab.command.d.ts +0 -8
  68. package/lib/types/controllers/render-controllers/doc-hover.render-controller.d.ts +0 -11
  69. package/lib/types/services/doc-hover-manager.service.d.ts +0 -20
package/lib/es/index.js CHANGED
@@ -4,9 +4,9 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
4
4
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
5
5
  import { FOCUSING_DOC, FOCUSING_UNIVER_EDITOR, FOCUSING_COMMON_DRAWINGS, FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE, Tools, LRUMap, BaselineOffset, BooleanNumber, ColorKit, DataStreamTreeTokenType, CustomRangeType, skipParseTagNames, DataStreamTreeNodeType, createIdentifier, Inject, IUniverInstanceService, ILogService, ICommandService, Disposable, SliceBodyType, normalizeBody, UniverInstanceType, toDisposable, getBodySlice, RxDisposable, Direction, EDITOR_ACTIVATED, LocaleService, Injector, Optional, useDependency, DocumentFlavor, CommandType, JSONX, useObservable, PresetListType, ThemeService, HorizontalAlign, MemoryCursor, TextX, TextXActionType, UpdateDocsAttributeType, generateRandomId, OnLifecycle, LifecycleStages, connectInjector, IContextService, checkForSubstrings, IConfigService, isInternalEditorID, DisposableCollection, DEFAULT_EMPTY_DOCUMENT_VALUE, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY, DOCS_NORMAL_EDITOR_UNIT_ID_KEY, DOCS_ZEN_EDITOR_UNIT_ID_KEY, fromEventSubject, QuickListTypeMap, Plugin, mergeOverrideWithDependencies, ObjectRelativeFromH, ObjectRelativeFromV } from "@univerjs/core";
6
6
  import { IClipboardInterfaceService, PLAIN_TEXT_CLIPBOARD_MIME_TYPE, HTML_CLIPBOARD_MIME_TYPE, IEditorService, KeyCode, MetaKeys, ILayoutService, ComponentManager, ISidebarService, IConfirmService, MenuGroup, MenuItemType, MenuPosition, getMenuHiddenObservable, FONT_FAMILY_LIST, FONT_SIZE_LIST, getHeaderFooterMenuHiddenObservable, CopyCommand, CutCommand, PasteCommand, FontFamily, FontFamilyItem, FontSize, BuiltInUIPart, IMenuService, IUIPartsService, IShortcutService, SetEditorResizeOperation, ICanvasPopupService, IContextMenuService } from "@univerjs/ui";
7
- import { getEmptyTableCell, getEmptyTableRow, genTableSource, getTableColumn, TextSelectionManagerService, DocCustomRangeService, getCursorWhenDelete, CutContentCommand, InnerPasteCommand, getDeleteSelection, DocSkeletonManagerService, VIEWPORT_KEY, getDocObject, MoveCursorOperation, MoveSelectionOperation, SelectAllOperation, neoGetDocObject, RichTextEditingMutation, SetDocZoomRatioOperation, SetInlineFormatBoldCommand, SetInlineFormatItalicCommand, SetInlineFormatUnderlineCommand, SetInlineFormatStrikethroughCommand, SetInlineFormatSubscriptCommand, SetInlineFormatSuperscriptCommand, AlignLeftCommand, AlignRightCommand, AlignCenterCommand, AlignJustifyCommand, OrderListCommand, BulletListCommand, TabCommand, CreateDocTableCommand, SetTextSelectionsOperation, SetInlineFormatCommand, SetInlineFormatFontFamilyCommand, SetInlineFormatFontSizeCommand, SetInlineFormatTextColorCommand, AlignOperationCommand, CheckListCommand, ResetInlineFormatTextBackgroundColorCommand, SetInlineFormatTextBackgroundColorCommand, getCommandSkeleton, getParagraphsInRange, getParagraphsInRanges, serializeDocRange, getRichTextEditPath, DeleteLeftCommand, DocTableInsertRowAboveCommand, DocTableInsertRowBellowCommand, DocTableInsertColumnLeftCommand, DocTableInsertColumnRightCommand, DocTableDeleteRowsCommand, DocTableDeleteColumnsCommand, DocTableDeleteTableCommand, EnterCommand, DeleteRightCommand, CoverContentCommand, DOCS_COMPONENT_MAIN_LAYER_INDEX, DOCS_COMPONENT_HEADER_LAYER_INDEX, DOCS_VIEW_KEY, DOCS_COMPONENT_DEFAULT_Z_INDEX, DOCS_COMPONENT_BACKGROUND_LAYER_INDEX, SetDocZoomRatioCommand, ChangeListNestingLevelCommand, ChangeListNestingLevelType, AfterSpaceCommand, QuickListCommand, ListOperationCommand, BreakLineCommand, DocAutoFormatService, ToggleCheckListCommand, DocTableTabCommand, DocTableShiftTabCommand, DocInterceptorService } from "@univerjs/docs";
8
- import { pixelToPt, ptToPixel, parseDataStreamToTree, DOC_RANGE_TYPE, NodePositionConvertToCursor, getAnchorBounding, IRenderManagerService, ITextSelectionRenderManager, Shape, DocumentEditArea, PageLayoutType, Vector2, Rect, Path, getNumberUnitValue, ScrollBar, Viewport, Layer, Documents, DocBackground, CURSOR_TYPE, pxToNum, getLineBounding, TRANSFORM_CHANGE_OBSERVABLE_TYPE, getParagraphByGlyph, GlyphType, isInSameTableCell } from "@univerjs/engine-render";
9
- import { takeUntil, Observable, combineLatest, map, fromEvent, BehaviorSubject, filter, throttleTime, Subject, debounceTime } from "rxjs";
7
+ import { getEmptyTableCell, getEmptyTableRow, genTableSource, getTableColumn, TextSelectionManagerService, DocCustomRangeService, getCursorWhenDelete, CutContentCommand, InnerPasteCommand, getDeleteSelection, DocSkeletonManagerService, VIEWPORT_KEY, getDocObject, MoveCursorOperation, MoveSelectionOperation, SelectAllOperation, neoGetDocObject, RichTextEditingMutation, SetDocZoomRatioOperation, SetInlineFormatBoldCommand, SetInlineFormatItalicCommand, SetInlineFormatUnderlineCommand, SetInlineFormatStrikethroughCommand, SetInlineFormatSubscriptCommand, SetInlineFormatSuperscriptCommand, AlignLeftCommand, AlignRightCommand, AlignCenterCommand, AlignJustifyCommand, OrderListCommand, BulletListCommand, TabCommand, CreateDocTableCommand, SetTextSelectionsOperation, SetInlineFormatCommand, SetInlineFormatFontFamilyCommand, SetInlineFormatFontSizeCommand, SetInlineFormatTextColorCommand, AlignOperationCommand, CheckListCommand, ResetInlineFormatTextBackgroundColorCommand, SetInlineFormatTextBackgroundColorCommand, getCommandSkeleton, getParagraphsInRange, getParagraphsInRanges, serializeDocRange, getRichTextEditPath, DeleteLeftCommand, DocTableInsertRowAboveCommand, DocTableInsertRowBellowCommand, DocTableInsertColumnLeftCommand, DocTableInsertColumnRightCommand, DocTableDeleteRowsCommand, DocTableDeleteColumnsCommand, DocTableDeleteTableCommand, EnterCommand, DeleteRightCommand, CoverContentCommand, DOCS_COMPONENT_MAIN_LAYER_INDEX, DOCS_COMPONENT_HEADER_LAYER_INDEX, DOCS_VIEW_KEY, DOCS_COMPONENT_DEFAULT_Z_INDEX, DOCS_COMPONENT_BACKGROUND_LAYER_INDEX, SetDocZoomRatioCommand, ChangeListNestingLevelCommand, ChangeListNestingLevelType, DocTableTabCommand, AfterSpaceCommand, QuickListCommand, ListOperationCommand, BreakLineCommand, DocAutoFormatService, ToggleCheckListCommand, DocInterceptorService } from "@univerjs/docs";
8
+ import { pixelToPt, ptToPixel, parseDataStreamToTree, DOC_RANGE_TYPE, NodePositionConvertToCursor, getAnchorBounding, IRenderManagerService, ITextSelectionRenderManager, Shape, DocumentEditArea, PageLayoutType, Vector2, Rect, Path, getNumberUnitValue, ScrollBar, Viewport, Layer, Documents, DocBackground, CURSOR_TYPE, pxToNum, getLineBounding, TRANSFORM_CHANGE_OBSERVABLE_TYPE, isInSameTableCell } from "@univerjs/engine-render";
9
+ import { takeUntil, Observable, combineLatest, map, fromEvent, BehaviorSubject, filter, throttleTime, animationFrameScheduler, Subject, distinctUntilChanged, mergeMap, take } from "rxjs";
10
10
  import * as require$$0 from "react";
11
11
  import require$$0__default, { forwardRef, useRef, createElement, useState, useEffect, useMemo, useCallback } from "react";
12
12
  import { Checkbox, InputNumber, Button, Slider, Tooltip, ColorPicker } from "@univerjs/design";
@@ -159,11 +159,11 @@ const DEFAULT_TABLE_WIDTH = 600, _HtmlToUDMService = class _HtmlToUDMService {
159
159
  return pastePlugin && (this._styleRules = [...pastePlugin.stylesRules], this._afterProcessRules = [...pastePlugin.afterProcessRules]), this._tableCache = [], this._styleCache.clear(), this._process(null, dom.childNodes, docData), this._styleCache.clear(), this._styleRules = [], this._afterProcessRules = [], docData;
160
160
  }
161
161
  _process(parent, nodes, doc) {
162
- var _a23, _b, _c;
162
+ var _a22, _b, _c;
163
163
  const body = doc.body;
164
164
  for (const node of nodes)
165
165
  if (node.nodeType === Node.TEXT_NODE) {
166
- if (((_a23 = node.nodeValue) == null ? void 0 : _a23.trim()) === "")
166
+ if (((_a22 = node.nodeValue) == null ? void 0 : _a22.trim()) === "")
167
167
  continue;
168
168
  let text = (_b = node.nodeValue) == null ? void 0 : _b.replace(/[\r\n]/g, ""), style;
169
169
  if (parent && parent.nodeType === Node.ELEMENT_NODE && parent.tagName.toUpperCase() === "A") {
@@ -202,11 +202,11 @@ const DEFAULT_TABLE_WIDTH = 600, _HtmlToUDMService = class _HtmlToUDMService {
202
202
  }
203
203
  }
204
204
  _processBeforeTable(node, doc) {
205
- var _a23;
205
+ var _a22;
206
206
  const tagName = node.tagName.toUpperCase(), body = doc.body;
207
207
  switch (tagName) {
208
208
  case "TABLE": {
209
- body.dataStream[body.dataStream.length - 1] !== "\r" && (body.dataStream += "\r", (_a23 = body.paragraphs) == null || _a23.push({
209
+ body.dataStream[body.dataStream.length - 1] !== "\r" && (body.dataStream += "\r", (_a22 = body.paragraphs) == null || _a22.push({
210
210
  startIndex: body.dataStream.length - 1
211
211
  }));
212
212
  const table = genTableSource(0, 0, DEFAULT_TABLE_WIDTH);
@@ -229,7 +229,7 @@ const DEFAULT_TABLE_WIDTH = 600, _HtmlToUDMService = class _HtmlToUDMService {
229
229
  }
230
230
  }
231
231
  _processAfterTable(node, doc) {
232
- var _a23;
232
+ var _a22;
233
233
  const tagName = node.tagName.toUpperCase(), body = doc.body;
234
234
  doc.tableSource == null && (doc.tableSource = {}), body.tables == null && (body.tables = []), body.sectionBreaks == null && (body.sectionBreaks = []);
235
235
  const { tableSource } = doc;
@@ -248,7 +248,7 @@ const DEFAULT_TABLE_WIDTH = 600, _HtmlToUDMService = class _HtmlToUDMService {
248
248
  break;
249
249
  }
250
250
  case "TD": {
251
- (_a23 = body.sectionBreaks) == null || _a23.push({
251
+ (_a22 = body.sectionBreaks) == null || _a22.push({
252
252
  startIndex: body.dataStream.length
253
253
  }), body.dataStream += `
254
254
  ${DataStreamTreeTokenType.TABLE_CELL_END}`;
@@ -411,7 +411,7 @@ function convertBodyToHtml(body) {
411
411
  }
412
412
  __name(convertBodyToHtml, "convertBodyToHtml");
413
413
  function processNode(node, body, result) {
414
- var _a23;
414
+ var _a22;
415
415
  switch (node.nodeType) {
416
416
  case DataStreamTreeNodeType.SECTION_BREAK: {
417
417
  for (const n2 of node.children)
@@ -419,7 +419,7 @@ function processNode(node, body, result) {
419
419
  break;
420
420
  }
421
421
  case DataStreamTreeNodeType.PARAGRAPH: {
422
- const { children, startIndex, endIndex } = node, paragraph = (_a23 = body.paragraphs.find((p2) => p2.startIndex === endIndex)) != null ? _a23 : {}, { paragraphStyle = {} } = paragraph, { spaceAbove, spaceBelow, lineSpacing } = paragraphStyle, style = [];
422
+ const { children, startIndex, endIndex } = node, paragraph = (_a22 = body.paragraphs.find((p2) => p2.startIndex === endIndex)) != null ? _a22 : {}, { paragraphStyle = {} } = paragraph, { spaceAbove, spaceBelow, lineSpacing } = paragraphStyle, style = [];
423
423
  if (spaceAbove != null && (typeof spaceAbove == "number" ? style.push(`margin-top: ${spaceAbove}px`) : style.push(`margin-top: ${spaceAbove.v}px`)), spaceBelow != null && (typeof spaceBelow == "number" ? style.push(`margin-bottom: ${spaceBelow}px`) : style.push(`margin-bottom: ${spaceBelow.v}px`)), lineSpacing != null && style.push(`line-height: ${lineSpacing}`), result.html += `<p class="UniverNormal" ${style.length ? `style="${style.join("; ")};"` : ""}>`, children.length)
424
424
  for (const table of children)
425
425
  processNode(table, body, result);
@@ -467,18 +467,18 @@ const _UDMToHtmlService = class _UDMToHtmlService {
467
467
  };
468
468
  __name(_UDMToHtmlService, "UDMToHtmlService");
469
469
  let UDMToHtmlService = _UDMToHtmlService;
470
- var __defProp$l = Object.defineProperty, __getOwnPropDesc$l = Object.getOwnPropertyDescriptor, __decorateClass$l = /* @__PURE__ */ __name((decorators, target, key, kind) => {
471
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$l(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
470
+ var __defProp$k = Object.defineProperty, __getOwnPropDesc$k = Object.getOwnPropertyDescriptor, __decorateClass$k = /* @__PURE__ */ __name((decorators, target, key, kind) => {
471
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$k(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
472
472
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
473
- return kind && result && __defProp$l(target, key, result), result;
474
- }, "__decorateClass$l"), __decorateParam$l = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$l");
473
+ return kind && result && __defProp$k(target, key, result), result;
474
+ }, "__decorateClass$k"), __decorateParam$k = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$k");
475
475
  HtmlToUDMService.use(PastePluginWord);
476
476
  HtmlToUDMService.use(PastePluginLark);
477
477
  HtmlToUDMService.use(PastePluginUniver);
478
478
  function getTableSlice(body, start, end) {
479
- var _a23, _b, _c;
479
+ var _a22, _b, _c;
480
480
  const bodySlice = getBodySlice(body, start, end + 2), dataStream = DataStreamTreeTokenType.TABLE_START + DataStreamTreeTokenType.TABLE_ROW_START + DataStreamTreeTokenType.TABLE_CELL_START + bodySlice.dataStream + DataStreamTreeTokenType.TABLE_CELL_END + DataStreamTreeTokenType.TABLE_ROW_END + DataStreamTreeTokenType.TABLE_END;
481
- return bodySlice.dataStream = dataStream, (_a23 = bodySlice.textRuns) == null || _a23.forEach((textRun) => {
481
+ return bodySlice.dataStream = dataStream, (_a22 = bodySlice.textRuns) == null || _a22.forEach((textRun) => {
482
482
  const { st, ed } = textRun;
483
483
  textRun.st = st + 3, textRun.ed = ed + 3;
484
484
  }), (_b = bodySlice.tables) == null || _b.forEach((table) => {
@@ -524,12 +524,12 @@ let DocClipboardService = (_a = class extends Disposable {
524
524
  return this._paste(partDocData);
525
525
  }
526
526
  async _cut() {
527
- var _a23, _b, _c;
527
+ var _a22, _b, _c;
528
528
  const {
529
529
  segmentId,
530
530
  endOffset: activeEndOffset,
531
531
  style
532
- } = (_a23 = this._textSelectionManagerService.getActiveTextRangeWithStyle()) != null ? _a23 : {}, textRanges = (_b = this._textSelectionManagerService.getCurrentTextRanges()) != null ? _b : [], rectRanges = (_c = this._textSelectionManagerService.getCurrentRectRanges()) != null ? _c : [];
532
+ } = (_a22 = this._textSelectionManagerService.getActiveTextRangeWithStyle()) != null ? _a22 : {}, textRanges = (_b = this._textSelectionManagerService.getCurrentTextRanges()) != null ? _b : [], rectRanges = (_c = this._textSelectionManagerService.getCurrentRectRanges()) != null ? _c : [];
533
533
  if (segmentId == null && this._logService.error("[DocClipboardController] segmentId is not existed"), textRanges.length === 0 && rectRanges.length === 0)
534
534
  return !1;
535
535
  this.copy(SliceBodyType.cut);
@@ -555,12 +555,12 @@ let DocClipboardService = (_a = class extends Disposable {
555
555
  }
556
556
  }
557
557
  async _paste(docData) {
558
- var _a23, _b;
558
+ var _a22, _b;
559
559
  const { body: _body } = docData;
560
560
  if (_body == null)
561
561
  return !1;
562
562
  let body = normalizeBody(_body);
563
- const unitId = (_a23 = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_DOC)) == null ? void 0 : _a23.getUnitId();
563
+ const unitId = (_a22 = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_DOC)) == null ? void 0 : _a22.getUnitId();
564
564
  if (!unitId)
565
565
  return !1;
566
566
  this._clipboardHooks.forEach((hook) => {
@@ -608,7 +608,7 @@ let DocClipboardService = (_a = class extends Disposable {
608
608
  }
609
609
  // eslint-disable-next-line max-lines-per-function
610
610
  _getDocumentBodyInRanges(sliceType) {
611
- var _a23;
611
+ var _a22;
612
612
  const docDataModel = this._univerInstanceService.getCurrentUniverDocInstance(), allRanges = this._textSelectionManagerService.getDocRanges(), results = [];
613
613
  let needCache = !0;
614
614
  if (docDataModel == null || allRanges.length === 0)
@@ -616,7 +616,7 @@ let DocClipboardService = (_a = class extends Disposable {
616
616
  bodyList: results,
617
617
  needCache
618
618
  };
619
- const segmentId = allRanges[0].segmentId, body = (_a23 = docDataModel == null ? void 0 : docDataModel.getSelfOrHeaderFooterModel(segmentId)) == null ? void 0 : _a23.getBody();
619
+ const segmentId = allRanges[0].segmentId, body = (_a22 = docDataModel == null ? void 0 : docDataModel.getSelfOrHeaderFooterModel(segmentId)) == null ? void 0 : _a22.getBody();
620
620
  if (body == null)
621
621
  return {
622
622
  bodyList: results,
@@ -705,19 +705,19 @@ let DocClipboardService = (_a = class extends Disposable {
705
705
  return this._htmlToUDM.convert(html);
706
706
  }
707
707
  }, __name(_a, "DocClipboardService"), _a);
708
- DocClipboardService = __decorateClass$l([
709
- __decorateParam$l(0, IUniverInstanceService),
710
- __decorateParam$l(1, ILogService),
711
- __decorateParam$l(2, ICommandService),
712
- __decorateParam$l(3, IClipboardInterfaceService),
713
- __decorateParam$l(4, Inject(TextSelectionManagerService)),
714
- __decorateParam$l(5, Inject(DocCustomRangeService))
708
+ DocClipboardService = __decorateClass$k([
709
+ __decorateParam$k(0, IUniverInstanceService),
710
+ __decorateParam$k(1, ILogService),
711
+ __decorateParam$k(2, ICommandService),
712
+ __decorateParam$k(3, IClipboardInterfaceService),
713
+ __decorateParam$k(4, Inject(TextSelectionManagerService)),
714
+ __decorateParam$k(5, Inject(DocCustomRangeService))
715
715
  ], DocClipboardService);
716
- var __defProp$k = Object.defineProperty, __getOwnPropDesc$k = Object.getOwnPropertyDescriptor, __decorateClass$k = /* @__PURE__ */ __name((decorators, target, key, kind) => {
717
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$k(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
716
+ var __defProp$j = Object.defineProperty, __getOwnPropDesc$j = Object.getOwnPropertyDescriptor, __decorateClass$j = /* @__PURE__ */ __name((decorators, target, key, kind) => {
717
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$j(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
718
718
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
719
- return kind && result && __defProp$k(target, key, result), result;
720
- }, "__decorateClass$k"), __decorateParam$k = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$k");
719
+ return kind && result && __defProp$j(target, key, result), result;
720
+ }, "__decorateClass$j"), __decorateParam$j = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$j");
721
721
  const ANCHOR_WIDTH = 1.5;
722
722
  var _a2;
723
723
  let DocBackScrollRenderController = (_a2 = class extends RxDisposable {
@@ -733,16 +733,16 @@ let DocBackScrollRenderController = (_a2 = class extends RxDisposable {
733
733
  });
734
734
  }
735
735
  scrollToRange(unitId, range) {
736
- var _a23;
737
- const docSkeletonManagerService = (_a23 = this._renderManagerService.getRenderById(unitId)) == null ? void 0 : _a23.with(DocSkeletonManagerService), skeleton = docSkeletonManagerService == null ? void 0 : docSkeletonManagerService.getSkeleton();
736
+ var _a22;
737
+ const docSkeletonManagerService = (_a22 = this._renderManagerService.getRenderById(unitId)) == null ? void 0 : _a22.with(DocSkeletonManagerService), skeleton = docSkeletonManagerService == null ? void 0 : docSkeletonManagerService.getSkeleton();
738
738
  if (!skeleton)
739
739
  return;
740
740
  const { startOffset } = range, anchorNodePosition = skeleton.findNodePositionByCharIndex(startOffset);
741
741
  this.scrollToNode(unitId, anchorNodePosition);
742
742
  }
743
743
  scrollToNode(unitId, startNodePosition) {
744
- var _a23;
745
- const docObject = this._getDocObject(), docSkeletonManagerService = (_a23 = this._renderManagerService.getRenderById(unitId)) == null ? void 0 : _a23.with(DocSkeletonManagerService), skeleton = docSkeletonManagerService == null ? void 0 : docSkeletonManagerService.getSkeleton();
744
+ var _a22;
745
+ const docObject = this._getDocObject(), docSkeletonManagerService = (_a22 = this._renderManagerService.getRenderById(unitId)) == null ? void 0 : _a22.with(DocSkeletonManagerService), skeleton = docSkeletonManagerService == null ? void 0 : docSkeletonManagerService.getSkeleton();
746
746
  if (docObject == null || skeleton == null)
747
747
  return;
748
748
  const documentOffsetConfig = docObject.document.getOffsetConfig(), { docsLeft, docsTop } = documentOffsetConfig, convertor = new NodePositionConvertToCursor(documentOffsetConfig, skeleton), { contentBoxPointGroup } = convertor.getRangePointData(startNodePosition, startNodePosition), { left: aLeft, top: aTop, height } = getAnchorBounding(contentBoxPointGroup), left = aLeft + docsLeft, top = aTop + docsTop, viewportMain = docObject.scene.getViewport(VIEWPORT_KEY.VIEW_MAIN), isEditor = !!this._editorService.getEditor(unitId);
@@ -772,11 +772,11 @@ let DocBackScrollRenderController = (_a2 = class extends RxDisposable {
772
772
  return getDocObject(this._univerInstanceService, this._renderManagerService);
773
773
  }
774
774
  }, __name(_a2, "DocBackScrollRenderController"), _a2);
775
- DocBackScrollRenderController = __decorateClass$k([
776
- __decorateParam$k(1, Inject(TextSelectionManagerService)),
777
- __decorateParam$k(2, IEditorService),
778
- __decorateParam$k(3, Inject(IUniverInstanceService)),
779
- __decorateParam$k(4, IRenderManagerService)
775
+ DocBackScrollRenderController = __decorateClass$j([
776
+ __decorateParam$j(1, Inject(TextSelectionManagerService)),
777
+ __decorateParam$j(2, IEditorService),
778
+ __decorateParam$j(3, Inject(IUniverInstanceService)),
779
+ __decorateParam$j(4, IRenderManagerService)
780
780
  ], DocBackScrollRenderController);
781
781
  const DefaultToolbarConfig = {
782
782
  undo: !0,
@@ -885,11 +885,11 @@ const DefaultToolbarConfig = {
885
885
  binding: KeyCode.A | MetaKeys.CTRL_COMMAND,
886
886
  preconditions: /* @__PURE__ */ __name((contextService) => contextService.getContextValue(FOCUSING_UNIVER_EDITOR) && (contextService.getContextValue(FOCUSING_DOC) || contextService.getContextValue(EDITOR_ACTIVATED)), "preconditions")
887
887
  };
888
- var __defProp$j = Object.defineProperty, __getOwnPropDesc$j = Object.getOwnPropertyDescriptor, __decorateClass$j = /* @__PURE__ */ __name((decorators, target, key, kind) => {
889
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$j(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
888
+ var __defProp$i = Object.defineProperty, __getOwnPropDesc$i = Object.getOwnPropertyDescriptor, __decorateClass$i = /* @__PURE__ */ __name((decorators, target, key, kind) => {
889
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$i(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
890
890
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
891
- return kind && result && __defProp$j(target, key, result), result;
892
- }, "__decorateClass$j"), __decorateParam$j = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$j"), _a3;
891
+ return kind && result && __defProp$i(target, key, result), result;
892
+ }, "__decorateClass$i"), __decorateParam$i = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$i"), _a3;
893
893
  let DocContainerUIController = (_a3 = class {
894
894
  constructor(_config, _localeService, _injector) {
895
895
  __publicField(this, "_docContainer");
@@ -929,15 +929,15 @@ let DocContainerUIController = (_a3 = class {
929
929
  return this._docContainer;
930
930
  }
931
931
  }, __name(_a3, "DocContainerUIController"), _a3);
932
- DocContainerUIController = __decorateClass$j([
933
- __decorateParam$j(1, Inject(LocaleService)),
934
- __decorateParam$j(2, Inject(Injector))
932
+ DocContainerUIController = __decorateClass$i([
933
+ __decorateParam$i(1, Inject(LocaleService)),
934
+ __decorateParam$i(2, Inject(Injector))
935
935
  ], DocContainerUIController);
936
- var __defProp$i = Object.defineProperty, __getOwnPropDesc$i = Object.getOwnPropertyDescriptor, __decorateClass$i = /* @__PURE__ */ __name((decorators, target, key, kind) => {
937
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$i(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
936
+ var __defProp$h = Object.defineProperty, __getOwnPropDesc$h = Object.getOwnPropertyDescriptor, __decorateClass$h = /* @__PURE__ */ __name((decorators, target, key, kind) => {
937
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$h(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
938
938
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
939
- return kind && result && __defProp$i(target, key, result), result;
940
- }, "__decorateClass$i"), __decorateParam$i = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$i"), _a4;
939
+ return kind && result && __defProp$h(target, key, result), result;
940
+ }, "__decorateClass$h"), __decorateParam$h = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$h"), _a4;
941
941
  let AppUIController = (_a4 = class extends RxDisposable {
942
942
  constructor(_config, _localeService, _injector, _textSelectionRenderManager, _layoutService) {
943
943
  super();
@@ -964,11 +964,11 @@ let AppUIController = (_a4 = class extends RxDisposable {
964
964
  return this._docContainerController;
965
965
  }
966
966
  }, __name(_a4, "AppUIController"), _a4);
967
- AppUIController = __decorateClass$i([
968
- __decorateParam$i(1, Inject(LocaleService)),
969
- __decorateParam$i(2, Inject(Injector)),
970
- __decorateParam$i(3, ITextSelectionRenderManager),
971
- __decorateParam$i(4, Optional(ILayoutService))
967
+ AppUIController = __decorateClass$h([
968
+ __decorateParam$h(1, Inject(LocaleService)),
969
+ __decorateParam$h(2, Inject(Injector)),
970
+ __decorateParam$h(3, ITextSelectionRenderManager),
971
+ __decorateParam$h(4, Optional(ILayoutService))
972
972
  ], AppUIController);
973
973
  var __assign = function() {
974
974
  return __assign = Object.assign || function(t) {
@@ -999,15 +999,15 @@ function replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend) {
999
999
  var attrs = __assign({}, node.attrs);
1000
1000
  extend != null && extend.colorChannel1 && attrs.fill === "colorChannel1" && (attrs.fill = extend.colorChannel1);
1001
1001
  var defIds = runtimeProps.defIds;
1002
- return !defIds || defIds.length === 0 || (node.tag === "use" && attrs["xlink:href"] && (attrs["xlink:href"] = attrs["xlink:href"] + runtimeProps.idSuffix), Object.entries(attrs).forEach(function(_a23) {
1003
- var key = _a23[0], value = _a23[1];
1002
+ return !defIds || defIds.length === 0 || (node.tag === "use" && attrs["xlink:href"] && (attrs["xlink:href"] = attrs["xlink:href"] + runtimeProps.idSuffix), Object.entries(attrs).forEach(function(_a22) {
1003
+ var key = _a22[0], value = _a22[1];
1004
1004
  typeof value == "string" && (attrs[key] = value.replace(/url\(#(.*)\)/, "url(#$1".concat(runtimeProps.idSuffix, ")")));
1005
1005
  })), attrs;
1006
1006
  }
1007
1007
  __name(replaceRuntimeIdsAndExtInAttrs, "replaceRuntimeIdsAndExtInAttrs");
1008
1008
  function replaceRuntimeIdsInDefs(node, runtimeProps) {
1009
- var _a23, defIds = runtimeProps.defIds;
1010
- return !defIds || defIds.length === 0 ? node : node.tag === "defs" && (!((_a23 = node.children) === null || _a23 === void 0) && _a23.length) ? __assign(__assign({}, node), { children: node.children.map(function(child) {
1009
+ var _a22, defIds = runtimeProps.defIds;
1010
+ return !defIds || defIds.length === 0 ? node : node.tag === "defs" && (!((_a22 = node.children) === null || _a22 === void 0) && _a22.length) ? __assign(__assign({}, node), { children: node.children.map(function(child) {
1011
1011
  return typeof child.attrs.id == "string" && defIds && defIds.indexOf(child.attrs.id) > -1 ? __assign(__assign({}, child), { attrs: __assign(__assign({}, child.attrs), { id: child.attrs.id + runtimeProps.idSuffix }) }) : child;
1012
1012
  }) }) : node;
1013
1013
  }
@@ -1142,12 +1142,12 @@ const panel = "univer-panel", optionsSection = "univer-options-section", options
1142
1142
  optionsMarginSetting
1143
1143
  }, DocHeaderFooterOptions = /* @__PURE__ */ __name((props) => {
1144
1144
  const localeService = useDependency(LocaleService), univerInstanceService = useDependency(IUniverInstanceService), renderManagerService = useDependency(IRenderManagerService), commandService = useDependency(ICommandService), textSelectionRenderService = useDependency(ITextSelectionRenderManager), textSelectionManagerService = useDependency(TextSelectionManagerService), { unitId } = props, [options, setOptions] = useState({}), handleCheckboxChange = /* @__PURE__ */ __name((val, type) => {
1145
- var _a23;
1145
+ var _a22;
1146
1146
  setOptions((prev) => ({
1147
1147
  ...prev,
1148
1148
  [type]: val ? BooleanNumber.TRUE : BooleanNumber.FALSE
1149
1149
  }));
1150
- const docDataModel = univerInstanceService.getUniverDocInstance(unitId), documentStyle = docDataModel == null ? void 0 : docDataModel.getSnapshot().documentStyle, docSkeletonManagerService = (_a23 = renderManagerService.getRenderById(unitId)) == null ? void 0 : _a23.with(DocSkeletonManagerService), viewModel = docSkeletonManagerService == null ? void 0 : docSkeletonManagerService.getViewModel();
1150
+ const docDataModel = univerInstanceService.getUniverDocInstance(unitId), documentStyle = docDataModel == null ? void 0 : docDataModel.getSnapshot().documentStyle, docSkeletonManagerService = (_a22 = renderManagerService.getRenderById(unitId)) == null ? void 0 : _a22.with(DocSkeletonManagerService), viewModel = docSkeletonManagerService == null ? void 0 : docSkeletonManagerService.getViewModel();
1151
1151
  if (documentStyle == null || viewModel == null)
1152
1152
  return;
1153
1153
  const editArea = viewModel.getEditArea();
@@ -1181,12 +1181,12 @@ const panel = "univer-panel", optionsSection = "univer-options-section", options
1181
1181
  }
1182
1182
  }), textSelectionRenderService.removeAllRanges(), textSelectionRenderService.blur();
1183
1183
  }, "handleMarginChange"), closeHeaderFooter = /* @__PURE__ */ __name(() => {
1184
- var _a23;
1184
+ var _a22;
1185
1185
  const renderObject = renderManagerService.getRenderById(unitId);
1186
1186
  if (renderObject == null)
1187
1187
  return;
1188
1188
  const { scene } = renderObject, transformer = scene.getTransformerByCreate(), docSkeletonManagerService = renderObject.with(DocSkeletonManagerService), skeleton = docSkeletonManagerService == null ? void 0 : docSkeletonManagerService.getSkeleton(), viewModel = docSkeletonManagerService == null ? void 0 : docSkeletonManagerService.getViewModel(), render2 = renderManagerService.getRenderById(unitId);
1189
- render2 == null || viewModel == null || skeleton == null || (textSelectionManagerService.replaceTextRanges([]), transformer.clearSelectedObjects(), textSelectionRenderService.setSegment(""), textSelectionRenderService.setSegmentPage(-1), viewModel.setEditArea(DocumentEditArea.BODY), skeleton.calculate(), (_a23 = render2.mainComponent) == null || _a23.makeDirty(!0));
1189
+ render2 == null || viewModel == null || skeleton == null || (textSelectionManagerService.replaceTextRanges([]), transformer.clearSelectedObjects(), textSelectionRenderService.setSegment(""), textSelectionRenderService.setSegmentPage(-1), viewModel.setEditArea(DocumentEditArea.BODY), skeleton.calculate(), (_a22 = render2.mainComponent) == null || _a22.makeDirty(!0));
1190
1190
  }, "closeHeaderFooter");
1191
1191
  return useEffect(() => {
1192
1192
  const docDataModel = univerInstanceService.getUniverDocInstance(unitId), documentStyle = docDataModel == null ? void 0 : docDataModel.getSnapshot().documentStyle;
@@ -1264,8 +1264,8 @@ const panel = "univer-panel", optionsSection = "univer-options-section", options
1264
1264
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$5.optionsSection, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { onClick: closeHeaderFooter, children: localeService.t("headerFooter.closeHeaderFooter") }) })
1265
1265
  ] });
1266
1266
  }, "DocHeaderFooterOptions"), DocHeaderFooterPanel = /* @__PURE__ */ __name(() => {
1267
- var _a23;
1268
- const localeService = useDependency(LocaleService), renderManagerService = useDependency(IRenderManagerService), unitId = useDependency(IUniverInstanceService).getCurrentUniverDocInstance().getUnitId(), viewModel = ((_a23 = renderManagerService.getRenderById(unitId)) == null ? void 0 : _a23.with(DocSkeletonManagerService)).getViewModel(), [isEditHeaderFooter, setIsEditHeaderFooter] = useState(!0);
1267
+ var _a22;
1268
+ const localeService = useDependency(LocaleService), renderManagerService = useDependency(IRenderManagerService), unitId = useDependency(IUniverInstanceService).getCurrentUniverDocInstance().getUnitId(), viewModel = ((_a22 = renderManagerService.getRenderById(unitId)) == null ? void 0 : _a22.with(DocSkeletonManagerService)).getViewModel(), [isEditHeaderFooter, setIsEditHeaderFooter] = useState(!0);
1269
1269
  return useEffect(() => {
1270
1270
  const editArea = viewModel.getEditArea();
1271
1271
  setIsEditHeaderFooter(editArea !== DocumentEditArea.BODY);
@@ -1277,11 +1277,11 @@ const panel = "univer-panel", optionsSection = "univer-options-section", options
1277
1277
  };
1278
1278
  }, []), /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$5.panel, children: isEditHeaderFooter ? /* @__PURE__ */ jsxRuntimeExports.jsx(DocHeaderFooterOptions, { unitId }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$5.panelDisableText, children: localeService.t("headerFooter.disableText") }) });
1279
1279
  }, "DocHeaderFooterPanel");
1280
- var __defProp$h = Object.defineProperty, __getOwnPropDesc$h = Object.getOwnPropertyDescriptor, __decorateClass$h = /* @__PURE__ */ __name((decorators, target, key, kind) => {
1281
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$h(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1280
+ var __defProp$g = Object.defineProperty, __getOwnPropDesc$g = Object.getOwnPropertyDescriptor, __decorateClass$g = /* @__PURE__ */ __name((decorators, target, key, kind) => {
1281
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$g(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1282
1282
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
1283
- return kind && result && __defProp$h(target, key, result), result;
1284
- }, "__decorateClass$h"), __decorateParam$h = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$h");
1283
+ return kind && result && __defProp$g(target, key, result), result;
1284
+ }, "__decorateClass$g"), __decorateParam$g = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$g");
1285
1285
  const HEADER_FOOTER_STROKE_COLOR = "rgba(58, 96, 247, 1)", HEADER_FOOTER_FILL_COLOR = "rgba(58, 96, 247, 0.08)";
1286
1286
  var HeaderFooterType = /* @__PURE__ */ ((HeaderFooterType2) => (HeaderFooterType2[HeaderFooterType2.FIRST_PAGE_HEADER = 0] = "FIRST_PAGE_HEADER", HeaderFooterType2[HeaderFooterType2.FIRST_PAGE_FOOTER = 1] = "FIRST_PAGE_FOOTER", HeaderFooterType2[HeaderFooterType2.DEFAULT_HEADER = 2] = "DEFAULT_HEADER", HeaderFooterType2[HeaderFooterType2.DEFAULT_FOOTER = 3] = "DEFAULT_FOOTER", HeaderFooterType2[HeaderFooterType2.EVEN_PAGE_HEADER = 4] = "EVEN_PAGE_HEADER", HeaderFooterType2[HeaderFooterType2.EVEN_PAGE_FOOTER = 5] = "EVEN_PAGE_FOOTER", HeaderFooterType2))(HeaderFooterType || {});
1287
1287
  function checkCreateHeaderFooterType(viewModel, editArea, segmentPage) {
@@ -1472,15 +1472,15 @@ let DocHeaderFooterController = (_a5 = class extends Disposable {
1472
1472
  return this._context.unit;
1473
1473
  }
1474
1474
  }, __name(_a5, "DocHeaderFooterController"), _a5);
1475
- DocHeaderFooterController = __decorateClass$h([
1476
- __decorateParam$h(1, ICommandService),
1477
- __decorateParam$h(2, IEditorService),
1478
- __decorateParam$h(3, IUniverInstanceService),
1479
- __decorateParam$h(4, IRenderManagerService),
1480
- __decorateParam$h(5, Inject(DocSkeletonManagerService)),
1481
- __decorateParam$h(6, ITextSelectionRenderManager),
1482
- __decorateParam$h(7, Inject(LocaleService)),
1483
- __decorateParam$h(8, Inject(ComponentManager))
1475
+ DocHeaderFooterController = __decorateClass$g([
1476
+ __decorateParam$g(1, ICommandService),
1477
+ __decorateParam$g(2, IEditorService),
1478
+ __decorateParam$g(3, IUniverInstanceService),
1479
+ __decorateParam$g(4, IRenderManagerService),
1480
+ __decorateParam$g(5, Inject(DocSkeletonManagerService)),
1481
+ __decorateParam$g(6, ITextSelectionRenderManager),
1482
+ __decorateParam$g(7, Inject(LocaleService)),
1483
+ __decorateParam$g(8, Inject(ComponentManager))
1484
1484
  ], DocHeaderFooterController);
1485
1485
  const SidebarDocHeaderFooterPanelOperation = {
1486
1486
  id: "sidebar.operation.doc-header-footer-panel",
@@ -1543,7 +1543,7 @@ function createHeaderFooterAction(segmentId, createType, documentStyle, actions)
1543
1543
  });
1544
1544
  actions.push(insertAction);
1545
1545
  const secondSegmentId = Tools.generateRandomId(ID_LEN), insertPairAction = jsonX.insertOp([isHeader ? "footers" : "headers", secondSegmentId], {
1546
- [isHeader ? "footers" : "headers"]: secondSegmentId,
1546
+ [isHeader ? "footerId" : "headerId"]: secondSegmentId,
1547
1547
  body: getEmptyHeaderFooterBody()
1548
1548
  });
1549
1549
  actions.push(insertPairAction);
@@ -1586,8 +1586,8 @@ const CoreHeaderFooterCommandId = "doc.command.core-header-footer", CoreHeaderFo
1586
1586
  type: CommandType.COMMAND,
1587
1587
  // eslint-disable-next-line max-lines-per-function
1588
1588
  handler: /* @__PURE__ */ __name(async (accessor, params) => {
1589
- var _a23;
1590
- const commandService = accessor.get(ICommandService), univerInstanceService = accessor.get(IUniverInstanceService), renderManagerService = accessor.get(IRenderManagerService), { unitId, segmentId, createType, headerFooterProps } = params, docSkeletonManagerService = (_a23 = renderManagerService.getRenderById(unitId)) == null ? void 0 : _a23.with(DocSkeletonManagerService), docDataModel = univerInstanceService.getUniverDocInstance(unitId), docViewModel = docSkeletonManagerService == null ? void 0 : docSkeletonManagerService.getViewModel();
1589
+ var _a22;
1590
+ const commandService = accessor.get(ICommandService), univerInstanceService = accessor.get(IUniverInstanceService), renderManagerService = accessor.get(IRenderManagerService), { unitId, segmentId, createType, headerFooterProps } = params, docSkeletonManagerService = (_a22 = renderManagerService.getRenderById(unitId)) == null ? void 0 : _a22.with(DocSkeletonManagerService), docDataModel = univerInstanceService.getUniverDocInstance(unitId), docViewModel = docSkeletonManagerService == null ? void 0 : docSkeletonManagerService.getViewModel();
1591
1591
  if (docDataModel == null || docViewModel == null)
1592
1592
  return !1;
1593
1593
  const editArea = docViewModel.getEditArea(), { documentStyle } = docDataModel.getSnapshot(), isUpdateMargin = (headerFooterProps == null ? void 0 : headerFooterProps.marginFooter) != null || (headerFooterProps == null ? void 0 : headerFooterProps.marginHeader) != null, textRanges = [{
@@ -1628,9 +1628,9 @@ const CoreHeaderFooterCommandId = "doc.command.core-header-footer", CoreHeaderFo
1628
1628
  }, ZOOM_MAP = [50, 80, 100, 130, 150, 170, 200, 400], DOC_ZOOM_RANGE = [10, 400];
1629
1629
  function ZoomSlider() {
1630
1630
  const commandService = useDependency(ICommandService), univerInstanceService = useDependency(IUniverInstanceService), currentDoc$ = useMemo(() => univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_DOC), []), documentDataModel = useObservable(currentDoc$), getCurrentZoom = useCallback(() => {
1631
- var _a23, _b;
1631
+ var _a22, _b;
1632
1632
  if (!documentDataModel) return 100;
1633
- const currentZoom = ((_b = (_a23 = documentDataModel.getSettings()) == null ? void 0 : _a23.zoomRatio) != null ? _b : 1) * 100;
1633
+ const currentZoom = ((_b = (_a22 = documentDataModel.getSettings()) == null ? void 0 : _a22.zoomRatio) != null ? _b : 1) * 100;
1634
1634
  return Math.round(currentZoom);
1635
1635
  }, [documentDataModel]), [zoom, setZoom] = useState(() => getCurrentZoom());
1636
1636
  useEffect(() => (setZoom(getCurrentZoom()), commandService.onCommandExecuted((commandInfo) => {
@@ -1903,6 +1903,25 @@ function getTableDisabledObservable(accessor) {
1903
1903
  });
1904
1904
  }
1905
1905
  __name(getTableDisabledObservable, "getTableDisabledObservable");
1906
+ function disableMenuWhenNoDocRange(accessor) {
1907
+ const textSelectionManagerService = accessor.get(TextSelectionManagerService);
1908
+ return new Observable((subscriber) => {
1909
+ const subscription = textSelectionManagerService.textSelection$.subscribe((selection) => {
1910
+ if (selection == null) {
1911
+ subscriber.next(!0);
1912
+ return;
1913
+ }
1914
+ const { textRanges, rectRanges } = selection;
1915
+ if (textRanges.length === 0 && rectRanges.length === 0) {
1916
+ subscriber.next(!0);
1917
+ return;
1918
+ }
1919
+ subscriber.next(!1);
1920
+ });
1921
+ return () => subscription.unsubscribe();
1922
+ });
1923
+ }
1924
+ __name(disableMenuWhenNoDocRange, "disableMenuWhenNoDocRange");
1906
1925
  function BoldMenuItemFactory(accessor) {
1907
1926
  const commandService = accessor.get(ICommandService);
1908
1927
  return {
@@ -1915,18 +1934,19 @@ function BoldMenuItemFactory(accessor) {
1915
1934
  positions: [MenuPosition.TOOLBAR_START],
1916
1935
  activated$: new Observable((subscriber) => {
1917
1936
  const disposable = commandService.onCommandExecuted((c) => {
1918
- var _a23;
1937
+ var _a22;
1919
1938
  const id = c.id;
1920
1939
  if (id === SetTextSelectionsOperation.id || id === SetInlineFormatCommand.id) {
1921
1940
  const textRun = getFontStyleAtCursor(accessor);
1922
1941
  if (textRun == null)
1923
1942
  return;
1924
- const bl = (_a23 = textRun.ts) == null ? void 0 : _a23.bl;
1943
+ const bl = (_a22 = textRun.ts) == null ? void 0 : _a22.bl;
1925
1944
  subscriber.next(bl === BooleanNumber.TRUE);
1926
1945
  }
1927
1946
  });
1928
1947
  return subscriber.next(!1), disposable.dispose;
1929
1948
  }),
1949
+ disabled$: disableMenuWhenNoDocRange(accessor),
1930
1950
  hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC)
1931
1951
  };
1932
1952
  }
@@ -1943,18 +1963,19 @@ function ItalicMenuItemFactory(accessor) {
1943
1963
  positions: [MenuPosition.TOOLBAR_START],
1944
1964
  activated$: new Observable((subscriber) => {
1945
1965
  const disposable = commandService.onCommandExecuted((c) => {
1946
- var _a23;
1966
+ var _a22;
1947
1967
  const id = c.id;
1948
1968
  if (id === SetTextSelectionsOperation.id || id === SetInlineFormatCommand.id) {
1949
1969
  const textRun = getFontStyleAtCursor(accessor);
1950
1970
  if (textRun == null)
1951
1971
  return;
1952
- const it = (_a23 = textRun.ts) == null ? void 0 : _a23.it;
1972
+ const it = (_a22 = textRun.ts) == null ? void 0 : _a22.it;
1953
1973
  subscriber.next(it === BooleanNumber.TRUE);
1954
1974
  }
1955
1975
  });
1956
1976
  return subscriber.next(!1), disposable.dispose;
1957
1977
  }),
1978
+ disabled$: disableMenuWhenNoDocRange(accessor),
1958
1979
  hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC)
1959
1980
  };
1960
1981
  }
@@ -1971,18 +1992,19 @@ function UnderlineMenuItemFactory(accessor) {
1971
1992
  positions: [MenuPosition.TOOLBAR_START],
1972
1993
  activated$: new Observable((subscriber) => {
1973
1994
  const disposable = commandService.onCommandExecuted((c) => {
1974
- var _a23;
1995
+ var _a22;
1975
1996
  const id = c.id;
1976
1997
  if (id === SetTextSelectionsOperation.id || id === SetInlineFormatCommand.id) {
1977
1998
  const textRun = getFontStyleAtCursor(accessor);
1978
1999
  if (textRun == null)
1979
2000
  return;
1980
- const ul = (_a23 = textRun.ts) == null ? void 0 : _a23.ul;
2001
+ const ul = (_a22 = textRun.ts) == null ? void 0 : _a22.ul;
1981
2002
  subscriber.next((ul == null ? void 0 : ul.s) === BooleanNumber.TRUE);
1982
2003
  }
1983
2004
  });
1984
2005
  return subscriber.next(!1), disposable.dispose;
1985
2006
  }),
2007
+ disabled$: disableMenuWhenNoDocRange(accessor),
1986
2008
  hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC)
1987
2009
  };
1988
2010
  }
@@ -1999,18 +2021,19 @@ function StrikeThroughMenuItemFactory(accessor) {
1999
2021
  positions: [MenuPosition.TOOLBAR_START],
2000
2022
  activated$: new Observable((subscriber) => {
2001
2023
  const disposable = commandService.onCommandExecuted((c) => {
2002
- var _a23;
2024
+ var _a22;
2003
2025
  const id = c.id;
2004
2026
  if (id === SetTextSelectionsOperation.id || id === SetInlineFormatCommand.id) {
2005
2027
  const textRun = getFontStyleAtCursor(accessor);
2006
2028
  if (textRun == null)
2007
2029
  return;
2008
- const st = (_a23 = textRun.ts) == null ? void 0 : _a23.st;
2030
+ const st = (_a22 = textRun.ts) == null ? void 0 : _a22.st;
2009
2031
  subscriber.next((st == null ? void 0 : st.s) === BooleanNumber.TRUE);
2010
2032
  }
2011
2033
  });
2012
2034
  return subscriber.next(!1), disposable.dispose;
2013
2035
  }),
2036
+ disabled$: disableMenuWhenNoDocRange(accessor),
2014
2037
  hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC)
2015
2038
  };
2016
2039
  }
@@ -2026,18 +2049,19 @@ function SubscriptMenuItemFactory(accessor) {
2026
2049
  positions: [MenuPosition.TOOLBAR_START],
2027
2050
  activated$: new Observable((subscriber) => {
2028
2051
  const disposable = commandService.onCommandExecuted((c) => {
2029
- var _a23;
2052
+ var _a22;
2030
2053
  const id = c.id;
2031
2054
  if (id === SetTextSelectionsOperation.id || id === SetInlineFormatCommand.id) {
2032
2055
  const textRun = getFontStyleAtCursor(accessor);
2033
2056
  if (textRun == null)
2034
2057
  return;
2035
- const va = (_a23 = textRun.ts) == null ? void 0 : _a23.va;
2058
+ const va = (_a22 = textRun.ts) == null ? void 0 : _a22.va;
2036
2059
  subscriber.next(va === BaselineOffset.SUBSCRIPT);
2037
2060
  }
2038
2061
  });
2039
2062
  return subscriber.next(!1), disposable.dispose;
2040
2063
  }),
2064
+ disabled$: disableMenuWhenNoDocRange(accessor),
2041
2065
  hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC)
2042
2066
  };
2043
2067
  }
@@ -2053,18 +2077,19 @@ function SuperscriptMenuItemFactory(accessor) {
2053
2077
  positions: [MenuPosition.TOOLBAR_START],
2054
2078
  activated$: new Observable((subscriber) => {
2055
2079
  const disposable = commandService.onCommandExecuted((c) => {
2056
- var _a23;
2080
+ var _a22;
2057
2081
  const id = c.id;
2058
2082
  if (id === SetTextSelectionsOperation.id || id === SetInlineFormatCommand.id) {
2059
2083
  const textRun = getFontStyleAtCursor(accessor);
2060
2084
  if (textRun == null)
2061
2085
  return;
2062
- const va = (_a23 = textRun.ts) == null ? void 0 : _a23.va;
2086
+ const va = (_a22 = textRun.ts) == null ? void 0 : _a22.va;
2063
2087
  subscriber.next(va === BaselineOffset.SUPERSCRIPT);
2064
2088
  }
2065
2089
  });
2066
2090
  return subscriber.next(!1), disposable.dispose;
2067
2091
  }),
2092
+ disabled$: disableMenuWhenNoDocRange(accessor),
2068
2093
  hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC)
2069
2094
  };
2070
2095
  }
@@ -2088,18 +2113,19 @@ function FontFamilySelectorMenuItemFactory(accessor) {
2088
2113
  // disabled$: getCurrentSheetDisabled$(accessor),
2089
2114
  value$: new Observable((subscriber) => {
2090
2115
  const defaultValue = FONT_FAMILY_LIST[0].value, disposable = commandService.onCommandExecuted((c) => {
2091
- var _a23;
2116
+ var _a22;
2092
2117
  const id = c.id;
2093
2118
  if (id === SetTextSelectionsOperation.id || id === SetInlineFormatFontFamilyCommand.id) {
2094
2119
  const textRun = getFontStyleAtCursor(accessor);
2095
2120
  if (textRun == null)
2096
2121
  return;
2097
- const ff = (_a23 = textRun.ts) == null ? void 0 : _a23.ff;
2122
+ const ff = (_a22 = textRun.ts) == null ? void 0 : _a22.ff;
2098
2123
  subscriber.next(ff != null ? ff : defaultValue);
2099
2124
  }
2100
2125
  });
2101
2126
  return subscriber.next(defaultValue), disposable.dispose;
2102
2127
  }),
2128
+ disabled$: disableMenuWhenNoDocRange(accessor),
2103
2129
  hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC)
2104
2130
  };
2105
2131
  }
@@ -2124,18 +2150,19 @@ function FontSizeSelectorMenuItemFactory(accessor) {
2124
2150
  // disabled$,
2125
2151
  value$: new Observable((subscriber) => {
2126
2152
  const disposable = commandService.onCommandExecuted((c) => {
2127
- var _a23;
2153
+ var _a22;
2128
2154
  const id = c.id;
2129
2155
  if (id === SetTextSelectionsOperation.id || id === SetInlineFormatFontSizeCommand.id) {
2130
2156
  const textRun = getFontStyleAtCursor(accessor);
2131
2157
  if (textRun == null)
2132
2158
  return;
2133
- const fs = (_a23 = textRun.ts) == null ? void 0 : _a23.fs;
2159
+ const fs = (_a22 = textRun.ts) == null ? void 0 : _a22.fs;
2134
2160
  subscriber.next(fs != null ? fs : 14);
2135
2161
  }
2136
2162
  });
2137
2163
  return subscriber.next(14), disposable.dispose;
2138
2164
  }),
2165
+ disabled$: disableMenuWhenNoDocRange(accessor),
2139
2166
  hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC)
2140
2167
  };
2141
2168
  }
@@ -2166,6 +2193,7 @@ function TextColorSelectorMenuItemFactory(accessor) {
2166
2193
  });
2167
2194
  return subscriber.next(defaultColor), disposable.dispose;
2168
2195
  }),
2196
+ disabled$: disableMenuWhenNoDocRange(accessor),
2169
2197
  hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC)
2170
2198
  // disabled$: getCurrentSheetDisabled$(accessor),
2171
2199
  };
@@ -2217,15 +2245,16 @@ function AlignLeftMenuItemFactory(accessor) {
2217
2245
  icon: "LeftJustifyingSingle",
2218
2246
  tooltip: "toolbar.alignLeft",
2219
2247
  positions: [MenuPosition.TOOLBAR_START],
2248
+ disabled$: disableMenuWhenNoDocRange(accessor),
2220
2249
  activated$: new Observable((subscriber) => {
2221
2250
  const disposable = commandService.onCommandExecuted((c) => {
2222
- var _a23;
2251
+ var _a22;
2223
2252
  const id = c.id;
2224
2253
  if (id === SetTextSelectionsOperation.id || id === AlignOperationCommand.id) {
2225
2254
  const paragraph = getParagraphStyleAtCursor(accessor);
2226
2255
  if (paragraph == null)
2227
2256
  return;
2228
- const alignType = (_a23 = paragraph.paragraphStyle) == null ? void 0 : _a23.horizontalAlign;
2257
+ const alignType = (_a22 = paragraph.paragraphStyle) == null ? void 0 : _a22.horizontalAlign;
2229
2258
  subscriber.next(alignType === HorizontalAlign.LEFT);
2230
2259
  }
2231
2260
  });
@@ -2246,18 +2275,19 @@ function AlignCenterMenuItemFactory(accessor) {
2246
2275
  positions: [MenuPosition.TOOLBAR_START],
2247
2276
  activated$: new Observable((subscriber) => {
2248
2277
  const disposable = commandService.onCommandExecuted((c) => {
2249
- var _a23;
2278
+ var _a22;
2250
2279
  const id = c.id;
2251
2280
  if (id === SetTextSelectionsOperation.id || id === AlignOperationCommand.id) {
2252
2281
  const paragraph = getParagraphStyleAtCursor(accessor);
2253
2282
  if (paragraph == null)
2254
2283
  return;
2255
- const alignType = (_a23 = paragraph.paragraphStyle) == null ? void 0 : _a23.horizontalAlign;
2284
+ const alignType = (_a22 = paragraph.paragraphStyle) == null ? void 0 : _a22.horizontalAlign;
2256
2285
  subscriber.next(alignType === HorizontalAlign.CENTER);
2257
2286
  }
2258
2287
  });
2259
2288
  return subscriber.next(!1), disposable.dispose;
2260
2289
  }),
2290
+ disabled$: disableMenuWhenNoDocRange(accessor),
2261
2291
  hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC)
2262
2292
  };
2263
2293
  }
@@ -2273,18 +2303,19 @@ function AlignRightMenuItemFactory(accessor) {
2273
2303
  positions: [MenuPosition.TOOLBAR_START],
2274
2304
  activated$: new Observable((subscriber) => {
2275
2305
  const disposable = commandService.onCommandExecuted((c) => {
2276
- var _a23;
2306
+ var _a22;
2277
2307
  const id = c.id;
2278
2308
  if (id === SetTextSelectionsOperation.id || id === AlignOperationCommand.id) {
2279
2309
  const paragraph = getParagraphStyleAtCursor(accessor);
2280
2310
  if (paragraph == null)
2281
2311
  return;
2282
- const alignType = (_a23 = paragraph.paragraphStyle) == null ? void 0 : _a23.horizontalAlign;
2312
+ const alignType = (_a22 = paragraph.paragraphStyle) == null ? void 0 : _a22.horizontalAlign;
2283
2313
  subscriber.next(alignType === HorizontalAlign.RIGHT);
2284
2314
  }
2285
2315
  });
2286
2316
  return subscriber.next(!1), disposable.dispose;
2287
2317
  }),
2318
+ disabled$: disableMenuWhenNoDocRange(accessor),
2288
2319
  hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC)
2289
2320
  };
2290
2321
  }
@@ -2300,18 +2331,19 @@ function AlignJustifyMenuItemFactory(accessor) {
2300
2331
  positions: [MenuPosition.TOOLBAR_START],
2301
2332
  activated$: new Observable((subscriber) => {
2302
2333
  const disposable = commandService.onCommandExecuted((c) => {
2303
- var _a23;
2334
+ var _a22;
2304
2335
  const id = c.id;
2305
2336
  if (id === SetTextSelectionsOperation.id || id === AlignOperationCommand.id) {
2306
2337
  const paragraph = getParagraphStyleAtCursor(accessor);
2307
2338
  if (paragraph == null)
2308
2339
  return;
2309
- const alignType = (_a23 = paragraph.paragraphStyle) == null ? void 0 : _a23.horizontalAlign;
2340
+ const alignType = (_a22 = paragraph.paragraphStyle) == null ? void 0 : _a22.horizontalAlign;
2310
2341
  subscriber.next(alignType === HorizontalAlign.JUSTIFIED);
2311
2342
  }
2312
2343
  });
2313
2344
  return subscriber.next(!1), disposable.dispose;
2314
2345
  }),
2346
+ disabled$: disableMenuWhenNoDocRange(accessor),
2315
2347
  hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC)
2316
2348
  };
2317
2349
  }
@@ -2324,14 +2356,14 @@ const listValueFactory$ = /* @__PURE__ */ __name((accessor) => new Observable((s
2324
2356
  return;
2325
2357
  const docDataModel = univerInstanceService.getUniverDocInstance(unitId);
2326
2358
  docDataModel != null && (textSubscription = textSelectionManagerService.textSelection$.subscribe(() => {
2327
- var _a23, _b;
2359
+ var _a22, _b;
2328
2360
  const range = textSelectionManagerService.getActiveTextRangeWithStyle();
2329
2361
  if (range) {
2330
- const doc = docDataModel.getSelfOrHeaderFooterModel(range == null ? void 0 : range.segmentId), paragraphs = getParagraphsInRange(range, (_b = (_a23 = doc.getBody()) == null ? void 0 : _a23.paragraphs) != null ? _b : []);
2362
+ const doc = docDataModel.getSelfOrHeaderFooterModel(range == null ? void 0 : range.segmentId), paragraphs = getParagraphsInRange(range, (_b = (_a22 = doc.getBody()) == null ? void 0 : _a22.paragraphs) != null ? _b : []);
2331
2363
  let listType;
2332
2364
  if (paragraphs.every((p2) => {
2333
- var _a24;
2334
- return listType || (listType = (_a24 = p2.bullet) == null ? void 0 : _a24.listType), p2.bullet && p2.bullet.listType === listType;
2365
+ var _a23;
2366
+ return listType || (listType = (_a23 = p2.bullet) == null ? void 0 : _a23.listType), p2.bullet && p2.bullet.listType === listType;
2335
2367
  })) {
2336
2368
  subscriber.next(listType);
2337
2369
  return;
@@ -2362,6 +2394,7 @@ function OrderListMenuItemFactory(accessor) {
2362
2394
  tooltip: "toolbar.order",
2363
2395
  positions: [MenuPosition.TOOLBAR_START],
2364
2396
  hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC),
2397
+ disabled$: disableMenuWhenNoDocRange(accessor),
2365
2398
  activated$: listValueFactory$(accessor).pipe(map((v) => v && v.indexOf("ORDER_LIST") === 0))
2366
2399
  };
2367
2400
  }
@@ -2383,6 +2416,7 @@ function BulletListMenuItemFactory(accessor) {
2383
2416
  icon: "UnorderSingle",
2384
2417
  tooltip: "toolbar.unorder",
2385
2418
  positions: [MenuPosition.TOOLBAR_START],
2419
+ disabled$: disableMenuWhenNoDocRange(accessor),
2386
2420
  hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC),
2387
2421
  activated$: listValueFactory$(accessor).pipe(map((v) => v && v.indexOf("BULLET_LIST") === 0))
2388
2422
  };
@@ -2396,6 +2430,7 @@ function CheckListMenuItemFactory(accessor) {
2396
2430
  icon: "TodoList",
2397
2431
  tooltip: "toolbar.checklist",
2398
2432
  positions: [MenuPosition.TOOLBAR_START],
2433
+ disabled$: disableMenuWhenNoDocRange(accessor),
2399
2434
  hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC),
2400
2435
  activated$: listValueFactory$(accessor).pipe(map((v) => v && v.indexOf("CHECK_LIST") === 0))
2401
2436
  };
@@ -2437,16 +2472,17 @@ function BackgroundColorSelectorMenuItemFactory(accessor) {
2437
2472
  });
2438
2473
  return subscriber.next(defaultColor), disposable.dispose;
2439
2474
  }),
2475
+ disabled$: disableMenuWhenNoDocRange(accessor),
2440
2476
  hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC)
2441
2477
  };
2442
2478
  }
2443
2479
  __name(BackgroundColorSelectorMenuItemFactory, "BackgroundColorSelectorMenuItemFactory");
2444
2480
  function getFontStyleAtCursor(accessor) {
2445
- var _a23;
2481
+ var _a22;
2446
2482
  const univerInstanceService = accessor.get(IUniverInstanceService), textSelectionService = accessor.get(TextSelectionManagerService), docDataModel = univerInstanceService.getCurrentUniverDocInstance(), activeTextRange = textSelectionService.getActiveTextRangeWithStyle();
2447
2483
  if (docDataModel == null || activeTextRange == null)
2448
2484
  return;
2449
- const { startOffset, segmentId } = activeTextRange, textRuns = (_a23 = docDataModel.getSelfOrHeaderFooterModel(segmentId).getBody()) == null ? void 0 : _a23.textRuns;
2485
+ const { startOffset, segmentId } = activeTextRange, textRuns = (_a22 = docDataModel.getSelfOrHeaderFooterModel(segmentId).getBody()) == null ? void 0 : _a22.textRuns;
2450
2486
  if (textRuns == null)
2451
2487
  return;
2452
2488
  let textRun;
@@ -2465,11 +2501,11 @@ function getFontStyleAtCursor(accessor) {
2465
2501
  }
2466
2502
  __name(getFontStyleAtCursor, "getFontStyleAtCursor");
2467
2503
  function getParagraphStyleAtCursor(accessor) {
2468
- var _a23;
2504
+ var _a22;
2469
2505
  const univerInstanceService = accessor.get(IUniverInstanceService), textSelectionService = accessor.get(TextSelectionManagerService), docDataModel = univerInstanceService.getCurrentUniverDocInstance(), activeTextRange = textSelectionService.getActiveTextRangeWithStyle();
2470
2506
  if (docDataModel == null || activeTextRange == null)
2471
2507
  return;
2472
- const { startOffset, segmentId } = activeTextRange, paragraphs = (_a23 = docDataModel.getSelfOrHeaderFooterModel(segmentId).getBody()) == null ? void 0 : _a23.paragraphs;
2508
+ const { startOffset, segmentId } = activeTextRange, paragraphs = (_a22 = docDataModel.getSelfOrHeaderFooterModel(segmentId).getBody()) == null ? void 0 : _a22.paragraphs;
2473
2509
  if (paragraphs == null)
2474
2510
  return;
2475
2511
  let prevIndex = -1;
@@ -2517,11 +2553,11 @@ const DOC_CLIPBOARD_PRIORITY = 999, DocCopyCommand = {
2517
2553
  id: "doc-paragraph-setting.command",
2518
2554
  type: CommandType.COMMAND,
2519
2555
  handler: /* @__PURE__ */ __name(async (accessor, config) => {
2520
- var _a23, _b, _c;
2556
+ var _a22, _b, _c;
2521
2557
  const textSelectionManagerService = accessor.get(TextSelectionManagerService), univerInstanceService = accessor.get(IUniverInstanceService), commandService = accessor.get(ICommandService), docDataModel = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_DOC), docRanges = textSelectionManagerService.getDocRanges();
2522
2558
  if (!docDataModel || docRanges.length === 0 || !config)
2523
2559
  return !1;
2524
- const segmentId = docRanges[0].segmentId, unitId = docDataModel.getUnitId(), allParagraphs = (_b = (_a23 = docDataModel.getSelfOrHeaderFooterModel(segmentId).getBody()) == null ? void 0 : _a23.paragraphs) != null ? _b : [], paragraphs = (_c = getParagraphsInRanges(docRanges, allParagraphs)) != null ? _c : [], serializedSelections = docRanges.map(serializeDocRange), doMutation = {
2560
+ const segmentId = docRanges[0].segmentId, unitId = docDataModel.getUnitId(), allParagraphs = (_b = (_a22 = docDataModel.getSelfOrHeaderFooterModel(segmentId).getBody()) == null ? void 0 : _a22.paragraphs) != null ? _b : [], paragraphs = (_c = getParagraphsInRanges(docRanges, allParagraphs)) != null ? _c : [], serializedSelections = docRanges.map(serializeDocRange), doMutation = {
2525
2561
  id: RichTextEditingMutation.id,
2526
2562
  params: {
2527
2563
  unitId,
@@ -2563,80 +2599,80 @@ const DOC_CLIPBOARD_PRIORITY = 999, DocCopyCommand = {
2563
2599
  return doMutation.params.actions = jsonX.editOp(textX.serialize(), path), !!commandService.syncExecuteCommand(doMutation.id, doMutation.params);
2564
2600
  }, "handler")
2565
2601
  }, useCurrentParagraph = /* @__PURE__ */ __name(() => {
2566
- var _a23, _b, _c;
2602
+ var _a22, _b, _c;
2567
2603
  const textSelectionManagerService = useDependency(TextSelectionManagerService), docDataModel = useDependency(IUniverInstanceService).getCurrentUnitForType(UniverInstanceType.UNIVER_DOC), docRanges = useMemo(() => textSelectionManagerService.getDocRanges(), []);
2568
2604
  if (!docDataModel || docRanges.length === 0)
2569
2605
  return [];
2570
- const segmentId = docRanges[0].segmentId, paragraphs = (_b = (_a23 = docDataModel.getSelfOrHeaderFooterModel(segmentId).getBody()) == null ? void 0 : _a23.paragraphs) != null ? _b : [];
2606
+ const segmentId = docRanges[0].segmentId, paragraphs = (_b = (_a22 = docDataModel.getSelfOrHeaderFooterModel(segmentId).getBody()) == null ? void 0 : _a22.paragraphs) != null ? _b : [];
2571
2607
  return (_c = getParagraphsInRanges(docRanges, paragraphs)) != null ? _c : [];
2572
2608
  }, "useCurrentParagraph"), useFirstParagraphHorizontalAlign = /* @__PURE__ */ __name((paragraph, defaultValue) => {
2573
2609
  const commandService = useDependency(ICommandService), [horizontalAlign, _horizontalAlignSet] = useState(() => {
2574
- var _a23, _b;
2610
+ var _a22, _b;
2575
2611
  const firstParagraph = paragraph[0];
2576
- return firstParagraph ? String((_b = (_a23 = firstParagraph.paragraphStyle) == null ? void 0 : _a23.horizontalAlign) != null ? _b : defaultValue) : defaultValue;
2612
+ return firstParagraph ? String((_b = (_a22 = firstParagraph.paragraphStyle) == null ? void 0 : _a22.horizontalAlign) != null ? _b : defaultValue) : defaultValue;
2577
2613
  });
2578
2614
  return [horizontalAlign, /* @__PURE__ */ __name((v) => (_horizontalAlignSet(v), commandService.executeCommand(DocParagraphSettingCommand.id, {
2579
2615
  horizontalAlign: Number(v)
2580
2616
  })), "horizontalAlignSet")];
2581
2617
  }, "useFirstParagraphHorizontalAlign"), useFirstParagraphIndentStart = /* @__PURE__ */ __name((paragraph) => {
2582
2618
  const commandService = useDependency(ICommandService), [indentStart, _indentStartSet] = useState(() => {
2583
- var _a23;
2619
+ var _a22;
2584
2620
  const firstParagraph = paragraph[0];
2585
- return firstParagraph ? getNumberUnitValue((_a23 = firstParagraph.paragraphStyle) == null ? void 0 : _a23.indentStart, 0) : 0;
2621
+ return firstParagraph ? getNumberUnitValue((_a22 = firstParagraph.paragraphStyle) == null ? void 0 : _a22.indentStart, 0) : 0;
2586
2622
  });
2587
2623
  return [indentStart, /* @__PURE__ */ __name((v) => (_indentStartSet(v), commandService.executeCommand(DocParagraphSettingCommand.id, {
2588
2624
  indentStart: { v }
2589
2625
  })), "indentStartSet")];
2590
2626
  }, "useFirstParagraphIndentStart"), useFirstParagraphIndentEnd = /* @__PURE__ */ __name((paragraph) => {
2591
2627
  const commandService = useDependency(ICommandService), [indentEnd, _indentEndSet] = useState(() => {
2592
- var _a23;
2628
+ var _a22;
2593
2629
  const firstParagraph = paragraph[0];
2594
- return firstParagraph ? getNumberUnitValue((_a23 = firstParagraph.paragraphStyle) == null ? void 0 : _a23.indentEnd, 0) : 0;
2630
+ return firstParagraph ? getNumberUnitValue((_a22 = firstParagraph.paragraphStyle) == null ? void 0 : _a22.indentEnd, 0) : 0;
2595
2631
  });
2596
2632
  return [indentEnd, /* @__PURE__ */ __name((v) => (_indentEndSet(v), commandService.executeCommand(DocParagraphSettingCommand.id, {
2597
2633
  indentEnd: { v }
2598
2634
  })), "indentEndSet")];
2599
2635
  }, "useFirstParagraphIndentEnd"), useFirstParagraphIndentFirstLine = /* @__PURE__ */ __name((paragraph) => {
2600
2636
  const commandService = useDependency(ICommandService), [indentFirstLine, _indentFirstLineSet] = useState(() => {
2601
- var _a23;
2637
+ var _a22;
2602
2638
  const firstParagraph = paragraph[0];
2603
- return firstParagraph ? getNumberUnitValue((_a23 = firstParagraph.paragraphStyle) == null ? void 0 : _a23.indentFirstLine, 0) : 0;
2639
+ return firstParagraph ? getNumberUnitValue((_a22 = firstParagraph.paragraphStyle) == null ? void 0 : _a22.indentFirstLine, 0) : 0;
2604
2640
  });
2605
2641
  return [indentFirstLine, /* @__PURE__ */ __name((v) => (_indentFirstLineSet(v), commandService.executeCommand(DocParagraphSettingCommand.id, {
2606
2642
  indentFirstLine: { v }
2607
2643
  })), "indentFirstLineSet")];
2608
2644
  }, "useFirstParagraphIndentFirstLine"), useFirstParagraphIndentHanging = /* @__PURE__ */ __name((paragraph) => {
2609
2645
  const commandService = useDependency(ICommandService), [hanging, _hangingSet] = useState(() => {
2610
- var _a23;
2646
+ var _a22;
2611
2647
  const firstParagraph = paragraph[0];
2612
- return firstParagraph ? getNumberUnitValue((_a23 = firstParagraph.paragraphStyle) == null ? void 0 : _a23.hanging, 0) : 0;
2648
+ return firstParagraph ? getNumberUnitValue((_a22 = firstParagraph.paragraphStyle) == null ? void 0 : _a22.hanging, 0) : 0;
2613
2649
  });
2614
2650
  return [hanging, /* @__PURE__ */ __name((v) => (_hangingSet(v), commandService.executeCommand(DocParagraphSettingCommand.id, {
2615
2651
  hanging: { v }
2616
2652
  })), "hangingSet")];
2617
2653
  }, "useFirstParagraphIndentHanging"), useFirstParagraphIndentSpaceAbove = /* @__PURE__ */ __name((paragraph) => {
2618
2654
  const commandService = useDependency(ICommandService), [spaceAbove, _spaceAboveSet] = useState(() => {
2619
- var _a23;
2655
+ var _a22;
2620
2656
  const firstParagraph = paragraph[0];
2621
- return firstParagraph ? getNumberUnitValue((_a23 = firstParagraph.paragraphStyle) == null ? void 0 : _a23.spaceAbove, 0) : 0;
2657
+ return firstParagraph ? getNumberUnitValue((_a22 = firstParagraph.paragraphStyle) == null ? void 0 : _a22.spaceAbove, 0) : 0;
2622
2658
  });
2623
2659
  return [spaceAbove, /* @__PURE__ */ __name((v) => (_spaceAboveSet(v), commandService.executeCommand(DocParagraphSettingCommand.id, {
2624
2660
  spaceAbove: { v }
2625
2661
  })), "spaceAboveSet")];
2626
2662
  }, "useFirstParagraphIndentSpaceAbove"), useFirstParagraphSpaceBelow = /* @__PURE__ */ __name((paragraph) => {
2627
2663
  const commandService = useDependency(ICommandService), [spaceBelow, _spaceBelowSet] = useState(() => {
2628
- var _a23;
2664
+ var _a22;
2629
2665
  const firstParagraph = paragraph[0];
2630
- return firstParagraph ? getNumberUnitValue((_a23 = firstParagraph.paragraphStyle) == null ? void 0 : _a23.spaceBelow, 0) : 0;
2666
+ return firstParagraph ? getNumberUnitValue((_a22 = firstParagraph.paragraphStyle) == null ? void 0 : _a22.spaceBelow, 0) : 0;
2631
2667
  });
2632
2668
  return [spaceBelow, /* @__PURE__ */ __name((v) => (_spaceBelowSet(v), commandService.executeCommand(DocParagraphSettingCommand.id, {
2633
2669
  spaceBelow: { v }
2634
2670
  })), "spaceBelowSet")];
2635
2671
  }, "useFirstParagraphSpaceBelow"), useFirstParagraphLineSpacing = /* @__PURE__ */ __name((paragraph) => {
2636
2672
  const commandService = useDependency(ICommandService), [lineSpacing, _lineSpacingSet] = useState(() => {
2637
- var _a23, _b;
2673
+ var _a22, _b;
2638
2674
  const firstParagraph = paragraph[0];
2639
- return firstParagraph && (_b = (_a23 = firstParagraph.paragraphStyle) == null ? void 0 : _a23.lineSpacing) != null ? _b : 1;
2675
+ return firstParagraph && (_b = (_a22 = firstParagraph.paragraphStyle) == null ? void 0 : _a22.lineSpacing) != null ? _b : 1;
2640
2676
  });
2641
2677
  return [lineSpacing, /* @__PURE__ */ __name((v) => (_lineSpacingSet(v), commandService.executeCommand(DocParagraphSettingCommand.id, {
2642
2678
  lineSpacing: v
@@ -2661,8 +2697,8 @@ const DOC_CLIPBOARD_PRIORITY = 999, DocCopyCommand = {
2661
2697
  onChange: /* @__PURE__ */ __name((v) => {
2662
2698
  onChange(v != null ? v : 0).finally(() => {
2663
2699
  setTimeout(() => {
2664
- var _a23;
2665
- (_a23 = ref.current) == null || _a23.focus();
2700
+ var _a22;
2701
+ (_a22 = ref.current) == null || _a22.focus();
2666
2702
  }, 2);
2667
2703
  });
2668
2704
  }, "onChange"),
@@ -2756,13 +2792,13 @@ function ParagraphSettingIndex() {
2756
2792
  const commandService = useDependency(ICommandService), localeService = useDependency(LocaleService), currentLocale = useObservable(localeService.currentLocale$), [key, keySet] = useState(""), rangeRef = useRef([]);
2757
2793
  return useEffect(() => {
2758
2794
  const dispose = commandService.onCommandExecuted((info) => {
2759
- var _a23;
2795
+ var _a22;
2760
2796
  if (SetTextSelectionsOperation.id === info.id) {
2761
2797
  const ranges = info.params.ranges;
2762
2798
  isRangesEqual(ranges, rangeRef.current) || keySet(generateRandomId(4)), rangeRef.current = ranges;
2763
2799
  }
2764
2800
  if (RichTextEditingMutation.id === info.id) {
2765
- const params = info.params, ranges = (_a23 = params.textRanges) != null ? _a23 : [];
2801
+ const params = info.params, ranges = (_a22 = params.textRanges) != null ? _a22 : [];
2766
2802
  params.trigger !== DocParagraphSettingCommand.id && isRangesIntersection(ranges, rangeRef.current) && keySet(generateRandomId(4));
2767
2803
  }
2768
2804
  });
@@ -2772,11 +2808,11 @@ function ParagraphSettingIndex() {
2772
2808
  }, [currentLocale]), /* @__PURE__ */ jsxRuntimeExports.jsx(ParagraphSetting, {}, key);
2773
2809
  }
2774
2810
  __name(ParagraphSettingIndex, "ParagraphSettingIndex");
2775
- var __defProp$g = Object.defineProperty, __getOwnPropDesc$g = Object.getOwnPropertyDescriptor, __decorateClass$g = /* @__PURE__ */ __name((decorators, target, key, kind) => {
2776
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$g(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
2811
+ var __defProp$f = Object.defineProperty, __getOwnPropDesc$f = Object.getOwnPropertyDescriptor, __decorateClass$f = /* @__PURE__ */ __name((decorators, target, key, kind) => {
2812
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$f(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
2777
2813
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
2778
- return kind && result && __defProp$g(target, key, result), result;
2779
- }, "__decorateClass$g"), __decorateParam$g = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$g");
2814
+ return kind && result && __defProp$f(target, key, result), result;
2815
+ }, "__decorateClass$f"), __decorateParam$f = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$f");
2780
2816
  const paragraphSettingIndexKey = "doc_ui_paragraph-setting-panel";
2781
2817
  var _a6;
2782
2818
  let DocParagraphSettingController = (_a6 = class extends Disposable {
@@ -2797,11 +2833,11 @@ let DocParagraphSettingController = (_a6 = class extends Disposable {
2797
2833
  this._sidebarService.open(props);
2798
2834
  }
2799
2835
  }, __name(_a6, "DocParagraphSettingController"), _a6);
2800
- DocParagraphSettingController = __decorateClass$g([
2836
+ DocParagraphSettingController = __decorateClass$f([
2801
2837
  OnLifecycle(LifecycleStages.Rendered, DocParagraphSettingController),
2802
- __decorateParam$g(0, ICommandService),
2803
- __decorateParam$g(1, Inject(ComponentManager)),
2804
- __decorateParam$g(2, Inject(ISidebarService))
2838
+ __decorateParam$f(0, ICommandService),
2839
+ __decorateParam$f(1, Inject(ComponentManager)),
2840
+ __decorateParam$f(2, Inject(ISidebarService))
2805
2841
  ], DocParagraphSettingController);
2806
2842
  const DocParagraphSettingPanelOperation = {
2807
2843
  id: "sidebar.operation.doc-paragraph-setting-panel",
@@ -2828,14 +2864,14 @@ const getDisableWhenSelectionNotInTableObservable = /* @__PURE__ */ __name((acce
2828
2864
  const textSelectionManagerService = accessor.get(TextSelectionManagerService), univerInstanceService = accessor.get(IUniverInstanceService);
2829
2865
  return new Observable((subscriber) => {
2830
2866
  const observable = textSelectionManagerService.textSelection$.subscribe(() => {
2831
- var _a23;
2867
+ var _a22;
2832
2868
  const rectRanges = textSelectionManagerService.getCurrentRectRanges(), activeRange = textSelectionManagerService.getActiveTextRangeWithStyle();
2833
2869
  if (rectRanges && rectRanges.length && inSameTable(rectRanges)) {
2834
2870
  subscriber.next(!1);
2835
2871
  return;
2836
2872
  }
2837
2873
  if (activeRange && (rectRanges == null || rectRanges.length === 0)) {
2838
- const { segmentId, startOffset, endOffset } = activeRange, docDataModel = univerInstanceService.getCurrentUniverDocInstance(), tables = (_a23 = docDataModel == null ? void 0 : docDataModel.getSelfOrHeaderFooterModel(segmentId).getBody()) == null ? void 0 : _a23.tables;
2874
+ const { segmentId, startOffset, endOffset } = activeRange, docDataModel = univerInstanceService.getCurrentUniverDocInstance(), tables = (_a22 = docDataModel == null ? void 0 : docDataModel.getSelfOrHeaderFooterModel(segmentId).getBody()) == null ? void 0 : _a22.tables;
2839
2875
  if (tables && tables.length && tables.some((table) => {
2840
2876
  const { startIndex, endIndex } = table;
2841
2877
  return startOffset > startIndex && startOffset < endIndex || endOffset > startIndex && endOffset < endIndex;
@@ -3001,11 +3037,11 @@ function DeleteTableMenuItemFactory(accessor) {
3001
3037
  };
3002
3038
  }
3003
3039
  __name(DeleteTableMenuItemFactory, "DeleteTableMenuItemFactory");
3004
- var __defProp$f = Object.defineProperty, __getOwnPropDesc$f = Object.getOwnPropertyDescriptor, __decorateClass$f = /* @__PURE__ */ __name((decorators, target, key, kind) => {
3005
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$f(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
3040
+ var __defProp$e = Object.defineProperty, __getOwnPropDesc$e = Object.getOwnPropertyDescriptor, __decorateClass$e = /* @__PURE__ */ __name((decorators, target, key, kind) => {
3041
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$e(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
3006
3042
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
3007
- return kind && result && __defProp$f(target, key, result), result;
3008
- }, "__decorateClass$f"), __decorateParam$f = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$f"), _a7;
3043
+ return kind && result && __defProp$e(target, key, result), result;
3044
+ }, "__decorateClass$e"), __decorateParam$e = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$e"), _a7;
3009
3045
  let DocUIController = (_a7 = class extends Disposable {
3010
3046
  constructor(_config, _injector, _componentManager, _commandService, _layoutService, _menuService, _uiPartsService, _univerInstanceService, _shortcutService) {
3011
3047
  super(), this._config = _config, this._injector = _injector, this._componentManager = _componentManager, this._commandService = _commandService, this._layoutService = _layoutService, this._menuService = _menuService, this._uiPartsService = _uiPartsService, this._univerInstanceService = _univerInstanceService, this._shortcutService = _shortcutService, this._init();
@@ -3015,9 +3051,9 @@ let DocUIController = (_a7 = class extends Disposable {
3015
3051
  this.disposeWithMe(componentManager.register(COLOR_PICKER_COMPONENT, ColorPicker)), this.disposeWithMe(componentManager.register(FONT_FAMILY_COMPONENT, FontFamily)), this.disposeWithMe(componentManager.register(FONT_FAMILY_ITEM_COMPONENT, FontFamilyItem)), this.disposeWithMe(componentManager.register(FONT_SIZE_COMPONENT, FontSize)), this.disposeWithMe(componentManager.register(BULLET_LIST_TYPE_COMPONENT, BulletListTypePicker)), this.disposeWithMe(componentManager.register(ORDER_LIST_TYPE_COMPONENT, OrderListTypePicker)), this.disposeWithMe(componentManager.register("TodoList", TodoList));
3016
3052
  }
3017
3053
  _initUiParts() {
3018
- var _a23, _b;
3054
+ var _a22, _b;
3019
3055
  const workbook = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
3020
- (_b = (_a23 = this._config.layout) == null ? void 0 : _a23.docContainerConfig) != null && _b.footer && !workbook && this.disposeWithMe(this._uiPartsService.registerComponent(BuiltInUIPart.FOOTER, () => connectInjector(DocFooter, this._injector)));
3056
+ (_b = (_a22 = this._config.layout) == null ? void 0 : _a22.docContainerConfig) != null && _b.footer && !workbook && this.disposeWithMe(this._uiPartsService.registerComponent(BuiltInUIPart.FOOTER, () => connectInjector(DocFooter, this._injector)));
3021
3057
  }
3022
3058
  _initMenus() {
3023
3059
  const { menu = {} } = this._config;
@@ -3104,16 +3140,16 @@ let DocUIController = (_a7 = class extends Disposable {
3104
3140
  );
3105
3141
  }
3106
3142
  }, __name(_a7, "DocUIController"), _a7);
3107
- DocUIController = __decorateClass$f([
3143
+ DocUIController = __decorateClass$e([
3108
3144
  OnLifecycle(LifecycleStages.Rendered, DocUIController),
3109
- __decorateParam$f(1, Inject(Injector)),
3110
- __decorateParam$f(2, Inject(ComponentManager)),
3111
- __decorateParam$f(3, ICommandService),
3112
- __decorateParam$f(4, ILayoutService),
3113
- __decorateParam$f(5, IMenuService),
3114
- __decorateParam$f(6, IUIPartsService),
3115
- __decorateParam$f(7, IUniverInstanceService),
3116
- __decorateParam$f(8, IShortcutService)
3145
+ __decorateParam$e(1, Inject(Injector)),
3146
+ __decorateParam$e(2, Inject(ComponentManager)),
3147
+ __decorateParam$e(3, ICommandService),
3148
+ __decorateParam$e(4, ILayoutService),
3149
+ __decorateParam$e(5, IMenuService),
3150
+ __decorateParam$e(6, IUIPartsService),
3151
+ __decorateParam$e(7, IUniverInstanceService),
3152
+ __decorateParam$e(8, IShortcutService)
3117
3153
  ], DocUIController);
3118
3154
  const BreakLineShortcut = {
3119
3155
  id: EnterCommand.id,
@@ -3128,11 +3164,11 @@ const BreakLineShortcut = {
3128
3164
  preconditions: whenDocAndEditorFocused,
3129
3165
  binding: KeyCode.DELETE
3130
3166
  };
3131
- var __defProp$e = Object.defineProperty, __getOwnPropDesc$e = Object.getOwnPropertyDescriptor, __decorateClass$e = /* @__PURE__ */ __name((decorators, target, key, kind) => {
3132
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$e(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
3167
+ var __defProp$d = Object.defineProperty, __getOwnPropDesc$d = Object.getOwnPropertyDescriptor, __decorateClass$d = /* @__PURE__ */ __name((decorators, target, key, kind) => {
3168
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$d(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
3133
3169
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
3134
- return kind && result && __defProp$e(target, key, result), result;
3135
- }, "__decorateClass$e"), __decorateParam$e = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$e"), _a8;
3170
+ return kind && result && __defProp$d(target, key, result), result;
3171
+ }, "__decorateClass$d"), __decorateParam$d = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$d"), _a8;
3136
3172
  let DocClipboardController = (_a8 = class extends RxDisposable {
3137
3173
  constructor(_commandService, _clipboardInterfaceService, _docClipboardService, _textSelectionRenderManager, _contextService) {
3138
3174
  super(), this._commandService = _commandService, this._clipboardInterfaceService = _clipboardInterfaceService, this._docClipboardService = _docClipboardService, this._textSelectionRenderManager = _textSelectionRenderManager, this._contextService = _contextService, this._init();
@@ -3141,30 +3177,30 @@ let DocClipboardController = (_a8 = class extends RxDisposable {
3141
3177
  [DocCopyCommand, DocCutCommand, DocPasteCommand].forEach((command) => this.disposeWithMe(this._commandService.registerMultipleCommand(command))), [InnerPasteCommand, CutContentCommand].forEach((command) => this.disposeWithMe(this._commandService.registerCommand(command))), this._initLegacyPasteCommand();
3142
3178
  }
3143
3179
  _initLegacyPasteCommand() {
3144
- var _a23;
3145
- (_a23 = this._textSelectionRenderManager) == null || _a23.onPaste$.pipe(takeUntil(this.dispose$)).subscribe((config) => {
3146
- var _a24, _b;
3180
+ var _a22;
3181
+ (_a22 = this._textSelectionRenderManager) == null || _a22.onPaste$.pipe(takeUntil(this.dispose$)).subscribe((config) => {
3182
+ var _a23, _b;
3147
3183
  if (!whenDocOrEditor(this._contextService))
3148
3184
  return;
3149
3185
  config.event.preventDefault();
3150
- const clipboardEvent = config.event, htmlContent = (_a24 = clipboardEvent.clipboardData) == null ? void 0 : _a24.getData("text/html"), textContent = (_b = clipboardEvent.clipboardData) == null ? void 0 : _b.getData("text/plain");
3186
+ const clipboardEvent = config.event, htmlContent = (_a23 = clipboardEvent.clipboardData) == null ? void 0 : _a23.getData("text/html"), textContent = (_b = clipboardEvent.clipboardData) == null ? void 0 : _b.getData("text/plain");
3151
3187
  this._docClipboardService.legacyPaste(htmlContent, textContent);
3152
3188
  });
3153
3189
  }
3154
3190
  }, __name(_a8, "DocClipboardController"), _a8);
3155
- DocClipboardController = __decorateClass$e([
3191
+ DocClipboardController = __decorateClass$d([
3156
3192
  OnLifecycle(LifecycleStages.Rendered, DocClipboardController),
3157
- __decorateParam$e(0, ICommandService),
3158
- __decorateParam$e(1, IClipboardInterfaceService),
3159
- __decorateParam$e(2, IDocClipboardService),
3160
- __decorateParam$e(3, ITextSelectionRenderManager),
3161
- __decorateParam$e(4, IContextService)
3193
+ __decorateParam$d(0, ICommandService),
3194
+ __decorateParam$d(1, IClipboardInterfaceService),
3195
+ __decorateParam$d(2, IDocClipboardService),
3196
+ __decorateParam$d(3, ITextSelectionRenderManager),
3197
+ __decorateParam$d(4, IContextService)
3162
3198
  ], DocClipboardController);
3163
- var __defProp$d = Object.defineProperty, __getOwnPropDesc$d = Object.getOwnPropertyDescriptor, __decorateClass$d = /* @__PURE__ */ __name((decorators, target, key, kind) => {
3164
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$d(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
3199
+ var __defProp$c = Object.defineProperty, __getOwnPropDesc$c = Object.getOwnPropertyDescriptor, __decorateClass$c = /* @__PURE__ */ __name((decorators, target, key, kind) => {
3200
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$c(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
3165
3201
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
3166
- return kind && result && __defProp$d(target, key, result), result;
3167
- }, "__decorateClass$d"), __decorateParam$d = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$d"), _a9;
3202
+ return kind && result && __defProp$c(target, key, result), result;
3203
+ }, "__decorateClass$c"), __decorateParam$c = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$c"), _a9;
3168
3204
  let DocEditorBridgeController = (_a9 = class extends Disposable {
3169
3205
  constructor(_univerInstanceService, _editorService, _commandService, _textSelectionRenderManager, _renderManagerService) {
3170
3206
  super();
@@ -3182,7 +3218,7 @@ let DocEditorBridgeController = (_a9 = class extends Disposable {
3182
3218
  }), this._commandExecutedListener(), this._initialSetValue(), this._initialBlur(), this._initialFocus(), this._initialValueChange();
3183
3219
  }
3184
3220
  _resize(unitId) {
3185
- var _a23, _b, _c;
3221
+ var _a22, _b, _c;
3186
3222
  if (unitId == null)
3187
3223
  return;
3188
3224
  const editor = this._editorService.getEditor(unitId);
@@ -3191,7 +3227,7 @@ let DocEditorBridgeController = (_a9 = class extends Disposable {
3191
3227
  const editorDataModel = this._univerInstanceService.getUniverDocInstance(unitId);
3192
3228
  if (!editorDataModel)
3193
3229
  return;
3194
- const skeleton = (_a23 = this._renderManagerService.getRenderById(editorDataModel.getUnitId())) == null ? void 0 : _a23.with(DocSkeletonManagerService).getSkeleton();
3230
+ const skeleton = (_a22 = this._renderManagerService.getRenderById(editorDataModel.getUnitId())) == null ? void 0 : _a22.with(DocSkeletonManagerService).getSkeleton();
3195
3231
  if (editor == null || editor.render == null || skeleton == null || editorDataModel == null)
3196
3232
  return;
3197
3233
  skeleton.calculate();
@@ -3224,8 +3260,8 @@ let DocEditorBridgeController = (_a9 = class extends Disposable {
3224
3260
  })
3225
3261
  ), this.disposeWithMe(
3226
3262
  this._textSelectionRenderManager.onBlur$.subscribe(() => {
3227
- var _a23;
3228
- const unitId = (_a23 = this._univerInstanceService.getCurrentUniverDocInstance()) == null ? void 0 : _a23.getUnitId();
3263
+ var _a22;
3264
+ const unitId = (_a22 = this._univerInstanceService.getCurrentUniverDocInstance()) == null ? void 0 : _a22.getUnitId();
3229
3265
  if (unitId == null)
3230
3266
  return;
3231
3267
  const editor = this._editorService.getEditor(unitId), focusEditor = this._editorService.getFocusEditor();
@@ -3273,8 +3309,8 @@ let DocEditorBridgeController = (_a9 = class extends Disposable {
3273
3309
  );
3274
3310
  }
3275
3311
  _valueChange() {
3276
- var _a23;
3277
- const unitId = (_a23 = this._univerInstanceService.getCurrentUniverDocInstance()) == null ? void 0 : _a23.getUnitId();
3312
+ var _a22;
3313
+ const unitId = (_a22 = this._univerInstanceService.getCurrentUniverDocInstance()) == null ? void 0 : _a22.getUnitId();
3278
3314
  if (unitId == null)
3279
3315
  return;
3280
3316
  const editor = this._editorService.getEditor(unitId);
@@ -3297,26 +3333,26 @@ let DocEditorBridgeController = (_a9 = class extends Disposable {
3297
3333
  );
3298
3334
  }
3299
3335
  }, __name(_a9, "DocEditorBridgeController"), _a9);
3300
- DocEditorBridgeController = __decorateClass$d([
3336
+ DocEditorBridgeController = __decorateClass$c([
3301
3337
  OnLifecycle(LifecycleStages.Rendered, DocEditorBridgeController),
3302
- __decorateParam$d(0, IUniverInstanceService),
3303
- __decorateParam$d(1, IEditorService),
3304
- __decorateParam$d(2, ICommandService),
3305
- __decorateParam$d(3, ITextSelectionRenderManager),
3306
- __decorateParam$d(4, IRenderManagerService)
3338
+ __decorateParam$c(0, IUniverInstanceService),
3339
+ __decorateParam$c(1, IEditorService),
3340
+ __decorateParam$c(2, ICommandService),
3341
+ __decorateParam$c(3, ITextSelectionRenderManager),
3342
+ __decorateParam$c(4, IRenderManagerService)
3307
3343
  ], DocEditorBridgeController);
3308
- var __defProp$c = Object.defineProperty, __getOwnPropDesc$c = Object.getOwnPropertyDescriptor, __decorateClass$c = /* @__PURE__ */ __name((decorators, target, key, kind) => {
3309
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$c(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
3344
+ var __defProp$b = Object.defineProperty, __getOwnPropDesc$b = Object.getOwnPropertyDescriptor, __decorateClass$b = /* @__PURE__ */ __name((decorators, target, key, kind) => {
3345
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$b(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
3310
3346
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
3311
- return kind && result && __defProp$c(target, key, result), result;
3312
- }, "__decorateClass$c"), __decorateParam$c = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$c"), _a10;
3347
+ return kind && result && __defProp$b(target, key, result), result;
3348
+ }, "__decorateClass$b"), __decorateParam$b = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$b"), _a10;
3313
3349
  let DocRenderController = (_a10 = class extends RxDisposable {
3314
3350
  constructor(_context, _contextService, _commandService, _docSkeletonManagerService, _configService, _editorService, _renderManagerService) {
3315
3351
  super(), this._context = _context, this._contextService = _contextService, this._commandService = _commandService, this._docSkeletonManagerService = _docSkeletonManagerService, this._configService = _configService, this._editorService = _editorService, this._renderManagerService = _renderManagerService, this._addNewRender(), this._initRenderRefresh(), this._initCommandListener();
3316
3352
  }
3317
3353
  reRender(unitId) {
3318
- var _a23, _b;
3319
- const docSkeletonManagerService = (_a23 = this._renderManagerService.getRenderById(unitId)) == null ? void 0 : _a23.with(DocSkeletonManagerService), skeleton = docSkeletonManagerService == null ? void 0 : docSkeletonManagerService.getSkeleton();
3354
+ var _a22, _b;
3355
+ const docSkeletonManagerService = (_a22 = this._renderManagerService.getRenderById(unitId)) == null ? void 0 : _a22.with(DocSkeletonManagerService), skeleton = docSkeletonManagerService == null ? void 0 : docSkeletonManagerService.getSkeleton();
3320
3356
  if (!(!skeleton || skeleton.getViewModel().getDataModel().getSnapshot().disabled)) {
3321
3357
  if (skeleton.calculate(), this._editorService.isEditor(unitId)) {
3322
3358
  (_b = this._context.mainComponent) == null || _b.makeDirty();
@@ -3348,7 +3384,7 @@ let DocRenderController = (_a10 = class extends RxDisposable {
3348
3384
  }), this._configService.getConfig("hasScroll") !== !1 && new ScrollBar(viewMain), scene.addLayer(
3349
3385
  new Layer(scene, [], DOCS_COMPONENT_MAIN_LAYER_INDEX),
3350
3386
  new Layer(scene, [], DOCS_COMPONENT_HEADER_LAYER_INDEX)
3351
- ), this._addComponent(), unit.getShouldRenderLoopImmediately() && engine.runRenderLoop(() => {
3387
+ ), this._addComponent(), engine.runRenderLoop(() => {
3352
3388
  scene.render();
3353
3389
  });
3354
3390
  }
@@ -3382,8 +3418,8 @@ let DocRenderController = (_a10 = class extends RxDisposable {
3382
3418
  }));
3383
3419
  }
3384
3420
  _recalculateSizeBySkeleton(skeleton) {
3385
- var _a23;
3386
- const { mainComponent, scene, unitId, components } = this._context, docsComponent = mainComponent, docBackground = components.get(DOCS_VIEW_KEY.BACKGROUND), pages = (_a23 = skeleton.getSkeletonData()) == null ? void 0 : _a23.pages;
3421
+ var _a22;
3422
+ const { mainComponent, scene, unitId, components } = this._context, docsComponent = mainComponent, docBackground = components.get(DOCS_VIEW_KEY.BACKGROUND), pages = (_a22 = skeleton.getSkeletonData()) == null ? void 0 : _a22.pages;
3387
3423
  if (pages == null)
3388
3424
  return;
3389
3425
  let width = 0, height = 0;
@@ -3394,21 +3430,21 @@ let DocRenderController = (_a10 = class extends RxDisposable {
3394
3430
  docsComponent.resize(width, height), docBackground.resize(width, height), this._editorService.isEditor(unitId) || scene.resize(width, height);
3395
3431
  }
3396
3432
  }, __name(_a10, "DocRenderController"), _a10);
3397
- DocRenderController = __decorateClass$c([
3398
- __decorateParam$c(1, IContextService),
3399
- __decorateParam$c(2, ICommandService),
3400
- __decorateParam$c(3, Inject(DocSkeletonManagerService)),
3401
- __decorateParam$c(4, IConfigService),
3402
- __decorateParam$c(5, IEditorService),
3403
- __decorateParam$c(6, IRenderManagerService)
3433
+ DocRenderController = __decorateClass$b([
3434
+ __decorateParam$b(1, IContextService),
3435
+ __decorateParam$b(2, ICommandService),
3436
+ __decorateParam$b(3, Inject(DocSkeletonManagerService)),
3437
+ __decorateParam$b(4, IConfigService),
3438
+ __decorateParam$b(5, IEditorService),
3439
+ __decorateParam$b(6, IRenderManagerService)
3404
3440
  ], DocRenderController);
3405
3441
  const _DocPageLayoutService = class _DocPageLayoutService extends Disposable {
3406
3442
  constructor(_context) {
3407
3443
  super(), this._context = _context;
3408
3444
  }
3409
3445
  calculatePagePosition() {
3410
- var _a23, _b;
3411
- const docObject = neoGetDocObject(this._context), zoomRatio = (_b = (_a23 = this._context.unit.getSettings()) == null ? void 0 : _a23.zoomRatio) != null ? _b : 1, { document: docsComponent, scene, docBackground } = docObject, parent = scene == null ? void 0 : scene.getParent(), { width: docsWidth, height: docsHeight, pageMarginLeft, pageMarginTop } = docsComponent;
3446
+ var _a22, _b;
3447
+ const docObject = neoGetDocObject(this._context), zoomRatio = (_b = (_a22 = this._context.unit.getSettings()) == null ? void 0 : _a22.zoomRatio) != null ? _b : 1, { document: docsComponent, scene, docBackground } = docObject, parent = scene == null ? void 0 : scene.getParent(), { width: docsWidth, height: docsHeight, pageMarginLeft, pageMarginTop } = docsComponent;
3412
3448
  if (parent == null || docsWidth === Number.POSITIVE_INFINITY || docsHeight === Number.POSITIVE_INFINITY)
3413
3449
  return;
3414
3450
  const { width: engineWidth, height: engineHeight } = parent;
@@ -3422,11 +3458,11 @@ const _DocPageLayoutService = class _DocPageLayoutService extends Disposable {
3422
3458
  };
3423
3459
  __name(_DocPageLayoutService, "DocPageLayoutService");
3424
3460
  let DocPageLayoutService = _DocPageLayoutService;
3425
- var __defProp$b = Object.defineProperty, __getOwnPropDesc$b = Object.getOwnPropertyDescriptor, __decorateClass$b = /* @__PURE__ */ __name((decorators, target, key, kind) => {
3426
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$b(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
3461
+ var __defProp$a = Object.defineProperty, __getOwnPropDesc$a = Object.getOwnPropertyDescriptor, __decorateClass$a = /* @__PURE__ */ __name((decorators, target, key, kind) => {
3462
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$a(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
3427
3463
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
3428
- return kind && result && __defProp$b(target, key, result), result;
3429
- }, "__decorateClass$b"), __decorateParam$b = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$b"), _a11;
3464
+ return kind && result && __defProp$a(target, key, result), result;
3465
+ }, "__decorateClass$a"), __decorateParam$a = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$a"), _a11;
3430
3466
  let DocZoomRenderController = (_a11 = class extends Disposable {
3431
3467
  constructor(_context, _contextService, _docSkeletonManagerService, _univerInstanceService, _commandService, _textSelectionManagerService, _editorService, _docPageLayoutService) {
3432
3468
  super(), this._context = _context, this._contextService = _contextService, this._docSkeletonManagerService = _docSkeletonManagerService, this._univerInstanceService = _univerInstanceService, this._commandService = _commandService, this._textSelectionManagerService = _textSelectionManagerService, this._editorService = _editorService, this._docPageLayoutService = _docPageLayoutService, this._initSkeletonListener(), this._initCommandExecutedListener(), this._initRenderRefresher(), setTimeout(() => this.updateViewZoom(1, !0), 20);
@@ -3474,25 +3510,25 @@ let DocZoomRenderController = (_a11 = class extends Disposable {
3474
3510
  }));
3475
3511
  }
3476
3512
  updateViewZoom(zoomRatio, needRefreshSelection = !0) {
3477
- var _a23;
3513
+ var _a22;
3478
3514
  const docObject = neoGetDocObject(this._context);
3479
- docObject.scene.scale(zoomRatio, zoomRatio), this._docPageLayoutService.calculatePagePosition(), needRefreshSelection && !this._editorService.isEditor(this._context.unitId) && this._textSelectionManagerService.refreshSelection(), (_a23 = docObject.scene.getTransformer()) == null || _a23.clearSelectedObjects();
3515
+ docObject.scene.scale(zoomRatio, zoomRatio), this._docPageLayoutService.calculatePagePosition(), needRefreshSelection && !this._editorService.isEditor(this._context.unitId) && this._textSelectionManagerService.refreshSelection(), (_a22 = docObject.scene.getTransformer()) == null || _a22.clearSelectedObjects();
3480
3516
  }
3481
3517
  }, __name(_a11, "DocZoomRenderController"), _a11);
3482
- DocZoomRenderController = __decorateClass$b([
3483
- __decorateParam$b(1, IContextService),
3484
- __decorateParam$b(2, Inject(DocSkeletonManagerService)),
3485
- __decorateParam$b(3, IUniverInstanceService),
3486
- __decorateParam$b(4, ICommandService),
3487
- __decorateParam$b(5, Inject(TextSelectionManagerService)),
3488
- __decorateParam$b(6, IEditorService),
3489
- __decorateParam$b(7, Inject(DocPageLayoutService))
3518
+ DocZoomRenderController = __decorateClass$a([
3519
+ __decorateParam$a(1, IContextService),
3520
+ __decorateParam$a(2, Inject(DocSkeletonManagerService)),
3521
+ __decorateParam$a(3, IUniverInstanceService),
3522
+ __decorateParam$a(4, ICommandService),
3523
+ __decorateParam$a(5, Inject(TextSelectionManagerService)),
3524
+ __decorateParam$a(6, IEditorService),
3525
+ __decorateParam$a(7, Inject(DocPageLayoutService))
3490
3526
  ], DocZoomRenderController);
3491
- var __defProp$a = Object.defineProperty, __getOwnPropDesc$a = Object.getOwnPropertyDescriptor, __decorateClass$a = /* @__PURE__ */ __name((decorators, target, key, kind) => {
3492
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$a(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
3527
+ var __defProp$9 = Object.defineProperty, __getOwnPropDesc$9 = Object.getOwnPropertyDescriptor, __decorateClass$9 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
3528
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$9(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
3493
3529
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
3494
- return kind && result && __defProp$a(target, key, result), result;
3495
- }, "__decorateClass$a"), __decorateParam$a = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$a"), _a12;
3530
+ return kind && result && __defProp$9(target, key, result), result;
3531
+ }, "__decorateClass$9"), __decorateParam$9 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$9"), _a12;
3496
3532
  let DocTextSelectionRenderController = (_a12 = class extends Disposable {
3497
3533
  constructor(_context, _commandService, _editorService, _instanceSrv, _textSelectionRenderManager, _docSkeletonManagerService, _textSelectionManagerService) {
3498
3534
  super();
@@ -3564,9 +3600,9 @@ let DocTextSelectionRenderController = (_a12 = class extends Disposable {
3564
3600
  const updateCommandList = [SetDocZoomRatioOperation.id];
3565
3601
  this.disposeWithMe(
3566
3602
  this._commandService.onCommandExecuted((command) => {
3567
- var _a23;
3603
+ var _a22;
3568
3604
  if (updateCommandList.includes(command.id)) {
3569
- const params = command.params, { unitId: documentId } = params, unitId = (_a23 = this._textSelectionManagerService.getCurrentSelection()) == null ? void 0 : _a23.unitId;
3605
+ const params = command.params, { unitId: documentId } = params, unitId = (_a22 = this._textSelectionManagerService.getCurrentSelection()) == null ? void 0 : _a22.unitId;
3570
3606
  if (documentId !== unitId)
3571
3607
  return;
3572
3608
  this._textSelectionManagerService.refreshSelection();
@@ -3591,19 +3627,19 @@ let DocTextSelectionRenderController = (_a12 = class extends Disposable {
3591
3627
  }));
3592
3628
  }
3593
3629
  }, __name(_a12, "DocTextSelectionRenderController"), _a12);
3594
- DocTextSelectionRenderController = __decorateClass$a([
3595
- __decorateParam$a(1, ICommandService),
3596
- __decorateParam$a(2, IEditorService),
3597
- __decorateParam$a(3, IUniverInstanceService),
3598
- __decorateParam$a(4, ITextSelectionRenderManager),
3599
- __decorateParam$a(5, Inject(DocSkeletonManagerService)),
3600
- __decorateParam$a(6, Inject(TextSelectionManagerService))
3630
+ DocTextSelectionRenderController = __decorateClass$9([
3631
+ __decorateParam$9(1, ICommandService),
3632
+ __decorateParam$9(2, IEditorService),
3633
+ __decorateParam$9(3, IUniverInstanceService),
3634
+ __decorateParam$9(4, ITextSelectionRenderManager),
3635
+ __decorateParam$9(5, Inject(DocSkeletonManagerService)),
3636
+ __decorateParam$9(6, Inject(TextSelectionManagerService))
3601
3637
  ], DocTextSelectionRenderController);
3602
- var __defProp$9 = Object.defineProperty, __getOwnPropDesc$9 = Object.getOwnPropertyDescriptor, __decorateClass$9 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
3603
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$9(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
3638
+ var __defProp$8 = Object.defineProperty, __getOwnPropDesc$8 = Object.getOwnPropertyDescriptor, __decorateClass$8 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
3639
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$8(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
3604
3640
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
3605
- return kind && result && __defProp$9(target, key, result), result;
3606
- }, "__decorateClass$9"), __decorateParam$9 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$9");
3641
+ return kind && result && __defProp$8(target, key, result), result;
3642
+ }, "__decorateClass$8"), __decorateParam$8 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$8");
3607
3643
  function transformBound2OffsetBound(originBound, scene) {
3608
3644
  const topLeft = transformPosition2Offset(originBound.left, originBound.top, scene), bottomRight = transformPosition2Offset(originBound.right, originBound.bottom, scene);
3609
3645
  return {
@@ -3628,6 +3664,32 @@ function transformPosition2Offset(x, y, scene) {
3628
3664
  };
3629
3665
  }
3630
3666
  __name(transformPosition2Offset, "transformPosition2Offset");
3667
+ function transformOffset2Bound(offsetX, offsetY, scene) {
3668
+ const { scaleX, scaleY } = scene.getAncestorScale(), viewMain = scene.getViewport(VIEWPORT_KEY.VIEW_MAIN);
3669
+ if (!viewMain)
3670
+ return {
3671
+ x: offsetX,
3672
+ y: offsetY
3673
+ };
3674
+ const { viewportScrollX: actualScrollX, viewportScrollY: actualScrollY } = viewMain, x = offsetX / scaleX + actualScrollX, y = offsetY / scaleY + actualScrollY;
3675
+ return {
3676
+ x,
3677
+ y
3678
+ };
3679
+ }
3680
+ __name(transformOffset2Bound, "transformOffset2Bound");
3681
+ const calcDocRangePositions$1 = /* @__PURE__ */ __name((range, currentRender) => {
3682
+ const { scene, mainComponent, engine } = currentRender, skeleton = currentRender.with(DocSkeletonManagerService).getSkeleton(), startPosition = skeleton.findNodePositionByCharIndex(range.startOffset, !1, range.segmentId, range.segmentPage), endPosition = skeleton.findNodePositionByCharIndex(range.endOffset, !1, range.segmentId, range.segmentPage), document = mainComponent;
3683
+ if (!endPosition || !startPosition)
3684
+ return;
3685
+ const documentOffsetConfig = document.getOffsetConfig(), { docsLeft, docsTop } = documentOffsetConfig, canvasElement = engine.getCanvasElement(), canvasClientRect = canvasElement.getBoundingClientRect(), widthOfCanvas = pxToNum(canvasElement.style.width), { top, left, width } = canvasClientRect, scaleAdjust = width / widthOfCanvas, { scaleX, scaleY } = scene.getAncestorScale(), convertor = new NodePositionConvertToCursor(documentOffsetConfig, skeleton), { borderBoxPointGroup } = convertor.getRangePointData(startPosition, endPosition);
3686
+ return getLineBounding(borderBoxPointGroup).map((bound) => transformBound2OffsetBound(bound, scene)).map((i) => ({
3687
+ left: (i.left + docsLeft * scaleX) * scaleAdjust + left,
3688
+ right: (i.right + docsLeft * scaleX) * scaleAdjust + left,
3689
+ top: (i.top + docsTop * scaleY) * scaleAdjust + top,
3690
+ bottom: (i.bottom + docsTop * scaleY) * scaleAdjust + top
3691
+ }));
3692
+ }, "calcDocRangePositions$1");
3631
3693
  var _a13;
3632
3694
  let DocCanvasPopManagerService = (_a13 = class extends Disposable {
3633
3695
  constructor(_globalPopupManagerService, _renderManagerService, _univerInstanceService, _commandService) {
@@ -3662,28 +3724,17 @@ let DocCanvasPopManagerService = (_a13 = class extends Disposable {
3662
3724
  };
3663
3725
  }
3664
3726
  _createRangePositionObserver(range, currentRender) {
3665
- var _a23;
3666
- const calc = /* @__PURE__ */ __name(() => {
3667
- const { scene, mainComponent, engine } = currentRender, skeleton = currentRender.with(DocSkeletonManagerService).getSkeleton(), startPosition = skeleton.findNodePositionByCharIndex(range.startOffset), endPosition = skeleton.findNodePositionByCharIndex(range.endOffset), document = mainComponent;
3668
- if (!endPosition || !startPosition)
3669
- return;
3670
- const documentOffsetConfig = document.getOffsetConfig(), { docsLeft, docsTop } = documentOffsetConfig, canvasElement = engine.getCanvasElement(), canvasClientRect = canvasElement.getBoundingClientRect(), widthOfCanvas = pxToNum(canvasElement.style.width), { top, left, width } = canvasClientRect, scaleAdjust = width / widthOfCanvas, { scaleX, scaleY } = scene.getAncestorScale(), convertor = new NodePositionConvertToCursor(documentOffsetConfig, skeleton), { contentBoxPointGroup } = convertor.getRangePointData(startPosition, endPosition);
3671
- return getLineBounding(contentBoxPointGroup).map((bound) => transformBound2OffsetBound(bound, scene)).map((i) => ({
3672
- left: (i.left + docsLeft * scaleX) * scaleAdjust + left,
3673
- right: (i.right + docsLeft * scaleX) * scaleAdjust + left,
3674
- top: (i.top + docsTop * scaleY) * scaleAdjust + top,
3675
- bottom: (i.bottom + docsTop * scaleY) * scaleAdjust + top
3676
- }));
3677
- }, "calc"), positions = (_a23 = calc()) != null ? _a23 : [], positions$ = new BehaviorSubject(positions), disposable = new DisposableCollection();
3727
+ var _a22;
3728
+ const positions = (_a22 = calcDocRangePositions$1(range, currentRender)) != null ? _a22 : [], positions$ = new BehaviorSubject(positions), disposable = new DisposableCollection();
3678
3729
  disposable.add(this._commandService.onCommandExecuted((commandInfo) => {
3679
3730
  if (commandInfo.id === SetDocZoomRatioOperation.id) {
3680
- const position = calc();
3731
+ const position = calcDocRangePositions$1(range, currentRender);
3681
3732
  position && positions$.next(position);
3682
3733
  }
3683
3734
  }));
3684
3735
  const viewMain = currentRender.scene.getViewport(VIEWPORT_KEY.VIEW_MAIN);
3685
3736
  return viewMain && disposable.add(viewMain.onScrollAfter$.subscribeEvent(() => {
3686
- const position = calc();
3737
+ const position = calcDocRangePositions$1(range, currentRender);
3687
3738
  position && positions$.next(position);
3688
3739
  })), {
3689
3740
  positions,
@@ -3709,7 +3760,8 @@ let DocCanvasPopManagerService = (_a13 = class extends Disposable {
3709
3760
  unitId,
3710
3761
  subUnitId: "default",
3711
3762
  anchorRect: position,
3712
- anchorRect$: position$
3763
+ anchorRect$: position$,
3764
+ canvasElement: currentRender.engine.getCanvasElement()
3713
3765
  });
3714
3766
  return {
3715
3767
  dispose: /* @__PURE__ */ __name(() => {
@@ -3732,7 +3784,8 @@ let DocCanvasPopManagerService = (_a13 = class extends Disposable {
3732
3784
  anchorRect$: position$,
3733
3785
  excludeRects: bounds,
3734
3786
  excludeRects$: bounds$,
3735
- direction: direction === "top" ? "top" : "bottom"
3787
+ direction: direction === "top" ? "top" : "bottom",
3788
+ canvasElement: currentRender.engine.getCanvasElement()
3736
3789
  });
3737
3790
  return {
3738
3791
  dispose: /* @__PURE__ */ __name(() => {
@@ -3741,17 +3794,17 @@ let DocCanvasPopManagerService = (_a13 = class extends Disposable {
3741
3794
  };
3742
3795
  }
3743
3796
  }, __name(_a13, "DocCanvasPopManagerService"), _a13);
3744
- DocCanvasPopManagerService = __decorateClass$9([
3745
- __decorateParam$9(0, Inject(ICanvasPopupService)),
3746
- __decorateParam$9(1, IRenderManagerService),
3747
- __decorateParam$9(2, IUniverInstanceService),
3748
- __decorateParam$9(3, ICommandService)
3797
+ DocCanvasPopManagerService = __decorateClass$8([
3798
+ __decorateParam$8(0, Inject(ICanvasPopupService)),
3799
+ __decorateParam$8(1, IRenderManagerService),
3800
+ __decorateParam$8(2, IUniverInstanceService),
3801
+ __decorateParam$8(3, ICommandService)
3749
3802
  ], DocCanvasPopManagerService);
3750
- var __defProp$8 = Object.defineProperty, __getOwnPropDesc$8 = Object.getOwnPropertyDescriptor, __decorateClass$8 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
3751
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$8(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
3803
+ var __defProp$7 = Object.defineProperty, __getOwnPropDesc$7 = Object.getOwnPropertyDescriptor, __decorateClass$7 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
3804
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$7(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
3752
3805
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
3753
- return kind && result && __defProp$8(target, key, result), result;
3754
- }, "__decorateClass$8"), __decorateParam$8 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$8"), _a14;
3806
+ return kind && result && __defProp$7(target, key, result), result;
3807
+ }, "__decorateClass$7"), __decorateParam$7 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$7"), _a14;
3755
3808
  let DocsRenderService = (_a14 = class extends RxDisposable {
3756
3809
  constructor(_instanceSrv, _renderManagerService) {
3757
3810
  super(), this._instanceSrv = _instanceSrv, this._renderManagerService = _renderManagerService, this._init();
@@ -3771,17 +3824,17 @@ let DocsRenderService = (_a14 = class extends RxDisposable {
3771
3824
  this._renderManagerService.removeRender(unitId);
3772
3825
  }
3773
3826
  }, __name(_a14, "DocsRenderService"), _a14);
3774
- DocsRenderService = __decorateClass$8([
3827
+ DocsRenderService = __decorateClass$7([
3775
3828
  OnLifecycle(LifecycleStages.Ready, DocsRenderService),
3776
- __decorateParam$8(0, IUniverInstanceService),
3777
- __decorateParam$8(1, IRenderManagerService)
3829
+ __decorateParam$7(0, IUniverInstanceService),
3830
+ __decorateParam$7(1, IRenderManagerService)
3778
3831
  ], DocsRenderService);
3779
- var __defProp$7 = Object.defineProperty, __getOwnPropDesc$7 = Object.getOwnPropertyDescriptor, __decorateClass$7 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
3780
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$7(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
3832
+ var __defProp$6 = Object.defineProperty, __getOwnPropDesc$6 = Object.getOwnPropertyDescriptor, __decorateClass$6 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
3833
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$6(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
3781
3834
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
3782
- return kind && result && __defProp$7(target, key, result), result;
3783
- }, "__decorateClass$7"), __decorateParam$7 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$7");
3784
- const SKIP_UNIT_IDS$1 = [
3835
+ return kind && result && __defProp$6(target, key, result), result;
3836
+ }, "__decorateClass$6"), __decorateParam$6 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$6");
3837
+ const SKIP_UNIT_IDS = [
3785
3838
  DEFAULT_EMPTY_DOCUMENT_VALUE,
3786
3839
  DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,
3787
3840
  DOCS_NORMAL_EDITOR_UNIT_ID_KEY,
@@ -3790,11 +3843,11 @@ const SKIP_UNIT_IDS$1 = [
3790
3843
  var _a15;
3791
3844
  let DocContextMenuRenderController = (_a15 = class extends Disposable {
3792
3845
  constructor(_context, _contextMenuService, _textSelectionManagerService, _commandService) {
3793
- super(), this._context = _context, this._contextMenuService = _contextMenuService, this._textSelectionManagerService = _textSelectionManagerService, this._commandService = _commandService, SKIP_UNIT_IDS$1.includes(this._context.unitId) || (this._initPointerDown(), this._initEditChange());
3846
+ super(), this._context = _context, this._contextMenuService = _contextMenuService, this._textSelectionManagerService = _textSelectionManagerService, this._commandService = _commandService, SKIP_UNIT_IDS.includes(this._context.unitId) || (this._initPointerDown(), this._initEditChange());
3794
3847
  }
3795
3848
  _initPointerDown() {
3796
- var _a23, _b;
3797
- const documentsSubscription = ((_b = (_a23 = this._context) == null ? void 0 : _a23.mainComponent) == null ? void 0 : _b.onPointerDown$).subscribeEvent((event) => {
3849
+ var _a22, _b;
3850
+ const documentsSubscription = ((_b = (_a22 = this._context) == null ? void 0 : _a22.mainComponent) == null ? void 0 : _b.onPointerDown$).subscribeEvent((event) => {
3798
3851
  event.button === 2 && this._contextMenuService.triggerContextMenu(event, MenuPosition.CONTEXT_MENU);
3799
3852
  });
3800
3853
  this.disposeWithMe(documentsSubscription);
@@ -3807,157 +3860,234 @@ let DocContextMenuRenderController = (_a15 = class extends Disposable {
3807
3860
  );
3808
3861
  }
3809
3862
  }, __name(_a15, "DocContextMenuRenderController"), _a15);
3810
- DocContextMenuRenderController = __decorateClass$7([
3811
- __decorateParam$7(1, IContextMenuService),
3812
- __decorateParam$7(2, Inject(TextSelectionManagerService)),
3813
- __decorateParam$7(3, ICommandService)
3863
+ DocContextMenuRenderController = __decorateClass$6([
3864
+ __decorateParam$6(1, IContextMenuService),
3865
+ __decorateParam$6(2, Inject(TextSelectionManagerService)),
3866
+ __decorateParam$6(3, ICommandService)
3814
3867
  ], DocContextMenuRenderController);
3815
- var __defProp$6 = Object.defineProperty, __getOwnPropDesc$6 = Object.getOwnPropertyDescriptor, __decorateClass$6 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
3816
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$6(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
3868
+ var __defProp$5 = Object.defineProperty, __getOwnPropDesc$5 = Object.getOwnPropertyDescriptor, __decorateClass$5 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
3869
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$5(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
3817
3870
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
3818
- return kind && result && __defProp$6(target, key, result), result;
3819
- }, "__decorateClass$6"), __decorateParam$6 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$6");
3820
- const SKIP_UNIT_IDS = [
3821
- DEFAULT_EMPTY_DOCUMENT_VALUE,
3822
- DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,
3823
- DOCS_NORMAL_EDITOR_UNIT_ID_KEY
3824
- ];
3825
- var _a16;
3871
+ return kind && result && __defProp$5(target, key, result), result;
3872
+ }, "__decorateClass$5"), __decorateParam$5 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$5"), _a16;
3826
3873
  let DocResizeRenderController = (_a16 = class extends Disposable {
3827
3874
  constructor(_context, _docPageLayoutService, _textSelectionManagerService) {
3828
- super(), this._context = _context, this._docPageLayoutService = _docPageLayoutService, this._textSelectionManagerService = _textSelectionManagerService, SKIP_UNIT_IDS.includes(this._context.unitId) || this._initResize();
3875
+ super(), this._context = _context, this._docPageLayoutService = _docPageLayoutService, this._textSelectionManagerService = _textSelectionManagerService;
3876
+ const unitId = this._context.unitId;
3877
+ if (isInternalEditorID(unitId) && unitId !== DOCS_ZEN_EDITOR_UNIT_ID_KEY) return this;
3878
+ this._initResize();
3829
3879
  }
3830
3880
  _initResize() {
3831
3881
  this.disposeWithMe(
3832
3882
  fromEventSubject(this._context.engine.onTransformChange$).pipe(
3833
3883
  filter((evt) => evt.type === TRANSFORM_CHANGE_OBSERVABLE_TYPE.resize),
3834
- throttleTime(16)
3884
+ throttleTime(0, animationFrameScheduler)
3835
3885
  ).subscribe(() => {
3836
3886
  this._docPageLayoutService.calculatePagePosition(), this._textSelectionManagerService.refreshSelection();
3837
3887
  })
3838
3888
  );
3839
3889
  }
3840
3890
  }, __name(_a16, "DocResizeRenderController"), _a16);
3841
- DocResizeRenderController = __decorateClass$6([
3842
- __decorateParam$6(1, Inject(DocPageLayoutService)),
3843
- __decorateParam$6(2, Inject(TextSelectionManagerService))
3891
+ DocResizeRenderController = __decorateClass$5([
3892
+ __decorateParam$5(1, Inject(DocPageLayoutService)),
3893
+ __decorateParam$5(2, Inject(TextSelectionManagerService))
3844
3894
  ], DocResizeRenderController);
3845
- var __defProp$5 = Object.defineProperty, __getOwnPropDesc$5 = Object.getOwnPropertyDescriptor, __decorateClass$5 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
3846
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$5(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
3895
+ var __defProp$4 = Object.defineProperty, __getOwnPropDesc$4 = Object.getOwnPropertyDescriptor, __decorateClass$4 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
3896
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$4(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
3847
3897
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
3848
- return kind && result && __defProp$5(target, key, result), result;
3849
- }, "__decorateClass$5"), __decorateParam$5 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$5"), _a17;
3850
- let DocHoverManagerService = (_a17 = class extends Disposable {
3851
- constructor(_univerInstanceService, _renderManagerService) {
3898
+ return kind && result && __defProp$4(target, key, result), result;
3899
+ }, "__decorateClass$4"), __decorateParam$4 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$4");
3900
+ const calcDocRangePositions = /* @__PURE__ */ __name((range, documents, skeleton, pageIndex) => {
3901
+ var _a22, _b, _c, _d, _e;
3902
+ const startPosition = skeleton.findNodePositionByCharIndex(range.startOffset, !1, range.segmentId, pageIndex), skeletonData = skeleton.getSkeletonData();
3903
+ let end = range.endOffset;
3904
+ if (range.segmentId) {
3905
+ const root = (_e = Array.from((_b = (_a22 = skeletonData == null ? void 0 : skeletonData.skeFooters.get(range.segmentId)) == null ? void 0 : _a22.values()) != null ? _b : [])[0]) != null ? _e : Array.from((_d = (_c = skeletonData == null ? void 0 : skeletonData.skeHeaders.get(range.segmentId)) == null ? void 0 : _c.values()) != null ? _d : [])[0];
3906
+ root && (end = Math.min(root.ed, end));
3907
+ }
3908
+ const endPosition = skeleton.findNodePositionByCharIndex(end, !1, range.segmentId, pageIndex);
3909
+ if (!endPosition || !startPosition)
3910
+ return;
3911
+ const documentOffsetConfig = documents.getOffsetConfig(), convertor = new NodePositionConvertToCursor(documentOffsetConfig, skeleton), { borderBoxPointGroup } = convertor.getRangePointData(startPosition, endPosition);
3912
+ return getLineBounding(borderBoxPointGroup).map((rect) => ({
3913
+ top: rect.top + documentOffsetConfig.docsTop,
3914
+ bottom: rect.bottom + documentOffsetConfig.docsTop,
3915
+ left: rect.left + documentOffsetConfig.docsLeft,
3916
+ right: rect.right + documentOffsetConfig.docsLeft
3917
+ }));
3918
+ }, "calcDocRangePositions"), calcDocGlyphPosition = /* @__PURE__ */ __name((glyph, documents, skeleton, pageIndex = -1) => {
3919
+ const start = skeleton.findPositionByGlyph(glyph, pageIndex);
3920
+ if (!start)
3921
+ return;
3922
+ const documentOffsetConfig = documents.getOffsetConfig(), startPosition = { ...start, isBack: !0 }, convertor = new NodePositionConvertToCursor(documentOffsetConfig, skeleton), { borderBoxPointGroup } = convertor.getRangePointData(startPosition, startPosition), rect = getLineBounding(borderBoxPointGroup)[0];
3923
+ return {
3924
+ top: rect.top + documentOffsetConfig.docsTop,
3925
+ bottom: rect.bottom + documentOffsetConfig.docsTop,
3926
+ left: rect.left + documentOffsetConfig.docsLeft,
3927
+ right: rect.left + documentOffsetConfig.docsLeft + glyph.width
3928
+ };
3929
+ }, "calcDocGlyphPosition");
3930
+ var _a17;
3931
+ let DocEventManagerService = (_a17 = class extends Disposable {
3932
+ constructor(_context, _docSkeletonManagerService) {
3852
3933
  super();
3853
- __publicField(this, "_activeCustomRanges$", new Subject());
3854
- __publicField(this, "activeCustomRanges$", this._activeCustomRanges$.asObservable());
3855
- __publicField(this, "_activeIndex$", new Subject());
3856
- __publicField(this, "activeIndex$", this._activeIndex$.asObservable());
3857
- __publicField(this, "_bullet$", new Subject());
3858
- __publicField(this, "bullet$", this._bullet$.asObservable());
3859
- __publicField(this, "_scrolling", !1);
3860
- this._univerInstanceService = _univerInstanceService, this._renderManagerService = _renderManagerService, this.disposeWithMe(() => {
3861
- this._activeCustomRanges$.complete(), this._activeIndex$.complete();
3862
- });
3934
+ __publicField(this, "_hoverCustomRanges$", new Subject());
3935
+ __publicField(this, "hoverCustomRanges$", this._hoverCustomRanges$.pipe(distinctUntilChanged((pre, aft) => pre.length === aft.length && pre.every((item, i) => aft[i].range.rangeId === item.range.rangeId && aft[i].segmentId === item.segmentId && aft[i].segmentPageIndex === item.segmentPageIndex))));
3936
+ __publicField(this, "_clickCustomRanges$", new Subject());
3937
+ __publicField(this, "clickCustomRanges$", this._clickCustomRanges$.asObservable());
3938
+ __publicField(this, "_hoverBullet$", new Subject());
3939
+ __publicField(this, "hoverBullet$", this._hoverBullet$.pipe(distinctUntilChanged((pre, aft) => (pre == null ? void 0 : pre.paragraph.startIndex) === (aft == null ? void 0 : aft.paragraph.startIndex) && (pre == null ? void 0 : pre.segmentId) === (aft == null ? void 0 : aft.segmentId) && (pre == null ? void 0 : pre.segmentPageIndex) === (aft == null ? void 0 : aft.segmentPageIndex))));
3940
+ __publicField(this, "_clickBullet$", new Subject());
3941
+ __publicField(this, "clickBullets$", this._clickBullet$.asObservable());
3942
+ __publicField(this, "_customRangeDirty", !0);
3943
+ __publicField(this, "_bulletDirty", !0);
3944
+ /**
3945
+ * cache the bounding of custom ranges,
3946
+ * it will be updated when the doc-skeleton is recalculated
3947
+ */
3948
+ __publicField(this, "_customRangeBounds", []);
3949
+ /**
3950
+ * cache the bounding of bullets,
3951
+ * it will be updated when the doc-skeleton is recalculated
3952
+ */
3953
+ __publicField(this, "_bulletBounds", []);
3954
+ this._context = _context, this._docSkeletonManagerService = _docSkeletonManagerService, this._initResetDirty(), this._initEvents(), this._initPointer();
3863
3955
  }
3864
- _getTransformCoordForDocumentOffset(document, viewport, evtOffsetX, evtOffsetY) {
3865
- const { documentTransform } = document.getOffsetConfig(), originCoord = viewport.transformVector2SceneCoord(Vector2.FromArray([evtOffsetX, evtOffsetY]));
3866
- if (originCoord)
3867
- return documentTransform.clone().invert().applyPoint(originCoord);
3956
+ get _skeleton() {
3957
+ return this._docSkeletonManagerService.getSkeleton();
3868
3958
  }
3869
- _calcActiveCustomRanges(offsetX, offsetY) {
3870
- var _a23, _b;
3871
- const document = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_DOC);
3872
- if (!document) {
3873
- this._activeCustomRanges$.next([]);
3874
- return;
3875
- }
3876
- const currentRender = this._renderManagerService.getRenderById(document.getUnitId());
3877
- if (!currentRender)
3878
- return null;
3879
- const documentComponent = currentRender.mainComponent, skeleton = currentRender.with(DocSkeletonManagerService).getSkeleton(), { pageLayoutType = PageLayoutType.VERTICAL, pageMarginLeft, pageMarginTop, docsLeft, docsTop } = documentComponent.getOffsetConfig(), coord = this._getTransformCoordForDocumentOffset(
3880
- documentComponent,
3881
- currentRender.scene.getViewport(VIEWPORT_KEY.VIEW_MAIN),
3882
- offsetX,
3883
- offsetY
3884
- );
3885
- if (!coord)
3886
- return;
3887
- const node = skeleton.findNodeByCoord(
3888
- coord,
3889
- pageLayoutType,
3890
- pageMarginLeft,
3891
- pageMarginTop
3892
- );
3893
- if (node && node.node) {
3894
- const left = node.node.left + pageMarginLeft, right = node.node.left + node.node.width + pageMarginLeft;
3895
- let index = node.node.parent.st + node.node.parent.glyphGroup.indexOf(node.node);
3896
- const paragraph = getParagraphByGlyph(node.node, document.getBody());
3897
- if (paragraph && paragraph.bullet && index === paragraph.paragraphStart) {
3898
- this._bullet$.next(paragraph), this._activeIndex$.next(null), this._activeCustomRanges$.next([]);
3899
- return;
3900
- }
3901
- if (coord.x < left || coord.x > right) {
3902
- this._activeIndex$.next(null), this._activeCustomRanges$.next([]), this._bullet$.next(null);
3903
- return;
3904
- }
3905
- paragraph && paragraph.bullet && (index = index - 1), this._bullet$.next(null), this._activeIndex$.next(index);
3906
- const ranges = (_b = (_a23 = document.getCustomRanges()) == null ? void 0 : _a23.filter((range) => range.startIndex <= index && range.endIndex >= index)) != null ? _b : [];
3907
- this._activeCustomRanges$.next(ranges);
3908
- }
3959
+ get _documents() {
3960
+ return this._context.mainComponent;
3909
3961
  }
3910
- onMouseMove(evt) {
3911
- if (this._scrolling)
3912
- return;
3913
- const { offsetX, offsetY } = evt;
3914
- this._calcActiveCustomRanges(offsetX, offsetY);
3962
+ dispose() {
3963
+ this._hoverCustomRanges$.complete(), this._clickCustomRanges$.complete(), super.dispose();
3915
3964
  }
3916
- startScroll() {
3917
- this._scrolling || (this._scrolling = !0);
3965
+ _initPointer() {
3966
+ let preCursor = CURSOR_TYPE.TEXT;
3967
+ this.disposeWithMe(this.hoverCustomRanges$.subscribe((ranges) => {
3968
+ ranges.length ? (preCursor = this._context.scene.getCursor(), this._context.scene.setCursor(CURSOR_TYPE.POINTER)) : this._context.scene.setCursor(preCursor);
3969
+ }));
3918
3970
  }
3919
- endScroll() {
3920
- this._scrolling = !1;
3971
+ _initResetDirty() {
3972
+ this.disposeWithMe(this._skeleton.dirty$.subscribe(() => {
3973
+ this._customRangeDirty = !0, this._bulletDirty = !0;
3974
+ })), this.disposeWithMe(
3975
+ fromEventSubject(this._context.engine.onTransformChange$).pipe(
3976
+ filter((evt) => evt.type === TRANSFORM_CHANGE_OBSERVABLE_TYPE.resize)
3977
+ ).subscribe(() => {
3978
+ this._customRangeDirty = !0, this._bulletDirty = !0;
3979
+ })
3980
+ );
3921
3981
  }
3922
- }, __name(_a17, "DocHoverManagerService"), _a17);
3923
- DocHoverManagerService = __decorateClass$5([
3924
- __decorateParam$5(0, IUniverInstanceService),
3925
- __decorateParam$5(1, IRenderManagerService)
3926
- ], DocHoverManagerService);
3927
- var __defProp$4 = Object.defineProperty, __getOwnPropDesc$4 = Object.getOwnPropertyDescriptor, __decorateClass$4 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
3928
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$4(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
3929
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
3930
- return kind && result && __defProp$4(target, key, result), result;
3931
- }, "__decorateClass$4"), __decorateParam$4 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$4"), _a18;
3932
- let DocHoverRenderController = (_a18 = class extends Disposable {
3933
- constructor(_context, _docHoverManagerService) {
3934
- super(), this._context = _context, this._docHoverManagerService = _docHoverManagerService, this._initPointerDown(), this._initScroll();
3982
+ _initEvents() {
3983
+ this.disposeWithMe(fromEventSubject(this._context.scene.onPointerMove$).pipe(throttleTime(0, animationFrameScheduler)).subscribe((evt) => {
3984
+ this._hoverCustomRanges$.next(
3985
+ this._calcActiveRanges(evt)
3986
+ ), this._hoverBullet$.next(
3987
+ this._calcActiveBullet(evt)
3988
+ );
3989
+ }));
3990
+ const onPointerDown$ = fromEventSubject(this._context.mainComponent.onPointerDown$), onPointerUp$ = fromEventSubject(this._context.scene.onPointerUp$);
3991
+ this.disposeWithMe(onPointerDown$.pipe(
3992
+ mergeMap((down) => onPointerUp$.pipe(take(1), map((up) => ({ down, up })))),
3993
+ filter(({ down, up }) => down.target === up.target && up.timeStamp - down.timeStamp < 300)
3994
+ // filter(({ down, up }) => down.offsetX === up.offsetX && down.offsetY === up.offsetY)
3995
+ ).subscribe(({ down }) => {
3996
+ if (down.button === 2)
3997
+ return;
3998
+ const ranges = this._calcActiveRanges(down);
3999
+ ranges.length && this._clickCustomRanges$.next(ranges.pop());
4000
+ const bullet = this._calcActiveBullet(down);
4001
+ bullet && this._clickBullet$.next(bullet);
4002
+ }));
3935
4003
  }
3936
- _initPointerDown() {
3937
- this.disposeWithMe(
3938
- fromEventSubject(this._context.scene.onPointerMove$).pipe(debounceTime(100)).subscribe((evt) => {
3939
- this._docHoverManagerService.onMouseMove(evt);
4004
+ _buildCustomRangeBoundsBySegment(segmentId, segmentPage = -1) {
4005
+ var _a22, _b, _c;
4006
+ const customRanges = (_c = (_b = (_a22 = this._context.unit.getSelfOrHeaderFooterModel(segmentId)) == null ? void 0 : _a22.getBody()) == null ? void 0 : _b.customRanges) != null ? _c : [], layouts = [];
4007
+ return customRanges.forEach((range) => {
4008
+ const textRange = {
4009
+ startOffset: range.startIndex,
4010
+ endOffset: range.endIndex,
4011
+ collapsed: !1,
4012
+ segmentId
4013
+ }, rects = calcDocRangePositions(textRange, this._documents, this._skeleton, segmentPage);
4014
+ if (!rects)
4015
+ return null;
4016
+ layouts.push({
4017
+ customRange: range,
4018
+ rects,
4019
+ segmentId,
4020
+ segmentPageIndex: segmentPage
4021
+ });
4022
+ }), layouts;
4023
+ }
4024
+ _buildCustomRangeBounds() {
4025
+ var _a22;
4026
+ if (!this._customRangeDirty)
4027
+ return;
4028
+ this._customRangeDirty = !1;
4029
+ const customRangeBounds = [];
4030
+ customRangeBounds.push(...this._buildCustomRangeBoundsBySegment()), (_a22 = this._skeleton.getSkeletonData()) == null || _a22.pages.forEach((page, pageIndex) => {
4031
+ page.headerId && customRangeBounds.push(...this._buildCustomRangeBoundsBySegment(page.headerId, pageIndex)), page.footerId && customRangeBounds.push(...this._buildCustomRangeBoundsBySegment(page.footerId, pageIndex));
4032
+ }), this._customRangeBounds = customRangeBounds;
4033
+ }
4034
+ _calcActiveRanges(evt) {
4035
+ this._buildCustomRangeBounds();
4036
+ const { offsetX, offsetY } = evt, { x, y } = transformOffset2Bound(offsetX, offsetY, this._context.scene);
4037
+ return this._customRangeBounds.filter((layout) => layout.rects.some((rect) => {
4038
+ const { left, right, top, bottom } = rect;
4039
+ return x >= left && x <= right && y >= top && y <= bottom;
4040
+ })).map(
4041
+ (range) => ({
4042
+ segmentId: range.segmentId,
4043
+ range: range.customRange,
4044
+ segmentPageIndex: range.segmentPageIndex
3940
4045
  })
3941
4046
  );
3942
4047
  }
3943
- _initScroll() {
3944
- const viewMain = this._context.scene.getViewport(VIEWPORT_KEY.VIEW_MAIN);
3945
- viewMain && (this.disposeWithMe(fromEventSubject(viewMain.onScrollAfter$).pipe(debounceTime(60)).subscribe(() => {
3946
- this._docHoverManagerService.endScroll();
3947
- })), this.disposeWithMe(viewMain.onScrollBefore$.subscribeEvent(() => {
3948
- this._docHoverManagerService.startScroll();
3949
- })));
3950
- }
3951
- }, __name(_a18, "DocHoverRenderController"), _a18);
3952
- DocHoverRenderController = __decorateClass$4([
3953
- __decorateParam$4(1, Inject(DocHoverManagerService))
3954
- ], DocHoverRenderController);
4048
+ _buildBulletBoundsBySegment(segmentId, segmentPage = -1) {
4049
+ var _a22, _b;
4050
+ const body = (_a22 = this._context.unit.getSelfOrHeaderFooterModel(segmentId)) == null ? void 0 : _a22.getBody(), paragraphs = (_b = body == null ? void 0 : body.paragraphs) != null ? _b : [], bounds = [];
4051
+ return paragraphs.forEach((paragraph) => {
4052
+ paragraph.bullet && paragraph.bullet.listType.indexOf("CHECK_LIST") === 0 && (/* @__PURE__ */ __name((pageIndex) => {
4053
+ var _a23, _b2, _c;
4054
+ const node = this._skeleton.findNodeByCharIndex(paragraph.startIndex, segmentId, pageIndex), divide = node == null ? void 0 : node.parent, line = divide == null ? void 0 : divide.parent, column = line == null ? void 0 : line.parent, targetLine = column == null ? void 0 : column.lines.find((l2) => l2.paragraphStart && l2.paragraphIndex === paragraph.startIndex), bulletNode = (_c = (_b2 = (_a23 = targetLine == null ? void 0 : targetLine.divides) == null ? void 0 : _a23[0]) == null ? void 0 : _b2.glyphGroup) == null ? void 0 : _c[0];
4055
+ if (!bulletNode || !bulletNode)
4056
+ return;
4057
+ const rect = calcDocGlyphPosition(bulletNode, this._documents, this._skeleton, pageIndex);
4058
+ rect && bounds.push({
4059
+ rect,
4060
+ segmentId,
4061
+ segmentPageIndex: pageIndex,
4062
+ paragraph
4063
+ });
4064
+ }, "calcRect"))(segmentPage);
4065
+ }), bounds;
4066
+ }
4067
+ _buildBulletBounds() {
4068
+ var _a22;
4069
+ this._bulletDirty && (this._bulletDirty = !1, this._bulletBounds = [], this._bulletBounds.push(...this._buildBulletBoundsBySegment()), (_a22 = this._skeleton.getSkeletonData()) == null || _a22.pages.forEach((page, pageIndex) => {
4070
+ page.headerId && this._bulletBounds.push(...this._buildBulletBoundsBySegment(page.headerId, pageIndex)), page.footerId && this._bulletBounds.push(...this._buildBulletBoundsBySegment(page.footerId, pageIndex));
4071
+ }));
4072
+ }
4073
+ _calcActiveBullet(evt) {
4074
+ this._buildBulletBounds();
4075
+ const { offsetX, offsetY } = evt, { x, y } = transformOffset2Bound(offsetX, offsetY, this._context.scene);
4076
+ return this._bulletBounds.find((layout) => {
4077
+ const { left, right, top, bottom } = layout.rect;
4078
+ return x >= left && x <= right && y >= top && y <= bottom;
4079
+ });
4080
+ }
4081
+ }, __name(_a17, "DocEventManagerService"), _a17);
4082
+ DocEventManagerService = __decorateClass$4([
4083
+ __decorateParam$4(1, Inject(DocSkeletonManagerService))
4084
+ ], DocEventManagerService);
3955
4085
  var __defProp$3 = Object.defineProperty, __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor, __decorateClass$3 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
3956
4086
  for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$3(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
3957
4087
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
3958
4088
  return kind && result && __defProp$3(target, key, result), result;
3959
- }, "__decorateClass$3"), __decorateParam$3 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$3"), _a19;
3960
- let DocAutoFormatController = (_a19 = class extends Disposable {
4089
+ }, "__decorateClass$3"), __decorateParam$3 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$3"), _a18;
4090
+ let DocAutoFormatController = (_a18 = class extends Disposable {
3961
4091
  constructor(_docAutoFormatService) {
3962
4092
  super(), this._docAutoFormatService = _docAutoFormatService, this._initListTabAutoFormat(), this._initListSpaceAutoFormat(), this._initDefaultEnterFormat(), this._initExitListAutoFormat();
3963
4093
  }
@@ -3966,15 +4096,15 @@ let DocAutoFormatController = (_a19 = class extends Disposable {
3966
4096
  this._docAutoFormatService.registerAutoFormat({
3967
4097
  id: TabCommand.id,
3968
4098
  match: /* @__PURE__ */ __name((context) => {
3969
- var _a23;
4099
+ var _a22;
3970
4100
  const { selection, paragraphs, unit } = context;
3971
4101
  if (paragraphs.length === 1 && selection.startOffset === paragraphs[0].paragraphStart && paragraphs[0].bullet) {
3972
- const allParagraphs = (_a23 = unit.getBody()) == null ? void 0 : _a23.paragraphs, bulletParagraphs = allParagraphs == null ? void 0 : allParagraphs.filter((p2) => {
3973
- var _a24;
3974
- return ((_a24 = p2.bullet) == null ? void 0 : _a24.listId) === paragraphs[0].bullet.listId;
4102
+ const allParagraphs = (_a22 = unit.getBody()) == null ? void 0 : _a22.paragraphs, bulletParagraphs = allParagraphs == null ? void 0 : allParagraphs.filter((p2) => {
4103
+ var _a23;
4104
+ return ((_a23 = p2.bullet) == null ? void 0 : _a23.listId) === paragraphs[0].bullet.listId;
3975
4105
  });
3976
4106
  return (bulletParagraphs == null ? void 0 : bulletParagraphs.findIndex((p2) => p2.startIndex === paragraphs[0].startIndex)) !== 0;
3977
- } else if (paragraphs.length > 1)
4107
+ } else if (paragraphs.length > 1 && paragraphs.some((p2) => p2.bullet))
3978
4108
  return !0;
3979
4109
  return !1;
3980
4110
  }, "match"),
@@ -3987,7 +4117,26 @@ let DocAutoFormatController = (_a19 = class extends Disposable {
3987
4117
  type: params != null && params.shift ? ChangeListNestingLevelType.decrease : ChangeListNestingLevelType.increase
3988
4118
  }
3989
4119
  }];
3990
- }
4120
+ },
4121
+ priority: 100
4122
+ })
4123
+ ), this.disposeWithMe(
4124
+ this._docAutoFormatService.registerAutoFormat({
4125
+ id: TabCommand.id,
4126
+ match: /* @__PURE__ */ __name((context) => {
4127
+ const { selection } = context, { startNodePosition, endNodePosition } = selection;
4128
+ return !!(startNodePosition && endNodePosition && isInSameTableCell(startNodePosition, endNodePosition) || startNodePosition && !endNodePosition && startNodePosition.path.indexOf("cells") > -1);
4129
+ }, "match"),
4130
+ getMutations(context) {
4131
+ const params = context.commandParams;
4132
+ return [{
4133
+ id: DocTableTabCommand.id,
4134
+ params: {
4135
+ shift: !!(params != null && params.shift)
4136
+ }
4137
+ }];
4138
+ },
4139
+ priority: 99
3991
4140
  })
3992
4141
  );
3993
4142
  }
@@ -3996,16 +4145,16 @@ let DocAutoFormatController = (_a19 = class extends Disposable {
3996
4145
  this._docAutoFormatService.registerAutoFormat({
3997
4146
  id: AfterSpaceCommand.id,
3998
4147
  match: /* @__PURE__ */ __name((context) => {
3999
- var _a23;
4148
+ var _a22;
4000
4149
  const { selection, paragraphs, unit } = context;
4001
4150
  if (!selection.collapsed || paragraphs.length !== 1)
4002
4151
  return !1;
4003
- const text = (_a23 = unit.getBody()) == null ? void 0 : _a23.dataStream.slice(paragraphs[0].paragraphStart, paragraphs[0].paragraphEnd - 1);
4152
+ const text = (_a22 = unit.getBody()) == null ? void 0 : _a22.dataStream.slice(paragraphs[0].paragraphStart, paragraphs[0].paragraphEnd - 1);
4004
4153
  return !!(text && Object.keys(QuickListTypeMap).includes(text));
4005
4154
  }, "match"),
4006
4155
  getMutations(context) {
4007
- var _a23;
4008
- const { paragraphs, unit } = context, text = (_a23 = unit.getBody()) == null ? void 0 : _a23.dataStream.slice(paragraphs[0].paragraphStart, paragraphs[0].paragraphEnd - 1);
4156
+ var _a22;
4157
+ const { paragraphs, unit } = context, text = (_a22 = unit.getBody()) == null ? void 0 : _a22.dataStream.slice(paragraphs[0].paragraphStart, paragraphs[0].paragraphEnd - 1);
4009
4158
  if (text && Object.keys(QuickListTypeMap).includes(text)) {
4010
4159
  const type = QuickListTypeMap[text];
4011
4160
  return [{
@@ -4060,7 +4209,7 @@ let DocAutoFormatController = (_a19 = class extends Disposable {
4060
4209
  })
4061
4210
  );
4062
4211
  }
4063
- }, __name(_a19, "DocAutoFormatController"), _a19);
4212
+ }, __name(_a18, "DocAutoFormatController"), _a18);
4064
4213
  DocAutoFormatController = __decorateClass$3([
4065
4214
  OnLifecycle(LifecycleStages.Rendered, DocAutoFormatController),
4066
4215
  __decorateParam$3(0, Inject(DocAutoFormatService))
@@ -4069,40 +4218,22 @@ var __defProp$2 = Object.defineProperty, __getOwnPropDesc$2 = Object.getOwnPrope
4069
4218
  for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
4070
4219
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
4071
4220
  return kind && result && __defProp$2(target, key, result), result;
4072
- }, "__decorateClass$2"), __decorateParam$2 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$2"), _a20;
4073
- let DocChecklistRenderController = (_a20 = class extends Disposable {
4074
- constructor(_context, _docSkeletonManagerService, _commandService, _docHoverManagerService) {
4075
- super(), this._context = _context, this._docSkeletonManagerService = _docSkeletonManagerService, this._commandService = _commandService, this._docHoverManagerService = _docHoverManagerService, this._initPointerDownObserver(), this._initHoverCursor();
4221
+ }, "__decorateClass$2"), __decorateParam$2 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$2"), _a19;
4222
+ let DocChecklistRenderController = (_a19 = class extends Disposable {
4223
+ constructor(_context, _docSkeletonManagerService, _commandService, _docEventManagerService, _textSelectionManagerService) {
4224
+ super(), this._context = _context, this._docSkeletonManagerService = _docSkeletonManagerService, this._commandService = _commandService, this._docEventManagerService = _docEventManagerService, this._textSelectionManagerService = _textSelectionManagerService, this._initPointerDownObserver(), this._initHoverCursor();
4076
4225
  }
4077
4226
  _initPointerDownObserver() {
4078
- this.disposeWithMe(
4079
- this._context.mainComponent.onPointerDown$.subscribeEvent((evt) => {
4080
- const { offsetX, offsetY } = evt, documentComponent = this._context.mainComponent, coord = this._getTransformCoordForDocumentOffset(
4081
- documentComponent,
4082
- this._context.scene.getViewport(VIEWPORT_KEY.VIEW_MAIN),
4083
- offsetX,
4084
- offsetY
4085
- );
4086
- if (!coord)
4087
- return;
4088
- const { pageLayoutType = PageLayoutType.VERTICAL, pageMarginLeft, pageMarginTop } = documentComponent.getOffsetConfig(), node = this._docSkeletonManagerService.getSkeleton().findNodeByCoord(
4089
- coord,
4090
- pageLayoutType,
4091
- pageMarginLeft,
4092
- pageMarginTop
4093
- );
4094
- if (!node)
4095
- return;
4096
- const paragraph = getParagraphByGlyph(node.node, this._context.unit.getBody());
4097
- paragraph && paragraph.bullet && node.node.glyphType === GlyphType.LIST && (paragraph.bullet.listType === PresetListType.CHECK_LIST || paragraph.bullet.listType === PresetListType.CHECK_LIST_CHECKED) && this._commandService.executeCommand(ToggleCheckListCommand.id, {
4098
- index: paragraph.startIndex
4099
- });
4100
- })
4101
- );
4227
+ this._docEventManagerService.clickBullets$.subscribe((paragraph) => {
4228
+ this._commandService.executeCommand(ToggleCheckListCommand.id, {
4229
+ index: paragraph.paragraph.startIndex,
4230
+ segmentId: paragraph.segmentId
4231
+ });
4232
+ });
4102
4233
  }
4103
4234
  _initHoverCursor() {
4104
4235
  this.disposeWithMe(
4105
- this._docHoverManagerService.bullet$.subscribe((paragraph) => {
4236
+ this._docEventManagerService.hoverBullet$.subscribe((paragraph) => {
4106
4237
  paragraph ? this._context.mainComponent.setCursor(CURSOR_TYPE.POINTER) : this._context.mainComponent.setCursor(CURSOR_TYPE.TEXT);
4107
4238
  })
4108
4239
  );
@@ -4112,11 +4243,12 @@ let DocChecklistRenderController = (_a20 = class extends Disposable {
4112
4243
  if (originCoord)
4113
4244
  return documentTransform.clone().invert().applyPoint(originCoord);
4114
4245
  }
4115
- }, __name(_a20, "DocChecklistRenderController"), _a20);
4246
+ }, __name(_a19, "DocChecklistRenderController"), _a19);
4116
4247
  DocChecklistRenderController = __decorateClass$2([
4117
4248
  __decorateParam$2(1, Inject(DocSkeletonManagerService)),
4118
4249
  __decorateParam$2(2, ICommandService),
4119
- __decorateParam$2(3, Inject(DocHoverManagerService))
4250
+ __decorateParam$2(3, Inject(DocEventManagerService)),
4251
+ __decorateParam$2(4, Inject(TextSelectionManagerService))
4120
4252
  ], DocChecklistRenderController);
4121
4253
  const create = "univer-create", createItem = "univer-create-item", createLabel = "univer-create-label", createInput = "univer-create-input", styles = {
4122
4254
  create,
@@ -4172,8 +4304,8 @@ var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPrope
4172
4304
  for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
4173
4305
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
4174
4306
  return kind && result && __defProp$1(target, key, result), result;
4175
- }, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$1"), _a21;
4176
- let DocTableController = (_a21 = class extends Disposable {
4307
+ }, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$1"), _a20;
4308
+ let DocTableController = (_a20 = class extends Disposable {
4177
4309
  constructor(_commandService, _componentManager) {
4178
4310
  super(), this._commandService = _commandService, this._componentManager = _componentManager, this._initialize();
4179
4311
  }
@@ -4191,41 +4323,20 @@ let DocTableController = (_a21 = class extends Disposable {
4191
4323
  }
4192
4324
  _init() {
4193
4325
  }
4194
- }, __name(_a21, "DocTableController"), _a21);
4326
+ }, __name(_a20, "DocTableController"), _a20);
4195
4327
  DocTableController = __decorateClass$1([
4196
4328
  OnLifecycle(LifecycleStages.Rendered, DocTableController),
4197
4329
  __decorateParam$1(0, ICommandService),
4198
4330
  __decorateParam$1(1, Inject(ComponentManager))
4199
4331
  ], DocTableController);
4200
- const DocTabCommand = {
4201
- id: "doc.tab.tab-in-doc",
4202
- type: CommandType.COMMAND,
4203
- handler: /* @__PURE__ */ __name(async (accessor) => {
4204
- const textSelectionManagerService = accessor.get(TextSelectionManagerService), commandService = accessor.get(ICommandService), activeTextRange = textSelectionManagerService.getActiveTextRangeWithStyle();
4205
- if (activeTextRange == null)
4206
- return !1;
4207
- const { startNodePosition, endNodePosition } = activeTextRange;
4208
- return startNodePosition && endNodePosition && isInSameTableCell(startNodePosition, endNodePosition) ? commandService.executeCommand(DocTableTabCommand.id) : !1;
4209
- }, "handler")
4210
- }, DocShiftTabCommand = {
4211
- id: "doc.tab.shift-tab-in-doc",
4212
- type: CommandType.COMMAND,
4213
- handler: /* @__PURE__ */ __name(async (accessor) => {
4214
- const textSelectionManagerService = accessor.get(TextSelectionManagerService), commandService = accessor.get(ICommandService), activeTextRange = textSelectionManagerService.getActiveTextRangeWithStyle();
4215
- if (activeTextRange == null)
4216
- return !1;
4217
- const { startNodePosition, endNodePosition } = activeTextRange;
4218
- return startNodePosition && endNodePosition && isInSameTableCell(startNodePosition, endNodePosition) ? commandService.executeCommand(DocTableShiftTabCommand.id) : !1;
4219
- }, "handler")
4220
- };
4221
4332
  var __defProp2 = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __decorateClass = /* @__PURE__ */ __name((decorators, target, key, kind) => {
4222
4333
  for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
4223
4334
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
4224
4335
  return kind && result && __defProp2(target, key, result), result;
4225
- }, "__decorateClass"), __decorateParam = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam"), _a22;
4226
- let UniverDocsUIPlugin = (_a22 = class extends Plugin {
4336
+ }, "__decorateClass"), __decorateParam = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam"), _a21;
4337
+ let UniverDocsUIPlugin = (_a21 = class extends Plugin {
4227
4338
  constructor(_config, _injector, _renderManagerSrv, _commandService, _logService) {
4228
- super(), this._config = _config, this._injector = _injector, this._renderManagerSrv = _renderManagerSrv, this._commandService = _commandService, this._logService = _logService, this._config = Tools.deepMerge({}, DefaultDocUiConfig, this._config), this._initDependencies(_injector), this._initializeShortcut(), this._initCommand(), this._registerCommands();
4339
+ super(), this._config = _config, this._injector = _injector, this._renderManagerSrv = _renderManagerSrv, this._commandService = _commandService, this._logService = _logService, this._config = Tools.deepMerge({}, DefaultDocUiConfig, this._config), this._initDependencies(_injector), this._initializeShortcut(), this._initCommand();
4229
4340
  }
4230
4341
  onReady() {
4231
4342
  this._initRenderBasics(), this._markDocAsFocused();
@@ -4259,12 +4370,6 @@ let UniverDocsUIPlugin = (_a22 = class extends Plugin {
4259
4370
  this._injector.get(IShortcutService).registerShortcut(shortcut);
4260
4371
  });
4261
4372
  }
4262
- _registerCommands() {
4263
- [
4264
- DocTabCommand,
4265
- DocShiftTabCommand
4266
- ].forEach((command) => this.disposeWithMe(this._commandService.registerCommand(command)));
4267
- }
4268
4373
  _initDependencies(injector) {
4269
4374
  mergeOverrideWithDependencies([
4270
4375
  [DocUIController, { useFactory: /* @__PURE__ */ __name(() => this._injector.createInstance(DocUIController, this._config), "useFactory") }],
@@ -4276,7 +4381,6 @@ let UniverDocsUIPlugin = (_a22 = class extends Plugin {
4276
4381
  [AppUIController, { useFactory: /* @__PURE__ */ __name(() => this._injector.createInstance(AppUIController, this._config), "useFactory") }],
4277
4382
  [IDocClipboardService, { useClass: DocClipboardService }],
4278
4383
  [DocCanvasPopManagerService],
4279
- [DocHoverManagerService],
4280
4384
  [DocParagraphSettingController]
4281
4385
  ], this._config.override).forEach((d) => injector.add(d));
4282
4386
  }
@@ -4307,18 +4411,18 @@ let UniverDocsUIPlugin = (_a22 = class extends Plugin {
4307
4411
  }
4308
4412
  _initRenderModules() {
4309
4413
  [
4414
+ [DocEventManagerService],
4310
4415
  [DocBackScrollRenderController],
4311
4416
  [DocTextSelectionRenderController],
4312
4417
  [DocHeaderFooterController],
4313
4418
  [DocResizeRenderController],
4314
- [DocHoverRenderController],
4315
4419
  [DocContextMenuRenderController],
4316
4420
  [DocChecklistRenderController]
4317
4421
  ].forEach((m2) => {
4318
4422
  this._renderManagerSrv.registerRenderModule(UniverInstanceType.UNIVER_DOC, m2);
4319
4423
  });
4320
4424
  }
4321
- }, __name(_a22, "UniverDocsUIPlugin"), __publicField(_a22, "pluginName", DOC_UI_PLUGIN_NAME), __publicField(_a22, "type", UniverInstanceType.UNIVER_DOC), _a22);
4425
+ }, __name(_a21, "UniverDocsUIPlugin"), __publicField(_a21, "pluginName", DOC_UI_PLUGIN_NAME), __publicField(_a21, "type", UniverInstanceType.UNIVER_DOC), _a21);
4322
4426
  UniverDocsUIPlugin = __decorateClass([
4323
4427
  __decorateParam(1, Inject(Injector)),
4324
4428
  __decorateParam(2, IRenderManagerService),
@@ -4362,7 +4466,7 @@ export {
4362
4466
  DocCopyCommand,
4363
4467
  DocCreateTableOperation,
4364
4468
  DocCutCommand,
4365
- DocHoverManagerService,
4469
+ DocEventManagerService,
4366
4470
  DocPasteCommand,
4367
4471
  DocRenderController,
4368
4472
  DocUIController,