@sobree/core 0.1.14 → 0.1.16
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/doc/builders/block.d.ts +8 -0
- package/dist/doc/{builders.d.ts → builders/document.d.ts} +1 -12
- package/dist/doc/builders/index.d.ts +26 -0
- package/dist/doc/builders/inline.d.ts +38 -0
- package/dist/doc/builders/numbering.d.ts +19 -0
- package/dist/doc/builders/style.d.ts +7 -0
- package/dist/doc/builders/table.d.ts +20 -0
- package/dist/doc/formatting.types.d.ts +9 -49
- package/dist/doc/tableStyle.types.d.ts +43 -0
- package/dist/doc/types.d.ts +4 -2
- package/dist/editor/index.d.ts +26 -2
- package/dist/editor/internal/mutations.d.ts +15 -2
- package/dist/editor/numbering.d.ts +14 -0
- package/dist/editor/sections.d.ts +15 -0
- package/dist/editor/styles.d.ts +16 -0
- package/dist/editor/types.d.ts +27 -1
- package/dist/headless.d.ts +18 -2
- package/dist/index.js +3367 -3076
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { InlineRun, Paragraph, ParagraphProperties, SectionBreak } from '../types';
|
|
2
|
+
/** A paragraph with the given runs and properties (both optional). */
|
|
3
|
+
export declare function paragraph(runs?: InlineRun[], properties?: ParagraphProperties): Paragraph;
|
|
4
|
+
/** Heading paragraph (`Heading{level}` style, level clamped to 1..6). */
|
|
5
|
+
export declare function heading(level: number, runs?: InlineRun[], properties?: ParagraphProperties): Paragraph;
|
|
6
|
+
/** A section break that switches to `toSectionIndex` in the document's
|
|
7
|
+
* `sections` array for the content that follows. */
|
|
8
|
+
export declare function sectionBreak(toSectionIndex: number): SectionBreak;
|
|
@@ -1,20 +1,9 @@
|
|
|
1
|
-
import { Block, HeaderFooterRef,
|
|
1
|
+
import { Block, HeaderFooterRef, NamedStyle, PageMargins, PageSize, Paragraph, SectionProperties, SobreeDocument, Table } from '../types';
|
|
2
2
|
/** A new, blank document with an A4 portrait section and the standard styles. */
|
|
3
3
|
export declare function emptyDocument(): SobreeDocument;
|
|
4
4
|
export declare function defaultSection(): SectionProperties;
|
|
5
5
|
export declare function defaultPageSize(): PageSize;
|
|
6
6
|
export declare function defaultMargins(): PageMargins;
|
|
7
|
-
/** A paragraph with no runs and no properties beyond the defaults. */
|
|
8
|
-
export declare function paragraph(runs?: InlineRun[], properties?: ParagraphProperties): Paragraph;
|
|
9
|
-
/** Heading paragraph (`Heading{level}` style, level clamped to 1..6). */
|
|
10
|
-
export declare function heading(level: number, runs?: InlineRun[], extra?: ParagraphProperties): Paragraph;
|
|
11
|
-
/** Plain text run with optional formatting. */
|
|
12
|
-
export declare function text(value: string, properties?: RunProperties): TextRun;
|
|
13
|
-
/** Convenience: emphasised (bold + italic) text run. */
|
|
14
|
-
export declare function emphasis(value: string, properties?: RunProperties): TextRun;
|
|
15
|
-
export declare function strong(value: string, properties?: RunProperties): TextRun;
|
|
16
|
-
export declare function softBreak(): InlineRun;
|
|
17
|
-
export declare function pageBreak(): InlineRun;
|
|
18
7
|
/** Default Word styles every doc declares so headings render correctly.
|
|
19
8
|
*
|
|
20
9
|
* Carries WORD-HARDCODED-DEFAULT typography — i.e. what Word uses
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Constructors for AST nodes. Two reasons these exist as helpers instead
|
|
3
|
+
* of object literals at every call site:
|
|
4
|
+
* 1. Defaults — A4 paper, an empty cell's placeholder paragraph, equal
|
|
5
|
+
* column widths — without sprinkling magic numbers into caller code.
|
|
6
|
+
* 2. Future schema migration — when a new required field is added, all
|
|
7
|
+
* construction goes through here and the migration is one diff.
|
|
8
|
+
*
|
|
9
|
+
* Conventions across the layer:
|
|
10
|
+
* - The factory is named for the node it builds (`text`, `table`,
|
|
11
|
+
* `tableCell`, `hyperlink`, `sectionBreak`).
|
|
12
|
+
* - Required content is positional; optional formatting is a trailing
|
|
13
|
+
* `properties` argument (a leaf's `RunProperties`, a container's
|
|
14
|
+
* `*Properties`). Many-field nodes (`image`, `table`, `namedStyle`)
|
|
15
|
+
* take a single trailing options object instead.
|
|
16
|
+
* - Measurements keep their native OOXML unit, suffixed (`widthEmu`,
|
|
17
|
+
* `…Twips`), matching the AST.
|
|
18
|
+
*
|
|
19
|
+
* Organised by node category: document / block / inline / table / style.
|
|
20
|
+
*/
|
|
21
|
+
export { appendBlock, defaultMargins, defaultPageSize, defaultSection, defaultStyles, emptyDocument, isParagraph, isTable, makeHeaderFooterRef, } from './document';
|
|
22
|
+
export { heading, paragraph, sectionBreak } from './block';
|
|
23
|
+
export { columnBreak, commentRef, emphasis, field, footnoteRef, hyperlink, image, type ImageOptions, pageBreak, softBreak, strong, tab, text, } from './inline';
|
|
24
|
+
export { type CellProperties, type TableOptions, table, tableCell, tableRow } from './table';
|
|
25
|
+
export { type NamedStyleOptions, namedStyle } from './style';
|
|
26
|
+
export { type NumberingLevelOptions, bulletDefinition, numberingDefinition, numberingLevel, orderedDefinition, } from './numbering';
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { BreakRun, CommentRefRun, DrawingRun, FieldRun, FootnoteRefRun, HyperlinkRun, InlineRun, RunProperties, TabRun, TextRun } from '../types';
|
|
2
|
+
/** Plain text run with optional formatting. */
|
|
3
|
+
export declare function text(value: string, properties?: RunProperties): TextRun;
|
|
4
|
+
/** Convenience: italic text run. */
|
|
5
|
+
export declare function emphasis(value: string, properties?: RunProperties): TextRun;
|
|
6
|
+
/** Convenience: bold text run. */
|
|
7
|
+
export declare function strong(value: string, properties?: RunProperties): TextRun;
|
|
8
|
+
/** Soft line break inside a paragraph (Shift-Enter). */
|
|
9
|
+
export declare function softBreak(): BreakRun;
|
|
10
|
+
/** Explicit page break. */
|
|
11
|
+
export declare function pageBreak(): BreakRun;
|
|
12
|
+
/** Column break (advances to the next column in a multi-column section). */
|
|
13
|
+
export declare function columnBreak(): BreakRun;
|
|
14
|
+
/** A tab character — advances to the next tab stop. */
|
|
15
|
+
export declare function tab(properties?: RunProperties): TabRun;
|
|
16
|
+
/** A hyperlink wrapping inline children. `href` is an external URL or an
|
|
17
|
+
* internal anchor id (`#bookmark`). */
|
|
18
|
+
export declare function hyperlink(href: string, children: InlineRun[], properties?: RunProperties): HyperlinkRun;
|
|
19
|
+
/** A field run (`PAGE`, `NUMPAGES`, `DATE`, …). `cached` is the preview
|
|
20
|
+
* text shown until a viewer recalculates the field. */
|
|
21
|
+
export declare function field(instruction: string, cached?: string, properties?: RunProperties): FieldRun;
|
|
22
|
+
/** Options for {@link image}. `partPath` references a binary in the
|
|
23
|
+
* document's `rawParts`; the caller is responsible for registering the
|
|
24
|
+
* bytes there (or use the editor's `insertImage`, which does both). */
|
|
25
|
+
export interface ImageOptions {
|
|
26
|
+
widthEmu: number;
|
|
27
|
+
heightEmu: number;
|
|
28
|
+
altText?: string;
|
|
29
|
+
/** Layout mode — defaults to `"inline"` (flows like a tall character). */
|
|
30
|
+
placement?: DrawingRun["placement"];
|
|
31
|
+
verticalAlign?: DrawingRun["verticalAlign"];
|
|
32
|
+
}
|
|
33
|
+
/** An image / drawing run referencing a part in `rawParts`. */
|
|
34
|
+
export declare function image(partPath: string, opts: ImageOptions): DrawingRun;
|
|
35
|
+
/** A footnote reference — `id` keys into `SobreeDocument.footnotes`. */
|
|
36
|
+
export declare function footnoteRef(id: number, properties?: RunProperties): FootnoteRefRun;
|
|
37
|
+
/** A comment reference — `id` keys into `SobreeDocument.comments`. */
|
|
38
|
+
export declare function commentRef(id: number, properties?: RunProperties): CommentRefRun;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { NumberingDefinition, NumberingLevel, ParagraphIndent, RunProperties } from '../types';
|
|
2
|
+
export interface NumberingLevelOptions {
|
|
3
|
+
restart?: number;
|
|
4
|
+
paragraphIndent?: ParagraphIndent;
|
|
5
|
+
/** Run properties for the marker glyph/number itself. */
|
|
6
|
+
runDefaults?: RunProperties;
|
|
7
|
+
}
|
|
8
|
+
/** One indent level of a list. `format` is `bullet` / `decimal` /
|
|
9
|
+
* `lowerRoman` / `upperLetter` / …; `text` is the marker template
|
|
10
|
+
* (`%1.`, `(%1)`, or a literal bullet glyph). */
|
|
11
|
+
export declare function numberingLevel(level: number, format: string, text: string, options?: NumberingLevelOptions): NumberingLevel;
|
|
12
|
+
/** A numbering definition: a `numId` (referenced from paragraphs) plus its
|
|
13
|
+
* level formats. */
|
|
14
|
+
export declare function numberingDefinition(numId: number, levels: NumberingLevel[]): NumberingDefinition;
|
|
15
|
+
/** A bullet list of `levels` levels (default 3), cycling • ◦ ▪. */
|
|
16
|
+
export declare function bulletDefinition(numId: number, levels?: number): NumberingDefinition;
|
|
17
|
+
/** An ordered list of `levels` levels (default 3), each `%1.` decimal,
|
|
18
|
+
* restarting at the level above. */
|
|
19
|
+
export declare function orderedDefinition(numId: number, levels?: number): NumberingDefinition;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { NamedStyle } from '../types';
|
|
2
|
+
/** Everything on {@link NamedStyle} except `id` (the positional argument);
|
|
3
|
+
* `type` defaults to `"paragraph"` and `displayName` to the id. */
|
|
4
|
+
export type NamedStyleOptions = Partial<Omit<NamedStyle, "id">>;
|
|
5
|
+
/** A named style. `id` is required; `type` defaults to `"paragraph"` and
|
|
6
|
+
* `displayName` to `id` when not given. */
|
|
7
|
+
export declare function namedStyle(id: string, options?: NamedStyleOptions): NamedStyle;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Block, Table, TableCell, TableProperties, TableRow } from '../types';
|
|
2
|
+
/** A cell's properties — everything on {@link TableCell} except `content`
|
|
3
|
+
* (which is the positional argument). */
|
|
4
|
+
export type CellProperties = Partial<Omit<TableCell, "content">>;
|
|
5
|
+
/** A table cell. `content` defaults to a single empty paragraph (Word
|
|
6
|
+
* requires every cell to hold at least one paragraph). */
|
|
7
|
+
export declare function tableCell(content?: Block[], properties?: CellProperties): TableCell;
|
|
8
|
+
/** A table row. */
|
|
9
|
+
export declare function tableRow(cells: TableCell[], opts?: {
|
|
10
|
+
isHeader?: boolean;
|
|
11
|
+
}): TableRow;
|
|
12
|
+
export interface TableOptions {
|
|
13
|
+
/** Column widths in twips (length = column count). Derived as equal
|
|
14
|
+
* columns from {@link DEFAULT_TABLE_WIDTH_TWIPS} when omitted. */
|
|
15
|
+
grid?: number[];
|
|
16
|
+
properties?: TableProperties;
|
|
17
|
+
}
|
|
18
|
+
/** A table. The column `grid` is taken from `opts.grid`, else derived as
|
|
19
|
+
* equal-width columns from the widest row's column count. */
|
|
20
|
+
export declare function table(rows: TableRow[], opts?: TableOptions): Table;
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* formatting.
|
|
2
|
+
* Visual formatting primitives: borders, shading, and cell spacing.
|
|
4
3
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* every AST type from `./types`.
|
|
4
|
+
* Low-level value-types shared across the AST — paragraphs, runs, and
|
|
5
|
+
* tables all paint with these. A dependency-free LEAF: none reference the
|
|
6
|
+
* recursive `Block` document graph, so keeping them here (out of
|
|
7
|
+
* `types.ts`) avoids a circular dependency. `types.ts` imports +
|
|
8
|
+
* re-exports them, so consumers still get every AST type from `./types`.
|
|
10
9
|
*/
|
|
11
10
|
export interface BorderSpec {
|
|
12
11
|
style: "single" | "double" | "dashed" | "dotted" | "thick" | "none";
|
|
@@ -25,6 +24,8 @@ export interface Shading {
|
|
|
25
24
|
/** Pattern foreground `#rrggbb` or `auto`. */
|
|
26
25
|
color?: string;
|
|
27
26
|
}
|
|
27
|
+
/** A table's outer edges plus the inside-horizontal / inside-vertical
|
|
28
|
+
* separators (`<w:tblBorders>`). */
|
|
28
29
|
export interface TableBorders {
|
|
29
30
|
top?: BorderSpec;
|
|
30
31
|
right?: BorderSpec;
|
|
@@ -33,6 +34,7 @@ export interface TableBorders {
|
|
|
33
34
|
insideH?: BorderSpec;
|
|
34
35
|
insideV?: BorderSpec;
|
|
35
36
|
}
|
|
37
|
+
/** A single cell's four edges (`<w:tcBorders>`). */
|
|
36
38
|
export interface TableCellBorders {
|
|
37
39
|
top?: BorderSpec;
|
|
38
40
|
right?: BorderSpec;
|
|
@@ -47,45 +49,3 @@ export interface TableCellMargins {
|
|
|
47
49
|
bottomTwips?: number;
|
|
48
50
|
leftTwips?: number;
|
|
49
51
|
}
|
|
50
|
-
/** `<w:tblLook>` flags. A flag absent ⇒ that conditional format is OFF. */
|
|
51
|
-
export interface TableLook {
|
|
52
|
-
firstRow?: boolean;
|
|
53
|
-
lastRow?: boolean;
|
|
54
|
-
firstColumn?: boolean;
|
|
55
|
-
lastColumn?: boolean;
|
|
56
|
-
/** Row (horizontal) banding active. */
|
|
57
|
-
hBand?: boolean;
|
|
58
|
-
/** Column (vertical) banding active. */
|
|
59
|
-
vBand?: boolean;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* A table style's conditional-format regions (`<w:tblStylePr w:type>`).
|
|
63
|
-
* Each names a slice of the table whose cells get extra formatting when
|
|
64
|
-
* the table's `<w:tblLook>` enables it. Resolution precedence (low→high,
|
|
65
|
-
* ECMA-376 §17.7.6): wholeTable → vBands → hBands → first/last column →
|
|
66
|
-
* first/last row → corner cells, then direct cell formatting wins.
|
|
67
|
-
*/
|
|
68
|
-
export type TableConditionalType = "firstRow" | "lastRow" | "firstCol" | "lastCol" | "band1Horz" | "band2Horz" | "band1Vert" | "band2Vert" | "nwCell" | "neCell" | "swCell" | "seCell";
|
|
69
|
-
/** The formatting one region (or the whole-table base) contributes. */
|
|
70
|
-
export interface TableStyleCellFormat {
|
|
71
|
-
shading?: Shading;
|
|
72
|
-
borders?: TableCellBorders;
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* A `<w:style w:type="table">` definition: whole-table base formatting +
|
|
76
|
-
* per-region conditional formatting + band sizes. Resolved per cell at
|
|
77
|
-
* render time against the table's `look`.
|
|
78
|
-
*/
|
|
79
|
-
export interface TableStyleDefinition {
|
|
80
|
-
/** Whole-table borders (`<w:tblBorders>` — incl. `insideH`/`insideV`). */
|
|
81
|
-
borders?: TableBorders;
|
|
82
|
-
/** Whole-table base cell shading. */
|
|
83
|
-
shading?: Shading;
|
|
84
|
-
/** Rows per horizontal band (`<w:tblStyleRowBandSize>`, default 1). */
|
|
85
|
-
rowBandSize?: number;
|
|
86
|
-
/** Columns per vertical band (`<w:tblStyleColBandSize>`, default 1). */
|
|
87
|
-
colBandSize?: number;
|
|
88
|
-
/** Whole-table default cell padding (`<w:tblCellMar>` in the style). */
|
|
89
|
-
cellMargins?: TableCellMargins;
|
|
90
|
-
conditional?: Partial<Record<TableConditionalType, TableStyleCellFormat>>;
|
|
91
|
-
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Shading, TableBorders, TableCellBorders, TableCellMargins } from './formatting.types';
|
|
2
|
+
/** `<w:tblLook>` flags. A flag absent ⇒ that conditional format is OFF. */
|
|
3
|
+
export interface TableLook {
|
|
4
|
+
firstRow?: boolean;
|
|
5
|
+
lastRow?: boolean;
|
|
6
|
+
firstColumn?: boolean;
|
|
7
|
+
lastColumn?: boolean;
|
|
8
|
+
/** Row (horizontal) banding active. */
|
|
9
|
+
hBand?: boolean;
|
|
10
|
+
/** Column (vertical) banding active. */
|
|
11
|
+
vBand?: boolean;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* A table style's conditional-format regions (`<w:tblStylePr w:type>`).
|
|
15
|
+
* Each names a slice of the table whose cells get extra formatting when
|
|
16
|
+
* the table's `<w:tblLook>` enables it. Resolution precedence (low→high,
|
|
17
|
+
* ECMA-376 §17.7.6): wholeTable → vBands → hBands → first/last column →
|
|
18
|
+
* first/last row → corner cells, then direct cell formatting wins.
|
|
19
|
+
*/
|
|
20
|
+
export type TableConditionalType = "firstRow" | "lastRow" | "firstCol" | "lastCol" | "band1Horz" | "band2Horz" | "band1Vert" | "band2Vert" | "nwCell" | "neCell" | "swCell" | "seCell";
|
|
21
|
+
/** The formatting one region (or the whole-table base) contributes. */
|
|
22
|
+
export interface TableStyleCellFormat {
|
|
23
|
+
shading?: Shading;
|
|
24
|
+
borders?: TableCellBorders;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* A `<w:style w:type="table">` definition: whole-table base formatting +
|
|
28
|
+
* per-region conditional formatting + band sizes. Resolved per cell at
|
|
29
|
+
* render time against the table's `look`.
|
|
30
|
+
*/
|
|
31
|
+
export interface TableStyleDefinition {
|
|
32
|
+
/** Whole-table borders (`<w:tblBorders>` — incl. `insideH`/`insideV`). */
|
|
33
|
+
borders?: TableBorders;
|
|
34
|
+
/** Whole-table base cell shading. */
|
|
35
|
+
shading?: Shading;
|
|
36
|
+
/** Rows per horizontal band (`<w:tblStyleRowBandSize>`, default 1). */
|
|
37
|
+
rowBandSize?: number;
|
|
38
|
+
/** Columns per vertical band (`<w:tblStyleColBandSize>`, default 1). */
|
|
39
|
+
colBandSize?: number;
|
|
40
|
+
/** Whole-table default cell padding (`<w:tblCellMar>` in the style). */
|
|
41
|
+
cellMargins?: TableCellMargins;
|
|
42
|
+
conditional?: Partial<Record<TableConditionalType, TableStyleCellFormat>>;
|
|
43
|
+
}
|
package/dist/doc/types.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { BorderSpec, Shading, TableBorders, TableCellBorders, TableCellMargins
|
|
1
|
+
import { BorderSpec, Shading, TableBorders, TableCellBorders, TableCellMargins } from './formatting.types';
|
|
2
|
+
import { TableLook, TableStyleDefinition } from './tableStyle.types';
|
|
2
3
|
import { FontDeclaration as _FontDeclaration } from '../fonts/types';
|
|
3
|
-
export type { BorderSpec, Shading, TableBorders, TableCellBorders, TableCellMargins,
|
|
4
|
+
export type { BorderSpec, Shading, TableBorders, TableCellBorders, TableCellMargins, } from './formatting.types';
|
|
5
|
+
export type { TableConditionalType, TableLook, TableStyleCellFormat, TableStyleDefinition, } from './tableStyle.types';
|
|
4
6
|
export interface SobreeDocument {
|
|
5
7
|
/** Top-level body content, in document order. */
|
|
6
8
|
body: Block[];
|
package/dist/editor/index.d.ts
CHANGED
|
@@ -6,14 +6,17 @@ import { EmbedFontFaces, EmbedFontOptions } from '../fonts';
|
|
|
6
6
|
import { History } from '../history';
|
|
7
7
|
import { BlockRegistry } from './internal/blockRegistry';
|
|
8
8
|
import { countBlocks } from './internal/positionMap';
|
|
9
|
+
import { EditorNumbering } from './numbering';
|
|
10
|
+
import { EditorSections } from './sections';
|
|
9
11
|
import { EditorSelection } from './selection';
|
|
12
|
+
import { EditorStyles } from './styles';
|
|
10
13
|
import { EditorTable } from './table';
|
|
11
|
-
import { ApiRangeType, BlockInfo, ChangePayload, CommandBus, CommandDefinition, CommandSnapshot, EditorEvent, EditorEventPayload, EditorOptions, KeyDownPayload, OutlineItem, ParagraphPropertiesPatch, RevisionSpan, SelectionPayload, TrackChangesState, Unsubscribe, WrapTag } from './types';
|
|
14
|
+
import { ApiRangeType, BlockInfo, ChangePayload, CommandBus, CommandDefinition, CommandSnapshot, EditorEvent, EditorEventPayload, EditorOptions, KeyDownPayload, NamedStylePatch, OutlineItem, ParagraphPropertiesPatch, RevisionSpan, SectionPropertiesPatch, SelectionPayload, TrackChangesState, Unsubscribe, WrapTag } from './types';
|
|
12
15
|
import * as Y from "yjs";
|
|
13
16
|
export { EditorCommands } from './commands';
|
|
14
17
|
export { EditorSelection } from './selection';
|
|
15
18
|
export type { BlockRef, EditError, EditResult, InlinePosition, Selection };
|
|
16
|
-
export type { ApiRangeType, BlockInfo, ChangePayload, CommandBus, CommandDefinition, CommandSnapshot, EditorEvent, EditorEventPayload, EditorOptions, KeyDownPayload, OutlineItem, ParagraphPropertiesPatch, RevisionSpan, SelectionPayload, TrackChangesState, Unsubscribe, WrapTag, };
|
|
19
|
+
export type { ApiRangeType, BlockInfo, ChangePayload, CommandBus, CommandDefinition, CommandSnapshot, EditorEvent, EditorEventPayload, EditorOptions, KeyDownPayload, NamedStylePatch, OutlineItem, ParagraphPropertiesPatch, RevisionSpan, SectionPropertiesPatch, SelectionPayload, TrackChangesState, Unsubscribe, WrapTag, };
|
|
17
20
|
export type { CellRef, InsertAt, InsertColumnOpts, InsertRowOpts, MergeCellsOpts, } from './types';
|
|
18
21
|
export { runsLength } from '../doc/runs';
|
|
19
22
|
export type { RunPropertiesPatch };
|
|
@@ -42,6 +45,27 @@ export declare class Editor {
|
|
|
42
45
|
* and inherits optimistic-lock checking via `replaceBlock`.
|
|
43
46
|
*/
|
|
44
47
|
readonly table: EditorTable;
|
|
48
|
+
/**
|
|
49
|
+
* Section-level edit operations — page size / margins, columns,
|
|
50
|
+
* header/footer references, vertical alignment. Grouped here (rather
|
|
51
|
+
* than as flat `Editor` methods) so the facade stays thin as the
|
|
52
|
+
* edit-op surface grows. Every method returns an `EditResult`.
|
|
53
|
+
*/
|
|
54
|
+
readonly sections: EditorSections;
|
|
55
|
+
/**
|
|
56
|
+
* Named-style edit operations — define / update / remove the style
|
|
57
|
+
* definitions content resolves through. Applying a `styleId` to content
|
|
58
|
+
* is `applyBlockProperties` / `applyRunProperties`; this manages the
|
|
59
|
+
* definitions themselves. Every method returns an `EditResult`.
|
|
60
|
+
*/
|
|
61
|
+
readonly styles: EditorStyles;
|
|
62
|
+
/**
|
|
63
|
+
* Numbering / list-definition edit operations — define / update / remove
|
|
64
|
+
* the list formats paragraphs reference by `numId`. Pointing a paragraph
|
|
65
|
+
* at a list is `applyBlockProperties`; this manages the definitions.
|
|
66
|
+
* Every method returns an `EditResult`.
|
|
67
|
+
*/
|
|
68
|
+
readonly numbering: EditorNumbering;
|
|
45
69
|
/**
|
|
46
70
|
* Named-command registry — the coordination point between plugins.
|
|
47
71
|
* Plugins register commands on attach and unregister on detach;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RunPropertiesPatch } from '../../doc/runs';
|
|
2
|
-
import { Block, ParagraphProperties, RunProperties, SectionProperties, SobreeDocument } from '../../doc/types';
|
|
3
|
-
import { ParagraphPropertiesPatch, WrapTag } from '../types';
|
|
2
|
+
import { Block, NamedStyle, ParagraphProperties, RunProperties, SectionProperties, SobreeDocument } from '../../doc/types';
|
|
3
|
+
import { NamedStylePatch, ParagraphPropertiesPatch, SectionPropertiesPatch, WrapTag } from '../types';
|
|
4
4
|
/**
|
|
5
5
|
* One registry-level operation produced by a mutation. The caller
|
|
6
6
|
* applies these to the BlockRegistry after committing the new doc:
|
|
@@ -49,6 +49,19 @@ export declare function mergeSectionsAcross(sections: readonly SectionProperties
|
|
|
49
49
|
* overwrites.
|
|
50
50
|
*/
|
|
51
51
|
export declare function mergeParagraphProps(prev: ParagraphProperties, patch: ParagraphPropertiesPatch): ParagraphProperties;
|
|
52
|
+
/**
|
|
53
|
+
* Merge a {@link SectionPropertiesPatch} onto existing section properties.
|
|
54
|
+
* `pageSize` / `pageMargins` are FIELD-merged (a partial stays valid); the
|
|
55
|
+
* other fields replace wholesale. For the optional fields (`columns`,
|
|
56
|
+
* `titlePage`, `type`, `vAlign`) an explicit `undefined` clears them, while
|
|
57
|
+
* the required `headerRefs` / `footerRefs` only replace when present.
|
|
58
|
+
*/
|
|
59
|
+
export declare function mergeSectionProps(prev: SectionProperties, patch: SectionPropertiesPatch): SectionProperties;
|
|
60
|
+
/** Merge a {@link NamedStylePatch} onto an existing style. Each present
|
|
61
|
+
* field replaces the style's field wholesale; an explicit `undefined`
|
|
62
|
+
* clears an OPTIONAL field. The required `type` / `displayName` are never
|
|
63
|
+
* cleared (an undefined for them is ignored). */
|
|
64
|
+
export declare function mergeNamedStyle(prev: NamedStyle, patch: NamedStylePatch): NamedStyle;
|
|
52
65
|
/**
|
|
53
66
|
* Map a semantic "wrap" tag to the run-property patch that achieves it.
|
|
54
67
|
* Same mapping the browser editor uses for toolbar buttons.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { EditResult } from '../doc/api';
|
|
2
|
+
import { NumberingDefinition, NumberingLevel } from '../doc/types';
|
|
3
|
+
import { EditorContext } from './context';
|
|
4
|
+
export declare class EditorNumbering {
|
|
5
|
+
private readonly ctx;
|
|
6
|
+
constructor(ctx: EditorContext);
|
|
7
|
+
/** Add a new numbering definition. Fails if `def.numId` already exists. */
|
|
8
|
+
define(def: NumberingDefinition): EditResult<void>;
|
|
9
|
+
/** Replace the levels of the definition with `numId`. Fails if missing. */
|
|
10
|
+
update(numId: number, levels: NumberingLevel[]): EditResult<void>;
|
|
11
|
+
/** Remove the definition with `numId`. Fails if missing. Paragraphs that
|
|
12
|
+
* still reference it render without a marker. */
|
|
13
|
+
remove(numId: number): EditResult<void>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { EditResult } from '../doc/api';
|
|
2
|
+
import { EditorContext } from './context';
|
|
3
|
+
import { SectionPropertiesPatch } from './types';
|
|
4
|
+
export declare class EditorSections {
|
|
5
|
+
private readonly ctx;
|
|
6
|
+
constructor(ctx: EditorContext);
|
|
7
|
+
/**
|
|
8
|
+
* Merge a patch into the section at `index`: page size / margins,
|
|
9
|
+
* columns, header/footer refs, vertical alignment. `pageSize` /
|
|
10
|
+
* `pageMargins` are field-merged (a partial stays valid); other fields
|
|
11
|
+
* replace wholesale, and an explicit `undefined` clears an optional one.
|
|
12
|
+
* Re-renders page geometry; undo-integrated.
|
|
13
|
+
*/
|
|
14
|
+
setProperties(index: number, patch: SectionPropertiesPatch): EditResult<void>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { EditResult } from '../doc/api';
|
|
2
|
+
import { NamedStyle } from '../doc/types';
|
|
3
|
+
import { EditorContext } from './context';
|
|
4
|
+
import { NamedStylePatch } from './types';
|
|
5
|
+
export declare class EditorStyles {
|
|
6
|
+
private readonly ctx;
|
|
7
|
+
constructor(ctx: EditorContext);
|
|
8
|
+
/** Add a new style. Fails if a style with the same `id` already exists
|
|
9
|
+
* (use {@link update} to change one). */
|
|
10
|
+
define(style: NamedStyle): EditResult<void>;
|
|
11
|
+
/** Merge a patch into the style with `id`. Fails if no such style. */
|
|
12
|
+
update(id: string, patch: NamedStylePatch): EditResult<void>;
|
|
13
|
+
/** Remove the style with `id`. Fails if no such style. Content that
|
|
14
|
+
* still references it falls back to the cascade's defaults. */
|
|
15
|
+
remove(id: string): EditResult<void>;
|
|
16
|
+
}
|
package/dist/editor/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BlobStore } from '../blob';
|
|
2
2
|
import { Range as ApiRange, BlockRef, EditResult, InlinePosition, Selection } from '../doc/api';
|
|
3
3
|
import { RunPropertiesPatch } from '../doc/runs';
|
|
4
|
-
import { Block, ParagraphAlignment, ParagraphProperties, SobreeDocument } from '../doc/types';
|
|
4
|
+
import { Block, HeaderFooterRef, NamedStyle, PageMargins, PageSize, ParagraphAlignment, ParagraphProperties, SectionColumns, SectionProperties, SobreeDocument } from '../doc/types';
|
|
5
5
|
/**
|
|
6
6
|
* Editor-surface types — the public type vocabulary of the `Editor`
|
|
7
7
|
* façade (events, payloads, command bus, options, tracked-change spans).
|
|
@@ -121,6 +121,32 @@ export interface OutlineItem {
|
|
|
121
121
|
export type ParagraphPropertiesPatch = {
|
|
122
122
|
[K in keyof ParagraphProperties]?: ParagraphProperties[K] | undefined;
|
|
123
123
|
};
|
|
124
|
+
/**
|
|
125
|
+
* Patch for a section's properties (page geometry, columns, header/footer
|
|
126
|
+
* refs, vertical alignment). `pageSize` / `pageMargins` are FIELD-merged
|
|
127
|
+
* into the existing values (so a partial — e.g. just `orientation` or
|
|
128
|
+
* `topTwips` — stays valid); every other field REPLACES wholesale, and an
|
|
129
|
+
* explicit `undefined` on an optional field clears it.
|
|
130
|
+
*/
|
|
131
|
+
export interface SectionPropertiesPatch {
|
|
132
|
+
pageSize?: Partial<PageSize>;
|
|
133
|
+
pageMargins?: Partial<PageMargins>;
|
|
134
|
+
columns?: SectionColumns | undefined;
|
|
135
|
+
headerRefs?: HeaderFooterRef[];
|
|
136
|
+
footerRefs?: HeaderFooterRef[];
|
|
137
|
+
titlePage?: boolean | undefined;
|
|
138
|
+
type?: SectionProperties["type"];
|
|
139
|
+
vAlign?: SectionProperties["vAlign"];
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Patch for an existing named style (everything except its `id`). Each
|
|
143
|
+
* present field replaces the style's corresponding field wholesale; an
|
|
144
|
+
* explicit `undefined` clears an optional one. The required `type` /
|
|
145
|
+
* `displayName` are never cleared.
|
|
146
|
+
*/
|
|
147
|
+
export type NamedStylePatch = {
|
|
148
|
+
[K in keyof Omit<NamedStyle, "id">]?: NamedStyle[K] | undefined;
|
|
149
|
+
};
|
|
124
150
|
export type WrapTag = "sup" | "sub" | "strong" | "em" | "u" | "s" | "mark";
|
|
125
151
|
/** The slice of selection state plugins read (see {@link EditorLike}). */
|
|
126
152
|
export interface EditorSelectionLike {
|
package/dist/headless.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BlobCache, BlobStore } from './blob';
|
|
2
2
|
import { BlockRef, EditError, EditResult, Selection } from './doc/api';
|
|
3
|
-
import { Block, ParagraphAlignment, ParagraphProperties, SobreeDocument } from './doc/types';
|
|
4
|
-
import { ParagraphPropertiesPatch, BlockInfo, CommandBus, OutlineItem } from './editor';
|
|
3
|
+
import { Block, NamedStyle, NumberingDefinition, NumberingLevel, ParagraphAlignment, ParagraphProperties, SobreeDocument } from './doc/types';
|
|
4
|
+
import { ParagraphPropertiesPatch, BlockInfo, CommandBus, NamedStylePatch, OutlineItem, SectionPropertiesPatch } from './editor';
|
|
5
5
|
import { History } from './history';
|
|
6
6
|
/**
|
|
7
7
|
* HeadlessSobree — a no-DOM Sobree peer for LLM agents, automation,
|
|
@@ -148,6 +148,22 @@ export declare class HeadlessSobree {
|
|
|
148
148
|
deleteBlock(target: BlockRef): EditResult<void>;
|
|
149
149
|
/** Merge a patch into each target paragraph's properties. */
|
|
150
150
|
applyBlockProperties(targets: BlockRef[], patch: ParagraphPropertiesPatch): EditResult<void>;
|
|
151
|
+
/** Merge a patch into a section's properties (page geometry, columns,
|
|
152
|
+
* header/footer refs, vertical alignment). `sectionIndex` is the
|
|
153
|
+
* section's position in the document's `sections` array. */
|
|
154
|
+
applySectionProperties(sectionIndex: number, patch: SectionPropertiesPatch): EditResult<void>;
|
|
155
|
+
/** Add a new named style. Fails if `style.id` already exists. */
|
|
156
|
+
defineStyle(style: NamedStyle): EditResult<void>;
|
|
157
|
+
/** Merge a patch into the style with `id`. Fails if no such style. */
|
|
158
|
+
updateStyle(id: string, patch: NamedStylePatch): EditResult<void>;
|
|
159
|
+
/** Remove the style with `id`. Fails if no such style. */
|
|
160
|
+
removeStyle(id: string): EditResult<void>;
|
|
161
|
+
/** Add a new numbering definition. Fails if `def.numId` already exists. */
|
|
162
|
+
defineNumbering(def: NumberingDefinition): EditResult<void>;
|
|
163
|
+
/** Replace the levels of the definition with `numId`. Fails if missing. */
|
|
164
|
+
updateNumbering(numId: number, levels: NumberingLevel[]): EditResult<void>;
|
|
165
|
+
/** Remove the definition with `numId`. Fails if missing. */
|
|
166
|
+
removeNumbering(numId: number): EditResult<void>;
|
|
151
167
|
on<E extends HeadlessEvent>(event: E, cb: (payload: HeadlessChangePayload) => void): HeadlessUnsubscribe;
|
|
152
168
|
destroy(): void;
|
|
153
169
|
private allBlockIds;
|