@a3s-lab/office 0.25.0 → 0.26.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.
@@ -1,4 +1,5 @@
1
1
  import { type DocxThemeColorReference } from './work-docx-theme-reference';
2
+ export { normalizeCssColor } from './work-css-color';
2
3
  export type DocumentParagraphShadingPattern = 'nil' | 'clear' | 'solid' | 'horzStripe' | 'vertStripe' | 'reverseDiagStripe' | 'diagStripe' | 'horzCross' | 'diagCross' | 'thinHorzStripe' | 'thinVertStripe' | 'thinReverseDiagStripe' | 'thinDiagStripe' | 'thinHorzCross' | 'thinDiagCross' | 'pct5' | 'pct10' | 'pct12' | 'pct15' | 'pct20' | 'pct25' | 'pct30' | 'pct35' | 'pct37' | 'pct40' | 'pct45' | 'pct50' | 'pct55' | 'pct60' | 'pct62' | 'pct65' | 'pct70' | 'pct75' | 'pct80' | 'pct85' | 'pct87' | 'pct90' | 'pct95';
3
4
  export interface DocumentParagraphShadingColor {
4
5
  value: 'auto' | `#${string}`;
@@ -15,4 +16,3 @@ export declare function parseDocumentParagraphShading(source: unknown): Document
15
16
  export declare function serializeDocumentParagraphShading(source: unknown): string | undefined;
16
17
  export declare function parseDocumentParagraphShadingElement(element: HTMLElement): DocumentParagraphShading | null;
17
18
  export declare function documentParagraphShadingDomAttributes(source: unknown): Record<string, string>;
18
- export declare function normalizeCssColor(source: string | null | undefined): 'transparent' | `#${string}` | null;
@@ -0,0 +1,28 @@
1
+ import type { Cell } from '@fortune-sheet/core';
2
+ import { type XlsxRichTextRun } from './work-xlsx-rich-text-model';
3
+ export interface SpreadsheetRichTextPasteIntent {
4
+ end: number;
5
+ runs: readonly XlsxRichTextRun[];
6
+ start: number;
7
+ text: string;
8
+ }
9
+ /**
10
+ * Reconciles a text edit emitted by Fortune with the previous native XLSX
11
+ * rich-text cell. Formula-bar edits may arrive as a plain string, while the
12
+ * in-cell editor emits visible runs without A3S-only semantic color metadata.
13
+ * This bounded model restores only style and metadata justified by the prior
14
+ * controlled value and the exact text replacement.
15
+ */
16
+ export declare function reconcileSpreadsheetRichTextCellEdit(previous: Cell | null | undefined, current: Cell, formattedPaste?: SpreadsheetRichTextPasteIntent): Cell;
17
+ /**
18
+ * Restores the controlled runs when an unauthenticated Fortune callback keeps
19
+ * the exact visible text but drops native run metadata. Callers must reserve
20
+ * this for non-structural batches without an exact cell-operation coordinate.
21
+ */
22
+ export declare function restoreSpreadsheetRichTextCellRuns(previous: Cell | null | undefined, current: Cell): Cell;
23
+ /**
24
+ * Proves that Fortune retained the visible text of a controlled native
25
+ * rich-text cell. This permits metadata-only callbacks to restore lost run
26
+ * structure without guessing across a text or structural edit.
27
+ */
28
+ export declare function sameSpreadsheetRichTextCellText(previous: Cell | null | undefined, current: Cell): boolean;
@@ -0,0 +1,40 @@
1
+ import type { Cell } from '@fortune-sheet/core';
2
+ import { type XlsxSemanticColorOrigin } from './work-xlsx-cell-style-origin';
3
+ import type { SpreadsheetUnderlineCellValue } from './work-spreadsheet-underline';
4
+ export declare const MAX_XLSX_RICH_TEXT_CELL_CHARACTERS = 32767;
5
+ export declare const MAX_XLSX_RICH_TEXT_RUNS_PER_CELL = 512;
6
+ export declare const MAX_XLSX_RICH_TEXT_CELLS = 10000;
7
+ export declare const MAX_XLSX_RICH_TEXT_RUNS = 100000;
8
+ export declare const MAX_XLSX_RICH_TEXT_FONT_NAME_CHARACTERS = 128;
9
+ export declare const MAX_XLSX_RICH_TEXT_FONT_SIZE = 409;
10
+ export interface XlsxRichTextRun {
11
+ a3sXlsxColorOrigin?: XlsxSemanticColorOrigin;
12
+ bl?: 0 | 1;
13
+ cl?: 0 | 1;
14
+ fc?: string;
15
+ ff?: string;
16
+ fs?: number;
17
+ it?: 0 | 1;
18
+ un?: SpreadsheetUnderlineCellValue;
19
+ v: string;
20
+ }
21
+ export interface NormalizedXlsxRichTextCell {
22
+ runs: XlsxRichTextRun[];
23
+ text: string;
24
+ }
25
+ /**
26
+ * Normalizes the text state that may participate in caret-level rich-text
27
+ * authoring. Native runs remain authoritative; bounded plain strings receive
28
+ * one run derived from the cell-wide font so partial formatting and formatted
29
+ * paste share the same conversion contract.
30
+ */
31
+ export declare function normalizeXlsxRichTextEditSource(cell: Cell | null | undefined): NormalizedXlsxRichTextCell | null;
32
+ export declare function xlsxRichTextBaseRun(cell: Cell | null | undefined, text: string): XlsxRichTextRun;
33
+ export declare function normalizeXlsxRichTextCell(cell: Cell): NormalizedXlsxRichTextCell | null;
34
+ export declare function normalizeXlsxRichTextRun(value: unknown): XlsxRichTextRun | null;
35
+ export declare function normalizeXlsxRichTextColor(value: unknown): string | null;
36
+ export declare function coalesceXlsxRichTextRuns(source: readonly XlsxRichTextRun[]): XlsxRichTextRun[];
37
+ export declare function sameXlsxRichTextRunStyle(left: XlsxRichTextRun, right: XlsxRichTextRun): boolean;
38
+ export declare function validXlsxRichText(value: string): boolean;
39
+ export declare function isHighSurrogate(value: number): boolean;
40
+ export declare function isLowSurrogate(value: number): boolean;
@@ -1,22 +1,9 @@
1
1
  import type { Cell, Sheet } from '@fortune-sheet/core';
2
- import { type SpreadsheetUnderlineCellValue, type SpreadsheetUnderlineStyle } from './work-spreadsheet-underline';
3
- import { type XlsxCellStyleOrigin, type XlsxSemanticColorOrigin, type XlsxSemanticPalette } from './work-xlsx-cell-style-origin';
2
+ import { type SpreadsheetUnderlineStyle } from './work-spreadsheet-underline';
3
+ import { type XlsxCellStyleOrigin, type XlsxSemanticPalette } from './work-xlsx-cell-style-origin';
4
4
  import { type XlsxColorResolver } from './work-xlsx-colors';
5
- export declare const MAX_XLSX_RICH_TEXT_CELL_CHARACTERS = 32767;
6
- export declare const MAX_XLSX_RICH_TEXT_RUNS_PER_CELL = 512;
7
- export declare const MAX_XLSX_RICH_TEXT_CELLS = 10000;
8
- export declare const MAX_XLSX_RICH_TEXT_RUNS = 100000;
9
- export interface XlsxRichTextRun {
10
- a3sXlsxColorOrigin?: XlsxSemanticColorOrigin;
11
- bl?: 0 | 1;
12
- cl?: 0 | 1;
13
- fc?: string;
14
- ff?: string;
15
- fs?: number;
16
- it?: 0 | 1;
17
- un?: SpreadsheetUnderlineCellValue;
18
- v: string;
19
- }
5
+ import { type XlsxRichTextRun } from './work-xlsx-rich-text-model';
6
+ export { MAX_XLSX_RICH_TEXT_CELL_CHARACTERS, MAX_XLSX_RICH_TEXT_CELLS, MAX_XLSX_RICH_TEXT_RUNS, MAX_XLSX_RICH_TEXT_RUNS_PER_CELL, type XlsxRichTextRun, } from './work-xlsx-rich-text-model';
20
7
  export interface XlsxRichTextCell {
21
8
  column: number;
22
9
  row: number;
@@ -52,4 +39,3 @@ export declare function xlsxRichTextCellText(cell: Cell): string | null;
52
39
  export declare function sheetHasXlsxRichTextCells(sheet: Sheet): boolean;
53
40
  export declare function xlsxRichTextStyleOrigins(sheet: Sheet): XlsxCellStyleOrigin[];
54
41
  export declare function writeXlsxRichTextCells(worksheet: Document, sheet: Sheet, semanticPalette?: XlsxSemanticPalette): void;
55
- export {};
Binary file
@@ -319,6 +319,33 @@ materialization. Fortune row/column operations are reconciled back into table
319
319
  ranges, column identities, filter offsets, and canonical header cells, while
320
320
  merge and worksheet AutoFilter commands reject intersecting ownership.
321
321
 
322
+ Native XLSX rich-text editing is reconciled at the controlled Fortune boundary,
323
+ not inside the rendering engine. A pure model normalizes at most 512 runs and
324
+ 32,767 UTF-16 code units, derives one contiguous replacement, uses binary run
325
+ lookup for inherited styles, and coalesces only semantically identical adjacent
326
+ runs. Authenticated `data[row][column]` operations permit text changes at exact
327
+ coordinates. In the full-projection compatibility path, a non-structural batch
328
+ without a cell coordinate may restore prior runs only when the visible text is
329
+ exactly unchanged; structural operations disable coordinate inference. This
330
+ keeps formula-bar and F2 commits to one host revision and one Undo record while
331
+ discarding Fortune focus callbacks that merely flatten or strip run metadata.
332
+
333
+ Formatted paste adds a separate one-shot authority instead of trusting live
334
+ DOM markup. A paste event in the formula bar or F2 editor records the exact
335
+ sheet object, coordinate, controlled source text, UTF-16 selection, sanitized
336
+ clipboard runs, and plain text before the browser mutates the editor. The
337
+ incremental and full projection paths may consume that authority only when an
338
+ authenticated cell operation emits the exact predicted replacement. Prefix
339
+ and suffix runs always come from the controlled source; only the inserted
340
+ range may use clipboard font family, point size, RGB color, bold, italic,
341
+ strikethrough, or underline. This also converts eligible plain or empty cells
342
+ to native inline strings without granting structural callbacks a coordinate.
343
+ The parser never retains clipboard HTML, ignores active/non-content elements,
344
+ and rejects mismatched text, invalid UTF-16, more than 256,000 HTML characters,
345
+ 32,767 cell characters, or 512 resulting runs. Imported semantic color
346
+ identities remain attached to untouched runs; pasted colors are explicit RGB
347
+ unless a future package-level source can prove a native palette identity.
348
+
322
349
  The table is a fidelity statement, not a marketing capability list. The
323
350
  current Document path shapes text-flow paragraphs in Rust/WASM when every
324
351
  explicit CSS family resolves to an exact registered face. Each run may carry up
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@a3s-lab/office",
3
- "version": "0.25.0",
3
+ "version": "0.26.0",
4
4
  "description": "Open-source collaborative browser editors for documents, Markdown, spreadsheets, presentations, and PDFs.",
5
5
  "keywords": [
6
6
  "office",