@stll/folio-core 0.43.0 → 0.45.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/__fixtures__/paragraphs.js +2 -2
- package/dist/ai-edits/headless.js +7 -5
- package/dist/ai-edits/index.d.ts +2 -2
- package/dist/ai-edits/index.js +2 -2
- package/dist/ai-edits/snapshot.js +13 -9
- package/dist/compare/content-alignment.js +94 -54
- package/dist/compare/inline-atoms.js +34 -20
- package/dist/compare/style-resources.js +6 -0
- package/dist/content-controls/mutateContentControls.js +4 -2
- package/dist/display-list/dom/renderDisplayListToDom.js +8 -8
- package/dist/document-operations.js +14 -3
- package/dist/docx/appVersionNormalization.d.ts +0 -18
- package/dist/docx/blockContentParser.js +8 -0
- package/dist/docx/blockRangeMarkers.d.ts +36 -0
- package/dist/docx/blockRangeMarkers.js +59 -0
- package/dist/docx/bookmarkParser.d.ts +2 -20
- package/dist/docx/bookmarkParser.js +6 -30
- package/dist/docx/borderParser.d.ts +13 -0
- package/dist/docx/borderParser.js +71 -0
- package/dist/docx/builtInStyles.d.ts +165 -0
- package/dist/docx/builtInStyles.js +239 -0
- package/dist/docx/commentIdNormalization.d.ts +3 -1
- package/dist/docx/commentIdNormalization.js +18 -1
- package/dist/docx/commentParser.d.ts +2 -1
- package/dist/docx/commentParser.js +80 -42
- package/dist/docx/commentReferenceNormalization.d.ts +4 -1
- package/dist/docx/commentReferenceNormalization.js +23 -14
- package/dist/docx/commentThreadKey.d.ts +18 -0
- package/dist/docx/commentThreadKey.js +22 -0
- package/dist/docx/danglingRelationshipReferences.d.ts +15 -0
- package/dist/docx/danglingRelationshipReferences.js +30 -0
- package/dist/docx/defaultParagraphStyle.d.ts +18 -1
- package/dist/docx/defaultParagraphStyle.js +23 -1
- package/dist/docx/diagramPreview.js +87 -27
- package/dist/docx/documentParser.d.ts +2 -1
- package/dist/docx/documentParser.js +2 -2
- package/dist/docx/drawingUtils.d.ts +8 -1
- package/dist/docx/drawingUtils.js +12 -3
- package/dist/docx/fieldParser.js +3 -5
- package/dist/docx/footnoteParser.d.ts +3 -2
- package/dist/docx/footnoteParser.js +19 -4
- package/dist/docx/groupDrawingParser.js +4 -4
- package/dist/docx/headerFooterRefParser.d.ts +4 -3
- package/dist/docx/headerFooterRefParser.js +42 -12
- package/dist/docx/headerFooterReferenceNormalization.d.ts +4 -1
- package/dist/docx/headerFooterReferenceNormalization.js +5 -1
- package/dist/docx/hyperlinkParser.js +13 -17
- package/dist/docx/imageParser.d.ts +10 -2
- package/dist/docx/imageParser.js +80 -30
- package/dist/docx/imageRawXml.d.ts +14 -1
- package/dist/docx/imageRawXml.js +35 -11
- package/dist/docx/markupRangeMarker.d.ts +15 -0
- package/dist/docx/markupRangeMarker.js +44 -0
- package/dist/docx/mathToMathml.js +12 -14
- package/dist/docx/nonVisualDrawingProps.d.ts +34 -0
- package/dist/docx/nonVisualDrawingProps.js +46 -0
- package/dist/docx/noteReferenceStyles.d.ts +29 -0
- package/dist/docx/noteReferenceStyles.js +70 -0
- package/dist/docx/numberingReferenceNormalization.d.ts +4 -1
- package/dist/docx/numberingReferenceNormalization.js +20 -1
- package/dist/docx/paraIdRangeNormalization.d.ts +0 -19
- package/dist/docx/paragraphParser.js +66 -99
- package/dist/docx/paragraphPropertySource.js +1 -0
- package/dist/docx/paragraphTextBoxEnrichment.js +3 -0
- package/dist/docx/paragraphTraversal.d.ts +37 -1
- package/dist/docx/paragraphTraversal.js +84 -1
- package/dist/docx/parseContext.d.ts +37 -0
- package/dist/docx/parseContext.js +67 -0
- package/dist/docx/parseWarningMessage.d.ts +6 -0
- package/dist/docx/parseWarningMessage.js +44 -0
- package/dist/docx/parser.js +83 -29
- package/dist/docx/previewBudget.d.ts +64 -0
- package/dist/docx/previewBudget.js +88 -0
- package/dist/docx/relsParser.d.ts +28 -11
- package/dist/docx/relsParser.js +26 -13
- package/dist/docx/revisionIdNormalization.js +96 -10
- package/dist/docx/rezip.js +80 -40
- package/dist/docx/runConsolidator.js +1 -2
- package/dist/docx/runParser.d.ts +8 -1
- package/dist/docx/runParser.js +30 -48
- package/dist/docx/sdtPropertiesPatch.js +24 -18
- package/dist/docx/sectionParser.d.ts +2 -1
- package/dist/docx/sectionParser.js +21 -65
- package/dist/docx/sectionReferenceHistory.js +2 -2
- package/dist/docx/selectiveSave.js +6 -6
- package/dist/docx/serializer/blockSdtSerializer.js +38 -26
- package/dist/docx/serializer/borderSerializer.d.ts +2 -3
- package/dist/docx/serializer/borderSerializer.js +13 -12
- package/dist/docx/serializer/commentSerializer.d.ts +41 -16
- package/dist/docx/serializer/commentSerializer.js +82 -72
- package/dist/docx/serializer/documentSerializer.d.ts +1 -5
- package/dist/docx/serializer/documentSerializer.js +6 -16
- package/dist/docx/serializer/fontTableSerializer.js +6 -6
- package/dist/docx/serializer/headerFooterSerializer.js +10 -5
- package/dist/docx/serializer/markupRangeAttributes.d.ts +8 -0
- package/dist/docx/serializer/markupRangeAttributes.js +24 -0
- package/dist/docx/serializer/noteSerializer.js +5 -0
- package/dist/docx/serializer/numberingSerializer.js +7 -6
- package/dist/docx/serializer/paragraphSerializer.d.ts +1 -5
- package/dist/docx/serializer/paragraphSerializer.js +47 -52
- package/dist/docx/serializer/partNamespaces.js +2 -2
- package/dist/docx/serializer/runSerializer.js +57 -31
- package/dist/docx/serializer/sectionPropertiesSerializer.js +11 -10
- package/dist/docx/serializer/settingsSerializer.js +4 -3
- package/dist/docx/serializer/stylesSerializer.js +6 -6
- package/dist/docx/serializer/tableSerializer.js +37 -21
- package/dist/docx/serializer/textFormattingSerializer.d.ts +2 -3
- package/dist/docx/serializer/textFormattingSerializer.js +29 -28
- package/dist/docx/serializer/themeSerializer.js +6 -6
- package/dist/docx/serializer/trackedChangeAttributes.js +2 -2
- package/dist/docx/serializer/xmlUtils.d.ts +1 -2
- package/dist/docx/serializer/xmlUtils.js +1 -13
- package/dist/docx/server/boundedArchive.d.ts +12 -0
- package/dist/docx/server/boundedArchive.js +20 -1
- package/dist/docx/server/build.js +8 -1
- package/dist/docx/server/createBilingualDocument.js +10 -18
- package/dist/docx/server/extractDocxText.js +3 -4
- package/dist/docx/server/validateDocxConformance.js +22 -1
- package/dist/docx/shadingParser.d.ts +6 -0
- package/dist/docx/shadingParser.js +32 -0
- package/dist/docx/shapeParser.js +10 -8
- package/dist/docx/styleParser.js +13 -87
- package/dist/docx/styleReferenceResolution.d.ts +36 -0
- package/dist/docx/styleReferenceResolution.js +51 -0
- package/dist/docx/tableLook.d.ts +57 -0
- package/dist/docx/tableLook.js +63 -0
- package/dist/docx/tableParser.d.ts +7 -9
- package/dist/docx/tableParser.js +64 -110
- package/dist/docx/textBoxParser.js +11 -6
- package/dist/docx/trackedMoveRangeNormalization.d.ts +3 -1
- package/dist/docx/trackedMoveRangeNormalization.js +11 -21
- package/dist/docx/transitionalSpelling.d.ts +13 -2
- package/dist/docx/transitionalSpelling.js +23 -1
- package/dist/docx/unzip.d.ts +23 -0
- package/dist/docx/unzip.js +32 -22
- package/dist/docx/verbatimCapture.js +5 -12
- package/dist/docx/vmlImageParser.js +5 -4
- package/dist/docx/vmlPreview.d.ts +1 -3
- package/dist/docx/vmlPreview.js +2 -30
- package/dist/docx/watermarkParser.js +2 -2
- package/dist/docx/xmlParser.d.ts +38 -33
- package/dist/docx/xmlParser.js +92 -47
- package/dist/docx/xmlResourceLimits.d.ts +89 -9
- package/dist/docx/xmlResourceLimits.js +105 -24
- package/dist/internal/pageBreakRunSourceDescendantIndex.js +2 -1
- package/dist/internal/paragraphFormattingSerialization.d.ts +2 -3
- package/dist/internal/paragraphFormattingSerialization.js +29 -8
- package/dist/layout-bridge/convert/footnoteLayout.js +2 -7
- package/dist/layout-engine/index.d.ts +2 -2
- package/dist/layout-engine/index.js +2 -2
- package/dist/layout-engine/measure/measureBlocks.js +1 -6
- package/dist/layout-engine/types.d.ts +8 -2
- package/dist/layout-engine/types.js +35 -2
- package/dist/layout-painter/renderImage.js +4 -3
- package/dist/layout-painter/renderParagraph.js +4 -3
- package/dist/managers/autoSaveCodec.js +2 -8
- package/dist/markdown/images.js +1 -4
- package/dist/markdown/index.js +1 -1
- package/dist/markdown/internals.d.ts +6 -1
- package/dist/markdown/internals.js +14 -1
- package/dist/markdown/renderBlock.js +35 -21
- package/dist/markdown/renderParagraph.js +14 -5
- package/dist/markdown/renderRuns.js +4 -3
- package/dist/markdown/renderTable.js +4 -3
- package/dist/markdown/trailers.js +41 -7
- package/dist/markdown/types.d.ts +3 -7
- package/dist/prosemirror/attrs/index.js +71 -5
- package/dist/prosemirror/bookmarkBoundaryAttrs.d.ts +11 -1
- package/dist/prosemirror/bookmarkBoundaryAttrs.js +18 -3
- package/dist/prosemirror/commands/image.js +1 -0
- package/dist/prosemirror/commands/index.d.ts +3 -3
- package/dist/prosemirror/commands/index.js +2 -2
- package/dist/prosemirror/commands/paragraph.d.ts +3 -3
- package/dist/prosemirror/commands/paragraph.js +2 -2
- package/dist/prosemirror/commentIdAllocator.js +2 -7
- package/dist/prosemirror/conversion/fromProseDoc.js +197 -68
- package/dist/prosemirror/conversion/toProseDoc.d.ts +1 -14
- package/dist/prosemirror/conversion/toProseDoc.js +458 -335
- package/dist/prosemirror/extensions/core/ParagraphExtension.d.ts +14 -1
- package/dist/prosemirror/extensions/core/ParagraphExtension.js +11 -6
- package/dist/prosemirror/extensions/features/EmptyParagraphFormatExtension.js +3 -3
- package/dist/prosemirror/extensions/features/PasteCleanupExtension.d.ts +4 -1
- package/dist/prosemirror/extensions/features/PasteCleanupExtension.js +6 -2
- package/dist/prosemirror/extensions/features/pastedHeadingStyles.d.ts +7 -0
- package/dist/prosemirror/extensions/features/pastedHeadingStyles.js +74 -0
- package/dist/prosemirror/extensions/marks/HyperlinkExtension.js +2 -3
- package/dist/prosemirror/extensions/marks/markUtils.d.ts +11 -3
- package/dist/prosemirror/extensions/marks/markUtils.js +98 -19
- package/dist/prosemirror/extensions/nodes/BookmarkBoundaryExtension.js +7 -3
- package/dist/prosemirror/extensions/nodes/ImageExtension.js +6 -1
- package/dist/prosemirror/extensions/nodes/ShapeExtension.js +8 -2
- package/dist/prosemirror/extensions/nodes/TableExtension.js +15 -1
- package/dist/prosemirror/extensions/nodes/TextBoxExtension.js +8 -4
- package/dist/prosemirror/extensions/types.d.ts +2 -2
- package/dist/prosemirror/index.d.ts +3 -3
- package/dist/prosemirror/index.js +3 -3
- package/dist/prosemirror/insertOperations.d.ts +9 -2
- package/dist/prosemirror/insertOperations.js +9 -4
- package/dist/prosemirror/paragraphFormattingProvenance.d.ts +162 -0
- package/dist/prosemirror/paragraphFormattingProvenance.js +115 -0
- package/dist/prosemirror/plugins/documentStyles.d.ts +9 -1
- package/dist/prosemirror/plugins/documentStyles.js +11 -1
- package/dist/prosemirror/plugins/index.d.ts +2 -2
- package/dist/prosemirror/plugins/index.js +2 -2
- package/dist/prosemirror/plugins/revisionIds.d.ts +11 -2
- package/dist/prosemirror/plugins/revisionIds.js +21 -6
- package/dist/prosemirror/runFormattingReconciliation.js +3 -2
- package/dist/prosemirror/runStyleFormatting.d.ts +1 -1
- package/dist/prosemirror/schema/nodes.d.ts +81 -1
- package/dist/prosemirror/styles/resolvedStyleAttrs.js +2 -0
- package/dist/prosemirror/styles/styleResolver.d.ts +9 -0
- package/dist/prosemirror/styles/styleResolver.js +12 -0
- package/dist/style-engine/styleEngine.d.ts +3 -0
- package/dist/style-engine/styleEngine.js +3 -0
- package/dist/style-sets/extract.js +1 -23
- package/dist/style-sets/stellaStyle.js +46 -39
- package/dist/style-sets/styleSetNormalization.d.ts +19 -0
- package/dist/style-sets/styleSetNormalization.js +99 -0
- package/dist/types/content.d.ts +2 -2
- package/dist/utils/base64.d.ts +36 -0
- package/dist/utils/base64.js +40 -0
- package/dist/utils/clipboard.js +2 -1
- package/dist/utils/createDocument.js +145 -20
- package/dist/utils/headingCollector.d.ts +8 -5
- package/dist/utils/headingCollector.js +23 -25
- package/dist/utils/tableOfContentsStyle.js +9 -2
- package/dist/utils/units.d.ts +10 -1
- package/dist/utils/units.js +12 -1
- package/dist/utils/urlSecurity.d.ts +8 -2
- package/dist/utils/urlSecurity.js +21 -3
- package/package.json +2 -2
- package/dist/docx/textWhitespace.d.ts +0 -4
- package/dist/docx/textWhitespace.js +0 -4
- package/dist/layout-bridge/engine/tableWidthUtils.d.ts +0 -6
- package/dist/layout-bridge/engine/tableWidthUtils.js +0 -25
- package/dist/markdown/headings.d.ts +0 -13
- package/dist/markdown/headings.js +0 -20
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import { cloneParagraphWithoutPropertySource } from "../docx/paragraphPropertySource.js";
|
|
2
2
|
import { renderParagraph } from "./renderParagraph.js";
|
|
3
3
|
import { renderTable } from "./renderTable.js";
|
|
4
|
+
import { panic } from "better-result";
|
|
4
5
|
//#region src/markdown/renderBlock.ts
|
|
5
6
|
/**
|
|
7
|
+
* Block-level dispatcher. Walks `BlockContent[]` and joins the rendered
|
|
8
|
+
* markdown for each block, suppressing redundant blank lines between list items
|
|
9
|
+
* of the same list. Ported from eigenpal/docx-editor PR #595.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
6
12
|
* In `trackedChanges: "clean"` mode every change is accepted. A paragraph whose
|
|
7
13
|
* end-of-paragraph mark is a pending deletion (`pPrMark.kind === "del"`) loses
|
|
8
14
|
* its break on accept and merges with the following paragraph. Word's join
|
|
@@ -34,30 +40,38 @@ function renderBlocks(ctx, pkg, blocks) {
|
|
|
34
40
|
const out = [];
|
|
35
41
|
let prevWasListItem = false;
|
|
36
42
|
const ordered = ctx.opts.trackedChanges === "clean" ? mergeAcceptedParagraphBreaks(blocks) : blocks;
|
|
37
|
-
for (const block of ordered)
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
+
for (const block of ordered) switch (block.type) {
|
|
44
|
+
case "paragraph": {
|
|
45
|
+
const isListItem = !!block.listRendering && !block.listRendering.markerHidden;
|
|
46
|
+
const md = renderParagraph(ctx, pkg, block);
|
|
47
|
+
if (!md) {
|
|
48
|
+
prevWasListItem = false;
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
if (isListItem && prevWasListItem) out.push(md);
|
|
52
|
+
else if (out.length) out.push("", md);
|
|
53
|
+
else out.push(md);
|
|
54
|
+
prevWasListItem = isListItem;
|
|
55
|
+
break;
|
|
43
56
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
out.push(md);
|
|
57
|
+
case "table": {
|
|
58
|
+
const md = renderTable(ctx, pkg, block);
|
|
59
|
+
if (md) {
|
|
60
|
+
if (out.length) out.push("");
|
|
61
|
+
out.push(md);
|
|
62
|
+
}
|
|
63
|
+
prevWasListItem = false;
|
|
64
|
+
break;
|
|
53
65
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
66
|
+
case "blockSdt": {
|
|
67
|
+
const nested = renderBlocks(ctx, pkg, block.content);
|
|
68
|
+
if (nested) {
|
|
69
|
+
if (out.length) out.push("");
|
|
70
|
+
out.push(nested);
|
|
71
|
+
}
|
|
72
|
+
break;
|
|
60
73
|
}
|
|
74
|
+
default: panic(`Unsupported block content in markdown: ${JSON.stringify(block)}`);
|
|
61
75
|
}
|
|
62
76
|
return out.join("\n");
|
|
63
77
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { isQuoteStyle, resolveHeadingLevel } from "../docx/builtInStyles.js";
|
|
1
2
|
import { resolveListTemplate } from "../prosemirror/listMarker.js";
|
|
2
|
-
import { isHeadingStyle, parseHeadingLevel } from "./headings.js";
|
|
3
3
|
import { renderParagraphInline } from "./renderRuns.js";
|
|
4
4
|
//#region src/markdown/renderParagraph.ts
|
|
5
5
|
/**
|
|
@@ -8,7 +8,13 @@ import { renderParagraphInline } from "./renderRuns.js";
|
|
|
8
8
|
* marker preserved); plain prose → escaped inline content. Word's `Quote` /
|
|
9
9
|
* `IntenseQuote` styles become blockquotes. Ported from eigenpal/docx-editor
|
|
10
10
|
* PR #595.
|
|
11
|
+
*
|
|
12
|
+
* Which paragraphs those are is `builtInStyles`' decision, not this file's: the
|
|
13
|
+
* id `Nadpis1` and the id `Heading1` are the same heading, and `ClauseHeading1`
|
|
14
|
+
* is not one at all.
|
|
11
15
|
*/
|
|
16
|
+
/** Markdown has six heading levels; Word has nine. */
|
|
17
|
+
const MAX_MARKDOWN_HEADING_LEVEL = 6;
|
|
12
18
|
/**
|
|
13
19
|
* Render a paragraph and return the block text. No surrounding blank line: the
|
|
14
20
|
* caller joins blocks.
|
|
@@ -16,13 +22,16 @@ import { renderParagraphInline } from "./renderRuns.js";
|
|
|
16
22
|
function renderParagraph(ctx, pkg, para) {
|
|
17
23
|
const inline = renderParagraphInline(ctx, pkg, para.content, para.paraId);
|
|
18
24
|
const styleId = para.formatting?.styleId;
|
|
19
|
-
|
|
25
|
+
const headingLevel = resolveHeadingLevel({
|
|
26
|
+
outlineLevel: para.formatting?.outlineLevel,
|
|
27
|
+
styleId
|
|
28
|
+
}, ctx.builtInStyles);
|
|
29
|
+
if (headingLevel !== void 0) {
|
|
20
30
|
if (!inline) return "";
|
|
21
|
-
|
|
22
|
-
return `${"#".repeat(Math.max(1, Math.min(6, level)))} ${inline}`;
|
|
31
|
+
return `${"#".repeat(Math.min(MAX_MARKDOWN_HEADING_LEVEL, headingLevel + 1))} ${inline}`;
|
|
23
32
|
}
|
|
24
33
|
if (para.listRendering && !para.listRendering.markerHidden) return renderListItem(ctx, para.listRendering, inline);
|
|
25
|
-
if (styleId
|
|
34
|
+
if (isQuoteStyle(styleId, ctx.builtInStyles)) return inline.split("\n").map((line) => `> ${line}`).join("\n");
|
|
26
35
|
return escapeLeadingBlockMarker(inline);
|
|
27
36
|
}
|
|
28
37
|
/**
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { RELATIONSHIP_TYPES, resolveRelationshipIdOfType } from "../docx/relsParser.js";
|
|
1
2
|
import { decodeOoxmlSymbolCharacter } from "../utils/ooxmlSymbol.js";
|
|
2
3
|
import { wrapComment, wrapDeletion, wrapInsertion, wrapMoveFrom, wrapMoveTo } from "./annotations.js";
|
|
3
4
|
import { escapeAltText, escapeInline, escapeLinkUrl } from "./escape.js";
|
|
@@ -88,8 +89,8 @@ function renderRunContent(ctx, pkg, content, paraId) {
|
|
|
88
89
|
break;
|
|
89
90
|
}
|
|
90
91
|
case "drawing": {
|
|
91
|
-
const ref = pkg?.relationships
|
|
92
|
-
const media = ref ? pkg?.media?.get(ref.target) : void 0;
|
|
92
|
+
const ref = resolveRelationshipIdOfType(pkg?.relationships, item.image.rId, RELATIONSHIP_TYPES.image);
|
|
93
|
+
const media = ref.status === "resolved" ? pkg?.media?.get(ref.relationship.target) : void 0;
|
|
93
94
|
if (media) {
|
|
94
95
|
const reg = registerImage(ctx, media, item.image, paraId);
|
|
95
96
|
const alt = reg.alt ? escapeAltText(reg.alt) : "";
|
|
@@ -101,7 +102,7 @@ function renderRunContent(ctx, pkg, content, paraId) {
|
|
|
101
102
|
out += ``;
|
|
102
103
|
break;
|
|
103
104
|
}
|
|
104
|
-
pushWarning(ctx, `image rId=${item.image.rId} not resolvable`);
|
|
105
|
+
pushWarning(ctx, `image rId=${item.image.rId ?? "(absent)"} not resolvable`);
|
|
105
106
|
break;
|
|
106
107
|
}
|
|
107
108
|
case "shape":
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { RELATIONSHIP_TYPES, resolveRelationshipIdOfType } from "../docx/relsParser.js";
|
|
1
2
|
import { decodeOoxmlSymbolCharacter } from "../utils/ooxmlSymbol.js";
|
|
2
3
|
import { escapeTableCell } from "./escape.js";
|
|
3
4
|
import { registerImage } from "./images.js";
|
|
@@ -185,8 +186,8 @@ function renderHtmlRun(ctx, pkg, run, paraId) {
|
|
|
185
186
|
break;
|
|
186
187
|
case "softHyphen": break;
|
|
187
188
|
case "drawing": {
|
|
188
|
-
const ref = pkg?.relationships
|
|
189
|
-
const media = ref ? pkg?.media?.get(ref.target) : void 0;
|
|
189
|
+
const ref = resolveRelationshipIdOfType(pkg?.relationships, item.image.rId, RELATIONSHIP_TYPES.image);
|
|
190
|
+
const media = ref.status === "resolved" ? pkg?.media?.get(ref.relationship.target) : void 0;
|
|
190
191
|
if (media) {
|
|
191
192
|
const reg = registerImage(ctx, media, item.image, paraId);
|
|
192
193
|
const alt = reg.alt ? escapeHtml(reg.alt) : "";
|
|
@@ -198,7 +199,7 @@ function renderHtmlRun(ctx, pkg, run, paraId) {
|
|
|
198
199
|
text += `<img src="${escapeHtml(item.image.src)}" alt="${alt}">`;
|
|
199
200
|
break;
|
|
200
201
|
}
|
|
201
|
-
pushWarning(ctx, `image rId=${item.image.rId} not resolvable`);
|
|
202
|
+
pushWarning(ctx, `image rId=${item.image.rId ?? "(absent)"} not resolvable`);
|
|
202
203
|
break;
|
|
203
204
|
}
|
|
204
205
|
case "footnoteRef":
|
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
import { escapeLinkUrl } from "./escape.js";
|
|
2
2
|
import { renderBlocks } from "./renderBlock.js";
|
|
3
|
+
import { panic } from "better-result";
|
|
3
4
|
//#region src/markdown/trailers.ts
|
|
4
5
|
/**
|
|
6
|
+
* Trailer sections appended after the document body: footnote definitions, the
|
|
7
|
+
* hyperlink reference list (`hyperlinks: "reference"`), and the comments
|
|
8
|
+
* sidecar (`comments: "sidecar"`). Split out of `internals` so the renderers
|
|
9
|
+
* can import `pushWarning` without pulling in `renderBlock` (which would form an
|
|
10
|
+
* import cycle). Ported from eigenpal/docx-editor PR #595.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
5
13
|
* Append footnote definitions, the hyperlink reference list (for
|
|
6
14
|
* `hyperlinks: "reference"`), and the comments sidecar block (for
|
|
7
15
|
* `comments: "sidecar"`). Each section is emitted only when its corresponding
|
|
@@ -41,13 +49,39 @@ function runText(run) {
|
|
|
41
49
|
/** Flatten paragraph inline content to plain text, recursing through wrappers. */
|
|
42
50
|
function inlineText(content) {
|
|
43
51
|
let out = "";
|
|
44
|
-
for (const item of content)
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
52
|
+
for (const item of content) switch (item.type) {
|
|
53
|
+
case "run":
|
|
54
|
+
out += runText(item);
|
|
55
|
+
break;
|
|
56
|
+
case "hyperlink":
|
|
57
|
+
for (const child of item.children) if (child.type === "run") out += runText(child);
|
|
58
|
+
break;
|
|
59
|
+
case "complexField":
|
|
60
|
+
out += inlineText(item.fieldResult);
|
|
61
|
+
break;
|
|
62
|
+
case "simpleField":
|
|
63
|
+
case "insertion":
|
|
64
|
+
case "deletion":
|
|
65
|
+
case "moveFrom":
|
|
66
|
+
case "moveTo":
|
|
67
|
+
case "inlineSdt":
|
|
68
|
+
case "bidiWrapper":
|
|
69
|
+
out += inlineText(item.content);
|
|
70
|
+
break;
|
|
71
|
+
case "mathEquation":
|
|
72
|
+
out += item.plainText ?? "";
|
|
73
|
+
break;
|
|
74
|
+
case "bookmarkStart":
|
|
75
|
+
case "bookmarkEnd":
|
|
76
|
+
case "commentRangeStart":
|
|
77
|
+
case "commentRangeEnd":
|
|
78
|
+
case "commentReference":
|
|
79
|
+
case "moveFromRangeStart":
|
|
80
|
+
case "moveFromRangeEnd":
|
|
81
|
+
case "moveToRangeStart":
|
|
82
|
+
case "moveToRangeEnd": break;
|
|
83
|
+
default: panic(`Unsupported paragraph content in trailer text: ${JSON.stringify(item)}`);
|
|
84
|
+
}
|
|
51
85
|
return out;
|
|
52
86
|
}
|
|
53
87
|
//#endregion
|
package/dist/markdown/types.d.ts
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
|
+
import { BuiltInStyleIndex } from "../docx/builtInStyles.js";
|
|
1
2
|
//#region src/markdown/types.d.ts
|
|
2
|
-
/**
|
|
3
|
-
* Types for the DOCX-document → Markdown converter (ported from eigenpal
|
|
4
|
-
* /docx-editor PR #595). This is folio's v1 surface: the synchronous,
|
|
5
|
-
* continuous (non-paged) `toMarkdown(Document)` path. The paged + async +
|
|
6
|
-
* image-handler variants from upstream are not ported (skills bodies have no
|
|
7
|
-
* images today); they can be added later if needed.
|
|
8
|
-
*/
|
|
9
3
|
/**
|
|
10
4
|
* Metadata describing a single image registration. Owned by the markdown
|
|
11
5
|
* module so its public surface is independent of the docx model's drawing
|
|
@@ -134,6 +128,8 @@ type RenderContext = {
|
|
|
134
128
|
listCounters: Map<number, number[]>;
|
|
135
129
|
/** `numId:level` pairs already seen, so a start override applies once. */
|
|
136
130
|
listSeenLevels: Set<string>;
|
|
131
|
+
/** The document's styles indexed by the built-in they are; classifies headings and quotes. */
|
|
132
|
+
builtInStyles: BuiltInStyleIndex;
|
|
137
133
|
};
|
|
138
134
|
//#endregion
|
|
139
135
|
export { ImageMeta, ImageRef, MarkdownOptions, MarkdownResult, RenderContext, ResolvedOptions };
|
|
@@ -53,6 +53,11 @@ const SHAPE_OUTLINE_CAPS = [
|
|
|
53
53
|
"round",
|
|
54
54
|
"square"
|
|
55
55
|
];
|
|
56
|
+
const SHAPE_OUTLINE_JOINS = [
|
|
57
|
+
"bevel",
|
|
58
|
+
"miter",
|
|
59
|
+
"round"
|
|
60
|
+
];
|
|
56
61
|
const SHAPE_LINE_END_TYPES = [
|
|
57
62
|
"none",
|
|
58
63
|
"triangle",
|
|
@@ -292,11 +297,7 @@ const readSymbolAttrs = (node) => {
|
|
|
292
297
|
expectNodeType(node, "symbol", issues);
|
|
293
298
|
requiredString(attrs, "font", "symbol.attrs.font", issues);
|
|
294
299
|
requiredString(attrs, "char", "symbol.attrs.char", issues);
|
|
295
|
-
if (typeof attrs["
|
|
296
|
-
path: "symbol.attrs.font",
|
|
297
|
-
message: "Expected a non-empty font name."
|
|
298
|
-
});
|
|
299
|
-
if (typeof attrs["char"] === "string" && !isOoxmlSymbolCharacter(attrs["char"])) issues.push({
|
|
300
|
+
if (typeof attrs["char"] === "string" && attrs["char"] !== "" && !isOoxmlSymbolCharacter(attrs["char"])) issues.push({
|
|
300
301
|
path: "symbol.attrs.char",
|
|
301
302
|
message: "Expected exactly four hexadecimal digits."
|
|
302
303
|
});
|
|
@@ -408,7 +409,11 @@ const readImageAttrs = (node) => {
|
|
|
408
409
|
optionalNumber(attrs, "paddingLeft", "image.attrs.paddingLeft", issues);
|
|
409
410
|
optionalImagePosition(attrs, "position", "image.attrs.position", issues);
|
|
410
411
|
optionalBoolean(attrs, "layoutInCell", "image.attrs.layoutInCell", issues);
|
|
412
|
+
optionalBoolean(attrs, "decorative", "image.attrs.decorative", issues);
|
|
413
|
+
optionalBoolean(attrs, "hidden", "image.attrs.hidden", issues);
|
|
414
|
+
optionalStringArray(attrs, "docPrExtensions", "image.attrs.docPrExtensions", issues);
|
|
411
415
|
optionalImageFrameLocks(attrs, "frameLocks", "image.attrs.frameLocks", issues);
|
|
416
|
+
optionalAuthoredEmu(attrs, "_docxAuthoredEmu", "image.attrs._docxAuthoredEmu", issues, IMAGE_AUTHORED_EMU_ATTRS);
|
|
412
417
|
optionalNumber(attrs, "borderWidth", "image.attrs.borderWidth", issues);
|
|
413
418
|
optionalString(attrs, "borderColor", "image.attrs.borderColor", issues);
|
|
414
419
|
optionalString(attrs, "borderStyle", "image.attrs.borderStyle", issues);
|
|
@@ -491,8 +496,12 @@ const readShapeAttrs = (node) => {
|
|
|
491
496
|
optionalString(attrs, "shapeType", "shape.attrs.shapeType", issues);
|
|
492
497
|
optionalString(attrs, "geometryAdjustments", "shape.attrs.geometryAdjustments", issues);
|
|
493
498
|
optionalString(attrs, "shapeId", "shape.attrs.shapeId", issues);
|
|
499
|
+
optionalString(attrs, "shapeName", "shape.attrs.shapeName", issues);
|
|
500
|
+
optionalString(attrs, "alt", "shape.attrs.alt", issues);
|
|
501
|
+
optionalString(attrs, "title", "shape.attrs.title", issues);
|
|
494
502
|
optionalNumber(attrs, "width", "shape.attrs.width", issues);
|
|
495
503
|
optionalNumber(attrs, "height", "shape.attrs.height", issues);
|
|
504
|
+
optionalAuthoredEmu(attrs, "_docxAuthoredEmu", "shape.attrs._docxAuthoredEmu", issues, SHAPE_AUTHORED_EMU_ATTRS);
|
|
496
505
|
optionalString(attrs, "fillColor", "shape.attrs.fillColor", issues);
|
|
497
506
|
optionalColorValue(attrs, "fillColorValue", "shape.attrs.fillColorValue", issues);
|
|
498
507
|
optionalOneOf(attrs, "fillType", "shape.attrs.fillType", issues, SHAPE_FILL_TYPES);
|
|
@@ -504,6 +513,7 @@ const readShapeAttrs = (node) => {
|
|
|
504
513
|
optionalColorValue(attrs, "outlineColorValue", "shape.attrs.outlineColorValue", issues);
|
|
505
514
|
optionalOneOf(attrs, "outlineStyle", "shape.attrs.outlineStyle", issues, OUTLINE_STYLE_ATTR_VALUES);
|
|
506
515
|
optionalOneOf(attrs, "outlineCap", "shape.attrs.outlineCap", issues, SHAPE_OUTLINE_CAPS);
|
|
516
|
+
optionalOneOf(attrs, "outlineJoin", "shape.attrs.outlineJoin", issues, SHAPE_OUTLINE_JOINS);
|
|
507
517
|
optionalShapeLineEnd(attrs, "outlineHeadEnd", "shape.attrs.outlineHeadEnd", issues);
|
|
508
518
|
optionalShapeLineEnd(attrs, "outlineTailEnd", "shape.attrs.outlineTailEnd", issues);
|
|
509
519
|
optionalString(attrs, "transform", "shape.attrs.transform", issues);
|
|
@@ -535,8 +545,12 @@ const readTextBoxAttrs = (node) => {
|
|
|
535
545
|
optionalWordArt(attrs, "wordArt", "textBox.attrs.wordArt", issues);
|
|
536
546
|
optionalOneOf(attrs, "textWrap", "textBox.attrs.textWrap", issues, TEXT_BOX_TEXT_WRAP_VALUES);
|
|
537
547
|
optionalString(attrs, "textBoxId", "textBox.attrs.textBoxId", issues);
|
|
548
|
+
optionalString(attrs, "textBoxName", "textBox.attrs.textBoxName", issues);
|
|
549
|
+
optionalString(attrs, "alt", "textBox.attrs.alt", issues);
|
|
550
|
+
optionalString(attrs, "title", "textBox.attrs.title", issues);
|
|
538
551
|
optionalString(attrs, "fillColor", "textBox.attrs.fillColor", issues);
|
|
539
552
|
optionalNumber(attrs, "outlineWidth", "textBox.attrs.outlineWidth", issues);
|
|
553
|
+
optionalAuthoredEmu(attrs, "_docxAuthoredEmu", "textBox.attrs._docxAuthoredEmu", issues, TEXT_BOX_AUTHORED_EMU_ATTRS);
|
|
540
554
|
optionalString(attrs, "outlineColor", "textBox.attrs.outlineColor", issues);
|
|
541
555
|
optionalOneOf(attrs, "outlineStyle", "textBox.attrs.outlineStyle", issues, OUTLINE_STYLE_ATTR_VALUES);
|
|
542
556
|
optionalTextBoxTransform(attrs, "transform", "textBox.attrs.transform", issues);
|
|
@@ -1645,6 +1659,7 @@ const validateParagraphFormatting = (value, path, issues) => {
|
|
|
1645
1659
|
]) optionalNumber(value, key, `${path}.${key}`, issues);
|
|
1646
1660
|
optionalOneOf(value, "lineSpacingRule", `${path}.lineSpacingRule`, issues, LINE_SPACING_RULE_VALUES);
|
|
1647
1661
|
optionalString(value, "styleId", `${path}.styleId`, issues);
|
|
1662
|
+
optionalString(value, "numberingChangeXml", `${path}.numberingChangeXml`, issues);
|
|
1648
1663
|
optionalOneOf(value, "listNumFmt", `${path}.listNumFmt`, issues, NUMBER_FORMAT_VALUES);
|
|
1649
1664
|
optionalString(value, "listMarker", `${path}.listMarker`, issues);
|
|
1650
1665
|
optionalString(value, "listMarkerTemplate", `${path}.listMarkerTemplate`, issues);
|
|
@@ -1787,6 +1802,57 @@ const validatePropertyChangeInfo = (value, path, issues) => {
|
|
|
1787
1802
|
optionalOneOf(value, "provenance", `${path}.provenance`, issues, TRACKED_CHANGE_PROVENANCE_VALUES);
|
|
1788
1803
|
optionalString(value, "suggestionId", `${path}.suggestionId`, issues);
|
|
1789
1804
|
};
|
|
1805
|
+
/**
|
|
1806
|
+
* The authored-EMU carrier: a sparse record of finite numbers keyed by the
|
|
1807
|
+
* pixel attribute each one was projected into. The keys are the node's own, so
|
|
1808
|
+
* they are checked against the list the caller passes rather than a shared one.
|
|
1809
|
+
*/
|
|
1810
|
+
const optionalAuthoredEmu = (attrs, key, path, issues, allowed) => {
|
|
1811
|
+
const value = attrs[key];
|
|
1812
|
+
if (value === void 0 || value === null) return;
|
|
1813
|
+
if (!isRecord(value)) {
|
|
1814
|
+
issues.push({
|
|
1815
|
+
path,
|
|
1816
|
+
message: "Expected an object."
|
|
1817
|
+
});
|
|
1818
|
+
return;
|
|
1819
|
+
}
|
|
1820
|
+
for (const name of Object.keys(value)) {
|
|
1821
|
+
if (!allowed.includes(name)) {
|
|
1822
|
+
issues.push({
|
|
1823
|
+
path: `${path}.${name}`,
|
|
1824
|
+
message: "Not a pixel attribute of this node."
|
|
1825
|
+
});
|
|
1826
|
+
continue;
|
|
1827
|
+
}
|
|
1828
|
+
optionalNumber(value, name, `${path}.${name}`, issues);
|
|
1829
|
+
}
|
|
1830
|
+
};
|
|
1831
|
+
const WRAP_DISTANCE_ATTRS = [
|
|
1832
|
+
"distTop",
|
|
1833
|
+
"distBottom",
|
|
1834
|
+
"distLeft",
|
|
1835
|
+
"distRight"
|
|
1836
|
+
];
|
|
1837
|
+
const TEXT_BOX_MARGIN_ATTRS = [
|
|
1838
|
+
"marginTop",
|
|
1839
|
+
"marginBottom",
|
|
1840
|
+
"marginLeft",
|
|
1841
|
+
"marginRight"
|
|
1842
|
+
];
|
|
1843
|
+
const IMAGE_AUTHORED_EMU_ATTRS = [
|
|
1844
|
+
"width",
|
|
1845
|
+
"height",
|
|
1846
|
+
"borderWidth",
|
|
1847
|
+
...WRAP_DISTANCE_ATTRS
|
|
1848
|
+
];
|
|
1849
|
+
const SHAPE_AUTHORED_EMU_ATTRS = [
|
|
1850
|
+
"width",
|
|
1851
|
+
"height",
|
|
1852
|
+
"outlineWidth",
|
|
1853
|
+
...WRAP_DISTANCE_ATTRS
|
|
1854
|
+
];
|
|
1855
|
+
const TEXT_BOX_AUTHORED_EMU_ATTRS = [...SHAPE_AUTHORED_EMU_ATTRS, ...TEXT_BOX_MARGIN_ATTRS];
|
|
1790
1856
|
const optionalImageFrameLocks = (attrs, key, path, issues) => {
|
|
1791
1857
|
const value = attrs[key];
|
|
1792
1858
|
if (value === void 0 || value === null) return;
|
|
@@ -1,8 +1,18 @@
|
|
|
1
|
+
import { document_d_exports } from "../types/document.js";
|
|
1
2
|
import { BookmarkBoundaryAttrs } from "./schema/nodes.js";
|
|
2
3
|
import { ReadProseMirrorAttrsResult } from "./attrs/index.js";
|
|
3
4
|
import { Node } from "prosemirror-model";
|
|
4
5
|
//#region src/prosemirror/bookmarkBoundaryAttrs.d.ts
|
|
6
|
+
declare const isDisplacedByCustomXml: (value: unknown) => value is document_d_exports.DisplacedByCustomXml;
|
|
7
|
+
/**
|
|
8
|
+
* A boundary's `w:displacedByCustomXml`, as a fragment to spread into the model
|
|
9
|
+
* content it rebuilds. Both a start and an end may carry it, so the callers
|
|
10
|
+
* that build either one share this rather than each remembering the attribute.
|
|
11
|
+
*/
|
|
12
|
+
declare const bookmarkBoundaryDisplacement: (attrs: BookmarkBoundaryAttrs) => {
|
|
13
|
+
displacedByCustomXml?: document_d_exports.DisplacedByCustomXml;
|
|
14
|
+
};
|
|
5
15
|
declare const readBookmarkBoundaryAttrs: (node: Node) => ReadProseMirrorAttrsResult<BookmarkBoundaryAttrs>;
|
|
6
16
|
declare const expectBookmarkBoundaryAttrs: (node: Node) => BookmarkBoundaryAttrs;
|
|
7
17
|
//#endregion
|
|
8
|
-
export { expectBookmarkBoundaryAttrs, readBookmarkBoundaryAttrs };
|
|
18
|
+
export { bookmarkBoundaryDisplacement, expectBookmarkBoundaryAttrs, isDisplacedByCustomXml, readBookmarkBoundaryAttrs };
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { panic } from "better-result";
|
|
2
2
|
//#region src/prosemirror/bookmarkBoundaryAttrs.ts
|
|
3
|
+
const isDisplacedByCustomXml = (value) => value === "next" || value === "prev";
|
|
3
4
|
const attrsCache = /* @__PURE__ */ new WeakMap();
|
|
5
|
+
/**
|
|
6
|
+
* A boundary's `w:displacedByCustomXml`, as a fragment to spread into the model
|
|
7
|
+
* content it rebuilds. Both a start and an end may carry it, so the callers
|
|
8
|
+
* that build either one share this rather than each remembering the attribute.
|
|
9
|
+
*/
|
|
10
|
+
const bookmarkBoundaryDisplacement = (attrs) => attrs.displacedByCustomXml === void 0 ? {} : { displacedByCustomXml: attrs.displacedByCustomXml };
|
|
4
11
|
const readBookmarkBoundaryAttrs = (node) => {
|
|
5
12
|
const issues = [];
|
|
6
13
|
if (node.type.name !== "bookmarkBoundary") issues.push({
|
|
@@ -32,10 +39,16 @@ const readBookmarkBoundaryAttrs = (node) => {
|
|
|
32
39
|
path: "bookmarkBoundary.attrs.colLast",
|
|
33
40
|
message: "Expected a non-negative integer."
|
|
34
41
|
});
|
|
42
|
+
const displaced = node.attrs["displacedByCustomXml"];
|
|
43
|
+
if (displaced !== void 0 && displaced !== null && !isDisplacedByCustomXml(displaced)) issues.push({
|
|
44
|
+
path: "bookmarkBoundary.attrs.displacedByCustomXml",
|
|
45
|
+
message: "Expected \"next\" or \"prev\"."
|
|
46
|
+
});
|
|
35
47
|
if (issues.length > 0 || typeof id !== "number") return {
|
|
36
48
|
ok: false,
|
|
37
49
|
issues
|
|
38
50
|
};
|
|
51
|
+
const displacement = isDisplacedByCustomXml(displaced) ? { displacedByCustomXml: displaced } : {};
|
|
39
52
|
if (type === "start" && typeof name === "string") return {
|
|
40
53
|
ok: true,
|
|
41
54
|
value: {
|
|
@@ -43,14 +56,16 @@ const readBookmarkBoundaryAttrs = (node) => {
|
|
|
43
56
|
id,
|
|
44
57
|
name,
|
|
45
58
|
...typeof colFirst === "number" ? { colFirst } : {},
|
|
46
|
-
...typeof colLast === "number" ? { colLast } : {}
|
|
59
|
+
...typeof colLast === "number" ? { colLast } : {},
|
|
60
|
+
...displacement
|
|
47
61
|
}
|
|
48
62
|
};
|
|
49
63
|
return {
|
|
50
64
|
ok: true,
|
|
51
65
|
value: {
|
|
52
66
|
type: "end",
|
|
53
|
-
id
|
|
67
|
+
id,
|
|
68
|
+
...displacement
|
|
54
69
|
}
|
|
55
70
|
};
|
|
56
71
|
};
|
|
@@ -63,4 +78,4 @@ const expectBookmarkBoundaryAttrs = (node) => {
|
|
|
63
78
|
return result.value;
|
|
64
79
|
};
|
|
65
80
|
//#endregion
|
|
66
|
-
export { expectBookmarkBoundaryAttrs, readBookmarkBoundaryAttrs };
|
|
81
|
+
export { bookmarkBoundaryDisplacement, expectBookmarkBoundaryAttrs, isDisplacedByCustomXml, readBookmarkBoundaryAttrs };
|
|
@@ -179,6 +179,7 @@ const insertImageFromFile = async (view, file, onInserted) => {
|
|
|
179
179
|
if (!imageType) return;
|
|
180
180
|
const imageNode = imageType.create({
|
|
181
181
|
src: dataUrl,
|
|
182
|
+
docPrName: file.name,
|
|
182
183
|
alt: file.name,
|
|
183
184
|
width: constrained.width,
|
|
184
185
|
height: constrained.height,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ResolvedStyleAttrs, getParagraphAlignment, getParagraphBidi, getStyleId } from "../extensions/core/ParagraphExtension.js";
|
|
1
|
+
import { GenerateTableOfContentsOptions, ResolvedStyleAttrs, getParagraphAlignment, getParagraphBidi, getStyleId } from "../extensions/core/ParagraphExtension.js";
|
|
2
2
|
import { BorderPreset, TableBorderPreset, TableContextInfo, getTableContext, isInTable as isInTableCell } from "../extensions/nodes/TableExtension.js";
|
|
3
3
|
import { AcceptSuggestionOptions, FolioSuggestion, SuggestionAppliedAs, SuggestionKind, acceptAIEditRevision, acceptAllChanges, acceptAllSuggestions, acceptChange, acceptSuggestion, addCommentMark, findAIEditRevisionRange, findNextChange, findPreviousChange, findSuggestionRange, getSuggestions, rejectAIEditRevision, rejectAllChanges, rejectAllSuggestions, rejectChange, rejectSuggestion, removeCommentMark } from "./comments.js";
|
|
4
4
|
import { CapturedTextFormatting, PAINTABLE_MARK_NAMES, applyFormatMarks, captureFormatMarks } from "./formatPainter.js";
|
|
@@ -6,8 +6,8 @@ import { clearFormatting, createRemoveMarkCommand, createSetMarkCommand, getMark
|
|
|
6
6
|
import { getHyperlinkAttrs, getSelectedText, isHyperlinkActive } from "../extensions/marks/HyperlinkExtension.js";
|
|
7
7
|
import { clearFontFamily, clearFontSize, clearHighlight, clearTextColor, insertHyperlink, removeHyperlink, setFontFamily, setFontSize, setHighlight, setHyperlink, setTextColor, setUnderlineStyle, toggleBold, toggleItalic, toggleStrike, toggleSubscript, toggleSuperscript, toggleUnderline } from "./formatting.js";
|
|
8
8
|
import { getListInfo, isInList } from "../extensions/features/ListExtension.js";
|
|
9
|
-
import { addTabStop, alignCenter, alignJustify, alignLeft, alignRight, applyStyle, clearStyle, decreaseIndent, decreaseListLevel, doubleSpacing,
|
|
9
|
+
import { addTabStop, alignCenter, alignJustify, alignLeft, alignRight, applyStyle, clearStyle, decreaseIndent, decreaseListLevel, doubleSpacing, generateTableOfContents, increaseIndent, increaseListLevel, oneAndHalfSpacing, removeList, removeTabStop, setAlignment, setIndentFirstLine, setIndentLeft, setIndentRight, setLineSpacing, setLtr, setRtl, setSpaceAfter, setSpaceBefore, singleSpacing, toggleBidi, toggleBulletList, toggleNumberedList } from "./paragraph.js";
|
|
10
10
|
import { addColumnLeft, addColumnRight, addRowAbove, addRowBelow, applyTableStyle, autoFitContents, deleteColumn, deleteRow, deleteTable, distributeColumns, insertTable, mergeCells, removeTableBorders, selectColumn, selectRow, selectTable, setAllTableBorders, setCellBorder, setCellFillColor, setCellMargins, setCellTextDirection, setCellVerticalAlign, setInsideTableBorders, setOutsideTableBorders, setRowHeight, setTableBorderColor, setTableBorderPreset, setTableBorderWidth, setTableBorders, setTableProperties, splitCell, toggleHeaderRow, toggleNoWrap } from "./table.js";
|
|
11
11
|
import { insertPageBreak } from "./pageBreak.js";
|
|
12
12
|
import { CLIPBOARD_READ_ERROR_EVENT, buildPlainTextSlice, pasteWithoutFormatting } from "./pastePlainText.js";
|
|
13
|
-
export { type AcceptSuggestionOptions, type BorderPreset, CLIPBOARD_READ_ERROR_EVENT, type CapturedTextFormatting, type FolioSuggestion, PAINTABLE_MARK_NAMES, type ResolvedStyleAttrs, type SuggestionAppliedAs, type SuggestionKind, type TableBorderPreset, type TableContextInfo, acceptAIEditRevision, acceptAllChanges, acceptAllSuggestions, acceptChange, acceptSuggestion, addColumnLeft, addColumnRight, addCommentMark, addRowAbove, addRowBelow, addTabStop, alignCenter, alignJustify, alignLeft, alignRight, applyFormatMarks, applyStyle, applyTableStyle, autoFitContents, buildPlainTextSlice, captureFormatMarks, clearFontFamily, clearFontSize, clearFormatting, clearHighlight, clearStyle, clearTextColor, createRemoveMarkCommand, createSetMarkCommand, decreaseIndent, decreaseListLevel, deleteColumn, deleteRow, deleteTable, distributeColumns, doubleSpacing, findAIEditRevisionRange, findNextChange, findPreviousChange, findSuggestionRange,
|
|
13
|
+
export { type AcceptSuggestionOptions, type BorderPreset, CLIPBOARD_READ_ERROR_EVENT, type CapturedTextFormatting, type FolioSuggestion, type GenerateTableOfContentsOptions, PAINTABLE_MARK_NAMES, type ResolvedStyleAttrs, type SuggestionAppliedAs, type SuggestionKind, type TableBorderPreset, type TableContextInfo, acceptAIEditRevision, acceptAllChanges, acceptAllSuggestions, acceptChange, acceptSuggestion, addColumnLeft, addColumnRight, addCommentMark, addRowAbove, addRowBelow, addTabStop, alignCenter, alignJustify, alignLeft, alignRight, applyFormatMarks, applyStyle, applyTableStyle, autoFitContents, buildPlainTextSlice, captureFormatMarks, clearFontFamily, clearFontSize, clearFormatting, clearHighlight, clearStyle, clearTextColor, createRemoveMarkCommand, createSetMarkCommand, decreaseIndent, decreaseListLevel, deleteColumn, deleteRow, deleteTable, distributeColumns, doubleSpacing, findAIEditRevisionRange, findNextChange, findPreviousChange, findSuggestionRange, generateTableOfContents, getHyperlinkAttrs, getListInfo, getMarkAttr, getParagraphAlignment, getParagraphBidi, getSelectedText, getStyleId, getSuggestions, getTableContext, increaseIndent, increaseListLevel, insertHyperlink, insertPageBreak, insertTable, isHyperlinkActive, isInList, isInTableCell as isInTable, isMarkActive, mergeCells, oneAndHalfSpacing, pasteWithoutFormatting, rejectAIEditRevision, rejectAllChanges, rejectAllSuggestions, rejectChange, rejectSuggestion, removeCommentMark, removeHyperlink, removeList, removeTabStop, removeTableBorders, selectColumn, selectRow, selectTable, setAlignment, setAllTableBorders, setCellBorder, setCellFillColor, setCellMargins, setCellTextDirection, setCellVerticalAlign, setFontFamily, setFontSize, setHighlight, setHyperlink, setIndentFirstLine, setIndentLeft, setIndentRight, setInsideTableBorders, setLineSpacing, setLtr, setOutsideTableBorders, setRowHeight, setRtl, setSpaceAfter, setSpaceBefore, setTableBorderColor, setTableBorderPreset, setTableBorderWidth, setTableBorders, setTableProperties, setTextColor, setUnderlineStyle, singleSpacing, splitCell, toggleBidi, toggleBold, toggleBulletList, toggleHeaderRow, toggleItalic, toggleNoWrap, toggleNumberedList, toggleStrike, toggleSubscript, toggleSuperscript, toggleUnderline };
|
|
@@ -7,7 +7,7 @@ import { acceptAIEditRevision, acceptAllChanges, acceptAllSuggestions, acceptCha
|
|
|
7
7
|
import { PAINTABLE_MARK_NAMES, applyFormatMarks, captureFormatMarks } from "./formatPainter.js";
|
|
8
8
|
import { clearFontFamily, clearFontSize, clearHighlight, clearTextColor, insertHyperlink, removeHyperlink, setFontFamily, setFontSize, setHighlight, setHyperlink, setTextColor, setUnderlineStyle, toggleBold, toggleItalic, toggleStrike, toggleSubscript, toggleSuperscript, toggleUnderline } from "./formatting.js";
|
|
9
9
|
import { insertPageBreak } from "./pageBreak.js";
|
|
10
|
-
import { addTabStop, alignCenter, alignJustify, alignLeft, alignRight, applyStyle, clearStyle, decreaseIndent, decreaseListLevel, doubleSpacing,
|
|
10
|
+
import { addTabStop, alignCenter, alignJustify, alignLeft, alignRight, applyStyle, clearStyle, decreaseIndent, decreaseListLevel, doubleSpacing, generateTableOfContents, increaseIndent, increaseListLevel, oneAndHalfSpacing, removeList, removeTabStop, setAlignment, setIndentFirstLine, setIndentLeft, setIndentRight, setLineSpacing, setLtr, setRtl, setSpaceAfter, setSpaceBefore, singleSpacing, toggleBidi, toggleBulletList, toggleNumberedList } from "./paragraph.js";
|
|
11
11
|
import { CLIPBOARD_READ_ERROR_EVENT, buildPlainTextSlice, pasteWithoutFormatting } from "./pastePlainText.js";
|
|
12
12
|
import { addColumnLeft, addColumnRight, addRowAbove, addRowBelow, applyTableStyle, autoFitContents, deleteColumn, deleteRow, deleteTable, distributeColumns, insertTable, mergeCells, removeTableBorders, selectColumn, selectRow, selectTable, setAllTableBorders, setCellBorder, setCellFillColor, setCellMargins, setCellTextDirection, setCellVerticalAlign, setInsideTableBorders, setOutsideTableBorders, setRowHeight, setTableBorderColor, setTableBorderPreset, setTableBorderWidth, setTableBorders, setTableProperties, splitCell, toggleHeaderRow, toggleNoWrap } from "./table.js";
|
|
13
|
-
export { CLIPBOARD_READ_ERROR_EVENT, PAINTABLE_MARK_NAMES, acceptAIEditRevision, acceptAllChanges, acceptAllSuggestions, acceptChange, acceptSuggestion, addColumnLeft, addColumnRight, addCommentMark, addRowAbove, addRowBelow, addTabStop, alignCenter, alignJustify, alignLeft, alignRight, applyFormatMarks, applyStyle, applyTableStyle, autoFitContents, buildPlainTextSlice, captureFormatMarks, clearFontFamily, clearFontSize, clearFormatting, clearHighlight, clearStyle, clearTextColor, createRemoveMarkCommand, createSetMarkCommand, decreaseIndent, decreaseListLevel, deleteColumn, deleteRow, deleteTable, distributeColumns, doubleSpacing, findAIEditRevisionRange, findNextChange, findPreviousChange, findSuggestionRange,
|
|
13
|
+
export { CLIPBOARD_READ_ERROR_EVENT, PAINTABLE_MARK_NAMES, acceptAIEditRevision, acceptAllChanges, acceptAllSuggestions, acceptChange, acceptSuggestion, addColumnLeft, addColumnRight, addCommentMark, addRowAbove, addRowBelow, addTabStop, alignCenter, alignJustify, alignLeft, alignRight, applyFormatMarks, applyStyle, applyTableStyle, autoFitContents, buildPlainTextSlice, captureFormatMarks, clearFontFamily, clearFontSize, clearFormatting, clearHighlight, clearStyle, clearTextColor, createRemoveMarkCommand, createSetMarkCommand, decreaseIndent, decreaseListLevel, deleteColumn, deleteRow, deleteTable, distributeColumns, doubleSpacing, findAIEditRevisionRange, findNextChange, findPreviousChange, findSuggestionRange, generateTableOfContents, getHyperlinkAttrs, getListInfo, getMarkAttr, getParagraphAlignment, getParagraphBidi, getSelectedText, getStyleId, getSuggestions, getTableContext, increaseIndent, increaseListLevel, insertHyperlink, insertPageBreak, insertTable, isHyperlinkActive, isInList, isInTableCell as isInTable, isMarkActive, mergeCells, oneAndHalfSpacing, pasteWithoutFormatting, rejectAIEditRevision, rejectAllChanges, rejectAllSuggestions, rejectChange, rejectSuggestion, removeCommentMark, removeHyperlink, removeList, removeTabStop, removeTableBorders, selectColumn, selectRow, selectTable, setAlignment, setAllTableBorders, setCellBorder, setCellFillColor, setCellMargins, setCellTextDirection, setCellVerticalAlign, setFontFamily, setFontSize, setHighlight, setHyperlink, setIndentFirstLine, setIndentLeft, setIndentRight, setInsideTableBorders, setLineSpacing, setLtr, setOutsideTableBorders, setRowHeight, setRtl, setSpaceAfter, setSpaceBefore, setTableBorderColor, setTableBorderPreset, setTableBorderWidth, setTableBorders, setTableProperties, setTextColor, setUnderlineStyle, singleSpacing, splitCell, toggleBidi, toggleBold, toggleBulletList, toggleHeaderRow, toggleItalic, toggleNoWrap, toggleNumberedList, toggleStrike, toggleSubscript, toggleSuperscript, toggleUnderline };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { document_d_exports } from "../../types/document.js";
|
|
2
|
-
import { ResolvedStyleAttrs, getParagraphAlignment, getParagraphBidi, getParagraphTabs, getStyleId } from "../extensions/core/ParagraphExtension.js";
|
|
2
|
+
import { GenerateTableOfContentsOptions, ResolvedStyleAttrs, getParagraphAlignment, getParagraphBidi, getParagraphTabs, getStyleId } from "../extensions/core/ParagraphExtension.js";
|
|
3
3
|
import { getListInfo, isInList } from "../extensions/features/ListExtension.js";
|
|
4
4
|
import { Command } from "prosemirror-state";
|
|
5
5
|
//#region src/prosemirror/commands/paragraph.d.ts
|
|
@@ -33,6 +33,6 @@ declare function removeTabStop(position: number): Command;
|
|
|
33
33
|
declare const toggleBidi: Command;
|
|
34
34
|
declare const setRtl: Command;
|
|
35
35
|
declare const setLtr: Command;
|
|
36
|
-
declare const
|
|
36
|
+
declare const generateTableOfContents: (options: GenerateTableOfContentsOptions) => Command;
|
|
37
37
|
//#endregion
|
|
38
|
-
export { type ResolvedStyleAttrs, addTabStop, alignCenter, alignJustify, alignLeft, alignRight, applyStyle, clearStyle, decreaseIndent, decreaseListLevel, doubleSpacing,
|
|
38
|
+
export { type GenerateTableOfContentsOptions, type ResolvedStyleAttrs, addTabStop, alignCenter, alignJustify, alignLeft, alignRight, applyStyle, clearStyle, decreaseIndent, decreaseListLevel, doubleSpacing, generateTableOfContents, getListInfo, getParagraphAlignment, getParagraphBidi, getParagraphTabs, getStyleId, increaseIndent, increaseListLevel, insertSectionBreak, isInList, oneAndHalfSpacing, removeList, removeSectionBreak, removeTabStop, setAlignment, setIndentFirstLine, setIndentLeft, setIndentRight, setLineSpacing, setLtr, setRtl, setSpaceAfter, setSpaceBefore, singleSpacing, toggleBidi, toggleBulletList, toggleNumberedList };
|
|
@@ -59,6 +59,6 @@ function removeTabStop(position) {
|
|
|
59
59
|
const toggleBidi = cmds.requireCommand("toggleBidi")();
|
|
60
60
|
const setRtl = cmds.requireCommand("setRtl")();
|
|
61
61
|
const setLtr = cmds.requireCommand("setLtr")();
|
|
62
|
-
const
|
|
62
|
+
const generateTableOfContents = (options) => cmds.requireCommand("generateTOC")(options);
|
|
63
63
|
//#endregion
|
|
64
|
-
export { addTabStop, alignCenter, alignJustify, alignLeft, alignRight, applyStyle, clearStyle, decreaseIndent, decreaseListLevel, doubleSpacing,
|
|
64
|
+
export { addTabStop, alignCenter, alignJustify, alignLeft, alignRight, applyStyle, clearStyle, decreaseIndent, decreaseListLevel, doubleSpacing, generateTableOfContents, getListInfo, getParagraphAlignment, getParagraphBidi, getParagraphTabs, getStyleId, increaseIndent, increaseListLevel, insertSectionBreak, isInList, oneAndHalfSpacing, removeList, removeSectionBreak, removeTabStop, setAlignment, setIndentFirstLine, setIndentLeft, setIndentRight, setLineSpacing, setLtr, setRtl, setSpaceAfter, setSpaceBefore, singleSpacing, toggleBidi, toggleBulletList, toggleNumberedList };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { seedRevisionIdsAbove } from "./plugins/revisionIds.js";
|
|
1
|
+
import { maxAnnotationIdInDoc, seedRevisionIdsAbove } from "./plugins/revisionIds.js";
|
|
2
2
|
import { MAX_REVISION_ID } from "@stll/docx-core/model";
|
|
3
3
|
//#region src/prosemirror/commentIdAllocator.ts
|
|
4
4
|
/** Sentinel ID for a comment that hasn't been persisted yet (anchored to selection). */
|
|
@@ -32,12 +32,7 @@ function createCommentIdAllocator() {
|
|
|
32
32
|
function seedCommentAllocator(allocator, comments, view) {
|
|
33
33
|
let max = 0;
|
|
34
34
|
for (const comment of comments ?? []) if (Number.isInteger(comment.id) && comment.id > max && comment.id <= MAX_REVISION_ID) max = comment.id;
|
|
35
|
-
if (view) view.state.doc
|
|
36
|
-
for (const mark of node.marks) {
|
|
37
|
-
const revisionId = mark.attrs["revisionId"];
|
|
38
|
-
if (typeof revisionId === "number" && Number.isInteger(revisionId) && revisionId > max && revisionId <= MAX_REVISION_ID) max = revisionId;
|
|
39
|
-
}
|
|
40
|
-
});
|
|
35
|
+
if (view) max = Math.max(max, maxAnnotationIdInDoc(view.state.doc));
|
|
41
36
|
allocator.seedAbove(max);
|
|
42
37
|
seedRevisionIdsAbove(max);
|
|
43
38
|
}
|