@a3s-lab/office 0.17.0 → 0.18.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
@@ -561,7 +561,10 @@ interaction model.
561
561
  style-only writes, Home and Font Grow/Shrink Font commands with
562
562
  `Cmd/Ctrl+Shift+.` / `Cmd/Ctrl+]` and `Cmd/Ctrl+Shift+,` / `Cmd/Ctrl+[` aliases,
563
563
  per-cell mixed-size stepping, native rectangle compaction, a 10,000-cell
564
- bound, and one-step Undo, plus a cell-border split control with side, all,
564
+ bound, and one-step Undo, a WPS-style Underline split control with single,
565
+ double, single-accounting, and double-accounting styles, exact Format Cells
566
+ and XLSX round trips, and active-style-aware `Cmd/Ctrl+U` toggling, plus a
567
+ cell-border split control with side, all,
565
568
  outside, inside, horizontal, vertical, clear, and diagonal targets, ten
566
569
  native line styles, exact color selection, compact overlapping range writes,
567
570
  `Cmd/Ctrl+Shift+&` Outside Borders and `Cmd/Ctrl+Shift+_` Clear Borders,
@@ -1519,6 +1522,7 @@ without hard-coded return URLs.
1519
1522
 
1520
1523
  - [Live Playground](https://a3s-lab.github.io/Office/)
1521
1524
  - [Documentation center](https://a3s-lab.github.io/Office/docs/)
1525
+ - [A3S Office 0.18.0 documentation](https://a3s-lab.github.io/Office/docs/0.18.0/)
1522
1526
  - [A3S Office 0.17.0 documentation](https://a3s-lab.github.io/Office/docs/0.17.0/)
1523
1527
  - [A3S Office 0.16.0 documentation](https://a3s-lab.github.io/Office/docs/0.16.0/)
1524
1528
  - [A3S Office 0.15.0 documentation](https://a3s-lab.github.io/Office/docs/0.15.0/)
@@ -4,7 +4,7 @@ import { Workbook } from "@fortune-sheet/react";
4
4
  import { AArrowDown, AArrowUp, AlignCenter, AlignLeft, AlignRight, AlignVerticalJustifyCenter, AlignVerticalJustifyEnd, AlignVerticalJustifyStart, ArrowDown, ArrowDownToLine, ArrowLeft, ArrowLeftToLine, ArrowRight, ArrowRightToLine, ArrowUp, ArrowUpToLine, BadgeJapaneseYen, BarChart3, BetweenHorizontalEnd, BetweenHorizontalStart, BetweenVerticalEnd, BetweenVerticalStart, Bold, Bookmark, Calculator, Check, ChevronDown, ChevronLeft, ChevronRight, ClipboardPaste, Cloud, Columns3, Copy, CopyPlus, DecimalsArrowLeft, DecimalsArrowRight, Eraser, Eye, EyeOff, FileX2, Globe2, Grid2X2, Grid3X3, Hash, Italic, KeyRound, Layers2, Link2, Link2Off, ListChecks, ListFilter, LocateFixed, Merge, MessageSquareX, MoveHorizontal, MoveVertical, Paintbrush, Palette, PanelLeft, PanelTop, PanelsTopLeft, Pencil, Percent, Plus, Printer, Redo2, RefreshCw, Rows3, Save, Scissors, Search, Settings2, ShieldCheck, Sigma, SortAsc, SortDesc, Strikethrough, SwatchBook, Table2, TableProperties, Trash2, Underline, Undo2, WrapText, X } from "lucide-react";
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
- import { freezeImportedSpreadsheetCell, withoutEditableRange, spreadsheetMatrixProfile, normalizeSpreadsheetConditionalVisualOptions, effectiveSpreadsheetPageSetup, attachSpreadsheetShownCommentCells, withEditableRange, sameSpreadsheetHistoryValue, createOfficeSpreadsheetCollaborationBinding as createWorkOfficeSpreadsheetCollaborationBinding, isSpreadsheetConditionalComparisonOperator, spreadsheetConditionalIconForValue, defaultSpreadsheetConditionalIconThresholds, normalizeSpreadsheetDateValidationBoundary, sheetProtectionAuthority, editableRangeCellCount, unlockedCellCount, registerDerivedSpreadsheetMatrix, editableRangeRequiresCredentials, SPREADSHEET_CONDITIONAL_COMPARISON_OPERATORS, normalizeSpreadsheetConditionalIconSetFormat, defaultSpreadsheetDataBarOptions, spreadsheetConditionalThresholdValue, normalizeSheetProtectionAuthority, withSheetProtection, spreadsheetProtectionKey, defaultSpreadsheetColorScaleThresholds, protectedSheetCount, SPREADSHEET_CONDITIONAL_ICON_SETS, withSheetSelectionPermissions, spreadsheetConditionalComparisonNeedsUpperValue, drawSpreadsheetConditionalIcon, replaceOfficeSpreadsheetCollaboration as replaceWorkOfficeSpreadsheetCollaboration, readOfficeSpreadsheetCollaboration as readWorkOfficeSpreadsheetCollaboration, spreadsheetConditionalThresholdsEqual } from "./2180.js";
7
+ import { freezeImportedSpreadsheetCell, withoutEditableRange, spreadsheetMatrixProfile, normalizeSpreadsheetConditionalVisualOptions, spreadsheetUnderlineCellValue, effectiveSpreadsheetPageSetup, attachSpreadsheetShownCommentCells, withEditableRange, sameSpreadsheetHistoryValue, createOfficeSpreadsheetCollaborationBinding as createWorkOfficeSpreadsheetCollaborationBinding, isSpreadsheetConditionalComparisonOperator, spreadsheetConditionalIconForValue, defaultSpreadsheetConditionalIconThresholds, spreadsheetUnderlineStyle, normalizeSpreadsheetDateValidationBoundary, sheetProtectionAuthority, editableRangeCellCount, unlockedCellCount, registerDerivedSpreadsheetMatrix, editableRangeRequiresCredentials, SPREADSHEET_CONDITIONAL_COMPARISON_OPERATORS, normalizeSpreadsheetConditionalIconSetFormat, defaultSpreadsheetDataBarOptions, spreadsheetConditionalThresholdValue, normalizeSheetProtectionAuthority, withSheetProtection, spreadsheetProtectionKey, defaultSpreadsheetColorScaleThresholds, protectedSheetCount, SPREADSHEET_CONDITIONAL_ICON_SETS, withSheetSelectionPermissions, spreadsheetConditionalComparisonNeedsUpperValue, drawSpreadsheetConditionalIcon, replaceOfficeSpreadsheetCollaboration as replaceWorkOfficeSpreadsheetCollaboration, readOfficeSpreadsheetCollaboration as readWorkOfficeSpreadsheetCollaboration, spreadsheetConditionalThresholdsEqual, isSpreadsheetUnderlineStyle } from "./1992.js";
8
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";
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";
@@ -187,15 +187,15 @@ function applyDefaultRule(styles, data, rule, blocked, matched) {
187
187
  for (const range of rule.cellrange){
188
188
  const positions = cellPositions(data, [
189
189
  range
190
- ]).filter(({ row, column })=>null != cellValue(data, row, column));
190
+ ]).filter(({ row, column })=>null != work_spreadsheet_conditional_format_cellValue(data, row, column));
191
191
  const occurrences = new Map();
192
192
  for (const { row, column } of positions){
193
- const key = comparableKey(cellValue(data, row, column));
193
+ const key = comparableKey(work_spreadsheet_conditional_format_cellValue(data, row, column));
194
194
  occurrences.set(key, (occurrences.get(key) ?? 0) + 1);
195
195
  }
196
196
  const unique = '1' === values[0];
197
197
  for (const { row, column } of positions){
198
- const count = occurrences.get(comparableKey(cellValue(data, row, column))) ?? 0;
198
+ const count = occurrences.get(comparableKey(work_spreadsheet_conditional_format_cellValue(data, row, column))) ?? 0;
199
199
  if (unique && 1 === count || !unique && count > 1) applyDifferentialStyle(styles, blocked, matched, row, column, style);
200
200
  }
201
201
  }
@@ -215,7 +215,7 @@ function applyDefaultRule(styles, data, rule, blocked, matched) {
215
215
  return;
216
216
  }
217
217
  forEachCell(data, rule.cellrange, ({ row, column })=>{
218
- const current = cellValue(data, row, column);
218
+ const current = work_spreadsheet_conditional_format_cellValue(data, row, column);
219
219
  if (matchesCondition(current, rule.conditionName, values)) applyDifferentialStyle(styles, blocked, matched, row, column, style);
220
220
  });
221
221
  }
@@ -370,13 +370,13 @@ function evaluateFormula(source, row, column, baseRange, data) {
370
370
  const blank = /^(NOT\()?ISBLANK\((\$?)([A-Z]{1,3})(\$?)([1-9]\d*)\)\)?$/i.exec(formula);
371
371
  if (blank) {
372
372
  const target = formulaReference(blank[2], blank[3], blank[4], blank[5], row, column, baseRange);
373
- const empty = null == cellValue(data, target.row, target.column) || '' === cellValue(data, target.row, target.column);
373
+ const empty = null == work_spreadsheet_conditional_format_cellValue(data, target.row, target.column) || '' === work_spreadsheet_conditional_format_cellValue(data, target.row, target.column);
374
374
  return blank[1] ? !empty : empty;
375
375
  }
376
376
  const comparison = /^(\$?)([A-Z]{1,3})(\$?)([1-9]\d*)(=|<>|>=|<=|>|<)(?:"((?:[^"]|"")*)"|(-?\d+(?:\.\d+)?))$/i.exec(formula);
377
377
  if (!comparison) return false;
378
378
  const target = formulaReference(comparison[1], comparison[2], comparison[3], comparison[4], row, column, baseRange);
379
- const left = cellValue(data, target.row, target.column);
379
+ const left = work_spreadsheet_conditional_format_cellValue(data, target.row, target.column);
380
380
  const right = void 0 !== comparison[6] ? comparison[6].replaceAll('""', '"') : Number(comparison[7]);
381
381
  return compareWithOperator(left, comparison[5], right);
382
382
  }
@@ -445,11 +445,11 @@ function forEachCell(data, ranges, visit) {
445
445
  column
446
446
  });
447
447
  }
