@a3s-lab/office 0.22.0 → 0.24.0

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/README.md CHANGED
@@ -123,9 +123,9 @@ baseline rather than one specific release.
123
123
 
124
124
  | Capability | A3S Office today | Traditional Office baseline |
125
125
  | --- | --- | --- |
126
- | Cells, sheets, navigation, and history | **Supported** — multiple sheets, sparse editing, search, clipboard, fill, and undo/redo | Mature grid workflows across desktop and web |
127
- | Formatting and style rendering | **Partial** — native fonts, colors, borders, alignment, number formats, cell styles, and static date/time entry | Broader themes, locale formats, rich text, and advanced style effects |
128
- | Ribbon and shortcuts | **Partial** — common Office-style Home/Data/View commands and grid-scoped shortcuts | Larger command catalog and platform-specific accelerators |
126
+ | Cells, sheets, navigation, and history | **Supported** — multiple sheets, sparse editing, search, clipboard, four-direction fill, exact formula/value copy from above, and undo/redo | Mature grid workflows across desktop and web |
127
+ | Formatting and style rendering | **Partial** — native fonts, colors, borders, alignment, number formats, cell styles, static date/time entry, and contrast-safe font preview | Broader themes, locale formats, rich text, and advanced style effects |
128
+ | Ribbon and shortcuts | **Partial** — common Office-style Home/Data/View commands, grid-scoped shortcuts, and focused Font-dialog aliases | Larger command catalog and platform-specific accelerators |
129
129
  | Formulas and recalculation | **Partial** — dependency-aware calculation and common formula paths | Wider functions, arrays, volatile semantics, and calculation parity |
130
130
  | Tables, pivots, charts, and rules | **Partial** — native tables, pivots, charts, conditional formatting, and validation | Calculated columns, slicers, pivot charts, advanced rules, and analysis |
131
131
  | Large worksheets | **Supported with boundaries** — maximum-dimension sparse import/editing and viewport-bounded Canvas painting | Highly optimized native grid with hardware-dependent limits |
@@ -1347,6 +1347,8 @@ without hard-coded return URLs.
1347
1347
 
