@a3s-lab/office 0.19.0 → 0.21.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.
@@ -2092,63 +2092,58 @@ 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';
2095
+ const A3S_DIAGONAL_BORDER_KEY = 'a3sDiagonal';
2096
+ function spreadsheetDiagonalBorderFromCellValue(value) {
2097
+ if (!isRecord(value)) return;
2098
+ const metadata = value[A3S_DIAGONAL_BORDER_KEY];
2099
+ if (isRecord(metadata)) {
2100
+ const up = metadata.up;
2101
+ const down = metadata.down;
2102
+ const line = spreadsheetDiagonalBorderLine(metadata.line);
2103
+ if ('boolean' == typeof up && 'boolean' == typeof down) {
2104
+ if (!up && !down) return null;
2105
+ if (line) return {
2106
+ down,
2107
+ line,
2108
+ up
2109
+ };
2110
+ }
2129
2111
  }
2112
+ if (null === value.s) return null;
2113
+ const legacyLine = spreadsheetDiagonalBorderLine(value.s);
2114
+ return legacyLine ? {
2115
+ down: true,
2116
+ line: legacyLine,
2117
+ up: false
2118
+ } : void 0;
2119
+ }
2120
+ function spreadsheetCellValueWithDiagonalBorder(value, border) {
2121
+ const next = {
2122
+ ...value
2123
+ };
2124
+ delete next.s;
2125
+ delete next[A3S_DIAGONAL_BORDER_KEY];
2126
+ if (!border) return next;
2127
+ const line = {
2128
+ ...border.line
2129
+ };
2130
+ next[A3S_DIAGONAL_BORDER_KEY] = {
2131
+ down: border.down,
2132
+ line,
2133
+ up: border.up
2134
+ };
2135
+ if (border.down) next.s = line;
2136
+ return next;
2137
+ }
2138
+ function spreadsheetDiagonalBorderLine(value) {
2139
+ if (!isRecord(value)) return null;
2140
+ return 'string' == typeof value.color && 'string' == typeof value.style ? {
2141
+ color: value.color,
2142
+ style: value.style
2143
+ } : null;
2130
2144
  }
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));
2145
+ function isRecord(value) {
2146
+ return Boolean(value && 'object' == typeof value && !Array.isArray(value));
2152
2147
  }
