@a3s-lab/office 0.19.0 → 0.20.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/dist/6164.js CHANGED
@@ -2092,64 +2092,6 @@ 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
- }
2153
2095
  const spreadsheetTextOrientationIds = [
2154
2096
  'horizontal',
2155
2097
  'angleCounterclockwise',
@@ -2256,6 +2198,64 @@ function integer(value) {
2256
2198
  const parsed = 'number' == typeof value ? value : Number(value);
2257
2199
  return Number.isSafeInteger(parsed) ? parsed : null;
2258
2200
  }
2201
+ const spreadsheetUnderlineStyles = [
2202
+ 'none',
2203
+ 'single',
2204
+ 'double',
2205
+ 'singleAccounting',
2206
+ 'doubleAccounting'
2207
+ ];
2208
+ const underlineCellValues = {
2209
+ none: 0,
2210
+ single: 1,
2211
+ double: 2,
2212
+ singleAccounting: 3,
2213
+ doubleAccounting: 4
2214
+ };
2215
+ function isSpreadsheetUnderlineStyle(value) {
2216
+ return 'string' == typeof value && spreadsheetUnderlineStyles.includes(value);
2217
+ }
2218
+ function spreadsheetUnderlineCellValue(style) {
2219
+ return underlineCellValues[style];
2220
+ }
2221
+ function spreadsheetUnderlineStyle(value) {
2222
+ switch(Number(value)){
2223
+ case 1:
2224
+ return 'single';
2225
+ case 2:
2226
+ return 'double';
2227
+ case 3:
2228
+ case 0x21:
2229
+ return 'singleAccounting';
2230
+ case 4:
2231
+ case 0x22:
2232
+ return 'doubleAccounting';
2233
+ default:
2234
+ return 'none';
2235
+ }
2236
+ }
2237
+ function spreadsheetUnderlineCellValueFromXlsx(value) {
2238
+ switch(value?.trim()){
2239
+ case null:
2240
+ case void 0:
2241
+ case '':
2242
+ case 'single':
2243
+ return 1;
2244
+ case 'double':
2245
+ return 2;
2246
+ case 'singleAccounting':
2247
+ return 3;
2248
+ case 'doubleAccounting':
2249
+ return 4;
2250
+ default:
2251
+ return 0;
2252
+ }
2253
+ }
2254
+ function spreadsheetUnderlineCellValueFromSheetJs(value) {
2255
+ if (true === value) return 1;
2256
+ if (isSpreadsheetUnderlineStyle(value)) return spreadsheetUnderlineCellValue(value);
2257
+ return spreadsheetUnderlineCellValue(spreadsheetUnderlineStyle(value));
2258
+ }
2259
2259
  const SPREADSHEET_CONDITIONAL_COMPARISON_OPERATORS = [
2260
2260
  'greaterThan',
2261
2261
  'greaterThanOrEqual',
@@ -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;
@@ -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: {
@@ -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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@a3s-lab/office",
3
- "version": "0.19.0",
3
+ "version": "0.20.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,7 @@
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-font-colors-shortcuts": "playwright test visual-tests/spreadsheet-font-colors-shortcuts.functional.spec.ts --config playwright.config.ts",
91
92
  "playground:visual:spreadsheet-hyperlink": "playwright test visual-tests/spreadsheet-hyperlink.functional.spec.ts --config playwright.config.ts",
92
93
  "playground:visual:spreadsheet-ribbon": "playwright test visual-tests/spreadsheet-ribbon.functional.spec.ts --config playwright.config.ts",
93
94
  "playground:visual:spreadsheet-underline": "playwright test visual-tests/spreadsheet-underline.functional.spec.ts --config playwright.config.ts",
@@ -136,6 +137,8 @@
136
137
  "test:e2e:spreadsheet-ribbon:check": "a3s-test check tests/e2e/spreadsheet-ribbon-alignment.acl --json",
137
138
  "test:e2e:spreadsheet-orientation-visibility": "a3s-test run tests/e2e/spreadsheet-ribbon-orientation-visibility.acl --json",
138
139
  "test:e2e:spreadsheet-orientation-visibility:check": "a3s-test check tests/e2e/spreadsheet-ribbon-orientation-visibility.acl --json",
140
+ "test:e2e:spreadsheet-font-colors-shortcuts": "a3s-test run tests/e2e/spreadsheet-font-colors-shortcuts.acl --json",
141
+ "test:e2e:spreadsheet-font-colors-shortcuts:check": "a3s-test check tests/e2e/spreadsheet-font-colors-shortcuts.acl --json",
139
142
  "test:e2e:spreadsheet-cell-style": "a3s-test run tests/e2e/spreadsheet-cell-style.acl --json",
140
143
  "test:e2e:spreadsheet-cell-style:check": "a3s-test check tests/e2e/spreadsheet-cell-style.acl --json",
141
144
  "test:e2e:spreadsheet-font-size-border-shortcuts": "a3s-test run tests/e2e/spreadsheet-font-size-border-shortcuts.acl --json",