@stll/folio-core 0.44.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/__fixtures__/paragraphs.js +2 -2
- package/dist/ai-edits/apply.js +59 -19
- package/dist/ai-edits/headless.js +2 -1
- package/dist/compare/compare.js +2 -5
- package/dist/compare/content-alignment.js +78 -53
- package/dist/compare/inline-atoms.js +34 -20
- 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 +21 -4
- 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 +18 -10
- package/dist/display-list/types.d.ts +17 -0
- package/dist/document-operations.js +14 -3
- 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/borderParser.js +5 -5
- 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 +78 -50
- 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/commentThreadKey.d.ts +18 -0
- package/dist/docx/commentThreadKey.js +22 -0
- 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/diagramPreview.js +87 -27
- 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/groupDrawingParser.js +3 -3
- 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 +78 -20
- package/dist/docx/imageParser.d.ts +9 -1
- package/dist/docx/imageParser.js +91 -20
- package/dist/docx/imageRawXml.d.ts +14 -1
- package/dist/docx/imageRawXml.js +30 -6
- package/dist/docx/inlineWrapperContent.d.ts +85 -0
- package/dist/docx/inlineWrapperContent.js +84 -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/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 +9 -52
- package/dist/docx/paragraphTraversal.js +7 -4
- package/dist/docx/parseWarningMessage.js +2 -1
- package/dist/docx/parser.js +2 -2
- package/dist/docx/preservedRunContent.d.ts +32 -0
- package/dist/docx/preservedRunContent.js +86 -0
- package/dist/docx/previewBudget.d.ts +64 -0
- package/dist/docx/previewBudget.js +88 -0
- package/dist/docx/renderedPageBreakNormalization.js +2 -4
- package/dist/docx/revisionIdNormalization.js +17 -5
- package/dist/docx/rezip.js +91 -36
- package/dist/docx/runParser.d.ts +1 -1
- package/dist/docx/runParser.js +16 -12
- package/dist/docx/sdtPropertiesPatch.js +24 -18
- package/dist/docx/sectionParser.js +8 -1
- package/dist/docx/sectionReferenceHistory.js +2 -2
- package/dist/docx/selectiveSave.js +6 -6
- package/dist/docx/selectiveXmlPatch.d.ts +46 -2
- package/dist/docx/selectiveXmlPatch.js +86 -39
- package/dist/docx/serializer/blockSdtSerializer.js +38 -26
- package/dist/docx/serializer/borderSerializer.d.ts +1 -1
- package/dist/docx/serializer/borderSerializer.js +15 -14
- package/dist/docx/serializer/commentSerializer.d.ts +41 -16
- package/dist/docx/serializer/commentSerializer.js +87 -92
- package/dist/docx/serializer/documentSerializer.js +8 -11
- package/dist/docx/serializer/fontTableSerializer.js +6 -6
- package/dist/docx/serializer/headerFooterSerializer.js +12 -14
- package/dist/docx/serializer/markupRangeAttributes.js +2 -2
- package/dist/docx/serializer/noteSerializer.js +8 -8
- package/dist/docx/serializer/numberingSerializer.js +7 -6
- package/dist/docx/serializer/paragraphSerializer.js +93 -72
- package/dist/docx/serializer/partNamespaces.js +2 -2
- package/dist/docx/serializer/runSerializer.js +73 -44
- package/dist/docx/serializer/sectionPropertiesSerializer.js +19 -14
- package/dist/docx/serializer/settingsSerializer.js +4 -3
- package/dist/docx/serializer/stylesSerializer.js +6 -6
- package/dist/docx/serializer/tableSerializer.js +28 -17
- 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/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/server/validateDocxConformance.js +22 -1
- package/dist/docx/shapeParser.js +12 -10
- 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 +59 -4
- package/dist/docx/unzip.d.ts +23 -0
- package/dist/docx/unzip.js +37 -26
- package/dist/docx/verbatimCapture.js +1 -1
- package/dist/docx/vmlImageParser.d.ts +17 -1
- package/dist/docx/vmlImageParser.js +20 -3
- package/dist/docx/vmlPreview.d.ts +1 -3
- package/dist/docx/vmlPreview.js +2 -30
- package/dist/docx/xmlEncoding.d.ts +5 -0
- package/dist/docx/xmlEncoding.js +12 -0
- package/dist/docx/xmlParser.d.ts +26 -2
- package/dist/docx/xmlParser.js +70 -27
- package/dist/docx/xmlResourceLimits.d.ts +89 -9
- package/dist/docx/xmlResourceLimits.js +105 -24
- 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/internal/paragraphFormattingSerialization.js +3 -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 +14 -6
- 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 +26 -6
- package/dist/managers/autoSaveCodec.d.ts +9 -1
- package/dist/managers/autoSaveCodec.js +14 -12
- package/dist/markdown/images.js +1 -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 +224 -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 +43 -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 +338 -99
- package/dist/prosemirror/conversion/index.d.ts +2 -2
- package/dist/prosemirror/conversion/toProseDoc.d.ts +7 -9
- package/dist/prosemirror/conversion/toProseDoc.js +551 -327
- 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/HyperlinkExtension.js +2 -3
- 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 +20 -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 +10 -2
- package/dist/prosemirror/extensions/nodes/TableExtension.js +3 -2
- package/dist/prosemirror/extensions/nodes/TextBoxExtension.js +13 -5
- 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/paragraphFormattingProvenance.d.ts +6 -3
- package/dist/prosemirror/paragraphFormattingProvenance.js +12 -3
- 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 +139 -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/base64.d.ts +36 -0
- package/dist/utils/base64.js +40 -0
- package/dist/utils/clipboard.d.ts +9 -1
- package/dist/utils/clipboard.js +29 -2
- 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/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/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
|
@@ -17,34 +17,10 @@ import { ParagraphChangeTrackerExtension } from "./features/ParagraphChangeTrack
|
|
|
17
17
|
import { PasteCleanupExtension } from "./features/PasteCleanupExtension.js";
|
|
18
18
|
import { PasteStyleInlinerExtension } from "./features/PasteStyleInlinerExtension.js";
|
|
19
19
|
import { SelectionTrackerExtension } from "./features/SelectionTrackerExtension.js";
|
|
20
|
-
import {
|
|
21
|
-
import { BoldExtension } from "./marks/BoldExtension.js";
|
|
22
|
-
import { CharacterSpacingExtension } from "./marks/CharacterSpacingExtension.js";
|
|
23
|
-
import { CharacterStyleExtension } from "./marks/CharacterStyleExtension.js";
|
|
24
|
-
import { CommentExtension } from "./marks/CommentExtension.js";
|
|
25
|
-
import { FontFamilyExtension } from "./marks/FontFamilyExtension.js";
|
|
26
|
-
import { FontSizeExtension } from "./marks/FontSizeExtension.js";
|
|
27
|
-
import { FootnoteRefExtension } from "./marks/FootnoteRefExtension.js";
|
|
28
|
-
import { HiddenTextExtension } from "./marks/HiddenTextExtension.js";
|
|
29
|
-
import { HighlightExtension } from "./marks/HighlightExtension.js";
|
|
30
|
-
import { HyperlinkExtension } from "./marks/HyperlinkExtension.js";
|
|
31
|
-
import { ItalicExtension } from "./marks/ItalicExtension.js";
|
|
32
|
-
import { LanguageExtension } from "./marks/LanguageExtension.js";
|
|
33
|
-
import { PageBreakRunOwnerExtension } from "./marks/PageBreakRunOwnerExtension.js";
|
|
34
|
-
import { RtlExtension } from "./marks/RtlExtension.js";
|
|
35
|
-
import { RunFormattingOverrideExtension } from "./marks/RunFormattingOverrideExtension.js";
|
|
36
|
-
import { RunShadingExtension } from "./marks/RunShadingExtension.js";
|
|
37
|
-
import { SmallCapsExtension } from "./marks/SmallCapsExtension.js";
|
|
38
|
-
import { StrikeExtension } from "./marks/StrikeExtension.js";
|
|
39
|
-
import { SubscriptExtension } from "./marks/SubscriptExtension.js";
|
|
40
|
-
import { SuperscriptExtension } from "./marks/SuperscriptExtension.js";
|
|
41
|
-
import { TextColorExtension } from "./marks/TextColorExtension.js";
|
|
42
|
-
import { TextEffectExtension } from "./marks/TextEffectExtension.js";
|
|
43
|
-
import { EmbossExtension, EmphasisMarkExtension, ImprintExtension, TextOutlineExtension, TextShadowExtension } from "./marks/TextEffectsExtensions.js";
|
|
44
|
-
import { DeletionExtension, InsertionExtension, RunPropertyChangeExtension } from "./marks/TrackedChangeExtensions.js";
|
|
45
|
-
import { UnderlineExtension } from "./marks/UnderlineExtension.js";
|
|
20
|
+
import { MARK_EXTENSIONS } from "./markRegistry.js";
|
|
46
21
|
import { BlockSdtExtension } from "./nodes/BlockSdtExtension.js";
|
|
47
22
|
import { BookmarkBoundaryExtension } from "./nodes/BookmarkBoundaryExtension.js";
|
|
23
|
+
import { CommentReferenceExtension } from "./nodes/CommentReferenceExtension.js";
|
|
48
24
|
import { FieldExtension, StructuredFieldExtension } from "./nodes/FieldExtension.js";
|
|
49
25
|
import { HardBreakExtension } from "./nodes/HardBreakExtension.js";
|
|
50
26
|
import { HorizontalRuleExtension } from "./nodes/HorizontalRuleExtension.js";
|
|
@@ -52,6 +28,8 @@ import { ImageExtension } from "./nodes/ImageExtension.js";
|
|
|
52
28
|
import { MathExtension } from "./nodes/MathExtension.js";
|
|
53
29
|
import { PageBreakExtension } from "./nodes/PageBreakExtension.js";
|
|
54
30
|
import { PageBreakRunExtension } from "./nodes/PageBreakRunExtension.js";
|
|
31
|
+
import { PreservedBlockExtension } from "./nodes/PreservedBlockExtension.js";
|
|
32
|
+
import { PreservedXmlExtension } from "./nodes/PreservedXmlExtension.js";
|
|
55
33
|
import { RenderedPageBreakExtension } from "./nodes/RenderedPageBreakExtension.js";
|
|
56
34
|
import { SdtExtension } from "./nodes/SdtExtension.js";
|
|
57
35
|
import { ShapeExtension } from "./nodes/ShapeExtension.js";
|
|
@@ -82,42 +60,13 @@ function createStarterKit(options = {}) {
|
|
|
82
60
|
...options.historyDepth !== void 0 ? { depth: options.historyDepth } : {},
|
|
83
61
|
...options.historyNewGroupDelay !== void 0 ? { newGroupDelay: options.historyNewGroupDelay } : {}
|
|
84
62
|
}));
|
|
85
|
-
add(
|
|
86
|
-
add("italic", ItalicExtension());
|
|
87
|
-
add("underline", UnderlineExtension());
|
|
88
|
-
add("strike", StrikeExtension());
|
|
89
|
-
add("textColor", TextColorExtension());
|
|
90
|
-
add("runShading", RunShadingExtension());
|
|
91
|
-
add("highlight", HighlightExtension());
|
|
92
|
-
add("fontSize", FontSizeExtension());
|
|
93
|
-
add("fontFamily", FontFamilyExtension());
|
|
94
|
-
add("language", LanguageExtension());
|
|
95
|
-
add("superscript", SuperscriptExtension());
|
|
96
|
-
add("subscript", SubscriptExtension());
|
|
97
|
-
add("hyperlink", HyperlinkExtension());
|
|
98
|
-
add("allCaps", AllCapsExtension());
|
|
99
|
-
add("smallCaps", SmallCapsExtension());
|
|
100
|
-
add("footnoteRef", FootnoteRefExtension());
|
|
101
|
-
add("characterSpacing", CharacterSpacingExtension());
|
|
102
|
-
add("emboss", EmbossExtension());
|
|
103
|
-
add("imprint", ImprintExtension());
|
|
104
|
-
add("hidden", HiddenTextExtension());
|
|
105
|
-
add("textShadow", TextShadowExtension());
|
|
106
|
-
add("emphasisMark", EmphasisMarkExtension());
|
|
107
|
-
add("textOutline", TextOutlineExtension());
|
|
108
|
-
add("rtl", RtlExtension());
|
|
109
|
-
add("textEffect", TextEffectExtension());
|
|
110
|
-
add("runFormattingOverride", RunFormattingOverrideExtension());
|
|
111
|
-
add("characterStyle", CharacterStyleExtension());
|
|
112
|
-
add("pageBreakRunOwner", PageBreakRunOwnerExtension());
|
|
113
|
-
add("comment", CommentExtension());
|
|
114
|
-
add("insertion", InsertionExtension());
|
|
115
|
-
add("deletion", DeletionExtension());
|
|
116
|
-
add("runPropertyChange", RunPropertyChangeExtension());
|
|
63
|
+
for (const [name, extension] of Object.entries(MARK_EXTENSIONS)) add(name, extension());
|
|
117
64
|
add("bookmarkBoundary", BookmarkBoundaryExtension({ getInternalClipboardToken }));
|
|
65
|
+
add("commentReference", CommentReferenceExtension({ getInternalClipboardToken }));
|
|
118
66
|
add("hardBreak", HardBreakExtension());
|
|
119
67
|
add("tab", TabExtension());
|
|
120
68
|
add("symbol", SymbolExtension());
|
|
69
|
+
add("preservedXml", PreservedXmlExtension());
|
|
121
70
|
add("image", ImageExtension());
|
|
122
71
|
add("textBox", TextBoxExtension());
|
|
123
72
|
add("textBoxAnchor", TextBoxAnchorExtension({ getInternalClipboardToken }));
|
|
@@ -134,6 +83,7 @@ function createStarterKit(options = {}) {
|
|
|
134
83
|
add("field", StructuredFieldExtension({ getInternalClipboardToken }));
|
|
135
84
|
add("sdt", SdtExtension());
|
|
136
85
|
add("blockSdt", BlockSdtExtension());
|
|
86
|
+
add("preservedBlock", PreservedBlockExtension());
|
|
137
87
|
add("math", MathExtension());
|
|
138
88
|
if (!disabled.has("table")) extensions.push(...createTableExtensions());
|
|
139
89
|
add("pasteCleanup", PasteCleanupExtension({ getInternalClipboardToken }));
|
|
@@ -13,7 +13,7 @@ const DocExtension = createNodeExtension({
|
|
|
13
13
|
_finalSectionStart: { default: null },
|
|
14
14
|
_adjustLineHeightInTable: { default: false }
|
|
15
15
|
},
|
|
16
|
-
content: "(paragraph | horizontalRule | pageBreak | table | textBox | blockSdt)+"
|
|
16
|
+
content: "(paragraph | horizontalRule | pageBreak | table | textBox | blockSdt | preservedBlock)+"
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
19
|
//#endregion
|
|
@@ -254,6 +254,7 @@ const paragraphNodeSpec = {
|
|
|
254
254
|
_autospacingBase: { default: null },
|
|
255
255
|
_sectionProperties: { default: null },
|
|
256
256
|
_propertyChanges: { default: null },
|
|
257
|
+
_preservedAttributes: { default: null },
|
|
257
258
|
pPrMark: { default: null },
|
|
258
259
|
_suggestedInsert: { default: null }
|
|
259
260
|
},
|
|
@@ -664,7 +665,7 @@ const ParagraphExtension = createNodeExtension({
|
|
|
664
665
|
instruction: `PAGEREF ${entry.name} \\h`,
|
|
665
666
|
displayText: "1",
|
|
666
667
|
fieldKind: "complex",
|
|
667
|
-
fldLock:
|
|
668
|
+
fldLock: null,
|
|
668
669
|
dirty: true
|
|
669
670
|
}));
|
|
670
671
|
tocNodes.push(s.node("paragraph", {
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { mergeTextFormatting } from "../../../utils/textFormattingMerge.js";
|
|
2
|
+
import { expectCharacterStyleMarkAttrs, expectRunFormattingOverrideMarkAttrs } from "../../attrs/index.js";
|
|
2
3
|
import { getDocumentStyleResolver } from "../../plugins/documentStyles.js";
|
|
4
|
+
import { RUN_FORMATTING_MARK_NAMES } from "../../runFormattingMarkNames.js";
|
|
5
|
+
import { authoredRunFormattingFromAttrs } from "../../runFormattingProvenance.js";
|
|
3
6
|
import { paragraphAttrsFromResolvedStyle } from "../../styles/resolvedStyleAttrs.js";
|
|
4
7
|
import { createExtension } from "../create.js";
|
|
5
|
-
import { textFormattingToMarks } from "../marks/markUtils.js";
|
|
8
|
+
import { marksToTextFormatting, textFormattingToMarks } from "../marks/markUtils.js";
|
|
6
9
|
import { Priority } from "../types.js";
|
|
7
10
|
import { baseKeymap, deleteSelection, joinBackward, joinForward, selectAll, selectParentNode, splitBlock } from "prosemirror-commands";
|
|
8
11
|
//#region src/prosemirror/extensions/features/BaseKeymapExtension.ts
|
|
@@ -44,7 +47,7 @@ const clearIndentOnBackspace = (state, dispatch) => {
|
|
|
44
47
|
};
|
|
45
48
|
/**
|
|
46
49
|
* Custom Enter handler: splits the block, inherits style-related attrs,
|
|
47
|
-
* clears paragraph borders, and preserves
|
|
50
|
+
* clears paragraph borders, and preserves run formatting on the new paragraph.
|
|
48
51
|
*
|
|
49
52
|
* splitBlock creates a new paragraph with default attrs (all null),
|
|
50
53
|
* so we must manually copy style-related attrs from the source paragraph.
|
|
@@ -61,12 +64,31 @@ const INHERITED_PARA_ATTRS = [
|
|
|
61
64
|
"spaceBefore",
|
|
62
65
|
"contextualSpacing"
|
|
63
66
|
];
|
|
64
|
-
/**
|
|
67
|
+
/** Style formatting needed when the caret has no marks of its own. */
|
|
65
68
|
const STYLE_MARK_NAMES = /* @__PURE__ */ new Set([
|
|
66
69
|
"fontFamily",
|
|
67
70
|
"fontSize",
|
|
68
71
|
"textColor"
|
|
69
72
|
]);
|
|
73
|
+
const directFormattingFromMarks = (marks) => {
|
|
74
|
+
const override = marks.find(({ type }) => type.name === "runFormattingOverride");
|
|
75
|
+
const directFormatting = override ? authoredRunFormattingFromAttrs(expectRunFormattingOverrideMarkAttrs(override)) : void 0;
|
|
76
|
+
const characterStyle = marks.find(({ type }) => type.name === "characterStyle");
|
|
77
|
+
if (!characterStyle) return directFormatting;
|
|
78
|
+
return {
|
|
79
|
+
...directFormatting,
|
|
80
|
+
styleId: expectCharacterStyleMarkAttrs(characterStyle).styleId
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
const marksForParagraphFormatting = (formatting, directFormatting, schema) => {
|
|
84
|
+
const marks = textFormattingToMarks(formatting, schema, {
|
|
85
|
+
authoredCarrier: "preserve",
|
|
86
|
+
directFormatting,
|
|
87
|
+
overrideFormatting: directFormatting
|
|
88
|
+
});
|
|
89
|
+
if (formatting.styleId) marks.push(schema.mark("characterStyle", { styleId: formatting.styleId }));
|
|
90
|
+
return marks;
|
|
91
|
+
};
|
|
70
92
|
/**
|
|
71
93
|
* If `sourcePara`'s style defines a `w:next`, replace the empty `newPara`
|
|
72
94
|
* with that style's resolved attrs and seed stored marks from its run
|
|
@@ -94,7 +116,8 @@ function applyNextParagraphStyle(tr, sourcePara, newPara, resolver) {
|
|
|
94
116
|
const splitBlockClearBorders = (state, dispatch, view) => {
|
|
95
117
|
const { $from: preSplitFrom } = state.selection;
|
|
96
118
|
const sourcePara = preSplitFrom.parent.type.name === "paragraph" ? preSplitFrom.parent : null;
|
|
97
|
-
const
|
|
119
|
+
const caretFormattingMarks = (state.storedMarks || preSplitFrom.marks()).filter((mark) => RUN_FORMATTING_MARK_NAMES.has(mark.type.name));
|
|
120
|
+
const resolver = getDocumentStyleResolver(state);
|
|
98
121
|
const splitResult = { tr: null };
|
|
99
122
|
if (!splitBlock(state, dispatch ? (tr) => {
|
|
100
123
|
splitResult.tr = tr;
|
|
@@ -104,8 +127,18 @@ const splitBlockClearBorders = (state, dispatch, view) => {
|
|
|
104
127
|
const { $from } = tr.selection;
|
|
105
128
|
const newPara = $from.parent;
|
|
106
129
|
if (newPara.type.name === "paragraph") {
|
|
107
|
-
const resolver = getDocumentStyleResolver(state);
|
|
108
130
|
if (resolver !== null && sourcePara !== null && newPara.content.size === 0 && applyNextParagraphStyle(tr, sourcePara, newPara, resolver)) {
|
|
131
|
+
const directFormatting = directFormattingFromMarks(caretFormattingMarks);
|
|
132
|
+
if (directFormatting && Object.keys(directFormatting).length > 0) {
|
|
133
|
+
const nextParagraph = tr.selection.$from.parent;
|
|
134
|
+
const nextStyleFormatting = nextParagraph.attrs["defaultTextFormatting"];
|
|
135
|
+
const defaultTextFormatting = mergeTextFormatting(nextStyleFormatting, directFormatting) ?? directFormatting;
|
|
136
|
+
tr.setNodeMarkup(tr.selection.$from.before(), void 0, {
|
|
137
|
+
...nextParagraph.attrs,
|
|
138
|
+
defaultTextFormatting
|
|
139
|
+
});
|
|
140
|
+
tr.setStoredMarks(marksForParagraphFormatting(defaultTextFormatting, directFormatting, state.schema));
|
|
141
|
+
}
|
|
109
142
|
dispatch(tr.scrollIntoView());
|
|
110
143
|
return true;
|
|
111
144
|
}
|
|
@@ -124,33 +157,18 @@ const splitBlockClearBorders = (state, dispatch, view) => {
|
|
|
124
157
|
}
|
|
125
158
|
if (attrsChanged) tr.setNodeMarkup($from.before(), void 0, newAttrs);
|
|
126
159
|
if (newPara.textContent.length === 0) {
|
|
127
|
-
let effectiveMarks =
|
|
160
|
+
let effectiveMarks = caretFormattingMarks;
|
|
128
161
|
if (effectiveMarks.length === 0 && sourcePara) {
|
|
129
162
|
const dtf = sourcePara.attrs["defaultTextFormatting"];
|
|
130
163
|
if (dtf) effectiveMarks = textFormattingToMarks(dtf, state.schema).filter((m) => STYLE_MARK_NAMES.has(m.type.name));
|
|
131
164
|
}
|
|
132
165
|
if (effectiveMarks.length > 0) {
|
|
133
|
-
const
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
dtf.fontSize = m.attrs["size"];
|
|
138
|
-
dtfChanged = true;
|
|
139
|
-
}
|
|
140
|
-
if (m.type.name === "fontFamily") {
|
|
141
|
-
const ascii = m.attrs["ascii"];
|
|
142
|
-
if (ascii && (!dtf.fontFamily || dtf.fontFamily.ascii !== ascii)) {
|
|
143
|
-
const nextFontFamily = { ascii };
|
|
144
|
-
const hAnsi = m.attrs["hAnsi"];
|
|
145
|
-
if (hAnsi !== void 0) nextFontFamily.hAnsi = hAnsi;
|
|
146
|
-
dtf.fontFamily = mergeFontFamily(dtf.fontFamily, nextFontFamily);
|
|
147
|
-
dtfChanged = true;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
if (dtfChanged) tr.setNodeMarkup($from.before(), void 0, {
|
|
166
|
+
const previousFormatting = newAttrs["defaultTextFormatting"];
|
|
167
|
+
const markFormatting = marksToTextFormatting(effectiveMarks);
|
|
168
|
+
const defaultTextFormatting = mergeTextFormatting(previousFormatting, markFormatting) ?? markFormatting;
|
|
169
|
+
tr.setNodeMarkup($from.before(), void 0, {
|
|
152
170
|
...newAttrs,
|
|
153
|
-
defaultTextFormatting
|
|
171
|
+
defaultTextFormatting
|
|
154
172
|
});
|
|
155
173
|
tr.setStoredMarks(effectiveMarks);
|
|
156
174
|
}
|
|
@@ -11,8 +11,9 @@ const emptyParagraphFormatKey = new PluginKey("emptyParagraphFormat");
|
|
|
11
11
|
* must be one `textFormattingToMarks` can turn into a mark, or the gate would
|
|
12
12
|
* open for work that produces nothing.
|
|
13
13
|
*/
|
|
14
|
+
const FONT_ONLY_DEFAULTS = /* @__PURE__ */ new Set(["fontFamily", "fontSize"]);
|
|
14
15
|
function hasNonFontDefaults(dtf) {
|
|
15
|
-
return
|
|
16
|
+
return Object.entries(dtf).some(([property, value]) => value !== void 0 && !FONT_ONLY_DEFAULTS.has(property));
|
|
16
17
|
}
|
|
17
18
|
function createEmptyParagraphFormatPlugin(schema) {
|
|
18
19
|
return new Plugin({
|
|
@@ -27,6 +28,7 @@ function createEmptyParagraphFormatPlugin(schema) {
|
|
|
27
28
|
const dtf = para.attrs["defaultTextFormatting"];
|
|
28
29
|
if (!dtf || !hasNonFontDefaults(dtf)) return null;
|
|
29
30
|
const marks = textFormattingToMarks(dtf, schema);
|
|
31
|
+
if (dtf.styleId) marks.push(schema.mark("characterStyle", { styleId: dtf.styleId }));
|
|
30
32
|
if (marks.length === 0) return null;
|
|
31
33
|
const tr = newState.tr.setStoredMarks(marks);
|
|
32
34
|
tr.setMeta("addToHistory", false);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FOLIO_INSERTED_PICTURE_FRAME_LOCKS } from "../../../docx/graphicFrameLocks.js";
|
|
2
|
+
import { getStandaloneClipboardImageFiles } from "../../../utils/clipboard.js";
|
|
2
3
|
import { isSafeImageFile } from "../../../utils/imageValidation.js";
|
|
3
4
|
import { sanitizeImageSrc } from "../../../utils/sanitizeImageSrc.js";
|
|
4
5
|
import { createExtension } from "../create.js";
|
|
@@ -73,7 +74,8 @@ async function insertImageFiles(view, files) {
|
|
|
73
74
|
height,
|
|
74
75
|
rId: `rId_img_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`,
|
|
75
76
|
wrapType: "inline",
|
|
76
|
-
displayMode: "inline"
|
|
77
|
+
displayMode: "inline",
|
|
78
|
+
frameLocks: FOLIO_INSERTED_PICTURE_FRAME_LOCKS
|
|
77
79
|
});
|
|
78
80
|
const tr = view.state.tr.insert(insertPos, imageNode);
|
|
79
81
|
insertPos += imageNode.nodeSize;
|
|
@@ -86,7 +88,7 @@ const ImagePasteExtension = createExtension({
|
|
|
86
88
|
name: "imagePaste",
|
|
87
89
|
onSchemaReady(_ctx) {
|
|
88
90
|
return { plugins: [new Plugin({ props: { handleDOMEvents: { paste(view, event) {
|
|
89
|
-
const imageFiles =
|
|
91
|
+
const imageFiles = getStandaloneClipboardImageFiles(event.clipboardData);
|
|
90
92
|
if (imageFiles.length === 0) return false;
|
|
91
93
|
if (!view.state.schema.nodes["image"]) return false;
|
|
92
94
|
event.preventDefault();
|
|
@@ -322,6 +322,7 @@ const createParaIdAllocatorPlugin = () => new Plugin({
|
|
|
322
322
|
ignoreTrackedChanges(tr);
|
|
323
323
|
tr.setMeta(paraIdAllocatorKey, "allocated");
|
|
324
324
|
tr.setMeta("addToHistory", false);
|
|
325
|
+
if (newState.storedMarks !== null) tr.setStoredMarks(newState.storedMarks);
|
|
325
326
|
return tr;
|
|
326
327
|
}
|
|
327
328
|
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { MarkExtension } from "./types.js";
|
|
2
|
+
//#region src/prosemirror/extensions/markRegistry.d.ts
|
|
3
|
+
declare const MARK_EXTENSIONS: {
|
|
4
|
+
readonly bold: (options?: Partial<Record<string, unknown>> | undefined) => MarkExtension;
|
|
5
|
+
readonly italic: (options?: Partial<Record<string, unknown>> | undefined) => MarkExtension;
|
|
6
|
+
readonly underline: (options?: Partial<Record<string, unknown>> | undefined) => MarkExtension;
|
|
7
|
+
readonly strike: (options?: Partial<Record<string, unknown>> | undefined) => MarkExtension;
|
|
8
|
+
readonly textColor: (options?: Partial<Record<string, unknown>> | undefined) => MarkExtension;
|
|
9
|
+
readonly runShading: (options?: Partial<Record<string, unknown>> | undefined) => MarkExtension;
|
|
10
|
+
readonly highlight: (options?: Partial<Record<string, unknown>> | undefined) => MarkExtension;
|
|
11
|
+
readonly fontSize: (options?: Partial<Record<string, unknown>> | undefined) => MarkExtension;
|
|
12
|
+
readonly fontFamily: (options?: Partial<Record<string, unknown>> | undefined) => MarkExtension;
|
|
13
|
+
readonly language: (options?: Partial<Record<string, unknown>> | undefined) => MarkExtension;
|
|
14
|
+
readonly superscript: (options?: Partial<Record<string, unknown>> | undefined) => MarkExtension;
|
|
15
|
+
readonly subscript: (options?: Partial<Record<string, unknown>> | undefined) => MarkExtension;
|
|
16
|
+
readonly hyperlink: (options?: Partial<Record<string, unknown>> | undefined) => MarkExtension;
|
|
17
|
+
readonly allCaps: (options?: Partial<Record<string, unknown>> | undefined) => MarkExtension;
|
|
18
|
+
readonly smallCaps: (options?: Partial<Record<string, unknown>> | undefined) => MarkExtension;
|
|
19
|
+
readonly footnoteRef: (options?: Partial<Record<string, unknown>> | undefined) => MarkExtension;
|
|
20
|
+
readonly characterSpacing: (options?: Partial<Record<string, unknown>> | undefined) => MarkExtension;
|
|
21
|
+
readonly emboss: (options?: Partial<Record<string, unknown>> | undefined) => MarkExtension;
|
|
22
|
+
readonly imprint: (options?: Partial<Record<string, unknown>> | undefined) => MarkExtension;
|
|
23
|
+
readonly hidden: (options?: Partial<Record<string, unknown>> | undefined) => MarkExtension;
|
|
24
|
+
readonly textShadow: (options?: Partial<Record<string, unknown>> | undefined) => MarkExtension;
|
|
25
|
+
readonly emphasisMark: (options?: Partial<Record<string, unknown>> | undefined) => MarkExtension;
|
|
26
|
+
readonly textOutline: (options?: Partial<Record<string, unknown>> | undefined) => MarkExtension;
|
|
27
|
+
readonly rtl: (options?: Partial<Record<string, unknown>> | undefined) => MarkExtension;
|
|
28
|
+
readonly textEffect: (options?: Partial<Record<string, unknown>> | undefined) => MarkExtension;
|
|
29
|
+
readonly runFormattingOverride: (options?: Partial<Record<string, unknown>> | undefined) => MarkExtension;
|
|
30
|
+
readonly characterStyle: (options?: Partial<Record<string, unknown>> | undefined) => MarkExtension;
|
|
31
|
+
readonly pageBreakRunOwner: (options?: Partial<Record<string, unknown>> | undefined) => MarkExtension;
|
|
32
|
+
readonly comment: (options?: Partial<Record<string, unknown>> | undefined) => MarkExtension;
|
|
33
|
+
readonly insertion: (options?: Partial<Record<string, unknown>> | undefined) => MarkExtension;
|
|
34
|
+
readonly deletion: (options?: Partial<Record<string, unknown>> | undefined) => MarkExtension;
|
|
35
|
+
readonly runPropertyChange: (options?: Partial<Record<string, unknown>> | undefined) => MarkExtension;
|
|
36
|
+
readonly inlineWrapper: (options?: Partial<Record<string, unknown>> | undefined) => MarkExtension;
|
|
37
|
+
};
|
|
38
|
+
/** A mark the editor schema declares. */
|
|
39
|
+
type SchemaMarkName = keyof typeof MARK_EXTENSIONS;
|
|
40
|
+
//#endregion
|
|
41
|
+
export { MARK_EXTENSIONS, SchemaMarkName };
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { AllCapsExtension } from "./marks/AllCapsExtension.js";
|
|
2
|
+
import { BoldExtension } from "./marks/BoldExtension.js";
|
|
3
|
+
import { CharacterSpacingExtension } from "./marks/CharacterSpacingExtension.js";
|
|
4
|
+
import { CharacterStyleExtension } from "./marks/CharacterStyleExtension.js";
|
|
5
|
+
import { CommentExtension } from "./marks/CommentExtension.js";
|
|
6
|
+
import { FontFamilyExtension } from "./marks/FontFamilyExtension.js";
|
|
7
|
+
import { FontSizeExtension } from "./marks/FontSizeExtension.js";
|
|
8
|
+
import { FootnoteRefExtension } from "./marks/FootnoteRefExtension.js";
|
|
9
|
+
import { HiddenTextExtension } from "./marks/HiddenTextExtension.js";
|
|
10
|
+
import { HighlightExtension } from "./marks/HighlightExtension.js";
|
|
11
|
+
import { HyperlinkExtension } from "./marks/HyperlinkExtension.js";
|
|
12
|
+
import { InlineWrapperExtension } from "./marks/InlineWrapperExtension.js";
|
|
13
|
+
import { ItalicExtension } from "./marks/ItalicExtension.js";
|
|
14
|
+
import { LanguageExtension } from "./marks/LanguageExtension.js";
|
|
15
|
+
import { PageBreakRunOwnerExtension } from "./marks/PageBreakRunOwnerExtension.js";
|
|
16
|
+
import { RtlExtension } from "./marks/RtlExtension.js";
|
|
17
|
+
import { RunFormattingOverrideExtension } from "./marks/RunFormattingOverrideExtension.js";
|
|
18
|
+
import { RunShadingExtension } from "./marks/RunShadingExtension.js";
|
|
19
|
+
import { SmallCapsExtension } from "./marks/SmallCapsExtension.js";
|
|
20
|
+
import { StrikeExtension } from "./marks/StrikeExtension.js";
|
|
21
|
+
import { SubscriptExtension } from "./marks/SubscriptExtension.js";
|
|
22
|
+
import { SuperscriptExtension } from "./marks/SuperscriptExtension.js";
|
|
23
|
+
import { TextColorExtension } from "./marks/TextColorExtension.js";
|
|
24
|
+
import { TextEffectExtension } from "./marks/TextEffectExtension.js";
|
|
25
|
+
import { EmbossExtension, EmphasisMarkExtension, ImprintExtension, TextOutlineExtension, TextShadowExtension } from "./marks/TextEffectsExtensions.js";
|
|
26
|
+
import { DeletionExtension, InsertionExtension, RunPropertyChangeExtension } from "./marks/TrackedChangeExtensions.js";
|
|
27
|
+
import { UnderlineExtension } from "./marks/UnderlineExtension.js";
|
|
28
|
+
//#region src/prosemirror/extensions/markRegistry.ts
|
|
29
|
+
/**
|
|
30
|
+
* Every mark the editor schema declares, in registration order.
|
|
31
|
+
*
|
|
32
|
+
* Registration order is DOM nesting order: a mark registered later is the
|
|
33
|
+
* inner span. `StarterKit` builds the schema from this record and from nothing
|
|
34
|
+
* else, so `SchemaMarkName` is the set of marks that exist rather than a list
|
|
35
|
+
* beside it — a table that must decide something per mark (what the painter
|
|
36
|
+
* does with it) can be checked total against this union, and a mark added
|
|
37
|
+
* without that decision does not compile.
|
|
38
|
+
*/
|
|
39
|
+
const MARK_EXTENSIONS = {
|
|
40
|
+
bold: BoldExtension,
|
|
41
|
+
italic: ItalicExtension,
|
|
42
|
+
underline: UnderlineExtension,
|
|
43
|
+
strike: StrikeExtension,
|
|
44
|
+
textColor: TextColorExtension,
|
|
45
|
+
runShading: RunShadingExtension,
|
|
46
|
+
highlight: HighlightExtension,
|
|
47
|
+
fontSize: FontSizeExtension,
|
|
48
|
+
fontFamily: FontFamilyExtension,
|
|
49
|
+
language: LanguageExtension,
|
|
50
|
+
superscript: SuperscriptExtension,
|
|
51
|
+
subscript: SubscriptExtension,
|
|
52
|
+
hyperlink: HyperlinkExtension,
|
|
53
|
+
allCaps: AllCapsExtension,
|
|
54
|
+
smallCaps: SmallCapsExtension,
|
|
55
|
+
footnoteRef: FootnoteRefExtension,
|
|
56
|
+
characterSpacing: CharacterSpacingExtension,
|
|
57
|
+
emboss: EmbossExtension,
|
|
58
|
+
imprint: ImprintExtension,
|
|
59
|
+
hidden: HiddenTextExtension,
|
|
60
|
+
textShadow: TextShadowExtension,
|
|
61
|
+
emphasisMark: EmphasisMarkExtension,
|
|
62
|
+
textOutline: TextOutlineExtension,
|
|
63
|
+
rtl: RtlExtension,
|
|
64
|
+
textEffect: TextEffectExtension,
|
|
65
|
+
runFormattingOverride: RunFormattingOverrideExtension,
|
|
66
|
+
characterStyle: CharacterStyleExtension,
|
|
67
|
+
pageBreakRunOwner: PageBreakRunOwnerExtension,
|
|
68
|
+
comment: CommentExtension,
|
|
69
|
+
insertion: InsertionExtension,
|
|
70
|
+
deletion: DeletionExtension,
|
|
71
|
+
runPropertyChange: RunPropertyChangeExtension,
|
|
72
|
+
inlineWrapper: InlineWrapperExtension
|
|
73
|
+
};
|
|
74
|
+
//#endregion
|
|
75
|
+
export { MARK_EXTENSIONS };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { normalizeUserUrl, sanitizeExternalUrl } from "../../../utils/urlSecurity.js";
|
|
1
|
+
import { anchorTargetAttrs, normalizeUserUrl, sanitizeExternalUrl } from "../../../utils/urlSecurity.js";
|
|
2
2
|
import { expectHyperlinkMarkAttrs } from "../../attrs/index.js";
|
|
3
3
|
import { createMarkExtension } from "../create.js";
|
|
4
4
|
import { isMarkActive } from "./markUtils.js";
|
|
@@ -96,8 +96,7 @@ const HyperlinkExtension = createMarkExtension({
|
|
|
96
96
|
const { href, tooltip } = expectHyperlinkMarkAttrs(mark);
|
|
97
97
|
const domAttrs = {
|
|
98
98
|
href: sanitizeStoredHref(href),
|
|
99
|
-
|
|
100
|
-
rel: "noopener noreferrer"
|
|
99
|
+
...anchorTargetAttrs(void 0)
|
|
101
100
|
};
|
|
102
101
|
if (tooltip) domAttrs["title"] = tooltip;
|
|
103
102
|
return [
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { MarkExtension } from "../types.js";
|
|
2
|
+
//#region src/prosemirror/extensions/marks/InlineWrapperExtension.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Inline wrapper mark — the transparent wrappers a leaf sits inside.
|
|
5
|
+
*
|
|
6
|
+
* One mark for every wrapper kind rather than one mark per kind: ProseMirror's
|
|
7
|
+
* mark set is unordered across types, so two marks could not say which wrapper
|
|
8
|
+
* is inside which. The nesting lives in the `stack` attr, outermost first, and
|
|
9
|
+
* the mark excludes itself (ProseMirror's default) because a second one would
|
|
10
|
+
* be a second answer to the same question.
|
|
11
|
+
*
|
|
12
|
+
* `inclusive: false` so typing at the end of a wrapped span does not silently
|
|
13
|
+
* extend the wrapper over text the author wrote outside it.
|
|
14
|
+
*/
|
|
15
|
+
declare const INLINE_WRAPPER_MARK_NAME = "inlineWrapper";
|
|
16
|
+
declare const InlineWrapperExtension: (options?: Partial<Record<string, unknown>> | undefined) => MarkExtension;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { INLINE_WRAPPER_MARK_NAME, InlineWrapperExtension };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { expectInlineWrapperMarkAttrs } from "../../attrs/index.js";
|
|
2
|
+
import { INLINE_WRAPPER_STACK_ATTRIBUTE, parseInlineWrapperStack, serializeInlineWrapperStack } from "../../inlineWrapperStack.js";
|
|
3
|
+
import { createMarkExtension } from "../create.js";
|
|
4
|
+
import { panic } from "better-result";
|
|
5
|
+
//#region src/prosemirror/extensions/marks/InlineWrapperExtension.ts
|
|
6
|
+
/**
|
|
7
|
+
* Inline wrapper mark — the transparent wrappers a leaf sits inside.
|
|
8
|
+
*
|
|
9
|
+
* One mark for every wrapper kind rather than one mark per kind: ProseMirror's
|
|
10
|
+
* mark set is unordered across types, so two marks could not say which wrapper
|
|
11
|
+
* is inside which. The nesting lives in the `stack` attr, outermost first, and
|
|
12
|
+
* the mark excludes itself (ProseMirror's default) because a second one would
|
|
13
|
+
* be a second answer to the same question.
|
|
14
|
+
*
|
|
15
|
+
* `inclusive: false` so typing at the end of a wrapped span does not silently
|
|
16
|
+
* extend the wrapper over text the author wrote outside it.
|
|
17
|
+
*/
|
|
18
|
+
const INLINE_WRAPPER_MARK_NAME = "inlineWrapper";
|
|
19
|
+
/**
|
|
20
|
+
* How one layer is spelled in HTML.
|
|
21
|
+
*
|
|
22
|
+
* `w:bdo` is `unicode-bidi: bidi-override`, which HTML gives an element of its
|
|
23
|
+
* own; `w:dir` is `unicode-bidi: embed`, which a `dir`-carrying span states.
|
|
24
|
+
*/
|
|
25
|
+
const layerElement = (layer, attributes) => {
|
|
26
|
+
switch (layer.kind) {
|
|
27
|
+
case "bidi":
|
|
28
|
+
if (layer.direction !== void 0) attributes["dir"] = layer.direction;
|
|
29
|
+
return [
|
|
30
|
+
layer.control === "override" ? "bdo" : "span",
|
|
31
|
+
attributes,
|
|
32
|
+
0
|
|
33
|
+
];
|
|
34
|
+
default:
|
|
35
|
+
layer.kind;
|
|
36
|
+
panic(`Unspelled inline wrapper layer: ${JSON.stringify(layer)}`);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
const InlineWrapperExtension = createMarkExtension({
|
|
40
|
+
name: INLINE_WRAPPER_MARK_NAME,
|
|
41
|
+
schemaMarkName: INLINE_WRAPPER_MARK_NAME,
|
|
42
|
+
markSpec: {
|
|
43
|
+
attrs: {
|
|
44
|
+
/** Outermost first. `null` is no wrapper, which is the absence of the mark. */
|
|
45
|
+
stack: { default: null } },
|
|
46
|
+
inclusive: false,
|
|
47
|
+
parseDOM: [{
|
|
48
|
+
tag: `[${INLINE_WRAPPER_STACK_ATTRIBUTE}]`,
|
|
49
|
+
getAttrs(dom) {
|
|
50
|
+
const stack = parseInlineWrapperStack(dom.getAttribute(INLINE_WRAPPER_STACK_ATTRIBUTE));
|
|
51
|
+
return stack === null ? false : { stack };
|
|
52
|
+
}
|
|
53
|
+
}],
|
|
54
|
+
toDOM(mark) {
|
|
55
|
+
const { stack } = expectInlineWrapperMarkAttrs(mark);
|
|
56
|
+
const innermost = stack.at(-1);
|
|
57
|
+
if (innermost === void 0) panic("An inline wrapper mark carries at least one layer");
|
|
58
|
+
return layerElement(innermost, { [INLINE_WRAPPER_STACK_ATTRIBUTE]: serializeInlineWrapperStack(stack) });
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
//#endregion
|
|
63
|
+
export { INLINE_WRAPPER_MARK_NAME, InlineWrapperExtension };
|
|
@@ -3,6 +3,7 @@ import { Command, EditorState } from "prosemirror-state";
|
|
|
3
3
|
import { Mark, MarkType, Schema } from "prosemirror-model";
|
|
4
4
|
//#region src/prosemirror/extensions/marks/markUtils.d.ts
|
|
5
5
|
type MarkAttrs = Record<string, unknown>;
|
|
6
|
+
declare function marksToTextFormatting(marks: readonly Mark[]): document_d_exports.TextFormatting;
|
|
6
7
|
declare function setMark(markType: MarkType, attrs: MarkAttrs): Command;
|
|
7
8
|
type PairedToggleProperty = "bold" | "italic";
|
|
8
9
|
/** UI toggle whose direct-formatting contract explicitly targets both script families. */
|
|
@@ -46,4 +47,4 @@ declare function createSetMarkCommand(markType: MarkType, attrs?: Record<string,
|
|
|
46
47
|
*/
|
|
47
48
|
declare function createRemoveMarkCommand(markType: MarkType): Command;
|
|
48
49
|
//#endregion
|
|
49
|
-
export { AuthoredRunFormattingCarrier, clearFontSizeForAllScripts, clearFormatting, createRemoveMarkCommand, createSetMarkCommand, getMarkAttr, isMarkActive, removeMark, setFontSizeForAllScripts, setMark, textFormattingToMarks, toggleMarkForAllScripts, toggleUnderlineMark };
|
|
50
|
+
export { AuthoredRunFormattingCarrier, clearFontSizeForAllScripts, clearFormatting, createRemoveMarkCommand, createSetMarkCommand, getMarkAttr, isMarkActive, marksToTextFormatting, removeMark, setFontSizeForAllScripts, setMark, textFormattingToMarks, toggleMarkForAllScripts, toggleUnderlineMark };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { FONT_THEME_VALUES } from "../../../types/documentEnumValues.js";
|
|
2
2
|
import { mergeFontFamily } from "../../../utils/fontFamilyMerge.js";
|
|
3
3
|
import { normalizeHorizontalScalePercent } from "../../../utils/horizontalScale.js";
|
|
4
|
-
import { expectFontFamilyMarkAttrs, expectRunFormattingOverrideMarkAttrs } from "../../attrs/index.js";
|
|
5
|
-
import { shadingToRunShadingAttrs } from "../../conversion/runShadingMark.js";
|
|
4
|
+
import { expectCharacterSpacingMarkAttrs, expectCharacterStyleMarkAttrs, expectEmphasisMarkAttrs, expectFontFamilyMarkAttrs, expectRunFormattingOverrideMarkAttrs, expectRunShadingMarkAttrs, expectStrikeMarkAttrs, expectTextEffectMarkAttrs } from "../../attrs/index.js";
|
|
5
|
+
import { runShadingAttrsToShading, shadingToRunShadingAttrs } from "../../conversion/runShadingMark.js";
|
|
6
6
|
import { selectRunFormattingCarrierRepresentations } from "../../runFormattingInlineCarriers.js";
|
|
7
7
|
import { hasRunFormattingOverrideAttrs } from "../../runFormattingProvenance.js";
|
|
8
8
|
import { COMPLEX_SCRIPT_RUN_PROPERTY_KEYS } from "../../schema/marks.js";
|
|
@@ -37,7 +37,8 @@ function marksToTextFormatting(marks) {
|
|
|
37
37
|
};
|
|
38
38
|
break;
|
|
39
39
|
case "strike":
|
|
40
|
-
formatting.
|
|
40
|
+
if (expectStrikeMarkAttrs(mark).double) formatting.doubleStrike = true;
|
|
41
|
+
else formatting.strike = true;
|
|
41
42
|
break;
|
|
42
43
|
case "textColor": {
|
|
43
44
|
const colorRgb = mark.attrs["rgb"] !== null && mark.attrs["rgb"] !== void 0 ? String(mark.attrs["rgb"]) : void 0;
|
|
@@ -55,6 +56,9 @@ function marksToTextFormatting(marks) {
|
|
|
55
56
|
case "highlight":
|
|
56
57
|
formatting.highlight = String(mark.attrs["color"]);
|
|
57
58
|
break;
|
|
59
|
+
case "runShading":
|
|
60
|
+
formatting.shading = runShadingAttrsToShading(expectRunShadingMarkAttrs(mark));
|
|
61
|
+
break;
|
|
58
62
|
case "fontSize":
|
|
59
63
|
formatting.fontSize = Number(mark.attrs["size"]);
|
|
60
64
|
break;
|
|
@@ -78,12 +82,51 @@ function marksToTextFormatting(marks) {
|
|
|
78
82
|
case "subscript":
|
|
79
83
|
formatting.vertAlign = "subscript";
|
|
80
84
|
break;
|
|
85
|
+
case "allCaps":
|
|
86
|
+
formatting.allCaps = true;
|
|
87
|
+
break;
|
|
88
|
+
case "smallCaps":
|
|
89
|
+
formatting.smallCaps = true;
|
|
90
|
+
break;
|
|
91
|
+
case "characterSpacing": {
|
|
92
|
+
const attrs = expectCharacterSpacingMarkAttrs(mark);
|
|
93
|
+
if (attrs.spacing !== void 0) formatting.spacing = attrs.spacing;
|
|
94
|
+
if (attrs.position !== void 0) formatting.position = attrs.position;
|
|
95
|
+
const scale = normalizeHorizontalScalePercent(attrs.scale);
|
|
96
|
+
if (scale !== void 0) formatting.scale = scale;
|
|
97
|
+
if (attrs.kerning !== void 0) formatting.kerning = attrs.kerning;
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
case "emboss":
|
|
101
|
+
formatting.emboss = true;
|
|
102
|
+
break;
|
|
103
|
+
case "imprint":
|
|
104
|
+
formatting.imprint = true;
|
|
105
|
+
break;
|
|
106
|
+
case "hidden":
|
|
107
|
+
formatting.hidden = true;
|
|
108
|
+
break;
|
|
109
|
+
case "textShadow":
|
|
110
|
+
formatting.shadow = true;
|
|
111
|
+
break;
|
|
112
|
+
case "emphasisMark":
|
|
113
|
+
formatting.emphasisMark = expectEmphasisMarkAttrs(mark).type || "dot";
|
|
114
|
+
break;
|
|
115
|
+
case "textOutline":
|
|
116
|
+
formatting.outline = true;
|
|
117
|
+
break;
|
|
81
118
|
case "rtl":
|
|
82
119
|
formatting.rtl = true;
|
|
83
120
|
break;
|
|
121
|
+
case "textEffect":
|
|
122
|
+
formatting.effect = expectTextEffectMarkAttrs(mark).effect;
|
|
123
|
+
break;
|
|
84
124
|
case "runFormattingOverride":
|
|
85
125
|
applyRunFormattingOverrideMark(formatting, mark);
|
|
86
126
|
break;
|
|
127
|
+
case "characterStyle":
|
|
128
|
+
formatting.styleId = expectCharacterStyleMarkAttrs(mark).styleId;
|
|
129
|
+
break;
|
|
87
130
|
default: break;
|
|
88
131
|
}
|
|
89
132
|
return formatting;
|
|
@@ -486,4 +529,4 @@ function createRemoveMarkCommand(markType) {
|
|
|
486
529
|
return removeMark(markType);
|
|
487
530
|
}
|
|
488
531
|
//#endregion
|
|
489
|
-
export { clearFontSizeForAllScripts, clearFormatting, createRemoveMarkCommand, createSetMarkCommand, getMarkAttr, isMarkActive, removeMark, setFontSizeForAllScripts, setMark, textFormattingToMarks, toggleMarkForAllScripts, toggleUnderlineMark };
|
|
532
|
+
export { clearFontSizeForAllScripts, clearFormatting, createRemoveMarkCommand, createSetMarkCommand, getMarkAttr, isMarkActive, marksToTextFormatting, removeMark, setFontSizeForAllScripts, setMark, textFormattingToMarks, toggleMarkForAllScripts, toggleUnderlineMark };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { NodeExtension } from "../types.js";
|
|
2
|
+
//#region src/prosemirror/extensions/nodes/CommentReferenceExtension.d.ts
|
|
3
|
+
/** Zero-width `w:commentReference`: where a comment's visible mark is painted. */
|
|
4
|
+
type CommentReferenceOptions = {
|
|
5
|
+
getInternalClipboardToken?: () => string;
|
|
6
|
+
};
|
|
7
|
+
/** The node name, for callers asking whether a paragraph holds any content. */
|
|
8
|
+
declare const COMMENT_REFERENCE_NODE_NAME = "commentReference";
|
|
9
|
+
declare const CommentReferenceExtension: (options?: Partial<CommentReferenceOptions> | undefined) => NodeExtension;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { COMMENT_REFERENCE_NODE_NAME, CommentReferenceExtension };
|