448
- function cellValue(data, row, column) {
448
+ function work_spreadsheet_conditional_format_cellValue(data, row, column) {
449
449
  return data[row]?.[column]?.v ?? null;
450
450
  }
451
451
  function numericCellValue(data, row, column) {
452
- const value = cellValue(data, row, column);
452
+ const value = work_spreadsheet_conditional_format_cellValue(data, row, column);
453
453
  return 'number' == typeof value && Number.isFinite(value) ? value : null;
454
454
  }
455
455
  function comparableKey(value) {
@@ -4049,7 +4049,7 @@ function canApplySpreadsheetCellFormat(content, request) {
4049
4049
  'top',
4050
4050
  'middle',
4051
4051
  'bottom'
4052
- ].includes(patch.verticalAlignment) || void 0 !== patch.wrapText && 'boolean' != typeof patch.wrapText || void 0 !== patch.rotation && (!Number.isInteger(patch.rotation) || patch.rotation < -90 || patch.rotation > 90) || void 0 !== patch.fontFamily && !validTrimmedString(patch.fontFamily, 128) || void 0 !== patch.fontSize && (!Number.isFinite(patch.fontSize) || patch.fontSize < 1 || patch.fontSize > 409) || void 0 !== patch.fontColor && !normalizeColor(patch.fontColor) || void 0 !== patch.fillColor && null !== patch.fillColor && !normalizeColor(patch.fillColor) || !validOptionalBoolean(patch.bold) || !validOptionalBoolean(patch.italic) || !validOptionalBoolean(patch.underline) || !validOptionalBoolean(patch.strike) || !validOptionalBoolean(patch.locked) || !validOptionalBoolean(patch.hidden)) return false;
4052
+ ].includes(patch.verticalAlignment) || void 0 !== patch.wrapText && 'boolean' != typeof patch.wrapText || void 0 !== patch.rotation && (!Number.isInteger(patch.rotation) || patch.rotation < -90 || patch.rotation > 90) || void 0 !== patch.fontFamily && !validTrimmedString(patch.fontFamily, 128) || void 0 !== patch.fontSize && (!Number.isFinite(patch.fontSize) || patch.fontSize < 1 || patch.fontSize > 409) || void 0 !== patch.fontColor && !normalizeColor(patch.fontColor) || void 0 !== patch.fillColor && null !== patch.fillColor && !normalizeColor(patch.fillColor) || !validOptionalBoolean(patch.bold) || !validOptionalBoolean(patch.italic) || void 0 !== patch.underline && !isSpreadsheetUnderlineStyle(patch.underline) || !validOptionalBoolean(patch.strike) || !validOptionalBoolean(patch.locked) || !validOptionalBoolean(patch.hidden)) return false;
4053
4053
  if (void 0 !== patch.borders) {
4054
4054
  const normalized = patch.borders.map(normalizeSpreadsheetBorderFormat);
4055
4055
  if (normalized.some((format)=>!format || ![
@@ -4214,7 +4214,7 @@ function formatCell(source, patch) {
4214
4214
  if (void 0 !== patch.fontColor) next.fc = normalizeColor(patch.fontColor) ?? patch.fontColor;
4215
4215
  if (void 0 !== patch.bold) next.bl = patch.bold ? 1 : 0;
4216
4216
  if (void 0 !== patch.italic) next.it = patch.italic ? 1 : 0;
4217
- if (void 0 !== patch.underline) next.un = patch.underline ? 1 : 0;
4217
+ if (void 0 !== patch.underline) next.un = spreadsheetUnderlineCellValue(patch.underline);
4218
4218
  if (void 0 !== patch.strike) next.cl = patch.strike ? 1 : 0;
4219
4219
  if (void 0 !== patch.fillColor) if (null === patch.fillColor) delete next.bg;
4220
4220
  else next.bg = normalizeColor(patch.fillColor) ?? patch.fillColor;
@@ -8166,7 +8166,8 @@ function isSpreadsheetAutoFilterTextTarget(target) {
8166
8166
  }
8167
8167
  function runSpreadsheetCellFormatShortcut(event, context, canExecute, execute, attribute) {
8168
8168
  if (event.repeat || isOfficeShortcutBlocked(event.target) || isSpreadsheetNativeTextUndoTarget(event.target)) return false;
8169
- const value = 1 === Number(context.toolbarCell?.[attribute]) ? 0 : 1;
8169
+ const active = 'un' === attribute ? 'none' !== spreadsheetUnderlineStyle(context.toolbarCell?.un) : 1 === Number(context.toolbarCell?.[attribute]);
8170
+ const value = active ? 0 : 1;
8170
8171
  return canExecute(attribute, value) && execute(attribute, value);
8171
8172
  }
8172
8173
  function runSpreadsheetNumberFormatShortcut(event, context, canExecute, execute, preset) {
@@ -9232,6 +9233,108 @@ function SpreadsheetBorderGlyph({ target }) {
9232
9233
  "aria-hidden": "true"
9233
9234
  });
9234
9235
  }
9236
+ const underlineOptions = [
9237
+ {
9238
+ value: 'none',
9239
+ label: '无下划线'
9240
+ },
9241
+ {
9242
+ value: 'single',
9243
+ label: '单下划线'
9244
+ },
9245
+ {
9246
+ value: 'double',
9247
+ label: '双下划线'
9248
+ },
9249
+ {
9250
+ value: 'singleAccounting',
9251
+ label: '单会计用下划线'
9252
+ },
9253
+ {
9254
+ value: 'doubleAccounting',
9255
+ label: '双会计用下划线'
9256
+ }
9257
+ ];
9258
+ function SpreadsheetUnderlineRibbon({ can, commands, value }) {
9259
+ const style = spreadsheetUnderlineStyle(value);
9260
+ const active = 'none' !== style;
9261
+ const toggleValue = active ? 0 : 1;
9262
+ const definition = spreadsheetCommandCatalog.underline;
9263
+ const currentLabel = underlineOptions.find((option)=>option.value === style)?.label ?? underlineOptions[0].label;
9264
+ const menuDisabled = underlineOptions.every((option)=>!can.setCellFormat('un', spreadsheetUnderlineCellValue(option.value)));
9265
+ return /*#__PURE__*/ jsx(Popover, {
9266
+ label: "更多下划线",
9267
+ panelLabel: "下划线样式",
9268
+ panelRole: "menu",
9269
+ portal: true,
9270
+ placement: "bottom-end",
9271
+ className: "work-spreadsheet-underline-split-root",
9272
+ panelClassName: "work-office-context-menu work-spreadsheet-ribbon-menu work-spreadsheet-underline-menu",
9273
+ disabled: menuDisabled,
9274
+ focusFirstOnOpen: true,
9275
+ onPanelKeyDown: moveOfficeMenuFocus,
9276
+ trigger: (triggerProps, { open })=>/*#__PURE__*/ jsxs(Fragment, {
9277
+ children: [
9278
+ /*#__PURE__*/ jsx("button", {
9279
+ type: "button",
9280
+ className: `work-spreadsheet-underline-primary${active ? ' active' : ''}`,
9281
+ "aria-label": definition.label,
9282
+ "aria-keyshortcuts": definition.shortcut.aria,
9283
+ "aria-pressed": active,
9284
+ title: `${definition.label}(${currentLabel};${definition.shortcut.label})`,
9285
+ disabled: !can.setCellFormat('un', toggleValue),
9286
+ onClick: ()=>commands.setCellFormat('un', toggleValue),
9287
+ children: /*#__PURE__*/ jsx(Underline, {
9288
+ size: 15,
9289
+ "aria-hidden": "true"
9290
+ })
9291
+ }),
9292
+ /*#__PURE__*/ jsx("button", {
9293
+ ...triggerProps,
9294
+ className: `work-spreadsheet-underline-disclosure${open ? ' active' : ''}`,
9295
+ title: "更多下划线",
9296
+ children: /*#__PURE__*/ jsx(ChevronDown, {
9297
+ size: 12,
9298
+ "aria-hidden": "true"
9299
+ })
9300
+ })
9301
+ ]
9302
+ }),
9303
+ children: (close)=>underlineOptions.map((option)=>{
9304
+ const cellValue = spreadsheetUnderlineCellValue(option.value);
9305
+ return /*#__PURE__*/ jsxs("button", {
9306
+ type: "button",
9307
+ role: "menuitemradio",
9308
+ tabIndex: -1,
9309
+ "aria-checked": style === option.value,
9310
+ "aria-label": option.label,
9311
+ disabled: !can.setCellFormat('un', cellValue),
9312
+ onClick: ()=>{
9313
+ close();
9314
+ commands.setCellFormat('un', cellValue);
9315
+ },
9316
+ children: [
9317
+ /*#__PURE__*/ jsx(SpreadsheetUnderlineGlyph, {
9318
+ style: option.value
9319
+ }),
9320
+ /*#__PURE__*/ jsx("span", {
9321
+ children: option.label
9322
+ })
9323
+ ]
9324
+ }, option.value);
9325
+ })
9326
+ });
9327
+ }
9328
+ function SpreadsheetUnderlineGlyph({ style }) {
9329
+ return /*#__PURE__*/ jsx("span", {
9330
+ className: "work-spreadsheet-underline-glyph",
9331
+ "data-underline-style": style,
9332
+ "aria-hidden": "true",
9333
+ children: /*#__PURE__*/ jsx(Underline, {
9334
+ size: 16
9335
+ })
9336
+ });
9337
+ }
9235
9338
  const spreadsheetNumberFormatOptions = [
9236
9339
  {
9237
9340
  value: 'general',
@@ -9302,7 +9405,6 @@ function SpreadsheetFontRibbonGroup({ can, commands, toolbarCell }) {
9302
9405
  const fontSize = Number(toolbarCell?.fs ?? 10);
9303
9406
  const bold = 1 === Number(toolbarCell?.bl);
9304
9407
  const italic = 1 === Number(toolbarCell?.it);
9305
- const underline = 1 === Number(toolbarCell?.un);
9306
9408
  const strike = 1 === Number(toolbarCell?.cl);
9307
9409
  const textColor = 'string' == typeof toolbarCell?.fc ? toolbarCell.fc : '#172033';
9308
9410
  const fillColor = 'string' == typeof toolbarCell?.bg ? toolbarCell.bg : '#ffffff';
@@ -9369,15 +9471,10 @@ function SpreadsheetFontRibbonGroup({ can, commands, toolbarCell }) {
9369
9471
  size: 15
9370
9472
  })
9371
9473
  }),
9372
- /*#__PURE__*/ jsx(SpreadsheetFontToggle, {
9373
- active: underline,
9374
- attribute: "un",
9474
+ /*#__PURE__*/ jsx(SpreadsheetUnderlineRibbon, {
9375
9475
  can: can,
9376
9476
  commands: commands,
9377
- command: "underline",
9378
- icon: /*#__PURE__*/ jsx(Underline, {
9379
- size: 15
9380
- })
9477
+ value: toolbarCell?.un
9381
9478
  }),
9382
9479
  /*#__PURE__*/ jsx(SpreadsheetFontToggle, {
9383
9480
  active: strike,
@@ -12070,6 +12167,28 @@ const verticalOptions = [
12070
12167
  label: '底端对齐'
12071
12168
  }
12072
12169
  ];
12170
+ const spreadsheet_format_cells_dialog_panels_underlineOptions = [
12171
+ {
12172
+ value: 'none',
12173
+ label: '无'
12174
+ },
12175
+ {
12176
+ value: 'single',
12177
+ label: '单下划线'
12178
+ },
12179
+ {
12180
+ value: 'double',
12181
+ label: '双下划线'
12182
+ },
12183
+ {
12184
+ value: 'singleAccounting',
12185
+ label: '单会计用下划线'
12186
+ },
12187
+ {
12188
+ value: 'doubleAccounting',
12189
+ label: '双会计用下划线'
12190
+ }
12191
+ ];
12073
12192
  const borderStyleOptions = [
12074
12193
  {
12075
12194
  value: 'thin',
@@ -12302,6 +12421,7 @@ function AlignmentPanel({ source, draft, errors, touched, setDraft, touch }) {
12302
12421
  function FontPanel({ source, draft, errors, touched, setDraft, touch }) {
12303
12422
  const familyMixed = source.fields.fontFamily.mixed && !touched.fontFamily;
12304
12423
  const sizeMixed = source.fields.fontSize.mixed && !touched.fontSize;
12424
+ const underlineMixed = source.fields.underline.mixed && !touched.underline;
12305
12425
  const toggle = (field, checked)=>{
12306
12426
  touch(field);
12307
12427
  setDraft((current)=>({
@@ -12363,10 +12483,6 @@ function FontPanel({ source, draft, errors, touched, setDraft, touch }) {
12363
12483
  'italic',
12364
12484
  '斜体'
12365
12485
  ],
12366
- [
12367
- 'underline',
12368
- '下划线'
12369
- ],
12370
12486
  [
12371
12487
  'strike',
12372
12488
  '删除线'
@@ -12380,6 +12496,22 @@ function FontPanel({ source, draft, errors, touched, setDraft, touch }) {
12380
12496
  }, field))
12381
12497
  ]
12382
12498
  }),
12499
+ /*#__PURE__*/ jsx(Field, {
12500
+ label: "下划线",
12501
+ children: /*#__PURE__*/ jsx(OfficeSelect, {
12502
+ ariaLabel: "下划线样式",
12503
+ value: underlineMixed ? MIXED_VALUE : draft.underline,
12504
+ options: withMixedOption(spreadsheet_format_cells_dialog_panels_underlineOptions, underlineMixed),
12505
+ onValueChange: (value)=>{
12506
+ if (value === MIXED_VALUE) return;
12507
+ touch('underline');
12508
+ setDraft((current)=>({
12509
+ ...current,
12510
+ underline: value
12511
+ }));
12512
+ }
12513
+ })
12514
+ }),
12383
12515
  /*#__PURE__*/ jsx(Field, {
12384
12516
  label: "文字颜色",
12385
12517
  children: /*#__PURE__*/ jsx(OfficeColorPicker, {
@@ -12402,10 +12534,12 @@ function FontPanel({ source, draft, errors, touched, setDraft, touch }) {
12402
12534
  fontSize: `${Math.max(10, draft.fontSize)}px`,
12403
12535
  fontStyle: draft.italic ? 'italic' : 'normal',
12404
12536
  fontWeight: draft.bold ? 700 : 400,
12405
- textDecoration: [
12406
- draft.underline && 'underline',
12537
+ textDecorationLine: [
12538
+ 'none' !== draft.underline && 'underline',
12407
12539
  draft.strike && 'line-through'
12408
- ].filter(Boolean).join(' ')
12540
+ ].filter(Boolean).join(' '),
12541
+ textDecorationStyle: 'double' === draft.underline || 'doubleAccounting' === draft.underline ? 'double' : 'solid',
12542
+ textUnderlineOffset: 'singleAccounting' === draft.underline || 'doubleAccounting' === draft.underline ? '0.24em' : '0.12em'
12409
12543
  },
12410
12544
  children: "A3S Office 字体预览"
12411
12545
  })
@@ -12722,7 +12856,7 @@ function createSpreadsheetFormatCellsDialogSource(content, sheetId, rangeInput,
12722
12856
  fontColor: values((cell)=>normalizedColor(cell?.fc, '#172033')),
12723
12857
  bold: values((cell)=>1 === Number(cell?.bl)),
12724
12858
  italic: values((cell)=>1 === Number(cell?.it)),
12725
- underline: values((cell)=>1 === Number(cell?.un)),
12859
+ underline: values((cell)=>spreadsheetUnderlineStyle(cell?.un)),
12726
12860
  strike: values((cell)=>1 === Number(cell?.cl)),
12727
12861
  fillColor: values((cell)=>'string' == typeof cell?.bg && cell.bg.trim() ? normalizedColor(cell.bg, null) : null),
12728
12862
  borders: {
@@ -5,7 +5,7 @@ import { markDocxParagraphShading, inspectDocxPageSize, docxCaptionBookmark, has
5
5
  import { normalizeDocumentHref } from "./0~work-document-links.js";
6
6
  import { xmlAttributeLocalName, parseDocxParagraphDefaultCollapsed, readDocxBibliography, DOCX_WORDPROCESSING_NAMESPACES, xmlAttributeNamespace, createDocxThemeResolver } from "./0~2805.js";
7
7
  import { updateSpreadsheetWorksheetCompatibilitySummary, inspectXlsxPivotTables, isSupportedXlsxChartLegend, isSupportedXlsxChartPlotLayout, xlsxChartNodeUsesStackedGrouping, isSupportedXlsxChartSeriesFormatting, readXlsxFormulaFeaturesFromPackage, inspectXlsxHeaderFooterText, emptySpreadsheetWorksheetCompatibilitySummary, xlsxChartSeriesFormattingShapeProperties, MAX_XLSX_WORKSHEET_IMAGE_BYTES, isSupportedXlsxWorksheetImageContentType, xlsxWorksheetCellEntries, diagnoseXlsxProtection, isEditableXlsxPaperSizeCode, isSupportedXlsxCombinationChartNodes } from "./4104.js";
8
- import { spreadsheetConditionalComparisonNeedsUpperValue, isSpreadsheetConditionalIconSetName, isSpreadsheetConditionalComparisonOperator, spreadsheetConditionalIconSetCount } from "./2180.js";
8
+ import { spreadsheetConditionalComparisonNeedsUpperValue, isSpreadsheetConditionalIconSetName, isSpreadsheetConditionalComparisonOperator, spreadsheetConditionalIconSetCount } from "./1992.js";
9
9
  import { formulaHasStructuredReference, formulaHasExternalReference, parseSpreadsheetPrintTitles, volatileSpreadsheetFormulaFunctions, stripSpreadsheetSheetQualifier } from "./8715.js";
10
10
  import { unsupportedSpreadsheetFormulaFunctions } from "./0~work-spreadsheet-formula-support.js";
11
11
  var work_office_diagnostics_namespaceObject = {};
@@ -2092,6 +2092,64 @@ function isoDateFromTimestamp(timestamp) {
2092
2092
  if (!Number.isFinite(timestamp) || year < 1900 || year > 9999) return null;
2093
2093
  return `${String(year).padStart(4, '0')}-${String(date.getUTCMonth() + 1).padStart(2, '0')}-${String(date.getUTCDate()).padStart(2, '0')}`;
2094
2094
  }
2095
+ const spreadsheetUnderlineStyles = [
2096
+ 'none',
2097
+ 'single',
2098
+ 'double',
2099
+ 'singleAccounting',
2100
+ 'doubleAccounting'
2101
+ ];
2102
+ const underlineCellValues = {
2103
+ none: 0,
2104
+ single: 1,
2105
+ double: 2,
2106
+ singleAccounting: 3,
2107
+ doubleAccounting: 4
2108
+ };
2109
+ function isSpreadsheetUnderlineStyle(value) {
2110
+ return 'string' == typeof value && spreadsheetUnderlineStyles.includes(value);
2111
+ }
2112
+ function spreadsheetUnderlineCellValue(style) {
2113
+ return underlineCellValues[style];
2114
+ }
2115
+ function spreadsheetUnderlineStyle(value) {
2116
+ switch(Number(value)){
2117
+ case 1:
2118
+ return 'single';
2119
+ case 2:
2120
+ return 'double';
2121
+ case 3:
2122
+ case 0x21:
2123
+ return 'singleAccounting';
2124
+ case 4:
2125
+ case 0x22:
2126
+ return 'doubleAccounting';
2127
+ default:
2128
+ return 'none';
2129
+ }
2130
+ }
2131
+ function spreadsheetUnderlineCellValueFromXlsx(value) {
2132
+ switch(value?.trim()){
2133
+ case null:
2134
+ case void 0:
2135
+ case '':
2136
+ case 'single':
2137
+ return 1;
2138
+ case 'double':
2139
+ return 2;
2140
+ case 'singleAccounting':
2141
+ return 3;
2142
+ case 'doubleAccounting':
2143
+ return 4;
2144
+ default:
2145
+ return 0;
2146
+ }
2147
+ }
2148
+ function spreadsheetUnderlineCellValueFromSheetJs(value) {
2149
+ if (true === value) return 1;
2150
+ if (isSpreadsheetUnderlineStyle(value)) return spreadsheetUnderlineCellValue(value);
2151
+ return spreadsheetUnderlineCellValue(spreadsheetUnderlineStyle(value));
2152
+ }
2095
2153
  const SPREADSHEET_CONDITIONAL_COMPARISON_OPERATORS = [
2096
2154
  'greaterThan',
2097
2155
  'greaterThanOrEqual',
@@ -2585,4 +2643,4 @@ function boundedInteger(value, minimum, maximum, fallback) {
2585
2643
  function boundedNumber(value, minimum, maximum, fallback) {
2586
2644
  return 'number' == typeof value && Number.isFinite(value) && value >= minimum && value <= maximum ? value : fallback;
2587
2645
  }
2588
- export { DEFAULT_PROTECTION_HINT, SPREADSHEET_CONDITIONAL_COMPARISON_OPERATORS, SPREADSHEET_CONDITIONAL_ICON_SETS, attachSpreadsheetShownCommentCells, createWorkOfficeSpreadsheetCollaborationBinding as createOfficeSpreadsheetCollaborationBinding, defaultSpreadsheetColorScaleThresholds, defaultSpreadsheetConditionalIconThresholds, defaultSpreadsheetDataBarOptions, drawSpreadsheetConditionalIcon, editableRangeCellCount, editableRangeRequiresCredentials, effectiveSpreadsheetPageSetup, freezeImportedSpreadsheetCell, importedSheetProtectionAuthority, initializeWorkOfficeSpreadsheetCollaboration as initializeOfficeSpreadsheetCollaboration, isSpreadsheetConditionalComparisonOperator, isSpreadsheetConditionalIconSetName, normalizeSheetProtectionAuthority, normalizeSpreadsheetConditionalIconSetFormat, normalizeSpreadsheetConditionalVisualOptions, normalizeSpreadsheetDateValidationBoundary, normalizeSpreadsheetPaperSize, protectedSheetCount, readWorkOfficeSpreadsheetCollaboration as readOfficeSpreadsheetCollaboration, registerDerivedSpreadsheetMatrix, registerImportedSpreadsheetMatrix, replaceWorkOfficeSpreadsheetCollaboration as replaceOfficeSpreadsheetCollaboration, sameSpreadsheetHistoryValue, sheetHasProtectionState, sheetProtectionAuthority, spreadsheetConditionalComparisonNeedsUpperValue, spreadsheetConditionalIconForValue, spreadsheetConditionalIconSetCount, spreadsheetConditionalThresholdValue, spreadsheetConditionalThresholdsEqual, spreadsheetDateValidationFormula, spreadsheetMatrixProfile, spreadsheetProtectionKey, unlockedCellCount, withEditableRange, withSheetProtection, withSheetSelectionPermissions, withoutEditableRange };
2646
+ export { DEFAULT_PROTECTION_HINT, SPREADSHEET_CONDITIONAL_COMPARISON_OPERATORS, SPREADSHEET_CONDITIONAL_ICON_SETS, attachSpreadsheetShownCommentCells, createWorkOfficeSpreadsheetCollaborationBinding as createOfficeSpreadsheetCollaborationBinding, defaultSpreadsheetColorScaleThresholds, defaultSpreadsheetConditionalIconThresholds, defaultSpreadsheetDataBarOptions, drawSpreadsheetConditionalIcon, editableRangeCellCount, editableRangeRequiresCredentials, effectiveSpreadsheetPageSetup, freezeImportedSpreadsheetCell, importedSheetProtectionAuthority, initializeWorkOfficeSpreadsheetCollaboration as initializeOfficeSpreadsheetCollaboration, isSpreadsheetConditionalComparisonOperator, isSpreadsheetConditionalIconSetName, isSpreadsheetUnderlineStyle, normalizeSheetProtectionAuthority, normalizeSpreadsheetConditionalIconSetFormat, normalizeSpreadsheetConditionalVisualOptions, normalizeSpreadsheetDateValidationBoundary, normalizeSpreadsheetPaperSize, protectedSheetCount, readWorkOfficeSpreadsheetCollaboration as readOfficeSpreadsheetCollaboration, registerDerivedSpreadsheetMatrix, registerImportedSpreadsheetMatrix, replaceWorkOfficeSpreadsheetCollaboration as replaceOfficeSpreadsheetCollaboration, sameSpreadsheetHistoryValue, sheetHasProtectionState, sheetProtectionAuthority, spreadsheetConditionalComparisonNeedsUpperValue, spreadsheetConditionalIconForValue, spreadsheetConditionalIconSetCount, spreadsheetConditionalThresholdValue, spreadsheetConditionalThresholdsEqual, spreadsheetDateValidationFormula, spreadsheetMatrixProfile, spreadsheetProtectionKey, spreadsheetUnderlineCellValue, spreadsheetUnderlineCellValueFromSheetJs, spreadsheetUnderlineCellValueFromXlsx, spreadsheetUnderlineStyle, unlockedCellCount, withEditableRange, withSheetProtection, withSheetSelectionPermissions, withoutEditableRange };
package/dist/4104.js CHANGED
@@ -5,7 +5,7 @@ import { OFFICE_COLLABORATION_PROTOCOL as WORK_OFFICE_COLLABORATION_PROTOCOL, Of
5
5
  import { contentTypeForPart, directChildren, bytesToDataUrl, OoxmlPackage as work_ooxml_package_OoxmlPackage, parseXml, firstDescendant, xmlNamespacePrefix, descendants, directChild, createArtifact as createWorkArtifact, xmlContainsAnyElement, createOfficeId as createWorkId, attribute as work_ooxml_package_attribute } from "./5184.js";
6
6
  import { mountWorkLiveDocumentCapture, materializeWorkDocumentContent as work_document_model_codec_materializeWorkDocumentContent, documentPageSurfaceGeometryForElement, createWorkDocumentModel, documentContentLayoutProperties, documentModelForContent, createWorkDocumentExtensions, positionWorkLiveDocumentCapture } from "./6282.js";
7
7
  import { normalizeWorkSpreadsheetDataLabels, workSpreadsheetChartSupportsGrouping, normalizeSpreadsheetPrintArea, normalizeWorkSpreadsheetChartLegendPosition, formatSpreadsheetCellRanges, spreadsheetCellAddress, normalizeWorkSpreadsheetChartSmoothLines, spreadsheetFormulaRangeForCell, normalizeWorkSpreadsheetChartColor, readXlsxDrawingAnchor, sparseArrayEntries, qualifySpreadsheetRange, normalizeWorkSpreadsheetBubbleScale, normalizeWorkSpreadsheetChartSeriesStyle, normalizeSpreadsheetPrintTitleRows, normalizeSpreadsheetPrintTitleColumns, spreadsheetPivotFilterValueKey, normalizeWorkSpreadsheetErrorBars, normalizeWorkSpreadsheetBubbleSizeRepresents, workSpreadsheetChartSupportsTrendlines, stripSpreadsheetSheetQualifier, normalizeWorkSpreadsheetChartLegendOverlay, normalizeWorkSpreadsheetChartGapWidth, normalizeWorkSpreadsheetChartGrouping, workSpreadsheetChartSupportsBarSpacing, workSpreadsheetChartSupportsSmoothLines, workSpreadsheetChartGroupingIsStacked, xlsxDrawingAnchorToBounds, xlsxTwoCellAnchorMarkers, workSpreadsheetChartSupportsErrorBars, sparseMatrixColumnCount, refreshSpreadsheetPivotTables, normalizeWorkSpreadsheetChartAxisGroup, isValidSpreadsheetDefinedName, normalizeWorkSpreadsheetScatterStyle, workSpreadsheetChartAxisDefaultLabelPosition, spreadsheetPivotValidation, resolveSpreadsheetChart, parseSpreadsheetCellRanges, workSpreadsheetChartAxisIsCategoryAxis, spreadsheetPivotFields, normalizeWorkSpreadsheetDoughnutHoleSize, normalizeWorkSpreadsheetChartAxes, parseSpreadsheetPrintTitles, spreadsheetFormulaRangeConflict, spreadsheetFormulaForXlsx, editableSpreadsheetFormula, workSpreadsheetChartUsesNumericXAxis, normalizeWorkSpreadsheetChartOverlap, workSpreadsheetChartSupportsAxes, workSpreadsheetChartAxisShowsMajorGridlinesByDefault, normalizeWorkSpreadsheetCombinationSeriesType, effectiveSpreadsheetCalculationSettings, normalizeWorkSpreadsheetTrendline, normalizeWorkSpreadsheetRadarStyle } from "./8715.js";
8
- import { freezeImportedSpreadsheetCell, editableRangeRequiresCredentials, spreadsheetDateValidationFormula, normalizeSpreadsheetConditionalIconSetFormat, defaultSpreadsheetDataBarOptions, normalizeSpreadsheetConditionalVisualOptions, normalizeSpreadsheetPaperSize, normalizeSheetProtectionAuthority, importedSheetProtectionAuthority, defaultSpreadsheetColorScaleThresholds, sheetHasProtectionState, spreadsheetConditionalComparisonNeedsUpperValue, isSpreadsheetConditionalComparisonOperator, registerImportedSpreadsheetMatrix, defaultSpreadsheetConditionalIconThresholds, DEFAULT_PROTECTION_HINT, normalizeSpreadsheetDateValidationBoundary, isSpreadsheetConditionalIconSetName, spreadsheetConditionalThresholdsEqual, spreadsheetConditionalIconSetCount } from "./2180.js";
8
+ import { freezeImportedSpreadsheetCell, editableRangeRequiresCredentials, spreadsheetDateValidationFormula, normalizeSpreadsheetConditionalIconSetFormat, defaultSpreadsheetDataBarOptions, normalizeSpreadsheetConditionalVisualOptions, normalizeSpreadsheetPaperSize, normalizeSheetProtectionAuthority, importedSheetProtectionAuthority, defaultSpreadsheetColorScaleThresholds, spreadsheetUnderlineCellValueFromXlsx, sheetHasProtectionState, spreadsheetConditionalComparisonNeedsUpperValue, isSpreadsheetConditionalComparisonOperator, registerImportedSpreadsheetMatrix, defaultSpreadsheetConditionalIconThresholds, spreadsheetUnderlineStyle, DEFAULT_PROTECTION_HINT, isSpreadsheetConditionalIconSetName, normalizeSpreadsheetDateValidationBoundary, spreadsheetConditionalThresholdsEqual, spreadsheetUnderlineCellValueFromSheetJs, spreadsheetConditionalIconSetCount } from "./1992.js";
9
9
  import { WorkFileImportController, materializeWorkFileSource } from "./9356.js";
10
10
  import "./2591.js";
11
11
  import "./3818.js";
@@ -3385,11 +3385,11 @@ function setXlsxToggleChild(document1, parent, name, enabled, order) {
3385
3385
  child.setAttribute('val', '1');
3386
3386
  insertXlsxOrderedChild(parent, child, order);
3387
3387
  }
3388
- function setXlsxUnderlineChild(document1, parent, enabled, order) {
3388
+ function setXlsxUnderlineChild(document1, parent, style, order) {
3389
3389
  removeXlsxChildren(parent, 'u');
3390
- if (!enabled) return;
3390
+ if ('none' === style) return;
3391
3391
  const child = document1.createElementNS(document1.documentElement.namespaceURI, 'u');
3392
- child.setAttribute('val', 'single');
3392
+ child.setAttribute('val', style);
3393
3393
  insertXlsxOrderedChild(parent, child, order);
3394
3394
  }
3395
3395
  function xlsxRgbColor(value) {
@@ -3651,7 +3651,7 @@ function directFontStyle(cell) {
3651
3651
  strike: 1 === Number(cell.cl)
3652
3652
  } : {},
3653
3653
  ...void 0 !== cell.un ? {
3654
- underline: 1 === Number(cell.un)
3654
+ underline: spreadsheetUnderlineStyle(cell.un)
3655
3655
  } : {}
3656
3656
  };
3657
3657
  }
@@ -3971,7 +3971,10 @@ function readDirectFontStyle(style, font, colors) {
3971
3971
  const strike = directChild(font, 'strike');
3972
3972
  if (strike && toggleEnabled(strike)) style.cl = 1;
3973
3973
  const underline = directChild(font, 'u');
3974
- if (underline && underlineEnabled(underline)) style.un = 1;
3974
+ if (underline) {
3975
+ const value = spreadsheetUnderlineCellValueFromXlsx(work_ooxml_package_attribute(underline, 'val'));
3976
+ if (value) style.un = value;
3977
+ }
3975
3978
  const name = work_ooxml_package_attribute(directChild(font, 'name') ?? font, 'val')?.trim();
3976
3979
  if (name) style.ff = name;
3977
3980
  const size = Number(work_ooxml_package_attribute(directChild(font, 'sz') ?? font, 'val'));
@@ -4027,10 +4030,6 @@ function toggleEnabled(element) {
4027
4030
  const value = work_ooxml_package_attribute(element, 'val')?.trim().toLowerCase();
4028
4031
  return '0' !== value && 'false' !== value && 'off' !== value;
4029
4032
  }
4030
- function underlineEnabled(element) {
4031
- const value = work_ooxml_package_attribute(element, 'val')?.trim().toLowerCase();
4032
- return '0' !== value && 'false' !== value && 'none' !== value;
4033
- }
4034
4033
  function work_xlsx_cell_styles_booleanAttribute(element, name) {
4035
4034
  const value = work_ooxml_package_attribute(element, name)?.trim().toLowerCase();
4036
4035
  return '1' === value || 'true' === value || 'on' === value;
@@ -8566,7 +8565,7 @@ function fortuneCellStyle(source) {
8566
8565
  if (font?.bold) target.bl = 1;
8567
8566
  if (font?.italic) target.it = 1;
8568
8567
  if (font?.strike) target.cl = 1;
8569
- if (font?.underline) target.un = 1;
8568
+ if (font?.underline) target.un = spreadsheetUnderlineCellValueFromSheetJs(font.underline);
8570
8569
  if (font?.name) target.ff = font.name;
8571
8570
  if (font?.sz !== void 0) target.fs = font.sz;
8572
8571
  const fontColor = spreadsheetColor(font?.color?.rgb);
package/dist/core.js CHANGED
@@ -7,6 +7,6 @@ export { createArtifact, createOfficeId, officeTemplates } from "./5184.js";
7
7
  export { createOfficeDocumentCollaborationBinding, initializeOfficeDocumentCollaboration, officeDocumentCollaborationFragment, readOfficeDocumentCollaboration } from "./6282.js";
8
8
  export { createOfficeMarkdownCollaborationBinding, initializeOfficeMarkdownCollaboration, readOfficeMarkdownCollaboration, replaceOfficeMarkdownCollaboration } from "./2591.js";
9
9
  export { createOfficePresentationCollaborationBinding, initializeOfficePresentationCollaboration, readOfficePresentationCollaboration, replaceOfficePresentationCollaboration } from "./4560.js";
10
- export { createOfficeSpreadsheetCollaborationBinding, initializeOfficeSpreadsheetCollaboration, readOfficeSpreadsheetCollaboration, replaceOfficeSpreadsheetCollaboration } from "./2180.js";
10
+ export { createOfficeSpreadsheetCollaborationBinding, initializeOfficeSpreadsheetCollaboration, readOfficeSpreadsheetCollaboration, replaceOfficeSpreadsheetCollaboration } from "./1992.js";
11
11
  export { normalizeWorkSpreadsheetBubbleScale, normalizeWorkSpreadsheetBubbleSizeRepresents, normalizeWorkSpreadsheetChartAxisGroup, normalizeWorkSpreadsheetCombinationSeriesType, normalizeWorkSpreadsheetDataLabelPosition, normalizeWorkSpreadsheetDataLabels, normalizeWorkSpreadsheetDoughnutHoleSize, normalizeWorkSpreadsheetErrorBars, normalizeWorkSpreadsheetRadarStyle, normalizeWorkSpreadsheetScatterStyle, normalizeWorkSpreadsheetTrendline, normalizeWorkSpreadsheetTrendlineType, workSpreadsheetChartSupportsAxes, workSpreadsheetChartSupportsErrorBars, workSpreadsheetChartSupportsTrendlines, workSpreadsheetChartTypeLabel, workSpreadsheetChartUsesNumericXAxis, workSpreadsheetCombinationSeriesTypeLabel, workSpreadsheetDataLabelPositionLabel, workSpreadsheetErrorBarTypeLabel, workSpreadsheetErrorBarValueTypeLabel, workSpreadsheetTrendlineTypeLabel } from "./8715.js";
12
12
  export { core_OFFICE_COLLABORATION_VERSION as OFFICE_COLLABORATION_VERSION };
package/dist/index.js CHANGED
@@ -10,6 +10,6 @@ export { createArtifact, createOfficeId, officeTemplates } from "./5184.js";
10
10
  export { createOfficeDocumentCollaborationBinding, initializeOfficeDocumentCollaboration, officeDocumentCollaborationFragment, readOfficeDocumentCollaboration } from "./6282.js";
11
11
  export { createOfficeMarkdownCollaborationBinding, initializeOfficeMarkdownCollaboration, readOfficeMarkdownCollaboration, replaceOfficeMarkdownCollaboration } from "./2591.js";
12
12
  export { createOfficePresentationCollaborationBinding, initializeOfficePresentationCollaboration, readOfficePresentationCollaboration, replaceOfficePresentationCollaboration } from "./4560.js";
13
- export { createOfficeSpreadsheetCollaborationBinding, initializeOfficeSpreadsheetCollaboration, readOfficeSpreadsheetCollaboration, replaceOfficeSpreadsheetCollaboration } from "./2180.js";
13
+ export { createOfficeSpreadsheetCollaborationBinding, initializeOfficeSpreadsheetCollaboration, readOfficeSpreadsheetCollaboration, replaceOfficeSpreadsheetCollaboration } from "./1992.js";
14
14
  export { normalizeWorkSpreadsheetBubbleScale, normalizeWorkSpreadsheetBubbleSizeRepresents, normalizeWorkSpreadsheetChartAxisGroup, normalizeWorkSpreadsheetCombinationSeriesType, normalizeWorkSpreadsheetDataLabelPosition, normalizeWorkSpreadsheetDataLabels, normalizeWorkSpreadsheetDoughnutHoleSize, normalizeWorkSpreadsheetErrorBars, normalizeWorkSpreadsheetRadarStyle, normalizeWorkSpreadsheetScatterStyle, normalizeWorkSpreadsheetTrendline, normalizeWorkSpreadsheetTrendlineType, workSpreadsheetChartSupportsAxes, workSpreadsheetChartSupportsErrorBars, workSpreadsheetChartSupportsTrendlines, workSpreadsheetChartTypeLabel, workSpreadsheetChartUsesNumericXAxis, workSpreadsheetCombinationSeriesTypeLabel, workSpreadsheetDataLabelPositionLabel, workSpreadsheetErrorBarTypeLabel, workSpreadsheetErrorBarValueTypeLabel, workSpreadsheetTrendlineTypeLabel } from "./8715.js";
15
15
  export { src_DOCUMENT_SNAPSHOT_VERSION as DOCUMENT_SNAPSHOT_VERSION, src_DOCUMENT_SOURCE_VERSION as DOCUMENT_SOURCE_VERSION, src_OFFICE_COLLABORATION_VERSION as OFFICE_COLLABORATION_VERSION };
@@ -1,5 +1,6 @@
1
1
  import type { Cell } from '@fortune-sheet/core';
2
2
  import type { WorkSpreadsheetContent, WorkSpreadsheetSheet } from '../work-types';
3
+ import { type SpreadsheetUnderlineStyle } from '../work-spreadsheet-underline';
3
4
  import { type SpreadsheetCellBorderFormat } from './spreadsheet-cell-border';
4
5
  import { type SpreadsheetCellRange } from './spreadsheet-cell-range';
5
6
  export declare const MAX_SPREADSHEET_CELL_FORMAT_CELLS = 10000;
@@ -16,7 +17,7 @@ export interface SpreadsheetCellFormatPatch {
16
17
  fontColor?: string;
17
18
  bold?: boolean;
18
19
  italic?: boolean;
19
- underline?: boolean;
20
+ underline?: SpreadsheetUnderlineStyle;
20
21
  strike?: boolean;
21
22
  fillColor?: string | null;
22
23
  borders?: readonly SpreadsheetCellBorderFormat[];
@@ -1,5 +1,6 @@
1
1
  import type { Cell } from '@fortune-sheet/core';
2
2
  import type { WorkSpreadsheetContent } from '../work-types';
3
+ import { type SpreadsheetUnderlineStyle } from '../work-spreadsheet-underline';
3
4
  import { type SpreadsheetCellBorderFormat, type SpreadsheetCellBorderStyle } from './spreadsheet-cell-border';
4
5
  import { type SpreadsheetCellFormatPatch, type SpreadsheetHorizontalAlignment, type SpreadsheetVerticalAlignment } from './spreadsheet-cell-format';
5
6
  import { type SpreadsheetCellRange } from './spreadsheet-cell-range';
@@ -38,7 +39,7 @@ export interface SpreadsheetFormatCellsFields {
38
39
  fontColor: SpreadsheetFormatCellsField<string>;
39
40
  bold: SpreadsheetFormatCellsField<boolean>;
40
41
  italic: SpreadsheetFormatCellsField<boolean>;
41
- underline: SpreadsheetFormatCellsField<boolean>;
42
+ underline: SpreadsheetFormatCellsField<SpreadsheetUnderlineStyle>;
42
43
  strike: SpreadsheetFormatCellsField<boolean>;
43
44
  fillColor: SpreadsheetFormatCellsField<string | null>;
44
45
  borders: SpreadsheetFormatCellsField<readonly SpreadsheetCellBorderFormat[]>;
@@ -62,7 +63,7 @@ export interface SpreadsheetFormatCellsDraft {
62
63
  fontColor: string;
63
64
  bold: boolean;
64
65
  italic: boolean;
65
- underline: boolean;
66
+ underline: SpreadsheetUnderlineStyle;
66
67
  strike: boolean;
67
68
  fillColor: string | null;
68
69
  borders: SpreadsheetCellBorderFormat[];
@@ -0,0 +1,6 @@
1
+ import type { SpreadsheetEditorCanCommands, SpreadsheetEditorCommands } from './spreadsheet-command-controller';
2
+ export declare function SpreadsheetUnderlineRibbon({ can, commands, value, }: {
3
+ can: SpreadsheetEditorCanCommands;
4
+ commands: SpreadsheetEditorCommands;
5
+ value: unknown;
6
+ }): import("react").JSX.Element;
@@ -0,0 +1,8 @@
1
+ export declare const spreadsheetUnderlineStyles: readonly ["none", "single", "double", "singleAccounting", "doubleAccounting"];
2
+ export type SpreadsheetUnderlineStyle = (typeof spreadsheetUnderlineStyles)[number];
3
+ export type SpreadsheetUnderlineCellValue = 0 | 1 | 2 | 3 | 4;
4
+ export declare function isSpreadsheetUnderlineStyle(value: unknown): value is SpreadsheetUnderlineStyle;
5
+ export declare function spreadsheetUnderlineCellValue(style: SpreadsheetUnderlineStyle): SpreadsheetUnderlineCellValue;
6
+ export declare function spreadsheetUnderlineStyle(value: unknown): SpreadsheetUnderlineStyle;
7
+ export declare function spreadsheetUnderlineCellValueFromXlsx(value: string | null): SpreadsheetUnderlineCellValue;
8
+ export declare function spreadsheetUnderlineCellValueFromSheetJs(value: unknown): SpreadsheetUnderlineCellValue;
@@ -1,4 +1,5 @@
1
1
  import type { XlsxCellBorderLine } from './work-xlsx-cell-borders';
2
+ import type { SpreadsheetUnderlineStyle } from './work-spreadsheet-underline';
2
3
  export interface XlsxDirectAlignmentStyle {
3
4
  horizontal?: 'center' | 'left' | 'right';
4
5
  textRotation?: number;
@@ -13,5 +14,5 @@ export declare function writeXlsxAlignment(document: Document, xf: Element, styl
13
14
  export declare function setXlsxValueChild(document: Document, parent: Element, name: string, value: string, order: readonly string[]): void;
14
15
  export declare function setXlsxColorChild(document: Document, parent: Element, color: string, order: readonly string[]): void;
15
16
  export declare function setXlsxToggleChild(document: Document, parent: Element, name: string, enabled: boolean, order: readonly string[]): void;
16
- export declare function setXlsxUnderlineChild(document: Document, parent: Element, enabled: boolean, order: readonly string[]): void;
17
+ export declare function setXlsxUnderlineChild(document: Document, parent: Element, style: SpreadsheetUnderlineStyle, order: readonly string[]): void;
17
18
  export declare function xlsxRgbColor(value: unknown): string | null;
Binary file
package/dist/styles.css CHANGED
@@ -15138,7 +15138,7 @@ button.work-office-collaboration-participant:hover .work-office-collaboration-lo
15138
15138
  }
15139
15139
  }
15140
15140
 
15141
- .work-spreadsheet-border-split-root {
15141
+ .work-spreadsheet-border-split-root, .work-spreadsheet-underline-split-root {
15142
15142
  border-radius: 6px;
15143
15143
  flex: none;
15144
15144
  align-items: stretch;
@@ -15146,6 +15146,118 @@ button.work-office-collaboration-participant:hover .work-office-collaboration-lo
15146
15146
  display: inline-flex;
15147
15147
  }
15148
15148
 
15149
+ .work-office-ribbon .work-office-toolbar .work-spreadsheet-underline-primary, .work-office-ribbon .work-office-toolbar .work-spreadsheet-underline-disclosure {
15150
+ border-radius: 0;
15151
+ height: 29px;
15152
+ padding: 0;
15153
+ }
15154
+
15155
+ .work-office-ribbon .work-office-toolbar .work-spreadsheet-underline-primary {
15156
+ border-radius: 6px 0 0 6px;
15157
+ width: 29px;
15158
+ min-width: 29px;
15159
+ }
15160
+
15161
+ .work-office-ribbon .work-office-toolbar .work-spreadsheet-underline-disclosure {
15162
+ border-left: 1px solid color-mix(in srgb, var(--a3s-line) 72%, transparent);
15163
+ border-radius: 0 6px 6px 0;
15164
+ width: 16px;
15165
+ min-width: 16px;
15166
+ }
15167
+
15168
+ .work-spreadsheet-underline-disclosure svg {
15169
+ transition: transform .12s;
15170
+ }
15171
+
15172
+ .work-spreadsheet-underline-disclosure[aria-expanded="true"] svg {
15173
+ transform: rotate(180deg);
15174
+ }
15175
+
15176
+ .work-spreadsheet-underline-primary:focus-visible, .work-spreadsheet-underline-disclosure:focus-visible {
15177
+ box-shadow: inset 0 0 0 1px var(--work-spreadsheet-accent);
15178
+ outline: 0;
15179
+ }
15180
+
15181
+ .work-spreadsheet-underline-menu {
15182
+ width: min(252px, 100vw - 32px);
15183
+ }
15184
+
15185
+ .work-spreadsheet-underline-menu > button {
15186
+ grid-template-columns: 22px minmax(0, 1fr) 14px;
15187
+ }
15188
+
15189
+ .work-spreadsheet-underline-menu > button[aria-checked="true"] {
15190
+ background: color-mix(in srgb,
15191
+ var(--work-office-menu-accent) 9%,
15192
+ transparent);
15193
+ }
15194
+
15195
+ .work-spreadsheet-underline-menu > button[aria-checked="true"]:after {
15196
+ color: var(--work-office-menu-accent);
15197
+ content: "✓";
15198
+ text-align: center;
15199
+ grid-column: 3;
15200
+ font-size: 12px;
15201
+ font-weight: 700;
15202
+ }
15203
+
15204
+ .work-spreadsheet-underline-glyph {
15205
+ width: 20px;
15206
+ height: 20px;
15207
+ color: var(--work-office-menu-accent);
15208
+ place-items: center;
15209
+ display: grid;
15210
+ position: relative;
15211
+ }
15212
+
15213
+ .work-spreadsheet-underline-glyph[data-underline-style="none"] {
15214
+ opacity: .42;
15215
+ }
15216
+
15217
+ .work-spreadsheet-underline-glyph[data-underline-style="none"]:after {
15218
+ content: "";
15219
+ background: currentColor;
15220
+ width: 18px;
15221
+ height: 1px;
15222
+ position: absolute;
15223
+ transform: rotate(-38deg);
15224
+ }
15225
+
15226
+ .work-spreadsheet-underline-glyph[data-underline-style="double"]:before {
15227
+ content: "";
15228
+ background: currentColor;
15229
+ height: 1px;
15230
+ position: absolute;
15231
+ bottom: 1px;
15232
+ left: 2px;
15233
+ right: 2px;
15234
+ }
15235
+
15236
+ .work-spreadsheet-underline-glyph[data-underline-style="singleAccounting"] svg line, .work-spreadsheet-underline-glyph[data-underline-style="doubleAccounting"] svg line {
15237
+ display: none;
15238
+ }
15239
+
15240
+ .work-spreadsheet-underline-glyph[data-underline-style="singleAccounting"]:after, .work-spreadsheet-underline-glyph[data-underline-style="doubleAccounting"]:before, .work-spreadsheet-underline-glyph[data-underline-style="doubleAccounting"]:after {
15241
+ content: "";
15242
+ background: currentColor;
15243
+ height: 1px;
15244
+ position: absolute;
15245
+ left: 0;
15246
+ right: 0;
15247
+ }
15248
+
15249
+ .work-spreadsheet-underline-glyph[data-underline-style="singleAccounting"]:after {
15250
+ bottom: 1px;
15251
+ }
15252
+
15253
+ .work-spreadsheet-underline-glyph[data-underline-style="doubleAccounting"]:before {
15254
+ bottom: 3px;
15255
+ }
15256
+
15257
+ .work-spreadsheet-underline-glyph[data-underline-style="doubleAccounting"]:after {
15258
+ bottom: 0;
15259
+ }
15260
+
15149
15261
  .work-office-ribbon .work-office-toolbar .work-spreadsheet-border-primary, .work-office-ribbon .work-office-toolbar .work-spreadsheet-border-disclosure {
15150
15262
  border-radius: 0;
15151
15263
  height: 29px;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@a3s-lab/office",
3
- "version": "0.17.0",
3
+ "version": "0.18.0",
4
4
  "description": "Open-source collaborative browser editors for documents, Markdown, spreadsheets, presentations, and PDFs.",
5
5
  "keywords": [
6
6
  "office",
@@ -90,6 +90,7 @@
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-hyperlink": "playwright test visual-tests/spreadsheet-hyperlink.functional.spec.ts --config playwright.config.ts",
92
92
  "playground:visual:spreadsheet-ribbon": "playwright test visual-tests/spreadsheet-ribbon.functional.spec.ts --config playwright.config.ts",
93
+ "playground:visual:spreadsheet-underline": "playwright test visual-tests/spreadsheet-underline.functional.spec.ts --config playwright.config.ts",
93
94
  "playground:visual:spreadsheet-table": "playwright test visual-tests/spreadsheet-table.functional.spec.ts --config playwright.config.ts",
94
95
  "playground:visual:update": "playwright test --config playwright.config.ts --update-snapshots",
95
96
  "performance:fixtures": "bun .a3s-test/performance/generate-fixtures.ts",
@@ -137,6 +138,8 @@
137
138
  "test:e2e:spreadsheet-cell-style:check": "a3s-test check tests/e2e/spreadsheet-cell-style.acl --json",
138
139
  "test:e2e:spreadsheet-font-size-border-shortcuts": "a3s-test run tests/e2e/spreadsheet-font-size-border-shortcuts.acl --json",
139
140
  "test:e2e:spreadsheet-font-size-border-shortcuts:check": "a3s-test check tests/e2e/spreadsheet-font-size-border-shortcuts.acl --json",
141
+ "test:e2e:spreadsheet-underline-styles": "a3s-test run tests/e2e/spreadsheet-underline-styles.acl --json",
142
+ "test:e2e:spreadsheet-underline-styles:check": "a3s-test check tests/e2e/spreadsheet-underline-styles.acl --json",
140
143
  "test:e2e:spreadsheet-table": "a3s-test run tests/e2e/spreadsheet-table.acl --json",
141
144
  "test:e2e:spreadsheet-table:check": "a3s-test check tests/e2e/spreadsheet-table.acl --json",
142
145
  "test:e2e:spreadsheet-cell-fill": "a3s-test run tests/e2e/spreadsheet-cell-fill.acl --json",