@univerjs/sheets-ui 1.0.0-alpha.0 → 1.0.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/lib/cjs/facade.js +4 -3
  2. package/lib/cjs/index.js +189 -50
  3. package/lib/cjs/locale/ar-SA.js +11 -4
  4. package/lib/cjs/locale/ca-ES.js +11 -4
  5. package/lib/cjs/locale/de-DE.js +11 -4
  6. package/lib/cjs/locale/en-US.js +9 -2
  7. package/lib/cjs/locale/es-ES.js +11 -4
  8. package/lib/cjs/locale/fa-IR.js +11 -4
  9. package/lib/cjs/locale/fr-FR.js +11 -4
  10. package/lib/cjs/locale/id-ID.js +11 -4
  11. package/lib/cjs/locale/it-IT.js +11 -4
  12. package/lib/cjs/locale/ja-JP.js +9 -2
  13. package/lib/cjs/locale/ko-KR.js +9 -2
  14. package/lib/cjs/locale/pl-PL.js +11 -4
  15. package/lib/cjs/locale/pt-BR.js +11 -4
  16. package/lib/cjs/locale/ru-RU.js +11 -4
  17. package/lib/cjs/locale/sk-SK.js +11 -4
  18. package/lib/cjs/locale/vi-VN.js +11 -4
  19. package/lib/cjs/locale/zh-CN.js +9 -2
  20. package/lib/cjs/locale/zh-HK.js +9 -2
  21. package/lib/cjs/locale/zh-TW.js +9 -2
  22. package/lib/es/facade.js +4 -3
  23. package/lib/es/index.js +192 -54
  24. package/lib/es/locale/ar-SA.js +11 -4
  25. package/lib/es/locale/ca-ES.js +11 -4
  26. package/lib/es/locale/de-DE.js +11 -4
  27. package/lib/es/locale/en-US.js +9 -2
  28. package/lib/es/locale/es-ES.js +11 -4
  29. package/lib/es/locale/fa-IR.js +11 -4
  30. package/lib/es/locale/fr-FR.js +11 -4
  31. package/lib/es/locale/id-ID.js +11 -4
  32. package/lib/es/locale/it-IT.js +11 -4
  33. package/lib/es/locale/ja-JP.js +9 -2
  34. package/lib/es/locale/ko-KR.js +9 -2
  35. package/lib/es/locale/pl-PL.js +11 -4
  36. package/lib/es/locale/pt-BR.js +11 -4
  37. package/lib/es/locale/ru-RU.js +11 -4
  38. package/lib/es/locale/sk-SK.js +11 -4
  39. package/lib/es/locale/vi-VN.js +11 -4
  40. package/lib/es/locale/zh-CN.js +9 -2
  41. package/lib/es/locale/zh-HK.js +9 -2
  42. package/lib/es/locale/zh-TW.js +9 -2
  43. package/lib/facade.js +4 -3
  44. package/lib/index.css +38 -4
  45. package/lib/index.js +192 -54
  46. package/lib/locale/ar-SA.js +11 -4
  47. package/lib/locale/ca-ES.js +11 -4
  48. package/lib/locale/de-DE.js +11 -4
  49. package/lib/locale/en-US.js +9 -2
  50. package/lib/locale/es-ES.js +11 -4
  51. package/lib/locale/fa-IR.js +11 -4
  52. package/lib/locale/fr-FR.js +11 -4
  53. package/lib/locale/id-ID.js +11 -4
  54. package/lib/locale/it-IT.js +11 -4
  55. package/lib/locale/ja-JP.js +9 -2
  56. package/lib/locale/ko-KR.js +9 -2
  57. package/lib/locale/pl-PL.js +11 -4
  58. package/lib/locale/pt-BR.js +11 -4
  59. package/lib/locale/ru-RU.js +11 -4
  60. package/lib/locale/sk-SK.js +11 -4
  61. package/lib/locale/vi-VN.js +11 -4
  62. package/lib/locale/zh-CN.js +9 -2
  63. package/lib/locale/zh-HK.js +9 -2
  64. package/lib/locale/zh-TW.js +9 -2
  65. package/lib/types/commands/commands/clipboard.command.d.ts +1 -0
  66. package/lib/types/controllers/clipboard/clipboard.controller.d.ts +4 -2
  67. package/lib/types/controllers/editor/data-sync.controller.d.ts +5 -2
  68. package/lib/types/facade/f-range.d.ts +5 -4
  69. package/lib/types/index.d.ts +1 -1
  70. package/lib/types/locale/en-US.d.ts +10 -1
  71. package/lib/types/services/clipboard/clipboard.service.d.ts +8 -2
  72. package/lib/umd/facade.js +1 -1
  73. package/lib/umd/index.js +8 -8
  74. package/lib/umd/locale/ar-SA.js +1 -1
  75. package/lib/umd/locale/ca-ES.js +1 -1
  76. package/lib/umd/locale/de-DE.js +1 -1
  77. package/lib/umd/locale/en-US.js +1 -1
  78. package/lib/umd/locale/es-ES.js +1 -1
  79. package/lib/umd/locale/fa-IR.js +1 -1
  80. package/lib/umd/locale/fr-FR.js +1 -1
  81. package/lib/umd/locale/id-ID.js +1 -1
  82. package/lib/umd/locale/it-IT.js +1 -1
  83. package/lib/umd/locale/ja-JP.js +1 -1
  84. package/lib/umd/locale/ko-KR.js +1 -1
  85. package/lib/umd/locale/pl-PL.js +1 -1
  86. package/lib/umd/locale/pt-BR.js +1 -1
  87. package/lib/umd/locale/ru-RU.js +1 -1
  88. package/lib/umd/locale/sk-SK.js +1 -1
  89. package/lib/umd/locale/vi-VN.js +1 -1
  90. package/lib/umd/locale/zh-CN.js +1 -1
  91. package/lib/umd/locale/zh-HK.js +1 -1
  92. package/lib/umd/locale/zh-TW.js +1 -1
  93. package/package.json +15 -15
