@univerjs/sheets-ui 1.0.1 → 1.0.3

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.
package/lib/cjs/index.js CHANGED
@@ -4780,14 +4780,18 @@ let SheetClipboardService = class SheetClipboardService extends _univerjs_core.D
4780
4780
  const pasteRangeStartColumn = cols[0];
4781
4781
  const pasteRangeEndColumn = cols[cols.length - 1];
4782
4782
  const needAutoHeight = [];
4783
- for (let r = pasteRangeStartRow; r <= pasteRangeEndRow; r++) if (!rowManager.getRow(r)) {
4784
- const autoHeight = skeleton.calculateAutoHeightInRange([{
4785
- startRow: r,
4786
- endRow: r,
4787
- startColumn: pasteRangeStartColumn,
4788
- endColumn: pasteRangeEndColumn
4789
- }]).filter((info) => info.autoHeight !== defaultRowHeight);
4790
- needAutoHeight.push(...autoHeight);
4783
+ for (let r = pasteRangeStartRow; r <= pasteRangeEndRow; r++) {
4784
+ const rowData = rowManager.getRow(r);
4785
+ const hasLegacyManualHeight = (rowData === null || rowData === void 0 ? void 0 : rowData.ia) == null && (rowData === null || rowData === void 0 ? void 0 : rowData.ah) == null && typeof (rowData === null || rowData === void 0 ? void 0 : rowData.h) === "number";
4786
+ if (!((rowData === null || rowData === void 0 ? void 0 : rowData.ia) === _univerjs_core.BooleanNumber.FALSE || hasLegacyManualHeight)) {
4787
+ const autoHeight = skeleton.calculateAutoHeightInRange([{
4788
+ startRow: r,
4789
+ endRow: r,
4790
+ startColumn: pasteRangeStartColumn,
4791
+ endColumn: pasteRangeEndColumn
4792
+ }]).filter((info) => info.autoHeight !== defaultRowHeight);
4793
+ needAutoHeight.push(...autoHeight);
4794
+ }
4791
4795
  }
4792
4796
  if (needAutoHeight.length > 0) {
4793
4797
  const setWorksheetRowAutoHeightMutationParams = {
@@ -11397,12 +11401,13 @@ function getPercentEditorSelection(editCellState, visibleParam, dataStream) {
11397
11401
  const percentOffset = getPercentOffset(editCellState, dataStream);
11398
11402
  if (percentOffset == null) return null;
11399
11403
  const { eventType, initialValue, keycode } = visibleParam;
11400
- if (eventType === _univerjs_engine_render.DeviceInputEventType.Dblclick || eventType === _univerjs_engine_render.DeviceInputEventType.Keyboard && keycode === _univerjs_ui.KeyCode.F2) return {
11404
+ if ((0, _univerjs_core.isFormulaString)(dataStream) && (eventType === _univerjs_engine_render.DeviceInputEventType.Dblclick || keycode === _univerjs_ui.KeyCode.F2)) return null;
11405
+ if (eventType === _univerjs_engine_render.DeviceInputEventType.Keyboard && keycode === _univerjs_ui.KeyCode.F2) return {
11401
11406
  startOffset: percentOffset,
11402
11407
  endOffset: percentOffset,
11403
11408
  collapsed: true
11404
11409
  };
11405
- if (eventType !== _univerjs_engine_render.DeviceInputEventType.Keyboard || keycode === _univerjs_ui.KeyCode.BACKSPACE || keycode === _univerjs_ui.KeyCode.DELETE || !/^\d/.test(initialValue ?? "")) return null;
11410
+ if (eventType !== _univerjs_engine_render.DeviceInputEventType.Dblclick && (eventType !== _univerjs_engine_render.DeviceInputEventType.Keyboard || keycode === _univerjs_ui.KeyCode.BACKSPACE || keycode === _univerjs_ui.KeyCode.DELETE || !/^\d/.test(initialValue ?? ""))) return null;
11406
11411
  return {
11407
11412
  startOffset: 0,
11408
11413
  endOffset: percentOffset,
@@ -11587,28 +11592,38 @@ let EditingRenderController = class EditingRenderController extends _univerjs_co
11587
11592
  */
11588
11593
  _commandExecutedListener(d) {
11589
11594
  d.add(this._commandService.beforeCommandExecuted((command) => {
11590
- var _this$_getDocumentDat;
11591
- if (command.id !== _univerjs_docs.InsertTextCommand.id) return;
11592
- const params = command.params;
11595
+ var _this$_getDocumentDat, _pasteParams$doc$body, _this$_textSelectionM;
11596
+ if (command.id !== _univerjs_docs.InsertTextCommand.id && command.id !== _univerjs_docs_ui.InnerPasteCommand.id) return;
11597
+ const insertParams = command.id === _univerjs_docs.InsertTextCommand.id ? command.params : null;
11598
+ const pasteParams = command.id === _univerjs_docs_ui.InnerPasteCommand.id ? command.params : null;
11599
+ const unitId = (insertParams === null || insertParams === void 0 ? void 0 : insertParams.unitId) ?? (pasteParams === null || pasteParams === void 0 ? void 0 : pasteParams.unitId);
11593
11600
  const visibleParam = this._editorBridgeService.isVisible();
11594
11601
  const editCellState = this._editorBridgeService.getEditLocation();
11595
- if (params.unitId !== _univerjs_core.DOCS_NORMAL_EDITOR_UNIT_ID_KEY || !visibleParam.visible || editCellState == null) return;
11602
+ if (unitId !== _univerjs_core.DOCS_NORMAL_EDITOR_UNIT_ID_KEY || !visibleParam.visible || editCellState == null) return;
11596
11603
  const dataStream = (_this$_getDocumentDat = this._getDocumentDataModel()) === null || _this$_getDocumentDat === void 0 || (_this$_getDocumentDat = _this$_getDocumentDat.getBody()) === null || _this$_getDocumentDat === void 0 ? void 0 : _this$_getDocumentDat.dataStream;
11597
11604
  if (dataStream == null) return;
11598
11605
  const percentOffset = getPercentOffset(editCellState, dataStream);
11599
- if (percentOffset != null && !this._editorBridgeService.getEditorDirty() && visibleParam.eventType === _univerjs_engine_render.DeviceInputEventType.Keyboard && /^\d/.test(visibleParam.initialValue ?? "") && /^\d/.test(params.body.dataStream)) {
11600
- params.range = {
11601
- startOffset: 0,
11602
- endOffset: percentOffset,
11606
+ if (percentOffset == null) return;
11607
+ if (insertParams && !this._editorBridgeService.getEditorDirty() && visibleParam.eventType === _univerjs_engine_render.DeviceInputEventType.Keyboard && /^\d/.test(visibleParam.initialValue ?? "") && /^\d/.test(insertParams.body.dataStream)) insertParams.range = {
11608
+ startOffset: 0,
11609
+ endOffset: percentOffset + (insertParams.body.dataStream.endsWith("%") ? 1 : 0),
11610
+ collapsed: false
11611
+ };
11612
+ const selectionParams = {
11613
+ unitId,
11614
+ subUnitId: unitId
11615
+ };
11616
+ const ranges = insertParams ? [insertParams.range] : this._textSelectionManagerService.getTextRanges(selectionParams);
11617
+ const input = (insertParams === null || insertParams === void 0 ? void 0 : insertParams.body.dataStream) ?? (pasteParams === null || pasteParams === void 0 || (_pasteParams$doc$body = pasteParams.doc.body) === null || _pasteParams$doc$body === void 0 ? void 0 : _pasteParams$doc$body.dataStream);
11618
+ if (!(0, _univerjs_core.isFormulaString)(dataStream) && (input === null || input === void 0 ? void 0 : input.endsWith("%")) && (ranges === null || ranges === void 0 ? void 0 : ranges.length) === 1 && ranges[0].endOffset === percentOffset && (!pasteParams || !((_this$_textSelectionM = this._textSelectionManagerService.getRectRanges(selectionParams)) === null || _this$_textSelectionM === void 0 ? void 0 : _this$_textSelectionM.length))) {
11619
+ const range = {
11620
+ ...ranges[0],
11621
+ endOffset: percentOffset + 1,
11603
11622
  collapsed: false
11604
11623
  };
11605
- return;
11624
+ if (insertParams) insertParams.range = range;
11625
+ else if (pasteParams) pasteParams.selections = [range];
11606
11626
  }
11607
- if (percentOffset != null && params.body.dataStream === "%" && params.range.collapsed && params.range.startOffset === percentOffset && params.range.endOffset === percentOffset) params.range = {
11608
- ...params.range,
11609
- endOffset: percentOffset + 1,
11610
- collapsed: false
11611
- };
11612
11627
  }));
11613
11628
  d.add(this._commandService.onCommandExecuted((command) => {
11614
11629
  if (command.id === _univerjs_docs.RichTextEditingMutation.id) {
@@ -11701,30 +11716,28 @@ let EditingRenderController = class EditingRenderController extends _univerjs_co
11701
11716
  else if (eventType === _univerjs_engine_render.DeviceInputEventType.Keyboard && keycode === _univerjs_ui.KeyCode.F2) {
11702
11717
  var _documentDataModel$ge2;
11703
11718
  document.makeDirty();
11704
- this._textSelectionManagerService.replaceDocRanges([{
11719
+ replaceSelection({
11705
11720
  startOffset: 0,
11706
- endOffset: 0
11707
- }]);
11721
+ endOffset: 0,
11722
+ collapsed: true
11723
+ });
11708
11724
  const endOffset = (((_documentDataModel$ge2 = documentDataModel.getBody()) === null || _documentDataModel$ge2 === void 0 ? void 0 : _documentDataModel$ge2.dataStream.length) ?? 2) - 2;
11709
- if (percentSelection) replaceSelection(percentSelection);
11710
- else this._textSelectionManagerService.replaceDocRanges([{
11725
+ replaceSelection(percentSelection ?? {
11711
11726
  startOffset: endOffset,
11712
- endOffset
11713
- }], {
11714
- unitId: _univerjs_core.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,
11715
- subUnitId: _univerjs_core.DOCS_NORMAL_EDITOR_UNIT_ID_KEY
11727
+ endOffset,
11728
+ collapsed: true
11716
11729
  });
11717
11730
  } else if (eventType === _univerjs_engine_render.DeviceInputEventType.Keyboard || eventType === _univerjs_engine_render.DeviceInputEventType.Dblclick && isInArrayFormulaRange) {
11718
11731
  if (percentSelection) replaceSelection(percentSelection);
11719
11732
  else clearAndEdit();
11720
11733
  } else if (eventType === _univerjs_engine_render.DeviceInputEventType.Dblclick) {
11721
11734
  if (this._contextService.getContextValue(_univerjs_core.FOCUSING_EDITOR_INPUT_FORMULA)) return;
11722
- const cursor = documentDataModel.getBody().dataStream.length - 2 || 0;
11723
- if (percentSelection) replaceSelection(percentSelection);
11724
- else this._textSelectionManagerService.replaceDocRanges([{
11725
- startOffset: cursor,
11726
- endOffset: cursor
11727
- }]);
11735
+ const endOffset = documentDataModel.getBody().dataStream.length - 2 || 0;
11736
+ replaceSelection(percentSelection ?? {
11737
+ startOffset: 0,
11738
+ endOffset,
11739
+ collapsed: endOffset === 0
11740
+ });
11728
11741
  }
11729
11742
  (_this$_renderManagerS5 = this._renderManagerService.getRenderUnitById(unitId)) === null || _this$_renderManagerS5 === void 0 || _this$_renderManagerS5.scene.resetCursor();
11730
11743
  }
@@ -19401,6 +19414,15 @@ function PasteSpacialMenuItemFactory(accessor) {
19401
19414
  hidden$: getObservableWithExclusiveRange$(accessor, (0, _univerjs_ui.getMenuHiddenObservable)(accessor, _univerjs_core.UniverInstanceType.UNIVER_SHEET))
19402
19415
  };
19403
19416
  }
19417
+ const PASTE_RIBBON_MENU_ID = "sheet.menu.paste";
19418
+ function PasteRibbonMenuItemFactory(accessor) {
19419
+ return {
19420
+ ...PasteSpacialMenuItemFactory(accessor),
19421
+ id: PASTE_RIBBON_MENU_ID,
19422
+ title: "sheets-ui.rightClick.paste",
19423
+ hidden$: (0, rxjs.combineLatest)([getObservableWithExclusiveRange$(accessor, (0, _univerjs_ui.getMenuHiddenObservable)(accessor, _univerjs_core.UniverInstanceType.UNIVER_SHEET)), accessor.get(_univerjs_core.IContextService).subscribeContextValue$(_univerjs_core.FOCUSING_SHAPE_TEXT_EDITOR).pipe((0, rxjs.startWith)(false))]).pipe((0, rxjs.map)(([hidden, editing]) => hidden || editing))
19424
+ };
19425
+ }
19404
19426
  function PasteValueMenuItemFactory(accessor) {
19405
19427
  return {
19406
19428
  id: SheetPasteValueCommand.id,
@@ -20326,6 +20348,39 @@ function ZoomRatioMenuItemFactory(accessor) {
20326
20348
  //#region src/menu/schema.ts
20327
20349
  const menuSchema = {
20328
20350
  [_univerjs_ui.RibbonPosition.START]: {
20351
+ [_univerjs_ui.RibbonStartGroup.HISTORY]: { [PASTE_RIBBON_MENU_ID]: {
20352
+ order: 4,
20353
+ gridLayout: {
20354
+ row: 1,
20355
+ column: 3,
20356
+ rowSpan: 2,
20357
+ showLabel: true
20358
+ },
20359
+ menuItemFactory: PasteRibbonMenuItemFactory,
20360
+ [SheetPasteCommand.name]: {
20361
+ order: 0,
20362
+ menuItemFactory: (accessor) => ({
20363
+ ...PasteMenuItemFactory(accessor),
20364
+ icon: void 0
20365
+ })
20366
+ },
20367
+ [SheetPasteValueCommand.id]: {
20368
+ order: 1,
20369
+ menuItemFactory: PasteValueMenuItemFactory
20370
+ },
20371
+ [SheetPasteFormatCommand.id]: {
20372
+ order: 2,
20373
+ menuItemFactory: PasteFormatMenuItemFactory
20374
+ },
20375
+ [SheetPasteColWidthCommand.id]: {
20376
+ order: 3,
20377
+ menuItemFactory: PasteColWidthMenuItemFactory
20378
+ },
20379
+ [SheetPasteBesidesBorderCommand.id]: {
20380
+ order: 4,
20381
+ menuItemFactory: PasteBesidesBorderMenuItemFactory
20382
+ }
20383
+ } },
20329
20384
  [_univerjs_ui.RibbonStartGroup.FORMAT]: {
20330
20385
  [SetRangeFontFamilyCommand.id]: {
20331
20386
  order: 1,
@@ -24855,7 +24910,7 @@ const useHighlightRange = (ranges = []) => {
24855
24910
  //#endregion
24856
24911
  //#region package.json
24857
24912
  var name = "@univerjs/sheets-ui";
24858
- var version = "1.0.1";
24913
+ var version = "1.0.3";
24859
24914
 
24860
24915
  //#endregion
24861
24916
  //#region src/views/cell-popup/config.ts
@@ -25482,16 +25537,20 @@ let FormatPainterController = class FormatPainterController extends _univerjs_co
25482
25537
  _initialize() {
25483
25538
  this._addDefaultHook();
25484
25539
  const session = this._injector.get(_univerjs_ui.FormatPainterSessionService);
25540
+ let disabled = true;
25541
+ const disabled$ = this._injector.invoke(ClearSelectionFormatMenuItemFactory).disabled$;
25485
25542
  this.disposeWithMe(session.register({
25486
25543
  id: "sheet-cells",
25487
25544
  priority: 0,
25488
25545
  clear: () => this._commandService.executeCommand(_univerjs_sheets.ClearSelectionFormatCommand.id),
25489
- changes$: this._selectionManagerService.selectionMoveEnd$,
25546
+ changes$: disabled$.pipe((0, rxjs.tap)((value) => {
25547
+ disabled = value;
25548
+ })),
25490
25549
  isActive: () => {
25491
25550
  var _this$_univerInstance;
25492
25551
  return ((_this$_univerInstance = this._univerInstanceService.getFocusedUnit()) === null || _this$_univerInstance === void 0 ? void 0 : _this$_univerInstance.type) === _univerjs_core.UniverInstanceType.UNIVER_SHEET;
25493
25552
  },
25494
- canStart: () => !!this._selectionManagerService.getCurrentLastSelection(),
25553
+ canStart: () => !disabled && !!this._selectionManagerService.getCurrentLastSelection(),
25495
25554
  capture: () => {
25496
25555
  const workbook = this._univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_SHEET);
25497
25556
  const format = this._collectSelectionRangeFormat();
package/lib/es/index.js CHANGED
@@ -1,9 +1,9 @@
1
- import { BreakLineCommand, CoverContentCommand, DOCS_COMPONENT_MAIN_LAYER_INDEX, DOCS_VIEW_KEY, DOC_VERTICAL_PADDING, DeleteLeftCommand, DeleteRightCommand, DocSelectionRenderService, EnterCommand, IEditorService, IMEInputCommand, MobileRichTextToolbar, MoveCursorOperation, MoveSelectionOperation, NodePositionConvertToCursor, ReplaceSnapshotCommand, SetDocInputStyleCommand, SetInlineFormatBoldCommand, SetInlineFormatCommand, SetInlineFormatFontFamilyCommand, SetInlineFormatFontSizeCommand, SetInlineFormatItalicCommand, SetInlineFormatStrikethroughCommand, SetInlineFormatSubscriptCommand, SetInlineFormatSuperscriptCommand, SetInlineFormatTextColorCommand, SetInlineFormatUnderlineCommand, UniverDocsUIPlugin, VIEWPORT_KEY, convertBodyToHtml, getCanvasOffsetByEngine, getLineBounding } from "@univerjs/docs-ui";
1
+ import { BreakLineCommand, CoverContentCommand, DOCS_COMPONENT_MAIN_LAYER_INDEX, DOCS_VIEW_KEY, DOC_VERTICAL_PADDING, DeleteLeftCommand, DeleteRightCommand, DocSelectionRenderService, EnterCommand, IEditorService, IMEInputCommand, InnerPasteCommand, MobileRichTextToolbar, MoveCursorOperation, MoveSelectionOperation, NodePositionConvertToCursor, ReplaceSnapshotCommand, SetDocInputStyleCommand, SetInlineFormatBoldCommand, SetInlineFormatCommand, SetInlineFormatFontFamilyCommand, SetInlineFormatFontSizeCommand, SetInlineFormatItalicCommand, SetInlineFormatStrikethroughCommand, SetInlineFormatSubscriptCommand, SetInlineFormatSuperscriptCommand, SetInlineFormatTextColorCommand, SetInlineFormatUnderlineCommand, UniverDocsUIPlugin, VIEWPORT_KEY, convertBodyToHtml, getCanvasOffsetByEngine, getLineBounding } from "@univerjs/docs-ui";
2
2
  import { AbsoluteRefType, BaselineOffset, BooleanNumber, BorderStyleTypes, BorderType, CellModeEnum, CellValueType, ColorKit, CommandType, CustomRangeType, DEFAULT_EMPTY_DOCUMENT_VALUE, DEFAULT_STYLES, DEFAULT_WORKSHEET_COLUMN_COUNT, DEFAULT_WORKSHEET_COLUMN_WIDTH, DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY, DEFAULT_WORKSHEET_ROW_COUNT, DEFAULT_WORKSHEET_ROW_HEIGHT, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY, DOCS_NORMAL_EDITOR_UNIT_ID_KEY, DataStreamTreeTokenType, DependentOn, Direction, Disposable, DisposableCollection, DocumentFlavor, EDITOR_ACTIVATED, ErrorService, FOCUSING_COMMENT_EDITOR, FOCUSING_COMMON_DRAWINGS, FOCUSING_EDITOR_INPUT_FORMULA, FOCUSING_EDITOR_STANDALONE, FOCUSING_FX_BAR_EDITOR, FOCUSING_SHAPE_TEXT_EDITOR, FOCUSING_SHEET, FOCUSING_UNIVER_EDITOR, FontItalic, FontWeight, HorizontalAlign, IAuthzIoService, ICommandService, IConfigService, IConfirmService, IContextService, ILogService, IPermissionService, IUndoRedoService, IUniverInstanceService, Inject, Injector, InterceptorEffectEnum, InterceptorManager, LRUMap, LocaleService, LocaleType, LookUp, NilCommand, ObjectMatrix, Optional, Plugin, PresetListType, Quantity, RANGE_TYPE, Range, Rectangle, RxDisposable, SHEET_EDITOR_UNITS, ThemeService, Tools, UndoCommandId, UniverInstanceType, UserManagerService, VerticalAlign, Workbook, WorksheetHiddenState, WrapStrategy, cloneCellData, cloneCellDataMatrix, cloneCellDataWithSpanAndDisplay, composeStyles, convertCellToRange, createDocumentModelWithStyle, createIdentifier, createInterceptorKey, createParagraphId, createSectionId, dateKit, debounce, extractPureTextFromCell, fromEventSubject, generateRandomId, get, getEmptyCell, getIntersectRange, getNumfmtLocaleTag, getNumfmtParseValueFilter, getReverseDirection, handleStyleToString, isDefaultFormat, isFormulaString, isNotNullOrUndefined, isRealNum, isSafeUrl, isTextFormat, isValidRange, merge, mergeOverrideWithDependencies, nameCharacterCheck, numberToABC, numfmt, registerDependencies, sequenceExecute, set, skipParseTagNames, sortRules, splitIntoGrid, throttle, toDisposable, touchDependencies, willLoseNumericPrecision } from "@univerjs/core";
3
3
  import { AUTO_FILL_APPLY_TYPE, AUTO_FILL_HOOK_TYPE, AddMergeUndoMutationFactory, AddRangeProtectionCommand, AddRangeProtectionMutation, AddWorksheetMergeAllCommand, AddWorksheetMergeCommand, AddWorksheetMergeHorizontalCommand, AddWorksheetMergeMutation, AddWorksheetMergeVerticalCommand, AddWorksheetProtectionCommand, AutoClearContentCommand, AutoFillCommand, AutoFillController, BEFORE_CELL_EDIT, BorderStyleManagerService, COMMAND_LISTENER_SKELETON_CHANGE, COMMAND_LISTENER_VALUE_CHANGE, CancelFrozenCommand, CancelMarkDirtyRowAutoHeightOperation, ClearSelectionAllCommand, ClearSelectionContentCommand, ClearSelectionFormatCommand, CopySheetCommand, DeleteRangeMoveLeftCommand, DeleteRangeMoveUpCommand, DeleteRangeProtectionCommand, DeleteRangeProtectionMutation, DeleteWorksheetProtectionCommand, DeltaColumnWidthCommand, DeltaRowHeightCommand, EditStateEnum, IAutoFillService, IExclusiveRangeService, INTERCEPTOR_POINT, INumfmtService, IRefSelectionsService, InsertColBeforeCommand, InsertColCommand, InsertColMutation, InsertDefinedNameCommand, InsertMultiColsLeftCommand, InsertMultiColsRightCommand, InsertMultiRowsAboveCommand, InsertMultiRowsAfterCommand, InsertRangeMoveDownCommand, InsertRangeMoveRightCommand, InsertRowBeforeCommand, InsertRowCommand, InsertRowMutation, InsertSheetCommand, InsertSheetMutation, MAX_CELL_PER_SHEET_KEY, MERGE_CELL_INTERCEPTOR_CHECK, MarkDirtyRowAutoHeightOperation, MergeCellController, MoveColsCommand, MoveColsMutation, MoveRangeCommand, MoveRangeMutation, MoveRowsCommand, MoveRowsMutation, REF_SELECTIONS_ENABLED, RangeProtectionCache, RangeProtectionPermissionEditPoint, RangeProtectionPermissionViewPoint, RangeProtectionRuleModel, RefRangeService, RefSelectionsService, RefillCommand, RemoveColCommand, RemoveColMutation, RemoveDefinedNameCommand, RemoveMergeUndoMutationFactory, RemoveRowCommand, RemoveRowMutation, RemoveSheetCommand, RemoveSheetMutation, RemoveWorksheetMergeCommand, RemoveWorksheetMergeMutation, ResetBackgroundColorCommand, ResetTextColorCommand, SCOPE_WORKBOOK_VALUE_DEFINED_NAME, SELECTIONS_ENABLED, SELECTION_CONTROL_BORDER_BUFFER_COLOR, SELECTION_CONTROL_BORDER_BUFFER_WIDTH, SHEETS_PLUGIN_CONFIG_KEY, ScrollToCellOperation, SelectionMoveType, SetBackgroundColorCommand, SetBoldCommand, SetBorderBasicCommand, SetBorderCommand, SetColHiddenCommand, SetColHiddenMutation, SetColVisibleMutation, SetColWidthCommand, SetDefinedNameCommand, SetFontFamilyCommand, SetFontSizeCommand, SetFrozenCommand, SetFrozenMutation, SetFrozenMutationFactory, SetHorizontalTextAlignCommand, SetItalicCommand, SetProtectionCommand, SetRangeValuesCommand, SetRangeValuesMutation, SetRangeValuesUndoMutationFactory, SetRowHeightCommand, SetRowHiddenCommand, SetRowHiddenMutation, SetRowVisibleMutation, SetSelectedColsVisibleCommand, SetSelectedRowsVisibleCommand, SetSelectionsOperation, SetShrinkToFitCommand, SetSpecificColsVisibleCommand, SetSpecificRowsVisibleCommand, SetStrikeThroughCommand, SetStyleCommand, SetTabColorCommand, SetTabColorMutation, SetTextColorCommand, SetTextRotationCommand, SetTextWrapCommand, SetUnderlineCommand, SetVerticalTextAlignCommand, SetWorksheetActivateCommand, SetWorksheetActiveOperation, SetWorksheetColWidthMutation, SetWorksheetColWidthMutationFactory, SetWorksheetHideCommand, SetWorksheetHideMutation, SetWorksheetNameCommand, SetWorksheetNameMutation, SetWorksheetOrderCommand, SetWorksheetOrderMutation, SetWorksheetPermissionPointsCommand, SetWorksheetRowAutoHeightMutation, SetWorksheetRowAutoHeightMutationFactory, SetWorksheetRowHeightMutation, SetWorksheetRowIsAutoHeightCommand, SetWorksheetRowIsAutoHeightMutation, SetWorksheetShowCommand, SheetCopyDownCommand, SheetCopyRightCommand, SheetInterceptorService, SheetPermissionCheckController, SheetPermissionInitController, SheetSkeletonService, SheetsSelectionsService, TextToNumberCommand, ToggleCellCheckboxCommand, ToggleGridlinesCommand, ToggleGridlinesMutation, UniverSheetsPlugin, ViewStateEnum, WorkbookCopyPermission, WorkbookCreateProtectPermission, WorkbookCreateSheetPermission, WorkbookDeleteColumnPermission, WorkbookDeleteRowPermission, WorkbookDeleteSheetPermission, WorkbookEditablePermission, WorkbookHideSheetPermission, WorkbookInsertColumnPermission, WorkbookInsertRowPermission, WorkbookManageCollaboratorPermission, WorkbookRenameSheetPermission, WorksheetCopyPermission, WorksheetDeleteColumnPermission, WorksheetDeleteProtectionPermission, WorksheetDeleteRowPermission, WorksheetEditPermission, WorksheetInsertColumnPermission, WorksheetInsertRowPermission, WorksheetManageCollaboratorPermission, WorksheetProtectionPointModel, WorksheetProtectionRuleModel, WorksheetSetCellStylePermission, WorksheetSetCellValuePermission, WorksheetSetColumnStylePermission, WorksheetSetRowStylePermission, WorksheetViewPermission, adjustRangeOnMutation, alignToMergedCellsBorders, attachPrimaryWithCoord, attachRangeWithCoord, attachSelectionWithCoord, baseProtectionActions, convertPrimaryWithCoordToPrimary, convertSelectionDataToRange, countCells, defaultLargeSheetOperationConfig, deserializeListOptions, discreteRangeToRange, expandToContinuousRange, findFirstNonEmptyCell, getAddMergeMutationRangeByType, getAllWorksheetPermissionPoint, getCellAtRowCol, getCellType, getCellValue, getClearContentMutationParamsForRanges, getMoveRangeCommandMutations, getPrimaryForRange, getSelectionsService, getSheetCommandTarget, isCellImage, rangeToDiscreteRange, serializeListOptions, setEndForRange, validateDefinedName } from "@univerjs/sheets";
4
4
  import { AnchoredContextMenu, BuiltInUIPart, COLOR_PICKER_COMPONENT, ComponentContainer, ComponentManager, ContextMenuGroup, ContextMenuPosition, CopyCommand, CutCommand, DISABLE_AUTO_FOCUS_KEY, FILE_PNG_CLIPBOARD_MIME_TYPE, FILE__BMP_CLIPBOARD_MIME_TYPE, FILE__JPEG_CLIPBOARD_MIME_TYPE, FILE__WEBP_CLIPBOARD_MIME_TYPE, FONT_FAMILY_COMPONENT, FONT_FAMILY_ITEM_COMPONENT, FONT_SIZE_COMPONENT, FONT_SIZE_LIST, FormatPainterSessionService, HTML_CLIPBOARD_MIME_TYPE, ICanvasPopupService, IClipboardInterfaceService, IContextMenuService, IDialogService, IFontService, ILayoutService, IMenuManagerService, IMessageService, INotificationService, IPlatformService, IRibbonService, IShortcutService, ISidebarService, IUIPartsService, IUIRuntimeScopeService, IWorkbenchService, IconManager, KeyCode, MenuItemType, MetaKeys, MobileDrawer, MobileMenu, MobileZoomIndicator, PLAIN_TEXT_CLIPBOARD_MIME_TYPE, PasteCommand, RibbonPosition, RibbonStartGroup, RibbonViewGroup, SheetPasteShortKeyCommandName, Slider, ToggleFullscreenOperation, ToolbarItem, UI_PLUGIN_CONFIG_KEY, UniverMobileUIPlugin, ZoomInput, bindFormatPainterCanvas, connectInjector, getEmbedBoundaryOwner, getEmbedChildUnitId, getMenuHiddenObservable, handleStringToStyle, imageMimeTypeSet, sanitizeParsedHtml, textTrim, useComponentsOfPart, useConfigValue, useDependency, useEvent, useObservable, useSidebarClick, useToolbarItemStatus, useVirtualList } from "@univerjs/ui";
5
5
  import { CURSOR_TYPE, DashedRect, DeviceInputEventType, DeviceType, FIX_ONE_PIXEL_BLUR_OFFSET, Group, IRenderManagerService, Layer, RENDER_CLASS_TYPE, RENDER_RAW_FORMULA_KEY, Rect, RegularPolygon, SHEET_EXTENSION_PREFIX, SHEET_VIEWPORT_KEY, ScrollBar, ScrollTimer, ScrollTimerType, Shape, SheetExtension, Spreadsheet, SpreadsheetColumnHeader, SpreadsheetRowHeader, TRANSFORM_CHANGE_OBSERVABLE_TYPE, UniverRenderEnginePlugin, Vector2, Viewport, calculateCellImageRect, cancelRequestFrame, convertTextRotation, convertTransformToOffsetX, convertTransformToOffsetY, fixLineWidthByScale, getCurrentTypeOfRenderer, getNextWheelZoomRatio, ptToPixel, requestNewFrame, withCurrentTypeOfRenderer } from "@univerjs/engine-render";
6
- import { BehaviorSubject, EMPTY, Observable, Subject, Subscription, combineLatest, combineLatestWith, distinctUntilChanged, filter, from, fromEvent, isObservable, map, merge as merge$1, of, shareReplay, skip, startWith, switchMap, takeUntil, throttleTime, withLatestFrom } from "rxjs";
6
+ import { BehaviorSubject, EMPTY, Observable, Subject, Subscription, combineLatest, combineLatestWith, distinctUntilChanged, filter, from, fromEvent, isObservable, map, merge as merge$1, of, shareReplay, skip, startWith, switchMap, takeUntil, tap, throttleTime, withLatestFrom } from "rxjs";
7
7
  import { DocSelectionManagerService, DocSkeletonManagerService, DocStateChangeManagerService, InsertTextCommand, RichTextEditingMutation, SetTextSelectionsOperation, UniverDocsPlugin } from "@univerjs/docs";
8
8
  import { ObjectScope, UnitAction, UnitObject, UnitRole } from "@univerjs/protocol";
9
9
  import { ActionRow, Avatar, Button, Calendar, CascaderList, ColorPicker, ColorPickerPanel, ConfigContext, Confirm, Dropdown, DropdownMenu, FormLayout, Input, InputNumber, MessageType, MobileActionRow, MobileActionRowGroup, MobileColorPicker, MobileColorPresets, MobileConfirm, MobileDialog, MobileDropdown, MobileDropdownMenu, MobileSelect, Radio, RadioGroup, Select, Separator, Switch, TimeInput, Tooltip, borderBottomClassName, borderClassName, borderLeftClassName, borderRightClassName, borderTopClassName, clsx, resetButtonClassName, scrollbarClassName, useMobileKeyboardViewportLayout } from "@univerjs/design";
@@ -4779,14 +4779,18 @@ let SheetClipboardService = class SheetClipboardService extends Disposable {
4779
4779
  const pasteRangeStartColumn = cols[0];
4780
4780
  const pasteRangeEndColumn = cols[cols.length - 1];
4781
4781
  const needAutoHeight = [];
4782
- for (let r = pasteRangeStartRow; r <= pasteRangeEndRow; r++) if (!rowManager.getRow(r)) {
4783
- const autoHeight = skeleton.calculateAutoHeightInRange([{
4784
- startRow: r,
4785
- endRow: r,
4786
- startColumn: pasteRangeStartColumn,
4787
- endColumn: pasteRangeEndColumn
4788
- }]).filter((info) => info.autoHeight !== defaultRowHeight);
4789
- needAutoHeight.push(...autoHeight);
4782
+ for (let r = pasteRangeStartRow; r <= pasteRangeEndRow; r++) {
4783
+ const rowData = rowManager.getRow(r);
4784
+ const hasLegacyManualHeight = (rowData === null || rowData === void 0 ? void 0 : rowData.ia) == null && (rowData === null || rowData === void 0 ? void 0 : rowData.ah) == null && typeof (rowData === null || rowData === void 0 ? void 0 : rowData.h) === "number";
4785
+ if (!((rowData === null || rowData === void 0 ? void 0 : rowData.ia) === BooleanNumber.FALSE || hasLegacyManualHeight)) {
4786
+ const autoHeight = skeleton.calculateAutoHeightInRange([{
4787
+ startRow: r,
4788
+ endRow: r,
4789
+ startColumn: pasteRangeStartColumn,
4790
+ endColumn: pasteRangeEndColumn
4791
+ }]).filter((info) => info.autoHeight !== defaultRowHeight);
4792
+ needAutoHeight.push(...autoHeight);
4793
+ }
4790
4794
  }
4791
4795
  if (needAutoHeight.length > 0) {
4792
4796
  const setWorksheetRowAutoHeightMutationParams = {
@@ -11396,12 +11400,13 @@ function getPercentEditorSelection(editCellState, visibleParam, dataStream) {
11396
11400
  const percentOffset = getPercentOffset(editCellState, dataStream);
11397
11401
  if (percentOffset == null) return null;
11398
11402
  const { eventType, initialValue, keycode } = visibleParam;
11399
- if (eventType === DeviceInputEventType.Dblclick || eventType === DeviceInputEventType.Keyboard && keycode === KeyCode.F2) return {
11403
+ if (isFormulaString(dataStream) && (eventType === DeviceInputEventType.Dblclick || keycode === KeyCode.F2)) return null;
11404
+ if (eventType === DeviceInputEventType.Keyboard && keycode === KeyCode.F2) return {
11400
11405
  startOffset: percentOffset,
11401
11406
  endOffset: percentOffset,
11402
11407
  collapsed: true
11403
11408
  };
11404
- if (eventType !== DeviceInputEventType.Keyboard || keycode === KeyCode.BACKSPACE || keycode === KeyCode.DELETE || !/^\d/.test(initialValue ?? "")) return null;
11409
+ if (eventType !== DeviceInputEventType.Dblclick && (eventType !== DeviceInputEventType.Keyboard || keycode === KeyCode.BACKSPACE || keycode === KeyCode.DELETE || !/^\d/.test(initialValue ?? ""))) return null;
11405
11410
  return {
11406
11411
  startOffset: 0,
11407
11412
  endOffset: percentOffset,
@@ -11586,28 +11591,38 @@ let EditingRenderController = class EditingRenderController extends Disposable {
11586
11591
  */
11587
11592
  _commandExecutedListener(d) {
11588
11593
  d.add(this._commandService.beforeCommandExecuted((command) => {
11589
- var _this$_getDocumentDat;
11590
- if (command.id !== InsertTextCommand.id) return;
11591
- const params = command.params;
11594
+ var _this$_getDocumentDat, _pasteParams$doc$body, _this$_textSelectionM;
11595
+ if (command.id !== InsertTextCommand.id && command.id !== InnerPasteCommand.id) return;
11596
+ const insertParams = command.id === InsertTextCommand.id ? command.params : null;
11597
+ const pasteParams = command.id === InnerPasteCommand.id ? command.params : null;
11598
+ const unitId = (insertParams === null || insertParams === void 0 ? void 0 : insertParams.unitId) ?? (pasteParams === null || pasteParams === void 0 ? void 0 : pasteParams.unitId);
11592
11599
  const visibleParam = this._editorBridgeService.isVisible();
11593
11600
  const editCellState = this._editorBridgeService.getEditLocation();
11594
- if (params.unitId !== DOCS_NORMAL_EDITOR_UNIT_ID_KEY || !visibleParam.visible || editCellState == null) return;
11601
+ if (unitId !== DOCS_NORMAL_EDITOR_UNIT_ID_KEY || !visibleParam.visible || editCellState == null) return;
11595
11602
  const dataStream = (_this$_getDocumentDat = this._getDocumentDataModel()) === null || _this$_getDocumentDat === void 0 || (_this$_getDocumentDat = _this$_getDocumentDat.getBody()) === null || _this$_getDocumentDat === void 0 ? void 0 : _this$_getDocumentDat.dataStream;
11596
11603
  if (dataStream == null) return;
11597
11604
  const percentOffset = getPercentOffset(editCellState, dataStream);
11598
- if (percentOffset != null && !this._editorBridgeService.getEditorDirty() && visibleParam.eventType === DeviceInputEventType.Keyboard && /^\d/.test(visibleParam.initialValue ?? "") && /^\d/.test(params.body.dataStream)) {
11599
- params.range = {
11600
- startOffset: 0,
11601
- endOffset: percentOffset,
11605
+ if (percentOffset == null) return;
11606
+ if (insertParams && !this._editorBridgeService.getEditorDirty() && visibleParam.eventType === DeviceInputEventType.Keyboard && /^\d/.test(visibleParam.initialValue ?? "") && /^\d/.test(insertParams.body.dataStream)) insertParams.range = {
11607
+ startOffset: 0,
11608
+ endOffset: percentOffset + (insertParams.body.dataStream.endsWith("%") ? 1 : 0),
11609
+ collapsed: false
11610
+ };
11611
+ const selectionParams = {
11612
+ unitId,
11613
+ subUnitId: unitId
11614
+ };
11615
+ const ranges = insertParams ? [insertParams.range] : this._textSelectionManagerService.getTextRanges(selectionParams);
11616
+ const input = (insertParams === null || insertParams === void 0 ? void 0 : insertParams.body.dataStream) ?? (pasteParams === null || pasteParams === void 0 || (_pasteParams$doc$body = pasteParams.doc.body) === null || _pasteParams$doc$body === void 0 ? void 0 : _pasteParams$doc$body.dataStream);
11617
+ if (!isFormulaString(dataStream) && (input === null || input === void 0 ? void 0 : input.endsWith("%")) && (ranges === null || ranges === void 0 ? void 0 : ranges.length) === 1 && ranges[0].endOffset === percentOffset && (!pasteParams || !((_this$_textSelectionM = this._textSelectionManagerService.getRectRanges(selectionParams)) === null || _this$_textSelectionM === void 0 ? void 0 : _this$_textSelectionM.length))) {
11618
+ const range = {
11619
+ ...ranges[0],
11620
+ endOffset: percentOffset + 1,
11602
11621
  collapsed: false
11603
11622
  };
11604
- return;
11623
+ if (insertParams) insertParams.range = range;
11624
+ else if (pasteParams) pasteParams.selections = [range];
11605
11625
  }
11606
- if (percentOffset != null && params.body.dataStream === "%" && params.range.collapsed && params.range.startOffset === percentOffset && params.range.endOffset === percentOffset) params.range = {
11607
- ...params.range,
11608
- endOffset: percentOffset + 1,
11609
- collapsed: false
11610
- };
11611
11626
  }));
11612
11627
  d.add(this._commandService.onCommandExecuted((command) => {
11613
11628
  if (command.id === RichTextEditingMutation.id) {
@@ -11700,30 +11715,28 @@ let EditingRenderController = class EditingRenderController extends Disposable {
11700
11715
  else if (eventType === DeviceInputEventType.Keyboard && keycode === KeyCode.F2) {
11701
11716
  var _documentDataModel$ge2;
11702
11717
  document.makeDirty();
11703
- this._textSelectionManagerService.replaceDocRanges([{
11718
+ replaceSelection({
11704
11719
  startOffset: 0,
11705
- endOffset: 0
11706
- }]);
11720
+ endOffset: 0,
11721
+ collapsed: true
11722
+ });
11707
11723
  const endOffset = (((_documentDataModel$ge2 = documentDataModel.getBody()) === null || _documentDataModel$ge2 === void 0 ? void 0 : _documentDataModel$ge2.dataStream.length) ?? 2) - 2;
11708
- if (percentSelection) replaceSelection(percentSelection);
11709
- else this._textSelectionManagerService.replaceDocRanges([{
11724
+ replaceSelection(percentSelection ?? {
11710
11725
  startOffset: endOffset,
11711
- endOffset
11712
- }], {
11713
- unitId: DOCS_NORMAL_EDITOR_UNIT_ID_KEY,
11714
- subUnitId: DOCS_NORMAL_EDITOR_UNIT_ID_KEY
11726
+ endOffset,
11727
+ collapsed: true
11715
11728
  });
11716
11729
  } else if (eventType === DeviceInputEventType.Keyboard || eventType === DeviceInputEventType.Dblclick && isInArrayFormulaRange) {
11717
11730
  if (percentSelection) replaceSelection(percentSelection);
11718
11731
  else clearAndEdit();
11719
11732
  } else if (eventType === DeviceInputEventType.Dblclick) {
11720
11733
  if (this._contextService.getContextValue(FOCUSING_EDITOR_INPUT_FORMULA)) return;
11721
- const cursor = documentDataModel.getBody().dataStream.length - 2 || 0;
11722
- if (percentSelection) replaceSelection(percentSelection);
11723
- else this._textSelectionManagerService.replaceDocRanges([{
11724
- startOffset: cursor,
11725
- endOffset: cursor
11726
- }]);
11734
+ const endOffset = documentDataModel.getBody().dataStream.length - 2 || 0;
11735
+ replaceSelection(percentSelection ?? {
11736
+ startOffset: 0,
11737
+ endOffset,
11738
+ collapsed: endOffset === 0
11739
+ });
11727
11740
  }
11728
11741
  (_this$_renderManagerS5 = this._renderManagerService.getRenderUnitById(unitId)) === null || _this$_renderManagerS5 === void 0 || _this$_renderManagerS5.scene.resetCursor();
11729
11742
  }
@@ -19400,6 +19413,15 @@ function PasteSpacialMenuItemFactory(accessor) {
19400
19413
  hidden$: getObservableWithExclusiveRange$(accessor, getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET))
19401
19414
  };
19402
19415
  }
19416
+ const PASTE_RIBBON_MENU_ID = "sheet.menu.paste";
19417
+ function PasteRibbonMenuItemFactory(accessor) {
19418
+ return {
19419
+ ...PasteSpacialMenuItemFactory(accessor),
19420
+ id: PASTE_RIBBON_MENU_ID,
19421
+ title: "sheets-ui.rightClick.paste",
19422
+ hidden$: combineLatest([getObservableWithExclusiveRange$(accessor, getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET)), accessor.get(IContextService).subscribeContextValue$(FOCUSING_SHAPE_TEXT_EDITOR).pipe(startWith(false))]).pipe(map(([hidden, editing]) => hidden || editing))
19423
+ };
19424
+ }
19403
19425
  function PasteValueMenuItemFactory(accessor) {
19404
19426
  return {
19405
19427
  id: SheetPasteValueCommand.id,
@@ -20325,6 +20347,39 @@ function ZoomRatioMenuItemFactory(accessor) {
20325
20347
  //#region src/menu/schema.ts
20326
20348
  const menuSchema = {
20327
20349
  [RibbonPosition.START]: {
20350
+ [RibbonStartGroup.HISTORY]: { [PASTE_RIBBON_MENU_ID]: {
20351
+ order: 4,
20352
+ gridLayout: {
20353
+ row: 1,
20354
+ column: 3,
20355
+ rowSpan: 2,
20356
+ showLabel: true
20357
+ },
20358
+ menuItemFactory: PasteRibbonMenuItemFactory,
20359
+ [SheetPasteCommand.name]: {
20360
+ order: 0,
20361
+ menuItemFactory: (accessor) => ({
20362
+ ...PasteMenuItemFactory(accessor),
20363
+ icon: void 0
20364
+ })
20365
+ },
20366
+ [SheetPasteValueCommand.id]: {
20367
+ order: 1,
20368
+ menuItemFactory: PasteValueMenuItemFactory
20369
+ },
20370
+ [SheetPasteFormatCommand.id]: {
20371
+ order: 2,
20372
+ menuItemFactory: PasteFormatMenuItemFactory
20373
+ },
20374
+ [SheetPasteColWidthCommand.id]: {
20375
+ order: 3,
20376
+ menuItemFactory: PasteColWidthMenuItemFactory
20377
+ },
20378
+ [SheetPasteBesidesBorderCommand.id]: {
20379
+ order: 4,
20380
+ menuItemFactory: PasteBesidesBorderMenuItemFactory
20381
+ }
20382
+ } },
20328
20383
  [RibbonStartGroup.FORMAT]: {
20329
20384
  [SetRangeFontFamilyCommand.id]: {
20330
20385
  order: 1,
@@ -24854,7 +24909,7 @@ const useHighlightRange = (ranges = []) => {
24854
24909
  //#endregion
24855
24910
  //#region package.json
24856
24911
  var name = "@univerjs/sheets-ui";
24857
- var version = "1.0.1";
24912
+ var version = "1.0.3";
24858
24913
 
24859
24914
  //#endregion
24860
24915
  //#region src/views/cell-popup/config.ts
@@ -25481,16 +25536,20 @@ let FormatPainterController = class FormatPainterController extends Disposable {
25481
25536
  _initialize() {
25482
25537
  this._addDefaultHook();
25483
25538
  const session = this._injector.get(FormatPainterSessionService);
25539
+ let disabled = true;
25540
+ const disabled$ = this._injector.invoke(ClearSelectionFormatMenuItemFactory).disabled$;
25484
25541
  this.disposeWithMe(session.register({
25485
25542
  id: "sheet-cells",
25486
25543
  priority: 0,
25487
25544
  clear: () => this._commandService.executeCommand(ClearSelectionFormatCommand.id),
25488
- changes$: this._selectionManagerService.selectionMoveEnd$,
25545
+ changes$: disabled$.pipe(tap((value) => {
25546
+ disabled = value;
25547
+ })),
25489
25548
  isActive: () => {
25490
25549
  var _this$_univerInstance;
25491
25550
  return ((_this$_univerInstance = this._univerInstanceService.getFocusedUnit()) === null || _this$_univerInstance === void 0 ? void 0 : _this$_univerInstance.type) === UniverInstanceType.UNIVER_SHEET;
25492
25551
  },
25493
- canStart: () => !!this._selectionManagerService.getCurrentLastSelection(),
25552
+ canStart: () => !disabled && !!this._selectionManagerService.getCurrentLastSelection(),
25494
25553
  capture: () => {
25495
25554
  const workbook = this._univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET);
25496
25555
  const format = this._collectSelectionRangeFormat();