2153
2148
  const spreadsheetTextOrientationIds = [
2154
2149
  'horizontal',
@@ -2256,6 +2251,64 @@ function integer(value) {
2256
2251
  const parsed = 'number' == typeof value ? value : Number(value);
2257
2252
  return Number.isSafeInteger(parsed) ? parsed : null;
2258
2253
  }
2254
+ const spreadsheetUnderlineStyles = [
2255
+ 'none',
2256
+ 'single',
2257
+ 'double',
2258
+ 'singleAccounting',
2259
+ 'doubleAccounting'
2260
+ ];
2261
+ const underlineCellValues = {
2262
+ none: 0,
2263
+ single: 1,
2264
+ double: 2,
2265
+ singleAccounting: 3,
2266
+ doubleAccounting: 4
2267
+ };
2268
+ function isSpreadsheetUnderlineStyle(value) {
2269
+ return 'string' == typeof value && spreadsheetUnderlineStyles.includes(value);
2270
+ }
2271
+ function spreadsheetUnderlineCellValue(style) {
2272
+ return underlineCellValues[style];
2273
+ }
2274
+ function spreadsheetUnderlineStyle(value) {
2275
+ switch(Number(value)){
2276
+ case 1:
2277
+ return 'single';
2278
+ case 2:
2279
+ return 'double';
2280
+ case 3:
2281
+ case 0x21:
2282
+ return 'singleAccounting';
2283
+ case 4:
2284
+ case 0x22:
2285
+ return 'doubleAccounting';
2286
+ default:
2287
+ return 'none';
2288
+ }
2289
+ }
2290
+ function spreadsheetUnderlineCellValueFromXlsx(value) {
2291
+ switch(value?.trim()){
2292
+ case null:
2293
+ case void 0:
2294
+ case '':
2295
+ case 'single':
2296
+ return 1;
2297
+ case 'double':
2298
+ return 2;
2299
+ case 'singleAccounting':
2300
+ return 3;
2301
+ case 'doubleAccounting':
2302
+ return 4;
2303
+ default:
2304
+ return 0;
2305
+ }
2306
+ }
2307
+ function spreadsheetUnderlineCellValueFromSheetJs(value) {
2308
+ if (true === value) return 1;
2309
+ if (isSpreadsheetUnderlineStyle(value)) return spreadsheetUnderlineCellValue(value);
2310
+ return spreadsheetUnderlineCellValue(spreadsheetUnderlineStyle(value));
2311
+ }
2259
2312
  const SPREADSHEET_CONDITIONAL_COMPARISON_OPERATORS = [
2260
2313
  'greaterThan',
2261
2314
  'greaterThanOrEqual',
@@ -2749,4 +2802,4 @@ function boundedInteger(value, minimum, maximum, fallback) {
2749
2802
  function boundedNumber(value, minimum, maximum, fallback) {
2750
2803
  return 'number' == typeof value && Number.isFinite(value) && value >= minimum && value <= maximum ? value : fallback;
2751
2804
  }
2752
- 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, isSpreadsheetTextOrientationId, isSpreadsheetUnderlineStyle, normalizeSheetProtectionAuthority, normalizeSpreadsheetConditionalIconSetFormat, normalizeSpreadsheetConditionalVisualOptions, normalizeSpreadsheetDateValidationBoundary, normalizeSpreadsheetPaperSize, protectedSheetCount, readWorkOfficeSpreadsheetCollaboration as readOfficeSpreadsheetCollaboration, registerDerivedSpreadsheetMatrix, registerImportedSpreadsheetMatrix, replaceWorkOfficeSpreadsheetCollaboration as replaceOfficeSpreadsheetCollaboration, sameSpreadsheetHistoryValue, sheetHasProtectionState, sheetProtectionAuthority, spreadsheetConditionalComparisonNeedsUpperValue, spreadsheetConditionalIconForValue, spreadsheetConditionalIconSetCount, spreadsheetConditionalThresholdValue, spreadsheetConditionalThresholdsEqual, spreadsheetDateValidationFormula, spreadsheetExplicitTextOrientationFromCell, spreadsheetMatrixProfile, spreadsheetProtectionKey, spreadsheetTextOrientationCellStyle, spreadsheetTextOrientationChoiceFromCell, spreadsheetTextOrientationFromAngle, spreadsheetTextOrientationFromCell, spreadsheetTextOrientationFromChoice, spreadsheetTextOrientationFromXlsx, spreadsheetTextOrientationXlsxValueFromCell, spreadsheetUnderlineCellValue, spreadsheetUnderlineCellValueFromSheetJs, spreadsheetUnderlineCellValueFromXlsx, spreadsheetUnderlineStyle, spreadsheetVisibleTextRotationFromCell, unlockedCellCount, withEditableRange, withSheetProtection, withSheetSelectionPermissions, withoutEditableRange };
2805
+ 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, isSpreadsheetTextOrientationId, isSpreadsheetUnderlineStyle, normalizeSheetProtectionAuthority, normalizeSpreadsheetConditionalIconSetFormat, normalizeSpreadsheetConditionalVisualOptions, normalizeSpreadsheetDateValidationBoundary, normalizeSpreadsheetPaperSize, protectedSheetCount, readWorkOfficeSpreadsheetCollaboration as readOfficeSpreadsheetCollaboration, registerDerivedSpreadsheetMatrix, registerImportedSpreadsheetMatrix, replaceWorkOfficeSpreadsheetCollaboration as replaceOfficeSpreadsheetCollaboration, sameSpreadsheetHistoryValue, sheetHasProtectionState, sheetProtectionAuthority, spreadsheetCellValueWithDiagonalBorder, spreadsheetConditionalComparisonNeedsUpperValue, spreadsheetConditionalIconForValue, spreadsheetConditionalIconSetCount, spreadsheetConditionalThresholdValue, spreadsheetConditionalThresholdsEqual, spreadsheetDateValidationFormula, spreadsheetDiagonalBorderFromCellValue, spreadsheetExplicitTextOrientationFromCell, spreadsheetMatrixProfile, spreadsheetProtectionKey, spreadsheetTextOrientationCellStyle, spreadsheetTextOrientationChoiceFromCell, spreadsheetTextOrientationFromAngle, spreadsheetTextOrientationFromCell, spreadsheetTextOrientationFromChoice, spreadsheetTextOrientationFromXlsx, spreadsheetTextOrientationXlsxValueFromCell, spreadsheetUnderlineCellValue, spreadsheetUnderlineCellValueFromSheetJs, spreadsheetUnderlineCellValueFromXlsx, spreadsheetUnderlineStyle, spreadsheetVisibleTextRotationFromCell, unlockedCellCount, withEditableRange, withSheetProtection, withSheetSelectionPermissions, withoutEditableRange };
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 "./6164.js";
10
+ export { createOfficeSpreadsheetCollaborationBinding, initializeOfficeSpreadsheetCollaboration, readOfficeSpreadsheetCollaboration, replaceOfficeSpreadsheetCollaboration } from "./5045.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 "./6164.js";
13
+ export { createOfficeSpreadsheetCollaborationBinding, initializeOfficeSpreadsheetCollaboration, readOfficeSpreadsheetCollaboration, replaceOfficeSpreadsheetCollaboration } from "./5045.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,11 +1,16 @@
1
1
  import { type ReactNode } from 'react';
2
- export declare function OfficeColorPicker({ ariaLabel, value, onValueChange, disabled, compact, className, triggerLabel, triggerIcon, }: {
2
+ export declare function OfficeColorPicker({ ariaLabel, value, onValueChange, disabled, compact, className, resetAction, triggerLabel, triggerIcon, }: {
3
3
  ariaLabel: string;
4
4
  value: string;
5
5
  onValueChange: (value: string) => void;
6
6
  disabled?: boolean;
7
7
  compact?: boolean;
8
8
  className?: string;
9
+ resetAction?: {
10
+ kind: 'automatic' | 'none';
11
+ label: string;
12
+ onSelect: () => void;
13
+ };
9
14
  triggerLabel?: string;
10
15
  triggerIcon?: ReactNode;
11
16
  }): import("react").JSX.Element;
@@ -1,6 +1,6 @@
1
1
  import type { WorkSpreadsheetContent, WorkSpreadsheetSheet } from '../work-types';
2
2
  import { type SpreadsheetCellRangeInput } from './spreadsheet-cell-range';
3
- export declare const spreadsheetCellBorderTargets: readonly ["top", "bottom", "left", "right", "none", "all", "outside", "inside", "horizontal", "vertical", "diagonal"];
3
+ export declare const spreadsheetCellBorderTargets: readonly ["top", "bottom", "left", "right", "none", "all", "outside", "inside", "horizontal", "vertical", "diagonalDown", "diagonalUp"];
4
4
  export type SpreadsheetCellBorderTarget = (typeof spreadsheetCellBorderTargets)[number];
5
5
  export declare const spreadsheetCellBorderStyles: readonly ["thin", "dotted", "dashed", "dash-dot", "dash-dot-dot", "medium", "medium-dashed", "medium-dash-dot", "medium-dash-dot-dot", "thick"];
6
6
  export type SpreadsheetCellBorderStyle = (typeof spreadsheetCellBorderStyles)[number];
@@ -15,14 +15,20 @@ export interface SpreadsheetResolvedCellBorderLine {
15
15
  }
16
16
  export interface SpreadsheetResolvedCellBorders {
17
17
  bottom?: SpreadsheetResolvedCellBorderLine;
18
- diagonal?: SpreadsheetResolvedCellBorderLine;
18
+ diagonalDown?: SpreadsheetResolvedCellBorderLine;
19
+ diagonalUp?: SpreadsheetResolvedCellBorderLine;
19
20
  left?: SpreadsheetResolvedCellBorderLine;
20
21
  right?: SpreadsheetResolvedCellBorderLine;
21
22
  top?: SpreadsheetResolvedCellBorderLine;
22
23
  }
24
+ export interface SpreadsheetRenderableDiagonalBorders {
25
+ down?: SpreadsheetResolvedCellBorderLine;
26
+ up?: SpreadsheetResolvedCellBorderLine;
27
+ }
23
28
  export declare const MAX_SPREADSHEET_DIAGONAL_BORDER_CELLS = 4096;
24
29
  export declare function spreadsheetNativeBorderStyle(style: SpreadsheetCellBorderStyle): string;
25
30
  export declare function canSetSpreadsheetCellBorders(content: WorkSpreadsheetContent, sheetId: string, range: SpreadsheetCellRangeInput, format: SpreadsheetCellBorderFormat): boolean;
26
31
  export declare function setSpreadsheetCellBorders(content: WorkSpreadsheetContent, sheetId: string, range: SpreadsheetCellRangeInput, format: SpreadsheetCellBorderFormat): WorkSpreadsheetContent | null;
27
32
  export declare function spreadsheetCellBordersAt(sheet: WorkSpreadsheetSheet | undefined, row: number, column: number): SpreadsheetResolvedCellBorders;
33
+ export declare function spreadsheetRenderableDiagonalBorders(sheet: WorkSpreadsheetSheet): ReadonlyMap<string, SpreadsheetRenderableDiagonalBorders>;
28
34
  export declare function normalizeSpreadsheetBorderFormat(format: SpreadsheetCellBorderFormat): SpreadsheetCellBorderFormat | null;
@@ -146,9 +146,9 @@ export declare const spreadsheetCommandCatalog: {
146
146
  readonly group: "font";
147
147
  };
148
148
  readonly shortcut: {
149
- readonly label: "Cmd/Ctrl+B";
150
- readonly aria: "Control+B Meta+B";
151
- readonly editor: readonly ["Mod-b"];
149
+ readonly label: "Cmd/Ctrl+B 或 Ctrl+2";
150
+ readonly aria: "Control+B Meta+B Control+2";
151
+ readonly editor: readonly ["Mod-b", "Control-2"];
152
152
  };
153
153
  };
154
154
  readonly italic: {
@@ -160,9 +160,9 @@ export declare const spreadsheetCommandCatalog: {
160
160
  readonly group: "font";
161
161
  };
162
162
  readonly shortcut: {
163
- readonly label: "Cmd/Ctrl+I";
164
- readonly aria: "Control+I Meta+I";
165
- readonly editor: readonly ["Mod-i"];
163
+ readonly label: "Cmd/Ctrl+I 或 Ctrl+3";
164
+ readonly aria: "Control+I Meta+I Control+3";
165
+ readonly editor: readonly ["Mod-i", "Control-3"];
166
166
  };
167
167
  };
168
168
  readonly underline: {
@@ -174,9 +174,9 @@ export declare const spreadsheetCommandCatalog: {
174
174
  readonly group: "font";
175
175
  };
176
176
  readonly shortcut: {
177
- readonly label: "Cmd/Ctrl+U";
178
- readonly aria: "Control+U Meta+U";
179
- readonly editor: readonly ["Mod-u"];
177
+ readonly label: "Cmd/Ctrl+U 或 Ctrl+4";
178
+ readonly aria: "Control+U Meta+U Control+4";
179
+ readonly editor: readonly ["Mod-u", "Control-4"];
180
180
  };
181
181
  };
182
182
  readonly strike: {
@@ -478,9 +478,18 @@ export declare const spreadsheetCommandCatalog: {
478
478
  readonly group: "font";
479
479
  };
480
480
  };
481
- readonly borderDiagonal: {
482
- readonly id: "font.borderDiagonal";
483
- readonly label: "斜线框线";
481
+ readonly borderDiagonalDown: {
482
+ readonly id: "font.borderDiagonalDown";
483
+ readonly label: "斜下框线";
484
+ readonly location: {
485
+ readonly area: "ribbon";
486
+ readonly tab: "home";
487
+ readonly group: "font";
488
+ };
489
+ };
490
+ readonly borderDiagonalUp: {
491
+ readonly id: "font.borderDiagonalUp";
492
+ readonly label: "斜上框线";
484
493
  readonly location: {
485
494
  readonly area: "ribbon";
486
495
  readonly tab: "home";
@@ -0,0 +1,12 @@
1
+ export interface SpreadsheetDiagonalBorderBounds {
2
+ endX: number;
3
+ endY: number;
4
+ startX: number;
5
+ startY: number;
6
+ }
7
+ export interface SpreadsheetDiagonalCanvasLine {
8
+ color: string;
9
+ style: string;
10
+ }
11
+ export declare function drawSpreadsheetDiagonalDownBorder(context: CanvasRenderingContext2D, bounds: SpreadsheetDiagonalBorderBounds, line: SpreadsheetDiagonalCanvasLine): void;
12
+ export declare function drawSpreadsheetDiagonalUpBorder(context: CanvasRenderingContext2D, bounds: SpreadsheetDiagonalBorderBounds, line: SpreadsheetDiagonalCanvasLine): void;
@@ -0,0 +1,13 @@
1
+ export interface WorkSpreadsheetDiagonalBorderLine {
2
+ color: string;
3
+ style: string;
4
+ }
5
+ export interface WorkSpreadsheetDiagonalBorder {
6
+ down: boolean;
7
+ line: WorkSpreadsheetDiagonalBorderLine;
8
+ up: boolean;
9
+ }
10
+ type UnknownRecord = Record<string, unknown>;
11
+ export declare function spreadsheetDiagonalBorderFromCellValue(value: unknown): WorkSpreadsheetDiagonalBorder | null | undefined;
12
+ export declare function spreadsheetCellValueWithDiagonalBorder(value: UnknownRecord, border: WorkSpreadsheetDiagonalBorder | null): UnknownRecord;
13
+ export {};
@@ -0,0 +1,44 @@
1
+ import type { Cell } from '@fortune-sheet/core';
2
+ import { type XlsxColorResolver } from './work-xlsx-colors';
3
+ export type XlsxSemanticColorOrigin = {
4
+ kind: 'automatic';
5
+ baseColor: string;
6
+ renderedColor: string;
7
+ tint?: number;
8
+ } | {
9
+ kind: 'indexed';
10
+ baseColor: string;
11
+ index: number;
12
+ renderedColor: string;
13
+ tint?: number;
14
+ } | {
15
+ kind: 'theme';
16
+ baseColor: string;
17
+ index: number;
18
+ renderedColor: string;
19
+ tint?: number;
20
+ };
21
+ export type XlsxBorderColorOrigins = Partial<Record<'bottom' | 'diagonal' | 'left' | 'right' | 'top', XlsxSemanticColorOrigin>>;
22
+ export interface XlsxCellStyleOrigin {
23
+ borderColors?: XlsxBorderColorOrigins;
24
+ fillColor?: XlsxSemanticColorOrigin;
25
+ fontColor?: XlsxSemanticColorOrigin;
26
+ }
27
+ export interface XlsxSemanticPalette {
28
+ indexed: ReadonlyMap<number, string>;
29
+ theme: ReadonlyMap<number, string>;
30
+ }
31
+ export interface PreparedXlsxSemanticPalette {
32
+ palette: XlsxSemanticPalette;
33
+ stylesChanged: boolean;
34
+ themeChanged: boolean;
35
+ }
36
+ export declare function readXlsxSemanticColorOrigin(element: Element | undefined, colors: XlsxColorResolver): XlsxSemanticColorOrigin | undefined;
37
+ export declare function withXlsxCellStyleOrigin(cell: Cell, origin: XlsxCellStyleOrigin | undefined): Cell;
38
+ export declare function xlsxCellStyleOrigin(cell: Cell | null | undefined): XlsxCellStyleOrigin | undefined;
39
+ export declare function xlsxSemanticColorMatchesValue(origin: XlsxSemanticColorOrigin, value: unknown): boolean;
40
+ export declare function xlsxColorElementMatchesOrigin(element: Element | undefined, origin: XlsxSemanticColorOrigin): boolean;
41
+ export declare function applyXlsxSemanticColorOrigin(element: Element, origin: XlsxSemanticColorOrigin): void;
42
+ export declare function xlsxSemanticColorOriginKey(origin: XlsxSemanticColorOrigin | undefined): string;
43
+ export declare function xlsxSemanticColorOriginSupported(origin: XlsxSemanticColorOrigin, palette: XlsxSemanticPalette | undefined): boolean;
44
+ export declare function prepareXlsxSemanticPalette(styles: Document, theme: Document | null, origins: Iterable<XlsxCellStyleOrigin>): PreparedXlsxSemanticPalette;
@@ -0,0 +1,26 @@
1
+ import type { Cell } from '@fortune-sheet/core';
2
+ import { type SpreadsheetUnderlineStyle } from './work-spreadsheet-underline';
3
+ import type { XlsxCellBorder } from './work-xlsx-cell-borders';
4
+ import { type XlsxSemanticColorOrigin, type XlsxSemanticPalette } from './work-xlsx-cell-style-origin';
5
+ import { type XlsxDirectAlignmentStyle } from './work-xlsx-cell-style-xml';
6
+ import { type XlsxColorResolver } from './work-xlsx-colors';
7
+ export interface XlsxDirectFontStyle {
8
+ bold?: boolean;
9
+ color?: string;
10
+ italic?: boolean;
11
+ name?: string;
12
+ size?: number;
13
+ strike?: boolean;
14
+ underline?: SpreadsheetUnderlineStyle;
15
+ }
16
+ export declare function hasXlsxDirectFontStyle(cell: Cell): boolean;
17
+ export declare function directXlsxFontStyle(cell: Cell): XlsxDirectFontStyle;
18
+ export declare function directXlsxAlignment(cell: Cell): XlsxDirectAlignmentStyle | null;
19
+ export declare function xlsxStyleCollectionIndex(collection: Element, childName: string, value: string | null): number;
20
+ export declare function xlsxColorMatches(element: Element | undefined, value: string, colors: XlsxColorResolver, fallback?: string): boolean;
21
+ export declare function xlsxToggleEnabled(element: Element | undefined): boolean;
22
+ export declare function xlsxUnderlineStyle(element: Element | undefined): SpreadsheetUnderlineStyle;
23
+ export declare function xlsxBorderLineMatches(element: Element | undefined, line: NonNullable<XlsxCellBorder['top']> | null, colors: XlsxColorResolver, semanticColor?: XlsxSemanticColorOrigin): boolean;
24
+ export declare function activeXlsxSemanticColorOrigin(origin: XlsxSemanticColorOrigin | undefined, value: unknown, palette: XlsxSemanticPalette | undefined): XlsxSemanticColorOrigin | undefined;
25
+ export declare function xlsxBooleanAttribute(element: Element | undefined, name: string): boolean;
26
+ export declare function xlsxAlignmentMatches(xf: Element, style: XlsxDirectAlignmentStyle): boolean;
@@ -1,7 +1,9 @@
1
1
  import type { Cell } from '@fortune-sheet/core';
2
2
  import type { XlsxCellBorder } from './work-xlsx-cell-borders';
3
+ import { type XlsxSemanticPalette } from './work-xlsx-cell-style-origin';
3
4
  export declare class XlsxDirectCellStyleWriter {
4
5
  private readonly styles;
6
+ private readonly semanticPalette?;
5
7
  private readonly fonts;
6
8
  private readonly fills;
7
9
  private readonly borders;
@@ -10,8 +12,9 @@ export declare class XlsxDirectCellStyleWriter {
10
12
  private readonly generatedFills;
11
13
  private readonly generatedBorders;
12
14
  private readonly generatedStyles;
15
+ private readonly colors;
13
16
  changed: boolean;
14
- constructor(styles: Document);
17
+ constructor(styles: Document, theme?: Document | null, semanticPalette?: XlsxSemanticPalette | undefined);
15
18
  styleId(baseStyleId: number, cell: Cell, border?: XlsxCellBorder): number;
16
19
  private fontId;
17
20
  private fillId;
@@ -1,10 +1,12 @@
1
1
  import type { Cell, Sheet } from '@fortune-sheet/core';
2
2
  import { type XlsxCellBorder } from './work-xlsx-cell-borders';
3
3
  import { type XlsxDirectCellStyleWriter } from './work-xlsx-cell-style-writer';
4
+ import { type XlsxCellStyleOrigin } from './work-xlsx-cell-style-origin';
4
5
  export { XlsxDirectCellStyleWriter } from './work-xlsx-cell-style-writer';
5
6
  export interface XlsxDirectCellStyle {
6
7
  border?: XlsxCellBorder;
7
8
  column: number;
9
+ origin?: XlsxCellStyleOrigin;
8
10
  row: number;
9
11
  style: Partial<Cell>;
10
12
  }
Binary file
package/dist/styles.css CHANGED
@@ -5008,6 +5008,47 @@ html[data-ds-resizing="horizontal"], html[data-ds-resizing="horizontal"] * {
5008
5008
  padding: 8px;
5009
5009
  }
5010
5010
 
5011
+ .work-office-color-reset {
5012
+ border: 0;
5013
+ border-bottom: 1px solid var(--a3s-line);
5014
+ width: 100%;
5015
+ min-height: 30px;
5016
+ color: var(--a3s-ink);
5017
+ font: inherit;
5018
+ text-align: start;
5019
+ cursor: pointer;
5020
+ background: none;
5021
+ outline: 0;
5022
+ align-items: center;
5023
+ gap: 8px;
5024
+ margin-bottom: 7px;
5025
+ padding: 4px 6px 7px;
5026
+ font-size: 10px;
5027
+ display: flex;
5028
+ }
5029
+
5030
+ .work-office-color-reset:hover, .work-office-color-reset:focus-visible {
5031
+ background: var(--a3s-panel-soft);
5032
+ color: var(--work-office-control-accent, var(--a3s-blue));
5033
+ }
5034
+
5035
+ .work-office-color-reset-swatch {
5036
+ border: 1px solid var(--a3s-line-strong);
5037
+ background: var(--a3s-panel);
5038
+ width: 19px;
5039
+ height: 16px;
5040
+ color: var(--a3s-red);
5041
+ border-radius: 3px;
5042
+ flex: 0 0 19px;
5043
+ place-items: center;
5044
+ display: grid;
5045
+ }
5046
+
5047
+ .work-office-color-reset[data-kind="automatic"] .work-office-color-reset-swatch {
5048
+ box-shadow: inset 0 0 0 2px var(--a3s-panel);
5049
+ background: #111827;
5050
+ }
5051
+
5011
5052
  .work-office-color-palette {
5012
5053
  gap: 6px;
5013
5054
  display: grid;
@@ -5142,6 +5183,20 @@ html[data-ds-resizing="horizontal"], html[data-ds-resizing="horizontal"] * {
5142
5183
  gap: 7px;
5143
5184
  }
5144
5185
 
5186
+ .work-office-color-reset {
5187
+ border-radius: 7px 7px 0 0;
5188
+ min-height: 44px;
5189
+ margin-bottom: 8px;
5190
+ padding: 8px 9px 9px;
5191
+ font-size: 11px;
5192
+ }
5193
+
5194
+ .work-office-color-reset-swatch {
5195
+ flex-basis: 24px;
5196
+ width: 24px;
5197
+ height: 20px;
5198
+ }
5199
+
5145
5200
  .work-office-color-section-title {
5146
5201
  font-size: 10px;
5147
5202
  }
@@ -15458,7 +15513,7 @@ button.work-office-collaboration-participant:hover .work-office-collaboration-lo
15458
15513
  border-style: dashed;
15459
15514
  }
15460
15515
 
15461
- .work-spreadsheet-border-glyph[data-border-target="none"]:before, .work-spreadsheet-border-glyph[data-border-target="diagonal"]:before {
15516
+ .work-spreadsheet-border-glyph[data-border-target="none"]:before, .work-spreadsheet-border-glyph[data-border-target="diagonal-up"]:before, .work-spreadsheet-border-glyph[data-border-target="diagonalUp"]:before {
15462
15517
  border-top: 1px solid;
15463
15518
  top: 7px;
15464
15519
  left: -1px;
@@ -15466,7 +15521,7 @@ button.work-office-collaboration-participant:hover .work-office-collaboration-lo
15466
15521
  transform: rotate(-45deg);
15467
15522
  }
15468
15523
 
15469
- .work-spreadsheet-border-glyph[data-border-target="none"]:after {
15524
+ .work-spreadsheet-border-glyph[data-border-target="diagonal-down"]:before, .work-spreadsheet-border-glyph[data-border-target="diagonalDown"]:before, .work-spreadsheet-border-glyph[data-border-target="none"]:after {
15470
15525
  border-top: 1px solid;
15471
15526
  top: 7px;
15472
15527
  left: -1px;
@@ -15986,13 +16041,20 @@ button.work-office-collaboration-participant:hover .work-office-collaboration-lo
15986
16041
  border-right: 2px solid;
15987
16042
  }
15988
16043
 
15989
- .work-spreadsheet-border-edge.diagonal > span:after {
16044
+ .work-spreadsheet-border-edge.diagonalDown > span:after, .work-spreadsheet-border-edge.diagonalUp > span:after {
15990
16045
  content: "";
15991
16046
  border-top: 2px solid;
15992
16047
  width: 20px;
15993
16048
  position: absolute;
15994
16049
  top: 8px;
15995
16050
  left: -2px;
16051
+ }
16052
+
16053
+ .work-spreadsheet-border-edge.diagonalDown > span:after {
16054
+ transform: rotate(45deg);
16055
+ }
16056
+
16057
+ .work-spreadsheet-border-edge.diagonalUp > span:after {
15996
16058
  transform: rotate(-45deg);
15997
16059
  }
15998
16060
 
@@ -16013,8 +16075,15 @@ button.work-office-collaboration-participant:hover .work-office-collaboration-lo
16013
16075
  inset: 10px;
16014
16076
  }
16015
16077
 
16016
- .work-spreadsheet-format-cells-border-preview > .diagonal {
16078
+ .work-spreadsheet-format-cells-border-preview > .diagonal-down, .work-spreadsheet-format-cells-border-preview > .diagonal-up {
16017
16079
  inset: 50% 5%;
16080
+ }
16081
+
16082
+ .work-spreadsheet-format-cells-border-preview > .diagonal-down {
16083
+ transform: rotate(26deg);
16084
+ }
16085
+
16086
+ .work-spreadsheet-format-cells-border-preview > .diagonal-up {
16018
16087
  transform: rotate(-26deg);
16019
16088
  }
16020
16089
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@a3s-lab/office",
3
- "version": "0.19.0",
3
+ "version": "0.21.0",
4
4
  "description": "Open-source collaborative browser editors for documents, Markdown, spreadsheets, presentations, and PDFs.",
5
5
  "keywords": [
6
6
  "office",
@@ -88,6 +88,8 @@
88
88
  "playground:typecheck": "tsc --noEmit -p playground/tsconfig.json",
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
+ "playground:visual:spreadsheet-diagonal-borders": "playwright test visual-tests/spreadsheet-diagonal-borders.functional.spec.ts --config playwright.config.ts",
92
+ "playground:visual:spreadsheet-font-colors-shortcuts": "playwright test visual-tests/spreadsheet-font-colors-shortcuts.functional.spec.ts --config playwright.config.ts",
91
93
  "playground:visual:spreadsheet-hyperlink": "playwright test visual-tests/spreadsheet-hyperlink.functional.spec.ts --config playwright.config.ts",
92
94
  "playground:visual:spreadsheet-ribbon": "playwright test visual-tests/spreadsheet-ribbon.functional.spec.ts --config playwright.config.ts",
93
95
  "playground:visual:spreadsheet-underline": "playwright test visual-tests/spreadsheet-underline.functional.spec.ts --config playwright.config.ts",
@@ -136,6 +138,8 @@
136
138
  "test:e2e:spreadsheet-ribbon:check": "a3s-test check tests/e2e/spreadsheet-ribbon-alignment.acl --json",
137
139
  "test:e2e:spreadsheet-orientation-visibility": "a3s-test run tests/e2e/spreadsheet-ribbon-orientation-visibility.acl --json",
138
140
  "test:e2e:spreadsheet-orientation-visibility:check": "a3s-test check tests/e2e/spreadsheet-ribbon-orientation-visibility.acl --json",
141
+ "test:e2e:spreadsheet-font-colors-shortcuts": "a3s-test run tests/e2e/spreadsheet-font-colors-shortcuts.acl --json",
142
+ "test:e2e:spreadsheet-font-colors-shortcuts:check": "a3s-test check tests/e2e/spreadsheet-font-colors-shortcuts.acl --json",
139
143
  "test:e2e:spreadsheet-cell-style": "a3s-test run tests/e2e/spreadsheet-cell-style.acl --json",
140
144
  "test:e2e:spreadsheet-cell-style:check": "a3s-test check tests/e2e/spreadsheet-cell-style.acl --json",
141
145
  "test:e2e:spreadsheet-font-size-border-shortcuts": "a3s-test run tests/e2e/spreadsheet-font-size-border-shortcuts.acl --json",
@@ -154,6 +158,8 @@
154
158
  "test:e2e:spreadsheet-go-to:check": "a3s-test check tests/e2e/spreadsheet-go-to.acl --json",
155
159
  "test:e2e:spreadsheet-data-validation": "a3s-test run tests/e2e/spreadsheet-data-validation.acl --json",
156
160
  "test:e2e:spreadsheet-data-validation:check": "a3s-test check tests/e2e/spreadsheet-data-validation.acl --json",
161
+ "test:e2e:spreadsheet-diagonal-borders": "a3s-test run tests/e2e/spreadsheet-diagonal-borders.acl --json",
162
+ "test:e2e:spreadsheet-diagonal-borders:check": "a3s-test check tests/e2e/spreadsheet-diagonal-borders.acl --json",
157
163
  "test:e2e:spreadsheet-hyperlink": "a3s-test run tests/e2e/spreadsheet-hyperlink.acl --json",
158
164
  "test:e2e:spreadsheet-hyperlink:check": "a3s-test check tests/e2e/spreadsheet-hyperlink.acl --json",
159
165
  "test:e2e:spreadsheet-maximum-sparse": "a3s-test run tests/e2e/spreadsheet-maximum-sparse.acl --json",