package/lib/es/index.js CHANGED
@@ -6,9 +6,9 @@ import { AUTO_FILL_APPLY_TYPE, AUTO_FILL_HOOK_TYPE, AddMergeUndoMutationFactory,
6
6
  import { BehaviorSubject, EMPTY, Observable, Subject, Subscription, combineLatest, combineLatestWith, distinctUntilChanged, filter, map, merge as merge$1, of, shareReplay, startWith, switchMap, takeUntil, throttleTime, withLatestFrom } from "rxjs";
7
7
  import { DocSelectionManagerService, DocSkeletonManagerService, InsertTextCommand, RichTextEditingMutation, SetTextSelectionsOperation } from "@univerjs/docs";
8
8
  import { ObjectScope, UnitAction, UnitObject, UnitRole } from "@univerjs/protocol";
9
- import { Avatar, Button, Calendar, CascaderList, ColorPicker, Confirm, Dropdown, DropdownMenu, FormLayout, Input, InputNumber, MessageType, Radio, RadioGroup, Select, Separator, Switch, TimeInput, Tooltip, borderBottomClassName, borderClassName, borderRightClassName, borderTopClassName, clsx, scrollbarClassName } from "@univerjs/design";
10
- import { AddImageIcon, AdjustHeightDoubleIcon, AdjustWidthDoubleIcon, AlignBottomIcon, AlignTopIcon, AllBorderIcon, AutoHeightDoubleIcon, AutoWidthDoubleIcon, AutofillDoubleIcon, AutowrapIcon, BackSlashDoubleIcon, BoldIcon, BrushIcon, CancelFreezeIcon, CancelMergeIcon, CheckMarkIcon, ClearFormatDoubleIcon, CloseIcon, CodeIcon, ConvertIcon, CopyDoubleIcon, CutIcon, DeleteCellShiftLeftDoubleIcon, DeleteCellShiftUpDoubleIcon, DeleteColumnDoubleIcon, DeleteIcon, DeleteRowDoubleIcon, DownBorderDoubleIcon, DownloadImageIcon, DropdownIcon, ErrorIcon, EyeOutlineIcon, EyelashIcon, FontColorDoubleIcon, FontSizeIncreaseIcon, FontSizeReduceIcon, FreezeColumnIcon, FreezeRowIcon, FreezeToSelectedIcon, FxIcon, HideDoubleIcon, HideGridlinesDoubleIcon, HorizontalBorderDoubleIcon, HorizontalMergeIcon, HorizontallyIcon, IncreaseIcon, InfoIcon, InnerBorderDoubleIcon, InsertCellDownDoubleIcon, InsertCellShiftRightDoubleIcon, InsertDoubleIcon, InsertRowAboveDoubleIcon, InsertRowBelowDoubleIcon, ItalicIcon, LeftBorderDoubleIcon, LeftDoubleDiagonalDoubleIcon, LeftInsertColumnDoubleIcon, LeftJustifyingIcon, LeftRotationFortyFiveDegreesIcon, LeftRotationNinetyDegreesIcon, LeftTridiagonalDoubleIcon, LockIcon, MergeAllIcon, MoreDownIcon, MoreIcon, NoBorderIcon, NoColorDoubleIcon, NoRotationIcon, OuterBorderDoubleIcon, OverflowIcon, PaintBucketDoubleIcon, PasteSpecialDoubleIcon, PenIcon, PipingIcon, ProtectIcon, ReduceDoubleIcon, RightBorderDoubleIcon, RightDoubleDiagonalDoubleIcon, RightInsertColumnDoubleIcon, RightJustifyingIcon, RightRotationFortyFiveDegreesIcon, RightRotationNinetyDegreesIcon, SlashDoubleIcon, StrikethroughIcon, SubscriptIcon, SuperscriptIcon, TruncationIcon, UnderlineIcon, UpBorderDoubleIcon, VerticalBorderDoubleIcon, VerticalCenterIcon, VerticalIntegrationIcon, VerticalTextIcon, WarningIcon, WriteIcon } from "@univerjs/icons";
11
- import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
9
+ import { Avatar, Button, Calendar, CascaderList, ColorPicker, ConfigContext, Confirm, Dropdown, DropdownMenu, FormLayout, Input, InputNumber, MessageType, Radio, RadioGroup, Select, Separator, Switch, TimeInput, Tooltip, borderBottomClassName, borderClassName, borderRightClassName, borderTopClassName, clsx, scrollbarClassName } from "@univerjs/design";
10
+ import { AddImageIcon, AdjustHeightDoubleIcon, AdjustWidthDoubleIcon, AlignBottomIcon, AlignTopIcon, AllBorderIcon, AutoHeightDoubleIcon, AutoWidthDoubleIcon, AutofillDoubleIcon, AutowrapIcon, BackSlashDoubleIcon, BoldIcon, BrushIcon, CancelFreezeIcon, CancelMergeIcon, CheckMarkIcon, ClearFormatDoubleIcon, CloseIcon, CodeIcon, ConvertIcon, CopyDoubleIcon, CutIcon, DeleteCellShiftLeftDoubleIcon, DeleteCellShiftUpDoubleIcon, DeleteColumnDoubleIcon, DeleteIcon, DeleteRowDoubleIcon, DownBorderDoubleIcon, DownloadImageIcon, DropdownIcon, ErrorIcon, EyeIcon, EyelashIcon, FontColorDoubleIcon, FontSizeIncreaseIcon, FontSizeReduceIcon, FreezeColumnIcon, FreezeRowIcon, FreezeToSelectedIcon, FxIcon, HideDoubleIcon, HideGridlinesDoubleIcon, HorizontalBorderDoubleIcon, HorizontalMergeIcon, HorizontallyIcon, IncreaseIcon, InfoIcon, InnerBorderDoubleIcon, InsertCellDownDoubleIcon, InsertCellShiftRightDoubleIcon, InsertDoubleIcon, InsertRowAboveDoubleIcon, InsertRowBelowDoubleIcon, ItalicIcon, LeftBorderDoubleIcon, LeftDoubleDiagonalDoubleIcon, LeftInsertColumnDoubleIcon, LeftJustifyingIcon, LeftRotationFortyFiveDegreesIcon, LeftRotationNinetyDegreesIcon, LeftTridiagonalDoubleIcon, LockIcon, MergeAllIcon, MoreDownIcon, MoreLeftIcon, MoreRightIcon, NoBorderIcon, NoColorDoubleIcon, NoRotationIcon, OuterBorderDoubleIcon, OverflowIcon, PaintBucketDoubleIcon, PasteSpecialDoubleIcon, PenIcon, PipingIcon, ProtectIcon, ReduceDoubleIcon, RightBorderDoubleIcon, RightDoubleDiagonalDoubleIcon, RightInsertColumnDoubleIcon, RightJustifyingIcon, RightRotationFortyFiveDegreesIcon, RightRotationNinetyDegreesIcon, SlashDoubleIcon, StrikethroughIcon, SubscriptIcon, SuperscriptIcon, TruncationIcon, UnderlineIcon, UpBorderDoubleIcon, VerticalBorderDoubleIcon, VerticalCenterIcon, VerticalIntegrationIcon, VerticalTextIcon, WarningIcon, WriteIcon } from "@univerjs/icons";
11
+ import { useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
12
12
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
13
13
  import { FUNCTION_NAMES_MATH, FUNCTION_NAMES_STATISTICAL, FUNCTION_NAMES_TEXT, FormulaDataModel, IDefinedNamesService, IFunctionService, ISuperTableService, LexerTreeBuilder, NullValueObject, SetFormulaCalculationNotificationMutation, deserializeRangeWithSheet, isReferenceStringWithEffectiveColumn, isReferenceStrings, matchToken, operatorToken, sequenceNodeType, serializeRange, serializeRangeWithSheet } from "@univerjs/engine-formula";
14
14
  import { ITelemetryService } from "@univerjs/telemetry";
@@ -4035,6 +4035,7 @@ const IMAGE_MIME_TO_EXTENSION = {
4035
4035
  [FILE__WEBP_CLIPBOARD_MIME_TYPE]: "webp",
4036
4036
  [FILE__BMP_CLIPBOARD_MIME_TYPE]: "bmp"
4037
4037
  };
4038
+ const FORMULA_CLIPBOARD_MIME_TYPE = "web application/x-univer-sheets-formula";
4038
4039
  /**
4039
4040
  * This service provide hooks for sheet features to supplement content or modify behavior of clipboard.
4040
4041
  */
@@ -4100,6 +4101,7 @@ let SheetClipboardService = class SheetClipboardService extends Disposable {
4100
4101
  return (_h$onBeforeCopy = h.onBeforeCopy) === null || _h$onBeforeCopy === void 0 ? void 0 : _h$onBeforeCopy.call(h, workbookId, worksheetId, range, copyType);
4101
4102
  });
4102
4103
  const copyContent = this._generateCopyContent(workbookId, worksheetId, range, hooks, copyHookType);
4104
+ if (copyContent && copyType === "COPY") copyContent.formulaClipboardPayload = this._generateFormulaClipboardPayload(workbookId, worksheetId, range, copyContent, hooks);
4103
4105
  hooks.forEach((h) => {
4104
4106
  var _h$onAfterCopy;
4105
4107
  return (_h$onAfterCopy = h.onAfterCopy) === null || _h$onAfterCopy === void 0 ? void 0 : _h$onAfterCopy.call(h);
@@ -4120,7 +4122,7 @@ let SheetClipboardService = class SheetClipboardService extends Disposable {
4120
4122
  copyHookType
4121
4123
  });
4122
4124
  if (!copyContent) return false;
4123
- const { html, plain, matrixFragment, copyId, discreteRange } = copyContent;
4125
+ const { html, plain, matrixFragment, copyId, discreteRange, formulaClipboardPayload } = copyContent;
4124
4126
  this._copyContentCache.set(copyId, {
4125
4127
  unitId: workbook.getUnitId(),
4126
4128
  subUnitId: worksheet.getSheetId(),
@@ -4128,7 +4130,7 @@ let SheetClipboardService = class SheetClipboardService extends Disposable {
4128
4130
  matrix: matrixFragment,
4129
4131
  copyType
4130
4132
  });
4131
- await this._clipboardInterfaceService.write(plain, html);
4133
+ await this._clipboardInterfaceService.write(plain, html, formulaClipboardPayload ? { [FORMULA_CLIPBOARD_MIME_TYPE]: formulaClipboardPayload } : void 0);
4132
4134
  this._markSelectionService.removeAllShapes();
4133
4135
  const style = createCopyPasteSelectionStyle(this._themeService);
4134
4136
  this._copyMarkId = this._markSelectionService.addShape({
@@ -4144,6 +4146,7 @@ let SheetClipboardService = class SheetClipboardService extends Disposable {
4144
4146
  const types = item.types;
4145
4147
  const text = types.indexOf(PLAIN_TEXT_CLIPBOARD_MIME_TYPE) !== -1 ? await item.getType(PLAIN_TEXT_CLIPBOARD_MIME_TYPE).then((blob) => blob && blob.text()) : "";
4146
4148
  const html = types.indexOf(HTML_CLIPBOARD_MIME_TYPE) !== -1 ? await item.getType(HTML_CLIPBOARD_MIME_TYPE).then((blob) => blob && blob.text()) : "";
4149
+ const formulaClipboardPayload = types.indexOf("web application/x-univer-sheets-formula") !== -1 ? await item.getType(FORMULA_CLIPBOARD_MIME_TYPE).then((blob) => blob && blob.text()).catch(() => "") : "";
4147
4150
  const imageIndex = types.findIndex((type) => imageMimeTypeSet.has(type));
4148
4151
  const shouldUseHTMLPaste = imageIndex === -1 || !htmlContainsImage(html);
4149
4152
  if (html && shouldUseHTMLPaste) {
@@ -4152,7 +4155,7 @@ let SheetClipboardService = class SheetClipboardService extends Disposable {
4152
4155
  title: this._localeService.t("sheets-ui.clipboard.shortCutNotify.title"),
4153
4156
  content: this._localeService.t("sheets-ui.clipboard.shortCutNotify.useShortCutInstead")
4154
4157
  });
4155
- return this._pasteHTML(html, pasteType);
4158
+ return this._pasteHTML(html, pasteType, formulaClipboardPayload);
4156
4159
  }
4157
4160
  if (imageIndex !== -1) {
4158
4161
  const imageMimeType = types[imageIndex];
@@ -4170,10 +4173,10 @@ let SheetClipboardService = class SheetClipboardService extends Disposable {
4170
4173
  async pasteByCopyId(copyId, pasteType = PREDEFINED_HOOK_NAME_PASTE.DEFAULT_PASTE) {
4171
4174
  return this._pasteInternal(copyId, pasteType);
4172
4175
  }
4173
- async legacyPaste(html, text, files) {
4176
+ async legacyPaste(html, text, files, formulaClipboardPayload) {
4174
4177
  const isFromExcel = htmlIsFromExcel(html !== null && html !== void 0 ? html : "");
4175
4178
  if (files && !isFromExcel) return this._pasteFiles(files, PREDEFINED_HOOK_NAME_PASTE.DEFAULT_PASTE);
4176
- else if (html) return this._pasteHTML(html, PREDEFINED_HOOK_NAME_PASTE.DEFAULT_PASTE);
4179
+ else if (html) return this._pasteHTML(html, PREDEFINED_HOOK_NAME_PASTE.DEFAULT_PASTE, formulaClipboardPayload);
4177
4180
  else if (text) if (/[\n\t]/.test(text)) return this._pasteHTML(convertTextToTable(text), PREDEFINED_HOOK_NAME_PASTE.DEFAULT_PASTE);
4178
4181
  else return this._pastePlainText(text, PREDEFINED_HOOK_NAME_PASTE.DEFAULT_PASTE);
4179
4182
  else return this._pasteUnrecognized();
@@ -4280,6 +4283,40 @@ let SheetClipboardService = class SheetClipboardService extends Disposable {
4280
4283
  discreteRange
4281
4284
  };
4282
4285
  }
4286
+ _generateFormulaClipboardPayload(unitId, subUnitId, range, copyContent, hooks) {
4287
+ if (this._hasFilteredRows(unitId, subUnitId, range, hooks)) return;
4288
+ const { startRow, startColumn, endRow, endColumn } = range;
4289
+ const rowCount = endRow - startRow + 1;
4290
+ const columnCount = endColumn - startColumn + 1;
4291
+ const formulaOnlyHook = hooks.find((hook) => hook.id === PREDEFINED_HOOK_NAME_COPY.SPECIAL_COPY_FORMULA_ONLY);
4292
+ const formulas = [];
4293
+ for (let row = 0; row < rowCount; row++) for (let column = 0; column < columnCount; column++) {
4294
+ var _formulaOnlyHook$onCo, _copyContent$matrixFr;
4295
+ const formula = (formulaOnlyHook === null || formulaOnlyHook === void 0 || (_formulaOnlyHook$onCo = formulaOnlyHook.onCopyCellContent) === null || _formulaOnlyHook$onCo === void 0 ? void 0 : _formulaOnlyHook$onCo.call(formulaOnlyHook, startRow + row, startColumn + column)) || ((_copyContent$matrixFr = copyContent.matrixFragment.getValue(row, column)) === null || _copyContent$matrixFr === void 0 ? void 0 : _copyContent$matrixFr.f);
4296
+ if (typeof formula === "string" && isFormulaString(formula)) formulas.push({
4297
+ row,
4298
+ column,
4299
+ f: formula
4300
+ });
4301
+ }
4302
+ if (!formulas.length) return;
4303
+ return JSON.stringify({
4304
+ rowCount,
4305
+ columnCount,
4306
+ origin: {
4307
+ row: startRow,
4308
+ column: startColumn
4309
+ },
4310
+ formulas
4311
+ });
4312
+ }
4313
+ _hasFilteredRows(unitId, subUnitId, range, hooks) {
4314
+ return hooks.some((hook) => {
4315
+ var _hook$getFilteredOutR;
4316
+ const rows = (_hook$getFilteredOutR = hook.getFilteredOutRows) === null || _hook$getFilteredOutR === void 0 ? void 0 : _hook$getFilteredOutR.call(hook, unitId, subUnitId, range);
4317
+ return !!(rows === null || rows === void 0 ? void 0 : rows.length);
4318
+ });
4319
+ }
4283
4320
  _notifyClipboardHook() {
4284
4321
  this._clipboardHooks$.next(this._clipboardHooks);
4285
4322
  }
@@ -4346,15 +4383,49 @@ let SheetClipboardService = class SheetClipboardService extends Disposable {
4346
4383
  return (_h$onPasteUnrecognize = h.onPasteUnrecognized) === null || _h$onPasteUnrecognize === void 0 ? void 0 : _h$onPasteUnrecognize.call(h, payload);
4347
4384
  });
4348
4385
  }
4349
- async _pasteHTML(html, pasteType) {
4386
+ async _pasteHTML(html, pasteType, formulaClipboardPayload) {
4350
4387
  const copyId = extractId(html);
4351
4388
  if (copyId && this._copyContentCache.get(copyId)) return this._pasteInternal(copyId, pasteType);
4352
- return this._pasteExternal(html, pasteType);
4389
+ return this._pasteExternal(html, pasteType, formulaClipboardPayload);
4353
4390
  }
4354
- async _pasteExternal(html, pasteType) {
4355
- var _this$_univerInstance;
4391
+ async _pasteExternal(html, pasteType, formulaClipboardPayload) {
4356
4392
  const { rowProperties, colProperties, cellMatrix } = this._htmlToUSM.convert(html);
4357
4393
  if (!cellMatrix) return false;
4394
+ const sourceRange = formulaClipboardPayload ? this._applyFormulaClipboardPayload(cellMatrix, formulaClipboardPayload) : void 0;
4395
+ return this._pasteExternalData({
4396
+ rowProperties,
4397
+ colProperties,
4398
+ cellMatrix
4399
+ }, pasteType, sourceRange);
4400
+ }
4401
+ _applyFormulaClipboardPayload(cellMatrix, text) {
4402
+ let payload;
4403
+ try {
4404
+ payload = JSON.parse(text);
4405
+ } catch {
4406
+ return;
4407
+ }
4408
+ if (!payload || !payload.origin || !Array.isArray(payload.formulas) || payload.rowCount <= 0 || payload.columnCount <= 0) return;
4409
+ cellMatrix.setValue(payload.rowCount - 1, payload.columnCount - 1, {
4410
+ ...getEmptyCell(),
4411
+ ...cellMatrix.getValue(payload.rowCount - 1, payload.columnCount - 1)
4412
+ });
4413
+ payload.formulas.forEach((formula) => {
4414
+ if (isFormulaString(formula.f) && formula.row >= 0 && formula.row < payload.rowCount && formula.column >= 0 && formula.column < payload.columnCount) cellMatrix.setValue(formula.row, formula.column, {
4415
+ ...getEmptyCell(),
4416
+ ...cellMatrix.getValue(formula.row, formula.column),
4417
+ f: formula.f
4418
+ });
4419
+ });
4420
+ return {
4421
+ rows: Array.from({ length: payload.rowCount }, (_, index) => payload.origin.row + index),
4422
+ cols: Array.from({ length: payload.columnCount }, (_, index) => payload.origin.column + index)
4423
+ };
4424
+ }
4425
+ _pasteExternalData(data, pasteType, sourceRange) {
4426
+ var _this$_univerInstance;
4427
+ const { rowProperties, colProperties, cellMatrix } = data;
4428
+ if (!cellMatrix) return false;
4358
4429
  const pasteTarget = this._getPastedRange(cellMatrix);
4359
4430
  if (!pasteTarget) return false;
4360
4431
  const worksheet = (_this$_univerInstance = this._univerInstanceService.getUniverSheetInstance(pasteTarget.unitId)) === null || _this$_univerInstance === void 0 ? void 0 : _this$_univerInstance.getSheetBySheetId(pasteTarget.subUnitId);
@@ -4368,11 +4439,18 @@ let SheetClipboardService = class SheetClipboardService extends Disposable {
4368
4439
  return false;
4369
4440
  }
4370
4441
  }
4442
+ const source = sourceRange ? {
4443
+ range: sourceRange,
4444
+ unitId: pasteTarget.unitId,
4445
+ subUnitId: pasteTarget.subUnitId,
4446
+ copyType: "COPY",
4447
+ copyId: ""
4448
+ } : void 0;
4371
4449
  return this._pasteUSM({
4372
4450
  rowProperties,
4373
4451
  colProperties,
4374
4452
  cellMatrix
4375
- }, pasteTarget, pasteType);
4453
+ }, pasteTarget, pasteType, source);
4376
4454
  }
4377
4455
  async _pasteInternal(copyId, pasteType) {
4378
4456
  var _this$_univerInstance2, _this$_univerInstance3;
@@ -5004,8 +5082,8 @@ const SheetPasteShortKeyCommand = {
5004
5082
  type: CommandType.COMMAND,
5005
5083
  handler: async (accessor, params) => {
5006
5084
  const clipboardService = accessor.get(ISheetClipboardService);
5007
- const { htmlContent, textContent, files } = params;
5008
- clipboardService.legacyPaste(htmlContent, textContent, files);
5085
+ const { htmlContent, textContent, files, formulaClipboardPayload } = params;
5086
+ clipboardService.legacyPaste(htmlContent, textContent, files, formulaClipboardPayload);
5009
5087
  return true;
5010
5088
  }
5011
5089
  };
@@ -9361,6 +9439,7 @@ let SheetCellEditorResizeService = class SheetCellEditorResizeService extends Di
9361
9439
  if (documentDataModel == null) return;
9362
9440
  const documentSkeleton = this._getEditorSkeleton();
9363
9441
  if (!documentSkeleton) return;
9442
+ documentSkeleton.resetInitialWidth();
9364
9443
  const info = this._predictingSize(position, canvasOffset, documentSkeleton, documentLayoutObject, scaleX, scaleY);
9365
9444
  if (!info || info.actualWidth <= 0) return;
9366
9445
  let { actualWidth, actualHeight } = info;
@@ -10785,6 +10864,9 @@ let EditingRenderController = class EditingRenderController extends Disposable {
10785
10864
  this._contextService.setContextValue(FOCUSING_EDITOR_BUT_HIDDEN, false);
10786
10865
  this._contextService.setContextValue(FOCUSING_FX_BAR_EDITOR, false);
10787
10866
  this._cellEditorManagerService.setState({ show: param.visible });
10867
+ const formulaBarEditor = this._editorService.getEditor(DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY);
10868
+ formulaBarEditor === null || formulaBarEditor === void 0 || formulaBarEditor.setSelectionRanges([], false);
10869
+ formulaBarEditor === null || formulaBarEditor === void 0 || formulaBarEditor.blur();
10788
10870
  const editorObject = this._getEditorObject();
10789
10871
  editorObject === null || editorObject === void 0 || (_editorObject$scene$g = editorObject.scene.getViewport(VIEWPORT_KEY.VIEW_MAIN)) === null || _editorObject$scene$g === void 0 || _editorObject$scene$g.scrollToViewportPos({
10790
10872
  viewportScrollX: 0,
@@ -11383,7 +11465,7 @@ const shouldRemoveShapeIds = [
11383
11465
  MoveColsMutation.id
11384
11466
  ];
11385
11467
  let SheetClipboardController = class SheetClipboardController extends RxDisposable {
11386
- constructor(_injector, _instanceService, _renderManagerService, _commandService, _contextService, _configService, _sheetClipboardService, _messageService, _localService, _uiPartsService) {
11468
+ constructor(_injector, _instanceService, _renderManagerService, _commandService, _contextService, _configService, _sheetClipboardService, _clipboardInterfaceService, _messageService, _localService, _uiPartsService) {
11387
11469
  super();
11388
11470
  this._injector = _injector;
11389
11471
  this._instanceService = _instanceService;
@@ -11392,6 +11474,7 @@ let SheetClipboardController = class SheetClipboardController extends RxDisposab
11392
11474
  this._contextService = _contextService;
11393
11475
  this._configService = _configService;
11394
11476
  this._sheetClipboardService = _sheetClipboardService;
11477
+ this._clipboardInterfaceService = _clipboardInterfaceService;
11395
11478
  this._messageService = _messageService;
11396
11479
  this._localService = _localService;
11397
11480
  this._uiPartsService = _uiPartsService;
@@ -11408,7 +11491,7 @@ let SheetClipboardController = class SheetClipboardController extends RxDisposab
11408
11491
  _pasteWithDoc() {
11409
11492
  var _this$_renderManagerS;
11410
11493
  const sheetPasteShortKeyFn = (docSelectionRenderService) => {
11411
- docSelectionRenderService.onPaste$.pipe(takeUntil(this.dispose$)).subscribe((config) => {
11494
+ docSelectionRenderService.onPaste$.pipe(takeUntil(this.dispose$)).subscribe(async (config) => {
11412
11495
  var _clipboardEvent$clipb, _clipboardEvent$clipb2;
11413
11496
  if (!whenSheetEditorFocused(this._contextService)) return;
11414
11497
  config.event.preventDefault();
@@ -11416,10 +11499,12 @@ let SheetClipboardController = class SheetClipboardController extends RxDisposab
11416
11499
  const htmlContent = (_clipboardEvent$clipb = clipboardEvent.clipboardData) === null || _clipboardEvent$clipb === void 0 ? void 0 : _clipboardEvent$clipb.getData("text/html");
11417
11500
  const textContent = (_clipboardEvent$clipb2 = clipboardEvent.clipboardData) === null || _clipboardEvent$clipb2 === void 0 ? void 0 : _clipboardEvent$clipb2.getData("text/plain");
11418
11501
  const files = this._resolveClipboardFiles(clipboardEvent.clipboardData);
11502
+ const formulaClipboardPayload = await this._readFormulaClipboardPayload();
11419
11503
  this._commandService.executeCommand(SheetPasteShortKeyCommand.id, {
11420
11504
  htmlContent,
11421
11505
  textContent,
11422
- files
11506
+ files,
11507
+ formulaClipboardPayload
11423
11508
  });
11424
11509
  });
11425
11510
  docSelectionRenderService === null || docSelectionRenderService === void 0 || docSelectionRenderService.onKeydown$.subscribe((event) => {
@@ -11441,6 +11526,16 @@ let SheetClipboardController = class SheetClipboardController extends RxDisposab
11441
11526
  const files = Array.from(clipboardData.items).map((item) => item.kind === "file" ? item.getAsFile() : void 0).filter(Boolean);
11442
11527
  return files.length > 0 ? files : void 0;
11443
11528
  }
11529
+ async _readFormulaClipboardPayload() {
11530
+ if (!this._clipboardInterfaceService.supportClipboard) return;
11531
+ try {
11532
+ const item = (await this._clipboardInterfaceService.read()).find((clipboardItem) => clipboardItem.types.includes(FORMULA_CLIPBOARD_MIME_TYPE));
11533
+ if (!item) return;
11534
+ return (await item.getType(FORMULA_CLIPBOARD_MIME_TYPE)).text();
11535
+ } catch {
11536
+ return;
11537
+ }
11538
+ }
11444
11539
  _init() {
11445
11540
  [
11446
11541
  SheetCopyCommand,
@@ -11895,9 +11990,10 @@ SheetClipboardController = __decorate([
11895
11990
  __decorateParam(4, IContextService),
11896
11991
  __decorateParam(5, IConfigService),
11897
11992
  __decorateParam(6, ISheetClipboardService),
11898
- __decorateParam(7, IMessageService),
11899
- __decorateParam(8, Inject(LocaleService)),
11900
- __decorateParam(9, IUIPartsService)
11993
+ __decorateParam(7, IClipboardInterfaceService),
11994
+ __decorateParam(8, IMessageService),
11995
+ __decorateParam(9, Inject(LocaleService)),
11996
+ __decorateParam(10, IUIPartsService)
11901
11997
  ], SheetClipboardController);
11902
11998
 
11903
11999
  //#endregion
@@ -12111,7 +12207,7 @@ let FormulaEditorController = class FormulaEditorController extends RxDisposable
12111
12207
  if (this._contextService.getContextValue(FOCUSING_EDITOR_BUT_HIDDEN) && !this._contextService.getContextValue(EDITOR_ACTIVATED)) {
12112
12208
  var _formulaEditorDataMod;
12113
12209
  this._univerInstanceService.setCurrentUnitForType(DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY);
12114
- const formulaEditorDataModel = this._univerInstanceService.getUniverDocInstance(DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY);
12210
+ const formulaEditorDataModel = this._univerInstanceService.getUnit(DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY, UniverInstanceType.UNIVER_DOC);
12115
12211
  if (this._editorBridgeService.isVisible().visible === false) this._commandService.syncExecuteCommand(SetCellEditVisibleOperation.id, {
12116
12212
  visible: true,
12117
12213
  eventType: DeviceInputEventType.PointerDown,
@@ -12151,7 +12247,7 @@ let FormulaEditorController = class FormulaEditorController extends RxDisposable
12151
12247
  this.disposeWithMe(combineLatest([this._formulaEditorManagerService.position$, addFormulaBar$]).subscribe(([position]) => {
12152
12248
  if (!position) return this._clearScheduledCallback();
12153
12249
  const editorObject = getEditorObject(DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY, this._renderManagerService);
12154
- const formulaEditorDataModel = this._univerInstanceService.getUniverDocInstance(DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY);
12250
+ const formulaEditorDataModel = this._univerInstanceService.getUnit(DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY, UniverInstanceType.UNIVER_DOC);
12155
12251
  if (editorObject == null || formulaEditorDataModel == null) return this._clearScheduledCallback();
12156
12252
  const { width, height } = position;
12157
12253
  if (width === 0 || height === 0) return this._clearScheduledCallback();
@@ -12170,7 +12266,7 @@ let FormulaEditorController = class FormulaEditorController extends RxDisposable
12170
12266
  const position = this._formulaEditorManagerService.getPosition();
12171
12267
  const skeleton = (_this$_renderManagerS = this._renderManagerService.getRenderById(DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY)) === null || _this$_renderManagerS === void 0 ? void 0 : _this$_renderManagerS.with(DocSkeletonManagerService).getSkeleton();
12172
12268
  const editorObject = this._renderManagerService.getRenderById(DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY);
12173
- const formulaEditorDataModel = this._univerInstanceService.getUniverDocInstance(DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY);
12269
+ const formulaEditorDataModel = this._univerInstanceService.getUnit(DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY, UniverInstanceType.UNIVER_DOC);
12174
12270
  if (skeleton == null || position == null || editorObject == null || formulaEditorDataModel == null) return;
12175
12271
  const { marginTop = 0, marginBottom = 0 } = formulaEditorDataModel.getSnapshot().documentStyle;
12176
12272
  const { scene, mainComponent } = editorObject;
@@ -15173,7 +15269,7 @@ let SheetRenderController = class SheetRenderController extends RxDisposable {
15173
15269
  this._renderFrameTags = {};
15174
15270
  }));
15175
15271
  this.disposeWithMe(engine.endFrame$.subscribe(() => {
15176
- if (this._renderFrameTimeMetric && Object.keys(this._renderFrameTimeMetric).filter((key) => key.startsWith(SHEET_EXTENSION_PREFIX)).length > 0) this._afterRenderMetric$.next({
15272
+ if (this._renderFrameTimeMetric && Object.keys(this._renderFrameTimeMetric).some((key) => key.startsWith(SHEET_EXTENSION_PREFIX))) this._afterRenderMetric$.next({
15177
15273
  frameTimeMetric: this._renderFrameTimeMetric,
15178
15274
  tags: this._renderFrameTags
15179
15275
  });
@@ -17964,7 +18060,7 @@ function ShowRowMenuItemFactory(accessor) {
17964
18060
  return {
17965
18061
  id: SetSelectedRowsVisibleCommand.id,
17966
18062
  type: MenuItemType.BUTTON,
17967
- icon: "EyeOutlineIcon",
18063
+ icon: "EyeIcon",
17968
18064
  title: "sheets-ui.rightClick.showHideRow",
17969
18065
  hidden$: deriveStateFromActiveSheet$(univerInstanceService, true, ({ worksheet }) => new Observable((subscriber) => {
17970
18066
  function hasHiddenRowsInSelections() {
@@ -18000,7 +18096,7 @@ function ShowColMenuItemFactory(accessor) {
18000
18096
  return {
18001
18097
  id: SetSelectedColsVisibleCommand.id,
18002
18098
  type: MenuItemType.BUTTON,
18003
- icon: "EyeOutlineIcon",
18099
+ icon: "EyeIcon",
18004
18100
  title: "sheets-ui.rightClick.showHideColumn",
18005
18101
  hidden$: deriveStateFromActiveSheet$(univerInstanceService, true, ({ worksheet }) => new Observable((subscriber) => {
18006
18102
  function hasHiddenColsInSelections() {
@@ -19668,10 +19764,11 @@ function DefinedNameOverlay({ search, isInputEvent }) {
19668
19764
  const definedNamesService = useDependency(IDefinedNamesService);
19669
19765
  const univerInstanceService = useDependency(IUniverInstanceService);
19670
19766
  const sidebarService = useDependency(ISidebarService);
19767
+ const direction = localeService.getDirection();
19671
19768
  const unitId = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET).getUnitId();
19672
19769
  const getDefinedNameMap = () => {
19673
19770
  const definedNameMap = definedNamesService.getDefinedNameMap(unitId);
19674
- if (definedNameMap) return Array.from(Object.values(definedNameMap));
19771
+ if (definedNameMap) return Object.values(definedNameMap);
19675
19772
  return [];
19676
19773
  };
19677
19774
  const [definedNames, setDefinedNames] = useState(getDefinedNameMap());
@@ -19722,7 +19819,9 @@ function DefinedNameOverlay({ search, isInputEvent }) {
19722
19819
  definedNamesService.focusRange(unitId, id);
19723
19820
  };
19724
19821
  return /* @__PURE__ */ jsxs("div", {
19725
- className: "univer-w-[300px]",
19822
+ "data-u-comp": "defined-name-overlay",
19823
+ dir: direction,
19824
+ className: "univer-w-[300px] rtl:univer-text-right",
19726
19825
  children: [/* @__PURE__ */ jsx("div", {
19727
19826
  ref: listContainerRef,
19728
19827
  className: clsx("univer-max-h-[360px] univer-min-h-0 univer-overflow-y-auto", scrollbarClassName, { "univer-min-h-[30px]": filteredDefinedNames.length > 0 }),
@@ -19736,13 +19835,16 @@ function DefinedNameOverlay({ search, isInputEvent }) {
19736
19835
  focusDefinedName(definedName);
19737
19836
  },
19738
19837
  children: /* @__PURE__ */ jsxs("div", {
19739
- className: clsx("univer-flex univer-items-center univer-justify-between univer-gap-2 univer-py-1", borderBottomClassName),
19838
+ "data-u-comp": "defined-name-overlay-row",
19839
+ className: clsx("univer-flex univer-items-center univer-gap-2 univer-py-1 rtl:univer-flex-row-reverse", borderBottomClassName),
19740
19840
  children: [/* @__PURE__ */ jsx("div", {
19741
- className: "univer-w-[50%] univer-flex-shrink-0 univer-truncate univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",
19841
+ "data-u-comp": "defined-name-overlay-name",
19842
+ className: "univer-min-w-0 univer-flex-1 univer-basis-0 univer-truncate univer-text-sm univer-text-gray-600 rtl:univer-text-right dark:!univer-text-gray-200",
19742
19843
  title: definedName.name,
19743
19844
  children: definedName.name
19744
19845
  }), /* @__PURE__ */ jsx("div", {
19745
- className: "univer-w-[50%] univer-flex-shrink-0 univer-truncate univer-text-xs univer-text-gray-400",
19846
+ "data-u-comp": "defined-name-overlay-reference",
19847
+ className: "univer-min-w-0 univer-flex-1 univer-basis-0 univer-truncate univer-text-xs univer-text-gray-400 rtl:univer-text-right",
19746
19848
  title: definedName.formulaOrRefString,
19747
19849
  children: definedName.formulaOrRefString
19748
19850
  })]
@@ -19751,7 +19853,8 @@ function DefinedNameOverlay({ search, isInputEvent }) {
19751
19853
  })
19752
19854
  })
19753
19855
  }), /* @__PURE__ */ jsxs("div", {
19754
- className: "univer-cursor-pointer univer-p-2 univer-transition-colors univer-duration-200 hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-600",
19856
+ "data-u-comp": "defined-name-overlay-footer",
19857
+ className: "univer-cursor-pointer univer-p-2 univer-transition-colors univer-duration-200 hover:univer-bg-gray-100 rtl:univer-text-right dark:hover:!univer-bg-gray-600",
19755
19858
  onClick: openSlider,
19756
19859
  children: [/* @__PURE__ */ jsx("div", {
19757
19860
  className: "univer-mb-2 univer-text-sm univer-font-semibold univer-text-gray-600 dark:!univer-text-gray-200",
@@ -19786,7 +19889,7 @@ function DefinedName({ disable }) {
19786
19889
  const inputRef = useRef(null);
19787
19890
  const getDefinedNameMap = () => {
19788
19891
  const definedNameMap = definedNamesService.getDefinedNameMap(unitId);
19789
- if (definedNameMap) return Array.from(Object.values(definedNameMap));
19892
+ if (definedNameMap) return Object.values(definedNameMap);
19790
19893
  return [];
19791
19894
  };
19792
19895
  const focusDefinedName = async (definedName) => {
@@ -19939,7 +20042,7 @@ function DefinedName({ disable }) {
19939
20042
  className: "univer-relative univer-box-border univer-flex univer-h-full univer-w-24 univer-border-r-gray-200 univer-py-1.5 univer-transition-all",
19940
20043
  children: [/* @__PURE__ */ jsx("input", {
19941
20044
  ref: inputRef,
19942
- className: clsx("univer-box-border univer-size-full univer-appearance-none univer-pl-1.5 univer-pr-5 univer-text-gray-900 focus:univer-outline-none dark:!univer-border-r-gray-700 dark:!univer-bg-gray-900 dark:!univer-text-white", borderRightClassName, { "univer-cursor-not-allowed": disable }),
20045
+ className: clsx("univer-box-border univer-size-full univer-appearance-none univer-pl-1.5 univer-pr-5 univer-text-gray-900 focus:univer-outline-none rtl:univer-pl-5 rtl:univer-pr-1.5 dark:!univer-border-r-gray-700 dark:!univer-bg-gray-900 dark:!univer-text-white", borderRightClassName, { "univer-cursor-not-allowed": disable }),
19943
20046
  type: "text",
19944
20047
  value: inputValue,
19945
20048
  onChange: handleChangeSelection,
@@ -19958,7 +20061,7 @@ function DefinedName({ disable }) {
19958
20061
  onOpenChange: setOpen,
19959
20062
  onOpenAutoFocus: (e) => e.preventDefault(),
19960
20063
  children: /* @__PURE__ */ jsx("a", {
19961
- className: clsx("univer-absolute univer-right-0 univer-top-0 univer-flex univer-h-full univer-cursor-pointer univer-items-center univer-justify-center univer-px-1 univer-transition-colors univer-duration-200 hover:univer-bg-gray-100 dark:!univer-text-white dark:hover:!univer-bg-gray-800", { "univer-cursor-not-allowed univer-text-gray-300 hover:univer-bg-transparent dark:!univer-text-gray-700": disable }),
20064
+ className: clsx("univer-absolute univer-right-0 univer-top-0 univer-flex univer-h-full univer-cursor-pointer univer-items-center univer-justify-center univer-px-1 univer-transition-colors univer-duration-200 hover:univer-bg-gray-100 rtl:univer-left-0 rtl:univer-right-auto dark:!univer-text-white dark:hover:!univer-bg-gray-800", { "univer-cursor-not-allowed univer-text-gray-300 hover:univer-bg-transparent dark:!univer-text-gray-700": disable }),
19962
20065
  children: /* @__PURE__ */ jsx(MoreDownIcon, {})
19963
20066
  })
19964
20067
  })]
@@ -21740,15 +21843,16 @@ const SheetBar = () => {
21740
21843
  }),
21741
21844
  /* @__PURE__ */ jsx(SheetBarTabs, {}),
21742
21845
  (!leftScrollState || !rightScrollState) && /* @__PURE__ */ jsxs("div", {
21743
- className: "univer-relative univer-flex univer-items-center univer-px-2 after:univer-absolute after:univer-right-0 after:univer-top-1/2 after:univer-h-4 after:univer-w-px after:-univer-translate-y-1/2 after:univer-bg-gray-200 after:univer-content-[\"\"]",
21846
+ "data-u-comp": "sheet-bar-scroll-buttons",
21847
+ className: "univer-relative univer-flex univer-items-center univer-px-2 after:univer-absolute after:univer-right-0 after:univer-top-1/2 after:univer-h-4 after:univer-w-px after:-univer-translate-y-1/2 after:univer-bg-gray-200 after:univer-content-[\"\"] rtl:univer-flex-row-reverse rtl:after:univer-left-0 rtl:after:univer-right-auto",
21744
21848
  children: [/* @__PURE__ */ jsx(SheetBarButton, {
21745
21849
  disabled: leftScrollState,
21746
21850
  onClick: handleScrollLeft,
21747
- children: /* @__PURE__ */ jsx(MoreIcon, { className: "univer-rotate-180" })
21851
+ children: /* @__PURE__ */ jsx(MoreLeftIcon, {})
21748
21852
  }), /* @__PURE__ */ jsx(SheetBarButton, {
21749
21853
  disabled: rightScrollState,
21750
21854
  onClick: handleScrollRight,
21751
- children: /* @__PURE__ */ jsx(MoreIcon, {})
21855
+ children: /* @__PURE__ */ jsx(MoreRightIcon, {})
21752
21856
  })]
21753
21857
  })
21754
21858
  ]
@@ -22646,7 +22750,7 @@ const useHighlightRange = (ranges = []) => {
22646
22750
  //#endregion
22647
22751
  //#region package.json
22648
22752
  var name = "@univerjs/sheets-ui";
22649
- var version = "1.0.0-alpha.0";
22753
+ var version = "1.0.0-alpha.2";
22650
22754
 
22651
22755
  //#endregion
22652
22756
  //#region src/controllers/cell-alert.controller.ts
@@ -24057,7 +24161,9 @@ function BorderPanel(props) {
24057
24161
  var _value$color;
24058
24162
  const iconManager = useDependency(IconManager);
24059
24163
  const borderStyleManagerService = useDependency(BorderStyleManagerService);
24060
- const { isAllValuesSame, value: currentValue } = useDependency(SheetsSelectionsService).getCellStylesProperty("bd");
24164
+ const selectionManagerService = useDependency(SheetsSelectionsService);
24165
+ const { direction } = useContext(ConfigContext);
24166
+ const { isAllValuesSame, value: currentValue } = selectionManagerService.getCellStylesProperty("bd");
24061
24167
  const color = isAllValuesSame ? getBorderColor(currentValue) : void 0;
24062
24168
  const type = isAllValuesSame ? getBorderStyle(currentValue) : void 0;
24063
24169
  const { onChange, value } = props;
@@ -24072,6 +24178,7 @@ function BorderPanel(props) {
24072
24178
  return Icon && /* @__PURE__ */ jsx(Icon, { className: "univer-fill-primary-600" });
24073
24179
  }
24074
24180
  return /* @__PURE__ */ jsxs("section", {
24181
+ dir: direction,
24075
24182
  className: "univer-box-border univer-grid univer-gap-2 univer-p-1.5",
24076
24183
  children: [
24077
24184
  /* @__PURE__ */ jsx("div", {
@@ -24466,7 +24573,7 @@ const DefinedNameContainer = () => {
24466
24573
  const getDefinedNameMap = () => {
24467
24574
  if (!unitId) return [];
24468
24575
  const definedNameMap = definedNamesService.getDefinedNameMap(unitId);
24469
- if (definedNameMap) return Array.from(Object.values(definedNameMap));
24576
+ if (definedNameMap) return Object.values(definedNameMap);
24470
24577
  return [];
24471
24578
  };
24472
24579
  const [editState, setEditState] = useState(false);
@@ -25947,7 +26054,7 @@ let ComponentsController = class ComponentsController extends Disposable {
25947
26054
  DeleteRowDoubleIcon,
25948
26055
  DownBorderDoubleIcon,
25949
26056
  DownloadImageIcon,
25950
- EyeOutlineIcon,
26057
+ EyeIcon,
25951
26058
  FontColorDoubleIcon,
25952
26059
  FontSizeIncreaseIcon,
25953
26060
  FontSizeReduceIcon,
@@ -26122,7 +26229,7 @@ const formulaEditorStyle = {
26122
26229
  }
26123
26230
  };
26124
26231
  let EditorDataSyncController = class EditorDataSyncController extends Disposable {
26125
- constructor(_univerInstanceService, _renderManagerService, _editorBridgeService, _commandService, _rangeProtectionRuleModel, _worksheetProtectionRuleModel, _formulaEditorController, _formulaEditorManagerService) {
26232
+ constructor(_univerInstanceService, _renderManagerService, _editorBridgeService, _commandService, _rangeProtectionRuleModel, _worksheetProtectionRuleModel, _formulaEditorController, _formulaEditorManagerService, _contextService) {
26126
26233
  super();
26127
26234
  this._univerInstanceService = _univerInstanceService;
26128
26235
  this._renderManagerService = _renderManagerService;
@@ -26132,11 +26239,13 @@ let EditorDataSyncController = class EditorDataSyncController extends Disposable
26132
26239
  this._worksheetProtectionRuleModel = _worksheetProtectionRuleModel;
26133
26240
  this._formulaEditorController = _formulaEditorController;
26134
26241
  this._formulaEditorManagerService = _formulaEditorManagerService;
26242
+ this._contextService = _contextService;
26135
26243
  this._initialize();
26136
26244
  }
26137
26245
  _initialize() {
26138
26246
  this._syncFormulaEditorContent();
26139
26247
  this._commandExecutedListener();
26248
+ this._syncFormulaRefRenderStyleOnFocusChange();
26140
26249
  }
26141
26250
  _getEditorViewModel(unitId) {
26142
26251
  var _this$_renderManagerS;
@@ -26222,6 +26331,7 @@ let EditorDataSyncController = class EditorDataSyncController extends Disposable
26222
26331
  unitId,
26223
26332
  syncer: parmas.unitId
26224
26333
  });
26334
+ this._checkAndSetRenderStyleConfig(docDataModel);
26225
26335
  docViewModel.reset(docDataModel);
26226
26336
  skeleton.calculate();
26227
26337
  if (INCLUDE_LIST.includes(unitId)) {
@@ -26253,27 +26363,54 @@ let EditorDataSyncController = class EditorDataSyncController extends Disposable
26253
26363
  }
26254
26364
  if (unitId === DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY) this._formulaEditorController.autoScroll();
26255
26365
  }
26366
+ _syncFormulaRefRenderStyleOnFocusChange() {
26367
+ this.disposeWithMe(this._contextService.subscribeContextValue$(FOCUSING_FX_BAR_EDITOR).subscribe(() => {
26368
+ this._refreshRenderStyleConfig(DOCS_NORMAL_EDITOR_UNIT_ID_KEY);
26369
+ this._refreshRenderStyleConfig(DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY);
26370
+ }));
26371
+ }
26372
+ _refreshRenderStyleConfig(unitId) {
26373
+ var _currentRender$mainCo3;
26374
+ const currentRender = this._renderManagerService.getRenderById(unitId);
26375
+ const skeleton = currentRender === null || currentRender === void 0 ? void 0 : currentRender.with(DocSkeletonManagerService).getSkeleton();
26376
+ const docDataModel = this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_DOC);
26377
+ const docViewModel = this._getEditorViewModel(unitId);
26378
+ if (currentRender == null || skeleton == null || docDataModel == null || docViewModel == null) return;
26379
+ this._checkAndSetRenderStyleConfig(docDataModel);
26380
+ docViewModel.reset(docDataModel);
26381
+ skeleton.calculate();
26382
+ (_currentRender$mainCo3 = currentRender.mainComponent) === null || _currentRender$mainCo3 === void 0 || _currentRender$mainCo3.makeDirty();
26383
+ if (unitId === DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY) this._formulaEditorController.autoScroll();
26384
+ }
26256
26385
  _checkAndSetRenderStyleConfig(documentDataModel) {
26257
- var _body$dataStream;
26386
+ var _snapshot$body$dataSt, _snapshot$body;
26258
26387
  const snapshot = documentDataModel.getSnapshot();
26259
- const { body } = snapshot;
26260
- if (snapshot.id !== DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY) return;
26261
- snapshot.documentStyle = formulaEditorStyle;
26388
+ if (snapshot.id !== DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY && snapshot.id !== DOCS_NORMAL_EDITOR_UNIT_ID_KEY) return;
26389
+ const isFormulaBar = snapshot.id === DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY;
26390
+ if (isFormulaBar) snapshot.documentStyle = formulaEditorStyle;
26391
+ else {
26392
+ var _snapshot$documentSty;
26393
+ (_snapshot$documentSty = snapshot.documentStyle) !== null && _snapshot$documentSty !== void 0 || (snapshot.documentStyle = {});
26394
+ }
26262
26395
  let renderConfig = snapshot.documentStyle.renderConfig;
26263
26396
  if (renderConfig == null) {
26264
26397
  renderConfig = {};
26265
26398
  snapshot.documentStyle.renderConfig = renderConfig;
26266
26399
  }
26267
- const position = this._formulaEditorManagerService.getPosition();
26268
- if (position) {
26400
+ const position = isFormulaBar ? this._formulaEditorManagerService.getPosition() : null;
26401
+ if (isFormulaBar && position) {
26269
26402
  const width = position.width;
26270
26403
  snapshot.documentStyle.pageSize = {
26271
26404
  width,
26272
26405
  height: Infinity
26273
26406
  };
26274
26407
  }
26275
- if (((_body$dataStream = body === null || body === void 0 ? void 0 : body.dataStream) !== null && _body$dataStream !== void 0 ? _body$dataStream : "").startsWith("=")) renderConfig.isRenderStyle = BooleanNumber.TRUE;
26276
- else renderConfig.isRenderStyle = BooleanNumber.FALSE;
26408
+ if (!((_snapshot$body$dataSt = (_snapshot$body = snapshot.body) === null || _snapshot$body === void 0 ? void 0 : _snapshot$body.dataStream) !== null && _snapshot$body$dataSt !== void 0 ? _snapshot$body$dataSt : "").startsWith("=")) {
26409
+ renderConfig.isRenderStyle = isFormulaBar ? BooleanNumber.FALSE : BooleanNumber.TRUE;
26410
+ return;
26411
+ }
26412
+ const isFocusFxBar = this._contextService.getContextValue(FOCUSING_FX_BAR_EDITOR);
26413
+ renderConfig.isRenderStyle = isFormulaBar === isFocusFxBar ? BooleanNumber.TRUE : BooleanNumber.FALSE;
26277
26414
  }
26278
26415
  _clearParagraph(paragraphs) {
26279
26416
  const newParagraphs = Tools.deepClone(paragraphs);
@@ -26289,7 +26426,8 @@ EditorDataSyncController = __decorate([
26289
26426
  __decorateParam(4, Inject(RangeProtectionRuleModel)),
26290
26427
  __decorateParam(5, Inject(WorksheetProtectionRuleModel)),
26291
26428
  __decorateParam(6, Inject(FormulaEditorController)),
26292
- __decorateParam(7, IFormulaEditorManagerService)
26429
+ __decorateParam(7, IFormulaEditorManagerService),
26430
+ __decorateParam(8, IContextService)
26293
26431
  ], EditorDataSyncController);
26294
26432
 
26295
26433
  //#endregion
@@ -30978,4 +31116,4 @@ UniverSheetsUIPlugin = __decorate([
30978
31116
  ], UniverSheetsUIPlugin);
30979
31117
 
30980
31118
  //#endregion
30981
- export { AddRangeProtectionFromContextMenuCommand, AddRangeProtectionFromSheetBarCommand, AddRangeProtectionFromToolbarCommand, ApplyFormatPainterCommand, AutoFillUIController, AutoHeightController, AutoWidthController, BaseSelectionRenderService, COPY_SPECIAL_MENU_ID, COPY_TYPE, CellAlertManagerService, CellAlertType, CellCustomRenderController, CellEditorManagerService, CellPopupManagerService, ChangeSheetProtectionFromSheetBarCommand, ChangeZoomRatioCommand, DeleteRangeMoveLeftConfirmCommand, DeleteRangeMoveUpConfirmCommand, DeleteRangeProtectionFromContextMenuCommand, DeleteWorksheetProtectionFormSheetBarCommand, DragManagerService, DragRenderController, EMBEDDING_FORMULA_EDITOR, EMBEDDING_FORMULA_EDITOR_COMPONENT_KEY, EditingRenderController, EditorBridgeService, ExpandSelectionCommand, FormatPainterStatus, FormulaEditorController, HEADER_UNHIDE_RANGE_VISIBLE_CHECK, HeaderFreezeRenderController, HeaderMoveRenderController, HeaderResizeRenderController, HeaderUnhideRangeAxis, HeaderUnhideRangeService, HeaderUnhideRenderController, HideColConfirmCommand, HideRowConfirmCommand, HoverManagerService, HoverRenderController, ICellEditorManagerService, IEditorBridgeService, IFormatPainterService, IFormulaEditorManagerService, IMarkSelectionService, IRepeatLastActionService, ISheetCellDropdownManagerService, ISheetClipboardService, ISheetSelectionRenderService, IStatusBarService, InsertRangeMoveDownConfirmCommand, InsertRangeMoveRightConfirmCommand, JumpOver, MarkSelectionService, MoveSelectionCommand, MoveSelectionEnterAndTabCommand, PASTE_SPECIAL_MENU_ID, PREDEFINED_HOOK_NAME, PREDEFINED_HOOK_NAME_COPY, PREDEFINED_HOOK_NAME_PASTE, RANGE_SELECTOR_COMPONENT_KEY, RANGE_SELECTOR_SYMBOLS, RemoveColConfirmCommand, RemoveRowConfirmCommand, RemoveSheetConfirmCommand, RenameSheetOperation, RepeatLastActionPermission, ResetRangeTextColorCommand, ResetScrollCommand, SELECTION_SHAPE_DEPTH, SHEET_UI_PLUGIN_NAME, SHEET_VIEW_KEY, ScrollCommand, ScrollToCellCommand, ScrollToRangeOperation, SelectAllCommand, SelectionControl, SelectionControl as SelectionShape, SelectionShapeExtension, SetActivateCellEditOperation, SetCellEditVisibleArrowOperation, SetCellEditVisibleOperation, SetCellEditVisibleWithF2Operation, SetColumnFrozenCommand, SetColumnHeaderHeightCommand, SetFirstColumnFrozenCommand, SetFirstRowFrozenCommand, SetFormatPainterOperation, SetInfiniteFormatPainterCommand, SetOnceFormatPainterCommand, SetRangeBoldCommand, SetRangeFontDecreaseCommand, SetRangeFontFamilyCommand, SetRangeFontIncreaseCommand, SetRangeFontSizeCommand, SetRangeItalicCommand, SetRangeProtectionFromContextMenuCommand, SetRangeStrickThroughCommand, SetRangeSubscriptCommand, SetRangeSuperscriptCommand, SetRangeTextColorCommand, SetRangeUnderlineCommand, SetRowFrozenCommand, SetRowHeaderWidthCommand, SetScrollOperation, SetScrollRelativeCommand, SetSelectionFrozenCommand, SetWorksheetColAutoWidthCommand, SetZoomRatioCommand, SetZoomRatioOperation, SheetCanvasPopManagerService, SheetCellDropdownManagerService, SheetCellEditorResizeService, SheetClipboardController, SheetClipboardService, SheetCopyCommand, SheetCutCommand, SheetMenuPosition, SheetPasteBesidesBorderCommand, SheetPasteColWidthCommand, SheetPasteCommand, SheetPasteFormatCommand, SheetPasteShortKeyCommand, SheetPasteValueCommand, SheetPermissionCheckUIController, SheetPermissionOpenDialogOperation, SheetPermissionOpenPanelOperation, SheetPermissionRenderManagerService, SheetPermissionUserManagerService, SheetPrintInterceptorService, SheetRenderController, SheetScrollManagerService, SheetSelectionRenderService, SheetSkeletonManagerService, SheetUIController, SheetsRenderService, SheetsScrollRenderController, menuSchema as SheetsUIMenuSchema, SheetsUIPart, ShowMenuListCommand, SidebarDefinedNameOperation, StatusBarController, StatusBarService, UNIVER_SHEET_PERMISSION_USER_PART, UniverSheetsMobileUIPlugin, UniverSheetsUIPlugin, ViewSheetPermissionFromContextMenuCommand, ViewSheetPermissionFromSheetBarCommand, calculateDocSkeletonRects, matchedSelectionByRowColIndex as checkInHeaderRanges, deriveStateFromActiveSheet$, functionDisplayNames, genNormalSelectionStyle, genSelectionByRange, selectionDataForSelectAll as getAllSelection, getCellRealRange, getCoordByCell, getCoordByOffset, getCurrentExclusiveRangeInterest$, getCurrentRangeDisable$, getCustomRangePosition, getEditingCustomRangePosition, getEditorObject, getMatrixPlainText, getObservableWithExclusiveRange$, getRepeatRange, getSheetObject, getTopLeftSelectionOfCurrSheet, getTransformCoord, getViewportByCell, isEmbeddingFormulaEditor, isRangeSelector, menuClipboardDisabledObservable, mergeSetRangeValues, useActiveWorkbook, useActiveWorksheet, useHighlightRange, useKeyEventConfig, useWorkbooks, virtualizeDiscreteRanges, whenFormulaEditorActivated, whenSheetEditorActivated, whenSheetEditorFocused };
31119
+ export { AddRangeProtectionFromContextMenuCommand, AddRangeProtectionFromSheetBarCommand, AddRangeProtectionFromToolbarCommand, ApplyFormatPainterCommand, AutoFillUIController, AutoHeightController, AutoWidthController, BaseSelectionRenderService, COPY_SPECIAL_MENU_ID, COPY_TYPE, CellAlertManagerService, CellAlertType, CellCustomRenderController, CellEditorManagerService, CellPopupManagerService, ChangeSheetProtectionFromSheetBarCommand, ChangeZoomRatioCommand, DeleteRangeMoveLeftConfirmCommand, DeleteRangeMoveUpConfirmCommand, DeleteRangeProtectionFromContextMenuCommand, DeleteWorksheetProtectionFormSheetBarCommand, DragManagerService, DragRenderController, EMBEDDING_FORMULA_EDITOR, EMBEDDING_FORMULA_EDITOR_COMPONENT_KEY, EditingRenderController, EditorBridgeService, ExpandSelectionCommand, FORMULA_CLIPBOARD_MIME_TYPE, FormatPainterStatus, FormulaEditorController, HEADER_UNHIDE_RANGE_VISIBLE_CHECK, HeaderFreezeRenderController, HeaderMoveRenderController, HeaderResizeRenderController, HeaderUnhideRangeAxis, HeaderUnhideRangeService, HeaderUnhideRenderController, HideColConfirmCommand, HideRowConfirmCommand, HoverManagerService, HoverRenderController, ICellEditorManagerService, IEditorBridgeService, IFormatPainterService, IFormulaEditorManagerService, IMarkSelectionService, IRepeatLastActionService, ISheetCellDropdownManagerService, ISheetClipboardService, ISheetSelectionRenderService, IStatusBarService, InsertRangeMoveDownConfirmCommand, InsertRangeMoveRightConfirmCommand, JumpOver, MarkSelectionService, MoveSelectionCommand, MoveSelectionEnterAndTabCommand, PASTE_SPECIAL_MENU_ID, PREDEFINED_HOOK_NAME, PREDEFINED_HOOK_NAME_COPY, PREDEFINED_HOOK_NAME_PASTE, RANGE_SELECTOR_COMPONENT_KEY, RANGE_SELECTOR_SYMBOLS, RemoveColConfirmCommand, RemoveRowConfirmCommand, RemoveSheetConfirmCommand, RenameSheetOperation, RepeatLastActionPermission, ResetRangeTextColorCommand, ResetScrollCommand, SELECTION_SHAPE_DEPTH, SHEET_UI_PLUGIN_NAME, SHEET_VIEW_KEY, ScrollCommand, ScrollToCellCommand, ScrollToRangeOperation, SelectAllCommand, SelectionControl, SelectionControl as SelectionShape, SelectionShapeExtension, SetActivateCellEditOperation, SetCellEditVisibleArrowOperation, SetCellEditVisibleOperation, SetCellEditVisibleWithF2Operation, SetColumnFrozenCommand, SetColumnHeaderHeightCommand, SetFirstColumnFrozenCommand, SetFirstRowFrozenCommand, SetFormatPainterOperation, SetInfiniteFormatPainterCommand, SetOnceFormatPainterCommand, SetRangeBoldCommand, SetRangeFontDecreaseCommand, SetRangeFontFamilyCommand, SetRangeFontIncreaseCommand, SetRangeFontSizeCommand, SetRangeItalicCommand, SetRangeProtectionFromContextMenuCommand, SetRangeStrickThroughCommand, SetRangeSubscriptCommand, SetRangeSuperscriptCommand, SetRangeTextColorCommand, SetRangeUnderlineCommand, SetRowFrozenCommand, SetRowHeaderWidthCommand, SetScrollOperation, SetScrollRelativeCommand, SetSelectionFrozenCommand, SetWorksheetColAutoWidthCommand, SetZoomRatioCommand, SetZoomRatioOperation, SheetCanvasPopManagerService, SheetCellDropdownManagerService, SheetCellEditorResizeService, SheetClipboardController, SheetClipboardService, SheetCopyCommand, SheetCutCommand, SheetMenuPosition, SheetPasteBesidesBorderCommand, SheetPasteColWidthCommand, SheetPasteCommand, SheetPasteFormatCommand, SheetPasteShortKeyCommand, SheetPasteValueCommand, SheetPermissionCheckUIController, SheetPermissionOpenDialogOperation, SheetPermissionOpenPanelOperation, SheetPermissionRenderManagerService, SheetPermissionUserManagerService, SheetPrintInterceptorService, SheetRenderController, SheetScrollManagerService, SheetSelectionRenderService, SheetSkeletonManagerService, SheetUIController, SheetsRenderService, SheetsScrollRenderController, menuSchema as SheetsUIMenuSchema, SheetsUIPart, ShowMenuListCommand, SidebarDefinedNameOperation, StatusBarController, StatusBarService, UNIVER_SHEET_PERMISSION_USER_PART, UniverSheetsMobileUIPlugin, UniverSheetsUIPlugin, ViewSheetPermissionFromContextMenuCommand, ViewSheetPermissionFromSheetBarCommand, calculateDocSkeletonRects, matchedSelectionByRowColIndex as checkInHeaderRanges, deriveStateFromActiveSheet$, functionDisplayNames, genNormalSelectionStyle, genSelectionByRange, selectionDataForSelectAll as getAllSelection, getCellRealRange, getCoordByCell, getCoordByOffset, getCurrentExclusiveRangeInterest$, getCurrentRangeDisable$, getCustomRangePosition, getEditingCustomRangePosition, getEditorObject, getMatrixPlainText, getObservableWithExclusiveRange$, getRepeatRange, getSheetObject, getTopLeftSelectionOfCurrSheet, getTransformCoord, getViewportByCell, isEmbeddingFormulaEditor, isRangeSelector, menuClipboardDisabledObservable, mergeSetRangeValues, useActiveWorkbook, useActiveWorksheet, useHighlightRange, useKeyEventConfig, useWorkbooks, virtualizeDiscreteRanges, whenFormulaEditorActivated, whenSheetEditorActivated, whenSheetEditorFocused };