@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,10 +1,13 @@
|
|
|
1
|
+
import { canonicalJson } from "../../utils/canonicalJson.js";
|
|
1
2
|
import { deterministicHexId } from "../../utils/hexId.js";
|
|
2
3
|
import { commentThreadParaId } from "../commentThreadKey.js";
|
|
3
4
|
import { serializeWithPreservedChildren } from "../containerChildren.js";
|
|
5
|
+
import { getDocumentSourceBaseline } from "../headerFooterVerbatim.js";
|
|
4
6
|
import { serializeParagraph } from "./paragraphSerializer.js";
|
|
5
7
|
import { serializePartElement } from "./partNamespaces.js";
|
|
6
8
|
import { serializeTextFormatting } from "./textFormattingSerializer.js";
|
|
7
|
-
import {
|
|
9
|
+
import { Result } from "better-result";
|
|
10
|
+
import { assertValidOoxmlNumericIds, escapeXmlAttribute } from "@stll/docx-core";
|
|
8
11
|
import { COMMENT_PART_RELATIONSHIPS } from "@stll/docx-core/model";
|
|
9
12
|
//#region src/docx/serializer/commentSerializer.ts
|
|
10
13
|
/**
|
|
@@ -12,6 +15,12 @@ import { COMMENT_PART_RELATIONSHIPS } from "@stll/docx-core/model";
|
|
|
12
15
|
*
|
|
13
16
|
* Serializes Comment[] to OOXML comments.xml format.
|
|
14
17
|
*/
|
|
18
|
+
/** An unrelated body edit must retain unmodelled duplicate comment definitions. */
|
|
19
|
+
const canReplayCommentsPart = (document, sourceXml) => {
|
|
20
|
+
if (Result.try(() => assertValidOoxmlNumericIds(sourceXml, "word/comments.xml")).isErr()) return false;
|
|
21
|
+
const baseline = getDocumentSourceBaseline(document);
|
|
22
|
+
return baseline.type === "captured" && canonicalJson(document.package.document.comments ?? []) === canonicalJson(baseline.body.comments ?? []);
|
|
23
|
+
};
|
|
15
24
|
/** An owned empty part survives deletion of its final thread. */
|
|
16
25
|
const hasOwnedCommentsPart = (document) => [...document.package.relationships?.values() ?? []].some(({ type }) => type === COMMENT_PART_RELATIONSHIPS.comments.type);
|
|
17
26
|
const DEFAULT_ANNOTATION_REFERENCE_PROPERTIES = "<w:rPr><w:rStyle w:val=\"CommentReference\"/></w:rPr>";
|
|
@@ -200,4 +209,4 @@ function serializeCommentsExtended(plan) {
|
|
|
200
209
|
});
|
|
201
210
|
}
|
|
202
211
|
//#endregion
|
|
203
|
-
export { hasOwnedCommentsPart, planCommentParts, serializeComments, serializeCommentsExtended };
|
|
212
|
+
export { canReplayCommentsPart, hasOwnedCommentsPart, planCommentParts, serializeComments, serializeCommentsExtended };
|
|
@@ -14,11 +14,11 @@ import { requiredWrapPolygon, serializeWrapPolygon } from "../wrapPolygon.js";
|
|
|
14
14
|
import { serializeParagraph } from "./paragraphSerializer.js";
|
|
15
15
|
import { serializeTable } from "./tableSerializer.js";
|
|
16
16
|
import { serializeTextFormatting } from "./textFormattingSerializer.js";
|
|
17
|
-
import {
|
|
17
|
+
import { serializeTrackedChangeAttributes } from "./trackedChangeAttributes.js";
|
|
18
18
|
import { intAttr } from "./xmlUtils.js";
|
|
19
19
|
import { panic } from "better-result";
|
|
20
20
|
import { escapeXmlAttribute, escapeXmlText, isValidOoxmlNumericId, requiresXmlSpacePreserve } from "@stll/docx-core";
|
|
21
|
-
import { SCHEME_COLOR_VALUE_BY_THEME_COLOR, knownThemeColor, presetLineDashToken } from "@stll/docx-core/model";
|
|
21
|
+
import { SCHEME_COLOR_VALUE_BY_THEME_COLOR, getSingularRunPropertyChange, knownThemeColor, presetLineDashToken } from "@stll/docx-core/model";
|
|
22
22
|
//#region src/docx/serializer/runSerializer.ts
|
|
23
23
|
/**
|
|
24
24
|
* Run Serializer - Serialize runs to OOXML XML
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { document_d_exports } from "../../types/document.js";
|
|
2
2
|
//#region src/docx/serializer/trackedChangeAttributes.d.ts
|
|
3
3
|
type SerializableTrackedChangeInfo = document_d_exports.TrackedChangeInfo | document_d_exports.PropertyChangeInfo;
|
|
4
|
-
/** Enforces the singular `w:rPrChange` child in a run-property container. */
|
|
5
|
-
declare const getSingularRunPropertyChange: (propertyChanges: readonly document_d_exports.RunPropertyChange[] | undefined) => document_d_exports.RunPropertyChange | undefined;
|
|
6
4
|
/** Normalized, unescaped attributes in schema order for an XML element or string serializer. */
|
|
7
5
|
declare const trackedChangeAttributeEntries: (info: SerializableTrackedChangeInfo) => readonly (readonly [string, string])[];
|
|
8
6
|
declare const trackedChangeAttributeRecord: (info: SerializableTrackedChangeInfo) => Record<string, string>;
|
|
9
7
|
declare const serializeTrackedChangeAttributes: (info: SerializableTrackedChangeInfo) => string;
|
|
10
8
|
//#endregion
|
|
11
|
-
export {
|
|
9
|
+
export { serializeTrackedChangeAttributes, trackedChangeAttributeEntries, trackedChangeAttributeRecord };
|
|
@@ -1,17 +1,7 @@
|
|
|
1
1
|
import { DATE_UTC_ATTRIBUTE } from "../trackedChangeInfo.js";
|
|
2
|
-
import { panic } from "better-result";
|
|
3
2
|
import { assertValidOoxmlNumericId, escapeXmlAttribute } from "@stll/docx-core";
|
|
4
3
|
import { normalizeRevisionId } from "@stll/docx-core/model";
|
|
5
4
|
//#region src/docx/serializer/trackedChangeAttributes.ts
|
|
6
|
-
/** Enforces the singular `w:rPrChange` child in a run-property container. */
|
|
7
|
-
const getSingularRunPropertyChange = (propertyChanges) => {
|
|
8
|
-
const propertyChangeCount = propertyChanges?.length ?? 0;
|
|
9
|
-
if (propertyChangeCount > 1) panic("A run-property container cannot serialize more than one w:rPrChange", {
|
|
10
|
-
elementName: "w:rPrChange",
|
|
11
|
-
propertyChangeCount
|
|
12
|
-
});
|
|
13
|
-
return propertyChanges?.at(0);
|
|
14
|
-
};
|
|
15
5
|
/** Normalized, unescaped attributes in schema order for an XML element or string serializer. */
|
|
16
6
|
const trackedChangeAttributeEntries = (info) => {
|
|
17
7
|
assertValidOoxmlNumericId({
|
|
@@ -34,4 +24,4 @@ const trackedChangeAttributeEntries = (info) => {
|
|
|
34
24
|
const trackedChangeAttributeRecord = (info) => Object.fromEntries(trackedChangeAttributeEntries(info));
|
|
35
25
|
const serializeTrackedChangeAttributes = (info) => trackedChangeAttributeEntries(info).map(([name, value]) => `${name}="${escapeXmlAttribute(value)}"`).join(" ");
|
|
36
26
|
//#endregion
|
|
37
|
-
export {
|
|
27
|
+
export { serializeTrackedChangeAttributes, trackedChangeAttributeEntries, trackedChangeAttributeRecord };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { fromProseDoc } from "../../prosemirror/conversion/fromProseDoc.js";
|
|
2
2
|
import { schema } from "../../prosemirror/schema/index.js";
|
|
3
|
-
import { FolioYjsNoteReferenceSchemaError, applyAttrSchemaMigrations, readYjsAttrSchemaVersion, readYjsParagraphSourceContract, withParagraphSourceContract } from "../../prosemirror/yjsDocumentMetadata.js";
|
|
3
|
+
import { FolioYjsNoteReferenceSchemaError, FolioYjsNumberingSourceSchemaError, applyAttrSchemaMigrations, readYjsAttrSchemaVersion, readYjsParagraphSourceContract, withParagraphSourceContract } from "../../prosemirror/yjsDocumentMetadata.js";
|
|
4
4
|
import { ParagraphPropertySourceValidationError } from "../paragraphPropertySource.js";
|
|
5
5
|
import { parseDocx } from "../parser.js";
|
|
6
6
|
import { repackDocx } from "../rezip.js";
|
|
@@ -57,7 +57,7 @@ const readProseMirrorDocument = (yjsUpdate) => {
|
|
|
57
57
|
},
|
|
58
58
|
catch: (cause) => {
|
|
59
59
|
if (cause instanceof FolioYjsDocxMaterializationError) return cause;
|
|
60
|
-
if (cause instanceof FolioYjsNoteReferenceSchemaError) return new FolioYjsDocxMaterializationError({
|
|
60
|
+
if (cause instanceof FolioYjsNoteReferenceSchemaError || cause instanceof FolioYjsNumberingSourceSchemaError) return new FolioYjsDocxMaterializationError({
|
|
61
61
|
code: "stale_attr_schema",
|
|
62
62
|
message: cause.message,
|
|
63
63
|
cause
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FolioYjsNoteReferenceSchemaError, applyAttrSchemaMigrations, readYjsAttrSchemaVersion } from "../../prosemirror/yjsDocumentMetadata.js";
|
|
1
|
+
import { FolioYjsNoteReferenceSchemaError, FolioYjsNumberingSourceSchemaError, applyAttrSchemaMigrations, readYjsAttrSchemaVersion } from "../../prosemirror/yjsDocumentMetadata.js";
|
|
2
2
|
import { FOLIO_YJS_PROSEMIRROR_FRAGMENT_NAME } from "./materializeYjsDocx.js";
|
|
3
3
|
import { Result, TaggedError } from "better-result";
|
|
4
4
|
import * as Y from "yjs";
|
|
@@ -77,19 +77,19 @@ const migrateFolioYjsSnapshot = (update) => {
|
|
|
77
77
|
catch: (cause) => new FolioYjsSnapshotMigrationError({
|
|
78
78
|
cause,
|
|
79
79
|
code: "unsupported_version",
|
|
80
|
-
message: cause instanceof FolioYjsNoteReferenceSchemaError ? cause.message : "Cannot migrate the collaboration attribute schema."
|
|
80
|
+
message: cause instanceof FolioYjsNoteReferenceSchemaError || cause instanceof FolioYjsNumberingSourceSchemaError ? cause.message : "Cannot migrate the collaboration attribute schema."
|
|
81
81
|
})
|
|
82
82
|
});
|
|
83
83
|
if (migratedAttrs.isErr()) {
|
|
84
84
|
ydoc.destroy();
|
|
85
85
|
return Result.err(migratedAttrs.error);
|
|
86
86
|
}
|
|
87
|
-
if (fromVersion ===
|
|
87
|
+
if (fromVersion === 13) {
|
|
88
88
|
ydoc.destroy();
|
|
89
89
|
return Result.ok({
|
|
90
90
|
fromVersion,
|
|
91
91
|
paragraphsRewritten: 0,
|
|
92
|
-
toVersion:
|
|
92
|
+
toVersion: 13,
|
|
93
93
|
update
|
|
94
94
|
});
|
|
95
95
|
}
|
|
@@ -99,7 +99,7 @@ const migrateFolioYjsSnapshot = (update) => {
|
|
|
99
99
|
return Result.ok({
|
|
100
100
|
fromVersion,
|
|
101
101
|
paragraphsRewritten,
|
|
102
|
-
toVersion:
|
|
102
|
+
toVersion: 13,
|
|
103
103
|
update: migrated
|
|
104
104
|
});
|
|
105
105
|
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
//#region src/fonts/embeddedFontFingerprint.d.ts
|
|
2
|
+
/** Callers replace owned maps on font changes; mutating a published map is unsupported. */
|
|
3
|
+
declare const embeddedFontFingerprint: (families: ReadonlyMap<string, string>) => string;
|
|
4
|
+
//#endregion
|
|
5
|
+
export { embeddedFontFingerprint };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//#region src/fonts/embeddedFontFingerprint.ts
|
|
2
|
+
/** Immutable editor-owned lookups share content fingerprints without retaining disposed editors. */
|
|
3
|
+
const fingerprints = /* @__PURE__ */ new WeakMap();
|
|
4
|
+
/** Callers replace owned maps on font changes; mutating a published map is unsupported. */
|
|
5
|
+
const embeddedFontFingerprint = (families) => {
|
|
6
|
+
const cached = fingerprints.get(families);
|
|
7
|
+
if (cached !== void 0) return cached;
|
|
8
|
+
const entries = [...families].sort(([left], [right]) => {
|
|
9
|
+
if (left < right) return -1;
|
|
10
|
+
if (left > right) return 1;
|
|
11
|
+
return 0;
|
|
12
|
+
});
|
|
13
|
+
const fingerprint = JSON.stringify(entries);
|
|
14
|
+
fingerprints.set(families, fingerprint);
|
|
15
|
+
return fingerprint;
|
|
16
|
+
};
|
|
17
|
+
//#endregion
|
|
18
|
+
export { embeddedFontFingerprint };
|
|
@@ -66,7 +66,7 @@ declare function getEmbeddedFontFaces(parts: EmbeddedFontParts, docNonce?: strin
|
|
|
66
66
|
/**
|
|
67
67
|
* Build the original DOCX font name → scoped registered family map for a set
|
|
68
68
|
* of resolved embedded faces. Callers thread this into font resolution (see
|
|
69
|
-
*
|
|
69
|
+
* the editor-owned layout session) so the document's own
|
|
70
70
|
* runs — which still carry the original name — keep resolving to the scoped
|
|
71
71
|
* face that was actually registered on `document.fonts`.
|
|
72
72
|
*/
|
|
@@ -111,7 +111,7 @@ function getEmbeddedFontFaces(parts, docNonce = generateHexId()) {
|
|
|
111
111
|
/**
|
|
112
112
|
* Build the original DOCX font name → scoped registered family map for a set
|
|
113
113
|
* of resolved embedded faces. Callers thread this into font resolution (see
|
|
114
|
-
*
|
|
114
|
+
* the editor-owned layout session) so the document's own
|
|
115
115
|
* runs — which still carry the original name — keep resolving to the scoped
|
|
116
116
|
* face that was actually registered on `document.fonts`.
|
|
117
117
|
*/
|
|
Binary file
|
|
@@ -81,7 +81,7 @@ export function shapeRun(font, face_index, text, right_to_left, script, language
|
|
|
81
81
|
function __wbg_get_imports() {
|
|
82
82
|
const import0 = {
|
|
83
83
|
__proto__: null,
|
|
84
|
-
|
|
84
|
+
__wbg___wbindgen_string_get_0380ccaa2f57f0d9: function(arg0, arg1) {
|
|
85
85
|
const obj = getObject(arg1);
|
|
86
86
|
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
87
87
|
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
@@ -89,10 +89,10 @@ function __wbg_get_imports() {
|
|
|
89
89
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
90
90
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
91
91
|
},
|
|
92
|
-
|
|
92
|
+
__wbg___wbindgen_throw_41e9ee4f547fc59a: function(arg0, arg1) {
|
|
93
93
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
94
94
|
},
|
|
95
|
-
|
|
95
|
+
__wbindgen_generic_0000000000000001: function(arg0, arg1) {
|
|
96
96
|
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
97
97
|
const ret = getStringFromWasm0(arg0, arg1);
|
|
98
98
|
return addHeapObject(ret);
|
|
@@ -268,11 +268,15 @@ function __wbg_finalize_init(instance, module) {
|
|
|
268
268
|
|
|
269
269
|
async function __wbg_load(module, imports) {
|
|
270
270
|
if (typeof Response === 'function' && module instanceof Response) {
|
|
271
|
+
if (!module.ok) {
|
|
272
|
+
throw new Error(`failed to fetch Wasm: ${module.status} ${module.statusText} fetching '${module.url}'`);
|
|
273
|
+
}
|
|
274
|
+
|
|
271
275
|
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
272
276
|
try {
|
|
273
277
|
return await WebAssembly.instantiateStreaming(module, imports);
|
|
274
278
|
} catch (e) {
|
|
275
|
-
const validResponse =
|
|
279
|
+
const validResponse = expectedResponseType(module.type);
|
|
276
280
|
|
|
277
281
|
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
278
282
|
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
Binary file
|
package/dist/headless-layout.js
CHANGED
|
@@ -108,6 +108,7 @@ const buildBlockLookup = (blocks, measures) => new Map(blocks.flatMap((block, in
|
|
|
108
108
|
}]];
|
|
109
109
|
}));
|
|
110
110
|
const buildStoryOptions = (flowOptions) => ({
|
|
111
|
+
...flowOptions.embeddedFontFamilyMap === void 0 ? {} : { embeddedFontFamilyMap: flowOptions.embeddedFontFamilyMap },
|
|
111
112
|
...flowOptions.defaultSize === void 0 ? {} : { defaultSize: flowOptions.defaultSize },
|
|
112
113
|
...flowOptions.styles === void 0 ? {} : { styles: flowOptions.styles },
|
|
113
114
|
...flowOptions.theme === void 0 ? {} : { theme: flowOptions.theme },
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { document_d_exports } from "./types/document.js";
|
|
2
|
-
import { FolioContentBlock, FolioContentContainerPathEntry, FolioContentFormatRange, FolioContentIdStability, FolioContentInlineBooleanProperty, FolioContentInlineComparisonResult, FolioContentInlineFormatting, FolioContentInlineFormattingPatch, FolioContentLineSpacingRule, FolioContentParagraphAlignment, FolioContentParagraphKind, FolioContentParagraphSpacing, FolioContentRun, FolioContentSnapshot, FolioContentTableLocation } from "./compare/content-types.js";
|
|
3
|
-
import { FolioAIBlock, FolioAIBlockAnchor, FolioAIBlockKind, FolioAIBlockPreviewRun, FolioAIBlockStructuralBoundary, FolioAIBlockTableLocation, FolioAIComment, FolioAIEditAppliedOperation, FolioAIEditApplyMode, FolioAIEditApplyResult, FolioAIEditNormalization, FolioAIEditNormalizationCode, FolioAIEditOperation, FolioAIEditPrecondition, FolioAIEditReviewMeta, FolioAIEditSeverity, FolioAIEditSkipReason, FolioAIEditSkippedOperation, FolioAIEditSnapshot, FolioAIInlineBooleanProperty, FolioAIInlineFormatting, FolioAIInlineFormattingPatch, FolioAIParagraphSpacing, FolioAISignatureParty } from "./ai-edits/types.js";
|
|
2
|
+
import { FolioContentBlock, FolioContentContainerPathEntry, FolioContentFormatRange, FolioContentIdStability, FolioContentInlineBooleanProperty, FolioContentInlineComparisonResult, FolioContentInlineFormatting, FolioContentInlineFormattingPatch, FolioContentLineSpacingRule, FolioContentParagraphAlignment, FolioContentParagraphKind, FolioContentParagraphSpacing, FolioContentRun, FolioContentSnapshot, FolioContentStatedNumbering, FolioContentTableLocation } from "./compare/content-types.js";
|
|
3
|
+
import { FolioAIBlock, FolioAIBlockAnchor, FolioAIBlockKind, FolioAIBlockPreviewRun, FolioAIBlockStructuralBoundary, FolioAIBlockTableLocation, FolioAIComment, FolioAIDiagnosticBlock, FolioAIEditAppliedOperation, FolioAIEditApplyMode, FolioAIEditApplyResult, FolioAIEditNormalization, FolioAIEditNormalizationCode, FolioAIEditOperation, FolioAIEditPrecondition, FolioAIEditReviewMeta, FolioAIEditSeverity, FolioAIEditSkipReason, FolioAIEditSkippedOperation, FolioAIEditSnapshot, FolioAIInlineBooleanProperty, FolioAIInlineFormatting, FolioAIInlineFormattingPatch, FolioAIParagraphBlock, FolioAIParagraphSpacing, FolioAISignatureParty } from "./ai-edits/types.js";
|
|
4
4
|
import { WORD_DIFF_GRANULARITIES, WordDiffGranularity, WordDiffNormalization, WordDiffOptions, WordDiffSegment, diffWordSegments } from "./ai-edits/word-diff.js";
|
|
5
|
-
import { FolioAIEditApplyOutcome, FolioRevisionStamp, FolioWordDiffOptions, applyFolioAIEditOperations } from "./ai-edits/apply.js";
|
|
5
|
+
import { FolioAIEditApplyOutcome, FolioRevisionStamp, FolioUndefinedReferencePolicy, FolioWordDiffOptions, applyFolioAIEditOperations } from "./ai-edits/apply.js";
|
|
6
6
|
import { ApplyFolioDocumentOperationsOptions, FOLIO_DOCUMENT_OPERATION_BATCH_MODES, FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FOLIO_DOCUMENT_OPERATION_MODES, FOLIO_DOCUMENT_OPERATION_MODES_BY_TYPE, FOLIO_DOCUMENT_OPERATION_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_STORIES, FOLIO_DOCUMENT_OPERATION_TYPES, FOLIO_LINE_SPACING_RULE_VALUES, FOLIO_PARAGRAPH_ALIGNMENT_VALUES, FolioDocumentOperation, FolioDocumentOperationAffectedTarget, FolioDocumentOperationBatch, FolioDocumentOperationCapabilities, FolioDocumentOperationIssue, FolioDocumentOperationMode, FolioDocumentOperationPrecondition, FolioDocumentOperationReceipt, FolioDocumentOperationRecovery, FolioDocumentOperationResult, FolioDocumentOperationResultBase, FolioDocumentOperationStatus, FolioDocumentOperationStory, FolioDocumentOperationType, FolioDocumentOperationUndoFailureReason, FolioDocumentOperationUndoHandle, FolioDocumentOperationUndoResult, InvalidFolioDocumentOperationBatchError, UnsupportedFolioDocumentOperationVersionError, applyFolioDocumentOperations, assertSupportedFolioDocumentOperationVersion, getFolioDocumentOperationCapabilities, getFolioDocumentOperationIssues, getFolioDocumentOperationReceipts, isFolioDocumentOperationModeSupported, isSupportedFolioDocumentOperationVersion, parseFolioDocumentOperationBatch } from "./document-operations.js";
|
|
7
7
|
import { createFolioAIEditSnapshot, hashFolioAIBlockText, isFolioAIContentBlock, normalizeFolioAIBlockText } from "./ai-edits/snapshot.js";
|
|
8
8
|
import { DeriveBlockIdInput, FolioBlockId, currentFolioBlockId, deriveBlockId, getFolioParaIdFromBlockId, isFolioBlockId, isSequentialFolioBlockId } from "./types/block-id.js";
|
|
@@ -38,9 +38,9 @@ import { ImageMeta, ImageRef, MarkdownOptions, MarkdownResult } from "./markdown
|
|
|
38
38
|
import { fromMarkdown } from "./markdown/fromMarkdown.js";
|
|
39
39
|
import { toMarkdown, toMarkdownResult } from "./markdown/index.js";
|
|
40
40
|
import { EmbeddedFont, EmbeddedFontParts, buildEmbeddedFontFamilyMap, extractEmbeddedFonts, getEmbeddedFontFaces, scopeEmbeddedFontFamily } from "./fonts/embeddedFonts.js";
|
|
41
|
-
import { getGoogleFontsEnabled,
|
|
41
|
+
import { getGoogleFontsEnabled, setGoogleFontsEnabled } from "./utils/fontResolver.js";
|
|
42
42
|
import { FOLIO_YJS_ATTR_SCHEMA_VERSION, FolioYjsAttrSchemaVersion, FolioYjsAttrSchemaVersionError } from "./prosemirror/yjsDocumentMetadata.js";
|
|
43
43
|
import { DOCX_CONFORMANCE_CLASSES } from "@stll/docx-core/model";
|
|
44
44
|
type Document = document_d_exports.Document;
|
|
45
45
|
type DocxConformanceClass = document_d_exports.DocxConformanceClass;
|
|
46
|
-
export { type AIBarStatus, type AIChatMode, type AICitation, type AICitationRange, type AICitationSource, type AIGenerateInput, type AISuggestion, type AISuggestionApplyMode, type AISuggestionPreset, type AISuggestionSeverity, type AISuggestionStatus, type AcceptAutocompleteResult, type AnonymizationMatch, type AnonymizationTerm, type ApplyFolioDocumentOperationsOptions, type ApplyResult, type AutocompleteSuggestionPluginOptions, type AutocompleteSuggestionState, type AutocompleteSuggestionStatus, type AutocompleteTriggerCheck, type AutocompleteTriggerOptions, type AutocompleteTriggerSkipReason, type BlockRect, COMPARE_REVISION_FORMATS, COMPARE_UNSUPPORTED_REASONS, COMPARE_VERIFICATION_CAUSES, COMPARE_VERIFICATION_INVARIANTS, type CompareChange, type CompareChangeLocation, type CompareCompatibility, type CompareContentOptions, CompareDocxApplyError, type CompareDocxError, CompareDocxFinalParagraphMarkError, CompareDocxOperationLimitError, type CompareDocxOptions, CompareDocxParseError, CompareDocxRoundTripError, CompareDocxSerializeError, type CompareFolioRequirement, type CompareResult, type CompareRevisionFormat, type CompareUnsupportedPart, type CompareUnsupportedReason, type CompareVerification, type CompareVerificationCause, type CompareVerificationFailure, type CompareVerificationInvariant, type CreateEmptyDocumentOptions, DEFAULT_AI_SUGGESTION_PRESETS, DEFAULT_AUTOCOMPLETE_DEAD_ZONE_NODES, DEFAULT_OUTLINE_DEPTH, DOCUMENT_PRESET_VERSION, DOCUMENT_STYLE_SET_VERSION, DOCX_CONFORMANCE_CLASSES, DRAWING_SAFETY_CLASSES, type DeriveBlockIdInput, type DirectiveKind, type DirectiveRange, type Document, type DocumentPreset, type DocumentPropertiesOptions, type DocumentStyleCatalog, type DocumentStyleCatalogEntry, type DocumentStyleSet, type DocxCompatibility, type DocxCompatibilityContext, type DocxCompatibilityIssue, type DocxCompatibilityLocation, type DocxCompatibilityPart, type DocxConformanceClass, type DocxDrawingClassification, type DrawingSafetyClass, type EmbeddedFont, type EmbeddedFontParts, type ExtractDocumentStyleSetOptions, FOLIO_CONTENT_COMPARISON_LIMITS, FOLIO_DOCUMENT_OPERATION_BATCH_MODES, FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FOLIO_DOCUMENT_OPERATION_MODES, FOLIO_DOCUMENT_OPERATION_MODES_BY_TYPE, FOLIO_DOCUMENT_OPERATION_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_STORIES, FOLIO_DOCUMENT_OPERATION_TYPES, FOLIO_LINE_SPACING_RULE_VALUES, FOLIO_PARAGRAPH_ALIGNMENT_VALUES, FOLIO_YJS_ATTR_SCHEMA_VERSION, type FinalParagraphMarkRevision, type FolioAIBlock, type FolioAIBlockAnchor, type FolioAIBlockKind, type FolioAIBlockPreviewRun, type FolioAIBlockStructuralBoundary, type FolioAIBlockTableLocation, type FolioAIComment, type FolioAIEditAppliedOperation, type FolioAIEditApplyMode, type FolioAIEditApplyOutcome, type FolioAIEditApplyResult, type FolioAIEditNormalization, type FolioAIEditNormalizationCode, type FolioAIEditOperation, type FolioAIEditPrecondition, type FolioAIEditReviewMeta, type FolioAIEditSeverity, type FolioAIEditSkipReason, type FolioAIEditSkippedOperation, type FolioAIEditSnapshot, type FolioAIInlineBooleanProperty, type FolioAIInlineFormatting, type FolioAIInlineFormattingPatch, type FolioAIParagraphSpacing, type FolioAISignatureParty, type FolioBlockId, type FolioContentBlock, type FolioContentBlockProperty, type FolioContentComparison, type FolioContentComparisonError, type FolioContentComparisonEvent, type FolioContentComparisonLimit, FolioContentComparisonLimitError, type FolioContentContainerPathEntry, type FolioContentFormatRange, type FolioContentFormattingChange, type FolioContentIdStability, type FolioContentInlineBooleanProperty, type FolioContentInlineComparisonResult, type FolioContentInlineFormatting, type FolioContentInlineFormattingPatch, FolioContentInlinePresentationProjectionError, type FolioContentLineSpacingRule, type FolioContentParagraphAlignment, type FolioContentParagraphFormattingPatch, type FolioContentParagraphKind, type FolioContentParagraphSpacing, type FolioContentRun, type FolioContentSnapshot, type FolioContentStructuralChange, type FolioContentTableLocation, type FolioContentTextSegment, type FolioDocumentOperation, type FolioDocumentOperationAffectedTarget, type FolioDocumentOperationBatch, type FolioDocumentOperationCapabilities, type FolioDocumentOperationIssue, type FolioDocumentOperationMode, type FolioDocumentOperationPrecondition, type FolioDocumentOperationReceipt, type FolioDocumentOperationRecovery, type FolioDocumentOperationResult, type FolioDocumentOperationResultBase, type FolioDocumentOperationStatus, type FolioDocumentOperationStory, type FolioDocumentOperationType, type FolioDocumentOperationUndoFailureReason, type FolioDocumentOperationUndoHandle, type FolioDocumentOperationUndoResult, type FolioDocxCompatibilityHost, type FolioDocxCompatibilityProfile, type FolioRevisionStamp, type FolioWordDiffOptions, type FolioYjsAttrSchemaVersion, FolioYjsAttrSchemaVersionError, type ImageMeta, type ImageRef, type InspectDocxCompatibilityOptions, InvalidCompareDocxOptionsError, InvalidFolioContentComparisonError, InvalidFolioDocumentOperationBatchError, MAX_COMPARE_OPERATIONS, type MarkdownOptions, type MarkdownResult, type OutlineDepth, type PositionalText, type ResolvedAnchor, STELLA_STYLE_SET_NAME, type TemplatePreviewHiddenRange, type TemplatePreviewSpan, type TemplatePreviewValue, type TemplatePreviewValues, type TemplateSlashMenuKeyAction, type TemplateSlashMenuState, UnsupportedFolioDocumentOperationVersionError, WORD_DIFF_GRANULARITIES, type WordDiffGranularity, type WordDiffNormalization, type WordDiffOptions, type WordDiffSegment, acceptAutocompleteSuggestion, acceptAutocompleteWord, anonymizationDecorationsKey, appendAutocompleteToken, applyFolioAIEditOperations, applyFolioDocumentOperations, applySuggestions, assertSupportedFolioDocumentOperationVersion, autocompleteSuggestionKey, autocompleteSuggestionPlugin, buildEmbeddedFontFamilyMap, buildPositionalText, clearAutocompleteSuggestion, clearTemplateSlashMenu, compareContent, compareDocx, consumeTemplateSlashQuery, createAICitationDecorationsPlugin, createDocx, createEmptyDocument, createFolioAIEditSnapshot, createStellaStyleDocumentPreset, createStellaStyleSet, currentFolioBlockId, deriveBlockId, diffWordSegments, extractDocumentStyleSet, extractDocumentStyleSetFromDocx, extractEmbeddedFonts, filterHeadingsByDepth, finishAutocompleteSuggestion, fromMarkdown, getAnonymizationMatches, getAutocompleteSuggestion, getEmbeddedFontFaces, getFolioCaretViewportRect, getFolioDocumentOperationCapabilities, getFolioDocumentOperationIssues, getFolioDocumentOperationReceipts, getFolioParaIdFromBlockId, getFolioSelectionViewportRect, getGoogleFontsEnabled, getTemplateDirectives, getTemplateSlashMenu, hashFolioAIBlockText, inspectDocumentStyles, inspectDocumentStylesFromDocx, inspectDocxCompatibility, isFolioAIContentBlock, isFolioBlockId, isFolioDocumentOperationModeSupported, isSequentialFolioBlockId, isSuggestionStale, isSupportedFolioDocumentOperationVersion, mergeDocumentContent, normalizeFolioAIBlockText, parseFolioDocumentOperationBatch, resetTemplateSlashQuery, resolveSuggestionAnchor, scanDirectives, scopeEmbeddedFontFamily, scrollFolioPositionIntoView, setAICitationsMeta, setAISuggestionsMeta, setActiveCitationMeta, setAnonymizationTermsMeta,
|
|
46
|
+
export { type AIBarStatus, type AIChatMode, type AICitation, type AICitationRange, type AICitationSource, type AIGenerateInput, type AISuggestion, type AISuggestionApplyMode, type AISuggestionPreset, type AISuggestionSeverity, type AISuggestionStatus, type AcceptAutocompleteResult, type AnonymizationMatch, type AnonymizationTerm, type ApplyFolioDocumentOperationsOptions, type ApplyResult, type AutocompleteSuggestionPluginOptions, type AutocompleteSuggestionState, type AutocompleteSuggestionStatus, type AutocompleteTriggerCheck, type AutocompleteTriggerOptions, type AutocompleteTriggerSkipReason, type BlockRect, COMPARE_REVISION_FORMATS, COMPARE_UNSUPPORTED_REASONS, COMPARE_VERIFICATION_CAUSES, COMPARE_VERIFICATION_INVARIANTS, type CompareChange, type CompareChangeLocation, type CompareCompatibility, type CompareContentOptions, CompareDocxApplyError, type CompareDocxError, CompareDocxFinalParagraphMarkError, CompareDocxOperationLimitError, type CompareDocxOptions, CompareDocxParseError, CompareDocxRoundTripError, CompareDocxSerializeError, type CompareFolioRequirement, type CompareResult, type CompareRevisionFormat, type CompareUnsupportedPart, type CompareUnsupportedReason, type CompareVerification, type CompareVerificationCause, type CompareVerificationFailure, type CompareVerificationInvariant, type CreateEmptyDocumentOptions, DEFAULT_AI_SUGGESTION_PRESETS, DEFAULT_AUTOCOMPLETE_DEAD_ZONE_NODES, DEFAULT_OUTLINE_DEPTH, DOCUMENT_PRESET_VERSION, DOCUMENT_STYLE_SET_VERSION, DOCX_CONFORMANCE_CLASSES, DRAWING_SAFETY_CLASSES, type DeriveBlockIdInput, type DirectiveKind, type DirectiveRange, type Document, type DocumentPreset, type DocumentPropertiesOptions, type DocumentStyleCatalog, type DocumentStyleCatalogEntry, type DocumentStyleSet, type DocxCompatibility, type DocxCompatibilityContext, type DocxCompatibilityIssue, type DocxCompatibilityLocation, type DocxCompatibilityPart, type DocxConformanceClass, type DocxDrawingClassification, type DrawingSafetyClass, type EmbeddedFont, type EmbeddedFontParts, type ExtractDocumentStyleSetOptions, FOLIO_CONTENT_COMPARISON_LIMITS, FOLIO_DOCUMENT_OPERATION_BATCH_MODES, FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FOLIO_DOCUMENT_OPERATION_MODES, FOLIO_DOCUMENT_OPERATION_MODES_BY_TYPE, FOLIO_DOCUMENT_OPERATION_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_STORIES, FOLIO_DOCUMENT_OPERATION_TYPES, FOLIO_LINE_SPACING_RULE_VALUES, FOLIO_PARAGRAPH_ALIGNMENT_VALUES, FOLIO_YJS_ATTR_SCHEMA_VERSION, type FinalParagraphMarkRevision, type FolioAIBlock, type FolioAIBlockAnchor, type FolioAIBlockKind, type FolioAIBlockPreviewRun, type FolioAIBlockStructuralBoundary, type FolioAIBlockTableLocation, type FolioAIComment, type FolioAIDiagnosticBlock, type FolioAIEditAppliedOperation, type FolioAIEditApplyMode, type FolioAIEditApplyOutcome, type FolioAIEditApplyResult, type FolioAIEditNormalization, type FolioAIEditNormalizationCode, type FolioAIEditOperation, type FolioAIEditPrecondition, type FolioAIEditReviewMeta, type FolioAIEditSeverity, type FolioAIEditSkipReason, type FolioAIEditSkippedOperation, type FolioAIEditSnapshot, type FolioAIInlineBooleanProperty, type FolioAIInlineFormatting, type FolioAIInlineFormattingPatch, type FolioAIParagraphBlock, type FolioAIParagraphSpacing, type FolioAISignatureParty, type FolioBlockId, type FolioContentBlock, type FolioContentBlockProperty, type FolioContentComparison, type FolioContentComparisonError, type FolioContentComparisonEvent, type FolioContentComparisonLimit, FolioContentComparisonLimitError, type FolioContentContainerPathEntry, type FolioContentFormatRange, type FolioContentFormattingChange, type FolioContentIdStability, type FolioContentInlineBooleanProperty, type FolioContentInlineComparisonResult, type FolioContentInlineFormatting, type FolioContentInlineFormattingPatch, FolioContentInlinePresentationProjectionError, type FolioContentLineSpacingRule, type FolioContentParagraphAlignment, type FolioContentParagraphFormattingPatch, type FolioContentParagraphKind, type FolioContentParagraphSpacing, type FolioContentRun, type FolioContentSnapshot, type FolioContentStatedNumbering, type FolioContentStructuralChange, type FolioContentTableLocation, type FolioContentTextSegment, type FolioDocumentOperation, type FolioDocumentOperationAffectedTarget, type FolioDocumentOperationBatch, type FolioDocumentOperationCapabilities, type FolioDocumentOperationIssue, type FolioDocumentOperationMode, type FolioDocumentOperationPrecondition, type FolioDocumentOperationReceipt, type FolioDocumentOperationRecovery, type FolioDocumentOperationResult, type FolioDocumentOperationResultBase, type FolioDocumentOperationStatus, type FolioDocumentOperationStory, type FolioDocumentOperationType, type FolioDocumentOperationUndoFailureReason, type FolioDocumentOperationUndoHandle, type FolioDocumentOperationUndoResult, type FolioDocxCompatibilityHost, type FolioDocxCompatibilityProfile, type FolioRevisionStamp, type FolioUndefinedReferencePolicy, type FolioWordDiffOptions, type FolioYjsAttrSchemaVersion, FolioYjsAttrSchemaVersionError, type ImageMeta, type ImageRef, type InspectDocxCompatibilityOptions, InvalidCompareDocxOptionsError, InvalidFolioContentComparisonError, InvalidFolioDocumentOperationBatchError, MAX_COMPARE_OPERATIONS, type MarkdownOptions, type MarkdownResult, type OutlineDepth, type PositionalText, type ResolvedAnchor, STELLA_STYLE_SET_NAME, type TemplatePreviewHiddenRange, type TemplatePreviewSpan, type TemplatePreviewValue, type TemplatePreviewValues, type TemplateSlashMenuKeyAction, type TemplateSlashMenuState, UnsupportedFolioDocumentOperationVersionError, WORD_DIFF_GRANULARITIES, type WordDiffGranularity, type WordDiffNormalization, type WordDiffOptions, type WordDiffSegment, acceptAutocompleteSuggestion, acceptAutocompleteWord, anonymizationDecorationsKey, appendAutocompleteToken, applyFolioAIEditOperations, applyFolioDocumentOperations, applySuggestions, assertSupportedFolioDocumentOperationVersion, autocompleteSuggestionKey, autocompleteSuggestionPlugin, buildEmbeddedFontFamilyMap, buildPositionalText, clearAutocompleteSuggestion, clearTemplateSlashMenu, compareContent, compareDocx, consumeTemplateSlashQuery, createAICitationDecorationsPlugin, createDocx, createEmptyDocument, createFolioAIEditSnapshot, createStellaStyleDocumentPreset, createStellaStyleSet, currentFolioBlockId, deriveBlockId, diffWordSegments, extractDocumentStyleSet, extractDocumentStyleSetFromDocx, extractEmbeddedFonts, filterHeadingsByDepth, finishAutocompleteSuggestion, fromMarkdown, getAnonymizationMatches, getAutocompleteSuggestion, getEmbeddedFontFaces, getFolioCaretViewportRect, getFolioDocumentOperationCapabilities, getFolioDocumentOperationIssues, getFolioDocumentOperationReceipts, getFolioParaIdFromBlockId, getFolioSelectionViewportRect, getGoogleFontsEnabled, getTemplateDirectives, getTemplateSlashMenu, hashFolioAIBlockText, inspectDocumentStyles, inspectDocumentStylesFromDocx, inspectDocxCompatibility, isFolioAIContentBlock, isFolioBlockId, isFolioDocumentOperationModeSupported, isSequentialFolioBlockId, isSuggestionStale, isSupportedFolioDocumentOperationVersion, mergeDocumentContent, normalizeFolioAIBlockText, parseFolioDocumentOperationBatch, resetTemplateSlashQuery, resolveSuggestionAnchor, scanDirectives, scopeEmbeddedFontFamily, scrollFolioPositionIntoView, setAICitationsMeta, setAISuggestionsMeta, setActiveCitationMeta, setAnonymizationTermsMeta, setFocusedSuggestionMeta, setGoogleFontsEnabled, setTemplatePreviewValues, shouldTriggerAutocomplete, startAutocompleteSuggestion, templateSlashMenuKey, toMarkdown, toMarkdownResult };
|
package/dist/index.js
CHANGED
|
@@ -31,8 +31,8 @@ import { STELLA_STYLE_SET_NAME, createStellaStyleDocumentPreset, createStellaSty
|
|
|
31
31
|
import { DOCUMENT_PRESET_VERSION, DOCUMENT_STYLE_SET_VERSION } from "./style-sets/types.js";
|
|
32
32
|
import { currentFolioBlockId, deriveBlockId, getFolioParaIdFromBlockId, isFolioBlockId, isSequentialFolioBlockId } from "./types/block-id.js";
|
|
33
33
|
import { createEmptyDocument } from "./utils/createDocument.js";
|
|
34
|
-
import { getGoogleFontsEnabled,
|
|
34
|
+
import { getGoogleFontsEnabled, setGoogleFontsEnabled } from "./utils/fontResolver.js";
|
|
35
35
|
import { mergeDocumentContent } from "./utils/mergeDocumentContent.js";
|
|
36
36
|
import { DEFAULT_OUTLINE_DEPTH, filterHeadingsByDepth } from "./utils/outlineDepth.js";
|
|
37
37
|
import { DOCX_CONFORMANCE_CLASSES } from "@stll/docx-core/model";
|
|
38
|
-
export { COMPARE_REVISION_FORMATS, COMPARE_UNSUPPORTED_REASONS, COMPARE_VERIFICATION_CAUSES, COMPARE_VERIFICATION_INVARIANTS, CompareDocxApplyError, CompareDocxFinalParagraphMarkError, CompareDocxOperationLimitError, CompareDocxParseError, CompareDocxRoundTripError, CompareDocxSerializeError, DEFAULT_AI_SUGGESTION_PRESETS, DEFAULT_AUTOCOMPLETE_DEAD_ZONE_NODES, DEFAULT_OUTLINE_DEPTH, DOCUMENT_PRESET_VERSION, DOCUMENT_STYLE_SET_VERSION, DOCX_CONFORMANCE_CLASSES, DRAWING_SAFETY_CLASSES, FOLIO_CONTENT_COMPARISON_LIMITS, FOLIO_DOCUMENT_OPERATION_BATCH_MODES, FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FOLIO_DOCUMENT_OPERATION_MODES, FOLIO_DOCUMENT_OPERATION_MODES_BY_TYPE, FOLIO_DOCUMENT_OPERATION_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_STORIES, FOLIO_DOCUMENT_OPERATION_TYPES, FOLIO_LINE_SPACING_RULE_VALUES, FOLIO_PARAGRAPH_ALIGNMENT_VALUES, FOLIO_YJS_ATTR_SCHEMA_VERSION, FolioContentComparisonLimitError, FolioContentInlinePresentationProjectionError, FolioYjsAttrSchemaVersionError, InvalidCompareDocxOptionsError, InvalidFolioContentComparisonError, InvalidFolioDocumentOperationBatchError, MAX_COMPARE_OPERATIONS, STELLA_STYLE_SET_NAME, UnsupportedFolioDocumentOperationVersionError, WORD_DIFF_GRANULARITIES, acceptAutocompleteSuggestion, acceptAutocompleteWord, anonymizationDecorationsKey, appendAutocompleteToken, applyFolioAIEditOperations, applyFolioDocumentOperations, applySuggestions, assertSupportedFolioDocumentOperationVersion, autocompleteSuggestionKey, autocompleteSuggestionPlugin, buildEmbeddedFontFamilyMap, buildPositionalText, clearAutocompleteSuggestion, clearTemplateSlashMenu, compareContent, compareDocx, consumeTemplateSlashQuery, createAICitationDecorationsPlugin, createDocx, createEmptyDocument, createFolioAIEditSnapshot, createStellaStyleDocumentPreset, createStellaStyleSet, currentFolioBlockId, deriveBlockId, diffWordSegments, extractDocumentStyleSet, extractDocumentStyleSetFromDocx, extractEmbeddedFonts, filterHeadingsByDepth, finishAutocompleteSuggestion, fromMarkdown, getAnonymizationMatches, getAutocompleteSuggestion, getEmbeddedFontFaces, getFolioCaretViewportRect, getFolioDocumentOperationCapabilities, getFolioDocumentOperationIssues, getFolioDocumentOperationReceipts, getFolioParaIdFromBlockId, getFolioSelectionViewportRect, getGoogleFontsEnabled, getTemplateDirectives, getTemplateSlashMenu, hashFolioAIBlockText, inspectDocumentStyles, inspectDocumentStylesFromDocx, inspectDocxCompatibility, isFolioAIContentBlock, isFolioBlockId, isFolioDocumentOperationModeSupported, isSequentialFolioBlockId, isSuggestionStale, isSupportedFolioDocumentOperationVersion, mergeDocumentContent, normalizeFolioAIBlockText, parseFolioDocumentOperationBatch, resetTemplateSlashQuery, resolveSuggestionAnchor, scanDirectives, scopeEmbeddedFontFamily, scrollFolioPositionIntoView, setAICitationsMeta, setAISuggestionsMeta, setActiveCitationMeta, setAnonymizationTermsMeta,
|
|
38
|
+
export { COMPARE_REVISION_FORMATS, COMPARE_UNSUPPORTED_REASONS, COMPARE_VERIFICATION_CAUSES, COMPARE_VERIFICATION_INVARIANTS, CompareDocxApplyError, CompareDocxFinalParagraphMarkError, CompareDocxOperationLimitError, CompareDocxParseError, CompareDocxRoundTripError, CompareDocxSerializeError, DEFAULT_AI_SUGGESTION_PRESETS, DEFAULT_AUTOCOMPLETE_DEAD_ZONE_NODES, DEFAULT_OUTLINE_DEPTH, DOCUMENT_PRESET_VERSION, DOCUMENT_STYLE_SET_VERSION, DOCX_CONFORMANCE_CLASSES, DRAWING_SAFETY_CLASSES, FOLIO_CONTENT_COMPARISON_LIMITS, FOLIO_DOCUMENT_OPERATION_BATCH_MODES, FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FOLIO_DOCUMENT_OPERATION_MODES, FOLIO_DOCUMENT_OPERATION_MODES_BY_TYPE, FOLIO_DOCUMENT_OPERATION_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_STORIES, FOLIO_DOCUMENT_OPERATION_TYPES, FOLIO_LINE_SPACING_RULE_VALUES, FOLIO_PARAGRAPH_ALIGNMENT_VALUES, FOLIO_YJS_ATTR_SCHEMA_VERSION, FolioContentComparisonLimitError, FolioContentInlinePresentationProjectionError, FolioYjsAttrSchemaVersionError, InvalidCompareDocxOptionsError, InvalidFolioContentComparisonError, InvalidFolioDocumentOperationBatchError, MAX_COMPARE_OPERATIONS, STELLA_STYLE_SET_NAME, UnsupportedFolioDocumentOperationVersionError, WORD_DIFF_GRANULARITIES, acceptAutocompleteSuggestion, acceptAutocompleteWord, anonymizationDecorationsKey, appendAutocompleteToken, applyFolioAIEditOperations, applyFolioDocumentOperations, applySuggestions, assertSupportedFolioDocumentOperationVersion, autocompleteSuggestionKey, autocompleteSuggestionPlugin, buildEmbeddedFontFamilyMap, buildPositionalText, clearAutocompleteSuggestion, clearTemplateSlashMenu, compareContent, compareDocx, consumeTemplateSlashQuery, createAICitationDecorationsPlugin, createDocx, createEmptyDocument, createFolioAIEditSnapshot, createStellaStyleDocumentPreset, createStellaStyleSet, currentFolioBlockId, deriveBlockId, diffWordSegments, extractDocumentStyleSet, extractDocumentStyleSetFromDocx, extractEmbeddedFonts, filterHeadingsByDepth, finishAutocompleteSuggestion, fromMarkdown, getAnonymizationMatches, getAutocompleteSuggestion, getEmbeddedFontFaces, getFolioCaretViewportRect, getFolioDocumentOperationCapabilities, getFolioDocumentOperationIssues, getFolioDocumentOperationReceipts, getFolioParaIdFromBlockId, getFolioSelectionViewportRect, getGoogleFontsEnabled, getTemplateDirectives, getTemplateSlashMenu, hashFolioAIBlockText, inspectDocumentStyles, inspectDocumentStylesFromDocx, inspectDocxCompatibility, isFolioAIContentBlock, isFolioBlockId, isFolioDocumentOperationModeSupported, isSequentialFolioBlockId, isSuggestionStale, isSupportedFolioDocumentOperationVersion, mergeDocumentContent, normalizeFolioAIBlockText, parseFolioDocumentOperationBatch, resetTemplateSlashQuery, resolveSuggestionAnchor, scanDirectives, scopeEmbeddedFontFamily, scrollFolioPositionIntoView, setAICitationsMeta, setAISuggestionsMeta, setActiveCitationMeta, setAnonymizationTermsMeta, setFocusedSuggestionMeta, setGoogleFontsEnabled, setTemplatePreviewValues, shouldTriggerAutocomplete, startAutocompleteSuggestion, templateSlashMenuKey, toMarkdown, toMarkdownResult };
|
|
@@ -3,14 +3,7 @@ import { ParagraphNumberingOverride } from "@stll/docx-core/model";
|
|
|
3
3
|
//#region src/internal/paragraphFormattingSerialization.d.ts
|
|
4
4
|
type ClassifiedParagraphFormattingField = "alignment" | "bidi" | "kinsoku" | "overflowPunctuation" | "spaceBefore" | "spaceAfter" | "lineSpacing" | "lineSpacingRule" | "snapToGrid" | "beforeAutospacing" | "afterAutospacing" | "spacingExplicit" | "spacingPreservedAttributes" | "indentLeft" | "indentRight" | "indentFirstLine" | "hangingIndent" | "indentPreservedAttributes" | "borders" | "shading" | "tabs" | "keepNext" | "keepLines" | "widowControl" | "pageBreakBefore" | "contextualSpacing" | "numPr" | "numPrFromStyle" | "numberingChangeXml" | "numberingInsertionXml" | "outlineLevel" | "styleId" | "frame" | "suppressLineNumbers" | "suppressAutoHyphens" | "runProperties" | "runInWithNext" | "preserved";
|
|
5
5
|
type ExhaustiveParagraphFormatting = document_d_exports.ExhaustiveFields<document_d_exports.ParagraphFormatting, ClassifiedParagraphFormattingField>;
|
|
6
|
-
/**
|
|
7
|
-
* Whether resolved numbering still belongs to the paragraph's style tier.
|
|
8
|
-
*
|
|
9
|
-
* Effective equality, not stated: the resolved field carries the level the
|
|
10
|
-
* cascade supplied even where the style stated none, and a paragraph whose
|
|
11
|
-
* numbering came wholly from its style must still not emit a direct
|
|
12
|
-
* `<w:numPr>`.
|
|
13
|
-
*/
|
|
6
|
+
/** Only an absent paragraph override leaves numbering wholly to its style. */
|
|
14
7
|
declare const isStyleSourcedParagraphNumbering: (numPr: ParagraphNumberingOverride | null | undefined, numPrFromStyle: ParagraphNumberingOverride | null | undefined) => boolean;
|
|
15
8
|
/** Exact fallback-emission instructions for the modeled part of `w:pPr`. */
|
|
16
9
|
type ModeledParagraphFormattingEmission = Readonly<{
|
|
@@ -6,18 +6,11 @@ import { TRANSITIONAL_NAME_BY_STRICT_NAME } from "../docx/strictNames.gen.js";
|
|
|
6
6
|
import { createCapturedXmlSanitizer } from "../docx/verbatimCapture.js";
|
|
7
7
|
import { NAMESPACES, OOXML_NAMESPACE_SCOPE } from "../docx/xmlParser.js";
|
|
8
8
|
import { escapeXmlAttribute, serializeOnOffElement } from "@stll/docx-core";
|
|
9
|
-
import {
|
|
9
|
+
import { outlineLevelStatedValue, paragraphNumberingSlots } from "@stll/docx-core/model";
|
|
10
10
|
import { serializeSequenceChildren } from "@stll/docx-core/schema";
|
|
11
11
|
//#region src/internal/paragraphFormattingSerialization.ts
|
|
12
|
-
/**
|
|
13
|
-
|
|
14
|
-
*
|
|
15
|
-
* Effective equality, not stated: the resolved field carries the level the
|
|
16
|
-
* cascade supplied even where the style stated none, and a paragraph whose
|
|
17
|
-
* numbering came wholly from its style must still not emit a direct
|
|
18
|
-
* `<w:numPr>`.
|
|
19
|
-
*/
|
|
20
|
-
const isStyleSourcedParagraphNumbering = (numPr, numPrFromStyle) => numPr != null && numPrFromStyle != null && sameEffectiveParagraphNumbering(numPr, numPrFromStyle);
|
|
12
|
+
/** Only an absent paragraph override leaves numbering wholly to its style. */
|
|
13
|
+
const isStyleSourcedParagraphNumbering = (numPr, numPrFromStyle) => numPr == null && numPrFromStyle != null;
|
|
21
14
|
const serializeParagraphBorders = (borders) => {
|
|
22
15
|
if (!borders) return "";
|
|
23
16
|
const { top, left, bottom, right, between, bar } = borders;
|
|
@@ -150,7 +143,7 @@ const paragraphMarkPropertiesInner = (runProperties, runInWithNext) => {
|
|
|
150
143
|
*/
|
|
151
144
|
const modelParagraphFormattingEmission = (input) => {
|
|
152
145
|
if (!input) return {};
|
|
153
|
-
const { alignment, bidi, kinsoku, overflowPunctuation, spaceBefore, spaceAfter, lineSpacing, lineSpacingRule, snapToGrid, beforeAutospacing, afterAutospacing, spacingExplicit, spacingPreservedAttributes, indentLeft, indentRight, indentFirstLine, hangingIndent, indentPreservedAttributes, borders, shading, tabs, keepNext, keepLines, widowControl, pageBreakBefore, contextualSpacing, numPr,
|
|
146
|
+
const { alignment, bidi, kinsoku, overflowPunctuation, spaceBefore, spaceAfter, lineSpacing, lineSpacingRule, snapToGrid, beforeAutospacing, afterAutospacing, spacingExplicit, spacingPreservedAttributes, indentLeft, indentRight, indentFirstLine, hangingIndent, indentPreservedAttributes, borders, shading, tabs, keepNext, keepLines, widowControl, pageBreakBefore, contextualSpacing, numPr, numberingChangeXml, numberingInsertionXml, outlineLevel, styleId, frame, suppressLineNumbers, suppressAutoHyphens, runProperties, runInWithNext, preserved } = input;
|
|
154
147
|
modelSpacingProvenance(spacingExplicit);
|
|
155
148
|
const propertiesXml = serializeSequenceChildren({
|
|
156
149
|
container: "paragraph-properties",
|
|
@@ -162,15 +155,8 @@ const modelParagraphFormattingEmission = (input) => {
|
|
|
162
155
|
["pageBreakBefore", serializeOnOffElement(pageBreakBefore, "pageBreakBefore")],
|
|
163
156
|
["framePr", serializeFrameProperties(frame)],
|
|
164
157
|
["widowControl", serializeOnOffElement(widowControl, "widowControl")],
|
|
165
|
-
["numPr",
|
|
166
|
-
numPr
|
|
167
|
-
numberingChangeXml,
|
|
168
|
-
numberingInsertionXml
|
|
169
|
-
}) : serializeNumbering({
|
|
170
|
-
numPr: numPr?.kind === "reference" && numPrFromStyle?.kind === "reference" && numPr.numId === numPrFromStyle.numId ? {
|
|
171
|
-
kind: "levelOnly",
|
|
172
|
-
ilvl: paragraphNumberingLevel(mergeParagraphNumbering(numPrFromStyle, numPr)) ?? 0
|
|
173
|
-
} : numPr,
|
|
158
|
+
["numPr", serializeNumbering({
|
|
159
|
+
numPr,
|
|
174
160
|
numberingChangeXml,
|
|
175
161
|
numberingInsertionXml
|
|
176
162
|
})],
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { document_d_exports } from "../../types/document.js";
|
|
2
2
|
import { RunStyleResolver } from "../../prosemirror/runStyleFormatting.js";
|
|
3
|
+
import { ListCounterStreams } from "../../prosemirror/listMarker.js";
|
|
3
4
|
import { ParagraphAttrs, ParagraphBlock, TableBlock } from "../../layout-engine/types.js";
|
|
4
5
|
import { FontAlternates } from "../../fonts/fontAlternates.js";
|
|
5
|
-
import { ListCounterStreams } from "../../prosemirror/listMarker.js";
|
|
6
6
|
import { Node } from "prosemirror-model";
|
|
7
7
|
//#region src/layout-bridge/convert/flowConversionShared.d.ts
|
|
8
8
|
/**
|
|
9
9
|
* Options for the conversion.
|
|
10
10
|
*/
|
|
11
11
|
type ToFlowBlocksOptions = {
|
|
12
|
+
/** Embedded families owned by this editor, never ambient process state. */
|
|
13
|
+
embeddedFontFamilyMap?: ReadonlyMap<string, string>;
|
|
12
14
|
/** Default font family. */
|
|
13
15
|
defaultFont?: string;
|
|
14
16
|
/** Default font size in points. */
|
|
@@ -4,7 +4,7 @@ import { ToFlowBlocksOptions } from "./flowConversionShared.js";
|
|
|
4
4
|
import "./toFlowBlocks.js";
|
|
5
5
|
//#region src/layout-bridge/convert/footnoteLayout.d.ts
|
|
6
6
|
type MeasureBlocksFn = (blocks: FlowBlock[], contentWidth: number) => Measure[];
|
|
7
|
-
type ConvertFootnoteOptions = {
|
|
7
|
+
type ConvertFootnoteOptions = Pick<ToFlowBlocksOptions, "embeddedFontFamilyMap"> & {
|
|
8
8
|
styles?: document_d_exports.StyleDefinitions | null;
|
|
9
9
|
numbering?: document_d_exports.NumberingDefinitions;
|
|
10
10
|
theme?: document_d_exports.Theme | null;
|
|
@@ -208,6 +208,7 @@ function convertNoteStoryToFlowBlocks(content, options, referenceMarkText) {
|
|
|
208
208
|
if (options.defaultSize !== void 0) flowOptions.defaultSize = options.defaultSize;
|
|
209
209
|
if (options.styles) flowOptions.styles = options.styles;
|
|
210
210
|
if (options.theme !== void 0) flowOptions.theme = options.theme;
|
|
211
|
+
if (options.embeddedFontFamilyMap !== void 0) flowOptions.embeddedFontFamilyMap = options.embeddedFontFamilyMap;
|
|
211
212
|
if (options.fontAlternates !== void 0) flowOptions.fontAlternates = options.fontAlternates;
|
|
212
213
|
if (options.defaultTabStopTwips !== void 0) flowOptions.defaultTabStopTwips = options.defaultTabStopTwips;
|
|
213
214
|
if (options.lineBreakRules) flowOptions.lineBreakRules = options.lineBreakRules;
|
|
@@ -392,6 +393,8 @@ function createFootnoteNumberRun(displayNumber, paragraph) {
|
|
|
392
393
|
fontSize: firstFormattedRun?.fontSize ?? paragraph.attrs?.defaultFontSize ?? FOOTNOTE_FONT_SIZE,
|
|
393
394
|
superscript: true
|
|
394
395
|
};
|
|
396
|
+
const embeddedFontFamilyMap = firstFormattedRun?.embeddedFontFamilyMap ?? paragraph.attrs?.embeddedFontFamilyMap;
|
|
397
|
+
if (embeddedFontFamilyMap) numberRun.embeddedFontFamilyMap = embeddedFontFamilyMap;
|
|
395
398
|
const fontFamily = firstFormattedRun?.fontFamily ?? paragraph.attrs?.defaultFontFamily;
|
|
396
399
|
if (fontFamily) numberRun.fontFamily = fontFamily;
|
|
397
400
|
const alternateFontFamily = firstFormattedRun?.fontFamily !== void 0 ? firstFormattedRun.alternateFontFamily : paragraph.attrs?.defaultAlternateFontFamily;
|
|
@@ -45,6 +45,7 @@ type ConvertHeaderFooterOptions = {
|
|
|
45
45
|
theme?: document_d_exports.Theme | null;
|
|
46
46
|
defaultSize?: number;
|
|
47
47
|
fontAlternates?: ToFlowBlocksOptions["fontAlternates"];
|
|
48
|
+
embeddedFontFamilyMap?: ReadonlyMap<string, string>;
|
|
48
49
|
measureBlocks: MeasureBlocksFn;
|
|
49
50
|
/** Document-wide `w:defaultTabStop` in twips — forwarded to toFlowBlocks. */
|
|
50
51
|
defaultTabStopTwips?: number;
|
|
@@ -346,6 +346,7 @@ function convertHeaderFooterToContent(headerFooter, contentWidth, metrics, optio
|
|
|
346
346
|
if (options.defaultSize !== void 0) flowOptions.defaultSize = options.defaultSize;
|
|
347
347
|
if (options.styles) flowOptions.styles = options.styles;
|
|
348
348
|
if (options.theme !== void 0) flowOptions.theme = options.theme;
|
|
349
|
+
if (options.embeddedFontFamilyMap !== void 0) flowOptions.embeddedFontFamilyMap = options.embeddedFontFamilyMap;
|
|
349
350
|
if (options.fontAlternates !== void 0) flowOptions.fontAlternates = options.fontAlternates;
|
|
350
351
|
if (options.defaultTabStopTwips !== void 0) flowOptions.defaultTabStopTwips = options.defaultTabStopTwips;
|
|
351
352
|
if (options.lineBreakRules) flowOptions.lineBreakRules = options.lineBreakRules;
|
|
@@ -371,6 +372,7 @@ function convertHeaderFooterPmDocToContent(pmDoc, contentWidth, metrics, options
|
|
|
371
372
|
if (options.defaultSize !== void 0) flowOptions.defaultSize = options.defaultSize;
|
|
372
373
|
if (options.styles) flowOptions.styles = options.styles;
|
|
373
374
|
if (options.theme !== void 0) flowOptions.theme = options.theme;
|
|
375
|
+
if (options.embeddedFontFamilyMap !== void 0) flowOptions.embeddedFontFamilyMap = options.embeddedFontFamilyMap;
|
|
374
376
|
if (options.fontAlternates !== void 0) flowOptions.fontAlternates = options.fontAlternates;
|
|
375
377
|
if (options.defaultTabStopTwips !== void 0) flowOptions.defaultTabStopTwips = options.defaultTabStopTwips;
|
|
376
378
|
if (options.lineBreakRules) flowOptions.lineBreakRules = options.lineBreakRules;
|
|
@@ -2,7 +2,6 @@ import { document_d_exports } from "../../types/document.js";
|
|
|
2
2
|
import { ParagraphAttrs, ParagraphPropertyChangeAttrs } from "../../prosemirror/schema/nodes.js";
|
|
3
3
|
import { ParagraphAttrs as ParagraphAttrs$1 } from "../../layout-engine/types.js";
|
|
4
4
|
import { FontAlternates } from "../../fonts/fontAlternates.js";
|
|
5
|
-
import { ListCounterState } from "../../prosemirror/listMarker.js";
|
|
6
5
|
//#region src/layout-bridge/convert/listMarkers.d.ts
|
|
7
6
|
declare function applyMarkerAllCaps(marker: string | null, allCaps: boolean | undefined): string | null;
|
|
8
7
|
/**
|
|
@@ -23,6 +22,6 @@ declare function isChangedNumberingChange(currentNumPr: NonNullable<ParagraphAtt
|
|
|
23
22
|
};
|
|
24
23
|
declare function applyDeletedListMarkerAttrs(attrs: ParagraphAttrs$1, change: ListPropertyChange & {
|
|
25
24
|
previousFormatting: ListPropertyFormatting;
|
|
26
|
-
},
|
|
25
|
+
}, theme: document_d_exports.Theme | null | undefined, fontAlternates: FontAlternates | undefined, paragraphMarkFormatting: () => document_d_exports.TextFormatting | undefined): void;
|
|
27
26
|
//#endregion
|
|
28
27
|
export { ListPropertyChange, ListPropertyFormatting, applyDeletedListMarkerAttrs, applyMarkerAllCaps, isAddedNumberingChange, isChangedNumberingChange, isRemovedNumberingChange, toListMarkerRevision };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { bulletMarkerFontName, convertBulletToUnicode } from "../../docx/bulletMarkers.js";
|
|
2
2
|
import { isListNumPr } from "../../layout-engine/types.js";
|
|
3
|
-
import { advanceListMarker } from "../../prosemirror/listMarker.js";
|
|
4
3
|
import { listMarkerFormattingFor } from "./textFormattingConversion.js";
|
|
5
4
|
import { sameStatedParagraphNumbering } from "@stll/docx-core/model";
|
|
6
5
|
//#region src/layout-bridge/convert/listMarkers.ts
|
|
@@ -12,9 +11,6 @@ function applyMarkerAllCaps(marker, allCaps) {
|
|
|
12
11
|
if (marker === null || !allCaps) return marker;
|
|
13
12
|
return marker.toLocaleUpperCase();
|
|
14
13
|
}
|
|
15
|
-
function computeListMarker(pmAttrs, state) {
|
|
16
|
-
return advanceListMarker(pmAttrs, state);
|
|
17
|
-
}
|
|
18
14
|
function toListMarkerRevision(kind, info) {
|
|
19
15
|
const revision = { kind };
|
|
20
16
|
if (typeof info?.author === "string") revision.author = info.author;
|
|
@@ -72,18 +68,14 @@ function toPreviousListAttrs(previousFormatting) {
|
|
|
72
68
|
if (listMarkerSecondSlotOffsetTwips !== void 0) attrs.listMarkerSecondSlotOffsetTwips = listMarkerSecondSlotOffsetTwips;
|
|
73
69
|
return attrs;
|
|
74
70
|
}
|
|
75
|
-
function resolveDeletedListMarker(previousListAttrs
|
|
76
|
-
if (listCounterState && previousListAttrs.numPr) {
|
|
77
|
-
const marker = computeListMarker(previousListAttrs, listCounterState);
|
|
78
|
-
if (marker) return marker;
|
|
79
|
-
}
|
|
71
|
+
function resolveDeletedListMarker(previousListAttrs) {
|
|
80
72
|
if (previousListAttrs.listMarker) return previousListAttrs.listIsBullet ? convertBulletToUnicode(previousListAttrs.listMarker, bulletMarkerFontName(previousListAttrs.listMarkerFormatting)) : previousListAttrs.listMarker;
|
|
81
73
|
if (previousListAttrs.listIsBullet) return "•";
|
|
82
74
|
return null;
|
|
83
75
|
}
|
|
84
|
-
function applyDeletedListMarkerAttrs(attrs, change,
|
|
76
|
+
function applyDeletedListMarkerAttrs(attrs, change, theme, fontAlternates, paragraphMarkFormatting) {
|
|
85
77
|
const previousListAttrs = toPreviousListAttrs(change.previousFormatting);
|
|
86
|
-
const marker = resolveDeletedListMarker(previousListAttrs
|
|
78
|
+
const marker = resolveDeletedListMarker(previousListAttrs);
|
|
87
79
|
if (!marker) return;
|
|
88
80
|
attrs.listMarker = marker;
|
|
89
81
|
attrs.listMarkerRevision = toListMarkerRevision("del", change.info);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { document_d_exports } from "../../types/document.js";
|
|
2
2
|
import { ParagraphAttrs } from "../../prosemirror/schema/nodes.js";
|
|
3
|
+
import { ListCounterStreams } from "../../prosemirror/listMarker.js";
|
|
3
4
|
import { ParagraphAttrs as ParagraphAttrs$1 } from "../../layout-engine/types.js";
|
|
4
5
|
import { FontAlternates } from "../../fonts/fontAlternates.js";
|
|
5
|
-
import { ListCounterStreams } from "../../prosemirror/listMarker.js";
|
|
6
6
|
//#region src/layout-bridge/convert/paragraphAttrs.d.ts
|
|
7
7
|
type ConvertParagraphAttrsOptions = {
|
|
8
8
|
theme: document_d_exports.Theme | null | undefined;
|
|
@@ -2,6 +2,7 @@ import { bulletMarkerFontName, convertBulletToUnicode } from "../../docx/bulletM
|
|
|
2
2
|
import { getFontAlternate } from "../../fonts/fontAlternates.js";
|
|
3
3
|
import { autospacingMatchesBase } from "../../prosemirror/autospacingBase.js";
|
|
4
4
|
import { advanceVisibleListMarker } from "../../prosemirror/listMarker.js";
|
|
5
|
+
import { effectiveParagraphNumberingReference, paragraphNumberingSourcesFromBoundary } from "../../prosemirror/numberingAttr.js";
|
|
5
6
|
import { directionIsRtl, directionToBidi } from "../../prosemirror/paragraphDirection.js";
|
|
6
7
|
import { mergeParagraphTabStops } from "../../utils/paragraphFormattingMerge.js";
|
|
7
8
|
import { AUTO_PARAGRAPH_SPACING_PX } from "../../utils/units.js";
|
|
@@ -9,7 +10,6 @@ import { convertBorderSpecToLayout } from "./flowBorders.js";
|
|
|
9
10
|
import { twipsToPixels } from "./flowConversionShared.js";
|
|
10
11
|
import { applyDeletedListMarkerAttrs, applyMarkerAllCaps, isAddedNumberingChange, isChangedNumberingChange, isRemovedNumberingChange, toListMarkerRevision } from "./listMarkers.js";
|
|
11
12
|
import { listMarkerFormattingFor, resolveWesternThemeFont } from "./textFormattingConversion.js";
|
|
12
|
-
import { paragraphNumberingLevel, paragraphNumberingReferenceId } from "@stll/docx-core/model";
|
|
13
13
|
//#region src/layout-bridge/convert/paragraphAttrs.ts
|
|
14
14
|
/**
|
|
15
15
|
* Converts ProseMirror paragraph attributes to layout ParagraphAttrs:
|
|
@@ -88,8 +88,12 @@ function convertParagraphAttrs(pmAttrs, { theme, fontAlternates, listCounterStre
|
|
|
88
88
|
let indentLeft = typeof pmAttrs.indentLeft === "number" ? pmAttrs.indentLeft : void 0;
|
|
89
89
|
let indentFirstLine = typeof pmAttrs.indentFirstLine === "number" ? pmAttrs.indentFirstLine : void 0;
|
|
90
90
|
let hangingIndent = pmAttrs.hangingIndent;
|
|
91
|
-
|
|
92
|
-
|
|
91
|
+
const numbering = effectiveParagraphNumberingReference(paragraphNumberingSourcesFromBoundary({
|
|
92
|
+
numPr: pmAttrs.numPr,
|
|
93
|
+
numPrFromStyle: pmAttrs.numPrFromStyle
|
|
94
|
+
}));
|
|
95
|
+
if (numbering !== void 0 && indentLeft === void 0 && indentFirstLine === void 0) {
|
|
96
|
+
indentLeft = ((numbering.ilvl ?? 0) + 1) * 720;
|
|
93
97
|
if (indentFirstLine === void 0) {
|
|
94
98
|
indentFirstLine = -360;
|
|
95
99
|
hangingIndent = true;
|
|
@@ -177,7 +181,7 @@ function convertParagraphAttrs(pmAttrs, { theme, fontAlternates, listCounterStre
|
|
|
177
181
|
if (!pmAttrs.numPr) {
|
|
178
182
|
const numberingRemovedChange = propertyChanges.find(isRemovedNumberingChange);
|
|
179
183
|
if (numberingRemovedChange) {
|
|
180
|
-
applyDeletedListMarkerAttrs(attrs, numberingRemovedChange,
|
|
184
|
+
applyDeletedListMarkerAttrs(attrs, numberingRemovedChange, theme, fontAlternates, paragraphMarkFormatting);
|
|
181
185
|
if (resolvedMarker !== null) {
|
|
182
186
|
attrs.listMarker = resolvedMarker;
|
|
183
187
|
attrs.listMarkerRevision = toListMarkerRevision("del", numberingRemovedChange.info);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { getFontAlternate } from "../../fonts/fontAlternates.js";
|
|
2
2
|
import { setParagraphFrame } from "../../layout-engine/paragraphFrame.js";
|
|
3
3
|
import { expectParagraphAttrs } from "../../prosemirror/attrs/index.js";
|
|
4
|
+
import { expectBookmarkBoundaryAttrs } from "../../prosemirror/bookmarkBoundaryAttrs.js";
|
|
4
5
|
import { expectTextBoxAnchorAttrs } from "../../prosemirror/textBoxAnchorAttrs.js";
|
|
5
6
|
import { nextBlockId, twipsToPixels } from "./flowConversionShared.js";
|
|
6
7
|
import { convertParagraphAttrs } from "./paragraphAttrs.js";
|
|
@@ -76,7 +77,13 @@ function convertParagraph(node, startPos, options, pageBreaks) {
|
|
|
76
77
|
if (isFullyHiddenParagraph) attrs.suppressEmptyParagraphHeight = true;
|
|
77
78
|
if (runs.length === 0 && expectDetachedWatermarkHostAttr(node.attrs)) attrs.suppressEmptyParagraphHeight = false;
|
|
78
79
|
if (runs.length === 0 && pmAttrs._pageBreakCarrier === true && !hasVisibleParagraphPayload(attrs)) attrs.suppressEmptyParagraphHeight = true;
|
|
79
|
-
const bookmarkNames = pmAttrs.bookmarks?.map((b) => b.name);
|
|
80
|
+
const bookmarkNames = pmAttrs.bookmarks?.map((b) => b.name) ?? [];
|
|
81
|
+
node.descendants((child) => {
|
|
82
|
+
if (child.type.name !== "bookmarkBoundary") return true;
|
|
83
|
+
const marker = expectBookmarkBoundaryAttrs(child);
|
|
84
|
+
if (marker.type === "start") bookmarkNames.push(marker.name);
|
|
85
|
+
return false;
|
|
86
|
+
});
|
|
80
87
|
const block = {
|
|
81
88
|
kind: "paragraph",
|
|
82
89
|
id: nextBlockId(),
|