@stll/folio-core 0.73.0 → 0.75.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/ai-edits/clean-text.d.ts +4 -1
- package/dist/ai-edits/clean-text.js +21 -7
- package/dist/ai-edits/headless.d.ts +5 -2
- package/dist/ai-edits/headless.js +20 -14
- package/dist/ai-edits/note-references.d.ts +1 -1
- package/dist/ai-edits/note-references.js +1 -1
- package/dist/ai-edits/pending-suggestions.d.ts +9 -7
- package/dist/ai-edits/pending-suggestions.js +134 -88
- package/dist/ai-edits/pendingJoin.d.ts +5 -1
- package/dist/ai-edits/pendingJoin.js +12 -3
- package/dist/ai-edits/result-validation.js +1 -1
- package/dist/ai-edits/retired-comment-receipts.d.ts +2 -2
- package/dist/ai-edits/retired-comment-receipts.js +3 -18
- package/dist/ai-edits/snapshot.js +1 -1
- package/dist/ai-edits/table-cell-mutations.js +1 -1
- package/dist/ai-edits/tracked-batch-fidelity.d.ts +6 -10
- package/dist/ai-edits/tracked-batch-fidelity.js +3 -182
- package/dist/canonical/canonicalBatchReview.d.ts +4 -1
- package/dist/canonical/canonicalBatchReview.js +32 -14
- package/dist/canonical/canonicalComments.d.ts +6 -2
- package/dist/canonical/canonicalComments.js +8 -4
- package/dist/canonical/canonicalInlineGaps.d.ts +56 -0
- package/dist/canonical/canonicalInlineGaps.js +118 -0
- package/dist/canonical/canonicalInlineProjection.d.ts +4 -13
- package/dist/canonical/canonicalInlineProjection.js +6 -28
- package/dist/canonical/canonicalProjectionBlocks.d.ts +4 -4
- package/dist/canonical/canonicalPublicOperations.js +99 -36
- package/dist/canonical/canonicalRefusalGrounds.d.ts +4 -0
- package/dist/canonical/canonicalRefusalGrounds.js +56 -0
- package/dist/canonical/canonicalSelection.js +1 -1
- package/dist/canonical/canonicalSession.d.ts +12 -6
- package/dist/canonical/canonicalSession.js +129 -141
- package/dist/canonical/canonicalTrackedBatchFidelity.js +3 -3
- package/dist/compare/inline-atoms.d.ts +35 -41
- package/dist/compare/inline-atoms.js +2 -465
- package/dist/compare/section-boundary-properties.d.ts +3 -30
- package/dist/compare/section-boundary-properties.js +4 -72
- package/dist/controller/autocompleteSuggestion.js +1 -1
- package/dist/controller/canonicalClipboard.js +45 -44
- package/dist/controller/canonicalComposition.d.ts +1 -1
- package/dist/controller/canonicalComposition.js +6 -6
- package/dist/controller/canonicalInput.d.ts +4 -2
- package/dist/controller/canonicalInput.js +34 -17
- package/dist/controller/canonicalPresence.js +1 -1
- package/dist/controller/canonicalRoomAuthority.js +1 -1
- package/dist/controller/canonicalRoomWire.js +1 -1
- package/dist/controller/canonicalStoryEditor.d.ts +2 -3
- package/dist/controller/canonicalStoryEditor.js +43 -25
- package/dist/controller/canonicalStructure.d.ts +19 -2
- package/dist/controller/canonicalStructure.js +140 -43
- package/dist/controller/canonicalTabRoom.js +1 -1
- package/dist/controller/canonicalYjsRoom.js +1 -1
- package/dist/controller/deferredDisplayListPainter.d.ts +8 -0
- package/dist/controller/deferredDisplayListPainter.js +34 -0
- package/dist/controller/folioEditor.js +4 -2
- package/dist/controller/headerFooterEditorManager.js +3 -17
- package/dist/controller/hiddenEditorApi.d.ts +24 -3
- package/dist/controller/hiddenEditorApi.js +4 -17
- package/dist/controller/hiddenEditorManager.js +136 -197
- package/dist/controller/layoutPipeline.d.ts +4 -86
- package/dist/controller/layoutPipeline.js +8 -727
- package/dist/controller/layoutPipelineExecution.d.ts +94 -0
- package/dist/controller/layoutPipelineExecution.js +730 -0
- package/dist/controller/noteEditorManager.js +3 -16
- package/dist/document-operations.js +1 -1
- package/dist/docx/blockContentParser.d.ts +1 -3
- package/dist/docx/blockContentParser.js +3 -10
- package/dist/docx/canonicalSave.d.ts +4 -3
- package/dist/docx/canonicalSave.js +4 -3
- package/dist/docx/canonicalSessionInput.js +1 -1
- package/dist/docx/containerChildren.js +1 -1
- package/dist/docx/createDocx.d.ts +4 -0
- package/dist/docx/createDocx.js +6 -0
- package/dist/docx/listMarkerComputation.d.ts +24 -17
- package/dist/docx/listMarkerComputation.js +31 -60
- package/dist/docx/listModelNormalization.js +8 -15
- package/dist/docx/modelValidation.js +1 -1
- package/dist/docx/parser.js +1 -1
- package/dist/docx/reviewResolutionProvenance.js +1 -1
- package/dist/docx/rezip.d.ts +16 -3
- package/dist/docx/rezip.js +36 -10
- package/dist/docx/selectiveSave.js +13 -5
- package/dist/docx/serializer/borderSerializer.js +1 -1
- package/dist/docx/serializer/commentSerializer.js +1 -1
- package/dist/docx/serializer/documentSerializer.js +1 -1
- package/dist/docx/serializer/paragraphSerializer.js +3 -3
- package/dist/docx/serializer/runSerializer.js +1 -1
- package/dist/docx/serializer/sectionPropertiesSerializer.js +1 -1
- package/dist/docx/serializer/tableSerializer.js +1 -1
- package/dist/docx/serializer/textFormattingSerializer.js +1 -1
- package/dist/docx/serializer/trackedChangeAttributes.js +1 -1
- package/dist/docx/server/templatePlan/apply.js +107 -14
- package/dist/docx/server/templatePlan/blocks.d.ts +16 -1
- package/dist/docx/server/templatePlan/blocks.js +93 -7
- package/dist/docx/server/templatePlan/builders.d.ts +37 -2
- package/dist/docx/server/templatePlan/builders.js +196 -5
- package/dist/docx/server/templatePlan/emit.d.ts +2 -0
- package/dist/docx/server/templatePlan/emit.js +2 -0
- package/dist/docx/server/templatePlan/inspect.js +81 -61
- package/dist/docx/server/templatePlan/labels.d.ts +16 -2
- package/dist/docx/server/templatePlan/labels.js +131 -20
- package/dist/docx/server/templatePlan/plan.d.ts +15 -1
- package/dist/docx/server/templatePlan/plan.js +62 -13
- package/dist/docx/server/templatePlan/planShape.js +52 -4
- package/dist/docx/server/templatePlan/story.d.ts +8 -0
- package/dist/docx/server/templatePlan/story.js +11 -1
- package/dist/docx/server/templatePlan/types.d.ts +176 -18
- package/dist/docx/server/templatePlan/types.js +1 -0
- package/dist/docx/server/templatePlan/verify.js +60 -11
- package/dist/docx/server/templatePlan/xml.d.ts +5 -0
- package/dist/docx/server/templatePlan/xml.js +7 -1
- package/dist/docx/storyBlockReplay.js +1 -1
- package/dist/docx/xmlParser.js +1 -1
- package/dist/i18n/loadMessages.d.ts +5 -0
- package/dist/i18n/loadMessages.js +46 -0
- package/dist/i18n/locales.d.ts +3 -0
- package/dist/i18n/locales.js +17 -0
- package/dist/i18n/messages/ar.gen.js +1 -0
- package/dist/i18n/messages/catalogs.gen.d.ts +17 -0
- package/dist/i18n/messages/catalogs.gen.js +17 -0
- package/dist/i18n/messages/cs.gen.js +1 -0
- package/dist/i18n/messages/de.gen.js +1 -0
- package/dist/i18n/messages/en.gen.js +1 -0
- package/dist/i18n/messages/es.gen.js +1 -0
- package/dist/i18n/messages/et.gen.js +1 -0
- package/dist/i18n/messages/fr.gen.js +1 -0
- package/dist/i18n/messages/he.gen.js +1 -0
- package/dist/i18n/messages/hi.gen.js +1 -0
- package/dist/i18n/messages/hu.gen.js +1 -0
- package/dist/i18n/messages/lt.gen.js +1 -0
- package/dist/i18n/messages/lv.gen.js +1 -0
- package/dist/i18n/messages/messages.gen.d.ts +1 -0
- package/dist/i18n/messages/pl.gen.js +1 -0
- package/dist/i18n/messages/pt-BR.gen.js +1 -0
- package/dist/i18n/messages/sk.gen.js +1 -0
- package/dist/i18n/messages/tr.gen.js +1 -0
- package/dist/i18n/messages/zh-CN.gen.js +1 -0
- package/dist/i18n/messages.d.ts +3 -2
- package/dist/i18n/messages.js +4 -16
- package/dist/internal/clipboardTransformPlugin.d.ts +3 -0
- package/dist/internal/clipboardTransformPlugin.js +13 -0
- package/dist/internal/extensionRuntime.d.ts +7 -0
- package/dist/internal/extensionRuntime.js +28 -0
- package/dist/internal/paragraphFormattingSerialization.js +1 -1
- package/dist/internal/starterKitExtensions.d.ts +20 -0
- package/dist/internal/starterKitExtensions.js +123 -0
- package/dist/internal/wholeStoryRevisionResolution.js +2 -2
- package/dist/layout-bridge/convert/toFlowBlocks.js +0 -12
- package/dist/layout-bridge/convert/topLevelConversion.js +1 -10
- package/dist/prosemirror/attrs/index.js +1 -1
- package/dist/prosemirror/canonicalSelectionRange.js +1 -1
- package/dist/prosemirror/canonicalTableCommands.js +1 -1
- package/dist/prosemirror/commands/comments.js +3 -3
- package/dist/prosemirror/commands/contentControls.js +1 -1
- package/dist/prosemirror/commands/pastePlainText.js +2 -3
- package/dist/prosemirror/commands/replaceRangeText.js +1 -1
- package/dist/prosemirror/commentRecords.js +2 -2
- package/dist/prosemirror/conversion/fromProseDoc.d.ts +0 -5
- package/dist/prosemirror/conversion/fromProseDoc.js +2 -9
- package/dist/prosemirror/conversion/index.d.ts +2 -2
- package/dist/prosemirror/conversion/index.js +2 -2
- package/dist/prosemirror/extensions/ExtensionManager.js +4 -22
- package/dist/prosemirror/extensions/StarterKit.d.ts +4 -27
- package/dist/prosemirror/extensions/StarterKit.js +29 -115
- package/dist/prosemirror/extensions/core/ParagraphExtension.js +2 -2
- package/dist/prosemirror/extensions/features/BaseKeymapExtension.js +1 -1
- package/dist/prosemirror/extensions/features/ImagePasteExtension.js +1 -1
- package/dist/prosemirror/extensions/features/ListExtension.js +7 -2
- package/dist/prosemirror/extensions/features/pastedHeadingStyles.js +1 -1
- package/dist/prosemirror/extensions/index.d.ts +2 -1
- package/dist/prosemirror/extensions/marks/FootnoteRefExtension.js +8 -3
- package/dist/prosemirror/extensions/nodes/TableExtension.js +7 -40
- package/dist/prosemirror/hyperlinkRemoval.js +7 -2
- package/dist/prosemirror/index.d.ts +2 -2
- package/dist/prosemirror/index.js +2 -2
- package/dist/prosemirror/keptRangeBoundaries.js +1 -1
- package/dist/prosemirror/listMarker.d.ts +1 -6
- package/dist/prosemirror/listMarker.js +4 -56
- package/dist/prosemirror/listNumbering.js +1 -1
- package/dist/prosemirror/noteReferenceOccurrences.js +1 -1
- package/dist/prosemirror/noteReferenceReview.d.ts +2 -56
- package/dist/prosemirror/noteReferenceReview.js +2 -243
- package/dist/prosemirror/pastedCommentCopies.js +1 -1
- package/dist/prosemirror/plugins/documentNumbering.js +1 -1
- package/dist/prosemirror/plugins/documentStyles.js +1 -1
- package/dist/prosemirror/replacedAnnotations.js +1 -1
- package/dist/prosemirror/suggestionCommands.d.ts +47 -0
- package/dist/prosemirror/suggestionCommands.js +31 -0
- package/dist/prosemirror/tableCellPaste.js +1 -1
- package/dist/prosemirror/tableRunIn.js +1 -1
- package/dist/prosemirror/textInput.js +1 -1
- package/dist/server.d.ts +2 -2
- package/dist/types/canonicalCapabilities.d.ts +42 -93
- package/dist/types/canonicalCapabilities.js +53 -91
- package/dist/types/canonicalComments.d.ts +2 -2
- package/dist/types/canonicalSections.d.ts +2 -2
- package/dist/utils/clipboard.d.ts +2 -28
- package/dist/utils/clipboard.js +1 -96
- package/dist/utils/clipboardFiles.d.ts +27 -0
- package/dist/utils/clipboardFiles.js +98 -0
- package/dist/utils/rulerControl.d.ts +1 -0
- package/dist/utils/rulerControl.js +2 -1
- package/package.json +2 -2
- package/dist/ai-edits/apply.d.ts +0 -94
- package/dist/ai-edits/apply.js +0 -6637
- package/dist/ai-edits/note-story-inventory.d.ts +0 -5
- package/dist/ai-edits/note-story-inventory.js +0 -10
- package/dist/ai-edits/revisionStretches.d.ts +0 -32
- package/dist/ai-edits/revisionStretches.js +0 -147
- package/dist/document-operations-apply.d.ts +0 -15
- package/dist/document-operations-apply.js +0 -280
- package/dist/prosemirror/extensions/core/HistoryExtension.d.ts +0 -12
- package/dist/prosemirror/extensions/core/HistoryExtension.js +0 -114
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.d.ts +0 -23
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.js +0 -270
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.d.ts +0 -51
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.js +0 -411
- package/dist/prosemirror/plugins/suggestionMode.d.ts +0 -92
- package/dist/prosemirror/plugins/suggestionMode.js +0 -1515
- package/dist/prosemirror/tablePositionedBookmarks.d.ts +0 -8
- package/dist/prosemirror/tablePositionedBookmarks.js +0 -80
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FolioDocxConformanceIssue } from "../validateDocxConformance.js";
|
|
2
2
|
import { TaggedErrorClass } from "better-result";
|
|
3
3
|
/** Why a template plan call stopped; every refusal names one of these. */
|
|
4
|
-
export declare const TEMPLATE_PLAN_ERROR_CODES: readonly ["archive-unreadable", "part-missing", "xml-unreadable", "plan-invalid", "sha-mismatch", "unknown-block", "hash-mismatch", "block-unplaced", "block-placed-twice", "strip-label-mismatch", "merge-invalid", "reference-span-invalid", "reference-target-unplaced", "highlight-span-invalid", "numbering-unknown", "style-unknown", "tracked-changes", "unsupported-content", "verification-failed"];
|
|
4
|
+
export declare const TEMPLATE_PLAN_ERROR_CODES: readonly ["archive-unreadable", "part-missing", "xml-unreadable", "plan-invalid", "sha-mismatch", "unknown-block", "hash-mismatch", "block-unplaced", "block-placed-twice", "strip-label-mismatch", "label-not-writable", "merge-invalid", "reference-span-invalid", "reference-target-unplaced", "highlight-span-invalid", "numbering-unknown", "style-unknown", "tracked-changes", "unsupported-content", "verification-failed"];
|
|
5
5
|
export type TemplatePlanErrorCode = (typeof TEMPLATE_PLAN_ERROR_CODES)[number];
|
|
6
6
|
declare const TemplatePlanErrorBase: TaggedErrorClass<"TemplatePlanError">;
|
|
7
7
|
/** A refused analysis, plan or output. `report` is set for `verification-failed`. */
|
|
@@ -50,6 +50,29 @@ export type DocxBlock = {
|
|
|
50
50
|
paraId?: string;
|
|
51
51
|
/** Drawings, pictures, embedded objects and equations anchored in the block. */
|
|
52
52
|
inlineObjects: number;
|
|
53
|
+
/**
|
|
54
|
+
* Page breaks among the paragraph's runs, when it holds any. A paragraph
|
|
55
|
+
* without text can hold one: it is then all that starts the next page.
|
|
56
|
+
*/
|
|
57
|
+
pageBreaks?: number;
|
|
58
|
+
/**
|
|
59
|
+
* The paragraph starts on a new page by its own formatting or its
|
|
60
|
+
* style's (`w:pageBreakBefore`). A plan carries it over with an item's
|
|
61
|
+
* `pageBreakBefore`; no other direct formatting of a paragraph comes along.
|
|
62
|
+
*/
|
|
63
|
+
pageBreakBefore?: true;
|
|
64
|
+
/**
|
|
65
|
+
* The paragraph is the last of its section: the block after it opens
|
|
66
|
+
* `sections[sectionIndex + 1]` of the manifest, whose `start` says whether
|
|
67
|
+
* on a new page.
|
|
68
|
+
*/
|
|
69
|
+
endsSection?: true;
|
|
70
|
+
/**
|
|
71
|
+
* The paragraph alignment in effect (`w:jc`, as written: `both`, `center`,
|
|
72
|
+
* ...): the paragraph's own, else its style's with inheritance resolved.
|
|
73
|
+
* Absent when neither states one.
|
|
74
|
+
*/
|
|
75
|
+
alignment?: string;
|
|
53
76
|
/** Table only: its cells in row order. */
|
|
54
77
|
cells?: DocxTableCell[];
|
|
55
78
|
/** Table only: every block inside the table in document order. */
|
|
@@ -59,10 +82,50 @@ export type DocxNote = {
|
|
|
59
82
|
id: string;
|
|
60
83
|
text: string;
|
|
61
84
|
};
|
|
85
|
+
/** Compatibility settings of a document that change how its text is laid out. */
|
|
86
|
+
export type DocxCompat = {
|
|
87
|
+
/**
|
|
88
|
+
* `w:doNotExpandShiftReturn`: a justified line that ends in a manual line
|
|
89
|
+
* break keeps its spaces instead of being stretched to the margin.
|
|
90
|
+
*/
|
|
91
|
+
doNotExpandShiftReturn: boolean;
|
|
92
|
+
};
|
|
93
|
+
/** One section of a document's main story: its page, and how it begins. */
|
|
94
|
+
export type DocxSection = {
|
|
95
|
+
index: number;
|
|
96
|
+
/**
|
|
97
|
+
* How the section begins after the one before it: on the next page, an
|
|
98
|
+
* even or odd one, in the next column, or on the same page. The first
|
|
99
|
+
* section's value says nothing.
|
|
100
|
+
*/
|
|
101
|
+
start: "nextPage" | "evenPage" | "oddPage" | "nextColumn" | "continuous";
|
|
102
|
+
orientation: "portrait" | "landscape";
|
|
103
|
+
/** Page size and margins in twentieths of a point; null where unstated. */
|
|
104
|
+
size: {
|
|
105
|
+
width: number | null;
|
|
106
|
+
height: number | null;
|
|
107
|
+
};
|
|
108
|
+
margins: {
|
|
109
|
+
top: number | null;
|
|
110
|
+
right: number | null;
|
|
111
|
+
bottom: number | null;
|
|
112
|
+
left: number | null;
|
|
113
|
+
};
|
|
114
|
+
/** Text columns of the section. */
|
|
115
|
+
columns: number;
|
|
116
|
+
};
|
|
62
117
|
export type DocxBlockManifest = {
|
|
63
118
|
sha256: string;
|
|
64
119
|
/** Top-level blocks of the main story in document order; a table is one block. */
|
|
65
120
|
blocks: DocxBlock[];
|
|
121
|
+
/**
|
|
122
|
+
* The sections of the main story in order; a block names its own by
|
|
123
|
+
* `sectionIndex`. A body that states no section properties of its own
|
|
124
|
+
* still ends in a section: it is listed with the defaults, nothing stated.
|
|
125
|
+
*/
|
|
126
|
+
sections: DocxSection[];
|
|
127
|
+
/** Compatibility settings of the document that change how its text is laid out. */
|
|
128
|
+
compat: DocxCompat;
|
|
66
129
|
footnotes: DocxNote[];
|
|
67
130
|
endnotes: DocxNote[];
|
|
68
131
|
comments: number;
|
|
@@ -81,6 +144,11 @@ export type DocxTemplateStyle = {
|
|
|
81
144
|
ilvl: number;
|
|
82
145
|
} | null;
|
|
83
146
|
outlineLvl: number | null;
|
|
147
|
+
/**
|
|
148
|
+
* The paragraph alignment the style states (`w:jc`), inheritance resolved;
|
|
149
|
+
* null when neither the style nor one it is based on states one.
|
|
150
|
+
*/
|
|
151
|
+
alignment: string | null;
|
|
84
152
|
isDefault: boolean;
|
|
85
153
|
};
|
|
86
154
|
export type DocxTemplateNumberingLevel = {
|
|
@@ -90,6 +158,12 @@ export type DocxTemplateNumberingLevel = {
|
|
|
90
158
|
start: number;
|
|
91
159
|
suff: "tab" | "space" | "nothing";
|
|
92
160
|
pStyle: string | null;
|
|
161
|
+
/** The level's paragraph indent in twentieths of a point; null where unstated. */
|
|
162
|
+
indent: {
|
|
163
|
+
left: number | null;
|
|
164
|
+
hanging: number | null;
|
|
165
|
+
firstLine: number | null;
|
|
166
|
+
};
|
|
93
167
|
};
|
|
94
168
|
export type DocxTemplateNumbering = {
|
|
95
169
|
abstractNums: {
|
|
@@ -121,20 +195,8 @@ export type DocxTemplateField = {
|
|
|
121
195
|
*/
|
|
122
196
|
endBlockId?: string;
|
|
123
197
|
};
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
orientation: "portrait" | "landscape";
|
|
127
|
-
/** Page size and margins in twentieths of a point. */
|
|
128
|
-
size: {
|
|
129
|
-
width: number | null;
|
|
130
|
-
height: number | null;
|
|
131
|
-
};
|
|
132
|
-
margins: {
|
|
133
|
-
top: number | null;
|
|
134
|
-
right: number | null;
|
|
135
|
-
bottom: number | null;
|
|
136
|
-
left: number | null;
|
|
137
|
-
};
|
|
198
|
+
/** A section of a template, with the header and footer parts it names. */
|
|
199
|
+
export type DocxTemplateSection = DocxSection & {
|
|
138
200
|
headers: {
|
|
139
201
|
type: string;
|
|
140
202
|
part: string | null;
|
|
@@ -149,7 +211,7 @@ export type DocxTemplateBookmark = {
|
|
|
149
211
|
id: string;
|
|
150
212
|
part: string;
|
|
151
213
|
};
|
|
152
|
-
export type DocxTemplateInspection = DocxBlockManifest & {
|
|
214
|
+
export type DocxTemplateInspection = Omit<DocxBlockManifest, "sections"> & {
|
|
153
215
|
styles: DocxTemplateStyle[];
|
|
154
216
|
numbering: DocxTemplateNumbering;
|
|
155
217
|
fields: DocxTemplateField[];
|
|
@@ -178,6 +240,35 @@ export type TemplatePlanNestedParagraph = {
|
|
|
178
240
|
styleId?: string;
|
|
179
241
|
numbering?: TemplatePlanNumbering | null;
|
|
180
242
|
stripLabel?: string;
|
|
243
|
+
/** As on a source item. */
|
|
244
|
+
labelAsText?: boolean;
|
|
245
|
+
};
|
|
246
|
+
/** A page other than the template's, in twentieths of a point. */
|
|
247
|
+
export type TemplatePlanSectionPage = {
|
|
248
|
+
orientation: "portrait" | "landscape";
|
|
249
|
+
width: number;
|
|
250
|
+
height: number;
|
|
251
|
+
/** Left out, the template's margins stay. */
|
|
252
|
+
margins?: {
|
|
253
|
+
top: number;
|
|
254
|
+
right: number;
|
|
255
|
+
bottom: number;
|
|
256
|
+
left: number;
|
|
257
|
+
};
|
|
258
|
+
};
|
|
259
|
+
/**
|
|
260
|
+
* A section of the output. It is built from the template's last section:
|
|
261
|
+
* the same headers, footers and every other property, with only the page
|
|
262
|
+
* given here put in its place. The first-page header and a page-number
|
|
263
|
+
* start stay with the document's first section alone.
|
|
264
|
+
*/
|
|
265
|
+
export type TemplatePlanSection = {
|
|
266
|
+
page?: TemplatePlanSectionPage;
|
|
267
|
+
/**
|
|
268
|
+
* How the section begins after the one before it; `nextPage` when left
|
|
269
|
+
* out. The document's first section begins the document.
|
|
270
|
+
*/
|
|
271
|
+
start?: "nextPage" | "evenPage" | "oddPage";
|
|
181
272
|
};
|
|
182
273
|
export type TemplatePlanSourceItem = {
|
|
183
274
|
kind: "source";
|
|
@@ -189,8 +280,36 @@ export type TemplatePlanSourceItem = {
|
|
|
189
280
|
numbering?: TemplatePlanNumbering | null;
|
|
190
281
|
/** The manual label at the start of the block to remove, with the space after it. */
|
|
191
282
|
stripLabel?: string;
|
|
283
|
+
/**
|
|
284
|
+
* Write the block's automatic label as text at the start of its text, with
|
|
285
|
+
* the tab or space its list puts after it: for a label no list of the
|
|
286
|
+
* template prints. The paragraph it leads must join no list
|
|
287
|
+
* (`numbering: null`). Only a label that reads the same wherever the file
|
|
288
|
+
* is opened can be written: numbers, letters and roman numerals, not a
|
|
289
|
+
* bullet glyph and not a number a language spells.
|
|
290
|
+
*/
|
|
291
|
+
labelAsText?: boolean;
|
|
192
292
|
/** Join the next item of the plan, a source paragraph, into this paragraph. */
|
|
193
293
|
mergeNext?: TemplatePlanMerge;
|
|
294
|
+
/**
|
|
295
|
+
* Start the paragraph on a new page (`w:pageBreakBefore`): for a page the
|
|
296
|
+
* source began by a break the plan does not place, by the paragraph's own
|
|
297
|
+
* formatting, or by a section. Not for a table, and not for a block that
|
|
298
|
+
* joins the paragraph before it.
|
|
299
|
+
*
|
|
300
|
+
* `false` is the same as leaving it out: nothing is written, and a style
|
|
301
|
+
* of the template that starts its paragraphs on a new page still does.
|
|
302
|
+
* Verification compares what the paragraph states for itself.
|
|
303
|
+
*/
|
|
304
|
+
pageBreakBefore?: boolean;
|
|
305
|
+
/**
|
|
306
|
+
* The paragraph is the last of a section, described here: for a part of
|
|
307
|
+
* the document whose page is another than the template's, such as a
|
|
308
|
+
* landscape annex. Not for a table, a nested paragraph, or a block that
|
|
309
|
+
* joins the paragraph before it. The template needs a last section of
|
|
310
|
+
* its own to build from.
|
|
311
|
+
*/
|
|
312
|
+
endsSection?: TemplatePlanSection;
|
|
194
313
|
/** Table only: the paragraph style of its cells. */
|
|
195
314
|
cellStyleId?: string;
|
|
196
315
|
/** Table only: placement of single paragraphs inside it. */
|
|
@@ -211,6 +330,16 @@ export type TemplatePlanNumberingPatch = {
|
|
|
211
330
|
lvlText?: string;
|
|
212
331
|
start?: number;
|
|
213
332
|
suff?: "tab" | "space" | "nothing";
|
|
333
|
+
/**
|
|
334
|
+
* The paragraph indent the level gives, in twentieths of a point. A value
|
|
335
|
+
* left out keeps what the level states; `hanging` and `firstLine` exclude
|
|
336
|
+
* each other, so stating one drops the other.
|
|
337
|
+
*/
|
|
338
|
+
indent?: {
|
|
339
|
+
left?: number;
|
|
340
|
+
hanging?: number;
|
|
341
|
+
firstLine?: number;
|
|
342
|
+
};
|
|
214
343
|
};
|
|
215
344
|
export type TemplatePlanReference = {
|
|
216
345
|
blockId: string;
|
|
@@ -249,6 +378,21 @@ export type TemplatePlan = {
|
|
|
249
378
|
freezeKinds?: string[];
|
|
250
379
|
updateOnOpen?: boolean;
|
|
251
380
|
};
|
|
381
|
+
/**
|
|
382
|
+
* Compatibility settings to switch on in the output's settings, which are
|
|
383
|
+
* otherwise the template's. `true` sets the setting at its place in the
|
|
384
|
+
* schema's order; nothing else of the settings changes, and a setting is
|
|
385
|
+
* never switched off.
|
|
386
|
+
*/
|
|
387
|
+
compat?: {
|
|
388
|
+
doNotExpandShiftReturn?: boolean;
|
|
389
|
+
};
|
|
390
|
+
/**
|
|
391
|
+
* The section the body ends with, when its page is another than the
|
|
392
|
+
* template's. Left out, the template's last section closes the body as it
|
|
393
|
+
* stands.
|
|
394
|
+
*/
|
|
395
|
+
lastSection?: TemplatePlanSection;
|
|
252
396
|
};
|
|
253
397
|
export type TemplatePlanBlockResult = {
|
|
254
398
|
/** The source block. */
|
|
@@ -260,6 +404,8 @@ export type TemplatePlanBlockResult = {
|
|
|
260
404
|
emphasis: "identical" | "mismatch" | "omitted";
|
|
261
405
|
/** What `stripLabel` removed, the following space included. */
|
|
262
406
|
strippedPrefix?: string;
|
|
407
|
+
/** The automatic label `labelAsText` wrote as text, without what follows it. */
|
|
408
|
+
labelAsText?: string;
|
|
263
409
|
/** The label the source showed: its automatic label, else the stripped one. */
|
|
264
410
|
sourceLabel: string | null;
|
|
265
411
|
/** The automatic label the output paragraph renders. */
|
|
@@ -307,7 +453,7 @@ export type TemplatePlanFieldLeftover = {
|
|
|
307
453
|
count: number;
|
|
308
454
|
};
|
|
309
455
|
export type TemplatePlanIssue = {
|
|
310
|
-
code: "text-mismatch" | "emphasis-mismatch" | "note-mismatch" | "block-missing" | "reference-broken" | "bookmark-dangling" | "field-unbalanced" | "relationship-dangling" | "note-dangling" | "numbering-dangling" | "style-dangling" | "style-mismatch" | "numbering-mismatch" | "template-mismatch" | "prompting-field-left" | "field-not-frozen" | "update-fields-mismatch" | "conformance";
|
|
456
|
+
code: "text-mismatch" | "emphasis-mismatch" | "note-mismatch" | "block-missing" | "reference-broken" | "bookmark-dangling" | "field-unbalanced" | "relationship-dangling" | "note-dangling" | "numbering-dangling" | "style-dangling" | "style-mismatch" | "numbering-mismatch" | "page-start-mismatch" | "section-mismatch" | "template-mismatch" | "prompting-field-left" | "field-not-frozen" | "update-fields-mismatch" | "compat-mismatch" | "conformance";
|
|
311
457
|
message: string;
|
|
312
458
|
blockId?: string;
|
|
313
459
|
part?: string;
|
|
@@ -332,8 +478,20 @@ export type TemplatePlanReport = {
|
|
|
332
478
|
emphasisMismatch: number;
|
|
333
479
|
/** Placed blocks whose source label and output label differ. */
|
|
334
480
|
labelChanged: number;
|
|
335
|
-
/** Placed blocks that showed a label in the source and
|
|
481
|
+
/** Placed blocks that showed a label in the source and show none: neither rendered nor written as text. */
|
|
336
482
|
labelLost: number;
|
|
483
|
+
/** Placed blocks whose automatic label is written as text. */
|
|
484
|
+
labelAsText: number;
|
|
485
|
+
/** Placed paragraphs the plan starts on a new page. */
|
|
486
|
+
pageStarts: number;
|
|
487
|
+
/** Placed paragraphs the plan ends a section with. */
|
|
488
|
+
sectionEnds: number;
|
|
489
|
+
/**
|
|
490
|
+
* Empty paragraphs written between two tables the plan puts next to each
|
|
491
|
+
* other, and after a table that ends the body: without one the tables
|
|
492
|
+
* are one table, and a body cannot end in a table.
|
|
493
|
+
*/
|
|
494
|
+
tableSeparators: number;
|
|
337
495
|
};
|
|
338
496
|
footnotes: TemplatePlanNoteCounts;
|
|
339
497
|
endnotes: TemplatePlanNoteCounts;
|
|
@@ -2,7 +2,7 @@ import { isNumberingReference } from "../../numberingReference.js";
|
|
|
2
2
|
import { parseSettings } from "../../settingsParser.js";
|
|
3
3
|
import { validateDocxConformance } from "../validateDocxConformance.js";
|
|
4
4
|
import { analyzeDocument } from "./blocks.js";
|
|
5
|
-
import { fieldBookmarkOf } from "./builders.js";
|
|
5
|
+
import { applyRefCaseFormat, fieldBookmarkOf, keepsShiftReturnSpacing, refCaseFormat } from "./builders.js";
|
|
6
6
|
import { linkAddress, linkAddressKey, templateCharacterStyles } from "./emit.js";
|
|
7
7
|
import { emphasisSignature, readDirectEmphasis, signatureHighlight, signatureWithoutHighlight } from "./emphasis.js";
|
|
8
8
|
import { partFields, readHeaderFooterParts } from "./inspect.js";
|
|
@@ -10,8 +10,8 @@ import { styleNumbering } from "./labels.js";
|
|
|
10
10
|
import { guarded, readPartText } from "./package.js";
|
|
11
11
|
import { hyperlinkFieldLink, paragraphPieces, piecesContent, resolvePlan, segmentPieces } from "./plan.js";
|
|
12
12
|
import { objectFingerprint, objectTargets, readStoryResources, relationshipIdsOf } from "./resources.js";
|
|
13
|
-
import { createStoryState, endStory, readParagraph, walkBlocks } from "./story.js";
|
|
14
|
-
import { integerOrNull, isW, readRawPart, wAttr, wChild, wChildVal, wChildren, wName, walkElements } from "./xml.js";
|
|
13
|
+
import { createStoryState, endStory, readParagraph, toggleOf, walkBlocks } from "./story.js";
|
|
14
|
+
import { integerOrNull, isW, readRawPart, twipsOrNull, wAttr, wChild, wChildVal, wChildren, wName, walkElements } from "./xml.js";
|
|
15
15
|
import { Result } from "better-result";
|
|
16
16
|
// src/docx/server/templatePlan/verify.ts
|
|
17
17
|
/**
|
|
@@ -204,7 +204,9 @@ const statedProperties = (paragraph) => {
|
|
|
204
204
|
return {
|
|
205
205
|
styleId: wChildVal(properties, "pStyle"),
|
|
206
206
|
numId: integerOrNull(wChildVal(numbering, "numId")),
|
|
207
|
-
ilvl: integerOrNull(wChildVal(numbering, "ilvl"))
|
|
207
|
+
ilvl: integerOrNull(wChildVal(numbering, "ilvl")),
|
|
208
|
+
pageBreakBefore: toggleOf(wChild(properties, "pageBreakBefore")) === true,
|
|
209
|
+
endsSection: wChild(properties, "sectPr") !== null
|
|
208
210
|
};
|
|
209
211
|
};
|
|
210
212
|
/** Whether a bookmark of `read` holds all of the paragraph's content. */
|
|
@@ -244,16 +246,21 @@ const reportTemplatePlanOutput = async ({ source, template, output, plan, resolv
|
|
|
244
246
|
const plannedProperties = (paragraph) => {
|
|
245
247
|
const slot = slotBlocks.get(paragraph);
|
|
246
248
|
if (slot !== void 0) return statedProperties(slot.element);
|
|
247
|
-
const { styleId, numbering } = paragraph;
|
|
249
|
+
const { styleId, numbering, pageBreakBefore } = paragraph;
|
|
250
|
+
const endsSection = paragraph.endsSection !== null;
|
|
248
251
|
if (numbering.kind === "direct") return {
|
|
249
252
|
styleId,
|
|
250
253
|
numId: numbering.numId,
|
|
251
|
-
ilvl: numbering.ilvl
|
|
254
|
+
ilvl: numbering.ilvl,
|
|
255
|
+
pageBreakBefore,
|
|
256
|
+
endsSection
|
|
252
257
|
};
|
|
253
258
|
return {
|
|
254
259
|
styleId,
|
|
255
260
|
numId: numbering.kind === "none" && styleNumbering(styleId ?? template.defaultStyleId, template.styles, template.numbering)?.kind === "reference" ? 0 : null,
|
|
256
|
-
ilvl: null
|
|
261
|
+
ilvl: null,
|
|
262
|
+
pageBreakBefore,
|
|
263
|
+
endsSection
|
|
257
264
|
};
|
|
258
265
|
};
|
|
259
266
|
const checkProperties = (planned, stated, blockId) => {
|
|
@@ -267,6 +274,16 @@ const reportTemplatePlanOutput = async ({ source, template, output, plan, resolv
|
|
|
267
274
|
message: `Block ${blockId} is not in the list, or at the level, the plan gives it.`,
|
|
268
275
|
blockId
|
|
269
276
|
});
|
|
277
|
+
if (stated.pageBreakBefore !== planned.pageBreakBefore) issues.push({
|
|
278
|
+
code: "page-start-mismatch",
|
|
279
|
+
message: planned.pageBreakBefore ? `Block ${blockId} does not start the new page the plan gives it.` : `Block ${blockId} starts a new page the plan does not give it.`,
|
|
280
|
+
blockId
|
|
281
|
+
});
|
|
282
|
+
if (stated.endsSection !== planned.endsSection) issues.push({
|
|
283
|
+
code: "section-mismatch",
|
|
284
|
+
message: planned.endsSection ? `Block ${blockId} does not end the section the plan gives it.` : `Block ${blockId} ends a section the plan does not give it.`,
|
|
285
|
+
blockId
|
|
286
|
+
});
|
|
270
287
|
};
|
|
271
288
|
const outputOf = /* @__PURE__ */ new Map();
|
|
272
289
|
const templateOutputIds = /* @__PURE__ */ new Set();
|
|
@@ -343,7 +360,7 @@ const reportTemplatePlanOutput = async ({ source, template, output, plan, resolv
|
|
|
343
360
|
resources: outputResources,
|
|
344
361
|
styles: characterStyles
|
|
345
362
|
});
|
|
346
|
-
return before.styleId === after.styleId && before.numId === after.numId && before.ilvl === after.ilvl && sameReading(was, is) && sameList(was.signatures, is.signatures);
|
|
363
|
+
return before.styleId === after.styleId && before.pageBreakBefore === after.pageBreakBefore && before.endsSection === after.endsSection && before.numId === after.numId && before.ilvl === after.ilvl && sameReading(was, is) && sameList(was.signatures, is.signatures);
|
|
347
364
|
}))) issues.push({
|
|
348
365
|
code: "template-mismatch",
|
|
349
366
|
message: `Template block ${item.block.block.id} does not read as the template has it.`,
|
|
@@ -358,6 +375,9 @@ const reportTemplatePlanOutput = async ({ source, template, output, plan, resolv
|
|
|
358
375
|
case "paragraph":
|
|
359
376
|
assign(item.paragraph, block);
|
|
360
377
|
break;
|
|
378
|
+
case "separator":
|
|
379
|
+
if (block?.read === null || block?.read === void 0 || block.read.atoms.length > 0) missing("An empty paragraph that parts two tables is not in place.");
|
|
380
|
+
break;
|
|
361
381
|
case "slot":
|
|
362
382
|
assign(item.paragraph, block);
|
|
363
383
|
break;
|
|
@@ -378,6 +398,15 @@ const reportTemplatePlanOutput = async ({ source, template, output, plan, resolv
|
|
|
378
398
|
}
|
|
379
399
|
}
|
|
380
400
|
if (outputTopLevel.length !== resolved.items.length) missing(`The plan places ${resolved.items.length} block(s), the output holds ${outputTopLevel.length}.`);
|
|
401
|
+
const pageIssue = (page, section) => page !== void 0 && (section === void 0 || section.orientation !== page.orientation || section.size.width !== page.width || section.size.height !== page.height || page.margins !== void 0 && (section.margins.top !== page.margins.top || section.margins.right !== page.margins.right || section.margins.bottom !== page.margins.bottom || section.margins.left !== page.margins.left));
|
|
402
|
+
for (const [paragraph, block] of outputOf) if (pageIssue(paragraph.endsSection?.page, out.manifest.sections[block.block.sectionIndex])) issues.push({
|
|
403
|
+
code: "section-mismatch",
|
|
404
|
+
message: `The section block ${paragraph.parts.at(0)?.block.block.id ?? "?"} ends does not have the page the plan gives it.`
|
|
405
|
+
});
|
|
406
|
+
if (pageIssue(plan.lastSection?.page, out.manifest.sections.at(-1))) issues.push({
|
|
407
|
+
code: "section-mismatch",
|
|
408
|
+
message: "The last section does not have the page the plan gives it."
|
|
409
|
+
});
|
|
381
410
|
const comparisons = /* @__PURE__ */ new Map();
|
|
382
411
|
const spans = {
|
|
383
412
|
source: {
|
|
@@ -546,7 +575,10 @@ const reportTemplatePlanOutput = async ({ source, template, output, plan, resolv
|
|
|
546
575
|
let predictedText = null;
|
|
547
576
|
if (targetBlock !== void 0) {
|
|
548
577
|
if (!hasNumberSwitch) predictedText = targetBlock.block.text;
|
|
549
|
-
else if (usesNumber)
|
|
578
|
+
else if (usesNumber) {
|
|
579
|
+
const number = /\\t\b/u.test(entry.reference.instruction) ? targetBlock.label?.numberOnly ?? null : targetBlock.label?.paragraphNumber ?? null;
|
|
580
|
+
predictedText = number === null ? null : applyRefCaseFormat(number, refCaseFormat(entry.reference.instruction));
|
|
581
|
+
}
|
|
550
582
|
}
|
|
551
583
|
let status = "ok";
|
|
552
584
|
if (field === void 0 || fieldBookmarkOf(field.instruction) !== bookmark || field.instruction.trim() !== entry.instruction.trim() || comparisons.get(paragraph)?.text === "identical" && (field.paragraphOrdinal !== block?.read?.ordinal || field.resultStart !== at)) status = "missing-field";
|
|
@@ -599,6 +631,9 @@ const reportTemplatePlanOutput = async ({ source, template, output, plan, resolv
|
|
|
599
631
|
lvlText: patch.lvlText
|
|
600
632
|
};
|
|
601
633
|
for (const [name, value] of Object.entries(planned)) if (value !== void 0 && wChildVal(level, name) !== value) numberingMismatch(`Level ${patch.ilvl} of list definition ${patch.abstractNumId} does not carry the planned ${name}.`);
|
|
634
|
+
const indent = wChild(wChild(level, "pPr"), "ind");
|
|
635
|
+
for (const [name, value] of Object.entries(patch.indent ?? {})) if (twipsOrNull(wAttr(indent, name)) !== value) numberingMismatch(`Level ${patch.ilvl} of list definition ${patch.abstractNumId} does not carry the planned ${name} indent.`);
|
|
636
|
+
for (const [stated, other] of [["hanging", "firstLine"], ["firstLine", "hanging"]]) if (patch.indent?.[stated] !== void 0 && wAttr(indent, other) !== null) numberingMismatch(`Level ${patch.ilvl} of list definition ${patch.abstractNumId} keeps a ${other} indent beside the planned ${stated} one.`);
|
|
602
637
|
}
|
|
603
638
|
const bookmarkNames = /* @__PURE__ */ new Map();
|
|
604
639
|
const bump = (map, key) => {
|
|
@@ -730,6 +765,10 @@ const reportTemplatePlanOutput = async ({ source, template, output, plan, resolv
|
|
|
730
765
|
message: `A ${field.kind} field the plan freezes is still live.`
|
|
731
766
|
});
|
|
732
767
|
if (nestedUnfrozen > 0) warnings.push(`${nestedUnfrozen} field(s) of a frozen kind sit inside another field's code and stay live.`);
|
|
768
|
+
if (plan.compat?.doNotExpandShiftReturn === true && (settingsXml.value === null || !keepsShiftReturnSpacing(settingsXml.value))) issues.push({
|
|
769
|
+
code: "compat-mismatch",
|
|
770
|
+
message: "The compatibility setting the plan switches on is not on in the output."
|
|
771
|
+
});
|
|
733
772
|
const updateOnOpen = plan.fields?.updateOnOpen;
|
|
734
773
|
if (updateOnOpen !== void 0 && updateOnOpen !== updatesOnOpen) issues.push({
|
|
735
774
|
code: "update-fields-mismatch",
|
|
@@ -777,7 +816,11 @@ const reportTemplatePlanOutput = async ({ source, template, output, plan, resolv
|
|
|
777
816
|
textMismatch: 0,
|
|
778
817
|
emphasisMismatch: 0,
|
|
779
818
|
labelChanged: 0,
|
|
780
|
-
labelLost: 0
|
|
819
|
+
labelLost: 0,
|
|
820
|
+
labelAsText: 0,
|
|
821
|
+
pageStarts: 0,
|
|
822
|
+
sectionEnds: 0,
|
|
823
|
+
tableSeparators: resolved.items.filter(({ kind }) => kind === "separator").length
|
|
781
824
|
};
|
|
782
825
|
const tables = /* @__PURE__ */ new Map();
|
|
783
826
|
for (const block of source.story.order) {
|
|
@@ -828,10 +871,14 @@ const reportTemplatePlanOutput = async ({ source, template, output, plan, resolv
|
|
|
828
871
|
const emphasis = comparison?.emphasis ?? "mismatch";
|
|
829
872
|
if (disposition === "merged") counts.merged += 1;
|
|
830
873
|
else counts.placed += 1;
|
|
874
|
+
if (leads && paragraph?.pageBreakBefore === true) counts.pageStarts += 1;
|
|
875
|
+
if (leads && paragraph !== void 0 && paragraph.endsSection !== null) counts.sectionEnds += 1;
|
|
831
876
|
if (text === "identical") counts.textIdentical += 1;
|
|
832
877
|
else counts.textMismatch += 1;
|
|
833
878
|
if (emphasis === "mismatch") counts.emphasisMismatch += 1;
|
|
834
|
-
|
|
879
|
+
const labelAsText = part?.labelAsText ?? null;
|
|
880
|
+
if (labelAsText !== null) counts.labelAsText += 1;
|
|
881
|
+
else if (sourceLabel !== null && outputLabel === null) counts.labelLost += 1;
|
|
835
882
|
else if (sourceLabel !== null && outputLabel !== null && sourceLabel.trim() !== outputLabel.trim()) counts.labelChanged += 1;
|
|
836
883
|
let tableId = block.parentId;
|
|
837
884
|
while (tableId !== null) {
|
|
@@ -847,11 +894,13 @@ const reportTemplatePlanOutput = async ({ source, template, output, plan, resolv
|
|
|
847
894
|
text,
|
|
848
895
|
emphasis,
|
|
849
896
|
...part === void 0 || part.strippedPrefix === "" ? {} : { strippedPrefix: part.strippedPrefix },
|
|
897
|
+
...labelAsText === null ? {} : { labelAsText },
|
|
850
898
|
sourceLabel,
|
|
851
899
|
outputLabel
|
|
852
900
|
});
|
|
853
901
|
}
|
|
854
902
|
if (counts.labelLost > 0) warnings.push(`${counts.labelLost} block(s) showed a number or label in the source and render none.`);
|
|
903
|
+
if (counts.labelAsText > 0) warnings.push(`${counts.labelAsText} block(s) carry their automatic number as text.`);
|
|
855
904
|
if (counts.labelChanged > 0) warnings.push(`${counts.labelChanged} block(s) render a label that differs from the source's.`);
|
|
856
905
|
const placedReads = resolvedParagraphs.flatMap(({ parts }) => parts.flatMap(({ block }) => block.read === null ? [] : [block.read]));
|
|
857
906
|
const droppedFields = /* @__PURE__ */ new Map();
|
|
@@ -20,6 +20,11 @@ export declare const wAttr: (element: XmlElement | null | undefined, localName:
|
|
|
20
20
|
/** `w:val` of the child `localName`, or null when the child is absent. */
|
|
21
21
|
export declare const wChildVal: (element: XmlElement | null | undefined, localName: string) => string | null;
|
|
22
22
|
export declare const integerOrNull: (value: string | null) => number | null;
|
|
23
|
+
/**
|
|
24
|
+
* A length attribute in twentieths of a point: a plain number, or a
|
|
25
|
+
* universal measure (`1in`, `2.54cm`), which the schema allows in its place.
|
|
26
|
+
*/
|
|
27
|
+
export declare const twipsOrNull: (value: string | null) => number | null;
|
|
23
28
|
/** The largest of `values`, or `floor` when none is larger. */
|
|
24
29
|
export declare const maxOf: (values: Iterable<number>, floor: number) => number;
|
|
25
30
|
/** A relationship attribute (`r:id`, `r:embed`, ...) by local name. */
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { spliceXml } from "../../selectiveXmlPatch.js";
|
|
2
|
+
import { universalMeasureAs } from "../../universalMeasure.js";
|
|
2
3
|
import { NAMESPACES, OFFICE_RELATIONSHIP_NAMESPACE_URIS, WORDPROCESSINGML_NAMESPACE_URIS, getAttributeByNamespaceUri, getLocalName } from "../../xmlParser.js";
|
|
3
4
|
import { escapeXmlAttribute, escapeXmlText } from "@stll/docx-core";
|
|
4
5
|
import { getXmlSourceRange, parseStreamingXmlWithSourceRanges } from "@stll/docx-core/xml";
|
|
@@ -26,6 +27,11 @@ const integerOrNull = (value) => {
|
|
|
26
27
|
const parsed = Number.parseInt(value, 10);
|
|
27
28
|
return Number.isSafeInteger(parsed) ? parsed : null;
|
|
28
29
|
};
|
|
30
|
+
/**
|
|
31
|
+
* A length attribute in twentieths of a point: a plain number, or a
|
|
32
|
+
* universal measure (`1in`, `2.54cm`), which the schema allows in its place.
|
|
33
|
+
*/
|
|
34
|
+
const twipsOrNull = (value) => integerOrNull(value) ?? (value === null ? null : universalMeasureAs(value.trim(), "twips") ?? null);
|
|
29
35
|
/** The largest of `values`, or `floor` when none is larger. */
|
|
30
36
|
const maxOf = (values, floor) => {
|
|
31
37
|
let max = floor;
|
|
@@ -116,4 +122,4 @@ const walkElements = (root, visit) => {
|
|
|
116
122
|
}
|
|
117
123
|
}
|
|
118
124
|
};
|
|
119
|
-
export { MARKUP_COMPATIBILITY_NAMESPACE, MATH_NAMESPACE, elementChildren, escapeXmlAttribute, escapeXmlText, innerRangeOf, integerOrNull, isW, maxOf, partPrefixes, prefixFor, rangeOf, readRawPart, relationshipAttr, sliceWithSplices, spliceXml, wAttr, wChild, wChildVal, wChildren, wName, walkElements };
|
|
125
|
+
export { MARKUP_COMPATIBILITY_NAMESPACE, MATH_NAMESPACE, elementChildren, escapeXmlAttribute, escapeXmlText, innerRangeOf, integerOrNull, isW, maxOf, partPrefixes, prefixFor, rangeOf, readRawPart, relationshipAttr, sliceWithSplices, spliceXml, twipsOrNull, wAttr, wChild, wChildVal, wChildren, wName, walkElements };
|
|
@@ -3,8 +3,8 @@ import { spliceXml } from "./selectiveXmlPatch.js";
|
|
|
3
3
|
import { TRANSITIONAL_NAMESPACE_BY_STRICT_URI } from "./strictValueEncodings.gen.js";
|
|
4
4
|
import { captureSourceProfileXml, hasReplayOpeningDeclarations, isSafeCapturedXmlDocument, isSafeCompactReplayFragment, prepareCompactReplaySuffix } from "./verbatimCapture.js";
|
|
5
5
|
import { WORDPROCESSINGML_NAMESPACE_URIS, getAttributeByNamespaceUri, getChildElements, getLocalName, getNamespaceUri } from "./xmlParser.js";
|
|
6
|
-
import { DOCX_CONFORMANCE_CLASSES } from "@stll/docx-core/model";
|
|
7
6
|
import { escapeXmlAttribute } from "@stll/docx-core";
|
|
7
|
+
import { DOCX_CONFORMANCE_CLASSES } from "@stll/docx-core/model";
|
|
8
8
|
import { getXmlSourceRange, parseStreamingXml, parseStreamingXmlWithSourceRanges } from "@stll/docx-core/xml";
|
|
9
9
|
// src/docx/storyBlockReplay.ts
|
|
10
10
|
/**
|
package/dist/docx/xmlParser.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { NUMBERS_PER_PERCENT, percentageSpelling, transitionalSlotEncoding } from "./transitionalSpelling.js";
|
|
2
2
|
import { universalMeasureAs } from "./universalMeasure.js";
|
|
3
|
-
import { PARSE_WARNING_CODES } from "@stll/docx-core/model";
|
|
4
3
|
import { escapeXmlAttribute, escapeXmlText } from "@stll/docx-core";
|
|
4
|
+
import { PARSE_WARNING_CODES } from "@stll/docx-core/model";
|
|
5
5
|
import { EMPTY_NAMESPACE_SCOPE, OOXML_NAMESPACE_SCOPE, OOXML_NS, attachXmlNamespaceContext, resolveNamespaceUri } from "@stll/docx-core/xml/namespaces";
|
|
6
6
|
import { XmlReadError, readXml } from "@stll/docx-core/xml";
|
|
7
7
|
// src/docx/xmlParser.ts
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { FolioMessages } from "./messages.js";
|
|
2
|
+
/** Read English or a catalog that has already loaded. */
|
|
3
|
+
export declare const getLoadedFolioMessages: (locale: string) => FolioMessages | undefined;
|
|
4
|
+
/** Load just the catalog for the requested locale. */
|
|
5
|
+
export declare const loadFolioMessages: (locale: string) => Promise<FolioMessages>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { resolveFolioLocale } from "./locales.js";
|
|
2
|
+
import messages from "./messages/en.gen.js";
|
|
3
|
+
// src/i18n/loadMessages.ts
|
|
4
|
+
const loaders = {
|
|
5
|
+
ar: () => import("./messages/ar.gen.js"),
|
|
6
|
+
cs: () => import("./messages/cs.gen.js"),
|
|
7
|
+
de: () => import("./messages/de.gen.js"),
|
|
8
|
+
es: () => import("./messages/es.gen.js"),
|
|
9
|
+
et: () => import("./messages/et.gen.js"),
|
|
10
|
+
fr: () => import("./messages/fr.gen.js"),
|
|
11
|
+
he: () => import("./messages/he.gen.js"),
|
|
12
|
+
hi: () => import("./messages/hi.gen.js"),
|
|
13
|
+
hu: () => import("./messages/hu.gen.js"),
|
|
14
|
+
lt: () => import("./messages/lt.gen.js"),
|
|
15
|
+
lv: () => import("./messages/lv.gen.js"),
|
|
16
|
+
pl: () => import("./messages/pl.gen.js"),
|
|
17
|
+
"pt-BR": () => import("./messages/pt-BR.gen.js"),
|
|
18
|
+
sk: () => import("./messages/sk.gen.js"),
|
|
19
|
+
tr: () => import("./messages/tr.gen.js"),
|
|
20
|
+
"zh-CN": () => import("./messages/zh-CN.gen.js")
|
|
21
|
+
};
|
|
22
|
+
const catalogs = /* @__PURE__ */ new Map();
|
|
23
|
+
/** Read English or a catalog that has already loaded. */
|
|
24
|
+
const getLoadedFolioMessages = (locale) => {
|
|
25
|
+
const resolved = resolveFolioLocale(locale);
|
|
26
|
+
if (resolved === "en") return messages;
|
|
27
|
+
const cached = catalogs.get(resolved);
|
|
28
|
+
return cached instanceof Promise ? void 0 : cached;
|
|
29
|
+
};
|
|
30
|
+
/** Load just the catalog for the requested locale. */
|
|
31
|
+
const loadFolioMessages = (locale) => {
|
|
32
|
+
const resolved = resolveFolioLocale(locale);
|
|
33
|
+
if (resolved === "en") return Promise.resolve(messages);
|
|
34
|
+
const cached = catalogs.get(resolved);
|
|
35
|
+
if (cached !== void 0) return Promise.resolve(cached);
|
|
36
|
+
const pending = loaders[resolved]().then(({ messages }) => {
|
|
37
|
+
catalogs.set(resolved, messages);
|
|
38
|
+
return messages;
|
|
39
|
+
}, (error) => {
|
|
40
|
+
catalogs.delete(resolved);
|
|
41
|
+
throw error;
|
|
42
|
+
});
|
|
43
|
+
catalogs.set(resolved, pending);
|
|
44
|
+
return pending;
|
|
45
|
+
};
|
|
46
|
+
export { getLoadedFolioMessages, loadFolioMessages };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { FOLIO_LOCALES } from "./messages/locales.js";
|
|
2
|
+
// src/i18n/locales.ts
|
|
3
|
+
const FOLIO_LOCALE_SET = new Set(FOLIO_LOCALES);
|
|
4
|
+
const isFolioLocale = (locale) => FOLIO_LOCALE_SET.has(locale);
|
|
5
|
+
const baseLanguageOf = (locale) => {
|
|
6
|
+
try {
|
|
7
|
+
return new Intl.Locale(locale).language;
|
|
8
|
+
} catch {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
const resolveFolioLocale = (locale) => {
|
|
13
|
+
if (isFolioLocale(locale)) return locale;
|
|
14
|
+
const base = baseLanguageOf(locale);
|
|
15
|
+
return base !== null && isFolioLocale(base) ? base : "en";
|
|
16
|
+
};
|
|
17
|
+
export { isFolioLocale, resolveFolioLocale };
|
|
@@ -337,6 +337,7 @@ const messages = { "folio": {
|
|
|
337
337
|
"editSessionTakenOver": "فتح علامة تبويب أو نافذة أو جهاز آخر هذا المستند للتعديل، لذا تم تحرير هذه الجلسة. تم الحفاظ على التغييرات المحلية غير المحفوظة؛ أعد فتح المستند للمتابعة.",
|
|
338
338
|
"editor": {
|
|
339
339
|
"accessibleName": "محرر المستندات",
|
|
340
|
+
"changeNotApplied": "تعذّر إجراء هذا التغيير.",
|
|
340
341
|
"changeUnavailable": "لا يمكن إجراء هذا التغيير هنا بعد.",
|
|
341
342
|
"contentLocked": "هذا الجزء من المستند مقفل.",
|
|
342
343
|
"editing": "تحرير",
|