1348
1348
  - [Live Playground](https://a3s-lab.github.io/Office/)
1349
1349
  - [Documentation center](https://a3s-lab.github.io/Office/docs/)
1350
+ - [A3S Office 0.24.0 documentation](https://a3s-lab.github.io/Office/docs/0.24.0/)
1351
+ - [A3S Office 0.23.0 documentation](https://a3s-lab.github.io/Office/docs/0.23.0/)
1350
1352
  - [A3S Office 0.22.0 documentation](https://a3s-lab.github.io/Office/docs/0.22.0/)
1351
1353
  - [A3S Office 0.21.0 documentation](https://a3s-lab.github.io/Office/docs/0.21.0/)
1352
1354
  - [A3S Office 0.20.0 documentation](https://a3s-lab.github.io/Office/docs/0.20.0/)
package/dist/0~4595.js CHANGED
@@ -343,7 +343,7 @@ function Dialog({ title, description, children, footer, onClose, closeDisabled =
343
343
  });
344
344
  return "u" > typeof document && portalRootRef.current ? /*#__PURE__*/ createPortal(dialog, portalRootRef.current) : dialog;
345
345
  }
346
- function OfficeSelect({ ariaLabel, value, options, onValueChange, disabled = false, placeholder = '请选择', className = '' }) {
346
+ function OfficeSelect({ ariaLabel, value, options, onValueChange, disabled = false, placeholder = '请选择', className = '', ariaKeyShortcuts, initialFocus = false }) {
347
347
  const reactId = useId().replaceAll(':', '');
348
348
  const [open, setOpen] = useState(false);
349
349
  const selectedIndex = useMemo(()=>options.findIndex((option)=>option.value === value), [
@@ -384,6 +384,8 @@ function OfficeSelect({ ariaLabel, value, options, onValueChange, disabled = fal
384
384
  ...triggerProps,
385
385
  role: "combobox",
386
386
  "aria-expanded": popoverOpen,
387
+ "aria-keyshortcuts": ariaKeyShortcuts,
388
+ "data-autofocus": initialFocus ? 'true' : void 0,
387
389
  onClick: (event)=>{
388
390
  if (!popoverOpen) {
389
391
  const next = nearestEnabledOption(options, selectedIndex >= 0 ? selectedIndex : 0, 1);
package/dist/0~6090.js CHANGED
@@ -258,6 +258,7 @@ function shortcutCodeKey(code) {
258
258
  if ('Equal' === code) return 'equal';
259
259
  if ('Minus' === code) return 'minus';
260
260
  if ('Semicolon' === code) return ';';
261
+ if ('Quote' === code) return "'";
261
262
  if ('Comma' === code) return ',';
262
263
  if ('Period' === code) return '.';
263
264
  return null;
@@ -5,7 +5,7 @@ import { AArrowDown, AArrowUp, AlignCenter, AlignLeft, AlignRight, AlignVertical
5
5
  import { Fragment as external_react_Fragment, cloneElement, memo, useCallback, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
6
6
  import { genarate, indexToColumnChar, update as core_update } from "@fortune-sheet/core";
7
7
  import { freezeImportedSpreadsheetCell, spreadsheetTextOrientationFromChoice, spreadsheetMatrixProfile, withoutEditableRange, spreadsheetTextOrientationFromAngle, isSpreadsheetTextOrientationId, normalizeSpreadsheetConditionalVisualOptions, spreadsheetCellValueWithDiagonalBorder, spreadsheetUnderlineCellValue, effectiveSpreadsheetPageSetup, attachSpreadsheetShownCommentCells, withEditableRange, sameSpreadsheetHistoryValue, createOfficeSpreadsheetCollaborationBinding as createWorkOfficeSpreadsheetCollaborationBinding, isSpreadsheetConditionalComparisonOperator, spreadsheetConditionalIconForValue, defaultSpreadsheetConditionalIconThresholds, spreadsheetUnderlineStyle, normalizeSpreadsheetDateValidationBoundary, sheetProtectionAuthority, editableRangeCellCount, unlockedCellCount, registerDerivedSpreadsheetMatrix, editableRangeRequiresCredentials, spreadsheetTextOrientationCellStyle, normalizeSpreadsheetConditionalIconSetFormat, defaultSpreadsheetDataBarOptions, spreadsheetConditionalThresholdValue, spreadsheetTextOrientationChoiceFromCell, normalizeSheetProtectionAuthority, withSheetProtection, defaultSpreadsheetColorScaleThresholds, spreadsheetProtectionKey, spreadsheetDiagonalBorderFromCellValue, SPREADSHEET_CONDITIONAL_ICON_SETS, protectedSheetCount, withSheetSelectionPermissions, SPREADSHEET_CONDITIONAL_COMPARISON_OPERATORS, spreadsheetConditionalComparisonNeedsUpperValue, drawSpreadsheetConditionalIcon, spreadsheetTextOrientationFromCell, replaceOfficeSpreadsheetCollaboration as replaceWorkOfficeSpreadsheetCollaboration, readOfficeSpreadsheetCollaboration as readWorkOfficeSpreadsheetCollaboration, spreadsheetConditionalThresholdsEqual, isSpreadsheetUnderlineStyle, spreadsheetVisibleTextRotationFromCell } from "./5045.js";
8
- import { workSpreadsheetChartSupportsGrouping, createSpreadsheetChartFromSelection, normalizeWorkSpreadsheetDataLabelPosition, normalizeSpreadsheetPrintTitleColumns, normalizeSpreadsheetPrintTitleRows, formulaHasStructuredReference, normalizeWorkSpreadsheetErrorBars, defaultPivotValueCaption, workSpreadsheetChartSupportsBarSpacing, normalizeWorkSpreadsheetChartGrouping, spreadsheetGridSize, normalizeWorkSpreadsheetChartAxisGroup, normalizeWorkSpreadsheetScatterStyle, cloneSparseMatrix, spreadsheetPivotAggregationLabel, workSpreadsheetChartAxisIsCategoryAxis, reconcileSpreadsheetChartPreviews, normalizeWorkSpreadsheetChartAxes, normalizeWorkSpreadsheetDoughnutHoleSize, normalizeWorkSpreadsheetChartLegendPosition, spreadsheetChartCount, workSpreadsheetChartTypeLabel, sparseArrayEntries, normalizeWorkSpreadsheetTrendline, effectiveSpreadsheetCalculationSettings, spreadsheetPivotIntersects, normalizeWorkSpreadsheetDataLabels, spreadsheetPivotOutputContains, normalizeSpreadsheetPrintArea, spreadsheetCellAddress, formatSpreadsheetCellRanges, normalizeWorkSpreadsheetChartLayout, spreadsheetFormulaRangeForCell, workSpreadsheetChartAxisIsValueAxis, normalizeWorkSpreadsheetChartSmoothLines, spreadsheetPivotFilterValueKey, normalizeWorkSpreadsheetBubbleScale, normalizeWorkSpreadsheetChartSeriesStyle, volatileSpreadsheetFormulaFunctions, sparseArrayIndexes, normalizeWorkSpreadsheetBubbleSizeRepresents, workSpreadsheetChartSupportsTrendlines, normalizeWorkSpreadsheetChartLegendOverlay, parseSpreadsheetChartReference, workSpreadsheetChartGroupingIsStacked, normalizeWorkSpreadsheetChartGapWidth, workSpreadsheetChartSupportsSmoothLines, refreshSpreadsheetPivotTables, createSpreadsheetPivotFromSelection, reconcileSpreadsheetPivots, spreadsheetPivotCount, sparseMatrixColumnCount, workSpreadsheetChartSupportsErrorBars, formulaHasExternalReference, isValidSpreadsheetDefinedName, spreadsheetPivotValidation, deleteSpreadsheetPivotTable, workSpreadsheetChartAxisDefaultLabelPosition, workSpreadsheetChartSupportsSeriesAnalysis, parseSpreadsheetCellRanges, spreadsheetPivotFilterItems, spreadsheetPivotFields, normalizeWorkSpreadsheetChartOverlap, spreadsheetFormulaRangeConflict, spreadsheetSheetsWithChartPreviews, workSpreadsheetChartUsesNumericXAxis, workSpreadsheetChartAxisShowsMajorGridlinesByDefault, workSpreadsheetChartSupportsAxes, normalizeWorkSpreadsheetCombinationSeriesType, normalizeWorkSpreadsheetRadarStyle } from "./8715.js";
8
+ import { workSpreadsheetChartSupportsGrouping, spreadsheetFormulaRangesForSelection, createSpreadsheetChartFromSelection, normalizeWorkSpreadsheetDataLabelPosition, normalizeSpreadsheetPrintTitleColumns, normalizeSpreadsheetPrintTitleRows, formulaHasStructuredReference, normalizeWorkSpreadsheetErrorBars, defaultPivotValueCaption, workSpreadsheetChartSupportsBarSpacing, normalizeWorkSpreadsheetChartGrouping, spreadsheetGridSize, normalizeWorkSpreadsheetChartAxisGroup, normalizeWorkSpreadsheetScatterStyle, cloneSparseMatrix, spreadsheetPivotAggregationLabel, workSpreadsheetChartAxisIsCategoryAxis, reconcileSpreadsheetChartPreviews, normalizeWorkSpreadsheetChartAxes, normalizeWorkSpreadsheetDoughnutHoleSize, normalizeWorkSpreadsheetChartLegendPosition, spreadsheetChartCount, workSpreadsheetChartTypeLabel, sparseArrayEntries, normalizeWorkSpreadsheetTrendline, effectiveSpreadsheetCalculationSettings, spreadsheetPivotIntersects, normalizeWorkSpreadsheetDataLabels, spreadsheetPivotOutputContains, normalizeSpreadsheetPrintArea, spreadsheetCellAddress, formatSpreadsheetCellRanges, normalizeWorkSpreadsheetChartLayout, spreadsheetFormulaRangeForCell, workSpreadsheetChartAxisIsValueAxis, normalizeWorkSpreadsheetChartSmoothLines, spreadsheetPivotFilterValueKey, normalizeWorkSpreadsheetBubbleScale, normalizeWorkSpreadsheetChartSeriesStyle, volatileSpreadsheetFormulaFunctions, sparseArrayIndexes, normalizeWorkSpreadsheetBubbleSizeRepresents, workSpreadsheetChartSupportsTrendlines, normalizeWorkSpreadsheetChartLegendOverlay, parseSpreadsheetChartReference, workSpreadsheetChartGroupingIsStacked, normalizeWorkSpreadsheetChartGapWidth, workSpreadsheetChartSupportsSmoothLines, refreshSpreadsheetPivotTables, createSpreadsheetPivotFromSelection, reconcileSpreadsheetPivots, spreadsheetPivotCount, sparseMatrixColumnCount, workSpreadsheetChartSupportsErrorBars, formulaHasExternalReference, isValidSpreadsheetDefinedName, spreadsheetPivotValidation, deleteSpreadsheetPivotTable, workSpreadsheetChartAxisDefaultLabelPosition, workSpreadsheetChartSupportsSeriesAnalysis, parseSpreadsheetCellRanges, spreadsheetPivotFilterItems, spreadsheetPivotFields, normalizeWorkSpreadsheetChartOverlap, spreadsheetFormulaRangeConflict, spreadsheetSheetsWithChartPreviews, workSpreadsheetChartUsesNumericXAxis, workSpreadsheetChartAxisShowsMajorGridlinesByDefault, workSpreadsheetChartSupportsAxes, normalizeWorkSpreadsheetCombinationSeriesType, normalizeWorkSpreadsheetRadarStyle } from "./8715.js";
9
9
  import { moveOfficeMenuFocus, stepOfficeZoom, useOfficeRemoteParticipants, Popover, officePresenceColor, useOfficePublishPresenceLocation, button_Button, icon_button_IconButton, moveOfficeGridMenuFocus, office_text_field_OfficeTextField, useDialogFocusScope, useOfficeEditorWheelZoom } from "./0~6090.js";
10
10
  import { useOfficeTaskPaneEscape, OfficeCheckbox, CommittedOfficeNumberField, useOfficeDialog, useOfficeTaskPaneModal, createOfficeKernelClient, officeFontFamilies, CollectionState, OfficeNumberField, handleOfficeTaskPaneKeyDown } from "./0~7048.js";
11
11
  import { isOfficeShortcutBlocked, OfficeColorPicker } from "./0~3635.js";
@@ -3284,6 +3284,38 @@ const spreadsheetCommandCatalog = {
3284
3284
  ]
3285
3285
  }
3286
3286
  },
3287
+ formatCellsFont: {
3288
+ id: 'font.formatCellsFont',
3289
+ label: '设置字体格式',
3290
+ location: {
3291
+ area: 'ribbon',
3292
+ tab: 'home',
3293
+ group: 'font'
3294
+ },
3295
+ shortcut: {
3296
+ label: 'Cmd/Ctrl+Shift+F',
3297
+ aria: 'Control+Shift+F Meta+Shift+F',
3298
+ editor: [
3299
+ 'Mod-Shift-f'
3300
+ ]
3301
+ }
3302
+ },
3303
+ formatCellsFontSize: {
3304
+ id: 'font.formatCellsFontSize',
3305
+ label: '设置字号格式',
3306
+ location: {
3307
+ area: 'ribbon',
3308
+ tab: 'home',
3309
+ group: 'font'
3310
+ },
3311
+ shortcut: {
3312
+ label: 'Cmd/Ctrl+Shift+P',
3313
+ aria: 'Control+Shift+P Meta+Shift+P',
3314
+ editor: [
3315
+ 'Mod-Shift-p'
3316
+ ]
3317
+ }
3318
+ },
3287
3319
  borderTop: {
3288
3320
  id: 'font.borderTop',
3289
3321
  label: '上框线',
@@ -3752,6 +3784,38 @@ const spreadsheetCommandCatalog = {
3752
3784
  group: 'editing'
3753
3785
  }
3754
3786
  },
3787
+ copyFormulaFromAbove: {
3788
+ id: 'editing.copyFormulaFromAbove',
3789
+ label: '复制上方公式',
3790
+ location: {
3791
+ area: 'ribbon',
3792
+ tab: 'home',
3793
+ group: 'editing'
3794
+ },
3795
+ shortcut: {
3796
+ label: "Ctrl+'",
3797
+ aria: "Control+'",
3798
+ editor: [
3799
+ "Control-'"
3800
+ ]
3801
+ }
3802
+ },
3803
+ copyValueFromAbove: {
3804
+ id: 'editing.copyValueFromAbove',
3805
+ label: '复制上方值',
3806
+ location: {
3807
+ area: 'ribbon',
3808
+ tab: 'home',
3809
+ group: 'editing'
3810
+ },
3811
+ shortcut: {
3812
+ label: "Ctrl+Shift+'",
3813
+ aria: "Control+Shift+'",
3814
+ editor: [
3815
+ "Control-Shift-'"
3816
+ ]
3817
+ }
3818
+ },
3755
3819
  clearAll: {
3756
3820
  id: 'editing.clearAll',
3757
3821
  label: '清除全部',
@@ -4720,6 +4784,56 @@ function normalizeColor(value) {
4720
4784
  function spreadsheet_cell_format_cellKey(row, column) {
4721
4785
  return `${row}:${column}`;
4722
4786
  }
4787
+ const spreadsheetFormatCellsTabs = [
4788
+ {
4789
+ id: 'number',
4790
+ label: '数字'
4791
+ },
4792
+ {
4793
+ id: 'alignment',
4794
+ label: '对齐'
4795
+ },
4796
+ {
4797
+ id: 'font',
4798
+ label: '字体'
4799
+ },
4800
+ {
4801
+ id: 'border',
4802
+ label: '边框'
4803
+ },
4804
+ {
4805
+ id: 'fill',
4806
+ label: '填充'
4807
+ },
4808
+ {
4809
+ id: 'protection',
4810
+ label: '保护'
4811
+ }
4812
+ ];
4813
+ const defaultSpreadsheetFormatCellsOpenIntent = {
4814
+ tab: 'number'
4815
+ };
4816
+ const spreadsheetFormatCellsTabIds = new Set(spreadsheetFormatCellsTabs.map(({ id })=>id));
4817
+ function normalizeSpreadsheetFormatCellsOpenIntent(value) {
4818
+ if (void 0 === value) return defaultSpreadsheetFormatCellsOpenIntent;
4819
+ if (!spreadsheet_format_cells_intent_isRecord(value)) return null;
4820
+ const keys = Object.keys(value);
4821
+ if (keys.some((key)=>'tab' !== key && 'focus' !== key)) return null;
4822
+ if ('string' != typeof value.tab || !spreadsheetFormatCellsTabIds.has(value.tab)) return null;
4823
+ if ('font' !== value.tab) return void 0 === value.focus ? {
4824
+ tab: value.tab
4825
+ } : null;
4826
+ if (void 0 === value.focus) return {
4827
+ tab: 'font'
4828
+ };
4829
+ return 'fontFamily' === value.focus || 'fontSize' === value.focus ? {
4830
+ tab: 'font',
4831
+ focus: value.focus
4832
+ } : null;
4833
+ }
4834
+ function spreadsheet_format_cells_intent_isRecord(value) {
4835
+ return Boolean(value && 'object' == typeof value && !Array.isArray(value));
4836
+ }
4723
4837
  function createSpreadsheetCellFormatExtension() {
4724
4838
  return createOfficeEditorExtension({
4725
4839
  name: 'spreadsheetCellFormat',
@@ -4734,17 +4848,27 @@ function createSpreadsheetCellFormatExtension() {
4734
4848
  }
4735
4849
  }),
4736
4850
  addKeyboardShortcuts: ()=>({
4737
- 'Mod-1': ({ can, commands }, event)=>runSpreadsheetFormatCellsShortcut(event, can.openFormatCells, commands.openFormatCells)
4851
+ [spreadsheetCommandCatalog.formatCells.shortcut.editor["0"]]: ({ can, commands }, event)=>runSpreadsheetFormatCellsShortcut(event, void 0, can.openFormatCells, commands.openFormatCells),
4852
+ [spreadsheetCommandCatalog.formatCellsFont.shortcut.editor["0"]]: ({ can, commands }, event)=>runSpreadsheetFormatCellsShortcut(event, {
4853
+ tab: 'font',
4854
+ focus: 'fontFamily'
4855
+ }, can.openFormatCells, commands.openFormatCells),
4856
+ [spreadsheetCommandCatalog.formatCellsFontSize.shortcut.editor["0"]]: ({ can, commands }, event)=>runSpreadsheetFormatCellsShortcut(event, {
4857
+ tab: 'font',
4858
+ focus: 'fontSize'
4859
+ }, can.openFormatCells, commands.openFormatCells)
4738
4860
  })
4739
4861
  });
4740
4862
  }
4741
- function canOpenSpreadsheetFormatCells(context) {
4863
+ function canOpenSpreadsheetFormatCells(context, intent) {
4864
+ if (!normalizeSpreadsheetFormatCellsOpenIntent(intent)) return false;
4742
4865
  if (!context.editable || !context.formatCells.canOpen || !context.workbook || !context.targetSheetId || context.targetSheetId !== context.activeSheetId) return false;
4743
4866
  const range = liveSpreadsheetFormatCellsRange(context);
4744
4867
  return Boolean(range && spreadsheet_cell_range_spreadsheetCellRangeArea(range) <= 10000);
4745
4868
  }
4746
- function spreadsheet_cell_format_command_openSpreadsheetFormatCells(context) {
4747
- if (!canOpenSpreadsheetFormatCells(context) || !context.workbook) return false;
4869
+ function spreadsheet_cell_format_command_openSpreadsheetFormatCells(context, intent) {
4870
+ const normalizedIntent = normalizeSpreadsheetFormatCellsOpenIntent(intent);
4871
+ if (!normalizedIntent || !canOpenSpreadsheetFormatCells(context, normalizedIntent) || !context.workbook) return false;
4748
4872
  const selection = context.workbook.getSelection()?.at(-1) ?? context.fallbackRange;
4749
4873
  const range = spreadsheet_cell_range_normalizeSpreadsheetCellRange(spreadsheetSingleRange(selection));
4750
4874
  if (!range) return false;
@@ -4755,7 +4879,8 @@ function spreadsheet_cell_format_command_openSpreadsheetFormatCells(context) {
4755
4879
  row: clampFocus(selection.row_focus, range.row),
4756
4880
  column: clampFocus(selection.column_focus, range.column)
4757
4881
  },
4758
- cells: []
4882
+ cells: [],
4883
+ intent: normalizedIntent
4759
4884
  };
4760
4885
  try {
4761
4886
  request.cells = context.workbook.getCellsByRange(range, {
@@ -4776,9 +4901,9 @@ function applySpreadsheetFormatCells(context, request) {
4776
4901
  function liveSpreadsheetFormatCellsRange(context) {
4777
4902
  return spreadsheet_cell_range_normalizeSpreadsheetCellRange(spreadsheetSingleRange(context.workbook?.getSelection()?.at(-1) ?? context.fallbackRange));
4778
4903
  }
4779
- function runSpreadsheetFormatCellsShortcut(event, canExecute, execute) {
4780
- if (event.repeat || isOfficeShortcutBlocked(event.target) || isSpreadsheetNativeTextUndoTarget(event.target) || !canExecute()) return false;
4781
- return execute();
4904
+ function runSpreadsheetFormatCellsShortcut(event, intent, canExecute, execute) {
4905
+ if (event.repeat || event.isComposing || isOfficeShortcutBlocked(event.target) || isSpreadsheetNativeTextUndoTarget(event.target) || !canExecute(intent)) return false;
4906
+ return execute(intent);
4782
4907
  }
4783
4908
  function clampFocus(value, range) {
4784
4909
  const minimum = range[0] ?? 0;
@@ -5223,6 +5348,213 @@ function spreadsheetSelectedCellFillPlan(context, direction) {
5223
5348
  const sheet = context.content.sheets.find((candidate)=>candidate.id === context.targetSheetId);
5224
5349
  return canApplySpreadsheetCellFill(sheet, plan) ? plan : null;
5225
5350
  }
5351
+ const MAX_SPREADSHEET_ROWS = 1048576;
5352
+ const spreadsheetPasteContentOptions = [
5353
+ {
5354
+ value: 'all',
5355
+ label: '全部',
5356
+ richOnly: false
5357
+ },
5358
+ {
5359
+ value: 'formulas',
5360
+ label: '公式',
5361
+ richOnly: false
5362
+ },
5363
+ {
5364
+ value: 'values',
5365
+ label: '值',
5366
+ richOnly: false
5367
+ },
5368
+ {
5369
+ value: 'formats',
5370
+ label: '格式',
5371
+ richOnly: true
5372
+ },
5373
+ {
5374
+ value: 'comments',
5375
+ label: '批注',
5376
+ richOnly: true
5377
+ },
5378
+ {
5379
+ value: 'validation',
5380
+ label: '数据验证',
5381
+ richOnly: true
5382
+ },
5383
+ {
5384
+ value: 'all-except-borders',
5385
+ label: '边框除外的全部',
5386
+ richOnly: true
5387
+ },
5388
+ {
5389
+ value: 'formulas-and-number-formats',
5390
+ label: '公式和数字格式',
5391
+ richOnly: true
5392
+ },
5393
+ {
5394
+ value: 'values-and-number-formats',
5395
+ label: '值和数字格式',
5396
+ richOnly: true
5397
+ },
5398
+ {
5399
+ value: 'column-widths',
5400
+ label: '列宽',
5401
+ richOnly: true
5402
+ }
5403
+ ];
5404
+ const spreadsheetPasteOperationOptions = [
5405
+ {
5406
+ value: 'none',
5407
+ label: '无'
5408
+ },
5409
+ {
5410
+ value: 'add',
5411
+ label: '加'
5412
+ },
5413
+ {
5414
+ value: 'subtract',
5415
+ label: '减'
5416
+ },
5417
+ {
5418
+ value: 'multiply',
5419
+ label: '乘'
5420
+ },
5421
+ {
5422
+ value: 'divide',
5423
+ label: '除'
5424
+ }
5425
+ ];
5426
+ function planSpreadsheetCopyFromAbove(sheet, target, kind) {
5427
+ if (!sheet || !isSpreadsheetCopyFromAboveKind(kind) || !spreadsheetCellCoordinateIsSupported(target.row, target.column) || 0 === target.row) return null;
5428
+ const targetRange = {
5429
+ row: [
5430
+ target.row,
5431
+ target.row
5432
+ ],
5433
+ column: [
5434
+ target.column,
5435
+ target.column
5436
+ ]
5437
+ };
5438
+ if (!canMutateSpreadsheetCellRange(sheet, targetRange)) return null;
5439
+ const source = {
5440
+ row: target.row - 1,
5441
+ column: target.column
5442
+ };
5443
+ const sourceCell = spreadsheetCopyFromAboveCellAt(sheet, source.row, source.column);
5444
+ const targetCell = spreadsheetCopyFromAboveCellAt(sheet, target.row, target.column);
5445
+ const formula = spreadsheetCopyableFormula(sheet, sourceCell, source.row, source.column);
5446
+ if ('formula' === kind && sourceCell?.f && null === formula) return null;
5447
+ const copiesFormula = 'formula' === kind && null !== formula;
5448
+ const value = copiesFormula ? formula : spreadsheetCopyFromAboveCellValue(sourceCell);
5449
+ if (copiesFormula ? targetCell?.f === value : !targetCell?.f && Object.is(spreadsheetCopyFromAboveCellValue(targetCell), value)) return null;
5450
+ return {
5451
+ formulaBarValue: value ?? '',
5452
+ kind,
5453
+ source,
5454
+ targetRange,
5455
+ value
5456
+ };
5457
+ }
5458
+ function spreadsheetCopyableFormula(sheet, cell, row, column) {
5459
+ if ('string' != typeof cell?.f || !cell.f.trim()) return null;
5460
+ const formula = cell.f.trim();
5461
+ if (!formula.startsWith('=') || formulaHasExternalReference(formula) || void 0 !== cell.spl || spreadsheetFormulaRangesForSelection(sheet, {
5462
+ startRow: row,
5463
+ endRow: row,
5464
+ startColumn: column,
5465
+ endColumn: column
5466
+ }).length > 0) return null;
5467
+ return formula;
5468
+ }
5469
+ function spreadsheetCopyFromAboveCellValue(cell) {
5470
+ if (cell?.v !== void 0 && null !== cell.v) return cell.v;
5471
+ const inlineText = spreadsheet_copy_from_above_spreadsheetInlineCellText(cell);
5472
+ if (null !== inlineText) return inlineText;
5473
+ if (cell?.m !== void 0 && null !== cell.m) return cell.m;
5474
+ return null;
5475
+ }
5476
+ function spreadsheet_copy_from_above_spreadsheetInlineCellText(cell) {
5477
+ const format = cell?.ct;
5478
+ if (format?.t !== 'inlineStr' || !Array.isArray(format.s)) return null;
5479
+ return format.s.map((run)=>spreadsheet_copy_from_above_isRecord(run) && ('string' == typeof run.v || 'number' == typeof run.v) ? String(run.v) : '').join('');
5480
+ }
5481
+ function spreadsheetCopyFromAboveCellAt(sheet, row, column) {
5482
+ if (void 0 !== sheet.data) return sheet.data[row]?.[column];
5483
+ return sheet.celldata?.find((entry)=>entry.r === row && entry.c === column)?.v;
5484
+ }
5485
+ function spreadsheetCellCoordinateIsSupported(row, column) {
5486
+ return Number.isSafeInteger(row) && row >= 0 && row < MAX_SPREADSHEET_ROWS && Number.isSafeInteger(column) && column >= 0 && column < 16384;
5487
+ }
5488
+ function isSpreadsheetCopyFromAboveKind(value) {
5489
+ return 'formula' === value || 'value' === value;
5490
+ }
5491
+ function spreadsheet_copy_from_above_isRecord(value) {
5492
+ return Boolean(value && 'object' == typeof value && !Array.isArray(value));
5493
+ }
5494
+ function createSpreadsheetCopyFromAboveExtension() {
5495
+ return createOfficeEditorExtension({
5496
+ name: 'spreadsheetCopyFromAbove',
5497
+ addCommands: ()=>({
5498
+ copyCellFromAbove: {
5499
+ canExecute: (context, kind)=>null !== spreadsheetSelectedCopyFromAbovePlan(context, kind),
5500
+ execute: copySpreadsheetCellFromAbove
5501
+ }
5502
+ }),
5503
+ addKeyboardShortcuts: ()=>({
5504
+ [spreadsheetCommandCatalog.copyFormulaFromAbove.shortcut.editor["0"]]: ({ can, commands }, event)=>runSpreadsheetCopyFromAboveShortcut(event, 'formula', can.copyCellFromAbove, commands.copyCellFromAbove),
5505
+ [spreadsheetCommandCatalog.copyValueFromAbove.shortcut.editor["0"]]: ({ can, commands }, event)=>runSpreadsheetCopyFromAboveShortcut(event, 'value', can.copyCellFromAbove, commands.copyCellFromAbove)
5506
+ })
5507
+ });
5508
+ }
5509
+ function copySpreadsheetCellFromAbove(context, kind) {
5510
+ const plan = spreadsheetSelectedCopyFromAbovePlan(context, kind);
5511
+ if (!plan || !context.workbook || !context.targetSheetId) return false;
5512
+ try {
5513
+ context.workbook.batchCallApis([
5514
+ {
5515
+ name: 'setCellValuesByRange',
5516
+ args: [
5517
+ [
5518
+ [
5519
+ plan.value
5520
+ ]
5521
+ ],
5522
+ plan.targetRange,
5523
+ {
5524
+ id: context.targetSheetId
5525
+ }
5526
+ ]
5527
+ }
5528
+ ]);
5529
+ } catch {
5530
+ return false;
5531
+ }
5532
+ try {
5533
+ context.formulaBar?.setValue(plan.formulaBarValue);
5534
+ } catch {}
5535
+ return true;
5536
+ }
5537
+ function spreadsheetSelectedCopyFromAbovePlan(context, kind) {
5538
+ const workbook = context.workbook;
5539
+ const sheetId = context.targetSheetId;
5540
+ if (!context.editable || !workbook || !sheetId || sheetId !== context.activeSheetId) return null;
5541
+ try {
5542
+ const selection = finiteSpreadsheetSelection(workbook.getSelection()?.at(-1) ?? context.fallbackRange);
5543
+ const row = selection.row_focus ?? selection.row[0] ?? 0;
5544
+ const column = selection.column_focus ?? selection.column[0] ?? 0;
5545
+ const sheet = context.content.sheets.find((candidate)=>candidate.id === sheetId);
5546
+ return planSpreadsheetCopyFromAbove(sheet, {
5547
+ row,
5548
+ column
5549
+ }, kind);
5550
+ } catch {
5551
+ return null;
5552
+ }
5553
+ }
5554
+ function runSpreadsheetCopyFromAboveShortcut(event, kind, canExecute, execute) {
5555
+ if (event.repeat || event.isComposing || isOfficeShortcutBlocked(event.target) || isSpreadsheetNativeTextUndoTarget(event.target) || !isSpreadsheetGridKeyboardTarget(event.target) || !canExecute(kind)) return false;
5556
+ return execute(kind);
5557
+ }
5226
5558
  function canEditSpreadsheetSelection(context) {
5227
5559
  return Boolean(context.editable && context.workbook && context.targetSheetId);
5228
5560
  }
@@ -6068,81 +6400,6 @@ function clampSpreadsheetDataValidationFocus(value, range) {
6068
6400
  const focus = 'number' == typeof value && Number.isFinite(value) ? Math.trunc(value) : minimum;
6069
6401
  return Math.min(maximum, Math.max(minimum, focus));
6070
6402
  }
6071
- const MAX_SPREADSHEET_ROWS = 1048576;
6072
- const spreadsheetPasteContentOptions = [
6073
- {
6074
- value: 'all',
6075
- label: '全部',
6076
- richOnly: false
6077
- },
6078
- {
6079
- value: 'formulas',
6080
- label: '公式',
6081
- richOnly: false
6082
- },
6083
- {
6084
- value: 'values',
6085
- label: '值',
6086
- richOnly: false
6087
- },
6088
- {
6089
- value: 'formats',
6090
- label: '格式',
6091
- richOnly: true
6092
- },
6093
- {
6094
- value: 'comments',
6095
- label: '批注',
6096
- richOnly: true
6097
- },
6098
- {
6099
- value: 'validation',
6100
- label: '数据验证',
6101
- richOnly: true
6102
- },
6103
- {
6104
- value: 'all-except-borders',
6105
- label: '边框除外的全部',
6106
- richOnly: true
6107
- },
6108
- {
6109
- value: 'formulas-and-number-formats',
6110
- label: '公式和数字格式',
6111
- richOnly: true
6112
- },
6113
- {
6114
- value: 'values-and-number-formats',
6115
- label: '值和数字格式',
6116
- richOnly: true
6117
- },
6118
- {
6119
- value: 'column-widths',
6120
- label: '列宽',
6121
- richOnly: true
6122
- }
6123
- ];
6124
- const spreadsheetPasteOperationOptions = [
6125
- {
6126
- value: 'none',
6127
- label: '无'
6128
- },
6129
- {
6130
- value: 'add',
6131
- label: '加'
6132
- },
6133
- {
6134
- value: 'subtract',
6135
- label: '减'
6136
- },
6137
- {
6138
- value: 'multiply',
6139
- label: '乘'
6140
- },
6141
- {
6142
- value: 'divide',
6143
- label: '除'
6144
- }
6145
- ];
6146
6403
  const MILLISECONDS_PER_DAY = 86400000;
6147
6404
  const MINUTES_PER_DAY = 1440;
6148
6405
  const EXCEL_1900_EPOCH_UTC = Date.UTC(1899, 11, 30);
@@ -8608,6 +8865,7 @@ function createSpreadsheetEditorExtensions() {
8608
8865
  createSpreadsheetTableExtension(),
8609
8866
  createSpreadsheetAutoSumExtension(),
8610
8867
  createSpreadsheetCellFillExtension(),
8868
+ createSpreadsheetCopyFromAboveExtension(),
8611
8869
  createSpreadsheetVisibilityShortcutExtension(),
8612
8870
  createOfficeEditorExtension({
8613
8871
  name: 'spreadsheetFormatPainter',
@@ -13438,7 +13696,7 @@ function AlignmentPanel({ source, draft, errors, touched, setDraft, touch }) {
13438
13696
  ]
13439
13697
  });
13440
13698
  }
13441
- function FontPanel({ source, draft, errors, touched, setDraft, touch }) {
13699
+ function FontPanel({ source, draft, errors, touched, initialFocus, setDraft, touch }) {
13442
13700
  const familyMixed = source.fields.fontFamily.mixed && !touched.fontFamily;
13443
13701
  const sizeMixed = source.fields.fontSize.mixed && !touched.fontSize;
13444
13702
  const underlineMixed = source.fields.underline.mixed && !touched.underline;
@@ -13456,6 +13714,8 @@ function FontPanel({ source, draft, errors, touched, setDraft, touch }) {
13456
13714
  label: "字体",
13457
13715
  children: /*#__PURE__*/ jsx(OfficeSelect, {
13458
13716
  ariaLabel: "单元格字体",
13717
+ ariaKeyShortcuts: spreadsheetCommandCatalog.formatCellsFont.shortcut.aria,
13718
+ initialFocus: 'fontFamily' === initialFocus,
13459
13719
  value: familyMixed ? MIXED_VALUE : draft.fontFamily,
13460
13720
  options: withMixedOption(spreadsheetFontFamilyOptions(draft.fontFamily), familyMixed),
13461
13721
  onValueChange: (value)=>{
@@ -13472,6 +13732,8 @@ function FontPanel({ source, draft, errors, touched, setDraft, touch }) {
13472
13732
  label: "字号",
13473
13733
  children: /*#__PURE__*/ jsx(OfficeSelect, {
13474
13734
  ariaLabel: "单元格字号",
13735
+ ariaKeyShortcuts: spreadsheetCommandCatalog.formatCellsFontSize.shortcut.aria,
13736
+ initialFocus: 'fontSize' === initialFocus,
13475
13737
  value: sizeMixed ? MIXED_VALUE : String(draft.fontSize),
13476
13738
  options: withMixedOption(spreadsheetFontSizeOptions(draft.fontSize), sizeMixed),
13477
13739
  onValueChange: (value)=>{
@@ -13549,6 +13811,7 @@ function FontPanel({ source, draft, errors, touched, setDraft, touch }) {
13549
13811
  /*#__PURE__*/ jsx("div", {
13550
13812
  className: "work-spreadsheet-format-cells-font-preview",
13551
13813
  style: {
13814
+ backgroundColor: spreadsheetFontPreviewBackground(draft.fontColor),
13552
13815
  color: draft.fontColor,
13553
13816
  fontFamily: draft.fontFamily,
13554
13817
  fontSize: `${Math.max(10, draft.fontSize)}px`,
@@ -13566,6 +13829,21 @@ function FontPanel({ source, draft, errors, touched, setDraft, touch }) {
13566
13829
  ]
13567
13830
  });
13568
13831
  }
13832
+ function spreadsheetFontPreviewBackground(color) {
13833
+ const match = /^#([0-9a-f]{6})$/i.exec(color.trim());
13834
+ if (!match?.[1]) return '#f4f6f8';
13835
+ const channels = [
13836
+ 0,
13837
+ 2,
13838
+ 4
13839
+ ].map((offset)=>Number.parseInt(match[1].slice(offset, offset + 2), 16));
13840
+ const [red = 0, green = 0, blue = 0] = channels.map((channel)=>{
13841
+ const component = channel / 255;
13842
+ return component <= 0.04045 ? component / 12.92 : ((component + 0.055) / 1.055) ** 2.4;
13843
+ });
13844
+ const luminance = 0.2126 * red + 0.7152 * green + 0.0722 * blue;
13845
+ return luminance >= 0.55 ? '#172033' : '#f4f6f8';
13846
+ }
13569
13847
  function BorderPanel({ source, draft, touched, setDraft, touch }) {
13570
13848
  const hasTarget = (target)=>draft.borders.some((format)=>format.target === target);
13571
13849
  const updateBorders = (borders)=>{
@@ -13818,32 +14096,6 @@ function borderCss(format) {
13818
14096
  const style = 'dotted' === format.style ? 'dotted' : format.style.includes('dash') ? 'dashed' : 'solid';
13819
14097
  return `${width}px ${style} ${format.color}`;
13820
14098
  }
13821
- const spreadsheetFormatCellsTabs = [
13822
- {
13823
- id: 'number',
13824
- label: '数字'
13825
- },
13826
- {
13827
- id: 'alignment',
13828
- label: '对齐'
13829
- },
13830
- {
13831
- id: 'font',
13832
- label: '字体'
13833
- },
13834
- {
13835
- id: 'border',
13836
- label: '边框'
13837
- },
13838
- {
13839
- id: 'fill',
13840
- label: '填充'
13841
- },
13842
- {
13843
- id: 'protection',
13844
- label: '保护'
13845
- }
13846
- ];
13847
14099
  function createSpreadsheetFormatCellsDialogSource(content, sheetId, rangeInput, cells, requestedActiveCell) {
13848
14100
  const range = spreadsheet_cell_range_normalizeSpreadsheetCellRange(rangeInput);
13849
14101
  const sheet = content.sheets.find((candidate)=>candidate.id === sheetId);
@@ -14015,10 +14267,10 @@ function sameDialogValue(left, right) {
14015
14267
  function clampIndex(value, minimum, maximum) {
14016
14268
  return Math.min(maximum, Math.max(minimum, Math.trunc(value)));
14017
14269
  }
14018
- function SpreadsheetFormatCellsDialog({ source, restoreFocusTarget, onApply, onClose }) {
14270
+ function SpreadsheetFormatCellsDialog({ source, restoreFocusTarget, openIntent = defaultSpreadsheetFormatCellsOpenIntent, onApply, onClose }) {
14019
14271
  const [draft, setDraft] = useState(()=>createSpreadsheetFormatCellsDraft(source));
14020
14272
  const [touched, setTouched] = useState({});
14021
- const [activeTab, setActiveTab] = useState('number');
14273
+ const [activeTab, setActiveTab] = useState(openIntent.tab);
14022
14274
  const formId = useId();
14023
14275
  const idBase = `spreadsheet-format-cells-${useId().replaceAll(':', '')}`;
14024
14276
  const errors = spreadsheetFormatCellsDraftErrors(draft);
@@ -14079,6 +14331,7 @@ function SpreadsheetFormatCellsDialog({ source, restoreFocusTarget, onApply, onC
14079
14331
  draft: draft,
14080
14332
  errors: errors,
14081
14333
  touched: touched,
14334
+ initialFocus: 'font' === openIntent.tab ? openIntent.focus : void 0,
14082
14335
  setDraft: setDraft,
14083
14336
  touch: (field)=>setTouched((current)=>({
14084
14337
  ...current,
@@ -23061,7 +23314,7 @@ function SpreadsheetEditorSurface({ autoFocus = true, content, collaborationHist
23061
23314
  const [selectionState, setSelectionState] = useState(null);
23062
23315
  const formatPainterSelectionHandlerRef = useRef((_sheetId, _selection)=>void 0);
23063
23316
  const [contextMenu, setContextMenu] = useState(null);
23064
- const [formatCellsSource, setFormatCellsSource] = useState(null);
23317
+ const [formatCellsDialog, setFormatCellsDialog] = useState(null);
23065
23318
  const formatCellsInvokerRef = useRef(null);
23066
23319
  const formatCellsSelectionRef = useRef(null);
23067
23320
  const formatCellsApplyingRef = useRef(false);
@@ -23211,7 +23464,7 @@ function SpreadsheetEditorSurface({ autoFocus = true, content, collaborationHist
23211
23464
  panelTriggerRef.current = null;
23212
23465
  setPanel(null);
23213
23466
  setContextMenu(null);
23214
- setFormatCellsSource(null);
23467
+ setFormatCellsDialog(null);
23215
23468
  formatCellsInvokerRef.current = null;
23216
23469
  formatCellsSelectionRef.current = null;
23217
23470
  formatCellsApplyingRef.current = false;
@@ -23491,14 +23744,17 @@ function SpreadsheetEditorSurface({ autoFocus = true, content, collaborationHist
23491
23744
  column_focus: request.activeCell.column
23492
23745
  }
23493
23746
  };
23494
- setFormatCellsSource(source);
23747
+ setFormatCellsDialog({
23748
+ source,
23749
+ intent: request.intent
23750
+ });
23495
23751
  return true;
23496
23752
  }, []);
23497
23753
  const closeSpreadsheetFormatCells = useCallback(()=>{
23498
23754
  const invoker = formatCellsInvokerRef.current;
23499
23755
  const canvas = spreadsheetCanvasRef.current;
23500
23756
  const openedFromGrid = Boolean(invoker && canvas?.contains(invoker));
23501
- setFormatCellsSource(null);
23757
+ setFormatCellsDialog(null);
23502
23758
  requestAnimationFrame(()=>{
23503
23759
  if (openedFromGrid || !invoker?.isConnected) focusSpreadsheetGrid(canvas, {
23504
23760
  focusOrigin: invoker
@@ -23639,7 +23895,7 @@ function SpreadsheetEditorSurface({ autoFocus = true, content, collaborationHist
23639
23895
  },
23640
23896
  formatPainter,
23641
23897
  formatCells: {
23642
- canOpen: !preview && null === formatCellsSource,
23898
+ canOpen: !preview && null === formatCellsDialog,
23643
23899
  open: openSpreadsheetFormatCells
23644
23900
  },
23645
23901
  hyperlink: spreadsheetHyperlink.commandPort,
@@ -24082,16 +24338,17 @@ function SpreadsheetEditorSurface({ autoFocus = true, content, collaborationHist
24082
24338
  onClose: ()=>setContextMenu(null),
24083
24339
  onRestoreFocus: ()=>focusSpreadsheetGrid(spreadsheetCanvasRef.current)
24084
24340
  }),
24085
- formatCellsSource && /*#__PURE__*/ jsx(SpreadsheetFormatCellsDialog, {
24086
- source: formatCellsSource,
24341
+ formatCellsDialog && /*#__PURE__*/ jsx(SpreadsheetFormatCellsDialog, {
24342
+ source: formatCellsDialog.source,
24343
+ openIntent: formatCellsDialog.intent,
24087
24344
  restoreFocusTarget: ()=>formatCellsInvokerRef.current?.isConnected ? formatCellsInvokerRef.current : spreadsheetGridFocusTarget(spreadsheetCanvasRef.current),
24088
24345
  onApply: (patch)=>{
24089
24346
  formatCellsApplyingRef.current = true;
24090
24347
  let handled = false;
24091
24348
  try {
24092
24349
  handled = spreadsheetCommands.applyCellFormat({
24093
- sheetId: formatCellsSource.sheetId,
24094
- range: formatCellsSource.range,
24350
+ sheetId: formatCellsDialog.source.sheetId,
24351
+ range: formatCellsDialog.source.range,
24095
24352
  patch
24096
24353
  });
24097
24354
  } finally{
@@ -24217,6 +24474,7 @@ function spreadsheetCommandsWithGridFocus(commands, restoreFocus) {
24217
24474
  activateFormatPainter: afterSuccessfulCommand(commands.activateFormatPainter),
24218
24475
  cancelFormatPainter: afterSuccessfulCommand(commands.cancelFormatPainter),
24219
24476
  clearSelectedCells: afterSuccessfulCommand(commands.clearSelectedCells),
24477
+ copyCellFromAbove: afterSuccessfulCommand(commands.copyCellFromAbove),
24220
24478
  copySelection: afterSuccessfulCommand(commands.copySelection),
24221
24479
  convertTableToRange: afterSuccessfulCommand(commands.convertTableToRange),
24222
24480
  cutSelection: afterSuccessfulCommand(commands.cutSelection),
@@ -8,7 +8,7 @@ export interface OfficeSelectOption<T extends string = string> {
8
8
  previewStyle?: CSSProperties;
9
9
  searchText?: string;
10
10
  }
11
- export declare function OfficeSelect<T extends string>({ ariaLabel, value, options, onValueChange, disabled, placeholder, className, }: {
11
+ export declare function OfficeSelect<T extends string>({ ariaLabel, value, options, onValueChange, disabled, placeholder, className, ariaKeyShortcuts, initialFocus, }: {
12
12
  ariaLabel: string;
13
13
  value: T;
14
14
  options: readonly OfficeSelectOption<T>[];
@@ -16,4 +16,6 @@ export declare function OfficeSelect<T extends string>({ ariaLabel, value, optio
16
16
  disabled?: boolean;
17
17
  placeholder?: string;
18
18
  className?: string;
19
+ ariaKeyShortcuts?: string;
20
+ initialFocus?: boolean;
19
21
  }): import("react").JSX.Element;
@@ -406,6 +406,34 @@ export declare const spreadsheetCommandCatalog: {
406
406
  readonly editor: readonly ["Mod-1"];
407
407
  };
408
408
  };
409
+ readonly formatCellsFont: {
410
+ readonly id: "font.formatCellsFont";
411
+ readonly label: "设置字体格式";
412
+ readonly location: {
413
+ readonly area: "ribbon";
414
+ readonly tab: "home";
415
+ readonly group: "font";
416
+ };
417
+ readonly shortcut: {
418
+ readonly label: "Cmd/Ctrl+Shift+F";
419
+ readonly aria: "Control+Shift+F Meta+Shift+F";
420
+ readonly editor: readonly ["Mod-Shift-f"];
421
+ };
422
+ };
423
+ readonly formatCellsFontSize: {
424
+ readonly id: "font.formatCellsFontSize";
425
+ readonly label: "设置字号格式";
426
+ readonly location: {
427
+ readonly area: "ribbon";
428
+ readonly tab: "home";
429
+ readonly group: "font";
430
+ };
431
+ readonly shortcut: {
432
+ readonly label: "Cmd/Ctrl+Shift+P";
433
+ readonly aria: "Control+Shift+P Meta+Shift+P";
434
+ readonly editor: readonly ["Mod-Shift-p"];
435
+ };
436
+ };
409
437
  readonly borderTop: {
410
438
  readonly id: "font.borderTop";
411
439
  readonly label: "上框线";
@@ -852,6 +880,34 @@ export declare const spreadsheetCommandCatalog: {
852
880
  readonly group: "editing";
853
881
  };
854
882
  };
883
+ readonly copyFormulaFromAbove: {
884
+ readonly id: "editing.copyFormulaFromAbove";
885
+ readonly label: "复制上方公式";
886
+ readonly location: {
887
+ readonly area: "ribbon";
888
+ readonly tab: "home";
889
+ readonly group: "editing";
890
+ };
891
+ readonly shortcut: {
892
+ readonly label: "Ctrl+'";
893
+ readonly aria: "Control+'";
894
+ readonly editor: readonly ["Control-'"];
895
+ };
896
+ };
897
+ readonly copyValueFromAbove: {
898
+ readonly id: "editing.copyValueFromAbove";
899
+ readonly label: "复制上方值";
900
+ readonly location: {
901
+ readonly area: "ribbon";
902
+ readonly tab: "home";
903
+ readonly group: "editing";
904
+ };
905
+ readonly shortcut: {
906
+ readonly label: "Ctrl+Shift+'";
907
+ readonly aria: "Control+Shift+'";
908
+ readonly editor: readonly ["Control-Shift-'"];
909
+ };
910
+ };
855
911
  readonly clearAll: {
856
912
  readonly id: "editing.clearAll";
857
913
  readonly label: "清除全部";
@@ -7,9 +7,11 @@ import type { SpreadsheetAutoSumFunction } from './spreadsheet-auto-sum';
7
7
  import { type SpreadsheetCellClearMode } from './spreadsheet-cell-clear';
8
8
  import type { SpreadsheetCellBorderFormat } from './spreadsheet-cell-border';
9
9
  import type { SpreadsheetCellFormatRequest } from './spreadsheet-cell-format';
10
+ import type { SpreadsheetFormatCellsOpenIntent } from './spreadsheet-format-cells-intent';
10
11
  import type { SpreadsheetCellRange } from './spreadsheet-cell-range';
11
12
  import type { SpreadsheetCellStyleChoice } from './spreadsheet-cell-style';
12
13
  import type { SpreadsheetCellFillDirection } from './spreadsheet-cell-fill';
14
+ import type { SpreadsheetCopyFromAboveKind } from './spreadsheet-copy-from-above';
13
15
  import { type SpreadsheetFontSizeDirection } from './spreadsheet-font-size-command';
14
16
  import { type SpreadsheetDateTimeKind } from './spreadsheet-date-time-command';
15
17
  import type { SpreadsheetDataValidationRequest, SpreadsheetDataValidationTarget } from './spreadsheet-data-validation';
@@ -118,6 +120,7 @@ export interface SpreadsheetFormatCellsOpenRequest {
118
120
  column: number;
119
121
  };
120
122
  cells: (Cell | null)[][];
123
+ intent: SpreadsheetFormatCellsOpenIntent;
121
124
  }
122
125
  export interface SpreadsheetFormatCellsCommandPort {
123
126
  canOpen: boolean;
@@ -162,6 +165,7 @@ export interface SpreadsheetEditorCommands {
162
165
  applyTable: (request: SpreadsheetTableRequest) => boolean;
163
166
  cancelFormatPainter: () => boolean;
164
167
  clearSelectedCells: (mode?: SpreadsheetCellClearMode) => boolean;
168
+ copyCellFromAbove: (kind: SpreadsheetCopyFromAboveKind) => boolean;
165
169
  copySelection: () => boolean;
166
170
  cutSelection: () => boolean;
167
171
  deleteSelectedStructure: (axis: SpreadsheetStructureAxis) => boolean;
@@ -177,7 +181,7 @@ export interface SpreadsheetEditorCommands {
177
181
  openAutoFilterMenu: () => boolean;
178
182
  openDataValidation: () => boolean;
179
183
  openFind: () => boolean;
180
- openFormatCells: () => boolean;
184
+ openFormatCells: (intent?: SpreadsheetFormatCellsOpenIntent) => boolean;
181
185
  openGoTo: () => boolean;
182
186
  openHyperlink: () => boolean;
183
187
  openPasteSpecial: () => boolean;
@@ -0,0 +1,3 @@
1
+ import { type OfficeEditorExtension } from './office-editor-extension';
2
+ import type { SpreadsheetCommandContext, SpreadsheetEditorCommands } from './spreadsheet-command-controller';
3
+ export declare function createSpreadsheetCopyFromAboveExtension(): OfficeEditorExtension<SpreadsheetCommandContext, SpreadsheetEditorCommands>;
@@ -0,0 +1,18 @@
1
+ import type { WorkSpreadsheetSheet } from '../work-types';
2
+ import type { SpreadsheetCellRange } from './spreadsheet-cell-range';
3
+ export type SpreadsheetCopyFromAboveKind = 'formula' | 'value';
4
+ export type SpreadsheetCopyFromAboveValue = boolean | number | string | null;
5
+ export interface SpreadsheetCopyFromAbovePlan {
6
+ formulaBarValue: SpreadsheetCopyFromAboveValue | '';
7
+ kind: SpreadsheetCopyFromAboveKind;
8
+ source: {
9
+ row: number;
10
+ column: number;
11
+ };
12
+ targetRange: SpreadsheetCellRange;
13
+ value: SpreadsheetCopyFromAboveValue;
14
+ }
15
+ export declare function planSpreadsheetCopyFromAbove(sheet: WorkSpreadsheetSheet | undefined, target: {
16
+ row: number;
17
+ column: number;
18
+ }, kind: SpreadsheetCopyFromAboveKind): SpreadsheetCopyFromAbovePlan | null;
@@ -4,26 +4,7 @@ import { type SpreadsheetUnderlineStyle } from '../work-spreadsheet-underline';
4
4
  import { type SpreadsheetCellBorderFormat, type SpreadsheetCellBorderStyle } from './spreadsheet-cell-border';
5
5
  import { type SpreadsheetCellFormatPatch, type SpreadsheetHorizontalAlignment, type SpreadsheetVerticalAlignment } from './spreadsheet-cell-format';
6
6
  import { type SpreadsheetCellRange } from './spreadsheet-cell-range';
7
- export declare const spreadsheetFormatCellsTabs: readonly [{
8
- readonly id: "number";
9
- readonly label: "数字";
10
- }, {
11
- readonly id: "alignment";
12
- readonly label: "对齐";
13
- }, {
14
- readonly id: "font";
15
- readonly label: "字体";
16
- }, {
17
- readonly id: "border";
18
- readonly label: "边框";
19
- }, {
20
- readonly id: "fill";
21
- readonly label: "填充";
22
- }, {
23
- readonly id: "protection";
24
- readonly label: "保护";
25
- }];
26
- export type SpreadsheetFormatCellsTabId = (typeof spreadsheetFormatCellsTabs)[number]['id'];
7
+ export { spreadsheetFormatCellsTabs, type SpreadsheetFormatCellsTabId, } from './spreadsheet-format-cells-intent';
27
8
  export interface SpreadsheetFormatCellsField<T> {
28
9
  value: T;
29
10
  mixed: boolean;
@@ -1,6 +1,7 @@
1
1
  import type { Dispatch, SetStateAction } from 'react';
2
2
  import type { SpreadsheetCellFormatPatch } from './spreadsheet-cell-format';
3
3
  import type { SpreadsheetFormatCellsDialogSource, SpreadsheetFormatCellsDraft, SpreadsheetFormatCellsDraftErrors, SpreadsheetFormatCellsTabId, SpreadsheetFormatCellsTouched } from './spreadsheet-format-cells-dialog-model';
4
+ import type { SpreadsheetFormatCellsInitialFocus } from './spreadsheet-format-cells-intent';
4
5
  interface PanelProps {
5
6
  activeTab: SpreadsheetFormatCellsTabId;
6
7
  idBase: string;
@@ -8,6 +9,7 @@ interface PanelProps {
8
9
  draft: SpreadsheetFormatCellsDraft;
9
10
  errors: SpreadsheetFormatCellsDraftErrors;
10
11
  touched: SpreadsheetFormatCellsTouched;
12
+ initialFocus?: SpreadsheetFormatCellsInitialFocus;
11
13
  setDraft: Dispatch<SetStateAction<SpreadsheetFormatCellsDraft>>;
12
14
  touch: (field: keyof SpreadsheetCellFormatPatch) => void;
13
15
  }
@@ -1,8 +1,10 @@
1
1
  import type { SpreadsheetCellFormatPatch } from './spreadsheet-cell-format';
2
2
  import { type SpreadsheetFormatCellsDialogSource } from './spreadsheet-format-cells-dialog-model';
3
- export declare function SpreadsheetFormatCellsDialog({ source, restoreFocusTarget, onApply, onClose, }: {
3
+ import { type SpreadsheetFormatCellsOpenIntent } from './spreadsheet-format-cells-intent';
4
+ export declare function SpreadsheetFormatCellsDialog({ source, restoreFocusTarget, openIntent, onApply, onClose, }: {
4
5
  source: SpreadsheetFormatCellsDialogSource;
5
6
  restoreFocusTarget: () => HTMLElement | null;
7
+ openIntent?: SpreadsheetFormatCellsOpenIntent;
6
8
  onApply: (patch: SpreadsheetCellFormatPatch) => boolean;
7
9
  onClose: () => void;
8
10
  }): import("react").JSX.Element;
@@ -0,0 +1,32 @@
1
+ export declare const spreadsheetFormatCellsTabs: readonly [{
2
+ readonly id: "number";
3
+ readonly label: "数字";
4
+ }, {
5
+ readonly id: "alignment";
6
+ readonly label: "对齐";
7
+ }, {
8
+ readonly id: "font";
9
+ readonly label: "字体";
10
+ }, {
11
+ readonly id: "border";
12
+ readonly label: "边框";
13
+ }, {
14
+ readonly id: "fill";
15
+ readonly label: "填充";
16
+ }, {
17
+ readonly id: "protection";
18
+ readonly label: "保护";
19
+ }];
20
+ export type SpreadsheetFormatCellsTabId = (typeof spreadsheetFormatCellsTabs)[number]['id'];
21
+ export type SpreadsheetFormatCellsInitialFocus = 'fontFamily' | 'fontSize';
22
+ export type SpreadsheetFormatCellsOpenIntent = {
23
+ tab: 'font';
24
+ focus?: SpreadsheetFormatCellsInitialFocus;
25
+ } | {
26
+ tab: Exclude<SpreadsheetFormatCellsTabId, 'font'>;
27
+ focus?: never;
28
+ };
29
+ export declare const defaultSpreadsheetFormatCellsOpenIntent: {
30
+ readonly tab: "number";
31
+ };
32
+ export declare function normalizeSpreadsheetFormatCellsOpenIntent(value: unknown): SpreadsheetFormatCellsOpenIntent | null;
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@a3s-lab/office",
3
- "version": "0.22.0",
3
+ "version": "0.24.0",
4
4
  "description": "Open-source collaborative browser editors for documents, Markdown, spreadsheets, presentations, and PDFs.",
5
5
  "keywords": [
6
6
  "office",
@@ -89,6 +89,8 @@
89
89
  "playground:visual": "playwright test --config playwright.config.ts",
90
90
  "playground:visual:spreadsheet-data-validation": "playwright test visual-tests/spreadsheet-data-validation.functional.spec.ts --config playwright.config.ts",
91
91
  "playground:visual:spreadsheet-date-time": "playwright test visual-tests/spreadsheet-date-time.functional.spec.ts --config playwright.config.ts",
92
+ "playground:visual:spreadsheet-copy-from-above": "playwright test visual-tests/spreadsheet-copy-from-above.functional.spec.ts --config playwright.config.ts",
93
+ "playground:visual:spreadsheet-font-dialog-shortcuts": "playwright test visual-tests/spreadsheet-font-dialog-shortcuts.functional.spec.ts --config playwright.config.ts",
92
94
  "playground:visual:spreadsheet-diagonal-borders": "playwright test visual-tests/spreadsheet-diagonal-borders.functional.spec.ts --config playwright.config.ts",
93
95
  "playground:visual:spreadsheet-font-colors-shortcuts": "playwright test visual-tests/spreadsheet-font-colors-shortcuts.functional.spec.ts --config playwright.config.ts",
94
96
  "playground:visual:spreadsheet-hyperlink": "playwright test visual-tests/spreadsheet-hyperlink.functional.spec.ts --config playwright.config.ts",
@@ -163,6 +165,10 @@
163
165
  "test:e2e:spreadsheet-diagonal-borders:check": "a3s-test check tests/e2e/spreadsheet-diagonal-borders.acl --json",
164
166
  "test:e2e:spreadsheet-date-time": "a3s-test run tests/e2e/spreadsheet-date-time.acl --json",
165
167
  "test:e2e:spreadsheet-date-time:check": "a3s-test check tests/e2e/spreadsheet-date-time.acl --json",
168
+ "test:e2e:spreadsheet-copy-from-above": "A3S_TEST_SUITE=tests/e2e/spreadsheet-copy-from-above.acl bash scripts/run-a3s-test-web-gate.sh",
169
+ "test:e2e:spreadsheet-copy-from-above:check": "a3s-test check tests/e2e/spreadsheet-copy-from-above.acl --json",
170
+ "test:e2e:spreadsheet-font-dialog-shortcuts": "A3S_TEST_SUITE=tests/e2e/spreadsheet-font-dialog-shortcuts.acl bash scripts/run-a3s-test-web-gate.sh",
171
+ "test:e2e:spreadsheet-font-dialog-shortcuts:check": "a3s-test check tests/e2e/spreadsheet-font-dialog-shortcuts.acl --json",
166
172
  "test:e2e:spreadsheet-hyperlink": "a3s-test run tests/e2e/spreadsheet-hyperlink.acl --json",
167
173
  "test:e2e:spreadsheet-hyperlink:check": "a3s-test check tests/e2e/spreadsheet-hyperlink.acl --json",
168
174
  "test:e2e:spreadsheet-maximum-sparse": "a3s-test run tests/e2e/spreadsheet-maximum-sparse.acl --json",