@stll/folio-core 0.67.0 → 0.68.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai-edits/apply.d.ts +9 -1
- package/dist/ai-edits/apply.js +94 -8
- package/dist/ai-edits/headless.d.ts +36 -21
- package/dist/ai-edits/headless.js +104 -34
- package/dist/ai-edits/index.d.ts +2 -2
- package/dist/ai-edits/note-references.d.ts +6 -0
- package/dist/ai-edits/note-references.js +7 -1
- package/dist/ai-edits/read.d.ts +19 -0
- package/dist/ai-edits/snapshot.d.ts +6 -0
- package/dist/ai-edits/snapshot.js +8 -3
- package/dist/ai-edits/types.d.ts +9 -1
- package/dist/ai-suggestions/apply.js +13 -4
- package/dist/compare/compare.js +2 -1
- package/dist/compare/inserted-resource-snapshot.d.ts +4 -1
- package/dist/compare/inserted-resource-snapshot.js +7 -3
- package/dist/controller/canonicalClipboard.js +29 -12
- package/dist/controller/canonicalComposition.js +1 -1
- package/dist/controller/canonicalInlineProjection.d.ts +35 -10
- package/dist/controller/canonicalInlineProjection.js +192 -28
- package/dist/controller/canonicalInput.d.ts +2 -1
- package/dist/controller/canonicalInput.js +28 -1
- package/dist/controller/canonicalListRendering.d.ts +2 -1
- package/dist/controller/canonicalListRendering.js +1 -1
- package/dist/controller/canonicalLockGuard.d.ts +8 -0
- package/dist/controller/canonicalLockGuard.js +88 -0
- package/dist/controller/canonicalPublicOperations.d.ts +12 -4
- package/dist/controller/canonicalPublicOperations.js +274 -20
- package/dist/controller/canonicalSession.d.ts +87 -7
- package/dist/controller/canonicalSession.js +327 -73
- package/dist/controller/canonicalStoryEditor.d.ts +3 -2
- package/dist/controller/canonicalStoryEditor.js +4 -3
- package/dist/controller/canonicalStructure.d.ts +2 -1
- package/dist/controller/canonicalStructure.js +129 -7
- package/dist/controller/contentControlWidgetController.d.ts +5 -0
- package/dist/controller/contentControlWidgetController.js +13 -1
- package/dist/controller/folioEditor.js +1 -0
- package/dist/controller/headerFooterEditorManager.d.ts +2 -2
- package/dist/controller/headerFooterEditorManager.js +5 -5
- package/dist/controller/hiddenEditorApi.d.ts +6 -0
- package/dist/controller/hiddenEditorApi.js +1 -0
- package/dist/controller/hiddenEditorManager.d.ts +4 -3
- package/dist/controller/hiddenEditorManager.js +91 -37
- package/dist/controller/layoutPipeline.js +48 -15
- package/dist/controller/noteEditorManager.d.ts +2 -2
- package/dist/controller/noteEditorManager.js +5 -5
- package/dist/display-list/build/pageFurniture.js +41 -19
- package/dist/display-list/build/tablePrimitives.js +23 -4
- package/dist/display-list/dom/renderDisplayListToDom.js +4 -4
- package/dist/document-operations.d.ts +8 -0
- package/dist/document-operations.js +4 -3
- package/dist/docx/blockContentParser.d.ts +7 -3
- package/dist/docx/blockContentParser.js +2 -3
- package/dist/docx/blockPlainText.js +2 -0
- package/dist/docx/bookmarkRangeJoin.d.ts +6 -0
- package/dist/docx/bookmarkRangeJoin.js +43 -0
- package/dist/docx/canonicalSave.js +5 -1
- package/dist/docx/canonicalSessionInput.d.ts +5 -1
- package/dist/docx/canonicalSessionInput.js +7 -2
- package/dist/docx/commentAnchorIndex.d.ts +21 -5
- package/dist/docx/commentAnchorIndex.js +39 -11
- package/dist/docx/commentRangeIntegrity.js +30 -24
- package/dist/docx/commentRangeJoin.d.ts +4 -0
- package/dist/docx/commentRangeJoin.js +26 -12
- package/dist/docx/commentReferenceCompletion.js +5 -4
- package/dist/docx/commentReferenceNormalization.js +40 -18
- package/dist/docx/compatibility.js +9 -2
- package/dist/docx/containerChildren.js +22 -1
- package/dist/docx/encryption/compoundFile.js +9 -1
- package/dist/docx/encryption/encryptionInfo.js +16 -2
- package/dist/docx/ensureParaIds.js +46 -7
- package/dist/docx/ensureUniqueControlIds.d.ts +25 -0
- package/dist/docx/ensureUniqueControlIds.js +110 -0
- package/dist/docx/headerFooterVerbatim.d.ts +7 -0
- package/dist/docx/headerFooterVerbatim.js +13 -2
- package/dist/docx/hostCommentThreads.d.ts +17 -0
- package/dist/docx/hostCommentThreads.js +49 -0
- package/dist/docx/hyperlinkParser.js +9 -2
- package/dist/docx/inlineWrapperContent.d.ts +8 -1
- package/dist/docx/inlineWrapperContent.js +9 -2
- package/dist/docx/listMarkerComputation.d.ts +35 -1
- package/dist/docx/listMarkerComputation.js +39 -1
- package/dist/docx/listModelNormalization.d.ts +44 -1
- package/dist/docx/listModelNormalization.js +227 -96
- package/dist/docx/markupRangeMarker.d.ts +14 -0
- package/dist/docx/markupRangeMarker.js +15 -1
- package/dist/docx/metadataPrivacy.js +43 -22
- package/dist/docx/normalizeBaseDirection.js +3 -1
- package/dist/docx/paragraphParser.js +159 -48
- package/dist/docx/paragraphPropertySource.d.ts +7 -0
- package/dist/docx/paragraphPropertySource.js +22 -1
- package/dist/docx/paragraphTextBoxEnrichment.js +2 -1
- package/dist/docx/paragraphTraversal.js +2 -0
- package/dist/docx/parseWarningMessage.js +2 -1
- package/dist/docx/parser.js +6 -0
- package/dist/docx/renderedPageBreakNormalization.js +1 -1
- package/dist/docx/reviewProvenanceDiagnostics.d.ts +7 -0
- package/dist/docx/reviewProvenanceDiagnostics.js +39 -0
- package/dist/docx/reviewResolutionProvenance.d.ts +29 -3
- package/dist/docx/reviewResolutionProvenance.js +110 -25
- package/dist/docx/rezip.d.ts +6 -0
- package/dist/docx/rezip.js +38 -21
- package/dist/docx/selectiveSave.js +6 -10
- package/dist/docx/selectiveXmlPatch.d.ts +5 -4
- package/dist/docx/selectiveXmlPatch.js +11 -7
- package/dist/docx/serializer/documentSerializer.js +3 -1
- package/dist/docx/serializer/headerFooterSerializer.js +3 -1
- package/dist/docx/serializer/markupRangeAttributes.d.ts +6 -1
- package/dist/docx/serializer/markupRangeAttributes.js +6 -1
- package/dist/docx/serializer/noteSerializer.d.ts +17 -4
- package/dist/docx/serializer/noteSerializer.js +23 -16
- package/dist/docx/serializer/paragraphSerializer.js +56 -12
- package/dist/docx/serializer/runSerializer.d.ts +1 -3
- package/dist/docx/serializer/runSerializer.js +2 -2
- package/dist/docx/serializer/tableSerializer.d.ts +4 -0
- package/dist/docx/serializer/tableSerializer.js +4 -2
- package/dist/docx/server/applyDocxXmlPatchProposal.js +8 -4
- package/dist/docx/server/createBilingualDocument.js +27 -5
- package/dist/docx/server/migrateYjsAttrSchema.js +4 -0
- package/dist/docx/sessionListPruning.d.ts +2 -0
- package/dist/docx/sessionListPruning.js +50 -0
- package/dist/docx/splitRevisionPieces.d.ts +10 -0
- package/dist/docx/splitRevisionPieces.js +14 -0
- package/dist/docx/storyBlockReplay.js +4 -0
- package/dist/docx/structuralXmlPatch.js +19 -7
- package/dist/docx/tableParser.d.ts +6 -2
- package/dist/docx/tableParser.js +2 -3
- package/dist/docx/textBoxContentParser.d.ts +11 -0
- package/dist/docx/textBoxContentParser.js +51 -0
- package/dist/docx/textBoxParser.d.ts +0 -5
- package/dist/docx/textBoxParser.js +1 -23
- package/dist/docx/verticalMergeProjection.js +1 -1
- package/dist/fonts/fontsourceFaces.d.ts +2 -8
- package/dist/fonts/fontsourceFaces.js +1 -7
- package/dist/i18n/messages/ar.gen.js +2 -0
- package/dist/i18n/messages/catalogs.gen.d.ts +34 -0
- package/dist/i18n/messages/catalogs.gen.js +34 -0
- package/dist/i18n/messages/cs.gen.js +2 -0
- package/dist/i18n/messages/de.gen.js +2 -0
- package/dist/i18n/messages/en.gen.js +2 -0
- package/dist/i18n/messages/es.gen.js +2 -0
- package/dist/i18n/messages/et.gen.js +2 -0
- package/dist/i18n/messages/fr.gen.js +2 -0
- package/dist/i18n/messages/he.gen.js +2 -0
- package/dist/i18n/messages/hi.gen.js +2 -0
- package/dist/i18n/messages/hu.gen.js +2 -0
- package/dist/i18n/messages/lt.gen.js +2 -0
- package/dist/i18n/messages/lv.gen.js +2 -0
- package/dist/i18n/messages/messages.gen.d.ts +2 -0
- package/dist/i18n/messages/pl.gen.js +2 -0
- package/dist/i18n/messages/pt-BR.gen.js +2 -0
- package/dist/i18n/messages/sk.gen.js +2 -0
- package/dist/i18n/messages/tr.gen.js +2 -0
- package/dist/i18n/messages/zh-CN.gen.js +2 -0
- package/dist/internal/acceptedBlockProjection.js +2 -0
- package/dist/internal/pageBreakRunSourceDescendantIndex.d.ts +5 -0
- package/dist/internal/pageBreakRunSourceDescendantIndex.js +5 -0
- package/dist/internal/revisionResolutionInline.js +1 -2
- package/dist/layout-bridge/convert/tableConversion.js +19 -8
- package/dist/layout-bridge/engine/blockIndex.d.ts +7 -0
- package/dist/layout-bridge/engine/blockIndex.js +12 -0
- package/dist/layout-bridge/engine/hitTest.js +9 -10
- package/dist/layout-bridge/engine/selectionRects.js +6 -6
- package/dist/layout-engine/footnoteContinuation.d.ts +36 -0
- package/dist/layout-engine/footnoteContinuation.js +210 -0
- package/dist/layout-engine/index.d.ts +2 -2
- package/dist/layout-engine/index.js +7 -2
- package/dist/layout-engine/measure/cache.js +10 -5
- package/dist/layout-engine/measure/measureParagraph.js +1 -1
- package/dist/layout-engine/tableLayout.js +29 -5
- package/dist/layout-engine/tableRowBreak.d.ts +36 -0
- package/dist/layout-engine/tableRowBreak.js +43 -1
- package/dist/layout-engine/types.d.ts +36 -1
- package/dist/layout-painter/renderPage.d.ts +4 -4
- package/dist/layout-painter/renderPage.js +46 -17
- package/dist/layout-painter/renderTable.js +7 -4
- package/dist/managers/AutoSaveManager.d.ts +5 -1
- package/dist/managers/FindReplaceManager.js +3 -10
- package/dist/markdown/escape.d.ts +20 -1
- package/dist/markdown/escape.js +43 -1
- package/dist/markdown/renderBlock.js +4 -1
- package/dist/markdown/renderParagraph.js +13 -27
- package/dist/markdown/renderTable.js +6 -2
- package/dist/markdown/trailers.js +1 -0
- package/dist/pdf/images.d.ts +17 -1
- package/dist/pdf/images.js +22 -4
- package/dist/pdf/writePdf.js +4 -2
- package/dist/prosemirror/attrs/index.js +1 -0
- package/dist/prosemirror/canonicalCommands.d.ts +39 -1
- package/dist/prosemirror/canonicalTableCommands.d.ts +28 -0
- package/dist/prosemirror/canonicalTableCommands.js +362 -0
- package/dist/prosemirror/commands/comments.d.ts +25 -0
- package/dist/prosemirror/commands/comments.js +102 -11
- package/dist/prosemirror/commands/formatting.d.ts +1 -1
- package/dist/prosemirror/commands/index.d.ts +1 -1
- package/dist/prosemirror/commentIdAllocator.js +2 -2
- package/dist/prosemirror/commentRangeBoundaryAttrs.d.ts +6 -0
- package/dist/prosemirror/commentRangeBoundaryAttrs.js +9 -3
- package/dist/prosemirror/commentReferenceIntegrity.js +3 -4
- package/dist/prosemirror/conversion/fromProseDoc.d.ts +2 -0
- package/dist/prosemirror/conversion/fromProseDoc.js +76 -31
- package/dist/prosemirror/conversion/index.d.ts +1 -1
- package/dist/prosemirror/conversion/toProseDoc.d.ts +128 -1
- package/dist/prosemirror/conversion/toProseDoc.js +319 -51
- package/dist/prosemirror/extensions/StarterKit.js +2 -0
- package/dist/prosemirror/extensions/core/DocExtension.js +1 -1
- package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.d.ts +1 -1
- package/dist/prosemirror/extensions/features/JoinedRunStyleExtension.d.ts +1 -1
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.d.ts +1 -1
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.d.ts +1 -1
- package/dist/prosemirror/extensions/features/pastedHtmlLists.js +5 -4
- package/dist/prosemirror/extensions/marks/CommentExtension.js +6 -3
- package/dist/prosemirror/extensions/nodes/BlockCommentRangeBoundaryExtension.d.ts +4 -0
- package/dist/prosemirror/extensions/nodes/BlockCommentRangeBoundaryExtension.js +49 -0
- package/dist/prosemirror/extensions/nodes/ImageExtension.js +12 -3
- package/dist/prosemirror/extensions/nodes/TableExtension.js +32 -31
- package/dist/prosemirror/extensions/nodes/TextBoxExtension.js +1 -1
- package/dist/prosemirror/index.d.ts +2 -2
- package/dist/prosemirror/listLabels.js +3 -2
- package/dist/prosemirror/listNumbering.d.ts +6 -0
- package/dist/prosemirror/listNumbering.js +12 -9
- package/dist/prosemirror/lockedControls.d.ts +13 -0
- package/dist/prosemirror/lockedControls.js +106 -0
- package/dist/prosemirror/markupViewProjection.js +1 -1
- package/dist/prosemirror/noteReferenceReview.js +2 -2
- package/dist/prosemirror/plugins/documentNumbering.js +4 -1
- package/dist/prosemirror/plugins/suggestionMode.js +20 -9
- package/dist/prosemirror/plugins/templatePreviewValues.js +16 -1
- package/dist/prosemirror/rebaseParagraphRuns.js +1 -1
- package/dist/prosemirror/replacedAnnotations.js +1 -0
- package/dist/prosemirror/runFormattingFromMarks.d.ts +0 -1
- package/dist/prosemirror/runFormattingFromMarks.js +2 -4
- package/dist/prosemirror/runFormattingReconciliation.js +2 -2
- package/dist/prosemirror/runPropertyChangeResolution.js +1 -2
- package/dist/prosemirror/runStyleFormatting.d.ts +14 -4
- package/dist/prosemirror/runStyleFormatting.js +16 -13
- package/dist/prosemirror/schema/marks.d.ts +6 -0
- package/dist/prosemirror/styles/paragraphStyleCascade.js +2 -2
- package/dist/prosemirror/validation.js +1 -0
- package/dist/redline.js +23 -9
- package/dist/server.d.ts +2 -2
- package/dist/style-sets/extract.js +2 -2
- package/dist/types/canonicalCapabilities.d.ts +29 -8
- package/dist/types/canonicalCapabilities.js +13 -9
- package/dist/utils/cssString.d.ts +7 -0
- package/dist/utils/cssString.js +9 -0
- package/dist/utils/fontResolver.js +4 -1
- package/dist/utils/replaceText.d.ts +11 -0
- package/dist/utils/replaceText.js +39 -7
- package/dist/version-comparison.d.ts +9 -1
- package/dist/version-comparison.js +11 -5
- package/package.json +2 -2
|
@@ -2,6 +2,12 @@ import { isDisplacedByCustomXml } from "./bookmarkBoundaryAttrs.js";
|
|
|
2
2
|
import { panic } from "better-result";
|
|
3
3
|
// src/prosemirror/commentRangeBoundaryAttrs.ts
|
|
4
4
|
const attrsCache = /* @__PURE__ */ new WeakMap();
|
|
5
|
+
/**
|
|
6
|
+
* Whether a node is a comment range boundary, inside a paragraph or between
|
|
7
|
+
* blocks. Both carry the same marker, so every reader asks this rather than
|
|
8
|
+
* naming one of them.
|
|
9
|
+
*/
|
|
10
|
+
const isCommentRangeBoundaryNode = (node) => node.type.name === "commentRangeBoundary" || node.type.name === "blockCommentRangeBoundary";
|
|
5
11
|
const isRecord = (value) => typeof value === "object" && value !== null;
|
|
6
12
|
const readCommentRangeBoundaryMarker = (value) => {
|
|
7
13
|
if (!isRecord(value)) return void 0;
|
|
@@ -18,9 +24,9 @@ const readCommentRangeBoundaryMarker = (value) => {
|
|
|
18
24
|
};
|
|
19
25
|
const readCommentRangeBoundaryAttrs = (node) => {
|
|
20
26
|
const issues = [];
|
|
21
|
-
if (node
|
|
27
|
+
if (!isCommentRangeBoundaryNode(node)) issues.push({
|
|
22
28
|
path: "commentRangeBoundary.type.name",
|
|
23
|
-
message: `Expected commentRangeBoundary, got ${node.type.name}.`
|
|
29
|
+
message: `Expected commentRangeBoundary or blockCommentRangeBoundary, got ${node.type.name}.`
|
|
24
30
|
});
|
|
25
31
|
const marker = readCommentRangeBoundaryMarker(node.attrs["marker"]);
|
|
26
32
|
if (!marker) issues.push({
|
|
@@ -47,4 +53,4 @@ const expectCommentRangeBoundaryAttrs = (node) => {
|
|
|
47
53
|
attrsCache.set(node, result.value);
|
|
48
54
|
return result.value;
|
|
49
55
|
};
|
|
50
|
-
export { expectCommentRangeBoundaryAttrs, readCommentRangeBoundaryAttrs, readCommentRangeBoundaryMarker };
|
|
56
|
+
export { expectCommentRangeBoundaryAttrs, isCommentRangeBoundaryNode, readCommentRangeBoundaryAttrs, readCommentRangeBoundaryMarker };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { readCommentRangeBoundaryAttrs } from "./commentRangeBoundaryAttrs.js";
|
|
1
|
+
import { isCommentRangeBoundaryNode, readCommentRangeBoundaryAttrs } from "./commentRangeBoundaryAttrs.js";
|
|
2
2
|
import { isCommentRangeInertAtom } from "./commentRangeInlineAtoms.js";
|
|
3
3
|
import { readCommentReferenceAttrs } from "./commentReferenceAttrs.js";
|
|
4
|
-
import "./extensions/nodes/CommentRangeBoundaryExtension.js";
|
|
5
4
|
import "./extensions/nodes/RangeAnchorExtension.js";
|
|
6
5
|
import { readRangeAnchorAttrs } from "./rangeAnchorAttrs.js";
|
|
7
6
|
import { panic } from "better-result";
|
|
@@ -43,7 +42,7 @@ const surveyCommentReferences = (doc) => {
|
|
|
43
42
|
}
|
|
44
43
|
return false;
|
|
45
44
|
}
|
|
46
|
-
if (node
|
|
45
|
+
if (isCommentRangeBoundaryNode(node)) {
|
|
47
46
|
const attrs = readCommentRangeBoundaryAttrs(node);
|
|
48
47
|
if (attrs.ok) {
|
|
49
48
|
const { id } = attrs.value.marker;
|
|
@@ -54,7 +53,7 @@ const surveyCommentReferences = (doc) => {
|
|
|
54
53
|
if (inert) return false;
|
|
55
54
|
if (!node.isInline) return true;
|
|
56
55
|
for (const mark of node.marks) {
|
|
57
|
-
if (mark.type.name !== "comment") continue;
|
|
56
|
+
if (mark.type.name !== "comment" || mark.attrs["point"] === true) continue;
|
|
58
57
|
const commentId = mark.attrs["commentId"];
|
|
59
58
|
if (typeof commentId !== "number") continue;
|
|
60
59
|
markEnds.set(commentId, Math.max(markEnds.get(commentId) ?? 0, position + node.nodeSize));
|
|
@@ -41,6 +41,8 @@ export declare function tableAttrsToFormatting(attrs: TableAttrs): document_d_ex
|
|
|
41
41
|
*/
|
|
42
42
|
export declare function tableRowAttrsToFormatting(attrs: TableRowAttrs): document_d_exports.TableRowFormatting | undefined;
|
|
43
43
|
export declare const standaloneTableCellFromProseMirror: (node: Node) => document_d_exports.TableCell;
|
|
44
|
+
/** A table node's rows as the save writes them, vertical merges included. */
|
|
45
|
+
export declare const standaloneTableRowsFromProseMirror: (node: Node) => document_d_exports.TableRow[];
|
|
44
46
|
export declare function tableCellAttrsToFormatting(attrs: TableCellAttrs): document_d_exports.TableCellFormatting | undefined;
|
|
45
47
|
/**
|
|
46
48
|
* Update a Document with content from a ProseMirror document
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { joinBookmarkRangesAcrossParagraphs } from "../../docx/bookmarkRangeJoin.js";
|
|
1
2
|
import { removeCommentMarkers } from "../../docx/commentAnchorIndex.js";
|
|
2
3
|
import { joinCommentRangesAcrossParagraphs } from "../../docx/commentRangeJoin.js";
|
|
3
4
|
import { completeCommentReferences } from "../../docx/commentReferenceCompletion.js";
|
|
@@ -402,6 +403,7 @@ function fromProseDoc(pmDoc, baseDocument, { stylesheetSource, reuse = "none" })
|
|
|
402
403
|
});
|
|
403
404
|
const blocks = extractBlocks(pmDoc, "resolve", createStyleEngine(styles));
|
|
404
405
|
joinCommentRangesAcrossParagraphs(blocks);
|
|
406
|
+
joinBookmarkRangesAcrossParagraphs(blocks);
|
|
405
407
|
completeCommentReferences(blocks);
|
|
406
408
|
const linkedSources = restoreLinkedParagraphPropertySources(blocks);
|
|
407
409
|
if (tokenSources) restoreParagraphPropertySourcesByToken(blocks, tokenSources);
|
|
@@ -462,7 +464,7 @@ function stripSuggestedInlineMarks(marks, readFormattingContext) {
|
|
|
462
464
|
if (!hasSuggestedDeletion && !suggestedRunPropertyChange) return marks;
|
|
463
465
|
let next = marks.filter((mark) => !((mark.type.name === "deletion" || mark.type.name === "runPropertyChange") && isSuggestedMark(mark)));
|
|
464
466
|
if (suggestedRunPropertyChange) {
|
|
465
|
-
const { baseParagraphFormatting, inheritedFormatting, paragraphMarkFormatting,
|
|
467
|
+
const { baseParagraphFormatting, inheritedFormatting, paragraphMarkFormatting, styleResolver } = readFormattingContext();
|
|
466
468
|
const previousFormatting = expectRunPropertyChangeMarkAttrs(suggestedRunPropertyChange).changes.at(0)?.previousFormatting;
|
|
467
469
|
const characterStyleMark = marks.find(({ type }) => type.name === "characterStyle");
|
|
468
470
|
const characterStyleAttrs = characterStyleMark ? expectCharacterStyleMarkAttrs(characterStyleMark) : void 0;
|
|
@@ -472,8 +474,7 @@ function stripSuggestedInlineMarks(marks, readFormattingContext) {
|
|
|
472
474
|
context: {
|
|
473
475
|
baseParagraphFormatting,
|
|
474
476
|
paragraphFormatting: inheritedFormatting,
|
|
475
|
-
paragraphMarkFormatting
|
|
476
|
-
paragraphMarkPrecedesStyle
|
|
477
|
+
paragraphMarkFormatting
|
|
477
478
|
},
|
|
478
479
|
...previousFormatting !== void 0 ? { directFormatting: previousFormatting } : {}
|
|
479
480
|
});
|
|
@@ -610,7 +611,6 @@ function mapSuggestionStrippedNode(node, readFormattingContext) {
|
|
|
610
611
|
baseParagraphFormatting: paragraphStyleContext.baseParagraphFormatting,
|
|
611
612
|
inheritedFormatting: paragraphStyleContext.paragraphFormatting,
|
|
612
613
|
paragraphMarkFormatting: paragraphStyleContext.paragraphMarkFormatting,
|
|
613
|
-
paragraphMarkPrecedesStyle: paragraphStyleContext.paragraphMarkPrecedesStyle,
|
|
614
614
|
styleResolver
|
|
615
615
|
};
|
|
616
616
|
return resolvedChildContext;
|
|
@@ -641,7 +641,6 @@ function stripSuggestedProvenance(doc, styleResolver) {
|
|
|
641
641
|
baseParagraphFormatting: void 0,
|
|
642
642
|
inheritedFormatting: void 0,
|
|
643
643
|
paragraphMarkFormatting: void 0,
|
|
644
|
-
paragraphMarkPrecedesStyle: false,
|
|
645
644
|
styleResolver
|
|
646
645
|
})) ?? doc;
|
|
647
646
|
}
|
|
@@ -733,6 +732,9 @@ function extractBlocks(inputDoc, refResolution = "resolve", styleResolver = null
|
|
|
733
732
|
} else if (node.type.name === "blockMoveRangeBoundary") {
|
|
734
733
|
blocks.push({ ...expectMoveRangeBoundaryAttrs(node) });
|
|
735
734
|
previousStandaloneTextBox = null;
|
|
735
|
+
} else if (node.type.name === "blockCommentRangeBoundary") {
|
|
736
|
+
blocks.push({ ...expectCommentRangeBoundaryAttrs(node).marker });
|
|
737
|
+
previousStandaloneTextBox = null;
|
|
736
738
|
}
|
|
737
739
|
});
|
|
738
740
|
if (pendingPageBreaks > 0 && !appendPendingPageBreaksToPreviousParagraph()) flushPendingPageBreaks();
|
|
@@ -1110,7 +1112,6 @@ function convertPMParagraph(node, documentCounts, textBoxAnchorMarkers, styleRes
|
|
|
1110
1112
|
baseParagraphFormatting: paragraphStyleContext.baseParagraphFormatting,
|
|
1111
1113
|
inheritedFormatting: paragraphStyleContext.paragraphFormatting,
|
|
1112
1114
|
paragraphMarkFormatting: paragraphStyleContext.paragraphMarkFormatting,
|
|
1113
|
-
paragraphMarkPrecedesStyle: paragraphStyleContext.paragraphMarkPrecedesStyle,
|
|
1114
1115
|
styleResolver
|
|
1115
1116
|
});
|
|
1116
1117
|
const bookmarks = attrs.bookmarks;
|
|
@@ -1594,7 +1595,6 @@ function extractParagraphContent(originalParagraph, _documentCounts, emptyHyperl
|
|
|
1594
1595
|
baseParagraphFormatting: paragraphStyleContext?.baseParagraphFormatting,
|
|
1595
1596
|
inheritedFormatting: paragraphStyleContext?.paragraphFormatting,
|
|
1596
1597
|
paragraphMarkFormatting: paragraphStyleContext?.paragraphMarkFormatting,
|
|
1597
|
-
paragraphMarkPrecedesStyle: paragraphStyleContext?.paragraphMarkPrecedesStyle ?? false,
|
|
1598
1598
|
styleResolver: null
|
|
1599
1599
|
};
|
|
1600
1600
|
const sortedEmptyHyperlinks = (emptyHyperlinks ?? []).map((attrs, order) => ({
|
|
@@ -2006,8 +2006,7 @@ function extractParagraphContent(originalParagraph, _documentCounts, emptyHyperl
|
|
|
2006
2006
|
const runFormattingContext = changeMark === deletionMark && changeAttrs._historicalFormatting ? {
|
|
2007
2007
|
...formattingContext,
|
|
2008
2008
|
inheritedFormatting: formattingContext.baseParagraphFormatting ?? formattingContext.inheritedFormatting,
|
|
2009
|
-
paragraphMarkFormatting: void 0
|
|
2010
|
-
paragraphMarkPrecedesStyle: false
|
|
2009
|
+
paragraphMarkFormatting: void 0
|
|
2011
2010
|
} : formattingContext;
|
|
2012
2011
|
const revisionAncestors = enclosingInsertionAncestors({
|
|
2013
2012
|
insertionMark: changeMark === deletionMark ? insertionMark : void 0,
|
|
@@ -2131,6 +2130,24 @@ function extractParagraphContent(originalParagraph, _documentCounts, emptyHyperl
|
|
|
2131
2130
|
return;
|
|
2132
2131
|
}
|
|
2133
2132
|
const fieldUnderLink = node.type.name === "field" || node.type.name === "structuredField";
|
|
2133
|
+
if (linkMark && fieldUnderLink) {
|
|
2134
|
+
const field = createFieldFromNode(node, {
|
|
2135
|
+
...formattingContext,
|
|
2136
|
+
marks: node.marks,
|
|
2137
|
+
textBoxAnchorMarkers
|
|
2138
|
+
});
|
|
2139
|
+
if (field.type === "complexField") {
|
|
2140
|
+
const linkKey = getLinkKey(linkMark);
|
|
2141
|
+
if (!currentHyperlink || currentHyperlinkKey !== linkKey) {
|
|
2142
|
+
flushCurrentInline();
|
|
2143
|
+
currentHyperlink = createIndexedHyperlink(linkMark);
|
|
2144
|
+
currentHyperlinkKey = linkKey;
|
|
2145
|
+
}
|
|
2146
|
+
currentHyperlink.children.push(field);
|
|
2147
|
+
syncStructuredCommentExit(node, offset);
|
|
2148
|
+
return;
|
|
2149
|
+
}
|
|
2150
|
+
}
|
|
2134
2151
|
if (linkMark && !fieldUnderLink) {
|
|
2135
2152
|
const linkKey = getLinkKey(linkMark);
|
|
2136
2153
|
if (currentHyperlink && currentHyperlinkKey === linkKey) {} else {
|
|
@@ -2254,12 +2271,11 @@ function extractParagraphContent(originalParagraph, _documentCounts, emptyHyperl
|
|
|
2254
2271
|
}
|
|
2255
2272
|
return nestInlineWrapperGroups(content, wrapperGroups, sourceHyperlinkIndices, revisionOuterWrapperCounts, revisionAncestorsByWrapper);
|
|
2256
2273
|
}
|
|
2257
|
-
function createTrackedChangeRun({ baseParagraphFormatting, inheritedFormatting, marks, node, paragraphMarkFormatting,
|
|
2274
|
+
function createTrackedChangeRun({ baseParagraphFormatting, inheritedFormatting, marks, node, paragraphMarkFormatting, styleResolver }) {
|
|
2258
2275
|
const formattingContext = {
|
|
2259
2276
|
baseParagraphFormatting,
|
|
2260
2277
|
inheritedFormatting,
|
|
2261
2278
|
paragraphMarkFormatting,
|
|
2262
|
-
paragraphMarkPrecedesStyle,
|
|
2263
2279
|
styleResolver
|
|
2264
2280
|
};
|
|
2265
2281
|
const noteRefMark = marks.find((mark) => mark.type.name === "footnoteRef");
|
|
@@ -2317,7 +2333,11 @@ function createEmptyHyperlink(attrs) {
|
|
|
2317
2333
|
}
|
|
2318
2334
|
function getCommentMarkIds(marks) {
|
|
2319
2335
|
const commentIds = /* @__PURE__ */ new Set();
|
|
2320
|
-
for (const mark of marks)
|
|
2336
|
+
for (const mark of marks) {
|
|
2337
|
+
if (mark.type.name !== "comment") continue;
|
|
2338
|
+
const attrs = expectCommentMarkAttrs(mark);
|
|
2339
|
+
if (attrs.point !== true) commentIds.add(attrs.commentId);
|
|
2340
|
+
}
|
|
2321
2341
|
return commentIds;
|
|
2322
2342
|
}
|
|
2323
2343
|
/**
|
|
@@ -2387,7 +2407,7 @@ function createHyperlink(linkMark) {
|
|
|
2387
2407
|
if (attrs.rId) hyperlink.rId = attrs.rId;
|
|
2388
2408
|
return hyperlink;
|
|
2389
2409
|
}
|
|
2390
|
-
function addNodeToHyperlink({ baseParagraphFormatting, hyperlink, inheritedFormatting, node, paragraphMarkFormatting,
|
|
2410
|
+
function addNodeToHyperlink({ baseParagraphFormatting, hyperlink, inheritedFormatting, node, paragraphMarkFormatting, sourceRunOwners, styleResolver }) {
|
|
2391
2411
|
if (node.type.name === "bookmarkBoundary") {
|
|
2392
2412
|
hyperlink.children.push(bookmarkMarkerFromAttrs(expectBookmarkBoundaryAttrs(node)));
|
|
2393
2413
|
return;
|
|
@@ -2396,7 +2416,6 @@ function addNodeToHyperlink({ baseParagraphFormatting, hyperlink, inheritedForma
|
|
|
2396
2416
|
baseParagraphFormatting,
|
|
2397
2417
|
inheritedFormatting,
|
|
2398
2418
|
paragraphMarkFormatting,
|
|
2399
|
-
paragraphMarkPrecedesStyle,
|
|
2400
2419
|
styleResolver
|
|
2401
2420
|
};
|
|
2402
2421
|
const nonLinkMarks = node.marks.filter((mark) => mark.type.name !== "hyperlink");
|
|
@@ -2415,7 +2434,6 @@ function addNodeToHyperlink({ baseParagraphFormatting, hyperlink, inheritedForma
|
|
|
2415
2434
|
baseParagraphFormatting,
|
|
2416
2435
|
inheritedFormatting,
|
|
2417
2436
|
paragraphMarkFormatting,
|
|
2418
|
-
paragraphMarkPrecedesStyle,
|
|
2419
2437
|
styleResolver
|
|
2420
2438
|
}));
|
|
2421
2439
|
return;
|
|
@@ -2426,7 +2444,6 @@ function addNodeToHyperlink({ baseParagraphFormatting, hyperlink, inheritedForma
|
|
|
2426
2444
|
inheritedFormatting,
|
|
2427
2445
|
marks: nonLinkMarks,
|
|
2428
2446
|
paragraphMarkFormatting,
|
|
2429
|
-
paragraphMarkPrecedesStyle,
|
|
2430
2447
|
styleResolver,
|
|
2431
2448
|
text: node.text
|
|
2432
2449
|
});
|
|
@@ -2446,7 +2463,6 @@ function addNodeToHyperlink({ baseParagraphFormatting, hyperlink, inheritedForma
|
|
|
2446
2463
|
baseParagraphFormatting,
|
|
2447
2464
|
inheritedFormatting,
|
|
2448
2465
|
paragraphMarkFormatting,
|
|
2449
|
-
paragraphMarkPrecedesStyle,
|
|
2450
2466
|
styleResolver
|
|
2451
2467
|
}));
|
|
2452
2468
|
return;
|
|
@@ -2456,7 +2472,6 @@ function addNodeToHyperlink({ baseParagraphFormatting, hyperlink, inheritedForma
|
|
|
2456
2472
|
baseParagraphFormatting,
|
|
2457
2473
|
inheritedFormatting,
|
|
2458
2474
|
paragraphMarkFormatting,
|
|
2459
|
-
paragraphMarkPrecedesStyle,
|
|
2460
2475
|
styleResolver
|
|
2461
2476
|
}));
|
|
2462
2477
|
return;
|
|
@@ -2466,7 +2481,6 @@ function addNodeToHyperlink({ baseParagraphFormatting, hyperlink, inheritedForma
|
|
|
2466
2481
|
baseParagraphFormatting,
|
|
2467
2482
|
inheritedFormatting,
|
|
2468
2483
|
paragraphMarkFormatting,
|
|
2469
|
-
paragraphMarkPrecedesStyle,
|
|
2470
2484
|
styleResolver
|
|
2471
2485
|
}));
|
|
2472
2486
|
return;
|
|
@@ -2485,7 +2499,6 @@ function addNodeToHyperlink({ baseParagraphFormatting, hyperlink, inheritedForma
|
|
|
2485
2499
|
baseParagraphFormatting,
|
|
2486
2500
|
inheritedFormatting,
|
|
2487
2501
|
paragraphMarkFormatting,
|
|
2488
|
-
paragraphMarkPrecedesStyle,
|
|
2489
2502
|
styleResolver
|
|
2490
2503
|
}));
|
|
2491
2504
|
return;
|
|
@@ -2543,12 +2556,11 @@ function textLeafRunContent(text, marks) {
|
|
|
2543
2556
|
function isTextLeafContent(content) {
|
|
2544
2557
|
return content.type === "text" || content.type === "softHyphen" || content.type === "noBreakHyphen";
|
|
2545
2558
|
}
|
|
2546
|
-
function createRunFromText({ baseParagraphFormatting, inheritedFormatting, marks, paragraphMarkFormatting,
|
|
2559
|
+
function createRunFromText({ baseParagraphFormatting, inheritedFormatting, marks, paragraphMarkFormatting, styleResolver, text }) {
|
|
2547
2560
|
const formatting = getRunFormattingFromMarks(marks, {
|
|
2548
2561
|
baseParagraphFormatting,
|
|
2549
2562
|
inheritedFormatting,
|
|
2550
2563
|
paragraphMarkFormatting,
|
|
2551
|
-
paragraphMarkPrecedesStyle,
|
|
2552
2564
|
styleResolver
|
|
2553
2565
|
});
|
|
2554
2566
|
const run = {
|
|
@@ -2732,7 +2744,7 @@ function appendRunToHyperlink(hyperlink, run, node, sourceRunOwners) {
|
|
|
2732
2744
|
hyperlink.children.push(run);
|
|
2733
2745
|
rememberSourceRunOwner(run, node, sourceRunOwners);
|
|
2734
2746
|
}
|
|
2735
|
-
function createPageBreakCarrierRun({ baseParagraphFormatting, clear, inheritedFormatting, marks, paragraphMarkFormatting,
|
|
2747
|
+
function createPageBreakCarrierRun({ baseParagraphFormatting, clear, inheritedFormatting, marks, paragraphMarkFormatting, styleResolver }) {
|
|
2736
2748
|
const run = {
|
|
2737
2749
|
type: "run",
|
|
2738
2750
|
content: [{
|
|
@@ -2745,7 +2757,6 @@ function createPageBreakCarrierRun({ baseParagraphFormatting, clear, inheritedFo
|
|
|
2745
2757
|
baseParagraphFormatting,
|
|
2746
2758
|
inheritedFormatting,
|
|
2747
2759
|
paragraphMarkFormatting,
|
|
2748
|
-
paragraphMarkPrecedesStyle,
|
|
2749
2760
|
styleResolver
|
|
2750
2761
|
});
|
|
2751
2762
|
if (formatting) run.formatting = formatting;
|
|
@@ -2815,20 +2826,18 @@ const withoutTheFieldsOwnMarks = (node) => {
|
|
|
2815
2826
|
});
|
|
2816
2827
|
return recreateProseNodeWithParagraphPropertySource(node, { content: Fragment.fromArray(children) });
|
|
2817
2828
|
};
|
|
2818
|
-
function createFieldFromNode(node, { baseParagraphFormatting, inheritedFormatting, marks, paragraphMarkFormatting,
|
|
2829
|
+
function createFieldFromNode(node, { baseParagraphFormatting, inheritedFormatting, marks, paragraphMarkFormatting, styleResolver, textBoxAnchorMarkers }) {
|
|
2819
2830
|
const attrs = expectFieldAttrs(node);
|
|
2820
2831
|
const formatting = marks && marks.length > 0 ? marksToTextFormatting(marks, {
|
|
2821
2832
|
baseParagraphFormatting,
|
|
2822
2833
|
inheritedFormatting,
|
|
2823
2834
|
paragraphMarkFormatting,
|
|
2824
|
-
paragraphMarkPrecedesStyle,
|
|
2825
2835
|
styleResolver
|
|
2826
2836
|
}) : void 0;
|
|
2827
2837
|
const fieldFormattingContext = {
|
|
2828
2838
|
baseParagraphFormatting,
|
|
2829
2839
|
inheritedFormatting,
|
|
2830
2840
|
paragraphMarkFormatting,
|
|
2831
|
-
paragraphMarkPrecedesStyle: paragraphMarkPrecedesStyle ?? false,
|
|
2832
2841
|
styleResolver: styleResolver ?? null
|
|
2833
2842
|
};
|
|
2834
2843
|
const extractedContent = extractParagraphContent(withoutTheFieldsOwnMarks(node), void 0, void 0, textBoxAnchorMarkers, false, fieldFormattingContext).filter(isSimpleFieldContent);
|
|
@@ -3638,6 +3647,9 @@ function convertPMTableCell(node, documentCounts, styleResolver = null) {
|
|
|
3638
3647
|
} else if (contentNode.type.name === "blockMoveRangeBoundary") {
|
|
3639
3648
|
content.push({ ...expectMoveRangeBoundaryAttrs(contentNode) });
|
|
3640
3649
|
previousStandaloneTextBox = null;
|
|
3650
|
+
} else if (contentNode.type.name === "blockCommentRangeBoundary") {
|
|
3651
|
+
content.push({ ...expectCommentRangeBoundaryAttrs(contentNode).marker });
|
|
3652
|
+
previousStandaloneTextBox = null;
|
|
3641
3653
|
}
|
|
3642
3654
|
});
|
|
3643
3655
|
removeUnresolvedTextBoxAnchors(content, textBoxAnchorMarkers);
|
|
@@ -3676,6 +3688,8 @@ function convertPMTableCell(node, documentCounts, styleResolver = null) {
|
|
|
3676
3688
|
return cell;
|
|
3677
3689
|
}
|
|
3678
3690
|
const standaloneTableCellFromProseMirror = (node) => convertPMTableCell(node);
|
|
3691
|
+
/** A table node's rows as the save writes them, vertical merges included. */
|
|
3692
|
+
const standaloneTableRowsFromProseMirror = (node) => convertPMTableRows(node);
|
|
3679
3693
|
const cellShadingFromAttrs = (attrs) => attrs.backgroundColor ? { fill: { rgb: attrs.backgroundColor } } : { pattern: "nil" };
|
|
3680
3694
|
function tableCellAttrsToFormatting(attrs) {
|
|
3681
3695
|
const backgroundChanged = attrs.backgroundColor !== attrs._resolvedBackgroundColor;
|
|
@@ -3700,16 +3714,21 @@ function tableCellAttrsToFormatting(attrs) {
|
|
|
3700
3714
|
if (attrs.textDirection) result.textDirection = attrs.textDirection;
|
|
3701
3715
|
else delete result.textDirection;
|
|
3702
3716
|
}
|
|
3717
|
+
if (attrs.noWrap !== (orig.noWrap ?? void 0)) {
|
|
3718
|
+
if (attrs.noWrap === true) result.noWrap = true;
|
|
3719
|
+
else delete result.noWrap;
|
|
3720
|
+
}
|
|
3703
3721
|
return Object.keys(result).length > 0 ? result : void 0;
|
|
3704
3722
|
}
|
|
3705
3723
|
const authoredWidth = attrs._authoredWidth;
|
|
3706
|
-
if (!(attrs.colspan > 1 || attrs.rowspan > 1 || authoredWidth !== void 0 || attrs.verticalAlign || backgroundChanged || attrs.borders || attrs.margins || attrs.textDirection)) return;
|
|
3724
|
+
if (!(attrs.colspan > 1 || attrs.rowspan > 1 || authoredWidth !== void 0 || attrs.verticalAlign || backgroundChanged || attrs.borders || attrs.margins || attrs.textDirection || attrs.noWrap === true)) return;
|
|
3707
3725
|
const f = {};
|
|
3708
3726
|
if (attrs.colspan > 1) f.gridSpan = attrs.colspan;
|
|
3709
3727
|
if (attrs.rowspan > 1) f.vMerge = "restart";
|
|
3710
3728
|
if (authoredWidth) f.width = authoredWidth;
|
|
3711
3729
|
if (attrs.verticalAlign) f.verticalAlign = attrs.verticalAlign;
|
|
3712
3730
|
if (attrs.textDirection) f.textDirection = attrs.textDirection;
|
|
3731
|
+
if (attrs.noWrap === true) f.noWrap = true;
|
|
3713
3732
|
if (backgroundChanged) f.shading = cellShadingFromAttrs(attrs);
|
|
3714
3733
|
if (attrs.borders) f.borders = attrs.borders;
|
|
3715
3734
|
if (attrs.margins) f.margins = buildCellMarginsFromAttrs(attrs.margins);
|
|
@@ -3743,8 +3762,33 @@ function convertPMTextBox(node, styleResolver = null) {
|
|
|
3743
3762
|
const verticalAlign = normalizeShapeTextAnchor(attrs.verticalAlign);
|
|
3744
3763
|
const childBlocks = [];
|
|
3745
3764
|
node.forEach((child) => {
|
|
3746
|
-
|
|
3747
|
-
|
|
3765
|
+
switch (child.type.name) {
|
|
3766
|
+
case "paragraph":
|
|
3767
|
+
childBlocks.push(convertPMParagraph(child, void 0, void 0, styleResolver));
|
|
3768
|
+
break;
|
|
3769
|
+
case "table":
|
|
3770
|
+
childBlocks.push(convertPMTable(child, void 0, styleResolver));
|
|
3771
|
+
break;
|
|
3772
|
+
case "blockSdt":
|
|
3773
|
+
childBlocks.push(convertPMBlockSdt(child, styleResolver));
|
|
3774
|
+
break;
|
|
3775
|
+
case "blockCustomXml":
|
|
3776
|
+
childBlocks.push(convertPMBlockCustomXml(child, styleResolver));
|
|
3777
|
+
break;
|
|
3778
|
+
case "preservedBlock":
|
|
3779
|
+
childBlocks.push({
|
|
3780
|
+
type: "preservedBlock",
|
|
3781
|
+
xml: expectPreservedBlockAttrs(child).xml
|
|
3782
|
+
});
|
|
3783
|
+
break;
|
|
3784
|
+
case "blockBookmarkBoundary":
|
|
3785
|
+
childBlocks.push(blockBookmarkMarker(child));
|
|
3786
|
+
break;
|
|
3787
|
+
case "blockMoveRangeBoundary":
|
|
3788
|
+
childBlocks.push({ ...expectMoveRangeBoundaryAttrs(child) });
|
|
3789
|
+
break;
|
|
3790
|
+
case "blockCommentRangeBoundary": childBlocks.push({ ...expectCommentRangeBoundaryAttrs(child).marker });
|
|
3791
|
+
}
|
|
3748
3792
|
});
|
|
3749
3793
|
const textBodyContent = projectTextBoxBodyContent(attrs._docxTextBodyContentState, childBlocks);
|
|
3750
3794
|
const margins = {};
|
|
@@ -3854,9 +3898,10 @@ function updateDocumentContent(originalDocument, pmDoc) {
|
|
|
3854
3898
|
function proseDocToBlocks(pmDoc, baseContent, styles) {
|
|
3855
3899
|
const blocks = extractBlocks(pmDoc, "resolve", styles ? createStyleEngine(styles) : null);
|
|
3856
3900
|
joinCommentRangesAcrossParagraphs(blocks);
|
|
3901
|
+
joinBookmarkRangesAcrossParagraphs(blocks);
|
|
3857
3902
|
completeCommentReferences(blocks);
|
|
3858
3903
|
const linkedSources = restoreLinkedParagraphPropertySources(blocks);
|
|
3859
3904
|
if (baseContent) restoreParagraphPropertySources(blocks, baseContent, linkedSources.targets, linkedSources.sources);
|
|
3860
3905
|
return blocks;
|
|
3861
3906
|
}
|
|
3862
|
-
export { fromProseDoc, marksToTextFormatting, proseDocToBlocks, standaloneTableCellFromProseMirror, tableAttrsToFormatting, tableCellAttrsToFormatting, tableRowAttrsToFormatting, updateDocumentContent };
|
|
3907
|
+
export { fromProseDoc, marksToTextFormatting, proseDocToBlocks, standaloneTableCellFromProseMirror, standaloneTableRowsFromProseMirror, tableAttrsToFormatting, tableCellAttrsToFormatting, tableRowAttrsToFormatting, updateDocumentContent };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FromProseDocOptions, ProjectionReuse, fromProseDoc, proseDocToBlocks, updateDocumentContent } from "./fromProseDoc.js";
|
|
2
1
|
import { ToProseDocOptions, createEmptyDoc, headerFooterToProseDoc, toProseDoc } from "./toProseDoc.js";
|
|
2
|
+
import { FromProseDocOptions, ProjectionReuse, fromProseDoc, proseDocToBlocks, updateDocumentContent } from "./fromProseDoc.js";
|
|
3
3
|
import { ProseMirrorDocumentValidationIssue, ValidateProseMirrorDocumentResult, assertValidProseMirrorDocument, formatProseMirrorDocumentIssues, validateProseMirrorDocument } from "../validation.js";
|
|
4
4
|
export { type FromProseDocOptions, type ProjectionReuse, type ProseMirrorDocumentValidationIssue, type ToProseDocOptions, type ValidateProseMirrorDocumentResult, assertValidProseMirrorDocument, createEmptyDoc, formatProseMirrorDocumentIssues, fromProseDoc, headerFooterToProseDoc, proseDocToBlocks, toProseDoc, updateDocumentContent, validateProseMirrorDocument };
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { document_d_exports } from "../../types/document.js";
|
|
2
2
|
import { TextBoxAttrs } from "../schema/nodes.js";
|
|
3
|
+
import { NumberingMap } from "../../docx/numberingParser.js";
|
|
4
|
+
import { StyleEngine } from "../../style-engine/styleEngine.js";
|
|
5
|
+
import "../../style-engine/index.js";
|
|
6
|
+
import { ListRenderingDefinition } from "../../docx/listRendering.js";
|
|
3
7
|
import { ParseContext } from "../../docx/parseContext.js";
|
|
8
|
+
import { PageBreakRunSourceDescendantIndex } from "../../internal/pageBreakRunSourceDescendantIndex.js";
|
|
9
|
+
import { MarkFactory } from "../extensions/marks/markUtils.js";
|
|
4
10
|
import { Node } from "prosemirror-model";
|
|
5
11
|
/**
|
|
6
12
|
* Options for document conversion
|
|
@@ -17,13 +23,101 @@ export type ToProseDocOptions = {
|
|
|
17
23
|
* already use. Absent means nobody is listening, not that nothing happened.
|
|
18
24
|
*/
|
|
19
25
|
warn?: ParseContext["warn"];
|
|
26
|
+
/**
|
|
27
|
+
* Blocks converted by earlier projections of the same story, reused where
|
|
28
|
+
* nothing a block's conversion read has changed. See
|
|
29
|
+
* {@link createProjectionBlockCache}.
|
|
30
|
+
*/
|
|
31
|
+
blockCache?: ProjectionBlockCache;
|
|
32
|
+
/**
|
|
33
|
+
* The salt of minted text-box anchor ids. Each conversion draws its own;
|
|
34
|
+
* a block cache keeps one for every projection it serves, and a caller
|
|
35
|
+
* comparing a cached projection with a fresh one gives the fresh one the
|
|
36
|
+
* cache's salt.
|
|
37
|
+
*/
|
|
38
|
+
textBoxGroupSalt?: string;
|
|
20
39
|
};
|
|
40
|
+
/** Records that a page break is projected less than exactly. */
|
|
41
|
+
type PageBreakProjectionWarn = (detail: string) => void;
|
|
42
|
+
type HyperlinkInstanceIndexAllocator = () => number;
|
|
21
43
|
/**
|
|
22
44
|
* Find bookmark pairs across every editable inline wrapper in a document story.
|
|
23
45
|
* Each endpoint is converted at its own structural position, so a range may
|
|
24
46
|
* start outside a hyperlink and end inside it (or the inverse).
|
|
25
47
|
*/
|
|
26
48
|
export declare const collectPairedBookmarkIds: (blocks: readonly document_d_exports.BlockContent[]) => ReadonlySet<number>;
|
|
49
|
+
/**
|
|
50
|
+
* What each field of the conversion context depends on: the package alone,
|
|
51
|
+
* or the story before the block being converted. A block's conversion reads
|
|
52
|
+
* the package fields freely; it reads the story fields only through a
|
|
53
|
+
* recorder, so a converted block is reused only where every story fact it
|
|
54
|
+
* read still holds. Total over the context: a field added to it does not
|
|
55
|
+
* compile until it is placed in one half or the other.
|
|
56
|
+
*/
|
|
57
|
+
declare const CONVERSION_CONTEXT_DEPENDENCY: {
|
|
58
|
+
readonly listRenderings: "package";
|
|
59
|
+
readonly numbering: "package";
|
|
60
|
+
readonly theme: "package";
|
|
61
|
+
readonly pageBreakRunSourceDescendants: "package";
|
|
62
|
+
readonly warnPageBreakProjection: "package";
|
|
63
|
+
readonly createMark: "package";
|
|
64
|
+
readonly nextTextBoxGroupId: "story";
|
|
65
|
+
readonly nextHyperlinkInstanceIndex: "story";
|
|
66
|
+
readonly nextNoteReferenceOccurrenceId: "story";
|
|
67
|
+
readonly pairedBookmarkIds: "story";
|
|
68
|
+
readonly storyRangedCommentIds: "story";
|
|
69
|
+
readonly openCommentIds: "story";
|
|
70
|
+
};
|
|
71
|
+
type ContextDependency = typeof CONVERSION_CONTEXT_DEPENDENCY;
|
|
72
|
+
type PackageContextField = { [K in keyof ContextDependency]: ContextDependency[K] extends "package" ? K : never; }[keyof ContextDependency];
|
|
73
|
+
/** The conversion context a block may read without recording. */
|
|
74
|
+
type PackageConversionContext = Pick<TableConversionContext, PackageContextField>;
|
|
75
|
+
/** Whether a story holds an id: all a block's conversion asks of a story id set. */
|
|
76
|
+
type IdMembership = Pick<ReadonlySet<number>, "has">;
|
|
77
|
+
/** One story counter, as the conversion advances it. */
|
|
78
|
+
type StoryCounter = {
|
|
79
|
+
value: number;
|
|
80
|
+
};
|
|
81
|
+
/** The story state a block conversion starts from and advances. */
|
|
82
|
+
type StoryState = {
|
|
83
|
+
textBoxGroups: StoryCounter;
|
|
84
|
+
hyperlinks: StoryCounter;
|
|
85
|
+
noteOccurrences: StoryCounter;
|
|
86
|
+
pairedBookmarkIds: IdMembership;
|
|
87
|
+
storyRangedCommentIds: IdMembership;
|
|
88
|
+
openCommentIds: Set<number>;
|
|
89
|
+
};
|
|
90
|
+
type ProjectionPackageInputs = {
|
|
91
|
+
styles: document_d_exports.StyleDefinitions | undefined;
|
|
92
|
+
theme: document_d_exports.Theme | null;
|
|
93
|
+
numbering: document_d_exports.NumberingDefinitions | undefined;
|
|
94
|
+
warn: ParseContext["warn"] | undefined;
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* Converted blocks kept across projections of one story.
|
|
98
|
+
*
|
|
99
|
+
* A block is the same object in the next document when an edit left it, so
|
|
100
|
+
* its nodes can be reused where the story facts its conversion read are the
|
|
101
|
+
* same: the counters it drew from, the comments open at its start, and the
|
|
102
|
+
* bookmark and comment ids it asked about. The package inputs (styles,
|
|
103
|
+
* theme, numbering) are part of the cache: a projection over other ones
|
|
104
|
+
* starts the cache over.
|
|
105
|
+
*/
|
|
106
|
+
export declare class ProjectionBlockCache {
|
|
107
|
+
readonly salt: string;
|
|
108
|
+
private inputs;
|
|
109
|
+
private context;
|
|
110
|
+
private blocks;
|
|
111
|
+
/** The package context for these inputs, the cache started over if they changed. */
|
|
112
|
+
packageContext(inputs: ProjectionPackageInputs): PackageConversionContext & {
|
|
113
|
+
styleResolver: StyleEngine;
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* The nodes of `paragraph` from the story state it starts at, reused when
|
|
117
|
+
* every story fact its last conversion read still holds, else converted.
|
|
118
|
+
*/
|
|
119
|
+
paragraph(paragraph: document_d_exports.Paragraph, state: StoryState, convert: (context: TableConversionContext, groupId: string) => Node[]): readonly Node[];
|
|
120
|
+
}
|
|
27
121
|
/**
|
|
28
122
|
* Convert a Document to a ProseMirror document
|
|
29
123
|
*
|
|
@@ -31,6 +125,38 @@ export declare const collectPairedBookmarkIds: (blocks: readonly document_d_expo
|
|
|
31
125
|
* @param options - Conversion options including style definitions
|
|
32
126
|
*/
|
|
33
127
|
export declare function toProseDoc(document: document_d_exports.Document, options?: ToProseDocOptions): Node;
|
|
128
|
+
type ResolvedListRendering = ListRenderingDefinition;
|
|
129
|
+
/**
|
|
130
|
+
* Convert a Table to a ProseMirror table node
|
|
131
|
+
*
|
|
132
|
+
* Handles column widths from w:tblGrid - if cell widths aren't specified,
|
|
133
|
+
* we use the grid column widths to set cell widths. This ensures tables
|
|
134
|
+
* preserve their layout when opened from DOCX files.
|
|
135
|
+
*/
|
|
136
|
+
type TableConversionContext = {
|
|
137
|
+
listRenderings: Map<string, ResolvedListRendering>;
|
|
138
|
+
numbering: NumberingMap | undefined;
|
|
139
|
+
theme: document_d_exports.Theme | null | undefined;
|
|
140
|
+
nextTextBoxGroupId: () => string;
|
|
141
|
+
nextHyperlinkInstanceIndex: HyperlinkInstanceIndexAllocator;
|
|
142
|
+
nextNoteReferenceOccurrenceId: () => string;
|
|
143
|
+
pairedBookmarkIds: IdMembership;
|
|
144
|
+
pageBreakRunSourceDescendants: PageBreakRunSourceDescendantIndex;
|
|
145
|
+
/** Comments the story opens a range for, for the point-comment question. */
|
|
146
|
+
storyRangedCommentIds: IdMembership;
|
|
147
|
+
warnPageBreakProjection: PageBreakProjectionWarn;
|
|
148
|
+
/** Shares one mark instance per distinct run formatting across the conversion. */
|
|
149
|
+
createMark: MarkFactory;
|
|
150
|
+
/**
|
|
151
|
+
* Comment ranges open at the walk's current position. A range is a story
|
|
152
|
+
* fact, not a paragraph one: it opens in one paragraph and closes in another,
|
|
153
|
+
* and every inline node between the two carries its mark. The walk visits the
|
|
154
|
+
* story in document order, so the set the block walker carries is exactly the
|
|
155
|
+
* set of ranges covering the node it is converting — the same way
|
|
156
|
+
* `pairedBookmarkIds` answers for a boundary whose partner is elsewhere.
|
|
157
|
+
*/
|
|
158
|
+
openCommentIds: Set<number>;
|
|
159
|
+
};
|
|
34
160
|
export declare function standaloneTableCellToProseMirror(cell: document_d_exports.TableCell, nodeType: "tableCell" | "tableHeader"): Node;
|
|
35
161
|
/**
|
|
36
162
|
* The host paragraph's attributes without its identity. The node may be
|
|
@@ -50,4 +176,5 @@ export declare function footnoteToProseDoc(content: document_d_exports.BlockCont
|
|
|
50
176
|
/**
|
|
51
177
|
* Create an empty ProseMirror document
|
|
52
178
|
*/
|
|
53
|
-
export declare function createEmptyDoc(): Node;
|
|
179
|
+
export declare function createEmptyDoc(): Node;
|
|
180
|
+
export {};
|