superdoc 2.24.0-next.8 → 2.24.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/collaboration-upgrade-engine.cjs +1 -1
- package/dist/collaboration-upgrade-engine.es.js +1 -1
- package/dist/document-api/src/authorities/authorities.types.d.ts +2 -0
- package/dist/document-api/src/bookmarks/bookmarks.types.d.ts +1 -0
- package/dist/document-api/src/captions/captions.types.d.ts +1 -0
- package/dist/document-api/src/citations/citations.types.d.ts +2 -0
- package/dist/document-api/src/content-controls/content-controls.types.d.ts +1 -0
- package/dist/document-api/src/contract/command-catalog.d.ts +1 -1
- package/dist/document-api/src/contract/operation-definitions.d.ts +22 -4
- package/dist/document-api/src/cross-refs/cross-refs.types.d.ts +1 -0
- package/dist/document-api/src/fields/fields.types.d.ts +1 -0
- package/dist/document-api/src/footnotes/footnotes.types.d.ts +2 -0
- package/dist/document-api/src/get/get.d.ts +2 -1
- package/dist/document-api/src/hyperlinks/hyperlinks.types.d.ts +1 -0
- package/dist/document-api/src/images/images.types.d.ts +2 -0
- package/dist/document-api/src/index/index.types.d.ts +2 -0
- package/dist/document-api/src/index.d.ts +9 -6
- package/dist/document-api/src/inline-semantics/token-sets.d.ts +11 -0
- package/dist/document-api/src/lists/lists.types.d.ts +10 -0
- package/dist/document-api/src/paragraphs/paragraphs.types.d.ts +3 -0
- package/dist/document-api/src/receipt-bridge.d.ts +1 -0
- package/dist/document-api/src/sections/sections.types.d.ts +4 -1
- package/dist/document-api/src/styles/apply.d.ts +5 -0
- package/dist/document-api/src/styles/catalog.d.ts +40 -19
- package/dist/document-api/src/styles/create.d.ts +160 -0
- package/dist/document-api/src/styles/index.d.ts +8 -4
- package/dist/document-api/src/styles/registry.d.ts +34 -2
- package/dist/document-api/src/styles/schema.d.ts +24 -5
- package/dist/document-api/src/styles/theme.d.ts +32 -0
- package/dist/document-api/src/styles/validation.d.ts +11 -2
- package/dist/document-api/src/templates/apply.d.ts +13 -15
- package/dist/document-api/src/toc/toc.types.d.ts +3 -0
- package/dist/document-api/src/types/blocks.types.d.ts +6 -1
- package/dist/document-api/src/types/create.types.d.ts +3 -1
- package/dist/document-api/src/types/fragment.d.ts +3 -0
- package/dist/document-api/src/types/mutation-plan.types.d.ts +4 -0
- package/dist/document-api/src/types/query-match.types.d.ts +43 -5
- package/dist/document-api/src/types/receipt.d.ts +8 -0
- package/dist/document-api/src/types/sd-contract.d.ts +2 -0
- package/dist/document-api/src/types/sd-props.d.ts +54 -14
- package/dist/document-api/src/types/sd-styles.d.ts +58 -3
- package/dist/document-api/src/types/table-operations.types.d.ts +2 -0
- package/dist/style.css +22 -22
- package/dist/style.layered.css +22 -22
- package/dist/superdoc/src/core/editor-runtime/v2/v2-session-shortcut-routes.d.ts +2 -0
- package/dist/superdoc.cjs +11 -8
- package/dist/superdoc.es.js +11 -8
- package/dist-cdn/style.layered.css +1 -1
- package/dist-cdn/superdoc.min.css +1 -1
- package/dist-cdn/superdoc.min.js +18 -18
- package/package.json +2 -2
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { ReceiptFailure } from '../types/receipt.js';
|
|
2
|
+
import { SDHighlightColor } from '../types/sd-props.js';
|
|
3
|
+
import { StylesParagraphPatch, StylesRunPatch, StylesStateMap } from './apply.js';
|
|
4
|
+
/**
|
|
5
|
+
* Run properties of a named style.
|
|
6
|
+
*
|
|
7
|
+
* A superset of {@link StylesRunPatch}: the four properties Word forbids in
|
|
8
|
+
* `w:docDefaults` and allows on a `w:style` are reachable here and nowhere
|
|
9
|
+
* else. `rtl` in particular is the property that makes a run right-to-left, so
|
|
10
|
+
* without it no right-to-left style could be authored through this API.
|
|
11
|
+
*/
|
|
12
|
+
export interface StyleRunPatch extends StylesRunPatch {
|
|
13
|
+
/** `w:cs` — treat the run as complex-script. */
|
|
14
|
+
cs?: boolean;
|
|
15
|
+
/** `w:rtl` — right-to-left run. */
|
|
16
|
+
rtl?: boolean;
|
|
17
|
+
/** `w:oMath` — the run is part of an equation. */
|
|
18
|
+
oMath?: boolean;
|
|
19
|
+
/** `w:highlight` — one of the closed `ST_HighlightColor` tokens. */
|
|
20
|
+
highlight?: SDHighlightColor;
|
|
21
|
+
}
|
|
22
|
+
/** What to do when a style with this `id`, or this `name`, already exists. */
|
|
23
|
+
export type StyleConflictPolicy = 'fail' | 'replace';
|
|
24
|
+
interface StylesCreateCommon {
|
|
25
|
+
/** `w:styleId`. Named `id` to match {@link StyleCatalogItem.id} on read. */
|
|
26
|
+
id: string;
|
|
27
|
+
/** `w:name`. */
|
|
28
|
+
name: string;
|
|
29
|
+
/** `w:basedOn`. `null` states "based on nothing" explicitly. */
|
|
30
|
+
basedOn?: string | null;
|
|
31
|
+
/** `w:aliases`, one entry per alias. */
|
|
32
|
+
aliases?: string[];
|
|
33
|
+
/** `w:uiPriority`. Named `priority` to match the catalogue on read. */
|
|
34
|
+
priority?: number | null;
|
|
35
|
+
/** `w:qFormat` — offer the style in Word's quick gallery. */
|
|
36
|
+
qFormat?: boolean;
|
|
37
|
+
/** `w:hidden`. */
|
|
38
|
+
hidden?: boolean;
|
|
39
|
+
/** `w:semiHidden`. */
|
|
40
|
+
semiHidden?: boolean;
|
|
41
|
+
/** `w:unhideWhenUsed`. */
|
|
42
|
+
unhideWhenUsed?: boolean;
|
|
43
|
+
/** `w:locked`. */
|
|
44
|
+
locked?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* `w:customStyle`. Defaults to `true`, which is what a style authored
|
|
47
|
+
* through this API is. Setting it `false` on a style whose name is not a
|
|
48
|
+
* built-in makes Word treat the name as one and re-label or hide the style.
|
|
49
|
+
*/
|
|
50
|
+
custom?: boolean;
|
|
51
|
+
/** Defaults to `'fail'`. */
|
|
52
|
+
conflictPolicy?: StyleConflictPolicy;
|
|
53
|
+
}
|
|
54
|
+
export interface StylesCreateParagraphInput extends StylesCreateCommon {
|
|
55
|
+
type: 'paragraph';
|
|
56
|
+
/** `w:next`. May name the style being created. */
|
|
57
|
+
next?: string | null;
|
|
58
|
+
/** `w:style/w:pPr`. */
|
|
59
|
+
paragraph?: StylesParagraphPatch;
|
|
60
|
+
/** `w:style/w:rPr`. */
|
|
61
|
+
run?: StyleRunPatch;
|
|
62
|
+
}
|
|
63
|
+
export interface StylesCreateCharacterInput extends StylesCreateCommon {
|
|
64
|
+
type: 'character';
|
|
65
|
+
/** A character style has no following-paragraph style. */
|
|
66
|
+
next?: never;
|
|
67
|
+
/** A character style has no paragraph properties. */
|
|
68
|
+
paragraph?: never;
|
|
69
|
+
/** `w:style/w:rPr`. */
|
|
70
|
+
run?: StyleRunPatch;
|
|
71
|
+
}
|
|
72
|
+
export type StylesCreateInput = StylesCreateParagraphInput | StylesCreateCharacterInput;
|
|
73
|
+
export interface StylesCreateOptions {
|
|
74
|
+
dryRun?: boolean;
|
|
75
|
+
expectedRevision?: string;
|
|
76
|
+
}
|
|
77
|
+
export interface NormalizedStylesCreateOptions {
|
|
78
|
+
dryRun: boolean;
|
|
79
|
+
expectedRevision: string | undefined;
|
|
80
|
+
}
|
|
81
|
+
export interface StylesCreateResolution {
|
|
82
|
+
scope: 'style';
|
|
83
|
+
id: string;
|
|
84
|
+
type: 'paragraph' | 'character';
|
|
85
|
+
xmlPart: string;
|
|
86
|
+
/**
|
|
87
|
+
* Literal, not `string`: `styles.apply` pins its two paths in the published
|
|
88
|
+
* schema and exports them as constants for the adapter to bind to. Without
|
|
89
|
+
* the narrowing an adapter could report the more specific
|
|
90
|
+
* `w:styles/w:style[@w:styleId='X']`, type-check, and then fail the schema.
|
|
91
|
+
*/
|
|
92
|
+
xmlPath: typeof STYLE_XML_PATH;
|
|
93
|
+
}
|
|
94
|
+
/** The `w:style` element path. Predicate-free, like `XML_PATH_BY_CHANNEL`. */
|
|
95
|
+
export declare const STYLE_XML_PATH = "w:styles/w:style";
|
|
96
|
+
/**
|
|
97
|
+
* Per-channel state, unlike {@link StylesApplyReceipt}'s flat map.
|
|
98
|
+
*
|
|
99
|
+
* `styles.apply` can be flat because `resolution.channel` says which channel
|
|
100
|
+
* the map describes. One `w:style` carries both at once, and `snapToGrid`,
|
|
101
|
+
* `shading` and `borders` exist on both — `borders` with genuinely different
|
|
102
|
+
* shapes (`w:bdr`, one border, against `w:pBdr`, six edges). Folded together
|
|
103
|
+
* they would be indistinguishable.
|
|
104
|
+
*/
|
|
105
|
+
export interface StyleChannelState {
|
|
106
|
+
paragraph: StylesStateMap | null;
|
|
107
|
+
run: StylesStateMap | null;
|
|
108
|
+
}
|
|
109
|
+
export interface StylesCreateReceiptSuccess {
|
|
110
|
+
success: true;
|
|
111
|
+
/** `false` when the definition already matched the input. */
|
|
112
|
+
changed: boolean;
|
|
113
|
+
/**
|
|
114
|
+
* `false` when an existing style was redefined under `conflictPolicy:
|
|
115
|
+
* 'replace'`. `created: true` implies `changed: true`. Under `dryRun` it
|
|
116
|
+
* describes what the call would have done.
|
|
117
|
+
*
|
|
118
|
+
* `ReceiptSuccess.inserted` / `updated` are deliberately not used: they take
|
|
119
|
+
* `EntityAddress`, and a style definition is not addressable as a document
|
|
120
|
+
* entity.
|
|
121
|
+
*/
|
|
122
|
+
created: boolean;
|
|
123
|
+
resolution: StylesCreateResolution;
|
|
124
|
+
dryRun: boolean;
|
|
125
|
+
/** `null` when the style did not exist. */
|
|
126
|
+
before: StyleChannelState | null;
|
|
127
|
+
after: StyleChannelState;
|
|
128
|
+
}
|
|
129
|
+
export interface StylesCreateReceiptFailure {
|
|
130
|
+
success: false;
|
|
131
|
+
failure: ReceiptFailure;
|
|
132
|
+
}
|
|
133
|
+
export type StylesCreateReceipt = StylesCreateReceiptSuccess | StylesCreateReceiptFailure;
|
|
134
|
+
export interface StylesCreateAdapter {
|
|
135
|
+
create(input: StylesCreateInput, options: NormalizedStylesCreateOptions): StylesCreateReceipt;
|
|
136
|
+
}
|
|
137
|
+
export interface StylesCreateApi {
|
|
138
|
+
create(input: StylesCreateInput, options?: StylesCreateOptions): StylesCreateReceipt;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Validates the shape of `styles.create` input.
|
|
142
|
+
*
|
|
143
|
+
* Deliberately shallow on identifiers: `id` is checked for "non-empty string"
|
|
144
|
+
* and nothing more, exactly as `styles.paragraph.setStyleRef` checks the same
|
|
145
|
+
* field. `w:styleId` is an `ST_String`, real documents carry ids with spaces,
|
|
146
|
+
* and a stricter rule here would mean `setStyleRef` could apply a style that
|
|
147
|
+
* `styles.create` cannot express.
|
|
148
|
+
*/
|
|
149
|
+
export declare function validateStylesCreateInput(input: unknown): asserts input is StylesCreateInput;
|
|
150
|
+
export declare function validateStylesCreateOptions(options: unknown): void;
|
|
151
|
+
/**
|
|
152
|
+
* Executes `styles.create` using the provided adapter.
|
|
153
|
+
*
|
|
154
|
+
* Fails closed when the host engine has no `create` hook, the same way
|
|
155
|
+
* `executeStylesGetCatalog` does for its optional catalogue hook — input is
|
|
156
|
+
* validated first, so a malformed call is reported as malformed rather than as
|
|
157
|
+
* an unavailable capability.
|
|
158
|
+
*/
|
|
159
|
+
export declare function executeStylesCreate(adapter: Partial<StylesCreateAdapter> | null | undefined, input: StylesCreateInput, options?: StylesCreateOptions): StylesCreateReceipt;
|
|
160
|
+
export {};
|
|
@@ -3,12 +3,16 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Public surface only: internal validation/schema helpers are not exposed.
|
|
5
5
|
*/
|
|
6
|
-
export type { ValueSchema, StylesChannel, MergeStrategy, PropertyDefinition } from './registry.js';
|
|
7
|
-
export { PROPERTY_REGISTRY, ALLOWED_KEYS_BY_CHANNEL, EXCLUDED_KEYS, XML_PATH_BY_CHANNEL, getPropertyDefinition, ST_VERTICAL_ALIGN_RUN, ST_EM, ST_TEXT_ALIGNMENT, ST_TEXT_DIRECTION, ST_TEXTBOX_TIGHT_WRAP, ST_TEXT_TRANSFORM, ST_JUSTIFICATION, } from './registry.js';
|
|
6
|
+
export type { ValueSchema, StylesChannel, StylesScope, MergeStrategy, PropertyDefinition } from './registry.js';
|
|
7
|
+
export { PROPERTY_REGISTRY, ALLOWED_KEYS_BY_CHANNEL, EXCLUDED_KEYS, STYLE_EXCLUDED_KEYS, EXCLUDED_KEYS_BY_SCOPE, SCOPE_LABEL, XML_PATH_BY_CHANNEL, getPropertyDefinition, ST_VERTICAL_ALIGN_RUN, ST_EM, ST_TEXT_ALIGNMENT, ST_TEXT_DIRECTION, ST_TEXTBOX_TIGHT_WRAP, ST_TEXT_TRANSFORM, ST_JUSTIFICATION, } from './registry.js';
|
|
8
8
|
export { toJsonSchema, buildPatchSchema, buildStateSchema } from './schema.js';
|
|
9
9
|
export type { StylesBooleanState, StylesNumberState, StylesEnumState, StylesObjectState, StylesArrayState, StylesRunPatch, StylesParagraphPatch, StylesTargetResolution, StylesApplyRunInput, StylesApplyParagraphInput, StylesApplyInput, StylesApplyOptions, StylesStateMap, StylesApplyReceiptSuccess, StylesApplyReceiptFailure, StylesApplyReceipt, StylesAdapter, NormalizedStylesApplyOptions, StylesApi, } from './apply.js';
|
|
10
10
|
export { executeStylesApply } from './apply.js';
|
|
11
|
-
export type {
|
|
11
|
+
export type { StyleRunPatch, StyleConflictPolicy, StyleChannelState, StylesCreateParagraphInput, StylesCreateCharacterInput, StylesCreateInput, StylesCreateOptions, NormalizedStylesCreateOptions, StylesCreateResolution, StylesCreateReceiptSuccess, StylesCreateReceiptFailure, StylesCreateReceipt, StylesCreateAdapter, StylesCreateApi, } from './create.js';
|
|
12
|
+
export { STYLE_XML_PATH, executeStylesCreate, validateStylesCreateInput, validateStylesCreateOptions, } from './create.js';
|
|
13
|
+
export type { StyleCatalogView, StyleCatalogItemType, StyleCatalogFilterType, StyleProvenance, StyleCatalogDiagnosticSeverity, StyleSourcePartStatus, StyleCatalogUsageStatus, StyleCatalogPreviewStatus, StyleCatalogViewStatus, StyleCatalogItemVisibility, StyleCatalogItemUsage, StyleCatalogItemPreview, StyleCatalogPreviewFontSource, StyleCatalogPreviewColorSource, StyleCatalogPreviewSources, StyleCatalogItem, StyleCatalogDefaults, StyleCatalogDiagnostic, StyleCatalogSourceStatus, StylesGetCatalogInput, StylesGetCatalogResult, StylesGetCatalogAdapter, } from './catalog.js';
|
|
12
14
|
export { STYLE_CATALOG_VIEWS, STYLE_CATALOG_FILTER_TYPES, executeStylesGetCatalog, validateStylesGetCatalogInput, } from './catalog.js';
|
|
15
|
+
export type { StylesGetThemeInput, StylesThemeSourceStatus, StylesGetThemeResult, StylesGetThemeAdapter, } from './theme.js';
|
|
16
|
+
export { executeStylesGetTheme, validateStylesGetThemeInput } from './theme.js';
|
|
13
17
|
export type { PatchKeyClassification } from './validation.js';
|
|
14
|
-
export { validateValue, classifyPatchKey } from './validation.js';
|
|
18
|
+
export { validateValue, classifyPatchKey, validatePatchObject } from './validation.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ST_UNDERLINE_VALUES } from '../inline-semantics/token-sets.js';
|
|
1
|
+
import { ST_HIGHLIGHT_VALUES, ST_UNDERLINE_VALUES } from '../inline-semantics/token-sets.js';
|
|
2
2
|
export declare const ST_VERTICAL_ALIGN_RUN: readonly ["superscript", "subscript", "baseline"];
|
|
3
3
|
export declare const ST_EM: readonly ["none", "dot", "comma", "circle", "sesame"];
|
|
4
4
|
export declare const ST_TEXT_ALIGNMENT: readonly ["top", "center", "baseline", "bottom", "auto"];
|
|
@@ -6,7 +6,7 @@ export declare const ST_TEXT_DIRECTION: readonly ["lrTb", "tbRl", "btLr", "lrTbV
|
|
|
6
6
|
export declare const ST_TEXTBOX_TIGHT_WRAP: readonly ["none", "allLines", "firstAndLastLine", "firstLineOnly", "lastLineOnly"];
|
|
7
7
|
export declare const ST_TEXT_TRANSFORM: readonly ["uppercase", "none"];
|
|
8
8
|
export declare const ST_JUSTIFICATION: readonly ["left", "center", "right", "justify", "distribute"];
|
|
9
|
-
export { ST_UNDERLINE_VALUES };
|
|
9
|
+
export { ST_HIGHLIGHT_VALUES, ST_UNDERLINE_VALUES };
|
|
10
10
|
/** Recursive schema AST describing the shape of a property value. */
|
|
11
11
|
export type ValueSchema = {
|
|
12
12
|
kind: 'boolean';
|
|
@@ -41,3 +41,35 @@ export declare const ALLOWED_KEYS_BY_CHANNEL: Record<StylesChannel, Set<string>>
|
|
|
41
41
|
export declare function getPropertyDefinition(key: string, channel: StylesChannel): PropertyDefinition | undefined;
|
|
42
42
|
export declare const EXCLUDED_KEYS: Record<StylesChannel, Map<string, string>>;
|
|
43
43
|
export declare const XML_PATH_BY_CHANNEL: Record<StylesChannel, string>;
|
|
44
|
+
/**
|
|
45
|
+
* Where in `word/styles.xml` a patch is being written.
|
|
46
|
+
*
|
|
47
|
+
* The exclusion list is a property of the *destination*, not of the property:
|
|
48
|
+
* `w:rtl` is disallowed in `w:docDefaults` and perfectly legal on a named
|
|
49
|
+
* `w:style`. Before this split, `EXCLUDED_KEYS` was the docDefaults list and
|
|
50
|
+
* the only list, so every caller inherited a restriction that only one of
|
|
51
|
+
* them was subject to.
|
|
52
|
+
*
|
|
53
|
+
* `docDefaults` is unchanged and remains what `styles.apply` uses.
|
|
54
|
+
*/
|
|
55
|
+
export type StylesScope = 'docDefaults' | 'style';
|
|
56
|
+
/**
|
|
57
|
+
* Keys excluded from a named `w:style`.
|
|
58
|
+
*
|
|
59
|
+
* Narrower than the docDefaults list on the run channel by exactly the four
|
|
60
|
+
* properties the style model reads back off a `w:style` (see the registry
|
|
61
|
+
* entries). `w:rPrChange` stays out because it is a revision-tracking wrapper
|
|
62
|
+
* around document content, and `w:rStyle` because the style model does not
|
|
63
|
+
* carry it on `StyleDefinition.runProperties`.
|
|
64
|
+
*
|
|
65
|
+
* The paragraph channel is unchanged: every key it excludes — `w:cnfStyle`,
|
|
66
|
+
* `w:divId`, `w:pPrChange`, `w:pStyle`, `w:pPr/w:rPr`, `w:sectPr` — is as
|
|
67
|
+
* out of place inside `w:style/w:pPr` as it is inside docDefaults. Run
|
|
68
|
+
* properties on a style live in `w:style/w:rPr`, which is the `run` channel
|
|
69
|
+
* here, not in `w:pPr/w:rPr`.
|
|
70
|
+
*/
|
|
71
|
+
export declare const STYLE_EXCLUDED_KEYS: Record<StylesChannel, Map<string, string>>;
|
|
72
|
+
/** Exclusion lists by destination. Defaults everywhere are `docDefaults`. */
|
|
73
|
+
export declare const EXCLUDED_KEYS_BY_SCOPE: Record<StylesScope, Record<StylesChannel, Map<string, string>>>;
|
|
74
|
+
/** Human-readable destination, for validation messages. */
|
|
75
|
+
export declare const SCOPE_LABEL: Record<StylesScope, string>;
|
|
@@ -1,9 +1,28 @@
|
|
|
1
|
-
import { ValueSchema, StylesChannel } from './registry.js';
|
|
1
|
+
import { ValueSchema, StylesChannel, StylesScope } from './registry.js';
|
|
2
2
|
type JsonSchema = Record<string, unknown>;
|
|
3
3
|
/** Converts a ValueSchema AST node to a JSON Schema object. */
|
|
4
4
|
export declare function toJsonSchema(schema: ValueSchema): JsonSchema;
|
|
5
|
-
/**
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Builds a JSON Schema for the patch object of a given channel and scope.
|
|
7
|
+
*
|
|
8
|
+
* The scope filter is what keeps the published `styles.apply` schema honest:
|
|
9
|
+
* the registry now carries run properties that only a named style accepts, and
|
|
10
|
+
* a schema that advertised them on `docDefaults` would describe an input the
|
|
11
|
+
* validator rejects.
|
|
12
|
+
*/
|
|
13
|
+
export declare function buildPatchSchema(channel: StylesChannel, scope?: StylesScope): JsonSchema;
|
|
14
|
+
/**
|
|
15
|
+
* Builds a JSON Schema for the before/after state map of a given scope.
|
|
16
|
+
*
|
|
17
|
+
* Scoped for the same reason `buildPatchSchema` is: a receipt cannot report
|
|
18
|
+
* state for a property the scope does not accept, and advertising one both
|
|
19
|
+
* misleads a contract-driven caller and loosens receipt validation, since these
|
|
20
|
+
* objects carry `additionalProperties: false`.
|
|
21
|
+
*
|
|
22
|
+
* `channel` narrows it further, for a receipt that reports the two channels
|
|
23
|
+
* separately. Omitted, both fold into one map — correct only where something
|
|
24
|
+
* else in the receipt says which channel it describes, as `styles.apply`'s
|
|
25
|
+
* `resolution.channel` does.
|
|
26
|
+
*/
|
|
27
|
+
export declare function buildStateSchema(scope?: StylesScope, channel?: StylesChannel): JsonSchema;
|
|
9
28
|
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { SDTheme } from '../types/sd-styles.js';
|
|
2
|
+
import { StyleCatalogDiagnostic, StyleSourcePartStatus } from './catalog.js';
|
|
3
|
+
/** `styles.getTheme` takes no options. */
|
|
4
|
+
export type StylesGetThemeInput = Record<string, never>;
|
|
5
|
+
/**
|
|
6
|
+
* Status of the package parts the theme is read from. A `missing` or
|
|
7
|
+
* `malformed` theme part still yields a theme: the default Office theme,
|
|
8
|
+
* labeled `source: 'fallback'`.
|
|
9
|
+
*/
|
|
10
|
+
export interface StylesThemeSourceStatus {
|
|
11
|
+
theme: StyleSourcePartStatus;
|
|
12
|
+
/** `word/settings.xml`, which carries `w:clrSchemeMapping`. */
|
|
13
|
+
settings: StyleSourcePartStatus;
|
|
14
|
+
}
|
|
15
|
+
export interface StylesGetThemeResult {
|
|
16
|
+
/** Always present. `source` says whether it is the document's own theme or the Office fallback. */
|
|
17
|
+
theme: SDTheme & {
|
|
18
|
+
source: 'document' | 'fallback';
|
|
19
|
+
};
|
|
20
|
+
sourceStatus: StylesThemeSourceStatus;
|
|
21
|
+
diagnostics: StyleCatalogDiagnostic[];
|
|
22
|
+
}
|
|
23
|
+
export interface StylesGetThemeAdapter {
|
|
24
|
+
getTheme(input?: StylesGetThemeInput): StylesGetThemeResult;
|
|
25
|
+
}
|
|
26
|
+
/** Validates `styles.getTheme` input. `undefined` and `{}` are the only valid calls. */
|
|
27
|
+
export declare function validateStylesGetThemeInput(input?: StylesGetThemeInput): void;
|
|
28
|
+
/**
|
|
29
|
+
* Executes `styles.getTheme` using the provided adapter.
|
|
30
|
+
* Validates input, then delegates to the adapter.
|
|
31
|
+
*/
|
|
32
|
+
export declare function executeStylesGetTheme(adapter: Partial<StylesGetThemeAdapter> | null | undefined, input?: StylesGetThemeInput): StylesGetThemeResult;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ValueSchema, StylesChannel } from './registry.js';
|
|
1
|
+
import { ValueSchema, StylesChannel, StylesScope } from './registry.js';
|
|
2
2
|
/**
|
|
3
3
|
* Validates a value against a ValueSchema AST node.
|
|
4
4
|
*
|
|
@@ -35,4 +35,13 @@ export type PatchKeyClassification = {
|
|
|
35
35
|
* nesting conditionals across excluded-key maps, allowed-key sets, and
|
|
36
36
|
* cross-channel lookups.
|
|
37
37
|
*/
|
|
38
|
-
export declare function classifyPatchKey(key: string, channel: StylesChannel): PatchKeyClassification;
|
|
38
|
+
export declare function classifyPatchKey(key: string, channel: StylesChannel, scope?: StylesScope): PatchKeyClassification;
|
|
39
|
+
/**
|
|
40
|
+
* Validates the keys and values of a patch object against one channel.
|
|
41
|
+
*
|
|
42
|
+
* Shared by `styles.apply` (scope `docDefaults`) and `styles.create` (scope
|
|
43
|
+
* `style`); `field` names the caller's own input path so the error points at
|
|
44
|
+
* `patch` or at `run` / `paragraph` rather than at whichever one happened to
|
|
45
|
+
* write this code.
|
|
46
|
+
*/
|
|
47
|
+
export declare function validatePatchObject(patch: Record<string, unknown>, channel: StylesChannel, scope: StylesScope, field: string): void;
|
|
@@ -3,19 +3,17 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Adopts a source DOCX's template **style system and reusable template assets**
|
|
5
5
|
* onto the currently open document while preserving the open document's
|
|
6
|
-
* body/story content
|
|
7
|
-
*
|
|
6
|
+
* body/story content. Source body content is never copied; `word/document.xml`
|
|
7
|
+
* is rewritten only to adopt section defaults. The adoption semantics are:
|
|
8
8
|
*
|
|
9
9
|
* - `styles`: source-authoritative overlap. For a `styleId` defined in both
|
|
10
10
|
* documents the source definition wins **in place** under the original id
|
|
11
11
|
* (no `*-tmpl` rename). The source `w:docDefaults` and `w:latentStyles`
|
|
12
|
-
* singletons replace the target's. Source-only styles are imported;
|
|
13
|
-
* styles
|
|
14
|
-
* - `numbering`:
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* deterministically, and references are rewritten coherently in both
|
|
18
|
-
* `numbering.xml` and `styles.xml`.
|
|
12
|
+
* singletons replace the target's. Source-only styles are imported; all
|
|
13
|
+
* target-only styles are retained.
|
|
14
|
+
* - `numbering`: every source `w:abstractNum`/`w:num` is appended. Colliding
|
|
15
|
+
* ids are remapped deterministically, and imported styles are rewritten to
|
|
16
|
+
* the remapped ids. Re-applying the same source appends the definitions again.
|
|
19
17
|
* - `settings`: bounded reconciliation — layout/style-affecting settings (e.g.
|
|
20
18
|
* default tab stop) are adopted; identity/workflow settings (`rsid*`, `docId`,
|
|
21
19
|
* protection/revision state, `attachedTemplate`) are preserved.
|
|
@@ -24,7 +22,8 @@
|
|
|
24
22
|
* imported as reusable template assets (even ones the page-1 governing
|
|
25
23
|
* section does not reference), together with their `.rels` and transitive
|
|
26
24
|
* media closure; colliding part names / relationship ids / media names are
|
|
27
|
-
* reallocated and references rewritten consistently.
|
|
25
|
+
* reallocated and references rewritten consistently. Re-applying the same
|
|
26
|
+
* source imports the parts again under new names.
|
|
28
27
|
* - `sectionDefaults`: the source `w:sectPr` that governs page 1 is adopted as
|
|
29
28
|
* the current document's active/final section-default model. On multi-section
|
|
30
29
|
* targets, its header/footer visibility model (`headerReference`,
|
|
@@ -32,11 +31,10 @@
|
|
|
32
31
|
* sections without overwriting their own page geometry. Intermediate / later
|
|
33
32
|
* source sections are not imported.
|
|
34
33
|
*
|
|
35
|
-
*
|
|
36
|
-
* comments, notes, people,
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* and body media remain out of scope and are reported, never applied.
|
|
34
|
+
* Other source parts are never applied. `customXml` is reported as an
|
|
35
|
+
* out-of-scope skipped scope. `customXml`, `docProps`, comments, notes, people,
|
|
36
|
+
* glossary, signatures, embeddings, and body media are reported in
|
|
37
|
+
* `unsupportedItems`.
|
|
40
38
|
*
|
|
41
39
|
* Engine-agnostic contract + execution entry point. No ProseMirror/converter imports.
|
|
42
40
|
*/
|
|
@@ -116,6 +116,7 @@ export interface TocRemoveInput {
|
|
|
116
116
|
}
|
|
117
117
|
export interface TocMutationSuccess {
|
|
118
118
|
success: true;
|
|
119
|
+
appliedChangeMode?: 'direct' | 'tracked';
|
|
119
120
|
toc: TocAddress;
|
|
120
121
|
}
|
|
121
122
|
export interface TocMutationFailure {
|
|
@@ -147,6 +148,7 @@ export interface CreateTableOfContentsInput {
|
|
|
147
148
|
}
|
|
148
149
|
export interface CreateTableOfContentsSuccess {
|
|
149
150
|
success: true;
|
|
151
|
+
appliedChangeMode?: 'direct' | 'tracked';
|
|
150
152
|
toc: TocAddress;
|
|
151
153
|
}
|
|
152
154
|
export interface CreateTableOfContentsFailure {
|
|
@@ -238,6 +240,7 @@ export interface TocEntryDomain {
|
|
|
238
240
|
export type TocListEntriesResult = DiscoveryOutput<TocEntryDomain>;
|
|
239
241
|
export interface TocEntryMutationSuccess {
|
|
240
242
|
success: true;
|
|
243
|
+
appliedChangeMode?: 'direct' | 'tracked';
|
|
241
244
|
entry: TocEntryAddress;
|
|
242
245
|
}
|
|
243
246
|
export interface TocEntryMutationFailure {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BlockNodeType, BlockNodeAddress, DeletableBlockNodeAddress } from './base.js';
|
|
2
|
-
import { AffectedRef, AffectedRefRemapping, Receipt, ReceiptFailure, ReceiptInsert, TextRangeShift } from './receipt.js';
|
|
2
|
+
import { AffectedRef, AffectedRefRemapping, Receipt, ReceiptFailure, ReceiptInsert, ReceiptSuccess, TextRangeShift } from './receipt.js';
|
|
3
3
|
import { StoryLocator } from './story.types.js';
|
|
4
4
|
import { ParagraphNumbering } from './paragraph.types.js';
|
|
5
5
|
import { SDProjectionReviewMode } from './content-projection.js';
|
|
@@ -117,6 +117,7 @@ export interface BlocksDeleteInput {
|
|
|
117
117
|
}
|
|
118
118
|
export interface BlocksDeleteResult {
|
|
119
119
|
success: true;
|
|
120
|
+
appliedChangeMode?: ReceiptSuccess['appliedChangeMode'];
|
|
120
121
|
deleted: DeletableBlockNodeAddress;
|
|
121
122
|
deletedBlock?: DeletedBlockSummary;
|
|
122
123
|
trackedChangeRefs?: ReceiptInsert[];
|
|
@@ -145,6 +146,7 @@ export interface BlocksSplitInput {
|
|
|
145
146
|
}
|
|
146
147
|
export interface BlocksSplitSuccessResult {
|
|
147
148
|
success: true;
|
|
149
|
+
appliedChangeMode?: ReceiptSuccess['appliedChangeMode'];
|
|
148
150
|
/** Address of the new paragraph created by the split (the tail). */
|
|
149
151
|
inserted: BlockNodeAddress;
|
|
150
152
|
/**
|
|
@@ -173,6 +175,7 @@ export interface BlocksMergeInput {
|
|
|
173
175
|
}
|
|
174
176
|
export interface BlocksMergeSuccessResult {
|
|
175
177
|
success: true;
|
|
178
|
+
appliedChangeMode?: ReceiptSuccess['appliedChangeMode'];
|
|
176
179
|
/** Address of the paragraph that was removed (the second paragraph). */
|
|
177
180
|
removed: BlockNodeAddress;
|
|
178
181
|
/**
|
|
@@ -208,6 +211,7 @@ export interface BlocksMoveInput {
|
|
|
208
211
|
}
|
|
209
212
|
export interface BlocksMoveSuccessResult {
|
|
210
213
|
success: true;
|
|
214
|
+
appliedChangeMode?: ReceiptSuccess['appliedChangeMode'];
|
|
211
215
|
/** Same `source` paragraph, now relocated. */
|
|
212
216
|
moved: BlockNodeAddress;
|
|
213
217
|
remappedRefs?: AffectedRefRemapping[];
|
|
@@ -229,6 +233,7 @@ export type BlocksMoveResult = BlocksMoveSuccessResult | BlocksMoveFailureResult
|
|
|
229
233
|
export type { Receipt };
|
|
230
234
|
export interface BlocksDeleteRangeResult {
|
|
231
235
|
success: true;
|
|
236
|
+
appliedChangeMode?: ReceiptSuccess['appliedChangeMode'];
|
|
232
237
|
deletedCount: number;
|
|
233
238
|
deletedBlocks: DeletedBlockSummary[];
|
|
234
239
|
revision: {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TextAddress } from './address.js';
|
|
2
2
|
import { BlockNodeAddress } from './base.js';
|
|
3
3
|
import { ResolvedHandle } from './discovery.js';
|
|
4
|
-
import { ReceiptFailure, ReceiptInsert } from './receipt.js';
|
|
4
|
+
import { ReceiptFailure, ReceiptInsert, ReceiptSuccess } from './receipt.js';
|
|
5
5
|
import { StoryLocator } from './story.types.js';
|
|
6
6
|
export type ParagraphCreateLocation = {
|
|
7
7
|
kind: 'documentStart';
|
|
@@ -29,6 +29,7 @@ export interface CreateParagraphInput {
|
|
|
29
29
|
}
|
|
30
30
|
export interface CreateParagraphSuccessResult {
|
|
31
31
|
success: true;
|
|
32
|
+
appliedChangeMode?: ReceiptSuccess['appliedChangeMode'];
|
|
32
33
|
paragraph: BlockNodeAddress;
|
|
33
34
|
insertionPoint: TextAddress;
|
|
34
35
|
trackedChangeRefs?: ReceiptInsert[];
|
|
@@ -95,6 +96,7 @@ export interface CreateHeadingInput {
|
|
|
95
96
|
}
|
|
96
97
|
export interface CreateHeadingSuccessResult {
|
|
97
98
|
success: true;
|
|
99
|
+
appliedChangeMode?: ReceiptSuccess['appliedChangeMode'];
|
|
98
100
|
heading: BlockNodeAddress;
|
|
99
101
|
insertionPoint: TextAddress;
|
|
100
102
|
trackedChangeRefs?: ReceiptInsert[];
|
|
@@ -2,6 +2,7 @@ import { SDContentNode } from './sd-nodes.js';
|
|
|
2
2
|
import { SDStyles, SDDocDefaults, SDTheme } from './sd-styles.js';
|
|
3
3
|
import { SDNumberingCatalog, SDSection, SDReferenceCatalogs, SDAnnotations } from './sd-sections.js';
|
|
4
4
|
import { SDDocumentMeta } from './sd-props.js';
|
|
5
|
+
import { SDDiagnostic } from './sd-contract.js';
|
|
5
6
|
/** Structural content payload for insert and replace operations. */
|
|
6
7
|
export type SDFragment = SDContentNode | SDContentNode[];
|
|
7
8
|
export interface SDDocument {
|
|
@@ -15,6 +16,8 @@ export interface SDDocument {
|
|
|
15
16
|
referenceCatalogs?: SDReferenceCatalogs;
|
|
16
17
|
annotations?: SDAnnotations;
|
|
17
18
|
metadata?: SDDocumentMeta;
|
|
19
|
+
/** Missing, malformed or fallback package parts, and read options not honored yet. */
|
|
20
|
+
diagnostics?: SDDiagnostic[];
|
|
18
21
|
}
|
|
19
22
|
export declare const SD_CONTENT_NODE_KINDS: readonly ["paragraph", "heading", "list", "table", "toc", "index", "bibliography", "tableOfAuthorities", "break", "horizontalRule", "sectionBreak", "sectPr", "image", "drawing", "sdt", "customXml", "altChunk", "math", "field"];
|
|
20
23
|
export type SDContentNodeKind = (typeof SD_CONTENT_NODE_KINDS)[number];
|
|
@@ -233,6 +233,8 @@ export type StructuralStepData = {
|
|
|
233
233
|
export type StepOutcomeData = TextStepData | AssertStepData | DomainStepData | TableStepData | StructuralStepData;
|
|
234
234
|
export type StepOutcome = {
|
|
235
235
|
stepId: string;
|
|
236
|
+
/** Effective mode when all committed requests in this step used the same mode. */
|
|
237
|
+
appliedChangeMode?: ChangeMode;
|
|
236
238
|
op: string;
|
|
237
239
|
effect: StepEffect;
|
|
238
240
|
matchCount: number;
|
|
@@ -241,6 +243,8 @@ export type StepOutcome = {
|
|
|
241
243
|
};
|
|
242
244
|
export type PlanReceipt = {
|
|
243
245
|
success: true;
|
|
246
|
+
/** Effective mode when every committed step used the same mode. */
|
|
247
|
+
appliedChangeMode?: ChangeMode;
|
|
244
248
|
revision: {
|
|
245
249
|
before: string;
|
|
246
250
|
after: string;
|
|
@@ -4,6 +4,7 @@ import { TextSelector, NodeSelector } from './query.js';
|
|
|
4
4
|
import { DiscoveryItem, DiscoveryResult } from './discovery.js';
|
|
5
5
|
import { InlineToggleDirective } from './style-policy.types.js';
|
|
6
6
|
import { StoryLocator } from './story.types.js';
|
|
7
|
+
import { StyleCatalogPreviewSources } from '../styles/catalog.js';
|
|
7
8
|
export type CardinalityRequirement = 'any' | 'first' | 'exactlyOne' | 'all';
|
|
8
9
|
/** Maximum total length for a match snippet (D11). */
|
|
9
10
|
export declare const SNIPPET_MAX_LENGTH = 500;
|
|
@@ -27,12 +28,32 @@ export interface MatchDirectStyles {
|
|
|
27
28
|
underline: InlineToggleDirective;
|
|
28
29
|
strike: InlineToggleDirective;
|
|
29
30
|
}
|
|
30
|
-
/**
|
|
31
|
+
/**
|
|
32
|
+
* Where an effective font or color came from: set as a literal value, or a
|
|
33
|
+
* theme reference (with tint/shade). Same vocabulary as catalog preview sources.
|
|
34
|
+
*/
|
|
35
|
+
export type MatchEffectiveSources = StyleCatalogPreviewSources;
|
|
36
|
+
/**
|
|
37
|
+
* Effective visual states: what the user sees after style cascade resolution
|
|
38
|
+
* (direct run formatting, character style, paragraph style chain, table style,
|
|
39
|
+
* document defaults, theme). The optional values are present when the cascade
|
|
40
|
+
* resolved them; `meta.effectiveResolved` says whether it ran.
|
|
41
|
+
*/
|
|
31
42
|
export interface MatchEffectiveStyles {
|
|
32
43
|
bold: boolean;
|
|
33
44
|
italic: boolean;
|
|
34
45
|
underline: boolean;
|
|
35
46
|
strike: boolean;
|
|
47
|
+
/** 6-digit lowercase hex with `#` prefix. Theme colors are resolved, tint/shade applied. */
|
|
48
|
+
color?: string;
|
|
49
|
+
/** 6-digit lowercase hex with `#` prefix. */
|
|
50
|
+
highlight?: string;
|
|
51
|
+
/** Latin-track font family. Theme fonts are resolved to the theme's typeface. */
|
|
52
|
+
fontFamily?: string;
|
|
53
|
+
/** Font size in points, rounded to 1 decimal place. */
|
|
54
|
+
fontSizePt?: number;
|
|
55
|
+
/** Origin of `fontFamily` and `color`. A value without a source is absent. */
|
|
56
|
+
sources?: MatchEffectiveSources;
|
|
36
57
|
}
|
|
37
58
|
/**
|
|
38
59
|
* Two-layer inline style state for a single run.
|
|
@@ -171,16 +192,33 @@ export type QueryMatchItem = DiscoveryItem<QueryMatchDomain>;
|
|
|
171
192
|
export type TextMatchItem = DiscoveryItem<TextMatchDomain>;
|
|
172
193
|
/** Node match item (blocks.length === 0). */
|
|
173
194
|
export type NodeMatchItem = DiscoveryItem<NodeMatchDomain>;
|
|
195
|
+
/**
|
|
196
|
+
* Why `styles.effective` could not be fully resolved for a match result.
|
|
197
|
+
*
|
|
198
|
+
* - `tracked-view-unresolved`: tracked-view matches (`includeDeletedText`) are not cascade-resolved.
|
|
199
|
+
* - `theme-fallback`: a theme font or color came from the default Office theme because the
|
|
200
|
+
* document's theme part or color scheme is missing or unreadable.
|
|
201
|
+
* - `style-parts-unavailable`: the document's style parts were not loaded, so styles were not applied.
|
|
202
|
+
* - `run-projection-unavailable`: the matched text could not be split into runs.
|
|
203
|
+
*/
|
|
204
|
+
export type QueryMatchDiagnosticCode = 'tracked-view-unresolved' | 'theme-fallback' | 'style-parts-unavailable' | 'run-projection-unavailable';
|
|
205
|
+
export interface QueryMatchDiagnostic {
|
|
206
|
+
code: QueryMatchDiagnosticCode;
|
|
207
|
+
message: string;
|
|
208
|
+
}
|
|
174
209
|
/**
|
|
175
210
|
* Metadata for `query.match`: always present on the output envelope.
|
|
176
211
|
*
|
|
177
|
-
* - `effectiveResolved: true`:
|
|
178
|
-
*
|
|
179
|
-
* - `effectiveResolved: false`:
|
|
180
|
-
* `styles.effective`
|
|
212
|
+
* - `effectiveResolved: true`: `styles.effective` on every run reflects full
|
|
213
|
+
* style cascade and theme resolution.
|
|
214
|
+
* - `effectiveResolved: false`: at least one run was not fully resolved, or the
|
|
215
|
+
* engine derives `styles.effective` from `direct` only. `diagnostics`, when
|
|
216
|
+
* present, says why.
|
|
181
217
|
*/
|
|
182
218
|
export interface QueryMatchMeta {
|
|
183
219
|
effectiveResolved: boolean;
|
|
220
|
+
/** Reasons the result is not fully resolved. Absent when there are none. */
|
|
221
|
+
diagnostics?: QueryMatchDiagnostic[];
|
|
184
222
|
}
|
|
185
223
|
export interface QueryMatchInput {
|
|
186
224
|
/** Selector for query.match. Text selectors may opt into deleted tracked text via `includeDeletedText`. */
|
|
@@ -2,6 +2,7 @@ import { BlockNavigationAddress, EntityAddress, SelectionTarget, TextAddress, Tr
|
|
|
2
2
|
import { BlockNodeAddress } from './base.js';
|
|
3
3
|
import { BookmarkAddress } from '../bookmarks/bookmarks.types.js';
|
|
4
4
|
import { StoryLocator } from './story.types.js';
|
|
5
|
+
import { ChangeMode } from '../write/write.js';
|
|
5
6
|
export type ReceiptInsert = TrackedChangeAddress;
|
|
6
7
|
export type ReceiptEntity = EntityAddress;
|
|
7
8
|
export type AffectedRef = TextAddress | BookmarkAddress | EntityAddress | BlockNavigationAddress;
|
|
@@ -109,6 +110,13 @@ export interface ReceiptEffects {
|
|
|
109
110
|
}
|
|
110
111
|
export type ReceiptSuccess = {
|
|
111
112
|
success: true;
|
|
113
|
+
/**
|
|
114
|
+
* Mode in which this call's document content was committed. An edit folded
|
|
115
|
+
* into the author's existing insertion is tracked; auxiliary style and
|
|
116
|
+
* numbering definition writes do not change the content mode. Omitted for
|
|
117
|
+
* dry runs, no-ops, and operations that do not author reviewable content.
|
|
118
|
+
*/
|
|
119
|
+
appliedChangeMode?: ChangeMode;
|
|
112
120
|
/**
|
|
113
121
|
* Convenience id for operations that create exactly one primary durable entity.
|
|
114
122
|
* Generic consumers should prefer `inserted`; this field exists for simple
|
|
@@ -23,6 +23,8 @@ export interface SDError {
|
|
|
23
23
|
export type MutationResolutionTarget = TextAddress | BlockNodeAddress | BodyStoryLocator;
|
|
24
24
|
export interface SDMutationReceipt {
|
|
25
25
|
success: boolean;
|
|
26
|
+
/** Effective content mode on a committed success; absent for no-op and dry-run calls. */
|
|
27
|
+
appliedChangeMode?: ReceiptSuccess['appliedChangeMode'];
|
|
26
28
|
/** Rich HTML/Markdown fidelity outcome, when this receipt came from a rich write. */
|
|
27
29
|
outcome?: SDHtmlMarkdownOutcome;
|
|
28
30
|
failure?: SDError;
|