@stll/folio-core 0.45.0 → 0.46.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.js +59 -19
- package/dist/ai-edits/headless.js +1 -1
- package/dist/compare/compare.js +2 -5
- package/dist/compare/scenario.js +2 -5
- package/dist/compare/types.d.ts +9 -1
- package/dist/compare/types.js +12 -1
- package/dist/compat/eigenpal.d.ts +2 -1
- package/dist/compat/eigenpal.js +2 -1
- package/dist/content-controls/checkboxDisplay.d.ts +11 -0
- package/dist/content-controls/checkboxDisplay.js +40 -0
- package/dist/content-controls/findContentControls.js +3 -1
- package/dist/content-controls/mutateContentControls.js +17 -2
- package/dist/controller/contentControlWidgetController.d.ts +1 -0
- package/dist/controller/contentControlWidgetController.js +3 -0
- package/dist/controller/hiddenEditorApi.js +3 -1
- package/dist/controller/hiddenEditorManager.d.ts +1 -1
- package/dist/controller/hiddenEditorManager.js +6 -3
- package/dist/display-list/build/buildDisplayList.js +20 -1
- package/dist/display-list/build/imagePrimitives.d.ts +1 -1
- package/dist/display-list/build/imagePrimitives.js +3 -1
- package/dist/display-list/build/paragraphPrimitives.js +21 -2
- package/dist/display-list/dom/renderDisplayListToDom.js +10 -2
- package/dist/display-list/types.d.ts +17 -0
- package/dist/docx/attributeRemainder.d.ts +43 -0
- package/dist/docx/attributeRemainder.js +65 -0
- package/dist/docx/blockContentParser.d.ts +1 -1
- package/dist/docx/blockContentParser.js +87 -63
- package/dist/docx/blockPlainText.d.ts +3 -4
- package/dist/docx/blockPlainText.js +1 -0
- package/dist/docx/bookmarkPlacement.js +2 -0
- package/dist/docx/commentAnchorIndex.d.ts +30 -0
- package/dist/docx/commentAnchorIndex.js +50 -0
- package/dist/docx/commentParser.d.ts +1 -1
- package/dist/docx/commentParser.js +54 -37
- package/dist/docx/commentRangeIntegrity.d.ts +16 -1
- package/dist/docx/commentRangeIntegrity.js +42 -1
- package/dist/docx/commentRangeJoin.d.ts +9 -0
- package/dist/docx/commentRangeJoin.js +33 -0
- package/dist/docx/commentReferenceCompletion.d.ts +9 -0
- package/dist/docx/commentReferenceCompletion.js +47 -0
- package/dist/docx/commentReferenceNormalization.js +1 -0
- package/dist/docx/commentReplyMarkers.js +11 -19
- package/dist/docx/compatibility.js +1 -0
- package/dist/docx/containerChildren.d.ts +111 -0
- package/dist/docx/containerChildren.gen.d.ts +28 -0
- package/dist/docx/containerChildren.gen.js +246 -0
- package/dist/docx/containerChildren.js +103 -0
- package/dist/docx/documentParser.d.ts +1 -1
- package/dist/docx/documentParser.js +3 -3
- package/dist/docx/ensureParaIds.js +17 -7
- package/dist/docx/fieldParser.d.ts +1 -1
- package/dist/docx/fieldParser.js +4 -4
- package/dist/docx/fieldState.d.ts +26 -0
- package/dist/docx/fieldState.js +53 -0
- package/dist/docx/footnoteParser.d.ts +1 -1
- package/dist/docx/graphicFrameLocks.d.ts +16 -4
- package/dist/docx/graphicFrameLocks.js +19 -6
- package/dist/docx/headerFooterParser.js +1 -1
- package/dist/docx/headerFooterReferenceNormalization.js +1 -0
- package/dist/docx/hyperlinkParser.d.ts +27 -8
- package/dist/docx/hyperlinkParser.js +76 -18
- package/dist/docx/imageParser.js +33 -8
- package/dist/docx/inlineWrapperContent.d.ts +85 -0
- package/dist/docx/inlineWrapperContent.js +84 -0
- package/dist/docx/normalizeBaseDirection.js +10 -1
- package/dist/docx/paraIdAttribute.d.ts +21 -0
- package/dist/docx/paraIdAttribute.js +64 -0
- package/dist/docx/paragraphParser.d.ts +1 -1
- package/dist/docx/paragraphParser.js +277 -168
- package/dist/docx/paragraphPropertySource.js +5 -1
- package/dist/docx/paragraphTextBoxEnrichment.d.ts +1 -1
- package/dist/docx/paragraphTextBoxEnrichment.js +6 -52
- package/dist/docx/paragraphTraversal.js +7 -4
- package/dist/docx/parseWarningMessage.js +2 -1
- package/dist/docx/preservedRunContent.d.ts +32 -0
- package/dist/docx/preservedRunContent.js +86 -0
- package/dist/docx/renderedPageBreakNormalization.js +2 -4
- package/dist/docx/rezip.js +74 -18
- package/dist/docx/runParser.d.ts +1 -1
- package/dist/docx/runParser.js +16 -12
- package/dist/docx/sectionParser.js +8 -1
- package/dist/docx/selectiveXmlPatch.d.ts +46 -2
- package/dist/docx/selectiveXmlPatch.js +86 -39
- package/dist/docx/serializer/borderSerializer.js +2 -2
- package/dist/docx/serializer/commentSerializer.js +5 -7
- package/dist/docx/serializer/documentSerializer.js +8 -11
- package/dist/docx/serializer/headerFooterSerializer.js +7 -9
- package/dist/docx/serializer/noteSerializer.js +8 -8
- package/dist/docx/serializer/paragraphSerializer.js +76 -56
- package/dist/docx/serializer/runSerializer.js +25 -16
- package/dist/docx/serializer/sectionPropertiesSerializer.js +8 -4
- package/dist/docx/serializer/tableSerializer.js +18 -8
- package/dist/docx/server/createBilingualDocument.js +3 -1
- package/dist/docx/server/materializeYjsDocx.d.ts +1 -1
- package/dist/docx/server/materializeYjsDocx.js +9 -1
- package/dist/docx/server/migrateYjsAttrSchema.d.ts +55 -0
- package/dist/docx/server/migrateYjsAttrSchema.js +95 -0
- package/dist/docx/shapeParser.js +5 -5
- package/dist/docx/tableParser.d.ts +1 -1
- package/dist/docx/tableParser.js +206 -85
- package/dist/docx/textBoxParser.d.ts +25 -2
- package/dist/docx/textBoxParser.js +52 -2
- package/dist/docx/unzip.js +5 -4
- package/dist/docx/vmlImageParser.d.ts +17 -1
- package/dist/docx/vmlImageParser.js +17 -1
- package/dist/docx/xmlEncoding.d.ts +5 -0
- package/dist/docx/xmlEncoding.js +12 -0
- package/dist/docx/xmlParser.d.ts +10 -1
- package/dist/docx/xmlParser.js +14 -1
- package/dist/headless-layout.js +10 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/internal/pageBreakRunSourceDescendantIndex.js +5 -2
- package/dist/layout-bridge/convert/toFlowBlocks.js +102 -12
- package/dist/layout-engine/measure/tableCellFloating.d.ts +2 -0
- package/dist/layout-engine/measure/tableCellFloating.js +2 -0
- package/dist/layout-engine/types.d.ts +23 -1
- package/dist/layout-painter/renderImage.d.ts +5 -1
- package/dist/layout-painter/renderImage.js +10 -3
- package/dist/layout-painter/renderPage.d.ts +2 -0
- package/dist/layout-painter/renderPage.js +4 -0
- package/dist/layout-painter/renderParagraph.d.ts +13 -1
- package/dist/layout-painter/renderParagraph.js +22 -3
- package/dist/managers/autoSaveCodec.d.ts +9 -1
- package/dist/managers/autoSaveCodec.js +12 -4
- package/dist/markdown/renderBlock.js +1 -0
- package/dist/markdown/renderRuns.d.ts +1 -1
- package/dist/markdown/renderRuns.js +28 -5
- package/dist/markdown/renderTable.js +22 -5
- package/dist/markdown/trailers.js +4 -1
- package/dist/pdf/images.js +142 -6
- package/dist/prosemirror/attrs/index.d.ts +14 -3
- package/dist/prosemirror/attrs/index.js +155 -2
- package/dist/prosemirror/authoredTransformAttrs.d.ts +28 -0
- package/dist/prosemirror/authoredTransformAttrs.js +64 -0
- package/dist/prosemirror/commands/contentControls.js +10 -2
- package/dist/prosemirror/commands/image.d.ts +9 -2
- package/dist/prosemirror/commands/image.js +42 -28
- package/dist/prosemirror/commands/pageBreak.js +1 -1
- package/dist/prosemirror/commentReferenceAttrs.d.ts +8 -0
- package/dist/prosemirror/commentReferenceAttrs.js +33 -0
- package/dist/prosemirror/commentReferenceIntegrity.d.ts +47 -0
- package/dist/prosemirror/commentReferenceIntegrity.js +43 -0
- package/dist/prosemirror/conversion/fromProseDoc.d.ts +2 -13
- package/dist/prosemirror/conversion/fromProseDoc.js +269 -70
- package/dist/prosemirror/conversion/index.d.ts +2 -2
- package/dist/prosemirror/conversion/toProseDoc.d.ts +7 -9
- package/dist/prosemirror/conversion/toProseDoc.js +468 -308
- package/dist/prosemirror/extensions/StarterKit.js +8 -58
- package/dist/prosemirror/extensions/core/DocExtension.js +1 -1
- package/dist/prosemirror/extensions/core/ParagraphExtension.js +2 -1
- package/dist/prosemirror/extensions/features/BaseKeymapExtension.js +45 -27
- package/dist/prosemirror/extensions/features/EmptyParagraphFormatExtension.js +3 -1
- package/dist/prosemirror/extensions/features/ImagePasteExtension.js +5 -3
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.js +1 -0
- package/dist/prosemirror/extensions/markRegistry.d.ts +41 -0
- package/dist/prosemirror/extensions/markRegistry.js +75 -0
- package/dist/prosemirror/extensions/marks/InlineWrapperExtension.d.ts +18 -0
- package/dist/prosemirror/extensions/marks/InlineWrapperExtension.js +63 -0
- package/dist/prosemirror/extensions/marks/markUtils.d.ts +2 -1
- package/dist/prosemirror/extensions/marks/markUtils.js +47 -4
- package/dist/prosemirror/extensions/nodes/CommentReferenceExtension.d.ts +11 -0
- package/dist/prosemirror/extensions/nodes/CommentReferenceExtension.js +87 -0
- package/dist/prosemirror/extensions/nodes/FieldExtension.js +9 -7
- package/dist/prosemirror/extensions/nodes/ImageExtension.js +16 -0
- package/dist/prosemirror/extensions/nodes/PreservedBlockExtension.d.ts +32 -0
- package/dist/prosemirror/extensions/nodes/PreservedBlockExtension.js +67 -0
- package/dist/prosemirror/extensions/nodes/PreservedXmlExtension.d.ts +16 -0
- package/dist/prosemirror/extensions/nodes/PreservedXmlExtension.js +60 -0
- package/dist/prosemirror/extensions/nodes/ShapeExtension.js +3 -0
- package/dist/prosemirror/extensions/nodes/TableExtension.js +3 -2
- package/dist/prosemirror/extensions/nodes/TextBoxExtension.js +5 -1
- package/dist/prosemirror/inlineWrapperStack.d.ts +39 -0
- package/dist/prosemirror/inlineWrapperStack.js +75 -0
- package/dist/prosemirror/pageBreakRunProjection.d.ts +17 -7
- package/dist/prosemirror/pageBreakRunProjection.js +19 -9
- package/dist/prosemirror/replacedAnnotations.d.ts +59 -0
- package/dist/prosemirror/replacedAnnotations.js +165 -0
- package/dist/prosemirror/runFormattingInlineCarriers.d.ts +3 -1
- package/dist/prosemirror/runFormattingInlineCarriers.js +5 -1
- package/dist/prosemirror/schema/index.d.ts +3 -3
- package/dist/prosemirror/schema/marks.d.ts +25 -1
- package/dist/prosemirror/schema/nodes.d.ts +90 -3
- package/dist/prosemirror/schema/nodes.js +16 -1
- package/dist/prosemirror/trackedRunInlineAtoms.d.ts +2 -0
- package/dist/prosemirror/trackedRunInlineAtoms.js +2 -0
- package/dist/prosemirror/validation.js +16 -2
- package/dist/prosemirror/yjsDocumentMetadata.d.ts +73 -0
- package/dist/prosemirror/yjsDocumentMetadata.js +171 -0
- package/dist/prosemirror/zeroWidthAnchors.js +2 -0
- package/dist/render-dom/commentAnchorAttributes.d.ts +37 -0
- package/dist/render-dom/commentAnchorAttributes.js +54 -0
- package/dist/server.d.ts +3 -1
- package/dist/server.js +3 -1
- package/dist/types/content.d.ts +2 -2
- package/dist/utils/clipboard.d.ts +9 -1
- package/dist/utils/clipboard.js +27 -1
- package/dist/utils/findReplace.js +1 -1
- package/dist/utils/imageLuminance.d.ts +15 -0
- package/dist/utils/imageLuminance.js +32 -0
- package/dist/utils/mergeDocumentContent.js +7 -17
- package/dist/utils/replaceText.js +1 -0
- package/package.json +2 -2
- package/dist/docx/blockRangeMarkers.d.ts +0 -36
- package/dist/docx/blockRangeMarkers.js +0 -59
- package/dist/prosemirror/yjsParagraphSourceContract.d.ts +0 -9
- package/dist/prosemirror/yjsParagraphSourceContract.js +0 -26
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Fragment, Mark, Node, Schema } from "prosemirror-model";
|
|
2
|
+
//#region src/prosemirror/replacedAnnotations.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* What a replacement does with each mark the schema declares
|
|
5
|
+
* `inclusive: false`. Boundary inheritance already handles every other mark,
|
|
6
|
+
* so this table is exactly the set that needs a decision; a new
|
|
7
|
+
* non-inclusive mark that is missing from it fails
|
|
8
|
+
* `replacedAnnotations.test.ts` rather than silently following the text.
|
|
9
|
+
*/
|
|
10
|
+
declare const NON_INCLUSIVE_MARK_DISPOSITION: {
|
|
11
|
+
readonly comment: "carry";
|
|
12
|
+
readonly hyperlink: "carry";
|
|
13
|
+
readonly footnoteRef: "followsTheText";
|
|
14
|
+
readonly pageBreakRunOwner: "followsTheText";
|
|
15
|
+
readonly insertion: "followsTheText";
|
|
16
|
+
readonly deletion: "followsTheText";
|
|
17
|
+
readonly runPropertyChange: "followsTheText";
|
|
18
|
+
readonly inlineWrapper: "followsTheText";
|
|
19
|
+
};
|
|
20
|
+
/** The mark names in the schema that a replacement must not silently drop. */
|
|
21
|
+
declare const nonInclusiveMarkNames: (schema: Schema) => string[];
|
|
22
|
+
type ReplacedAnnotations = {
|
|
23
|
+
/** Marks the replacement must carry, in document order. */
|
|
24
|
+
carried: readonly Mark[];
|
|
25
|
+
/** Anchors restored before the replacement, in their original order. */
|
|
26
|
+
leading: readonly Node[];
|
|
27
|
+
/** Anchors restored after the replacement, in their original order. */
|
|
28
|
+
trailing: readonly Node[];
|
|
29
|
+
};
|
|
30
|
+
declare const hasReplacedAnnotations: ({ carried, leading, trailing }: ReplacedAnnotations) => boolean;
|
|
31
|
+
/**
|
|
32
|
+
* The annotations carried by `[from, to)`. An anchor counts only when the
|
|
33
|
+
* range covers it whole: a partially covered atom is not deleted by the
|
|
34
|
+
* replacement either.
|
|
35
|
+
*/
|
|
36
|
+
declare const surveyReplacedAnnotations: (doc: Node, from: number, to: number) => ReplacedAnnotations;
|
|
37
|
+
type AnnotatedReplacementOptions = {
|
|
38
|
+
annotations: ReplacedAnnotations;
|
|
39
|
+
/** The replacement's own inline content, already carrying its formatting. */
|
|
40
|
+
content: Fragment;
|
|
41
|
+
};
|
|
42
|
+
type AnnotatedReplacement = {
|
|
43
|
+
fragment: Fragment;
|
|
44
|
+
/** Size of the anchors restored before the replacement's own content. */
|
|
45
|
+
leadingSize: number;
|
|
46
|
+
/** Size of the replacement's own content, once the marks are on it. */
|
|
47
|
+
contentSize: number;
|
|
48
|
+
};
|
|
49
|
+
/** `marks` with the carried marks added, each type's exclusions respected. */
|
|
50
|
+
declare const addCarriedMarks: (marks: readonly Mark[], carried: readonly Mark[]) => readonly Mark[];
|
|
51
|
+
/** `content` with the surveyed marks on it and the surveyed anchors around it. */
|
|
52
|
+
declare const annotatedReplacement: ({ annotations: { carried, leading, trailing }, content }: AnnotatedReplacementOptions) => AnnotatedReplacement;
|
|
53
|
+
/**
|
|
54
|
+
* The marks a replacement inherits at `[from, to)`, exactly as
|
|
55
|
+
* `Transaction.insertText` would compute them.
|
|
56
|
+
*/
|
|
57
|
+
declare const inheritedReplacementMarks: (doc: Node, from: number, to: number) => readonly Mark[];
|
|
58
|
+
//#endregion
|
|
59
|
+
export { NON_INCLUSIVE_MARK_DISPOSITION, ReplacedAnnotations, addCarriedMarks, annotatedReplacement, hasReplacedAnnotations, inheritedReplacementMarks, nonInclusiveMarkNames, surveyReplacedAnnotations };
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { BOOKMARK_BOUNDARY_NODE_NAME } from "./extensions/nodes/BookmarkBoundaryExtension.js";
|
|
2
|
+
import { COMMENT_REFERENCE_NODE_NAME } from "./extensions/nodes/CommentReferenceExtension.js";
|
|
3
|
+
import { TEXT_BOX_ANCHOR_NODE_NAME } from "./extensions/nodes/TextBoxAnchorExtension.js";
|
|
4
|
+
import { Fragment, Mark } from "prosemirror-model";
|
|
5
|
+
//#region src/prosemirror/replacedAnnotations.ts
|
|
6
|
+
/**
|
|
7
|
+
* What survives when an edit replaces a span of inline content.
|
|
8
|
+
*
|
|
9
|
+
* ProseMirror gives a replacement the marks it inherits at the boundary, and
|
|
10
|
+
* drops any mark declared `inclusive: false` once the span reaches the end of
|
|
11
|
+
* what that mark covers. For formatting that is right. For a mark that names
|
|
12
|
+
* something outside itself — the comment this text is commented by, the
|
|
13
|
+
* address this text links to — it is not: the target survives the edit, and
|
|
14
|
+
* only the mark saying so is lost. A comment loses the range start that lived
|
|
15
|
+
* on the replaced text, so the save emits a `commentRangeEnd` with no
|
|
16
|
+
* `commentRangeStart`, invalid OOXML and a comment anchored to nothing; a
|
|
17
|
+
* hyperlink simply stops being a link. Zero-width anchors fare worse still: a
|
|
18
|
+
* plain replace deletes them outright.
|
|
19
|
+
*
|
|
20
|
+
* Word moves a range start that sits inside a replaced span to the beginning
|
|
21
|
+
* of the replacement and lets the range keep covering the new text; it keeps
|
|
22
|
+
* a link across a replacement of its display text. A range wholly inside the
|
|
23
|
+
* span collapses onto the replacement, and disappears only when every
|
|
24
|
+
* character it covered is gone. One rule per marker kind, and that is the
|
|
25
|
+
* whole contract:
|
|
26
|
+
*
|
|
27
|
+
* - `comment` mark: the replacement carries every comment the span covered, so
|
|
28
|
+
* a range that started inside it starts at the replacement instead.
|
|
29
|
+
* - `hyperlink` mark: the replacement carries the first link the span held, so
|
|
30
|
+
* replacing a link's display text leaves the link on the new text. A span
|
|
31
|
+
* crossing two links keeps the one it opens in, because the mark excludes
|
|
32
|
+
* itself and a replacement is one run of text with one address.
|
|
33
|
+
* - `footnoteRef` mark (footnotes and endnotes alike): not carried. It marks
|
|
34
|
+
* the reference's own number, not prose around it, and it serializes as a
|
|
35
|
+
* bare `w:footnoteReference` run, so carrying it onto a replacement would
|
|
36
|
+
* discard the new text. Replacing a reference's text deletes the reference,
|
|
37
|
+
* as deleting that text does.
|
|
38
|
+
* - `pageBreakRunOwner` mark: not carried. It is editor-only identity for one
|
|
39
|
+
* authored run, not a target, and carrying it would fuse the replacement
|
|
40
|
+
* into a run it was never part of.
|
|
41
|
+
* - tracked-change marks (`insertion`, `deletion`, `runPropertyChange`): not
|
|
42
|
+
* carried. The applier decides them per edit mode and writes them itself.
|
|
43
|
+
* - `inlineWrapper` mark: not carried. Every wrapper kind states something
|
|
44
|
+
* about the text under it and names nothing outside itself, so boundary
|
|
45
|
+
* inheritance is the right rule: a replacement inside a bidirectional
|
|
46
|
+
* override is still inside it, and one that replaces the whole of it is not.
|
|
47
|
+
* - `commentReference` node: kept after the replacement, where the comment's
|
|
48
|
+
* last covered position now is.
|
|
49
|
+
* - `bookmarkBoundary` node: a start kept before the replacement, an end after
|
|
50
|
+
* it, so the bookmark still covers the new text.
|
|
51
|
+
* - `textBoxAnchor` node: kept after the replacement; the shape it anchors
|
|
52
|
+
* outlives the sentence it was typed into.
|
|
53
|
+
* - `renderedPageBreak` node: dropped with the text. It is Word's cached
|
|
54
|
+
* pagination, re-derived on layout, and nothing else names it.
|
|
55
|
+
* - every other mark: formatting, and left to boundary inheritance, which
|
|
56
|
+
* already gives the replacement the formatting of the text it replaces.
|
|
57
|
+
*
|
|
58
|
+
* Deleting the whole of a comment's span leaves it no mark anywhere, so
|
|
59
|
+
* `CommentReferenceExtension` drops the orphan reference and the save drops
|
|
60
|
+
* the comment: the one case where a range is meant to disappear.
|
|
61
|
+
*/
|
|
62
|
+
/**
|
|
63
|
+
* What a replacement does with each mark the schema declares
|
|
64
|
+
* `inclusive: false`. Boundary inheritance already handles every other mark,
|
|
65
|
+
* so this table is exactly the set that needs a decision; a new
|
|
66
|
+
* non-inclusive mark that is missing from it fails
|
|
67
|
+
* `replacedAnnotations.test.ts` rather than silently following the text.
|
|
68
|
+
*/
|
|
69
|
+
const NON_INCLUSIVE_MARK_DISPOSITION = {
|
|
70
|
+
comment: "carry",
|
|
71
|
+
hyperlink: "carry",
|
|
72
|
+
footnoteRef: "followsTheText",
|
|
73
|
+
pageBreakRunOwner: "followsTheText",
|
|
74
|
+
insertion: "followsTheText",
|
|
75
|
+
deletion: "followsTheText",
|
|
76
|
+
runPropertyChange: "followsTheText",
|
|
77
|
+
inlineWrapper: "followsTheText"
|
|
78
|
+
};
|
|
79
|
+
/** The mark names in the schema that a replacement must not silently drop. */
|
|
80
|
+
const nonInclusiveMarkNames = (schema) => Object.entries(schema.marks).filter(([, type]) => type.spec.inclusive === false).map(([name]) => name);
|
|
81
|
+
const isCarried = (mark) => NON_INCLUSIVE_MARK_DISPOSITION[mark.type.name] === "carry";
|
|
82
|
+
/** Anchors an edit must put back, and where relative to the replacement. */
|
|
83
|
+
const ANCHOR_PLACEMENT = {
|
|
84
|
+
[COMMENT_REFERENCE_NODE_NAME]: "after",
|
|
85
|
+
[TEXT_BOX_ANCHOR_NODE_NAME]: "after",
|
|
86
|
+
[BOOKMARK_BOUNDARY_NODE_NAME]: "byBoundaryType"
|
|
87
|
+
};
|
|
88
|
+
const anchorPlacement = (node) => ANCHOR_PLACEMENT[node.type.name];
|
|
89
|
+
const NOTHING_REPLACED = {
|
|
90
|
+
carried: [],
|
|
91
|
+
leading: [],
|
|
92
|
+
trailing: []
|
|
93
|
+
};
|
|
94
|
+
const hasReplacedAnnotations = ({ carried, leading, trailing }) => carried.length > 0 || leading.length > 0 || trailing.length > 0;
|
|
95
|
+
/**
|
|
96
|
+
* The annotations carried by `[from, to)`. An anchor counts only when the
|
|
97
|
+
* range covers it whole: a partially covered atom is not deleted by the
|
|
98
|
+
* replacement either.
|
|
99
|
+
*/
|
|
100
|
+
const surveyReplacedAnnotations = (doc, from, to) => {
|
|
101
|
+
if (to <= from) return NOTHING_REPLACED;
|
|
102
|
+
const carried = [];
|
|
103
|
+
const leading = [];
|
|
104
|
+
const trailing = [];
|
|
105
|
+
doc.nodesBetween(from, to, (node, position) => {
|
|
106
|
+
if (!node.isInline) return true;
|
|
107
|
+
for (const mark of node.marks) if (isCarried(mark) && !alreadyCarried(mark, carried)) carried.push(mark);
|
|
108
|
+
const placement = anchorPlacement(node);
|
|
109
|
+
if (placement === void 0 || position < from || position + node.nodeSize > to) return false;
|
|
110
|
+
(placement === "byBoundaryType" && node.attrs["type"] === "start" ? leading : trailing).push(node);
|
|
111
|
+
return false;
|
|
112
|
+
});
|
|
113
|
+
return {
|
|
114
|
+
carried,
|
|
115
|
+
leading,
|
|
116
|
+
trailing
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
/**
|
|
120
|
+
* Whether the span already contributed this mark, or one the mark would evict.
|
|
121
|
+
* Comments do not exclude each other, so every comment is collected; a
|
|
122
|
+
* hyperlink excludes its own type, so the first address in the span wins
|
|
123
|
+
* rather than the last silently overwriting it.
|
|
124
|
+
*/
|
|
125
|
+
const alreadyCarried = (mark, carried) => carried.some((other) => other.eq(mark) || mark.type.excludes(other.type));
|
|
126
|
+
const anchorsSize = (anchors) => {
|
|
127
|
+
let size = 0;
|
|
128
|
+
for (const node of anchors) size += node.nodeSize;
|
|
129
|
+
return size;
|
|
130
|
+
};
|
|
131
|
+
/** `marks` with the carried marks added, each type's exclusions respected. */
|
|
132
|
+
const addCarriedMarks = (marks, carried) => {
|
|
133
|
+
let next = marks;
|
|
134
|
+
for (const mark of carried) next = mark.addToSet(next);
|
|
135
|
+
return next;
|
|
136
|
+
};
|
|
137
|
+
const withCarriedMarks = (node, carried) => node.mark(addCarriedMarks(node.marks, carried));
|
|
138
|
+
/** `content` with the surveyed marks on it and the surveyed anchors around it. */
|
|
139
|
+
const annotatedReplacement = ({ annotations: { carried, leading, trailing }, content }) => {
|
|
140
|
+
const inline = [];
|
|
141
|
+
content.forEach((child) => {
|
|
142
|
+
inline.push(carried.length === 0 ? child : withCarriedMarks(child, carried));
|
|
143
|
+
});
|
|
144
|
+
const fragment = Fragment.fromArray([
|
|
145
|
+
...leading,
|
|
146
|
+
...inline,
|
|
147
|
+
...trailing
|
|
148
|
+
]);
|
|
149
|
+
const leadingSize = anchorsSize(leading);
|
|
150
|
+
return {
|
|
151
|
+
fragment,
|
|
152
|
+
leadingSize,
|
|
153
|
+
contentSize: fragment.size - leadingSize - anchorsSize(trailing)
|
|
154
|
+
};
|
|
155
|
+
};
|
|
156
|
+
/**
|
|
157
|
+
* The marks a replacement inherits at `[from, to)`, exactly as
|
|
158
|
+
* `Transaction.insertText` would compute them.
|
|
159
|
+
*/
|
|
160
|
+
const inheritedReplacementMarks = (doc, from, to) => {
|
|
161
|
+
const $from = doc.resolve(from);
|
|
162
|
+
return (to === from ? $from.marks() : $from.marksAcross(doc.resolve(to))) ?? Mark.none;
|
|
163
|
+
};
|
|
164
|
+
//#endregion
|
|
165
|
+
export { NON_INCLUSIVE_MARK_DISPOSITION, addCarriedMarks, annotatedReplacement, hasReplacedAnnotations, inheritedReplacementMarks, nonInclusiveMarkNames, surveyReplacedAnnotations };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Transaction } from "prosemirror-state";
|
|
2
2
|
import { Mark, Node } from "prosemirror-model";
|
|
3
3
|
//#region src/prosemirror/runFormattingInlineCarriers.d.ts
|
|
4
|
-
type RunFormattingInlineAtomDisposition = "break-run" | "field-run" | "not-a-run" | "page-break-carrier" | "structured-field" | "symbol-run" | "tab-run" | "text-run";
|
|
4
|
+
type RunFormattingInlineAtomDisposition = "break-run" | "field-run" | "not-a-run" | "page-break-carrier" | "preserved-xml-run" | "structured-field" | "symbol-run" | "tab-run" | "text-run";
|
|
5
5
|
/**
|
|
6
6
|
* How every inline atom maps to a serialized run-formatting carrier.
|
|
7
7
|
*
|
|
@@ -12,11 +12,13 @@ type RunFormattingInlineAtomDisposition = "break-run" | "field-run" | "not-a-run
|
|
|
12
12
|
*/
|
|
13
13
|
declare const RUN_FORMATTING_INLINE_ATOM_DISPOSITIONS: Readonly<{
|
|
14
14
|
readonly bookmarkBoundary: "not-a-run";
|
|
15
|
+
readonly commentReference: "not-a-run";
|
|
15
16
|
readonly field: "field-run";
|
|
16
17
|
readonly hardBreak: "break-run";
|
|
17
18
|
readonly image: "not-a-run";
|
|
18
19
|
readonly math: "not-a-run";
|
|
19
20
|
readonly pageBreakRun: "page-break-carrier";
|
|
21
|
+
readonly preservedXml: "preserved-xml-run";
|
|
20
22
|
readonly renderedPageBreak: "not-a-run";
|
|
21
23
|
readonly shape: "not-a-run";
|
|
22
24
|
readonly structuredField: "structured-field";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { decodeOoxmlSymbolCharacter } from "../utils/ooxmlSymbol.js";
|
|
2
|
-
import { expectFieldAttrs, expectSymbolAttrs } from "./attrs/index.js";
|
|
2
|
+
import { expectFieldAttrs, expectPreservedXmlAttrs, expectSymbolAttrs } from "./attrs/index.js";
|
|
3
3
|
import { panic } from "better-result";
|
|
4
4
|
import { Mark } from "prosemirror-model";
|
|
5
5
|
//#region src/prosemirror/runFormattingInlineCarriers.ts
|
|
@@ -13,11 +13,13 @@ import { Mark } from "prosemirror-model";
|
|
|
13
13
|
*/
|
|
14
14
|
const RUN_FORMATTING_INLINE_ATOM_DISPOSITIONS = Object.freeze({
|
|
15
15
|
bookmarkBoundary: "not-a-run",
|
|
16
|
+
commentReference: "not-a-run",
|
|
16
17
|
field: "field-run",
|
|
17
18
|
hardBreak: "break-run",
|
|
18
19
|
image: "not-a-run",
|
|
19
20
|
math: "not-a-run",
|
|
20
21
|
pageBreakRun: "page-break-carrier",
|
|
22
|
+
preservedXml: "preserved-xml-run",
|
|
21
23
|
renderedPageBreak: "not-a-run",
|
|
22
24
|
shape: "not-a-run",
|
|
23
25
|
structuredField: "structured-field",
|
|
@@ -32,6 +34,7 @@ const CONTROL_CHARACTER_BY_DISPOSITION = Object.freeze({
|
|
|
32
34
|
"field-run": null,
|
|
33
35
|
"not-a-run": null,
|
|
34
36
|
"page-break-carrier": null,
|
|
37
|
+
"preserved-xml-run": null,
|
|
35
38
|
"structured-field": null,
|
|
36
39
|
"symbol-run": null,
|
|
37
40
|
"tab-run": " ",
|
|
@@ -162,6 +165,7 @@ const runFormattingCarrierReviewText = (carrier) => {
|
|
|
162
165
|
const { char } = expectSymbolAttrs(carrier.node);
|
|
163
166
|
return decodeOoxmlSymbolCharacter(char) ?? "�";
|
|
164
167
|
}
|
|
168
|
+
case "preserved-xml-run": return expectPreservedXmlAttrs(carrier.node).text;
|
|
165
169
|
case "field-run":
|
|
166
170
|
case "structured-field": return expectFieldAttrs(carrier.node).displayText ?? carrier.node.textContent;
|
|
167
171
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CharacterSpacingAttrs, CharacterStyleAttrs, CommentAttrs, EmphasisMarkAttrs, FontFamilyAttrs, FontSizeAttrs, FootnoteRefAttrs, HighlightAttrs, HyperlinkAttrs, LanguageAttrs, PageBreakRunOwnerMarkAttrs, RunFormattingOverrideAttrs, RunPropertyChangeMarkAttrs, RunShadingAttrs, StrikeAttrs, TextColorAttrs, TextEffectAttrs, TrackedChangeMarkAttrs, UnderlineAttrs } from "./marks.js";
|
|
2
|
-
import { BlockSdtAttrs, BookmarkBoundaryAttrs, FieldAttrs, HardBreakAttrs, ImageAttrs, ImagePositionAttrs, MathAttrs, PageBreakRunAttrs, ParagraphAttrs, ParagraphPropertyChangeAttrs, SdtAttrs, ShapeAttrs, SymbolAttrs, TabAttrs, TableAttrs, TableCellAttrs, TableRowAttrs, TextBoxAttrs } from "./nodes.js";
|
|
1
|
+
import { CharacterSpacingAttrs, CharacterStyleAttrs, CommentAttrs, EmphasisMarkAttrs, FontFamilyAttrs, FontSizeAttrs, FootnoteRefAttrs, HighlightAttrs, HyperlinkAttrs, InlineWrapperAttrs, InlineWrapperKind, InlineWrapperLayer, LanguageAttrs, PageBreakRunOwnerMarkAttrs, RunFormattingOverrideAttrs, RunPropertyChangeMarkAttrs, RunShadingAttrs, StrikeAttrs, TextColorAttrs, TextEffectAttrs, TrackedChangeMarkAttrs, UnderlineAttrs } from "./marks.js";
|
|
2
|
+
import { BlockSdtAttrs, BookmarkBoundaryAttrs, FieldAttrs, HardBreakAttrs, ImageAttrs, ImagePositionAttrs, MathAttrs, PageBreakRunAttrs, ParagraphAttrs, ParagraphPropertyChangeAttrs, PreservedBlockAttrs, PreservedXmlAttrs, PreservedXmlLevel, SdtAttrs, ShapeAttrs, SymbolAttrs, TabAttrs, TableAttrs, TableCellAttrs, TableRowAttrs, TextBoxAttrs } from "./nodes.js";
|
|
3
3
|
import { ExtensionManager } from "../extensions/ExtensionManager.js";
|
|
4
4
|
//#region src/prosemirror/schema/index.d.ts
|
|
5
5
|
declare const singletonManager: ExtensionManager;
|
|
@@ -11,4 +11,4 @@ type DocxSchema = typeof schema;
|
|
|
11
11
|
type DocxNode = ReturnType<typeof schema.node>;
|
|
12
12
|
type DocxMark = ReturnType<typeof schema.mark>;
|
|
13
13
|
//#endregion
|
|
14
|
-
export { type BlockSdtAttrs, type BookmarkBoundaryAttrs, type CharacterSpacingAttrs, type CharacterStyleAttrs, type CommentAttrs, DocxMark, DocxNode, DocxSchema, type EmphasisMarkAttrs, type FieldAttrs, type FontFamilyAttrs, type FontSizeAttrs, type FootnoteRefAttrs, type HardBreakAttrs, type HighlightAttrs, type HyperlinkAttrs, type ImageAttrs, type ImagePositionAttrs, type LanguageAttrs, type MathAttrs, type PageBreakRunAttrs, type PageBreakRunOwnerMarkAttrs, type ParagraphAttrs, type ParagraphPropertyChangeAttrs, type RunFormattingOverrideAttrs, type RunPropertyChangeMarkAttrs, type RunShadingAttrs, type SdtAttrs, type ShapeAttrs, type StrikeAttrs, type SymbolAttrs, type TabAttrs, type TableAttrs, type TableCellAttrs, type TableRowAttrs, type TextBoxAttrs, type TextColorAttrs, type TextEffectAttrs, type TrackedChangeMarkAttrs, type UnderlineAttrs, schema, singletonManager };
|
|
14
|
+
export { type BlockSdtAttrs, type BookmarkBoundaryAttrs, type CharacterSpacingAttrs, type CharacterStyleAttrs, type CommentAttrs, DocxMark, DocxNode, DocxSchema, type EmphasisMarkAttrs, type FieldAttrs, type FontFamilyAttrs, type FontSizeAttrs, type FootnoteRefAttrs, type HardBreakAttrs, type HighlightAttrs, type HyperlinkAttrs, type ImageAttrs, type ImagePositionAttrs, type InlineWrapperAttrs, type InlineWrapperKind, type InlineWrapperLayer, type LanguageAttrs, type MathAttrs, type PageBreakRunAttrs, type PageBreakRunOwnerMarkAttrs, type ParagraphAttrs, type ParagraphPropertyChangeAttrs, type PreservedBlockAttrs, type PreservedXmlAttrs, type PreservedXmlLevel, type RunFormattingOverrideAttrs, type RunPropertyChangeMarkAttrs, type RunShadingAttrs, type SdtAttrs, type ShapeAttrs, type StrikeAttrs, type SymbolAttrs, type TabAttrs, type TableAttrs, type TableCellAttrs, type TableRowAttrs, type TextBoxAttrs, type TextColorAttrs, type TextEffectAttrs, type TrackedChangeMarkAttrs, type UnderlineAttrs, schema, singletonManager };
|
|
@@ -127,6 +127,30 @@ type RunPropertyChangeMarkAttrs = {
|
|
|
127
127
|
type PageBreakRunOwnerMarkAttrs = {
|
|
128
128
|
id: number;
|
|
129
129
|
};
|
|
130
|
+
/**
|
|
131
|
+
* One transparent wrapper a leaf sits inside, minus the content ProseMirror
|
|
132
|
+
* now holds instead.
|
|
133
|
+
*
|
|
134
|
+
* Distributed over the model's union rather than written out beside it: a
|
|
135
|
+
* wrapper kind exists in both places or in neither, and the fields a kind
|
|
136
|
+
* carries are stated once. A smart tag cannot gain a `control` this way, and
|
|
137
|
+
* a kind added to the model reaches the editor as a compile error at every
|
|
138
|
+
* site that decides per kind.
|
|
139
|
+
*/
|
|
140
|
+
type WrapperLayer<Wrapper> = Wrapper extends unknown ? Omit<Wrapper, "type" | "content"> : never;
|
|
141
|
+
type InlineWrapperLayer = WrapperLayer<document_d_exports.InlineWrapper>;
|
|
142
|
+
type InlineWrapperKind = InlineWrapperLayer["kind"];
|
|
143
|
+
/**
|
|
144
|
+
* The wrappers a leaf sits inside, outermost first.
|
|
145
|
+
*
|
|
146
|
+
* Multiplicity lives here rather than in the mark set: ProseMirror marks are
|
|
147
|
+
* unordered across types and a mark excludes its own type, so nesting a
|
|
148
|
+
* wrapper inside another cannot be spelled as two marks. `null` is no
|
|
149
|
+
* wrapper; an empty stack is never stored.
|
|
150
|
+
*/
|
|
151
|
+
type InlineWrapperAttrs = {
|
|
152
|
+
stack: readonly InlineWrapperLayer[];
|
|
153
|
+
};
|
|
130
154
|
declare const COMPLEX_SCRIPT_RUN_PROPERTY_KEYS: readonly ["boldCs", "italicCs", "fontSizeCs"];
|
|
131
155
|
type ComplexScriptRunPropertyKey = (typeof COMPLEX_SCRIPT_RUN_PROPERTY_KEYS)[number];
|
|
132
156
|
declare const RUN_FORMATTING_BOOLEAN_PROPERTIES: readonly ["bold", "boldCs", "italic", "italicCs", "strike", "doubleStrike", "smallCaps", "allCaps", "hidden", "noProof", "emboss", "imprint", "outline", "shadow", "rtl", "cs"];
|
|
@@ -231,4 +255,4 @@ type HyperlinkAttrs = {
|
|
|
231
255
|
_docxHyperlinkIndex?: number;
|
|
232
256
|
};
|
|
233
257
|
//#endregion
|
|
234
|
-
export { AuthoredRunFormattingValues, COMPLEX_SCRIPT_RUN_PROPERTY_KEYS, CharacterSpacingAttrs, CharacterStyleAttrs, CommentAttrs, ComplexScriptRunPropertyKey, EmphasisMarkAttrs, FontFamilyAttrs, FontSizeAttrs, FootnoteRefAttrs, HighlightAttrs, HyperlinkAttrs, LanguageAttrs, PageBreakRunOwnerMarkAttrs, RUN_FORMATTING_BOOLEAN_PROPERTIES, RUN_FORMATTING_PROPERTY_SPECS, RUN_FORMATTING_VALUE_PROPERTIES, RunFormattingBooleanProperty, RunFormattingOverrideAttrs, RunFormattingValueProperty, RunPropertyChangeMarkAttrs, RunShadingAttrs, StrikeAttrs, TRACKED_CHANGE_PROVENANCE_VALUES, TextColorAttrs, TextEffectAttrs, TrackedChangeMarkAttrs, TrackedChangeProvenance, UnderlineAttrs };
|
|
258
|
+
export { AuthoredRunFormattingValues, COMPLEX_SCRIPT_RUN_PROPERTY_KEYS, CharacterSpacingAttrs, CharacterStyleAttrs, CommentAttrs, ComplexScriptRunPropertyKey, EmphasisMarkAttrs, FontFamilyAttrs, FontSizeAttrs, FootnoteRefAttrs, HighlightAttrs, HyperlinkAttrs, InlineWrapperAttrs, InlineWrapperKind, InlineWrapperLayer, LanguageAttrs, PageBreakRunOwnerMarkAttrs, RUN_FORMATTING_BOOLEAN_PROPERTIES, RUN_FORMATTING_PROPERTY_SPECS, RUN_FORMATTING_VALUE_PROPERTIES, RunFormattingBooleanProperty, RunFormattingOverrideAttrs, RunFormattingValueProperty, RunPropertyChangeMarkAttrs, RunShadingAttrs, StrikeAttrs, TRACKED_CHANGE_PROVENANCE_VALUES, TextColorAttrs, TextEffectAttrs, TrackedChangeMarkAttrs, TrackedChangeProvenance, UnderlineAttrs };
|
|
@@ -21,6 +21,35 @@ type SymbolAttrs = {
|
|
|
21
21
|
font: string;
|
|
22
22
|
char: string;
|
|
23
23
|
};
|
|
24
|
+
/** A run child folio does not model, carried through the editor untouched. */
|
|
25
|
+
/**
|
|
26
|
+
* Which container the captured markup came out of, and goes back into.
|
|
27
|
+
*
|
|
28
|
+
* `w:ruby` is a run child and has to be written back inside a `w:r`;
|
|
29
|
+
* `w:permStart` is a paragraph child and the schema admits none inside a run,
|
|
30
|
+
* so writing one there would produce a package Word repairs. One atom serves
|
|
31
|
+
* both because the editor treats them identically — opaque, zero-width unless
|
|
32
|
+
* the markup shows text, carrying whatever marks surround it — and only the
|
|
33
|
+
* save path has to tell them apart.
|
|
34
|
+
*/
|
|
35
|
+
declare const PRESERVED_XML_LEVELS: {
|
|
36
|
+
readonly run: "run";
|
|
37
|
+
readonly inline: "inline";
|
|
38
|
+
};
|
|
39
|
+
type PreservedXmlLevel = (typeof PRESERVED_XML_LEVELS)[keyof typeof PRESERVED_XML_LEVELS];
|
|
40
|
+
/** A run or inline child folio does not model, carried through the editor untouched. */
|
|
41
|
+
type PreservedXmlAttrs = {
|
|
42
|
+
/** Replayable markup, as `captureVerbatimXml` wrote it. */
|
|
43
|
+
xml: string;
|
|
44
|
+
/** The visible text the markup puts on the line, empty when it shows none. */
|
|
45
|
+
text: string;
|
|
46
|
+
level: PreservedXmlLevel;
|
|
47
|
+
};
|
|
48
|
+
/** A block child folio does not model, carried through the editor untouched. */
|
|
49
|
+
type PreservedBlockAttrs = {
|
|
50
|
+
/** Replayable markup, as `captureVerbatimXml` wrote it. */
|
|
51
|
+
xml: string;
|
|
52
|
+
};
|
|
24
53
|
type BookmarkBoundaryAttrs = {
|
|
25
54
|
type: "start";
|
|
26
55
|
id: number;
|
|
@@ -33,6 +62,14 @@ type BookmarkBoundaryAttrs = {
|
|
|
33
62
|
id: number;
|
|
34
63
|
displacedByCustomXml?: document_d_exports.DisplacedByCustomXml;
|
|
35
64
|
};
|
|
65
|
+
/**
|
|
66
|
+
* The position of a comment's `w:commentReference`: the run that paints the
|
|
67
|
+
* visible comment mark. It is authored data, not a consequence of where the
|
|
68
|
+
* range ends, so the editor carries it as a node of its own.
|
|
69
|
+
*/
|
|
70
|
+
type CommentReferenceAttrs = {
|
|
71
|
+
commentId: number;
|
|
72
|
+
};
|
|
36
73
|
/**
|
|
37
74
|
* Paragraph node attributes - maps to ParagraphFormatting
|
|
38
75
|
*/
|
|
@@ -213,6 +250,17 @@ type ParagraphAttrs = {
|
|
|
213
250
|
/** Full section properties for paragraphs that end a section.
|
|
214
251
|
* Used by layout engine for per-section column/page config and round-trip. */
|
|
215
252
|
_sectionProperties?: document_d_exports.SectionProperties;
|
|
253
|
+
/**
|
|
254
|
+
* Attributes the authored `w:p` carried and the model has no field for
|
|
255
|
+
* (`w:rsidR` and its family), carried opaquely so an edit does not rewrite
|
|
256
|
+
* the document's revision history.
|
|
257
|
+
*
|
|
258
|
+
* The remainder follows the record. ProseMirror copies a node's attrs to
|
|
259
|
+
* both halves of a split, so `fromProseDoc` gives it to the first paragraph
|
|
260
|
+
* that carries it and to no other: a paragraph the editor created never had
|
|
261
|
+
* those attributes and must not inherit them from a neighbour.
|
|
262
|
+
*/
|
|
263
|
+
_preservedAttributes?: document_d_exports.PreservedAttribute[];
|
|
216
264
|
/** Paragraph-property-change tracking entries (`w:pPrChange`).
|
|
217
265
|
* Preserved opaquely through ProseMirror — the editor does not surface
|
|
218
266
|
* them in UI today, but stripping them on every edit would corrupt the
|
|
@@ -302,13 +350,23 @@ type ImageAttrs = {
|
|
|
302
350
|
displayMode?: "inline" | "float" | "block";
|
|
303
351
|
/** CSS float direction for floating images */
|
|
304
352
|
cssFloat?: "left" | "right" | "none";
|
|
305
|
-
/** CSS transform string
|
|
353
|
+
/** CSS transform string, derived from the authored transform below. */
|
|
306
354
|
transform?: string;
|
|
355
|
+
/** Authored `a:xfrm@rot` in degrees; `null` when the drawing states none. */
|
|
356
|
+
docxRotation?: number | null;
|
|
357
|
+
/** Authored `a:xfrm@flipH`; `null` when the drawing states none. */
|
|
358
|
+
docxFlipH?: boolean | null;
|
|
359
|
+
/** Authored `a:xfrm@flipV`; `null` when the drawing states none. */
|
|
360
|
+
docxFlipV?: boolean | null;
|
|
307
361
|
/**
|
|
308
362
|
* Opacity in [0, 1] from `<a:alphaModFix amt>`. Undefined / 1 means fully
|
|
309
363
|
* opaque (no CSS `opacity` emitted). eigenpal #424.
|
|
310
364
|
*/
|
|
311
365
|
opacity?: number;
|
|
366
|
+
/** DrawingML `a:lum@bright` as a signed percentage in [-100, 100]. */
|
|
367
|
+
brightness?: number;
|
|
368
|
+
/** DrawingML `a:lum@contrast` as a signed percentage in [-100, 100]. */
|
|
369
|
+
contrast?: number;
|
|
312
370
|
/** Distance from text above (pixels) */
|
|
313
371
|
distTop?: number;
|
|
314
372
|
/** Distance from text below (pixels) */
|
|
@@ -537,8 +595,14 @@ type ShapeAttrs = {
|
|
|
537
595
|
outlineHeadEnd?: NonNullable<document_d_exports.ShapeOutline["headEnd"]>;
|
|
538
596
|
/** Tail arrow/end marker */
|
|
539
597
|
outlineTailEnd?: NonNullable<document_d_exports.ShapeOutline["tailEnd"]>;
|
|
540
|
-
/** CSS transform */
|
|
598
|
+
/** CSS transform, derived from the authored transform below. */
|
|
541
599
|
transform?: string;
|
|
600
|
+
/** Authored `a:xfrm@rot` in degrees; `null` when the drawing states none. */
|
|
601
|
+
docxRotation?: number | null;
|
|
602
|
+
/** Authored `a:xfrm@flipH`; `null` when the drawing states none. */
|
|
603
|
+
docxFlipH?: boolean | null;
|
|
604
|
+
/** Authored `a:xfrm@flipV`; `null` when the drawing states none. */
|
|
605
|
+
docxFlipV?: boolean | null;
|
|
542
606
|
/** Display mode */
|
|
543
607
|
displayMode?: "inline" | "float" | "block";
|
|
544
608
|
/** CSS float */
|
|
@@ -618,6 +682,12 @@ type TextBoxAttrs = {
|
|
|
618
682
|
outlineStyle?: OutlineStyleAttr;
|
|
619
683
|
/** DrawingML rotation and/or flips, serialized as CSS transform functions. */
|
|
620
684
|
transform?: string;
|
|
685
|
+
/** Authored `a:xfrm@rot` in degrees; `null` when the drawing states none. */
|
|
686
|
+
docxRotation?: number | null;
|
|
687
|
+
/** Authored `a:xfrm@flipH`; `null` when the drawing states none. */
|
|
688
|
+
docxFlipH?: boolean | null;
|
|
689
|
+
/** Authored `a:xfrm@flipV`; `null` when the drawing states none. */
|
|
690
|
+
docxFlipV?: boolean | null;
|
|
621
691
|
/** Internal margin top in pixels */
|
|
622
692
|
marginTop?: number;
|
|
623
693
|
/** Internal margin bottom in pixels */
|
|
@@ -674,6 +744,17 @@ type TextBoxAttrs = {
|
|
|
674
744
|
};
|
|
675
745
|
/** Original inline content-control ancestry for save-path reconstruction. */
|
|
676
746
|
_docxInlineSdts?: SdtAttrs[];
|
|
747
|
+
/**
|
|
748
|
+
* The attribute remainder of the `w:p` this node was lifted out of.
|
|
749
|
+
*
|
|
750
|
+
* A paragraph whose only content was an anchored drawing has no paragraph
|
|
751
|
+
* node in the editor: this node stands in for it, so it carries the host's
|
|
752
|
+
* remainder the way `ParagraphAttrs._preservedAttributes` carries a
|
|
753
|
+
* paragraph's own. Only a `"standalone"` placement has a host to speak for;
|
|
754
|
+
* an `"inlineWithPrevious"` text box sits in a paragraph that is projected
|
|
755
|
+
* itself and keeps its own.
|
|
756
|
+
*/
|
|
757
|
+
_preservedAttributes?: document_d_exports.PreservedAttribute[];
|
|
677
758
|
};
|
|
678
759
|
/** Internal inline position marker for an extracted text box block. */
|
|
679
760
|
type TextBoxAnchorAttrs = {
|
|
@@ -748,6 +829,12 @@ type TableRowAttrs = {
|
|
|
748
829
|
_originalFormatting?: document_d_exports.TableRowFormatting;
|
|
749
830
|
/** Tracked row property changes (w:trPrChange) for round-trip + accept/reject */
|
|
750
831
|
trPrChange?: document_d_exports.TableRowPropertyChange[];
|
|
832
|
+
/**
|
|
833
|
+
* Attributes the authored `w:tr` carried and the model has no field for
|
|
834
|
+
* (`w:rsidR`, `w:rsidDel`, `w:rsidTr`, `w:rsidRPr`), carried opaquely for
|
|
835
|
+
* the reason `ParagraphAttrs._preservedAttributes` gives.
|
|
836
|
+
*/
|
|
837
|
+
_preservedAttributes?: document_d_exports.PreservedAttribute[];
|
|
751
838
|
} & ({
|
|
752
839
|
/**
|
|
753
840
|
* Tracked structural row insertion (w:trPr/w:ins). A `"suggested"`
|
|
@@ -885,4 +972,4 @@ type TableCellAttrs = {
|
|
|
885
972
|
_docxVMergeContinuationCells?: unknown;
|
|
886
973
|
};
|
|
887
974
|
//#endregion
|
|
888
|
-
export { AuthoredEmuAttrs, BlockSdtAttrs, BookmarkBoundaryAttrs, FieldAttrs, HardBreakAttrs, ImageAttrs, ImagePositionAttrs, MathAttrs, PageBreakRunAttrs, ParagraphAttrs, ParagraphPropertyChangeAttrs, SdtAttrs, ShapeAttrs, SuggestedStructuralMarker, SymbolAttrs, TEXT_BOX_TEXT_BODY_CONTENT_STATE_TYPES, TabAttrs, TableAttrs, TableCellAttrs, TableRowAttrs, TextBoxAnchorAttrs, TextBoxAttrs, TextBoxTextBodyContentState };
|
|
975
|
+
export { AuthoredEmuAttrs, BlockSdtAttrs, BookmarkBoundaryAttrs, CommentReferenceAttrs, FieldAttrs, HardBreakAttrs, ImageAttrs, ImagePositionAttrs, MathAttrs, PRESERVED_XML_LEVELS, PageBreakRunAttrs, ParagraphAttrs, ParagraphPropertyChangeAttrs, PreservedBlockAttrs, PreservedXmlAttrs, PreservedXmlLevel, SdtAttrs, ShapeAttrs, SuggestedStructuralMarker, SymbolAttrs, TEXT_BOX_TEXT_BODY_CONTENT_STATE_TYPES, TabAttrs, TableAttrs, TableCellAttrs, TableRowAttrs, TextBoxAnchorAttrs, TextBoxAttrs, TextBoxTextBodyContentState };
|
|
@@ -1,7 +1,22 @@
|
|
|
1
1
|
//#region src/prosemirror/schema/nodes.ts
|
|
2
|
+
/** A run child folio does not model, carried through the editor untouched. */
|
|
3
|
+
/**
|
|
4
|
+
* Which container the captured markup came out of, and goes back into.
|
|
5
|
+
*
|
|
6
|
+
* `w:ruby` is a run child and has to be written back inside a `w:r`;
|
|
7
|
+
* `w:permStart` is a paragraph child and the schema admits none inside a run,
|
|
8
|
+
* so writing one there would produce a package Word repairs. One atom serves
|
|
9
|
+
* both because the editor treats them identically — opaque, zero-width unless
|
|
10
|
+
* the markup shows text, carrying whatever marks surround it — and only the
|
|
11
|
+
* save path has to tell them apart.
|
|
12
|
+
*/
|
|
13
|
+
const PRESERVED_XML_LEVELS = {
|
|
14
|
+
run: "run",
|
|
15
|
+
inline: "inline"
|
|
16
|
+
};
|
|
2
17
|
/**
|
|
3
18
|
* Text box node attributes
|
|
4
19
|
*/
|
|
5
20
|
const TEXT_BOX_TEXT_BODY_CONTENT_STATE_TYPES = Object.freeze(["source-empty", "authored"]);
|
|
6
21
|
//#endregion
|
|
7
|
-
export { TEXT_BOX_TEXT_BODY_CONTENT_STATE_TYPES };
|
|
22
|
+
export { PRESERVED_XML_LEVELS, TEXT_BOX_TEXT_BODY_CONTENT_STATE_TYPES };
|
|
@@ -11,11 +11,13 @@ type TrackedRunInlineAtomDisposition = "carry" | "field-carrier" | "outside-wrap
|
|
|
11
11
|
*/
|
|
12
12
|
declare const TRACKED_RUN_INLINE_ATOM_DISPOSITIONS: Readonly<{
|
|
13
13
|
readonly bookmarkBoundary: "carry";
|
|
14
|
+
readonly commentReference: "transparent";
|
|
14
15
|
readonly field: "field-carrier";
|
|
15
16
|
readonly hardBreak: "carry";
|
|
16
17
|
readonly image: "carry";
|
|
17
18
|
readonly math: "carry";
|
|
18
19
|
readonly pageBreakRun: "page-break-carrier";
|
|
20
|
+
readonly preservedXml: "carry";
|
|
19
21
|
readonly renderedPageBreak: "transparent";
|
|
20
22
|
readonly shape: "carry";
|
|
21
23
|
readonly structuredField: "carry";
|
|
@@ -10,11 +10,13 @@ import { panic } from "better-result";
|
|
|
10
10
|
*/
|
|
11
11
|
const TRACKED_RUN_INLINE_ATOM_DISPOSITIONS = Object.freeze({
|
|
12
12
|
bookmarkBoundary: "carry",
|
|
13
|
+
commentReference: "transparent",
|
|
13
14
|
field: "field-carrier",
|
|
14
15
|
hardBreak: "carry",
|
|
15
16
|
image: "carry",
|
|
16
17
|
math: "carry",
|
|
17
18
|
pageBreakRun: "page-break-carrier",
|
|
19
|
+
preservedXml: "carry",
|
|
18
20
|
renderedPageBreak: "transparent",
|
|
19
21
|
shape: "carry",
|
|
20
22
|
structuredField: "carry",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { readBlockSdtAttrs, readCharacterSpacingMarkAttrs, readCharacterStyleMarkAttrs, readCommentMarkAttrs, readEmphasisMarkAttrs, readFieldAttrs, readFontFamilyMarkAttrs, readFontSizeMarkAttrs, readFootnoteRefMarkAttrs, readHardBreakAttrs, readHighlightMarkAttrs, readHyperlinkMarkAttrs, readImageAttrs, readLanguageMarkAttrs, readMathAttrs, readPageBreakRunAttrs, readPageBreakRunOwnerMarkAttrs, readParagraphAttrs, readRunFormattingOverrideMarkAttrs, readRunPropertyChangeMarkAttrs, readRunShadingMarkAttrs, readSdtAttrs, readShapeAttrs, readStrikeMarkAttrs, readSymbolAttrs, readTabAttrs, readTableAttrs, readTableCellAttrs, readTableRowAttrs, readTextBoxAttrs, readTextColorMarkAttrs, readTextEffectMarkAttrs, readTrackedChangeMarkAttrs, readUnderlineMarkAttrs } from "./attrs/index.js";
|
|
1
|
+
import { readBlockSdtAttrs, readCharacterSpacingMarkAttrs, readCharacterStyleMarkAttrs, readCommentMarkAttrs, readEmphasisMarkAttrs, readFieldAttrs, readFontFamilyMarkAttrs, readFontSizeMarkAttrs, readFootnoteRefMarkAttrs, readHardBreakAttrs, readHighlightMarkAttrs, readHyperlinkMarkAttrs, readImageAttrs, readInlineWrapperMarkAttrs, readLanguageMarkAttrs, readMathAttrs, readPageBreakRunAttrs, readPageBreakRunOwnerMarkAttrs, readParagraphAttrs, readPreservedBlockAttrs, readPreservedXmlAttrs, readRunFormattingOverrideMarkAttrs, readRunPropertyChangeMarkAttrs, readRunShadingMarkAttrs, readSdtAttrs, readShapeAttrs, readStrikeMarkAttrs, readSymbolAttrs, readTabAttrs, readTableAttrs, readTableCellAttrs, readTableRowAttrs, readTextBoxAttrs, readTextColorMarkAttrs, readTextEffectMarkAttrs, readTrackedChangeMarkAttrs, readUnderlineMarkAttrs } from "./attrs/index.js";
|
|
2
2
|
import { readBookmarkBoundaryAttrs } from "./bookmarkBoundaryAttrs.js";
|
|
3
|
+
import { readCommentReferenceAttrs } from "./commentReferenceAttrs.js";
|
|
3
4
|
import { readTextBoxAnchorAttrs } from "./textBoxAnchorAttrs.js";
|
|
4
5
|
//#region src/prosemirror/validation.ts
|
|
5
6
|
var ProseMirrorDocumentValidationError = class extends Error {
|
|
@@ -142,12 +143,21 @@ const validateNodeAttrs = (node, path, issues) => {
|
|
|
142
143
|
case "bookmarkBoundary":
|
|
143
144
|
appendAttrIssues(path, readBookmarkBoundaryAttrs(node), issues);
|
|
144
145
|
return;
|
|
146
|
+
case "commentReference":
|
|
147
|
+
appendAttrIssues(path, readCommentReferenceAttrs(node), issues);
|
|
148
|
+
return;
|
|
145
149
|
case "tab":
|
|
146
150
|
appendAttrIssues(path, readTabAttrs(node), issues);
|
|
147
151
|
return;
|
|
148
152
|
case "symbol":
|
|
149
153
|
appendAttrIssues(path, readSymbolAttrs(node), issues);
|
|
150
154
|
return;
|
|
155
|
+
case "preservedXml":
|
|
156
|
+
appendAttrIssues(path, readPreservedXmlAttrs(node), issues);
|
|
157
|
+
return;
|
|
158
|
+
case "preservedBlock":
|
|
159
|
+
appendAttrIssues(path, readPreservedBlockAttrs(node), issues);
|
|
160
|
+
return;
|
|
151
161
|
case "hardBreak":
|
|
152
162
|
appendAttrIssues(path, readHardBreakAttrs(node), issues);
|
|
153
163
|
return;
|
|
@@ -184,6 +194,7 @@ const validateNodeAttrs = (node, path, issues) => {
|
|
|
184
194
|
if (fieldAttrs.ok) {
|
|
185
195
|
const hasStructuredHyperlink = node.content.content.some((child) => child.marks.some((mark) => mark.type.name === "hyperlink"));
|
|
186
196
|
const hasPageBreakCarrier = node.content.content.some((child) => child.type.name === "pageBreakRun");
|
|
197
|
+
const hasPreservedCapture = node.content.content.some((child) => child.type.name === "preservedXml");
|
|
187
198
|
if (fieldAttrs.value.fieldKind === "complex" && !hasPageBreakCarrier) issues.push({
|
|
188
199
|
path: `${path}.content`,
|
|
189
200
|
message: "Complex fields cannot contain structured result children."
|
|
@@ -192,7 +203,7 @@ const validateNodeAttrs = (node, path, issues) => {
|
|
|
192
203
|
path: `${path}.content`,
|
|
193
204
|
message: "Complex field results cannot contain hyperlink content."
|
|
194
205
|
});
|
|
195
|
-
else if (!hasStructuredHyperlink && !hasPageBreakCarrier) issues.push({
|
|
206
|
+
else if (!hasStructuredHyperlink && !hasPageBreakCarrier && !hasPreservedCapture) issues.push({
|
|
196
207
|
path: `${path}.content`,
|
|
197
208
|
message: "Structured simple fields require hyperlink content."
|
|
198
209
|
});
|
|
@@ -314,6 +325,9 @@ const validateMarks = (marks, path, issues) => {
|
|
|
314
325
|
case "hyperlink":
|
|
315
326
|
appendAttrIssues(markPath, readHyperlinkMarkAttrs(mark), issues);
|
|
316
327
|
continue;
|
|
328
|
+
case "inlineWrapper":
|
|
329
|
+
appendAttrIssues(markPath, readInlineWrapperMarkAttrs(mark), issues);
|
|
330
|
+
continue;
|
|
317
331
|
default: issues.push({
|
|
318
332
|
path: `${markPath}.type.name`,
|
|
319
333
|
message: `Unsupported ProseMirror mark type ${mark.type.name}.`
|