oasis-editor 0.0.397 → 0.0.399

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,4 @@
1
- import { EditorState } from '../model.js';
1
+ import { EditorState, EditorLayoutDocument } from '../model.js';
2
2
  /** Default TOC scope: outline levels 1–3, matching Word's `TOC \o "1-3"`. */
3
3
  export declare const DEFAULT_TOC_MAX_LEVEL = 3;
4
4
  /** A heading captured for a TOC entry. */
@@ -27,5 +27,9 @@ export declare function insertTableOfContents(state: EditorState, resolvePage?:
27
27
  * the unchanged state when no TOC field is present.
28
28
  */
29
29
  export declare function updateTableOfContents(state: EditorState, resolvePage?: TocPageNumberResolver, maxLevel?: number): EditorState;
30
+ /** Update a qualified TOC from a known completed layout snapshot. This is
31
+ * intentionally not automatic convergence; callers must remeasure if pages
32
+ * shift after regeneration. Missing page facts are kept blank. */
33
+ export declare function updateTableOfContentsFromLayout(state: EditorState, layout: EditorLayoutDocument, maxLevel?: number): EditorState;
30
34
  /** Whether a TOC field exists in the active section (for menu enablement). */
31
35
  export declare function hasTableOfContents(state: EditorState): boolean;
@@ -1,6 +1,7 @@
1
1
  import { PageNumberFormat } from '../model.js';
2
2
  import { TemporalFormattingOptions } from '../format/temporalFieldFormat.js';
3
3
  import { FieldStorySpan } from './fieldStoryGraph.js';
4
+ import { DocumentPropertyValues } from '../../ooxml/opc/documentProperties.js';
4
5
  export type NumericFieldCommand = "PAGE" | "NUMPAGES" | "SECTION" | "SECTIONPAGES";
5
6
  export type ReferenceFieldCommand = "REF" | "PAGEREF";
6
7
  export type TemporalFieldCommand = "DATE" | "TIME" | "CREATEDATE" | "SAVEDATE" | "PRINTDATE";
@@ -12,7 +13,22 @@ export interface SequenceField {
12
13
  headingLevel?: number;
13
14
  format?: PageNumberFormat;
14
15
  }
15
- export type EvaluatableField = SequenceField | {
16
+ export type ConditionalOperand = {
17
+ kind: "literal";
18
+ value: string;
19
+ } | {
20
+ kind: "document-variable" | "document-property";
21
+ name: string;
22
+ };
23
+ export interface NestedConditionalField {
24
+ type: "IF_NESTED";
25
+ left: ConditionalOperand;
26
+ right: ConditionalOperand;
27
+ operator: "=" | "<>" | "<" | ">" | "<=" | ">=";
28
+ whenTrue: string;
29
+ whenFalse: string;
30
+ }
31
+ export type EvaluatableField = SequenceField | NestedConditionalField | {
16
32
  type: TemporalFieldCommand;
17
33
  temporal: true;
18
34
  picture?: string;
@@ -23,6 +39,9 @@ export type EvaluatableField = SequenceField | {
23
39
  type: ReferenceFieldCommand;
24
40
  bookmark: string;
25
41
  hyperlink?: boolean;
42
+ } | {
43
+ type: "DOCPROPERTY";
44
+ name: string;
26
45
  } | {
27
46
  type: "DOCVARIABLE";
28
47
  name: string;
@@ -59,6 +78,9 @@ export type FieldDependency = {
59
78
  } | {
60
79
  kind: "document-variable";
61
80
  name: string;
81
+ } | {
82
+ kind: "document-property";
83
+ name: string;
62
84
  };
63
85
  /** All numbers are the caller's one-based display values, not array indexes.
64
86
  * No DOM, clock, mutable editor state or layout service is consulted here.
@@ -67,6 +89,7 @@ export type FieldDependency = {
67
89
  export interface FieldEvaluationContext {
68
90
  temporal?: TemporalFieldContext;
69
91
  documentVariables?: Readonly<Record<string, string>>;
92
+ documentProperties?: Readonly<DocumentPropertyValues>;
70
93
  /** Precomputed value for this exact SEQ occurrence, never a mutable counter. */
71
94
  sequenceValue?: number;
72
95
  pageNumber?: number;
@@ -0,0 +1,8 @@
1
+ import { EditorParagraphNode } from '../model.js';
2
+ import { NestedConditionalField } from './fieldEvaluation.js';
3
+ import { FieldStoryGraph, FieldStorySpan } from './fieldStoryGraph.js';
4
+ /** Qualify one complete scalar, single-paragraph IF with one or two direct
5
+ * nested DOCVARIABLE/DOCPROPERTY operands. Reject non-operand nesting,
6
+ * arbitrary code, locks, unresolved spans and non-token-boundary insertion.
7
+ * No nested field cache is written or executed. */
8
+ export declare function compileNestedConditionalField(parent: FieldStorySpan, graph: FieldStoryGraph, paragraph: EditorParagraphNode): NestedConditionalField | undefined;
@@ -0,0 +1,22 @@
1
+ import { EditorBlockNode, EditorDocument, EditorLayoutDocument } from '../model.js';
2
+ export interface TocFieldSettings {
3
+ startLevel: number;
4
+ endLevel: number;
5
+ hyperlinks: boolean;
6
+ hideWebNumbers: boolean;
7
+ useOutline: boolean;
8
+ }
9
+ export interface QualifiedTocRegion extends TocFieldSettings {
10
+ startBlockIndex: number;
11
+ endBlockIndex: number;
12
+ }
13
+ /** Word TOC switch grammar (bounded F3A subset). Unknown and duplicate
14
+ * switches are not ignored; quoted field-name occurrences are not commands. */
15
+ export declare function parseTocInstruction(raw: string): TocFieldSettings | undefined;
16
+ /** Only regenerate complete, flat TOC regions: the begin/instruction/separator
17
+ * occupy one marker paragraph; a separate end marker closes plain text entries.
18
+ * Other document content is never rewritten, even on malformed TOC markup. */
19
+ export declare function findQualifiedTocRegion(blocks: readonly EditorBlockNode[]): QualifiedTocRegion | undefined;
20
+ /** Read-only, geometry-certified heading page numbers; never infer from
21
+ * paragraph order. A missing or uncertain physical section/page is unresolved. */
22
+ export declare function createTocPageNumberResolver(document: EditorDocument, layout: EditorLayoutDocument): (headingId: string) => number | undefined;
@@ -270,6 +270,11 @@ export interface EditorDocument {
270
270
  * substitution metadata. Preserved on import and re-emitted on export.
271
271
  */
272
272
  fontTable?: EditorFontInfo[];
273
+ /** Qualified plain-text document properties read from OPC core and custom parts. */
274
+ documentProperties?: {
275
+ core?: Record<string, string>;
276
+ custom?: Record<string, string>;
277
+ };
273
278
  /** Imported w:docVars plain-text values. */
274
279
  documentVariables?: Record<string, string>;
275
280
  /** Actual document lifecycle timestamps, epoch milliseconds. Missing means unknown. */