@stll/folio-core 0.58.5 → 0.60.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/README.md +10 -1
- package/dist/ai-edits/apply.d.ts +11 -12
- package/dist/ai-edits/apply.js +179 -168
- package/dist/ai-edits/headless.d.ts +15 -13
- package/dist/ai-edits/headless.js +40 -13
- package/dist/ai-edits/index.d.ts +3 -3
- package/dist/ai-edits/newListNumbering.d.ts +3 -9
- package/dist/ai-edits/newListNumbering.js +36 -41
- package/dist/ai-edits/referenceClassification.d.ts +22 -0
- package/dist/ai-edits/referenceClassification.js +21 -0
- package/dist/ai-edits/snapshot.js +39 -40
- package/dist/ai-edits/types.d.ts +24 -32
- package/dist/compare/column-alignment.d.ts +4 -4
- package/dist/compare/compare.d.ts +3 -7
- package/dist/compare/compare.js +25 -27
- package/dist/compare/content-alignment.d.ts +9 -9
- package/dist/compare/content-types.d.ts +23 -10
- package/dist/compare/content-types.js +14 -0
- package/dist/compare/content.d.ts +16 -17
- package/dist/compare/content.js +30 -7
- package/dist/compare/formatting.d.ts +3 -3
- package/dist/compare/import-style-closure.d.ts +22 -0
- package/dist/compare/import-style-closure.js +33 -0
- package/dist/compare/inserted-resource-snapshot.d.ts +15 -0
- package/dist/compare/inserted-resource-snapshot.js +63 -0
- package/dist/compare/plan.js +20 -13
- package/dist/compare/scenario.js +12 -2
- package/dist/compare/style-resources.d.ts +8 -2
- package/dist/compare/style-resources.js +63 -14
- package/dist/compare/verification.d.ts +15 -3
- package/dist/compare/verification.js +47 -8
- package/dist/compat/eigenpal.d.ts +5 -5
- package/dist/compat/eigenpal.js +2 -2
- package/dist/controller/canonicalListRendering.js +13 -22
- package/dist/controller/canonicalPublicOperations.js +1 -1
- package/dist/controller/canonicalSession.js +3 -2
- package/dist/controller/canonicalStructure.js +55 -28
- package/dist/controller/fontReadiness.js +1 -1
- package/dist/controller/layoutPipeline.js +7 -1
- package/dist/controller/layoutSession.d.ts +2 -0
- package/dist/display-list/build/fontTable.js +7 -5
- package/dist/display-list/build/furniture.d.ts +1 -0
- package/dist/display-list/build/furniture.js +1 -0
- package/dist/display-list/build/watermarkPrimitives.d.ts +2 -1
- package/dist/display-list/build/watermarkPrimitives.js +9 -3
- package/dist/display-list/editor/pageRenderer.js +1 -0
- package/dist/document-operations.d.ts +4 -9
- package/dist/document-operations.js +45 -41
- package/dist/docx/attributeRemainder.d.ts +1 -1
- package/dist/docx/bookmarkIdNormalization.d.ts +10 -0
- package/dist/docx/bookmarkIdNormalization.js +100 -0
- package/dist/docx/bookmarkParser.js +4 -2
- package/dist/docx/importedIdCollisions.d.ts +136 -0
- package/dist/docx/importedIdCollisions.js +215 -0
- package/dist/docx/index.d.ts +1 -1
- package/dist/docx/listMarkerComputation.js +9 -14
- package/dist/docx/listTemplate.d.ts +22 -0
- package/dist/docx/listTemplate.js +40 -0
- package/dist/docx/numberingParser.js +4 -4
- package/dist/docx/numberingReferenceNormalization.js +3 -3
- package/dist/docx/paragraphParser.js +3 -4
- package/dist/docx/paragraphPropertySource.js +1 -2
- package/dist/docx/parseContext.d.ts +2 -1
- package/dist/docx/parseContext.js +1 -0
- package/dist/docx/parseWarningMessage.js +1 -0
- package/dist/docx/parser.js +5 -1
- package/dist/docx/relsParser.js +1 -1
- package/dist/docx/rezip.js +4 -3
- package/dist/docx/selectedXmlIdentityScan.d.ts +10 -0
- package/dist/docx/selectedXmlIdentityScan.js +36 -0
- package/dist/docx/selectiveSave.js +5 -4
- package/dist/docx/selectiveXmlPatch.js +44 -52
- package/dist/docx/serializer/commentSerializer.d.ts +3 -1
- package/dist/docx/serializer/commentSerializer.js +11 -2
- package/dist/docx/serializer/runSerializer.js +2 -2
- package/dist/docx/serializer/trackedChangeAttributes.d.ts +1 -3
- package/dist/docx/serializer/trackedChangeAttributes.js +1 -11
- package/dist/docx/server/materializeYjsDocx.js +2 -2
- package/dist/docx/server/migrateYjsAttrSchema.js +5 -5
- package/dist/fonts/embeddedFontFingerprint.d.ts +5 -0
- package/dist/fonts/embeddedFontFingerprint.js +18 -0
- package/dist/fonts/embeddedFonts.d.ts +1 -1
- package/dist/fonts/embeddedFonts.js +1 -1
- package/dist/fonts/headlessMeasure.js +0 -0
- package/dist/generated/text_shaper.js +8 -4
- package/dist/generated/text_shaper_bg.wasm +0 -0
- package/dist/headless-layout.js +1 -0
- package/dist/index.d.ts +5 -5
- package/dist/index.js +2 -2
- package/dist/internal/paragraphFormattingSerialization.d.ts +1 -8
- package/dist/internal/paragraphFormattingSerialization.js +6 -20
- package/dist/layout-bridge/convert/flowConversionShared.d.ts +3 -1
- package/dist/layout-bridge/convert/footnoteLayout.d.ts +1 -1
- package/dist/layout-bridge/convert/footnoteLayout.js +3 -0
- package/dist/layout-bridge/convert/headerFooterLayout.d.ts +1 -0
- package/dist/layout-bridge/convert/headerFooterLayout.js +2 -0
- package/dist/layout-bridge/convert/listMarkers.d.ts +1 -2
- package/dist/layout-bridge/convert/listMarkers.js +3 -11
- package/dist/layout-bridge/convert/paragraphAttrs.d.ts +1 -1
- package/dist/layout-bridge/convert/paragraphAttrs.js +8 -4
- package/dist/layout-bridge/convert/paragraphConversion.js +8 -1
- package/dist/layout-bridge/convert/toFlowBlocks.d.ts +2 -1
- package/dist/layout-bridge/convert/toFlowBlocks.js +27 -2
- package/dist/layout-engine/measure/cache.js +39 -7
- package/dist/layout-engine/measure/lineTypography.js +1 -0
- package/dist/layout-engine/measure/listMarkerWidth.d.ts +1 -0
- package/dist/layout-engine/measure/listMarkerWidth.js +1 -0
- package/dist/layout-engine/measure/measureContainer.js +3 -4
- package/dist/layout-engine/measure/measureHelpers.d.ts +6 -9
- package/dist/layout-engine/measure/measureHelpers.js +21 -18
- package/dist/layout-engine/measure/measureParagraph.js +2 -0
- package/dist/layout-engine/measure/measureTypes.d.ts +2 -0
- package/dist/layout-engine/types.d.ts +4 -1
- package/dist/layout-painter/renderPage.d.ts +1 -0
- package/dist/layout-painter/renderPage.js +11 -3
- package/dist/layout-painter/renderParagraph.js +13 -3
- package/dist/layout-painter/renderWatermark.d.ts +1 -0
- package/dist/layout-painter/renderWatermark.js +7 -3
- package/dist/managers/editorShortcuts.d.ts +2 -1
- package/dist/managers/editorShortcuts.js +2 -1
- package/dist/markdown/renderParagraph.js +29 -3
- package/dist/prosemirror/canonicalSelectionRange.d.ts +4 -1
- package/dist/prosemirror/canonicalSelectionRange.js +9 -3
- package/dist/prosemirror/commands/comments.js +5 -32
- package/dist/prosemirror/commands/paragraphBookmarkJoin.d.ts +7 -1
- package/dist/prosemirror/commands/paragraphBookmarkJoin.js +35 -1
- package/dist/prosemirror/commands/propertyChangeScope.js +6 -0
- package/dist/prosemirror/commands/resolveParagraphProperties.js +10 -5
- package/dist/prosemirror/conversion/fromProseDoc.js +23 -9
- package/dist/prosemirror/conversion/toProseDoc.js +31 -7
- package/dist/prosemirror/extensions/core/ParagraphExtension.js +29 -14
- package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.d.ts +8 -2
- package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.js +39 -3
- package/dist/prosemirror/extensions/features/EmptyParagraphFormatExtension.d.ts +8 -2
- package/dist/prosemirror/extensions/features/EmptyParagraphFormatExtension.js +4 -3
- package/dist/prosemirror/extensions/features/ImageDragExtension.js +4 -3
- package/dist/prosemirror/extensions/features/JoinedRunStyleExtension.js +4 -3
- package/dist/prosemirror/extensions/features/ListExtension.js +51 -21
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.d.ts +9 -3
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.js +6 -5
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.d.ts +8 -2
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.js +11 -3
- package/dist/prosemirror/extensions/marks/RunIdentityExtension.js +4 -3
- package/dist/prosemirror/extensions/marks/markUtils.js +1 -1
- package/dist/prosemirror/listInstanceReferences.js +21 -15
- package/dist/prosemirror/listLabels.d.ts +4 -3
- package/dist/prosemirror/listLabels.js +18 -51
- package/dist/prosemirror/listMarker.d.ts +2 -19
- package/dist/prosemirror/listMarker.js +28 -57
- package/dist/prosemirror/listNumbering.js +16 -6
- package/dist/prosemirror/listRendering.d.ts +4 -3
- package/dist/prosemirror/listRendering.js +22 -3
- package/dist/prosemirror/listRenderingAttrs.d.ts +2 -1
- package/dist/prosemirror/listRenderingAttrs.js +6 -11
- package/dist/prosemirror/numberedRefFields.js +9 -5
- package/dist/prosemirror/numberingAttr.d.ts +19 -1
- package/dist/prosemirror/numberingAttr.js +16 -2
- package/dist/prosemirror/paragraphIndentation.js +5 -2
- package/dist/prosemirror/paragraphMarkJoin.js +17 -3
- package/dist/prosemirror/paragraphPropertyCarry.js +5 -6
- package/dist/prosemirror/pluginKeyOwner.d.ts +13 -0
- package/dist/prosemirror/pluginKeyOwner.js +35 -0
- package/dist/prosemirror/plugins/aiCitationDecorations.d.ts +11 -4
- package/dist/prosemirror/plugins/aiCitationDecorations.js +16 -3
- package/dist/prosemirror/plugins/aiSuggestionDecorations.d.ts +11 -4
- package/dist/prosemirror/plugins/aiSuggestionDecorations.js +18 -3
- package/dist/prosemirror/plugins/anonymizationDecorations.d.ts +11 -11
- package/dist/prosemirror/plugins/anonymizationDecorations.js +23 -13
- package/dist/prosemirror/plugins/autocompleteSuggestion.d.ts +8 -2
- package/dist/prosemirror/plugins/autocompleteSuggestion.js +27 -5
- package/dist/prosemirror/plugins/contentControlWidgets.d.ts +8 -2
- package/dist/prosemirror/plugins/contentControlWidgets.js +4 -3
- package/dist/prosemirror/plugins/createDocScanPlugin.d.ts +6 -5
- package/dist/prosemirror/plugins/createDocScanPlugin.js +1 -1
- package/dist/prosemirror/plugins/documentNumbering.js +5 -3
- package/dist/prosemirror/plugins/documentStyleState.d.ts +8 -2
- package/dist/prosemirror/plugins/documentStyleState.js +2 -2
- package/dist/prosemirror/plugins/documentStyles.js +1 -1
- package/dist/prosemirror/plugins/selectionTracker.d.ts +8 -2
- package/dist/prosemirror/plugins/selectionTracker.js +4 -3
- package/dist/prosemirror/plugins/suggestionMode.d.ts +8 -2
- package/dist/prosemirror/plugins/suggestionMode.js +4 -3
- package/dist/prosemirror/plugins/templateDirectives.d.ts +8 -2
- package/dist/prosemirror/plugins/templateDirectives.js +19 -4
- package/dist/prosemirror/plugins/templatePreviewValues.d.ts +8 -2
- package/dist/prosemirror/plugins/templatePreviewValues.js +27 -5
- package/dist/prosemirror/plugins/templateSlashMenu.d.ts +8 -2
- package/dist/prosemirror/plugins/templateSlashMenu.js +23 -5
- package/dist/prosemirror/plugins/transactionInvariants.js +29 -5
- package/dist/prosemirror/schema/nodes.d.ts +2 -1
- package/dist/prosemirror/selectionState.js +5 -1
- package/dist/prosemirror/storyListNumbering.js +11 -12
- package/dist/prosemirror/styles/paragraphStyleCascade.js +2 -6
- package/dist/prosemirror/styles/resolvedStyleAttrs.d.ts +11 -4
- package/dist/prosemirror/styles/resolvedStyleAttrs.js +28 -18
- package/dist/prosemirror/yjsDocumentMetadata.d.ts +9 -3
- package/dist/prosemirror/yjsDocumentMetadata.js +42 -10
- package/dist/redline.d.ts +17 -1
- package/dist/redline.js +118 -57
- package/dist/server.d.ts +3 -3
- package/dist/server.js +2 -2
- package/dist/utils/fontLoader.d.ts +2 -2
- package/dist/utils/fontLoader.js +2 -7
- package/dist/utils/fontResolver.d.ts +7 -3
- package/dist/utils/fontResolver.js +6 -8
- package/dist/version-comparison.d.ts +1 -2
- package/dist/version-comparison.js +1 -2
- package/package.json +26 -9
|
@@ -1,6 +1,26 @@
|
|
|
1
|
+
import { createPluginKeyOwner } from "../pluginKeyOwner.js";
|
|
1
2
|
import { getTemplateDirectives } from "./templateDirectives.js";
|
|
2
|
-
import { Plugin
|
|
3
|
+
import { Plugin } from "prosemirror-state";
|
|
3
4
|
//#region src/prosemirror/plugins/templateSlashMenu.ts
|
|
5
|
+
/**
|
|
6
|
+
* Template slash-menu trigger plugin.
|
|
7
|
+
*
|
|
8
|
+
* Watches the template editor for a `/` typed at a marker boundary (start of a
|
|
9
|
+
* text block or right after whitespace) and tracks the query the author types
|
|
10
|
+
* after it. The plugin owns only the *trigger* state — `{active, from, query}` —
|
|
11
|
+
* and the keyboard contract while active; the floating menu UI and the actual
|
|
12
|
+
* marker insertion live in the host (template-studio), which subscribes via
|
|
13
|
+
* {@link TemplateSlashMenuPluginOptions.onChange} and resolves keys via
|
|
14
|
+
* {@link TemplateSlashMenuPluginOptions.onKeyAction}.
|
|
15
|
+
*
|
|
16
|
+
* The trigger guard is deliberately strict so the menu never misfires inside
|
|
17
|
+
* ordinary legal prose: dates (`30/06`), `and/or`, and URLs all have a non-space
|
|
18
|
+
* char before the `/`, so only a leading or post-whitespace `/` opens the menu.
|
|
19
|
+
*
|
|
20
|
+
* Insertion is host-driven: a doc-changing transaction the host dispatches to
|
|
21
|
+
* insert the marker carries a `clear` meta so the plugin tears down without the
|
|
22
|
+
* generic doc-change reset racing the host's selection move.
|
|
23
|
+
*/
|
|
4
24
|
const IDLE = {
|
|
5
25
|
active: false,
|
|
6
26
|
from: null,
|
|
@@ -8,9 +28,7 @@ const IDLE = {
|
|
|
8
28
|
query: ""
|
|
9
29
|
};
|
|
10
30
|
const QUERY_CHAR = /[\p{L}\p{N}_.-]/u;
|
|
11
|
-
const
|
|
12
|
-
const keyHolder = globalThis;
|
|
13
|
-
const templateSlashMenuKey = keyHolder[KEY_HOLDER_SYMBOL] ?? (keyHolder[KEY_HOLDER_SYMBOL] = new PluginKey("templateSlashMenu"));
|
|
31
|
+
const templateSlashMenuKey = createPluginKeyOwner("templateSlashMenu");
|
|
14
32
|
/** Whether the char immediately before `pos` is a marker boundary (start of the
|
|
15
33
|
* text block or whitespace). This is the misfire guard: a `/` mid-token (dates,
|
|
16
34
|
* URLs, and/or) has a word char before it and never opens the menu. */
|
|
@@ -78,7 +96,7 @@ const tryOpenTrigger = (view) => {
|
|
|
78
96
|
};
|
|
79
97
|
const templateSlashMenuPlugin = (options = {}) => {
|
|
80
98
|
return new Plugin({
|
|
81
|
-
key: templateSlashMenuKey,
|
|
99
|
+
key: templateSlashMenuKey.createKey(),
|
|
82
100
|
state: {
|
|
83
101
|
init: () => IDLE,
|
|
84
102
|
apply: (tr, value, _oldState, newState) => {
|
|
@@ -1,8 +1,29 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { expectParagraphAttrs } from "../attrs/index.js";
|
|
2
|
+
import { effectiveParagraphNumberingReference, paragraphNumberingSourcesFromBoundary } from "../numberingAttr.js";
|
|
3
|
+
import { createPluginKeyOwner } from "../pluginKeyOwner.js";
|
|
2
4
|
import { validateProseMirrorDocument } from "../validation.js";
|
|
3
5
|
import { getDocumentNumbering, hasDocumentNumbering } from "./documentNumbering.js";
|
|
4
|
-
import { Plugin
|
|
6
|
+
import { Plugin } from "prosemirror-state";
|
|
5
7
|
//#region src/prosemirror/plugins/transactionInvariants.ts
|
|
8
|
+
/**
|
|
9
|
+
* Transaction invariants: a development and test aid that checks the editor
|
|
10
|
+
* document after every transaction, so a command that leaves a document the
|
|
11
|
+
* save path will refuse fails where it happens rather than at save.
|
|
12
|
+
*
|
|
13
|
+
* Off by default. {@link ExtensionManager} installs it when
|
|
14
|
+
* `globalThis.__folioTransactionInvariants` is `{ enabled: true }` at the time
|
|
15
|
+
* the runtime is initialized; the core test preload sets that flag, which turns
|
|
16
|
+
* every editor test built on the extension manager into a validity check. A
|
|
17
|
+
* host may set it in a development build. Production code never reads it
|
|
18
|
+
* otherwise.
|
|
19
|
+
*
|
|
20
|
+
* The checks are the ones the document-model validator makes that the editor
|
|
21
|
+
* state can answer on its own:
|
|
22
|
+
* - the ProseMirror document is structurally valid (node and mark attributes,
|
|
23
|
+
* bookmark pairing), incrementally cached per node;
|
|
24
|
+
* - every paragraph numbering reference names an instance the document's
|
|
25
|
+
* numbering defines.
|
|
26
|
+
*/
|
|
6
27
|
/** Whether new extension-manager runtimes install the invariant plugin. */
|
|
7
28
|
const areTransactionInvariantsEnabled = () => globalThis.__folioTransactionInvariants?.enabled === true;
|
|
8
29
|
const MAX_REPORTED_STEPS_LENGTH = 4e3;
|
|
@@ -27,7 +48,10 @@ const numberingReferenceIssues = (state) => {
|
|
|
27
48
|
const issues = [];
|
|
28
49
|
state.doc.descendants((node, pos) => {
|
|
29
50
|
if (node.type.name !== "paragraph") return true;
|
|
30
|
-
const numId =
|
|
51
|
+
const numId = effectiveParagraphNumberingReference(paragraphNumberingSourcesFromBoundary({
|
|
52
|
+
numPr: expectParagraphAttrs(node).numPr,
|
|
53
|
+
numPrFromStyle: expectParagraphAttrs(node).numPrFromStyle
|
|
54
|
+
}))?.numId;
|
|
31
55
|
if (numId !== void 0 && !numbering?.hasNumbering(numId)) issues.push({
|
|
32
56
|
path: `paragraph at ${pos}.numPr.numId`,
|
|
33
57
|
message: `Numbering definition ${numId} is missing.`,
|
|
@@ -65,14 +89,14 @@ const introducedIssues = (before, after, transactions) => {
|
|
|
65
89
|
return false;
|
|
66
90
|
});
|
|
67
91
|
};
|
|
68
|
-
const transactionInvariantsKey =
|
|
92
|
+
const transactionInvariantsKey = createPluginKeyOwner("transactionInvariants");
|
|
69
93
|
/**
|
|
70
94
|
* Throw a {@link TransactionInvariantError} naming the offending steps when a
|
|
71
95
|
* document-changing transaction leaves the state with an issue it did not
|
|
72
96
|
* have before.
|
|
73
97
|
*/
|
|
74
98
|
const createTransactionInvariantPlugin = () => new Plugin({
|
|
75
|
-
key: transactionInvariantsKey,
|
|
99
|
+
key: transactionInvariantsKey.createKey(),
|
|
76
100
|
appendTransaction(transactions, oldState, newState) {
|
|
77
101
|
if (!transactions.some((transaction) => transaction.docChanged)) return null;
|
|
78
102
|
const issues = checkEditorStateInvariants(newState);
|
|
@@ -346,8 +346,9 @@ type ParagraphPropertyChangeAttrs = Omit<document_d_exports.ParagraphPropertyCha
|
|
|
346
346
|
provenance?: TrackedChangeProvenance;
|
|
347
347
|
suggestionId?: string | null;
|
|
348
348
|
};
|
|
349
|
-
previousFormatting?: Omit<document_d_exports.ParagraphFormatting, "numPr"> & {
|
|
349
|
+
previousFormatting?: Omit<document_d_exports.ParagraphFormatting, "numPr" | "numPrFromStyle"> & {
|
|
350
350
|
numPr?: ParagraphAttrs["numPr"] | null;
|
|
351
|
+
numPrFromStyle?: ParagraphAttrs["numPrFromStyle"] | null;
|
|
351
352
|
} & Partial<Pick<ParagraphAttrs, "listIsBullet" | "listIsLegal" | "listNumFmt" | "listMarker" | "listMarkerTemplate" | "listMarkerHidden" | "listMarkerFormatting" | "listMarkerAlignment" | "listMarkerSuffix" | "listMarkerAllCaps" | "listImplicitChildLevelAdvances" | "listFoldedMarkerSuffix" | "listMarkerSecondSlotOffsetTwips" | "listLevelNumFmts" | "listLevelStarts" | "listLevelTabs" | "listAbstractNumId" | "listStartOverride" | "lineSpacingExplicit" | "direction" | "_autospacingBase">>;
|
|
352
353
|
currentFormatting?: document_d_exports.ParagraphFormatting;
|
|
353
354
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { FONT_THEME_VALUES } from "../types/documentEnumValues.js";
|
|
2
2
|
import { expectFontFamilyMarkAttrs, expectFontSizeMarkAttrs, expectHighlightMarkAttrs, expectParagraphAttrs, expectStrikeMarkAttrs, expectTextColorMarkAttrs, expectUnderlineMarkAttrs } from "./attrs/index.js";
|
|
3
3
|
import { resolveListState } from "./listState.js";
|
|
4
|
+
import { effectiveParagraphNumbering, paragraphNumberingSourcesFromBoundary } from "./numberingAttr.js";
|
|
4
5
|
import { directionIsRtl } from "./paragraphDirection.js";
|
|
5
6
|
import { getDocumentNumbering } from "./plugins/documentNumbering.js";
|
|
6
7
|
import { collectMarksInRange } from "./selectionMarks.js";
|
|
@@ -46,7 +47,10 @@ function extractSelectionSnapshot(state) {
|
|
|
46
47
|
styleId,
|
|
47
48
|
startParagraphIndex,
|
|
48
49
|
endParagraphIndex,
|
|
49
|
-
listState: resolveListState(getDocumentNumbering(state),
|
|
50
|
+
listState: resolveListState(getDocumentNumbering(state), effectiveParagraphNumbering(paragraphNumberingSourcesFromBoundary({
|
|
51
|
+
numPr: paragraphAttrs?.numPr,
|
|
52
|
+
numPrFromStyle: paragraphAttrs?.numPrFromStyle
|
|
53
|
+
})))
|
|
50
54
|
};
|
|
51
55
|
}
|
|
52
56
|
/** Compatibility entry point used by existing React and Vue integrations. */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createNumberingIdAllocator } from "../docx/numberingIds.js";
|
|
2
2
|
import { getCachedNumberingMap, isBulletLevel } from "../docx/numberingParser.js";
|
|
3
|
-
import {
|
|
3
|
+
import { paragraphNumberingReference } from "../docx/numberingReference.js";
|
|
4
4
|
import { expectParagraphAttrs } from "./attrs/index.js";
|
|
5
5
|
import { completeNumberingForDoc, paragraphListReferences } from "./listInstanceReferences.js";
|
|
6
6
|
import { paragraphNumberingAttr } from "./numberingAttr.js";
|
|
@@ -8,13 +8,12 @@ import { getPackageNumberingDefinitions } from "./plugins/documentNumbering.js";
|
|
|
8
8
|
import { Transform } from "prosemirror-transform";
|
|
9
9
|
//#region src/prosemirror/storyListNumbering.ts
|
|
10
10
|
const remappedNumPr = (numPr, numIds) => {
|
|
11
|
-
|
|
12
|
-
const next =
|
|
11
|
+
if (numPr?.kind !== "reference") return numPr;
|
|
12
|
+
const next = numIds.get(numPr.numId);
|
|
13
13
|
if (next === void 0) return numPr;
|
|
14
|
-
|
|
15
|
-
return paragraphNumberingAttr(paragraphNumberingReference(ilvl === void 0 ? { numId: next } : {
|
|
14
|
+
return paragraphNumberingAttr(paragraphNumberingReference(numPr.ilvl === void 0 ? { numId: next } : {
|
|
16
15
|
numId: next,
|
|
17
|
-
ilvl
|
|
16
|
+
ilvl: numPr.ilvl
|
|
18
17
|
}));
|
|
19
18
|
};
|
|
20
19
|
const remappedAbstractNumId = (abstractNumId, remap) => {
|
|
@@ -47,10 +46,10 @@ const storyListNumbering = (state, numbering) => {
|
|
|
47
46
|
const abstractId = change.previousFormatting?.listAbstractNumId;
|
|
48
47
|
if (typeof abstractId === "number") existingAbstractNumIds.add(abstractId);
|
|
49
48
|
}
|
|
50
|
-
const
|
|
51
|
-
if (
|
|
52
|
-
const level = definedMap.getLevel(numId,
|
|
53
|
-
if (!(level !== null && isBulletLevel(level) === (attrs.listIsBullet === true) && (attrs.listAbstractNumId ?? void 0) === (definedMap.getAbstractNumId(numId) ?? void 0))) colliding.add(numId);
|
|
49
|
+
const statedNumbering = attrs.numPr;
|
|
50
|
+
if (statedNumbering?.kind === "reference" && !storyBase.has(statedNumbering.numId) && definedMap?.hasNumbering(statedNumbering.numId)) {
|
|
51
|
+
const level = definedMap.getLevel(statedNumbering.numId, statedNumbering.ilvl ?? 0);
|
|
52
|
+
if (!(level !== null && isBulletLevel(level) === (attrs.listIsBullet === true) && (attrs.listAbstractNumId ?? void 0) === (definedMap.getAbstractNumId(statedNumbering.numId) ?? void 0))) colliding.add(statedNumbering.numId);
|
|
54
53
|
}
|
|
55
54
|
return false;
|
|
56
55
|
});
|
|
@@ -69,11 +68,11 @@ const storyListNumbering = (state, numbering) => {
|
|
|
69
68
|
state.doc.descendants((node, pos) => {
|
|
70
69
|
if (node.type.name !== "paragraph") return true;
|
|
71
70
|
const attrs = expectParagraphAttrs(node);
|
|
72
|
-
const numId =
|
|
71
|
+
const numId = attrs.numPr?.kind === "reference" ? attrs.numPr.numId : void 0;
|
|
73
72
|
const moves = numId !== void 0 && remap.numIds.has(numId);
|
|
74
73
|
const changes = attrs._propertyChanges?.map((change) => {
|
|
75
74
|
const previous = change.previousFormatting;
|
|
76
|
-
const previousNumId =
|
|
75
|
+
const previousNumId = previous?.numPr?.kind === "reference" ? previous.numPr.numId : void 0;
|
|
77
76
|
if (!previous || previousNumId === void 0 || !remap.numIds.has(previousNumId)) return change;
|
|
78
77
|
return {
|
|
79
78
|
...change,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { paragraphNumberingReferenceId } from "../../docx/numberingReference.js";
|
|
2
2
|
import { mergeParagraphFormatting, mergeParagraphTabStops } from "../../utils/paragraphFormattingMerge.js";
|
|
3
3
|
import { mergeTextFormatting } from "../../utils/textFormattingMerge.js";
|
|
4
4
|
import { paragraphNumberingAttr } from "../numberingAttr.js";
|
|
@@ -103,11 +103,7 @@ function paragraphStyleCascadeAttrs({ styleId, formatting, styleResolver, tableP
|
|
|
103
103
|
set("direction", directionFromBidi(formatting?.bidi ?? stylePpr?.bidi));
|
|
104
104
|
set("defaultTextFormatting", resolveParagraphDefaultTextFormatting(styleId, formatting, styleResolver, { includeParagraphMarkRunProperties }));
|
|
105
105
|
const styleNumbering = stylePpr?.numPr;
|
|
106
|
-
if (styleNumbering?.kind === "reference" && (formatting?.numPr === void 0 || formatting.numPr.kind === "levelOnly"))
|
|
107
|
-
const merged = mergeParagraphNumbering(styleNumbering, formatting?.numPr);
|
|
108
|
-
if (merged !== void 0) attrs.numPr = paragraphNumberingAttr(merged);
|
|
109
|
-
attrs.numPrFromStyle = paragraphNumberingAttr(styleNumbering);
|
|
110
|
-
}
|
|
106
|
+
if (styleNumbering?.kind === "reference" && (formatting?.numPr === void 0 || formatting.numPr.kind === "levelOnly")) attrs.numPrFromStyle = paragraphNumberingAttr(styleNumbering);
|
|
111
107
|
return {
|
|
112
108
|
attrs,
|
|
113
109
|
stylePpr
|
|
@@ -4,6 +4,16 @@ import { ResolvedParagraphStyle } from "./styleResolver.js";
|
|
|
4
4
|
import { NumberingMap } from "../../docx/numberingParser.js";
|
|
5
5
|
import { DirectParagraphIndentation } from "../paragraphIndentation.js";
|
|
6
6
|
//#region src/prosemirror/styles/resolvedStyleAttrs.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* Shared helper for projecting a resolved paragraph style onto ProseMirror
|
|
9
|
+
* paragraph node attrs.
|
|
10
|
+
*
|
|
11
|
+
* Both `applyStyle` (toolbar style picker) and the Enter handler's
|
|
12
|
+
* next-style switch need to write the same set of style-controlled attrs.
|
|
13
|
+
* Keeping the projection in one place ensures the two paths stay in sync —
|
|
14
|
+
* a style applied via the picker and a style applied on Enter produce
|
|
15
|
+
* identical paragraph attrs.
|
|
16
|
+
*/
|
|
7
17
|
type ResolvedStyleIdentity = {
|
|
8
18
|
styleId: string;
|
|
9
19
|
styleName?: string;
|
|
@@ -59,9 +69,6 @@ declare function listIndentationProvenancePatch({ direct, styleFormatting, numbe
|
|
|
59
69
|
*/
|
|
60
70
|
declare function listLevelIndentRemovalPatch(attrs: Readonly<ParagraphAttrs>, numbering: NumberingMap | null | undefined): ParagraphAttrsPatch;
|
|
61
71
|
/** Recompute every level-dependent attr when a paragraph changes list level. */
|
|
62
|
-
declare function listLevelAttrPatch(attrs: Pick<ParagraphAttrs, "listImplicitChildLevelAdvances" | "_originalFormatting" | "_resolvedFormatting" | "_styleResolvedFormatting" | "numPr" | "numPrFromStyle" | "indentLeft" | "indentRight" | "indentFirstLine" | "hangingIndent">,
|
|
63
|
-
numId: number;
|
|
64
|
-
ilvl: number;
|
|
65
|
-
}, numbering: NumberingMap | null | undefined): ParagraphAttrsPatch;
|
|
72
|
+
declare function listLevelAttrPatch(attrs: Pick<ParagraphAttrs, "listImplicitChildLevelAdvances" | "_originalFormatting" | "_resolvedFormatting" | "_styleResolvedFormatting" | "numPr" | "numPrFromStyle" | "indentLeft" | "indentRight" | "indentFirstLine" | "hangingIndent">, ilvl: number, numbering: NumberingMap | null | undefined): ParagraphAttrsPatch;
|
|
66
73
|
//#endregion
|
|
67
74
|
export { listAttrsFromNumbering, listAttrsFromResolvedStyle, listIndentationProvenancePatch, listLevelAttrPatch, listLevelIndentRemovalPatch, paragraphAttrsFromResolvedStyle };
|
|
@@ -4,21 +4,12 @@ import { tableOfContentsStyleLevel } from "../../utils/tableOfContentsStyle.js";
|
|
|
4
4
|
import { setAutospacingBaseValue } from "../autospacingBase.js";
|
|
5
5
|
import { CLEARED_LIST_RENDERING_ATTRS } from "../listMarker.js";
|
|
6
6
|
import { listRenderingAttrPatch } from "../listRenderingAttrs.js";
|
|
7
|
-
import { paragraphNumberingAttr } from "../numberingAttr.js";
|
|
7
|
+
import { effectiveParagraphNumbering, effectiveParagraphNumberingReference, paragraphNumberingAttr, paragraphNumberingSourcesFromBoundary } from "../numberingAttr.js";
|
|
8
8
|
import { styleResolvedParagraphFormatting } from "../paragraphFormattingProvenance.js";
|
|
9
9
|
import { directParagraphIndentation, paragraphIndentationAttrPatch, paragraphIndentationFromFormatting, withDirectParagraphIndentation } from "../paragraphIndentation.js";
|
|
10
|
+
import { panic } from "better-result";
|
|
10
11
|
//#region src/prosemirror/styles/resolvedStyleAttrs.ts
|
|
11
12
|
/**
|
|
12
|
-
* Shared helper for projecting a resolved paragraph style onto ProseMirror
|
|
13
|
-
* paragraph node attrs.
|
|
14
|
-
*
|
|
15
|
-
* Both `applyStyle` (toolbar style picker) and the Enter handler's
|
|
16
|
-
* next-style switch need to write the same set of style-controlled attrs.
|
|
17
|
-
* Keeping the projection in one place ensures the two paths stay in sync —
|
|
18
|
-
* a style applied via the picker and a style applied on Enter produce
|
|
19
|
-
* identical paragraph attrs.
|
|
20
|
-
*/
|
|
21
|
-
/**
|
|
22
13
|
* The paragraph attrs a style definition controls. Applying a style resets
|
|
23
14
|
* every one of these to the style's value (or `null` to clear), so a prior
|
|
24
15
|
* style's properties (e.g. a heading's spacing) never leak through. Returns
|
|
@@ -82,10 +73,13 @@ function listAttrsFromResolvedStyle(resolved, numbering) {
|
|
|
82
73
|
const numPr = resolved.paragraphFormatting?.numPr;
|
|
83
74
|
if (numPr?.kind !== "reference") return null;
|
|
84
75
|
const { numId, ilvl = 0 } = numPr;
|
|
85
|
-
const attrs =
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
76
|
+
const attrs = {
|
|
77
|
+
...listAttrsFromNumbering({
|
|
78
|
+
numId,
|
|
79
|
+
ilvl
|
|
80
|
+
}, numbering),
|
|
81
|
+
numPr: null
|
|
82
|
+
};
|
|
89
83
|
attrs.numPrFromStyle = paragraphNumberingAttr(paragraphNumberingReference({
|
|
90
84
|
numId,
|
|
91
85
|
ilvl
|
|
@@ -173,7 +167,10 @@ function listIndentationProvenancePatch({ direct, styleFormatting, numberingSour
|
|
|
173
167
|
* {@link listLevelIndentAttrPatch}.
|
|
174
168
|
*/
|
|
175
169
|
function listLevelIndentRemovalPatch(attrs, numbering) {
|
|
176
|
-
if (
|
|
170
|
+
if (effectiveParagraphNumbering(paragraphNumberingSourcesFromBoundary({
|
|
171
|
+
numPr: attrs.numPr,
|
|
172
|
+
numPrFromStyle: attrs.numPrFromStyle
|
|
173
|
+
}))?.kind !== "reference") return {};
|
|
177
174
|
const direct = directParagraphIndentation(attrs);
|
|
178
175
|
return {
|
|
179
176
|
...listIndentationProvenancePatch({
|
|
@@ -187,15 +184,28 @@ function listLevelIndentRemovalPatch(attrs, numbering) {
|
|
|
187
184
|
};
|
|
188
185
|
}
|
|
189
186
|
/** Recompute every level-dependent attr when a paragraph changes list level. */
|
|
190
|
-
function listLevelAttrPatch(attrs,
|
|
187
|
+
function listLevelAttrPatch(attrs, ilvl, numbering) {
|
|
188
|
+
const reference = effectiveParagraphNumberingReference(paragraphNumberingSourcesFromBoundary({
|
|
189
|
+
numPr: attrs.numPr,
|
|
190
|
+
numPrFromStyle: attrs.numPrFromStyle
|
|
191
|
+
}));
|
|
192
|
+
if (reference === void 0) panic("Cannot change list level without an effective numbering reference");
|
|
193
|
+
const numPr = {
|
|
194
|
+
numId: reference.numId,
|
|
195
|
+
ilvl
|
|
196
|
+
};
|
|
191
197
|
const direct = directParagraphIndentation(attrs);
|
|
192
198
|
return {
|
|
193
199
|
...listAttrsFromNumbering(numPr, numbering),
|
|
200
|
+
...attrs.numPr?.kind !== "reference" && attrs.numPrFromStyle?.kind === "reference" ? { numPr: paragraphNumberingAttr({
|
|
201
|
+
kind: "levelOnly",
|
|
202
|
+
ilvl: numPr.ilvl
|
|
203
|
+
}) } : {},
|
|
194
204
|
listImplicitChildLevelAdvances: attrs.listImplicitChildLevelAdvances ?? null,
|
|
195
205
|
...listIndentationProvenancePatch({
|
|
196
206
|
direct,
|
|
197
207
|
styleFormatting: attrs._styleResolvedFormatting,
|
|
198
|
-
numberingSource: attrs.numPrFromStyle == null ? "paragraph" : "style",
|
|
208
|
+
numberingSource: attrs.numPr?.kind === "reference" || attrs.numPrFromStyle == null ? "paragraph" : "style",
|
|
199
209
|
numPr,
|
|
200
210
|
numbering
|
|
201
211
|
}),
|
|
@@ -8,20 +8,26 @@ import * as Y from "yjs";
|
|
|
8
8
|
*/
|
|
9
9
|
type AttrSchemaMigrationStep = (fragment: Y.XmlFragment) => number;
|
|
10
10
|
/** Every attr-schema version this build reads, oldest first, with no gaps. */
|
|
11
|
-
declare const FOLIO_YJS_ATTR_SCHEMA_VERSIONS: readonly [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
|
|
11
|
+
declare const FOLIO_YJS_ATTR_SCHEMA_VERSIONS: readonly [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13];
|
|
12
12
|
/** An attr-schema version this build can read. */
|
|
13
13
|
type FolioYjsAttrSchemaVersion = (typeof FOLIO_YJS_ATTR_SCHEMA_VERSIONS)[number];
|
|
14
14
|
/**
|
|
15
15
|
* The attr-schema version this build writes. Derived against the migration map
|
|
16
16
|
* so the constant and the map cannot disagree.
|
|
17
17
|
*/
|
|
18
|
-
declare const FOLIO_YJS_ATTR_SCHEMA_VERSION =
|
|
18
|
+
declare const FOLIO_YJS_ATTR_SCHEMA_VERSION = 13;
|
|
19
19
|
declare const FolioYjsNoteReferenceSchemaError_base: import("better-result").TaggedErrorClass<"FolioYjsNoteReferenceSchemaError">;
|
|
20
20
|
declare class FolioYjsNoteReferenceSchemaError extends FolioYjsNoteReferenceSchemaError_base<{
|
|
21
21
|
message: string;
|
|
22
22
|
schemaVersion: FolioYjsAttrSchemaVersion;
|
|
23
23
|
requiredSchemaVersion: FolioYjsAttrSchemaVersion;
|
|
24
24
|
}> {}
|
|
25
|
+
declare const FolioYjsNumberingSourceSchemaError_base: import("better-result").TaggedErrorClass<"FolioYjsNumberingSourceSchemaError">;
|
|
26
|
+
declare class FolioYjsNumberingSourceSchemaError extends FolioYjsNumberingSourceSchemaError_base<{
|
|
27
|
+
message: string;
|
|
28
|
+
schemaVersion: FolioYjsAttrSchemaVersion;
|
|
29
|
+
requiredSchemaVersion: FolioYjsAttrSchemaVersion;
|
|
30
|
+
}> {}
|
|
25
31
|
/**
|
|
26
32
|
* The steps that carry a snapshot written under `fromVersion` up to
|
|
27
33
|
* {@link FOLIO_YJS_ATTR_SCHEMA_VERSION}, in order. Empty when the snapshot is
|
|
@@ -76,4 +82,4 @@ declare const writeYjsDocumentMetadata: (ydoc: Y.Doc, document: Node) => void;
|
|
|
76
82
|
declare const readYjsParagraphSourceContract: (ydoc: Y.Doc) => string | null;
|
|
77
83
|
declare const withParagraphSourceContract: (document: Node, contract: string) => Node;
|
|
78
84
|
//#endregion
|
|
79
|
-
export { FOLIO_YJS_ATTR_SCHEMA_VERSION, FolioYjsAttrSchemaVersion, FolioYjsAttrSchemaVersionError, FolioYjsNoteReferenceSchemaError, applyAttrSchemaMigrations, attrSchemaMigrationSteps, proseDocumentParagraphSourceContract, readYjsAttrSchemaVersion, readYjsParagraphSourceContract, withParagraphSourceContract, writeYjsAttrSchemaVersion, writeYjsDocumentMetadata };
|
|
85
|
+
export { FOLIO_YJS_ATTR_SCHEMA_VERSION, FolioYjsAttrSchemaVersion, FolioYjsAttrSchemaVersionError, FolioYjsNoteReferenceSchemaError, FolioYjsNumberingSourceSchemaError, applyAttrSchemaMigrations, attrSchemaMigrationSteps, proseDocumentParagraphSourceContract, readYjsAttrSchemaVersion, readYjsParagraphSourceContract, withParagraphSourceContract, writeYjsAttrSchemaVersion, writeYjsDocumentMetadata };
|
|
@@ -475,7 +475,8 @@ const FOLIO_YJS_ATTR_SCHEMA_VERSIONS = [
|
|
|
475
475
|
9,
|
|
476
476
|
10,
|
|
477
477
|
11,
|
|
478
|
-
12
|
|
478
|
+
12,
|
|
479
|
+
13
|
|
479
480
|
];
|
|
480
481
|
/**
|
|
481
482
|
* The one place a persisted attr-shape change is decided.
|
|
@@ -500,14 +501,44 @@ const ATTR_SCHEMA_MIGRATIONS = {
|
|
|
500
501
|
9: dropUnstatedPlaceholderFlags,
|
|
501
502
|
10: renamePageBreakRunOwnerMarkAttr,
|
|
502
503
|
11: stampMarkerOnly,
|
|
503
|
-
12:
|
|
504
|
+
12: stampMarkerOnly,
|
|
505
|
+
13: "current"
|
|
504
506
|
};
|
|
505
507
|
/**
|
|
506
508
|
* The attr-schema version this build writes. Derived against the migration map
|
|
507
509
|
* so the constant and the map cannot disagree.
|
|
508
510
|
*/
|
|
509
|
-
const FOLIO_YJS_ATTR_SCHEMA_VERSION =
|
|
511
|
+
const FOLIO_YJS_ATTR_SCHEMA_VERSION = 13;
|
|
510
512
|
var FolioYjsNoteReferenceSchemaError = class extends TaggedError("FolioYjsNoteReferenceSchemaError") {};
|
|
513
|
+
var FolioYjsNumberingSourceSchemaError = class extends TaggedError("FolioYjsNumberingSourceSchemaError") {};
|
|
514
|
+
/** Older snapshots can hold a resolved style reference where a stated override belongs. */
|
|
515
|
+
const requireStatedNumberingSources = (fragment, schemaVersion) => {
|
|
516
|
+
if (schemaVersion === 13) return;
|
|
517
|
+
const pending = [];
|
|
518
|
+
const visit = (node) => {
|
|
519
|
+
if ("getAttributes" in node) pending.push(node.getAttributes());
|
|
520
|
+
for (const child of node.toArray()) if (typeof child !== "string" && !isXmlText(child) && "toArray" in child) visit(child);
|
|
521
|
+
};
|
|
522
|
+
visit(fragment);
|
|
523
|
+
const seen = /* @__PURE__ */ new WeakSet();
|
|
524
|
+
while (pending.length > 0) {
|
|
525
|
+
const value = pending.pop();
|
|
526
|
+
if (typeof value !== "object" || value === null || seen.has(value)) continue;
|
|
527
|
+
seen.add(value);
|
|
528
|
+
if (Array.isArray(value)) {
|
|
529
|
+
for (const entry of value) pending.push(entry);
|
|
530
|
+
continue;
|
|
531
|
+
}
|
|
532
|
+
if (!isRecord(value)) continue;
|
|
533
|
+
const numbering = value["numPr"];
|
|
534
|
+
if (isRecord(value["numPrFromStyle"]) && isRecord(numbering) && (numbering["kind"] === "reference" || "numId" in numbering)) throw new FolioYjsNumberingSourceSchemaError({
|
|
535
|
+
schemaVersion,
|
|
536
|
+
requiredSchemaVersion: 13,
|
|
537
|
+
message: `Yjs schema ${schemaVersion} has ambiguous numbering ownership; schema 13 requires stated numbering overrides. Rebuild the collaboration state from the saved DOCX.`
|
|
538
|
+
});
|
|
539
|
+
for (const entry of Object.values(value)) pending.push(entry);
|
|
540
|
+
}
|
|
541
|
+
};
|
|
511
542
|
/** Check before any migration mutates the snapshot or any PM builder can drop text. */
|
|
512
543
|
const requireNoteOccurrenceAttribution = (fragment, schemaVersion) => {
|
|
513
544
|
const visit = (node) => {
|
|
@@ -524,8 +555,8 @@ const requireNoteOccurrenceAttribution = (fragment, schemaVersion) => {
|
|
|
524
555
|
if (isRecord(reference) && isNoteReferenceOccurrenceId(reference["occurrenceId"])) continue;
|
|
525
556
|
throw new FolioYjsNoteReferenceSchemaError({
|
|
526
557
|
schemaVersion,
|
|
527
|
-
requiredSchemaVersion:
|
|
528
|
-
message: `Yjs schema ${schemaVersion} has unattributed note references; schema
|
|
558
|
+
requiredSchemaVersion: 13,
|
|
559
|
+
message: `Yjs schema ${schemaVersion} has unattributed note references; schema 13 requires occurrence identities. Rebuild the collaboration state from the saved DOCX.`
|
|
529
560
|
});
|
|
530
561
|
}
|
|
531
562
|
}
|
|
@@ -557,7 +588,8 @@ const attrSchemaMigrationSteps = (fromVersion) => FOLIO_YJS_ATTR_SCHEMA_VERSIONS
|
|
|
557
588
|
*/
|
|
558
589
|
const applyAttrSchemaMigrations = (ydoc, fragment, fromVersion) => {
|
|
559
590
|
requireNoteOccurrenceAttribution(fragment, fromVersion);
|
|
560
|
-
|
|
591
|
+
requireStatedNumberingSources(fragment, fromVersion);
|
|
592
|
+
if (fromVersion === 13) return 0;
|
|
561
593
|
let rewritten = 0;
|
|
562
594
|
ydoc.transact(() => {
|
|
563
595
|
for (const step of attrSchemaMigrationSteps(fromVersion)) rewritten += step(fragment);
|
|
@@ -567,7 +599,7 @@ const applyAttrSchemaMigrations = (ydoc, fragment, fromVersion) => {
|
|
|
567
599
|
};
|
|
568
600
|
/** Raised when a snapshot's attr-schema marker is ahead of the running code. */
|
|
569
601
|
var FolioYjsAttrSchemaVersionError = class extends TaggedError("FolioYjsAttrSchemaVersionError") {};
|
|
570
|
-
const isReadableVersion = (marker) => typeof marker === "number" && Number.isInteger(marker) && marker >= 0 && marker <=
|
|
602
|
+
const isReadableVersion = (marker) => typeof marker === "number" && Number.isInteger(marker) && marker >= 0 && marker <= 13;
|
|
571
603
|
/**
|
|
572
604
|
* The attr-schema version a collaboration document was written under.
|
|
573
605
|
*
|
|
@@ -585,7 +617,7 @@ const readYjsAttrSchemaVersion = (ydoc) => {
|
|
|
585
617
|
return Result.err(new FolioYjsAttrSchemaVersionError({
|
|
586
618
|
marker,
|
|
587
619
|
message: "The collaboration snapshot was written by a newer Folio attr schema than this build reads.",
|
|
588
|
-
supportedVersion:
|
|
620
|
+
supportedVersion: 13
|
|
589
621
|
}));
|
|
590
622
|
};
|
|
591
623
|
const proseDocumentParagraphSourceContract = (document) => {
|
|
@@ -593,7 +625,7 @@ const proseDocumentParagraphSourceContract = (document) => {
|
|
|
593
625
|
};
|
|
594
626
|
/** Stamp the attr-schema version of the build that wrote the current fragment. */
|
|
595
627
|
const writeYjsAttrSchemaVersion = (ydoc) => {
|
|
596
|
-
ydoc.getMap(FOLIO_YJS_METADATA_MAP_NAME).set(ATTR_SCHEMA_VERSION_KEY,
|
|
628
|
+
ydoc.getMap(FOLIO_YJS_METADATA_MAP_NAME).set(ATTR_SCHEMA_VERSION_KEY, 13);
|
|
597
629
|
};
|
|
598
630
|
/**
|
|
599
631
|
* Write both metadata bindings for a freshly seeded collaboration document.
|
|
@@ -618,4 +650,4 @@ const withParagraphSourceContract = (document, contract) => {
|
|
|
618
650
|
}, document.content, document.marks);
|
|
619
651
|
};
|
|
620
652
|
//#endregion
|
|
621
|
-
export { FOLIO_YJS_ATTR_SCHEMA_VERSION, FolioYjsAttrSchemaVersionError, FolioYjsNoteReferenceSchemaError, applyAttrSchemaMigrations, attrSchemaMigrationSteps, proseDocumentParagraphSourceContract, readYjsAttrSchemaVersion, readYjsParagraphSourceContract, withParagraphSourceContract, writeYjsAttrSchemaVersion, writeYjsDocumentMetadata };
|
|
653
|
+
export { FOLIO_YJS_ATTR_SCHEMA_VERSION, FolioYjsAttrSchemaVersionError, FolioYjsNoteReferenceSchemaError, FolioYjsNumberingSourceSchemaError, applyAttrSchemaMigrations, attrSchemaMigrationSteps, proseDocumentParagraphSourceContract, readYjsAttrSchemaVersion, readYjsParagraphSourceContract, withParagraphSourceContract, writeYjsAttrSchemaVersion, writeYjsDocumentMetadata };
|
package/dist/redline.d.ts
CHANGED
|
@@ -20,6 +20,12 @@ declare class InvalidGenerateRedlineDocxOptionsError extends InvalidGenerateRedl
|
|
|
20
20
|
option: "baseView" | "revisedView";
|
|
21
21
|
receivedValue: unknown;
|
|
22
22
|
}> {}
|
|
23
|
+
declare const GenerateRedlineDocxResourceImportError_base: import("better-result").TaggedErrorClass<"GenerateRedlineDocxResourceImportError">;
|
|
24
|
+
/** Raised before body operations when revised resources cannot be imported atomically. */
|
|
25
|
+
declare class GenerateRedlineDocxResourceImportError extends GenerateRedlineDocxResourceImportError_base<{
|
|
26
|
+
message: string;
|
|
27
|
+
detail: string;
|
|
28
|
+
}> {}
|
|
23
29
|
/** A document story that could not be paired across the two input packages. */
|
|
24
30
|
type GenerateRedlineUnprocessedStory = {
|
|
25
31
|
/** Story in the base package, or `null` when it exists only in the revision. */
|
|
@@ -29,6 +35,14 @@ type GenerateRedlineUnprocessedStory = {
|
|
|
29
35
|
/** Why the story could not be represented in the generated redline. */
|
|
30
36
|
reason: "missing-base-story" | "missing-revised-story";
|
|
31
37
|
};
|
|
38
|
+
/** A source-undefined style cleared so it cannot acquire unrelated base meaning. */
|
|
39
|
+
type GenerateRedlineReferenceWarning = {
|
|
40
|
+
/** Position in the revised story's ProseMirror projection. */
|
|
41
|
+
paragraphPosition: number;
|
|
42
|
+
story: FolioDocumentStoryHandle;
|
|
43
|
+
kind: "style";
|
|
44
|
+
id: string;
|
|
45
|
+
};
|
|
32
46
|
/** Result of {@link generateRedlineDocx}. */
|
|
33
47
|
type GenerateRedlineDocxResult = {
|
|
34
48
|
/** The base package with generated tracked changes. */
|
|
@@ -37,6 +51,8 @@ type GenerateRedlineDocxResult = {
|
|
|
37
51
|
applied: FolioAIEditAppliedOperation[];
|
|
38
52
|
/** Block operations that could not be applied. */
|
|
39
53
|
skipped: FolioAIEditSkippedOperation[];
|
|
54
|
+
/** Undefined source references cleared to avoid binding to a base definition. */
|
|
55
|
+
referenceWarnings: GenerateRedlineReferenceWarning[];
|
|
40
56
|
/** Package parts that could not be represented as story-scoped text edits. */
|
|
41
57
|
unprocessedStories: GenerateRedlineUnprocessedStory[];
|
|
42
58
|
/** Privacy transforms applied to the generated package. */
|
|
@@ -45,4 +61,4 @@ type GenerateRedlineDocxResult = {
|
|
|
45
61
|
/** Compare two buffers and return tracked changes for every matched editable story. */
|
|
46
62
|
declare const generateRedlineDocx: (base: ArrayBuffer, revised: ArrayBuffer, options?: GenerateRedlineDocxOptions) => Promise<GenerateRedlineDocxResult>;
|
|
47
63
|
//#endregion
|
|
48
|
-
export { GenerateRedlineDocxOptions, GenerateRedlineDocxResult, GenerateRedlineUnprocessedStory, InvalidGenerateRedlineDocxOptionsError, generateRedlineDocx };
|
|
64
|
+
export { GenerateRedlineDocxOptions, GenerateRedlineDocxResourceImportError, GenerateRedlineDocxResult, GenerateRedlineReferenceWarning, GenerateRedlineUnprocessedStory, InvalidGenerateRedlineDocxOptionsError, generateRedlineDocx };
|