@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,10 +1,9 @@
|
|
|
1
1
|
import { CanonicalSessionError } from "../canonical/canonicalSession.js";
|
|
2
2
|
import { isSeparatorEndnote, isSeparatorFootnote } from "../docx/footnoteParser.js";
|
|
3
3
|
import { createNativeNavigationPlugin, createNativeSelectionRefreshPlugin } from "../prosemirror/nativeSelection.js";
|
|
4
|
-
import { noteReferenceTransactionIssue } from "../prosemirror/noteReferenceOccurrences.js";
|
|
5
4
|
import { createDocumentNumberingPlugin } from "../prosemirror/plugins/documentNumbering.js";
|
|
6
5
|
import { createDocumentStyleContextPlugin } from "../prosemirror/plugins/documentStyles.js";
|
|
7
|
-
import {
|
|
6
|
+
import { CANONICAL_CONDITION } from "../types/canonicalCapabilities.js";
|
|
8
7
|
import { readModel } from "../types/documentModel.js";
|
|
9
8
|
import { createCanonicalStoryEditor, refreshCanonicalStoryView } from "./canonicalStoryEditor.js";
|
|
10
9
|
import { OP_STORIES } from "@stll/docx-core/ops";
|
|
@@ -80,7 +79,6 @@ const createNoteEditorManager = (deps) => {
|
|
|
80
79
|
},
|
|
81
80
|
getView: () => view,
|
|
82
81
|
getApi: () => deps.getCanonicalApi?.() ?? null,
|
|
83
|
-
enabled: () => true,
|
|
84
82
|
onRefusal: deps.onSessionRefusal,
|
|
85
83
|
onSelectionChange: () => deps.onTransaction?.({
|
|
86
84
|
...storyKey,
|
|
@@ -110,18 +108,7 @@ const createNoteEditorManager = (deps) => {
|
|
|
110
108
|
]
|
|
111
109
|
}),
|
|
112
110
|
dispatchTransaction(transaction) {
|
|
113
|
-
|
|
114
|
-
const nextState = view.state.apply(transaction);
|
|
115
|
-
const docChanged = !nextState.doc.eq(view.state.doc);
|
|
116
|
-
view.updateState(nextState);
|
|
117
|
-
const noteIssue = noteReferenceTransactionIssue(transaction);
|
|
118
|
-
if (noteIssue) deps.onSessionRefusal?.(noteIssue.message, { gap: CANONICAL_GAP.dispatch }, noteIssue);
|
|
119
|
-
deps.onTransaction?.({
|
|
120
|
-
...storyKey,
|
|
121
|
-
docChanged,
|
|
122
|
-
selectionChanged: transaction.selectionSet,
|
|
123
|
-
view
|
|
124
|
-
});
|
|
111
|
+
canonical.dispatch(transaction);
|
|
125
112
|
}
|
|
126
113
|
});
|
|
127
114
|
mounted.set(key, {
|
|
@@ -155,7 +142,7 @@ const createNoteEditorManager = (deps) => {
|
|
|
155
142
|
const canonical = deps.getCanonicalApi?.()?.getCanonicalDocument();
|
|
156
143
|
if (canonical) return canonical;
|
|
157
144
|
throw new CanonicalSessionError({
|
|
158
|
-
ground: {
|
|
145
|
+
ground: { condition: CANONICAL_CONDITION.notReady },
|
|
159
146
|
reason: "refused",
|
|
160
147
|
message: "Canonical story snapshot is unavailable."
|
|
161
148
|
});
|
|
@@ -5,8 +5,8 @@ import "./docx/tableParser.js";
|
|
|
5
5
|
import { outlineLevelFromAttrValue } from "./prosemirror/outlineLevelAttr.js";
|
|
6
6
|
import { HIGHLIGHT_COLOR_VALUES, LINE_SPACING_RULE_VALUES, PARAGRAPH_ALIGNMENT_VALUES } from "./types/documentEnumValues.js";
|
|
7
7
|
import { TaggedError } from "better-result";
|
|
8
|
-
import { NUMBER_FORMATS, isNumberingReference, paragraphNumberingReference } from "@stll/docx-core/model";
|
|
9
8
|
import { sanitizeXmlCharacters } from "@stll/docx-core";
|
|
9
|
+
import { NUMBER_FORMATS, isNumberingReference, paragraphNumberingReference } from "@stll/docx-core/model";
|
|
10
10
|
// src/document-operations.ts
|
|
11
11
|
const FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION = 1;
|
|
12
12
|
/** Direct paragraph-alignment values accepted by the operation contract. */
|
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
import { document_d_exports } from "../types/document.js";
|
|
10
10
|
import { DeepReadonly } from "../types/documentModel.js";
|
|
11
11
|
import { OwnedElsewhere } from "./containerChildren.js";
|
|
12
|
-
import { PreviousListState } from "./listMarkerComputation.js";
|
|
13
12
|
import { NumberingMap } from "./numberingParser.js";
|
|
14
13
|
import { ParseContext } from "./parseContext.js";
|
|
15
14
|
import { PreviewLedger } from "./previewBudget.js";
|
|
@@ -28,8 +27,7 @@ type BlockContentScope = ParseBlockContentOptions & {
|
|
|
28
27
|
type ParseBlockContentState = {
|
|
29
28
|
listCounters: Map<number, number[]>;
|
|
30
29
|
abstractCounters: Map<number, number[]>;
|
|
31
|
-
|
|
32
|
-
previousList: PreviousListState;
|
|
30
|
+
startedLevels: Set<number>;
|
|
33
31
|
options: BlockContentScope;
|
|
34
32
|
};
|
|
35
33
|
export declare const parseBlockContent: (parent: XmlElement, styles: StyleMap | null, theme: DeepReadonly<document_d_exports.Theme> | null, numbering: NumberingMap | null, rels: document_d_exports.RelationshipMap | null, media: Map<string, document_d_exports.MediaFile> | null, options?: ParseBlockContentOptions) => document_d_exports.BlockContent[];
|
|
@@ -55,12 +55,7 @@ const countContainedListMarkers = (blocks, counters) => {
|
|
|
55
55
|
const parseBlockContent = (parent, styles, theme, numbering, rels, media, options) => parseBlockContentWithState(parent, styles, theme, numbering, rels, media, {
|
|
56
56
|
listCounters: /* @__PURE__ */ new Map(),
|
|
57
57
|
abstractCounters: /* @__PURE__ */ new Map(),
|
|
58
|
-
|
|
59
|
-
previousList: {
|
|
60
|
-
abstractNumId: null,
|
|
61
|
-
fromStyle: false,
|
|
62
|
-
numId: null
|
|
63
|
-
},
|
|
58
|
+
startedLevels: /* @__PURE__ */ new Set(),
|
|
64
59
|
options: {
|
|
65
60
|
...options,
|
|
66
61
|
rootXmlns: mergeXmlnsDeclarations(options?.rootXmlns ?? {}, parent),
|
|
@@ -90,8 +85,7 @@ const BLOCK_CONTENT_HANDLERS = {
|
|
|
90
85
|
numbering,
|
|
91
86
|
listCounters: state.listCounters,
|
|
92
87
|
abstractCounters: state.abstractCounters,
|
|
93
|
-
|
|
94
|
-
previousList: state.previousList
|
|
88
|
+
startedLevels: state.startedLevels
|
|
95
89
|
});
|
|
96
90
|
modelled.push(paragraph);
|
|
97
91
|
},
|
|
@@ -105,8 +99,7 @@ const BLOCK_CONTENT_HANDLERS = {
|
|
|
105
99
|
numbering,
|
|
106
100
|
listCounters: state.listCounters,
|
|
107
101
|
abstractCounters: state.abstractCounters,
|
|
108
|
-
|
|
109
|
-
previousList: state.previousList
|
|
102
|
+
startedLevels: state.startedLevels
|
|
110
103
|
});
|
|
111
104
|
modelled.push(table);
|
|
112
105
|
},
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { CANONICAL_GAP } from "../types/canonicalCapabilities.js";
|
|
2
1
|
import { CanonicalSaveSnapshot } from "../types/canonicalSave.js";
|
|
3
2
|
import { FolioDocxSerializationPath, FolioGetDocxOptions } from "../types/docxSerialization.js";
|
|
4
3
|
import { SaveDiagnostic } from "./saveDiagnostics.js";
|
|
@@ -7,10 +6,12 @@ import { TripwireResult } from "./selectiveSaveTripwire.js";
|
|
|
7
6
|
import { TaggedErrorClass } from "better-result";
|
|
8
7
|
import { Document } from "@stll/docx-core";
|
|
9
8
|
declare const CanonicalSaveDiagnosticErrorBase: TaggedErrorClass<"CanonicalSaveDiagnosticError">;
|
|
10
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* Forward a fidelity fallback through the adapters' existing error channel:
|
|
11
|
+
* the save succeeded, by a path that rewrote more of the package.
|
|
12
|
+
*/
|
|
11
13
|
export declare class CanonicalSaveDiagnosticError extends CanonicalSaveDiagnosticErrorBase<{
|
|
12
14
|
message: string;
|
|
13
|
-
gap: typeof CANONICAL_GAP.save;
|
|
14
15
|
diagnostic: SaveDiagnostic;
|
|
15
16
|
}> {}
|
|
16
17
|
/** The adapters' error channel for one fidelity fallback. */
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { withoutUnreferencedNotes } from "../prosemirror/noteReferenceReview.js";
|
|
2
|
-
import { CANONICAL_GAP } from "../types/canonicalCapabilities.js";
|
|
3
2
|
import { FOLIO_DOCX_SERIALIZATION_MODE } from "../types/docxSerialization.js";
|
|
4
3
|
import { canonicalJson } from "../utils/canonicalJson.js";
|
|
5
4
|
import { repackWithCanonicalStoryRemovals } from "./canonicalStoryRepack.js";
|
|
@@ -12,11 +11,13 @@ import { Result, TaggedError } from "better-result";
|
|
|
12
11
|
import { idKey, packageParagraphIds, withoutPendingSuggestions } from "@stll/docx-core/ops";
|
|
13
12
|
// src/docx/canonicalSave.ts
|
|
14
13
|
const CanonicalSaveDiagnosticErrorBase = TaggedError("CanonicalSaveDiagnosticError");
|
|
15
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* Forward a fidelity fallback through the adapters' existing error channel:
|
|
16
|
+
* the save succeeded, by a path that rewrote more of the package.
|
|
17
|
+
*/
|
|
16
18
|
var CanonicalSaveDiagnosticError = class extends CanonicalSaveDiagnosticErrorBase {};
|
|
17
19
|
/** The adapters' error channel for one fidelity fallback. */
|
|
18
20
|
const canonicalSaveDiagnosticError = (diagnostic) => new CanonicalSaveDiagnosticError({
|
|
19
|
-
gap: CANONICAL_GAP.save,
|
|
20
21
|
diagnostic,
|
|
21
22
|
message: `Canonical save used a fidelity fallback: ${diagnostic.type} (${diagnostic.part}).`
|
|
22
23
|
});
|
|
@@ -7,8 +7,8 @@ import { keepNormalizedSourceParts } from "./normalizedSourceParts.js";
|
|
|
7
7
|
import { MalformedPackageRelationshipsError } from "./packageRelationshipsRoot.js";
|
|
8
8
|
import { parseDocx } from "./parser.js";
|
|
9
9
|
import { Result, TaggedError } from "better-result";
|
|
10
|
-
import { documentStories, idKey, packageParagraphIds, paragraphsThroughTextBoxes } from "@stll/docx-core/ops";
|
|
11
10
|
import { MalformedXmlReferenceError } from "@stll/docx-core/xml";
|
|
11
|
+
import { documentStories, idKey, packageParagraphIds, paragraphsThroughTextBoxes } from "@stll/docx-core/ops";
|
|
12
12
|
// src/docx/canonicalSessionInput.ts
|
|
13
13
|
const CanonicalDocxInputErrorBase = TaggedError("CanonicalDocxInputError");
|
|
14
14
|
var CanonicalDocxInputError = class extends CanonicalDocxInputErrorBase {};
|
|
@@ -2,8 +2,8 @@ import { TRANSITIONAL_NAMESPACE_BY_STRICT_URI } from "./strictValueEncodings.gen
|
|
|
2
2
|
import { captureVerbatimXml } from "./verbatimCapture.js";
|
|
3
3
|
import { WORDPROCESSINGML_NAMESPACE_URIS, getChildElements, getLocalName, getNamespaceUri } from "./xmlParser.js";
|
|
4
4
|
import { preservedChildGap } from "@stll/docx-core/model";
|
|
5
|
-
import { SEQUENCE_CHILDREN } from "@stll/docx-core/schema";
|
|
6
5
|
import { OOXML_NS } from "@stll/docx-core/xml/namespaces";
|
|
6
|
+
import { SEQUENCE_CHILDREN } from "@stll/docx-core/schema";
|
|
7
7
|
// src/docx/containerChildren.ts
|
|
8
8
|
/**
|
|
9
9
|
* The shared child dispatcher: one way to walk a container's children.
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { document_d_exports } from "../types/document.js";
|
|
2
|
+
import { DocumentPropertiesOptions } from "./rezip.js";
|
|
3
|
+
/** Create a DOCX from a document, loading the package writer on demand. */
|
|
4
|
+
export declare function createDocx(document: document_d_exports.Document, properties?: DocumentPropertiesOptions): Promise<ArrayBuffer>;
|
|
@@ -1,17 +1,25 @@
|
|
|
1
1
|
import { document_d_exports } from "../types/document.js";
|
|
2
2
|
import { NumberingMap } from "./numberingParser.js";
|
|
3
|
-
export type PreviousListState = {
|
|
4
|
-
abstractNumId: number | null;
|
|
5
|
-
fromStyle: boolean;
|
|
6
|
-
numId: number | null;
|
|
7
|
-
};
|
|
8
3
|
export type ComputeListMarkerOptions = {
|
|
9
4
|
numbering: NumberingMap | null;
|
|
5
|
+
/** The counters each list instance counts on. */
|
|
10
6
|
listCounters: Map<number, number[]>;
|
|
7
|
+
/**
|
|
8
|
+
* The counters of each list definition. Every instance of a definition
|
|
9
|
+
* counts on these: a list goes on where the last paragraph of its
|
|
10
|
+
* definition stands, whichever instance that paragraph named.
|
|
11
|
+
*/
|
|
11
12
|
abstractCounters: Map<number, number[]>;
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
/**
|
|
14
|
+
* The levels of list instances a paragraph has used, as
|
|
15
|
+
* {@link startedLevelKey}. An instance's start override sets a level's
|
|
16
|
+
* number the first time the instance is used on that level, and never
|
|
17
|
+
* again.
|
|
18
|
+
*/
|
|
19
|
+
startedLevels: Set<number>;
|
|
14
20
|
};
|
|
21
|
+
/** One level of one list instance, as a member of `startedLevels`. */
|
|
22
|
+
export declare const startedLevelKey: (numId: number, level: number) => number;
|
|
15
23
|
/**
|
|
16
24
|
* What each field of the marker counters depends on: the package alone, or
|
|
17
25
|
* the paragraphs of the story before the current one. Total over the fields:
|
|
@@ -22,8 +30,7 @@ declare const LIST_COUNTER_DEPENDENCY: {
|
|
|
22
30
|
readonly numbering: "package";
|
|
23
31
|
readonly listCounters: "story";
|
|
24
32
|
readonly abstractCounters: "story";
|
|
25
|
-
readonly
|
|
26
|
-
readonly previousList: "story";
|
|
33
|
+
readonly startedLevels: "story";
|
|
27
34
|
};
|
|
28
35
|
type CounterDependency = typeof LIST_COUNTER_DEPENDENCY;
|
|
29
36
|
type StoryCounterField = { [K in keyof CounterDependency]: CounterDependency[K] extends "story" ? K : never; }[keyof CounterDependency];
|
|
@@ -39,8 +46,7 @@ export type ListCounterSnapshot = {
|
|
|
39
46
|
readonly cells: ReadonlyMap<number, readonly number[]>;
|
|
40
47
|
readonly listCounters: readonly (readonly [number, number])[];
|
|
41
48
|
readonly abstractCounters: readonly (readonly [number, number])[];
|
|
42
|
-
readonly
|
|
43
|
-
readonly previousList: Readonly<PreviousListState>;
|
|
49
|
+
readonly startedLevels: readonly number[];
|
|
44
50
|
} & Record<StoryCounterField, unknown>;
|
|
45
51
|
export declare const snapshotListCounters: (counters: ComputeListMarkerOptions) => ListCounterSnapshot;
|
|
46
52
|
/** Put the story half of `counters` back as the snapshot copied it. */
|
|
@@ -48,33 +54,34 @@ export declare const restoreListCounters: (counters: ComputeListMarkerOptions, s
|
|
|
48
54
|
/**
|
|
49
55
|
* The counter arrays one paragraph advanced: the array bound to its list
|
|
50
56
|
* instance and abstract list after it, and those bound to them before it.
|
|
51
|
-
* Besides these the paragraph changes only
|
|
52
|
-
*
|
|
57
|
+
* Besides these the paragraph changes only which level of its instance has
|
|
58
|
+
* been used.
|
|
53
59
|
*/
|
|
54
60
|
export type ListCounterAdvance = {
|
|
55
61
|
readonly numId: number;
|
|
56
62
|
readonly abstractNumId: number | null;
|
|
63
|
+
/** The level the paragraph counted on. */
|
|
64
|
+
readonly level: number;
|
|
57
65
|
readonly counters: number[];
|
|
58
66
|
readonly listBefore: number[] | undefined;
|
|
59
67
|
readonly abstractBefore: number[] | undefined;
|
|
60
68
|
};
|
|
61
69
|
/** What one paragraph's marker computation left in the story half of the counters. */
|
|
62
70
|
export type ListCounterStep = {
|
|
63
|
-
readonly previousList: Readonly<PreviousListState>;
|
|
64
71
|
readonly advanced: {
|
|
65
72
|
readonly numId: number;
|
|
66
73
|
readonly abstractNumId: number | null;
|
|
74
|
+
readonly level: number;
|
|
67
75
|
readonly cell: number;
|
|
68
76
|
readonly values: readonly number[];
|
|
69
|
-
readonly restarted: boolean;
|
|
70
77
|
} | undefined;
|
|
71
78
|
};
|
|
72
79
|
/** The step a paragraph just took, `advance` being what its computation returned. */
|
|
73
|
-
export declare const listCounterStep: (
|
|
80
|
+
export declare const listCounterStep: (advance: ListCounterAdvance | null) => ListCounterStep;
|
|
74
81
|
/**
|
|
75
82
|
* Take `step` again from the counters it was first taken from: the counters
|
|
76
83
|
* end as the paragraph's computation left them, without the paragraph.
|
|
77
84
|
*/
|
|
78
85
|
export declare const replayListCounterStep: (counters: ComputeListMarkerOptions, step: ListCounterStep) => ListCounterAdvance | null;
|
|
79
|
-
export declare const computeListMarker: (paragraph: document_d_exports.Paragraph, { numbering, listCounters, abstractCounters,
|
|
86
|
+
export declare const computeListMarker: (paragraph: document_d_exports.Paragraph, { numbering, listCounters, abstractCounters, startedLevels }: ComputeListMarkerOptions) => ListCounterAdvance | null;
|
|
80
87
|
export {};
|
|
@@ -4,6 +4,9 @@ import { isNumberingReference } from "./numberingReference.js";
|
|
|
4
4
|
import { panic } from "better-result";
|
|
5
5
|
// src/docx/listMarkerComputation.ts
|
|
6
6
|
/** Marker counters shared by parsing and canonical model normalization. */
|
|
7
|
+
const LEVELS_PER_INSTANCE = 16;
|
|
8
|
+
/** One level of one list instance, as a member of `startedLevels`. */
|
|
9
|
+
const startedLevelKey = (numId, level) => numId * LEVELS_PER_INSTANCE + level;
|
|
7
10
|
/**
|
|
8
11
|
* Counter arrays by the list instance that made them: an array is made when
|
|
9
12
|
* its instance's first paragraph is met, once per story run, so the numId
|
|
@@ -29,8 +32,7 @@ const snapshotListCounters = (counters) => {
|
|
|
29
32
|
listCounters: [...counters.listCounters].map(([numId, values]) => [numId, cellOf(values)]),
|
|
30
33
|
abstractCounters: [...counters.abstractCounters].map(([abstractNumId, values]) => [abstractNumId, cellOf(values)]),
|
|
31
34
|
cells,
|
|
32
|
-
|
|
33
|
-
previousList: { ...counters.previousList }
|
|
35
|
+
startedLevels: [...counters.startedLevels]
|
|
34
36
|
};
|
|
35
37
|
};
|
|
36
38
|
/** Put the story half of `counters` back as the snapshot copied it. */
|
|
@@ -40,83 +42,58 @@ const restoreListCounters = (counters, snapshot) => {
|
|
|
40
42
|
const story = {
|
|
41
43
|
listCounters: new Map(snapshot.listCounters.map(([numId, cell]) => [numId, arrayOf(cell)])),
|
|
42
44
|
abstractCounters: new Map(snapshot.abstractCounters.map(([abstractNumId, cell]) => [abstractNumId, arrayOf(cell)])),
|
|
43
|
-
|
|
44
|
-
previousList: { ...snapshot.previousList }
|
|
45
|
+
startedLevels: new Set(snapshot.startedLevels)
|
|
45
46
|
};
|
|
46
47
|
Object.assign(counters, story);
|
|
47
48
|
};
|
|
48
49
|
/** The step a paragraph just took, `advance` being what its computation returned. */
|
|
49
|
-
const listCounterStep = (
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
restarted: counters.restartedNumIds.has(advance.numId)
|
|
57
|
-
}
|
|
58
|
-
});
|
|
50
|
+
const listCounterStep = (advance) => ({ advanced: advance === null ? void 0 : {
|
|
51
|
+
numId: advance.numId,
|
|
52
|
+
abstractNumId: advance.abstractNumId,
|
|
53
|
+
level: advance.level,
|
|
54
|
+
cell: counterCellOf(advance.counters),
|
|
55
|
+
values: [...advance.counters]
|
|
56
|
+
} });
|
|
59
57
|
/**
|
|
60
58
|
* Take `step` again from the counters it was first taken from: the counters
|
|
61
59
|
* end as the paragraph's computation left them, without the paragraph.
|
|
62
60
|
*/
|
|
63
61
|
const replayListCounterStep = (counters, step) => {
|
|
64
|
-
Object.assign(counters.previousList, step.previousList);
|
|
65
62
|
const advanced = step.advanced;
|
|
66
63
|
if (advanced === void 0) return null;
|
|
67
|
-
const { numId, abstractNumId, cell, values
|
|
64
|
+
const { numId, abstractNumId, level, cell, values } = advanced;
|
|
68
65
|
const listBefore = counters.listCounters.get(numId);
|
|
69
66
|
const abstractBefore = abstractNumId === null ? void 0 : counters.abstractCounters.get(abstractNumId);
|
|
70
|
-
const array = [
|
|
71
|
-
for (let
|
|
67
|
+
const array = [abstractBefore, listBefore].find((bound) => bound !== void 0 && counterCellOf(bound) === cell) ?? cellArray(cell, values);
|
|
68
|
+
for (let index = 0; index < values.length; index += 1) array[index] = values[index] ?? NaN;
|
|
72
69
|
counters.listCounters.set(numId, array);
|
|
73
70
|
if (abstractNumId !== null) counters.abstractCounters.set(abstractNumId, array);
|
|
74
|
-
|
|
71
|
+
counters.startedLevels.add(startedLevelKey(numId, level));
|
|
75
72
|
return {
|
|
76
73
|
numId,
|
|
77
74
|
abstractNumId,
|
|
75
|
+
level,
|
|
78
76
|
counters: array,
|
|
79
77
|
listBefore,
|
|
80
78
|
abstractBefore
|
|
81
79
|
};
|
|
82
80
|
};
|
|
83
|
-
const computeListMarker = (paragraph, { numbering, listCounters, abstractCounters,
|
|
81
|
+
const computeListMarker = (paragraph, { numbering, listCounters, abstractCounters, startedLevels }) => {
|
|
84
82
|
const listRendering = paragraph.listRendering;
|
|
85
|
-
if (!listRendering || !numbering)
|
|
86
|
-
previousList.abstractNumId = null;
|
|
87
|
-
previousList.fromStyle = false;
|
|
88
|
-
previousList.numId = null;
|
|
89
|
-
return null;
|
|
90
|
-
}
|
|
83
|
+
if (!listRendering || !numbering) return null;
|
|
91
84
|
const { numId, level } = listRendering;
|
|
92
|
-
if (!isNumberingReference(numId))
|
|
93
|
-
previousList.abstractNumId = null;
|
|
94
|
-
previousList.fromStyle = false;
|
|
95
|
-
previousList.numId = null;
|
|
96
|
-
return null;
|
|
97
|
-
}
|
|
85
|
+
if (!isNumberingReference(numId)) return null;
|
|
98
86
|
const listBefore = listCounters.get(numId);
|
|
99
|
-
const firstEncounter = listBefore === void 0;
|
|
100
|
-
let counters = listBefore ?? cellArray(numId, UNSET_COUNTERS);
|
|
101
|
-
if (firstEncounter) listCounters.set(numId, counters);
|
|
102
87
|
const abstractNumId = numbering.getAbstractNumId(numId);
|
|
103
|
-
const
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
113
|
-
if (listRendering.startOverride !== void 0 || resumesRestartedInstance || previousList.numId === numId && restartedNumIds.has(numId)) restartedNumIds.add(numId);
|
|
114
|
-
if (abstractNumId !== null && level > 0) {
|
|
115
|
-
const latestAbstractCounters = abstractCounters.get(abstractNumId);
|
|
116
|
-
if (counters.slice(0, level).every(Number.isNaN)) for (let i = 0; i < level; i += 1) {
|
|
117
|
-
const latestCounter = latestAbstractCounters?.[i];
|
|
118
|
-
counters[i] = latestCounter !== void 0 && !Number.isNaN(latestCounter) ? latestCounter : numbering.getLevel(numId, i)?.start ?? 1;
|
|
119
|
-
}
|
|
88
|
+
const abstractBefore = abstractNumId === null ? void 0 : abstractCounters.get(abstractNumId);
|
|
89
|
+
const counters = abstractBefore ?? listBefore ?? cellArray(numId, UNSET_COUNTERS);
|
|
90
|
+
listCounters.set(numId, counters);
|
|
91
|
+
const startedKey = startedLevelKey(numId, level);
|
|
92
|
+
const startsLevel = !startedLevels.has(startedKey);
|
|
93
|
+
startedLevels.add(startedKey);
|
|
94
|
+
if (startsLevel && listRendering.startOverride !== void 0) counters[level] = listRendering.startOverride - 1;
|
|
95
|
+
if (abstractNumId !== null) {
|
|
96
|
+
for (let i = 0; i < level; i += 1) if (Number.isNaN(counters[i])) counters[i] = numbering.getLevel(numId, i)?.start ?? 1;
|
|
120
97
|
}
|
|
121
98
|
if (Number.isNaN(counters[level])) counters[level] = (numbering.getLevel(numId, level)?.start ?? 1) - 1;
|
|
122
99
|
counters[level] = (counters[level] ?? 0) + 1;
|
|
@@ -126,24 +103,18 @@ const computeListMarker = (paragraph, { numbering, listCounters, abstractCounter
|
|
|
126
103
|
const childCounter = counters[level + 1];
|
|
127
104
|
counters[level + 1] = (childCounter === void 0 || Number.isNaN(childCounter) ? 0 : childCounter) + childAdvances;
|
|
128
105
|
}
|
|
129
|
-
const abstractBefore = abstractNumId === null ? void 0 : abstractCounters.get(abstractNumId);
|
|
130
106
|
if (abstractNumId !== null) abstractCounters.set(abstractNumId, counters);
|
|
131
107
|
const advance = {
|
|
132
108
|
numId,
|
|
133
109
|
abstractNumId,
|
|
110
|
+
level,
|
|
134
111
|
counters,
|
|
135
112
|
listBefore,
|
|
136
113
|
abstractBefore
|
|
137
114
|
};
|
|
138
|
-
previousList.abstractNumId = abstractNumId;
|
|
139
|
-
previousList.fromStyle = Boolean(styleNumbering);
|
|
140
|
-
previousList.numId = numId;
|
|
141
115
|
const pattern = listRendering.marker;
|
|
142
116
|
if (listRendering.isBullet) {
|
|
143
117
|
listRendering.marker = convertBulletToUnicode(pattern || "", bulletMarkerFontName(listRendering.markerFormatting));
|
|
144
|
-
previousList.abstractNumId = null;
|
|
145
|
-
previousList.fromStyle = false;
|
|
146
|
-
previousList.numId = null;
|
|
147
118
|
return advance;
|
|
148
119
|
}
|
|
149
120
|
const currentLevelInfo = numbering.getLevel(numId, level);
|
|
@@ -155,4 +126,4 @@ const computeListMarker = (paragraph, { numbering, listCounters, abstractCounter
|
|
|
155
126
|
});
|
|
156
127
|
return advance;
|
|
157
128
|
};
|
|
158
|
-
export { computeListMarker, counterCellOf, listCounterStep, replayListCounterStep, restoreListCounters, snapshotListCounters };
|
|
129
|
+
export { computeListMarker, counterCellOf, listCounterStep, replayListCounterStep, restoreListCounters, snapshotListCounters, startedLevelKey };
|
|
@@ -4,7 +4,7 @@ import { listIndentationProvenancePatch } from "../prosemirror/styles/resolvedSt
|
|
|
4
4
|
import { createStyleResolver } from "../prosemirror/styles/styleResolver.js";
|
|
5
5
|
import { canonicalJson } from "../utils/canonicalJson.js";
|
|
6
6
|
import { foldListNumberFields, planParagraphListNumberFold, unfoldedListNumberContent } from "./foldedListNumberFields.js";
|
|
7
|
-
import { computeListMarker, counterCellOf, listCounterStep, replayListCounterStep, restoreListCounters, snapshotListCounters } from "./listMarkerComputation.js";
|
|
7
|
+
import { computeListMarker, counterCellOf, listCounterStep, replayListCounterStep, restoreListCounters, snapshotListCounters, startedLevelKey } from "./listMarkerComputation.js";
|
|
8
8
|
import { listRenderingDefinitionsMatch } from "./listRendering.js";
|
|
9
9
|
import { computeListRendering, getCachedNumberingMap } from "./numberingParser.js";
|
|
10
10
|
import { assignParagraphIndentationProjection, cloneParagraphWithPropertySource, paragraphFormattingWithAuthoredIndentation, sameParagraphIndentationProjection, sealParagraphFacts, withStatedIndentationBaseline } from "./paragraphPropertySource.js";
|
|
@@ -56,12 +56,7 @@ const freshCounters = (numbering) => ({
|
|
|
56
56
|
numbering,
|
|
57
57
|
listCounters: /* @__PURE__ */ new Map(),
|
|
58
58
|
abstractCounters: /* @__PURE__ */ new Map(),
|
|
59
|
-
|
|
60
|
-
previousList: {
|
|
61
|
-
abstractNumId: null,
|
|
62
|
-
fromStyle: false,
|
|
63
|
-
numId: null
|
|
64
|
-
}
|
|
59
|
+
startedLevels: /* @__PURE__ */ new Set()
|
|
65
60
|
});
|
|
66
61
|
/**
|
|
67
62
|
* The counters before block `index` of a run, from the nearest kept
|
|
@@ -127,12 +122,11 @@ const cellOrNone = (values) => values === void 0 ? void 0 : counterCellOf(values
|
|
|
127
122
|
const samePart = (part, left, right) => {
|
|
128
123
|
const l = left.counters;
|
|
129
124
|
const r = right.counters;
|
|
130
|
-
if (part === "p") return l.previousList.abstractNumId === r.previousList.abstractNumId && l.previousList.fromStyle === r.previousList.fromStyle && l.previousList.numId === r.previousList.numId;
|
|
131
125
|
const id = Number(part.slice(1));
|
|
132
126
|
switch (part[0]) {
|
|
133
127
|
case "n": return cellOrNone(l.listCounters.get(id)) === cellOrNone(r.listCounters.get(id));
|
|
134
128
|
case "a": return cellOrNone(l.abstractCounters.get(id)) === cellOrNone(r.abstractCounters.get(id));
|
|
135
|
-
case "
|
|
129
|
+
case "s": return l.startedLevels.has(id) === r.startedLevels.has(id);
|
|
136
130
|
default: {
|
|
137
131
|
const a = left.cell(id);
|
|
138
132
|
const b = right.cell(id);
|
|
@@ -143,11 +137,10 @@ const samePart = (part, left, right) => {
|
|
|
143
137
|
};
|
|
144
138
|
/** The parts a step can have changed. */
|
|
145
139
|
const partsOf = (advance) => {
|
|
146
|
-
if (advance === null) return [
|
|
140
|
+
if (advance === null) return [];
|
|
147
141
|
const parts = [
|
|
148
|
-
"p",
|
|
149
142
|
`n${String(advance.numId)}`,
|
|
150
|
-
`
|
|
143
|
+
`s${String(startedLevelKey(advance.numId, advance.level))}`,
|
|
151
144
|
`c${String(counterCellOf(advance.counters))}`
|
|
152
145
|
];
|
|
153
146
|
if (advance.abstractNumId !== null) parts.push(`a${String(advance.abstractNumId)}`);
|
|
@@ -157,11 +150,11 @@ const partsOf = (advance) => {
|
|
|
157
150
|
};
|
|
158
151
|
/** Every part in which two states differ. */
|
|
159
152
|
const differingParts = (left, right) => {
|
|
160
|
-
const parts = /* @__PURE__ */ new Set(
|
|
153
|
+
const parts = /* @__PURE__ */ new Set();
|
|
161
154
|
for (const view of [left, right]) {
|
|
162
155
|
for (const numId of view.counters.listCounters.keys()) parts.add(`n${String(numId)}`);
|
|
163
156
|
for (const abstractNumId of view.counters.abstractCounters.keys()) parts.add(`a${String(abstractNumId)}`);
|
|
164
|
-
for (const
|
|
157
|
+
for (const started of view.counters.startedLevels) parts.add(`s${String(started)}`);
|
|
165
158
|
for (const cell of view.cells()) parts.add(`c${String(cell)}`);
|
|
166
159
|
}
|
|
167
160
|
for (const part of parts) if (samePart(part, left, right)) parts.delete(part);
|
|
@@ -228,7 +221,7 @@ var ListNormalizationCache = class {
|
|
|
228
221
|
const steps = [];
|
|
229
222
|
const { output, settled } = normalize(block, (advance) => {
|
|
230
223
|
advances.push(advance);
|
|
231
|
-
steps.push(listCounterStep(
|
|
224
|
+
steps.push(listCounterStep(advance));
|
|
232
225
|
});
|
|
233
226
|
sinceCheckpoint += 1;
|
|
234
227
|
normalized += 1;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { isCanonicallyEmptyParagraphFormatting } from "@stll/docx-core/model";
|
|
2
1
|
import { validateDocumentModel } from "@stll/docx-core";
|
|
2
|
+
import { isCanonicallyEmptyParagraphFormatting } from "@stll/docx-core/model";
|
|
3
3
|
// src/docx/modelValidation.ts
|
|
4
4
|
var DocxModelValidationError = class extends Error {
|
|
5
5
|
issues;
|
package/dist/docx/parser.js
CHANGED
|
@@ -48,9 +48,9 @@ import { renderWmfSvg } from "./wmfSvg.js";
|
|
|
48
48
|
import { getAttribute, getChildElements, getLocalName, parseXml, parseXmlDocument } from "./xmlParser.js";
|
|
49
49
|
import { TaggedError, panic } from "better-result";
|
|
50
50
|
import { PARSE_WARNING_CODES, setDocumentBodyComments } from "@stll/docx-core/model";
|
|
51
|
-
import { isCommentExhausted, orphanRootCommentIds } from "@stll/docx-core/ops";
|
|
52
51
|
import { MalformedXmlReferenceError, malformedXmlReferenceError } from "@stll/docx-core/xml";
|
|
53
52
|
import { FOLIO_XML_RESOURCE_LIMITS } from "@stll/docx-core/xml/limits";
|
|
53
|
+
import { isCommentExhausted, orphanRootCommentIds } from "@stll/docx-core/ops";
|
|
54
54
|
// src/docx/parser.ts
|
|
55
55
|
/**
|
|
56
56
|
* Main Parser Orchestrator - Unified parseDocx function
|
|
@@ -2,9 +2,9 @@ import "../reviewHistoryLimits.js";
|
|
|
2
2
|
import { FOLIO_REVIEW_HISTORY_NAMESPACE } from "./reviewHistoryNamespace.js";
|
|
3
3
|
import { getAttributeByNamespaceUri } from "./xmlParser.js";
|
|
4
4
|
import { Result, TaggedError, panic } from "better-result";
|
|
5
|
+
import { escapeXmlAttribute } from "@stll/docx-core";
|
|
5
6
|
import { MAX_REVISION_ID } from "@stll/docx-core/model";
|
|
6
7
|
import { isCopyOriginAncestors, isKeptCut, isKeptCutPiece } from "@stll/docx-core/ops";
|
|
7
|
-
import { escapeXmlAttribute } from "@stll/docx-core";
|
|
8
8
|
// src/docx/reviewResolutionProvenance.ts
|
|
9
9
|
const NAMESPACES = /* @__PURE__ */ new Set([FOLIO_REVIEW_HISTORY_NAMESPACE]);
|
|
10
10
|
/**
|
package/dist/docx/rezip.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { CANONICAL_GAP } from "../types/canonicalCapabilities.js";
|
|
2
1
|
import { BlockContent, Hyperlink } from "../types/content.js";
|
|
3
2
|
import { document_d_exports } from "../types/document.js";
|
|
4
3
|
import { SaveDiagnosticOptions } from "./saveDiagnostics.js";
|
|
@@ -59,20 +58,34 @@ export declare const assertSectionCarriersMatchModel: ({ doc, serializedSectionC
|
|
|
59
58
|
*/
|
|
60
59
|
export declare function readRelsOrStub(zip: ZipArchive, relsPath: string): Promise<string>;
|
|
61
60
|
declare const CanonicalImageRelationshipRefusalErrorBase: TaggedErrorClass<"CanonicalImageRelationshipRefusalError">;
|
|
61
|
+
/**
|
|
62
|
+
* A picture the save cannot publish: the model and the package disagree on its
|
|
63
|
+
* relationship (`conflict` in the main document part, `unresolved`), its
|
|
64
|
+
* bytes are missing, or its target is unsafe.
|
|
65
|
+
*/
|
|
62
66
|
export declare class CanonicalImageRelationshipRefusalError extends CanonicalImageRelationshipRefusalErrorBase<{
|
|
63
67
|
message: string;
|
|
64
|
-
gap: typeof CANONICAL_GAP.save;
|
|
65
68
|
part: string;
|
|
66
69
|
relationshipId: string;
|
|
67
70
|
reason: "conflict" | "unresolved" | "missingMedia" | "unsafeTarget";
|
|
68
71
|
}> {}
|
|
69
72
|
type PublishCanonicalImageResourcesOptions = {
|
|
73
|
+
/**
|
|
74
|
+
* The save's own copy of the document: a copied picture whose id another
|
|
75
|
+
* binding in its header, footer or note part already holds is published
|
|
76
|
+
* under a fresh id in that part, written onto this copy's picture.
|
|
77
|
+
*/
|
|
70
78
|
document: document_d_exports.Document;
|
|
71
79
|
zip: ZipArchive;
|
|
72
80
|
compressionLevel: number;
|
|
81
|
+
/**
|
|
82
|
+
* Whether the caller may rebind such a picture. A caller that cannot passes
|
|
83
|
+
* false and receives the parts that need it, to save another way.
|
|
84
|
+
*/
|
|
85
|
+
rebind: boolean;
|
|
73
86
|
};
|
|
74
87
|
/** Publish allocated pictures into each owning story without rebinding canonical ids. */
|
|
75
|
-
export declare const publishCanonicalImageResources: ({ document, zip, compressionLevel }: PublishCanonicalImageResourcesOptions) => Promise<
|
|
88
|
+
export declare const publishCanonicalImageResources: ({ document, zip, compressionLevel, rebind }: PublishCanonicalImageResourcesOptions) => Promise<readonly string[]>;
|
|
76
89
|
/** Newly authored text links; the census shares the complete owning-part traversal. */
|
|
77
90
|
export declare function collectHyperlinksWithoutRId(blocks: BlockContent[]): Hyperlink[];
|
|
78
91
|
/** The selective save boundary must use the same resource census as full repack. */
|