@stll/folio-core 0.35.1 → 0.37.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +59 -1
- package/dist/ai-edits/apply.js +878 -377
- package/dist/ai-edits/block-identity.d.ts +4 -1
- package/dist/ai-edits/block-identity.js +4 -1
- package/dist/ai-edits/blockRange.js +14 -14
- package/dist/ai-edits/clean-text.d.ts +40 -1
- package/dist/ai-edits/clean-text.js +52 -2
- package/dist/ai-edits/headless.d.ts +3 -1
- package/dist/ai-edits/headless.js +141 -73
- package/dist/ai-edits/index.d.ts +3 -3
- package/dist/ai-edits/index.js +2 -2
- package/dist/ai-edits/read.js +38 -20
- package/dist/ai-edits/snapshot.d.ts +14 -6
- package/dist/ai-edits/snapshot.js +105 -20
- package/dist/ai-edits/table-cell-mutations.js +1 -1
- package/dist/ai-edits/table-row-column-mutations.js +7 -0
- package/dist/ai-edits/table-template.d.ts +11 -1
- package/dist/ai-edits/table-template.js +49 -17
- package/dist/ai-edits/types.d.ts +62 -61
- package/dist/ai-edits/word-diff.d.ts +18 -3
- package/dist/ai-edits/word-diff.js +556 -67
- package/dist/ai-suggestions/conflict.js +1 -4
- package/dist/ai-suggestions/text-positions.d.ts +8 -0
- package/dist/ai-suggestions/text-positions.js +27 -5
- package/dist/compare/__fixtures__/body-sequence.js +3 -4
- package/dist/compare/column-alignment.d.ts +13 -13
- package/dist/compare/column-alignment.js +78 -39
- package/dist/compare/compare.d.ts +4 -3
- package/dist/compare/compare.js +48 -21
- package/dist/compare/content-alignment.d.ts +95 -0
- package/dist/compare/content-alignment.js +1450 -0
- package/dist/compare/content-types.d.ts +100 -0
- package/dist/compare/content-types.js +0 -0
- package/dist/compare/content.d.ts +209 -0
- package/dist/compare/content.js +885 -0
- package/dist/compare/formatting.d.ts +5 -5
- package/dist/compare/formatting.js +6 -4
- package/dist/compare/plan.d.ts +6 -1
- package/dist/compare/plan.js +171 -566
- package/dist/compare/scenario.d.ts +2 -2
- package/dist/compare/types.d.ts +3 -3
- package/dist/compare/verification.d.ts +8 -9
- package/dist/compare/verification.js +72 -50
- package/dist/compat/eigenpal.d.ts +5 -3
- package/dist/compat/eigenpal.js +3 -2
- package/dist/controller/headerFooterEditorManager.js +18 -10
- package/dist/controller/hiddenEditorApi.js +1 -1
- package/dist/controller/hiddenEditorManager.d.ts +7 -2
- package/dist/controller/hiddenEditorManager.js +15 -6
- package/dist/controller/layoutPipeline.js +5 -3
- package/dist/controller/noteEditorManager.js +12 -7
- package/dist/display-list/build/headerFooterPrimitives.js +1 -0
- package/dist/display-list/build/storyPrimitives.d.ts +5 -2
- package/dist/display-list/build/storyPrimitives.js +60 -3
- package/dist/display-list/build/tablePrimitives.js +30 -0
- package/dist/display-list/primitives.d.ts +1 -1
- package/dist/document-operations.d.ts +8 -4
- package/dist/document-operations.js +104 -12
- package/dist/docx/blockContentParser.js +6 -27
- package/dist/docx/commentParser.js +2 -4
- package/dist/docx/commentRangeIntegrity.js +2 -4
- package/dist/docx/documentClone.d.ts +2 -0
- package/dist/docx/documentClone.js +2 -0
- package/dist/docx/ensureParaIds.js +9 -4
- package/dist/docx/headerFooterParser.js +2 -4
- package/dist/docx/normalizeBaseDirection.js +5 -7
- package/dist/docx/numberingParser.d.ts +3 -1
- package/dist/docx/numberingParser.js +4 -1
- package/dist/docx/paragraphParser.js +34 -35
- package/dist/docx/paragraphPropertySource.d.ts +49 -0
- package/dist/docx/paragraphPropertySource.js +113 -0
- package/dist/docx/paragraphTraversal.js +30 -34
- package/dist/docx/rezip.d.ts +0 -8
- package/dist/docx/rezip.js +41 -16
- package/dist/docx/runConsolidator.js +2 -4
- package/dist/docx/runParser.js +6 -17
- package/dist/docx/sectionParser.js +1 -15
- package/dist/docx/serializer/paragraphSerializer.js +289 -30
- package/dist/docx/serializer/runSerializer.js +6 -12
- package/dist/docx/serializer/sectionPropertiesSerializer.js +2 -10
- package/dist/docx/serializer/tableSerializer.js +4 -23
- package/dist/docx/serializer/trackedChangeAttributes.d.ts +11 -0
- package/dist/docx/serializer/trackedChangeAttributes.js +31 -0
- package/dist/docx/server/build.d.ts +1 -1
- package/dist/docx/server/createBilingualDocument.js +8 -10
- package/dist/docx/server/evaluateDocxXmlPatchProposal.js +22 -13
- package/dist/docx/server/validateDocxConformance.js +17 -13
- package/dist/docx/tableParser.js +1 -37
- package/dist/docx/trackedChangeInfo.d.ts +11 -0
- package/dist/docx/trackedChangeInfo.js +38 -0
- package/dist/docx/verbatimCapture.d.ts +20 -9
- package/dist/docx/verbatimCapture.js +208 -8
- package/dist/docx/xmlParser.d.ts +3 -1
- package/dist/docx/xmlParser.js +6 -1
- package/dist/docx/xmlSafety.d.ts +1 -1
- package/dist/docx/xmlSafety.js +157 -0
- package/dist/headless-layout.js +5 -4
- package/dist/index.d.ts +5 -3
- package/dist/index.js +3 -2
- package/dist/internal/headlessRevisionResolution.d.ts +23 -0
- package/dist/internal/headlessRevisionResolution.js +155 -0
- package/dist/internal/headlessRevisionResolutionGuard.d.ts +12 -0
- package/dist/internal/headlessRevisionResolutionGuard.js +28 -0
- package/dist/internal/pageBreakRunDescendantIndex.d.ts +9 -0
- package/dist/internal/pageBreakRunDescendantIndex.js +27 -0
- package/dist/internal/pageBreakRunPartition.d.ts +26 -0
- package/dist/internal/pageBreakRunPartition.js +35 -0
- package/dist/internal/pageBreakRunSourceDescendantIndex.d.ts +15 -0
- package/dist/internal/pageBreakRunSourceDescendantIndex.js +126 -0
- package/dist/internal/sectionEndpointResolution.d.ts +32 -0
- package/dist/internal/sectionEndpointResolution.js +38 -0
- package/dist/layout-bridge/convert/footnoteLayout.js +1 -0
- package/dist/layout-bridge/convert/headerFooterLayout.d.ts +16 -4
- package/dist/layout-bridge/convert/headerFooterLayout.js +52 -9
- package/dist/layout-bridge/convert/toFlowBlocks.d.ts +4 -0
- package/dist/layout-bridge/convert/toFlowBlocks.js +391 -82
- package/dist/layout-bridge/dom/clickToPositionDom.d.ts +8 -1
- package/dist/layout-bridge/dom/clickToPositionDom.js +114 -40
- package/dist/layout-bridge/dom/textStreamDom.d.ts +24 -0
- package/dist/layout-bridge/dom/textStreamDom.js +75 -0
- package/dist/layout-bridge/headerFooterLayout.js +16 -30
- package/dist/layout-engine/index.js +12 -3
- package/dist/layout-engine/measure/tableFragmentBorderGeometry.d.ts +17 -0
- package/dist/layout-engine/measure/tableFragmentBorderGeometry.js +24 -0
- package/dist/layout-engine/renderedBreakReconciliation.js +1 -1
- package/dist/layout-engine/types.d.ts +7 -0
- package/dist/layout-painter/imageLayout.d.ts +1 -1
- package/dist/layout-painter/renderTable.js +20 -0
- package/dist/markdown/renderBlock.js +7 -10
- package/dist/model.d.ts +1 -1
- package/dist/paged-layout/rangeProjection.js +6 -9
- package/dist/paged-layout/transactionDirtyRange.d.ts +3 -1
- package/dist/paged-layout/transactionDirtyRange.js +23 -1
- package/dist/prosemirror/attrs/index.d.ts +7 -3
- package/dist/prosemirror/attrs/index.js +128 -7
- package/dist/prosemirror/bookmarkBoundaryIntegrity.d.ts +9 -0
- package/dist/prosemirror/bookmarkBoundaryIntegrity.js +22 -0
- package/dist/prosemirror/commands/comments.d.ts +10 -1
- package/dist/prosemirror/commands/comments.js +551 -87
- package/dist/prosemirror/commands/formatPainter.d.ts +45 -10
- package/dist/prosemirror/commands/formatPainter.js +319 -63
- package/dist/prosemirror/commands/index.d.ts +2 -2
- package/dist/prosemirror/commands/pageBreak.d.ts +5 -2
- package/dist/prosemirror/commands/pageBreak.js +18 -36
- package/dist/prosemirror/commands/propertyChangeScope.d.ts +27 -3
- package/dist/prosemirror/commands/propertyChangeScope.js +85 -14
- package/dist/prosemirror/conversion/fromProseDoc.d.ts +8 -5
- package/dist/prosemirror/conversion/fromProseDoc.js +935 -223
- package/dist/prosemirror/conversion/runShadingMark.js +2 -2
- package/dist/prosemirror/conversion/toProseDoc.d.ts +26 -1
- package/dist/prosemirror/conversion/toProseDoc.js +439 -291
- package/dist/prosemirror/extensions/StarterKit.js +4 -0
- package/dist/prosemirror/extensions/core/ParagraphExtension.js +54 -6
- package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.js +7 -1
- package/dist/prosemirror/extensions/features/ListExtension.js +95 -123
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.js +19 -6
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.d.ts +27 -1
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.js +134 -30
- package/dist/prosemirror/extensions/features/pasteCleanup.js +9 -15
- package/dist/prosemirror/extensions/marks/BoldExtension.js +4 -3
- package/dist/prosemirror/extensions/marks/CharacterStyleExtension.d.ts +4 -7
- package/dist/prosemirror/extensions/marks/CharacterStyleExtension.js +5 -11
- package/dist/prosemirror/extensions/marks/FontSizeExtension.js +3 -3
- package/dist/prosemirror/extensions/marks/ItalicExtension.js +4 -3
- package/dist/prosemirror/extensions/marks/PageBreakRunOwnerExtension.d.ts +13 -0
- package/dist/prosemirror/extensions/marks/PageBreakRunOwnerExtension.js +39 -0
- package/dist/prosemirror/extensions/marks/RunFormattingOverrideExtension.d.ts +7 -1
- package/dist/prosemirror/extensions/marks/RunFormattingOverrideExtension.js +67 -21
- package/dist/prosemirror/extensions/marks/TrackedChangeExtensions.js +2 -0
- package/dist/prosemirror/extensions/marks/markUtils.d.ts +8 -1
- package/dist/prosemirror/extensions/marks/markUtils.js +88 -2
- package/dist/prosemirror/extensions/nodes/BookmarkBoundaryExtension.js +44 -3
- package/dist/prosemirror/extensions/nodes/FieldExtension.js +1 -1
- package/dist/prosemirror/extensions/nodes/HardBreakExtension.js +15 -4
- package/dist/prosemirror/extensions/nodes/PageBreakExtension.d.ts +6 -0
- package/dist/prosemirror/extensions/nodes/PageBreakExtension.js +6 -0
- package/dist/prosemirror/extensions/nodes/PageBreakRunExtension.d.ts +6 -0
- package/dist/prosemirror/extensions/nodes/PageBreakRunExtension.js +36 -0
- package/dist/prosemirror/findReplaceSelection.js +8 -3
- package/dist/prosemirror/index.d.ts +3 -3
- package/dist/prosemirror/listMarker.d.ts +26 -1
- package/dist/prosemirror/listMarker.js +108 -14
- package/dist/prosemirror/pageBreakRunProjection.d.ts +28 -0
- package/dist/prosemirror/pageBreakRunProjection.js +47 -0
- package/dist/prosemirror/paraText.js +6 -0
- package/dist/prosemirror/paragraphAlignment.d.ts +12 -0
- package/dist/prosemirror/paragraphAlignment.js +13 -0
- package/dist/prosemirror/paragraphSpacing.d.ts +29 -0
- package/dist/prosemirror/paragraphSpacing.js +125 -0
- package/dist/prosemirror/plugins/documentNumbering.d.ts +8 -0
- package/dist/prosemirror/plugins/documentNumbering.js +18 -0
- package/dist/prosemirror/plugins/pmTextScan.d.ts +3 -2
- package/dist/prosemirror/plugins/pmTextScan.js +14 -4
- package/dist/prosemirror/plugins/suggestionMode.js +9 -11
- package/dist/prosemirror/rebaseParagraphRunFormatting.d.ts +16 -0
- package/dist/prosemirror/rebaseParagraphRunFormatting.js +61 -0
- package/dist/prosemirror/runFormattingInlineCarriers.d.ts +64 -0
- package/dist/prosemirror/runFormattingInlineCarriers.js +121 -0
- package/dist/prosemirror/runFormattingProvenance.d.ts +12 -0
- package/dist/prosemirror/runFormattingProvenance.js +48 -0
- package/dist/prosemirror/runFormattingReconciliation.d.ts +25 -0
- package/dist/prosemirror/runFormattingReconciliation.js +54 -0
- package/dist/prosemirror/runPropertyChangeResolution.d.ts +18 -0
- package/dist/prosemirror/runPropertyChangeResolution.js +18 -0
- package/dist/prosemirror/runStyleFormatting.d.ts +50 -0
- package/dist/prosemirror/runStyleFormatting.js +105 -0
- package/dist/prosemirror/schema/index.d.ts +3 -3
- package/dist/prosemirror/schema/marks.d.ts +84 -9
- package/dist/prosemirror/schema/marks.js +73 -1
- package/dist/prosemirror/schema/nodes.d.ts +30 -6
- package/dist/prosemirror/styles/resolvedStyleAttrs.d.ts +14 -2
- package/dist/prosemirror/styles/resolvedStyleAttrs.js +45 -23
- package/dist/prosemirror/styles/styleResolver.d.ts +10 -13
- package/dist/prosemirror/styles/styleResolver.js +3 -3
- package/dist/prosemirror/styles/styleToggleCascade.d.ts +8 -1
- package/dist/prosemirror/styles/styleToggleCascade.js +24 -1
- package/dist/prosemirror/tableGridMutation.d.ts +20 -0
- package/dist/prosemirror/tableGridMutation.js +30 -0
- package/dist/prosemirror/trackedRunInlineAtoms.d.ts +31 -0
- package/dist/prosemirror/trackedRunInlineAtoms.js +39 -0
- package/dist/prosemirror/utils/visualLineNavigation.js +27 -31
- package/dist/prosemirror/validation.js +23 -4
- package/dist/redline.js +4 -1
- package/dist/render-dom/HeaderFooterSelectionOverlay.js +20 -20
- package/dist/render-dom/RenderedDomContext.js +17 -34
- package/dist/server.d.ts +4 -4
- package/dist/server.js +2 -2
- package/dist/style-engine/styleEngine.d.ts +1 -1
- package/dist/utils/clipboard.js +1 -1
- package/dist/utils/findReplace.js +38 -21
- package/dist/utils/mergeDocumentContent.js +3 -3
- package/dist/utils/replaceText.js +2 -1
- package/dist/version-comparison.d.ts +38 -44
- package/dist/version-comparison.js +270 -399
- package/dist/watermark/index.js +2 -4
- package/package.json +8 -2
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { mergeDirtyRanges } from "./incrementalMeasure.js";
|
|
1
2
|
import { AddMarkStep, RemoveMarkStep } from "prosemirror-transform";
|
|
2
3
|
//#region src/paged-layout/transactionDirtyRange.ts
|
|
3
4
|
function getTransactionDirtyRange(transaction) {
|
|
@@ -9,6 +10,27 @@ function getTransactionDirtyRange(transaction) {
|
|
|
9
10
|
if (!Number.isFinite(dirtyRange.from) || !Number.isFinite(dirtyRange.to)) return null;
|
|
10
11
|
return dirtyRange;
|
|
11
12
|
}
|
|
13
|
+
/** Collect every transaction in an applied batch in the final document's coordinates. */
|
|
14
|
+
function getTransactionsDirtyRange(transactions) {
|
|
15
|
+
let combinedRange = null;
|
|
16
|
+
for (let index = 0; index < transactions.length; index += 1) {
|
|
17
|
+
const transaction = transactions[index];
|
|
18
|
+
if (!transaction) continue;
|
|
19
|
+
const range = getTransactionDirtyRange(transaction);
|
|
20
|
+
if (!range) continue;
|
|
21
|
+
let from = range.from;
|
|
22
|
+
let to = range.to;
|
|
23
|
+
for (const followingTransaction of transactions.slice(index + 1)) {
|
|
24
|
+
from = followingTransaction.mapping.map(from, -1);
|
|
25
|
+
to = followingTransaction.mapping.map(to, 1);
|
|
26
|
+
}
|
|
27
|
+
combinedRange = mergeDirtyRanges(combinedRange, {
|
|
28
|
+
from,
|
|
29
|
+
to
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
return combinedRange;
|
|
33
|
+
}
|
|
12
34
|
function includeStepDirtyRange(transaction, stepIndex, dirtyRange) {
|
|
13
35
|
const map = transaction.mapping.maps[stepIndex];
|
|
14
36
|
if (!map) return;
|
|
@@ -24,4 +46,4 @@ function includeStepDirtyRange(transaction, stepIndex, dirtyRange) {
|
|
|
24
46
|
if (step instanceof AddMarkStep || step instanceof RemoveMarkStep) extend(step.from, step.to);
|
|
25
47
|
}
|
|
26
48
|
//#endregion
|
|
27
|
-
export { getTransactionDirtyRange };
|
|
49
|
+
export { getTransactionDirtyRange, getTransactionsDirtyRange };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CharacterSpacingAttrs, CharacterStyleAttrs, CommentAttrs, EmphasisMarkAttrs, FontFamilyAttrs, FontSizeAttrs, FootnoteRefAttrs, HighlightAttrs, HyperlinkAttrs, LanguageAttrs, RunFormattingOverrideAttrs, RunPropertyChangeMarkAttrs, RunShadingAttrs, StrikeAttrs, TextColorAttrs, TextEffectAttrs, TrackedChangeMarkAttrs, UnderlineAttrs } from "../schema/marks.js";
|
|
2
|
-
import { BlockSdtAttrs, FieldAttrs, HardBreakAttrs, ImageAttrs, MathAttrs, ParagraphAttrs, SdtAttrs, ShapeAttrs, SymbolAttrs, TabAttrs, TableAttrs, TableCellAttrs, TableRowAttrs, TextBoxAttrs } from "../schema/nodes.js";
|
|
1
|
+
import { CharacterSpacingAttrs, CharacterStyleAttrs, CommentAttrs, EmphasisMarkAttrs, FontFamilyAttrs, FontSizeAttrs, FootnoteRefAttrs, HighlightAttrs, HyperlinkAttrs, LanguageAttrs, PageBreakRunOwnerMarkAttrs, RunFormattingOverrideAttrs, RunPropertyChangeMarkAttrs, RunShadingAttrs, StrikeAttrs, TextColorAttrs, TextEffectAttrs, TrackedChangeMarkAttrs, UnderlineAttrs } from "../schema/marks.js";
|
|
2
|
+
import { BlockSdtAttrs, FieldAttrs, HardBreakAttrs, ImageAttrs, MathAttrs, PageBreakRunAttrs, ParagraphAttrs, SdtAttrs, ShapeAttrs, SymbolAttrs, TabAttrs, TableAttrs, TableCellAttrs, TableRowAttrs, TextBoxAttrs } from "../schema/nodes.js";
|
|
3
3
|
import "../schema/index.js";
|
|
4
4
|
import { Mark, Node } from "prosemirror-model";
|
|
5
5
|
//#region src/prosemirror/attrs/index.d.ts
|
|
@@ -18,6 +18,8 @@ declare const readParagraphAttrs: (node: Node) => ReadProseMirrorAttrsResult<Par
|
|
|
18
18
|
declare const expectParagraphAttrs: (node: Node) => ParagraphAttrs;
|
|
19
19
|
declare const readHardBreakAttrs: (node: Node) => ReadProseMirrorAttrsResult<HardBreakAttrs>;
|
|
20
20
|
declare const expectHardBreakAttrs: (node: Node) => HardBreakAttrs;
|
|
21
|
+
declare const readPageBreakRunAttrs: (node: Node) => ReadProseMirrorAttrsResult<PageBreakRunAttrs>;
|
|
22
|
+
declare const expectPageBreakRunAttrs: (node: Node) => PageBreakRunAttrs;
|
|
21
23
|
declare const readTabAttrs: (node: Node) => ReadProseMirrorAttrsResult<TabAttrs>;
|
|
22
24
|
declare const expectTabAttrs: (node: Node) => TabAttrs;
|
|
23
25
|
declare const readSymbolAttrs: (node: Node) => ReadProseMirrorAttrsResult<SymbolAttrs>;
|
|
@@ -74,6 +76,8 @@ declare const readTrackedChangeMarkAttrs: (mark: Mark) => ReadProseMirrorAttrsRe
|
|
|
74
76
|
declare const expectTrackedChangeMarkAttrs: (mark: Mark) => TrackedChangeMarkAttrs;
|
|
75
77
|
declare const readRunPropertyChangeMarkAttrs: (mark: Mark) => ReadProseMirrorAttrsResult<RunPropertyChangeMarkAttrs>;
|
|
76
78
|
declare const expectRunPropertyChangeMarkAttrs: (mark: Mark) => RunPropertyChangeMarkAttrs;
|
|
79
|
+
declare const readPageBreakRunOwnerMarkAttrs: (mark: Mark) => ReadProseMirrorAttrsResult<PageBreakRunOwnerMarkAttrs>;
|
|
80
|
+
declare const expectPageBreakRunOwnerMarkAttrs: (mark: Mark) => PageBreakRunOwnerMarkAttrs;
|
|
77
81
|
declare const readRunFormattingOverrideMarkAttrs: (mark: Mark) => ReadProseMirrorAttrsResult<RunFormattingOverrideAttrs>;
|
|
78
82
|
declare const expectRunFormattingOverrideMarkAttrs: (mark: Mark) => RunFormattingOverrideAttrs;
|
|
79
83
|
declare const readHyperlinkMarkAttrs: (mark: Mark) => ReadProseMirrorAttrsResult<HyperlinkAttrs>;
|
|
@@ -85,4 +89,4 @@ declare const mergeTableAttrs: (node: Node, patch: NodeAttrPatch<TableAttrs>) =>
|
|
|
85
89
|
declare const mergeTableRowAttrs: (node: Node, patch: NodeAttrPatch<TableRowAttrs>) => TableRowAttrs;
|
|
86
90
|
declare const mergeTableCellAttrs: (node: Node, patch: NodeAttrPatch<TableCellAttrs>) => TableCellAttrs;
|
|
87
91
|
//#endregion
|
|
88
|
-
export { ProseMirrorAttrIssue, ReadProseMirrorAttrsResult, expectBlockSdtAttrs, expectCharacterSpacingMarkAttrs, expectCharacterStyleMarkAttrs, expectCommentMarkAttrs, expectEmphasisMarkAttrs, expectFieldAttrs, expectFontFamilyMarkAttrs, expectFontSizeMarkAttrs, expectFootnoteRefMarkAttrs, expectHardBreakAttrs, expectHighlightMarkAttrs, expectHyperlinkMarkAttrs, expectImageAttrs, expectLanguageMarkAttrs, expectMathAttrs, expectParagraphAttrs, expectRunFormattingOverrideMarkAttrs, expectRunPropertyChangeMarkAttrs, expectRunShadingMarkAttrs, expectSdtAttrs, expectShapeAttrs, expectStrikeMarkAttrs, expectSymbolAttrs, expectTabAttrs, expectTableAttrs, expectTableCellAttrs, expectTableRowAttrs, expectTextBoxAttrs, expectTextColorMarkAttrs, expectTextEffectMarkAttrs, expectTrackedChangeMarkAttrs, expectUnderlineMarkAttrs, mergeImageAttrs, mergeParagraphAttrs, mergeTableAttrs, mergeTableCellAttrs, mergeTableRowAttrs, readBlockSdtAttrs, readCharacterSpacingMarkAttrs, readCharacterStyleMarkAttrs, readCommentMarkAttrs, readEmphasisMarkAttrs, readFieldAttrs, readFontFamilyMarkAttrs, readFontSizeMarkAttrs, readFootnoteRefMarkAttrs, readHardBreakAttrs, readHighlightMarkAttrs, readHyperlinkMarkAttrs, readImageAttrs, readLanguageMarkAttrs, readMathAttrs, readParagraphAttrs, readRunFormattingOverrideMarkAttrs, readRunPropertyChangeMarkAttrs, readRunShadingMarkAttrs, readSdtAttrs, readShapeAttrs, readStrikeMarkAttrs, readSymbolAttrs, readTabAttrs, readTableAttrs, readTableCellAttrs, readTableRowAttrs, readTextBoxAttrs, readTextColorMarkAttrs, readTextEffectMarkAttrs, readTrackedChangeMarkAttrs, readUnderlineMarkAttrs };
|
|
92
|
+
export { ProseMirrorAttrIssue, ReadProseMirrorAttrsResult, expectBlockSdtAttrs, expectCharacterSpacingMarkAttrs, expectCharacterStyleMarkAttrs, expectCommentMarkAttrs, expectEmphasisMarkAttrs, expectFieldAttrs, expectFontFamilyMarkAttrs, expectFontSizeMarkAttrs, expectFootnoteRefMarkAttrs, expectHardBreakAttrs, expectHighlightMarkAttrs, expectHyperlinkMarkAttrs, expectImageAttrs, expectLanguageMarkAttrs, expectMathAttrs, expectPageBreakRunAttrs, expectPageBreakRunOwnerMarkAttrs, expectParagraphAttrs, expectRunFormattingOverrideMarkAttrs, expectRunPropertyChangeMarkAttrs, expectRunShadingMarkAttrs, expectSdtAttrs, expectShapeAttrs, expectStrikeMarkAttrs, expectSymbolAttrs, expectTabAttrs, expectTableAttrs, expectTableCellAttrs, expectTableRowAttrs, expectTextBoxAttrs, expectTextColorMarkAttrs, expectTextEffectMarkAttrs, expectTrackedChangeMarkAttrs, expectUnderlineMarkAttrs, mergeImageAttrs, mergeParagraphAttrs, mergeTableAttrs, mergeTableCellAttrs, mergeTableRowAttrs, 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 };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { EMPHASIS_MARK_VALUES, FIELD_TYPE_VALUES, FONT_HINT_VALUES, FONT_THEME_VALUES, HIGHLIGHT_COLOR_VALUES, IMAGE_HORIZONTAL_ALIGNMENT_VALUES, IMAGE_HORIZONTAL_RELATIVE_TO_VALUES, IMAGE_VERTICAL_ALIGNMENT_VALUES, IMAGE_VERTICAL_RELATIVE_TO_VALUES, IMAGE_WRAP_TEXT_VALUES, IMAGE_WRAP_TYPE_VALUES, LINE_SPACING_RULE_VALUES, NUMBER_FORMAT_VALUES, OUTLINE_STYLE_ATTR_VALUES, PARAGRAPH_ALIGNMENT_VALUES, POSITIONAL_TAB_ALIGNMENT_VALUES, POSITIONAL_TAB_LEADER_VALUES, POSITIONAL_TAB_RELATIVE_TO_VALUES, SDT_LOCK_VALUES, SDT_TYPE_VALUES, SHADING_PATTERN_VALUES, TABLE_CELL_TEXT_DIRECTION_VALUES, TABLE_CELL_VERTICAL_ALIGNMENT_VALUES, TABLE_JUSTIFICATION_VALUES, TABLE_ROW_HEIGHT_RULE_VALUES, TABLE_WIDTH_TYPE_VALUES, TAB_LEADER_VALUES, TAB_STOP_ALIGNMENT_VALUES, TEXT_EFFECT_VALUES, THEME_COLOR_SLOT_VALUES, UNDERLINE_STYLE_VALUES } from "../../types/documentEnumValues.js";
|
|
2
2
|
import { normalizeHorizontalScalePercent } from "../../utils/horizontalScale.js";
|
|
3
3
|
import { isParagraphDirection } from "../paragraphDirection.js";
|
|
4
|
-
import { TRACKED_CHANGE_PROVENANCE_VALUES } from "../schema/marks.js";
|
|
4
|
+
import { COMPLEX_SCRIPT_RUN_PROPERTY_KEYS, RUN_FORMATTING_BOOLEAN_PROPERTIES, RUN_FORMATTING_VALUE_PROPERTIES, TRACKED_CHANGE_PROVENANCE_VALUES } from "../schema/marks.js";
|
|
5
5
|
import { panic } from "better-result";
|
|
6
6
|
import { DRAWING_RAW_XML_MODES, isOoxmlSymbolCharacter } from "@stll/docx-core/model";
|
|
7
7
|
//#region src/prosemirror/attrs/index.ts
|
|
@@ -77,7 +77,13 @@ const TEXT_BOX_TRACKED_CHANGE_TYPES = [
|
|
|
77
77
|
"moveFrom",
|
|
78
78
|
"moveTo"
|
|
79
79
|
];
|
|
80
|
-
const HARD_BREAK_TYPES = ["column"];
|
|
80
|
+
const HARD_BREAK_TYPES = ["column", "textWrapping"];
|
|
81
|
+
const PAGE_BREAK_CLEAR_VALUES = [
|
|
82
|
+
"none",
|
|
83
|
+
"left",
|
|
84
|
+
"right",
|
|
85
|
+
"all"
|
|
86
|
+
];
|
|
81
87
|
const RUN_FORMATTING_OVERRIDE_BOOLEAN_KEYS = [
|
|
82
88
|
"bold",
|
|
83
89
|
"italic",
|
|
@@ -91,6 +97,20 @@ const RUN_FORMATTING_OVERRIDE_BOOLEAN_KEYS = [
|
|
|
91
97
|
"outline"
|
|
92
98
|
];
|
|
93
99
|
const RUN_FORMATTING_OVERRIDE_FALSE_KEYS = ["doubleStrike", "rtl"];
|
|
100
|
+
const RUN_FORMATTING_OVERRIDE_STRING_SENTINELS = {
|
|
101
|
+
color: ["auto"],
|
|
102
|
+
effect: ["none"],
|
|
103
|
+
emphasisMark: ["none"],
|
|
104
|
+
highlight: ["none"],
|
|
105
|
+
underline: ["none"],
|
|
106
|
+
vertAlign: ["baseline"]
|
|
107
|
+
};
|
|
108
|
+
const RUN_FORMATTING_OVERRIDE_NUMBER_SENTINELS = {
|
|
109
|
+
kerning: 0,
|
|
110
|
+
position: 0,
|
|
111
|
+
scale: 100,
|
|
112
|
+
spacing: 0
|
|
113
|
+
};
|
|
94
114
|
const RUN_FORMATTING_OVERRIDE_DIRECT_FONT_PROPERTIES = [
|
|
95
115
|
"fontFamily",
|
|
96
116
|
"fontSize",
|
|
@@ -112,6 +132,7 @@ const SECTION_VERTICAL_ALIGNMENTS = [
|
|
|
112
132
|
];
|
|
113
133
|
const paragraphAttrsCache = /* @__PURE__ */ new WeakMap();
|
|
114
134
|
const hardBreakAttrsCache = /* @__PURE__ */ new WeakMap();
|
|
135
|
+
const pageBreakRunAttrsCache = /* @__PURE__ */ new WeakMap();
|
|
115
136
|
const tabAttrsCache = /* @__PURE__ */ new WeakMap();
|
|
116
137
|
const symbolAttrsCache = /* @__PURE__ */ new WeakMap();
|
|
117
138
|
const tableAttrsCache = /* @__PURE__ */ new WeakMap();
|
|
@@ -139,6 +160,7 @@ const footnoteRefAttrsCache = /* @__PURE__ */ new WeakMap();
|
|
|
139
160
|
const commentAttrsCache = /* @__PURE__ */ new WeakMap();
|
|
140
161
|
const trackedChangeAttrsCache = /* @__PURE__ */ new WeakMap();
|
|
141
162
|
const runPropertyChangeAttrsCache = /* @__PURE__ */ new WeakMap();
|
|
163
|
+
const pageBreakRunOwnerAttrsCache = /* @__PURE__ */ new WeakMap();
|
|
142
164
|
const runFormattingOverrideAttrsCache = /* @__PURE__ */ new WeakMap();
|
|
143
165
|
const hyperlinkAttrsCache = /* @__PURE__ */ new WeakMap();
|
|
144
166
|
const readParagraphAttrs = (node) => {
|
|
@@ -148,6 +170,7 @@ const readParagraphAttrs = (node) => {
|
|
|
148
170
|
optionalString(attrs, "paraId", "paragraph.attrs.paraId", issues);
|
|
149
171
|
optionalString(attrs, "textId", "paragraph.attrs.textId", issues);
|
|
150
172
|
optionalOneOf(attrs, "alignment", "paragraph.attrs.alignment", issues, PARAGRAPH_ALIGNMENT_VALUES);
|
|
173
|
+
optionalOneOf(attrs, "alignmentFromStyle", "paragraph.attrs.alignmentFromStyle", issues, PARAGRAPH_ALIGNMENT_VALUES);
|
|
151
174
|
optionalString(attrs, "styleId", "paragraph.attrs.styleId", issues);
|
|
152
175
|
optionalNumber(attrs, "_tableOfContentsLevel", "paragraph.attrs._tableOfContentsLevel", issues);
|
|
153
176
|
optionalBoolean(attrs, "kinsoku", "paragraph.attrs.kinsoku", issues);
|
|
@@ -157,7 +180,7 @@ const readParagraphAttrs = (node) => {
|
|
|
157
180
|
optionalNumber(attrs, "spaceBefore", "paragraph.attrs.spaceBefore", issues);
|
|
158
181
|
optionalNumber(attrs, "spaceAfter", "paragraph.attrs.spaceAfter", issues);
|
|
159
182
|
optionalNumber(attrs, "lineSpacing", "paragraph.attrs.lineSpacing", issues);
|
|
160
|
-
|
|
183
|
+
optionalLineSpacingProvenance(attrs, "lineSpacingExplicit", "paragraph.attrs.lineSpacingExplicit", issues);
|
|
161
184
|
optionalBoolean(attrs, "snapToGrid", "paragraph.attrs.snapToGrid", issues);
|
|
162
185
|
optionalOneOf(attrs, "lineSpacingRule", "paragraph.attrs.lineSpacingRule", issues, LINE_SPACING_RULE_VALUES);
|
|
163
186
|
optionalNumber(attrs, "indentLeft", "paragraph.attrs.indentLeft", issues);
|
|
@@ -169,6 +192,7 @@ const readParagraphAttrs = (node) => {
|
|
|
169
192
|
optionalBoolean(attrs, "listIsBullet", "paragraph.attrs.listIsBullet", issues);
|
|
170
193
|
optionalBoolean(attrs, "listIsLegal", "paragraph.attrs.listIsLegal", issues);
|
|
171
194
|
optionalString(attrs, "listMarker", "paragraph.attrs.listMarker", issues);
|
|
195
|
+
optionalString(attrs, "listMarkerTemplate", "paragraph.attrs.listMarkerTemplate", issues);
|
|
172
196
|
optionalBoolean(attrs, "listMarkerHidden", "paragraph.attrs.listMarkerHidden", issues);
|
|
173
197
|
optionalTextFormatting(attrs, "listMarkerFormatting", "paragraph.attrs.listMarkerFormatting", issues);
|
|
174
198
|
optionalOneOf(attrs, "listMarkerAlignment", "paragraph.attrs.listMarkerAlignment", issues, [
|
|
@@ -228,9 +252,18 @@ const readHardBreakAttrs = (node) => {
|
|
|
228
252
|
const issues = [];
|
|
229
253
|
expectNodeType(node, "hardBreak", issues);
|
|
230
254
|
optionalOneOf(attrs, "breakType", "hardBreak.attrs.breakType", issues, HARD_BREAK_TYPES);
|
|
255
|
+
optionalOneOf(attrs, "clear", "hardBreak.attrs.clear", issues, PAGE_BREAK_CLEAR_VALUES);
|
|
231
256
|
return attrsResult(attrs, issues);
|
|
232
257
|
};
|
|
233
258
|
const expectHardBreakAttrs = (node) => expectCachedNodeAttrs(node, hardBreakAttrsCache, readHardBreakAttrs, "hard break attrs");
|
|
259
|
+
const readPageBreakRunAttrs = (node) => {
|
|
260
|
+
const attrs = attrsRecord(node.attrs);
|
|
261
|
+
const issues = [];
|
|
262
|
+
expectNodeType(node, "pageBreakRun", issues);
|
|
263
|
+
optionalOneOf(attrs, "clear", "pageBreakRun.attrs.clear", issues, PAGE_BREAK_CLEAR_VALUES);
|
|
264
|
+
return attrsResult(attrs, issues);
|
|
265
|
+
};
|
|
266
|
+
const expectPageBreakRunAttrs = (node) => expectCachedNodeAttrs(node, pageBreakRunAttrsCache, readPageBreakRunAttrs, "page break run attrs");
|
|
234
267
|
const readTabAttrs = (node) => {
|
|
235
268
|
const attrs = attrsRecord(node.attrs);
|
|
236
269
|
const issues = [];
|
|
@@ -557,7 +590,6 @@ const readCharacterStyleMarkAttrs = (mark) => {
|
|
|
557
590
|
const issues = [];
|
|
558
591
|
expectMarkType(mark, "characterStyle", issues);
|
|
559
592
|
requiredString(attrs, "styleId", "characterStyle.attrs.styleId", issues);
|
|
560
|
-
optionalRecord(attrs, "_styleRPr", "characterStyle.attrs._styleRPr", issues);
|
|
561
593
|
return attrsResult(attrs, issues);
|
|
562
594
|
};
|
|
563
595
|
const expectCharacterStyleMarkAttrs = (mark) => expectCachedMarkAttrs(mark, characterStyleAttrsCache, readCharacterStyleMarkAttrs, "character style attrs");
|
|
@@ -655,6 +687,7 @@ const readTrackedChangeMarkAttrs = (mark) => {
|
|
|
655
687
|
requiredNumber(attrs, "revisionId", `${mark.type.name}.attrs.revisionId`, issues);
|
|
656
688
|
requiredString(attrs, "author", `${mark.type.name}.attrs.author`, issues);
|
|
657
689
|
optionalString(attrs, "date", `${mark.type.name}.attrs.date`, issues);
|
|
690
|
+
optionalString(attrs, "utcDate", `${mark.type.name}.attrs.utcDate`, issues);
|
|
658
691
|
optionalString(attrs, "initials", `${mark.type.name}.attrs.initials`, issues);
|
|
659
692
|
optionalOneOf(attrs, "moveKind", `${mark.type.name}.attrs.moveKind`, issues, TRACKED_CHANGE_MOVE_KINDS);
|
|
660
693
|
optionalOneOf(attrs, "provenance", `${mark.type.name}.attrs.provenance`, issues, TRACKED_CHANGE_PROVENANCE_VALUES);
|
|
@@ -672,6 +705,18 @@ const readRunPropertyChangeMarkAttrs = (mark) => {
|
|
|
672
705
|
return attrsResult(attrs, issues);
|
|
673
706
|
};
|
|
674
707
|
const expectRunPropertyChangeMarkAttrs = (mark) => expectCachedMarkAttrs(mark, runPropertyChangeAttrsCache, readRunPropertyChangeMarkAttrs, "run property change attrs");
|
|
708
|
+
const readPageBreakRunOwnerMarkAttrs = (mark) => {
|
|
709
|
+
const attrs = attrsRecord(mark.attrs);
|
|
710
|
+
const issues = [];
|
|
711
|
+
expectMarkType(mark, "pageBreakRunOwner", issues);
|
|
712
|
+
const id = attrs["id"];
|
|
713
|
+
if (typeof id !== "number" || !Number.isSafeInteger(id) || id < 0) issues.push({
|
|
714
|
+
path: "pageBreakRunOwner.attrs.id",
|
|
715
|
+
message: "Expected a non-negative safe integer."
|
|
716
|
+
});
|
|
717
|
+
return attrsResult(attrs, issues);
|
|
718
|
+
};
|
|
719
|
+
const expectPageBreakRunOwnerMarkAttrs = (mark) => expectCachedMarkAttrs(mark, pageBreakRunOwnerAttrsCache, readPageBreakRunOwnerMarkAttrs, "page break run owner attrs");
|
|
675
720
|
const readRunFormattingOverrideMarkAttrs = (mark) => {
|
|
676
721
|
const attrs = attrsRecord(mark.attrs);
|
|
677
722
|
const issues = [];
|
|
@@ -682,13 +727,65 @@ const readRunFormattingOverrideMarkAttrs = (mark) => {
|
|
|
682
727
|
optionalBoolean(attrs, "italicCs", "runFormattingOverride.attrs.italicCs", issues);
|
|
683
728
|
optionalNumber(attrs, "fontSizeCs", "runFormattingOverride.attrs.fontSizeCs", issues);
|
|
684
729
|
optionalBoolean(attrs, "cs", "runFormattingOverride.attrs.cs", issues);
|
|
685
|
-
|
|
730
|
+
optionalShading(attrs, "shading", "runFormattingOverride.attrs.shading", issues);
|
|
731
|
+
const shading = attrs["shading"];
|
|
732
|
+
if (isRecord(shading) && shading["pattern"] !== "nil") issues.push({
|
|
733
|
+
path: "runFormattingOverride.attrs.shading.pattern",
|
|
734
|
+
message: "Expected \"nil\"."
|
|
735
|
+
});
|
|
736
|
+
for (const [key, values] of Object.entries(RUN_FORMATTING_OVERRIDE_STRING_SENTINELS)) optionalOneOf(attrs, key, `runFormattingOverride.attrs.${key}`, issues, values);
|
|
737
|
+
for (const [key, expected] of Object.entries(RUN_FORMATTING_OVERRIDE_NUMBER_SENTINELS)) {
|
|
738
|
+
const value = attrs[key];
|
|
739
|
+
if (value !== void 0 && value !== null && value !== expected) issues.push({
|
|
740
|
+
path: `runFormattingOverride.attrs.${key}`,
|
|
741
|
+
message: `Expected ${expected}.`
|
|
742
|
+
});
|
|
743
|
+
}
|
|
686
744
|
optionalOneOfArray(attrs, "directFontProperties", "runFormattingOverride.attrs.directFontProperties", issues, RUN_FORMATTING_OVERRIDE_DIRECT_FONT_PROPERTIES);
|
|
745
|
+
optionalOneOfArray(attrs, "complexScriptPropertyAbsences", "runFormattingOverride.attrs.complexScriptPropertyAbsences", issues, COMPLEX_SCRIPT_RUN_PROPERTY_KEYS);
|
|
746
|
+
optionalOneOfArray(attrs, "_authoredOn", "runFormattingOverride.attrs._authoredOn", issues, RUN_FORMATTING_BOOLEAN_PROPERTIES);
|
|
747
|
+
optionalOneOfArray(attrs, "_authoredOff", "runFormattingOverride.attrs._authoredOff", issues, RUN_FORMATTING_BOOLEAN_PROPERTIES);
|
|
748
|
+
optionalTextFormatting(attrs, "_authoredValues", "runFormattingOverride.attrs._authoredValues", issues);
|
|
749
|
+
const authoredValues = attrs["_authoredValues"];
|
|
750
|
+
if (isRecord(authoredValues)) {
|
|
751
|
+
const allowed = new Set(RUN_FORMATTING_VALUE_PROPERTIES);
|
|
752
|
+
for (const property of Object.keys(authoredValues)) if (!allowed.has(property)) issues.push({
|
|
753
|
+
path: `runFormattingOverride.attrs._authoredValues.${property}`,
|
|
754
|
+
message: "Expected a non-boolean authored formatting property."
|
|
755
|
+
});
|
|
756
|
+
}
|
|
687
757
|
const directFontProperties = attrs["directFontProperties"];
|
|
688
758
|
if (Array.isArray(directFontProperties) && new Set(directFontProperties).size !== directFontProperties.length) issues.push({
|
|
689
759
|
path: "runFormattingOverride.attrs.directFontProperties",
|
|
690
760
|
message: "Expected unique direct font properties."
|
|
691
761
|
});
|
|
762
|
+
const complexScriptPropertyAbsences = attrs["complexScriptPropertyAbsences"];
|
|
763
|
+
if (Array.isArray(complexScriptPropertyAbsences) && new Set(complexScriptPropertyAbsences).size !== complexScriptPropertyAbsences.length) issues.push({
|
|
764
|
+
path: "runFormattingOverride.attrs.complexScriptPropertyAbsences",
|
|
765
|
+
message: "Expected unique complex-script property absences."
|
|
766
|
+
});
|
|
767
|
+
if (Array.isArray(complexScriptPropertyAbsences)) {
|
|
768
|
+
for (const property of complexScriptPropertyAbsences) if (attrs[property] !== void 0 && attrs[property] !== null) issues.push({
|
|
769
|
+
path: `runFormattingOverride.attrs.${property}`,
|
|
770
|
+
message: "Expected a property to be either present or explicitly absent, not both."
|
|
771
|
+
});
|
|
772
|
+
}
|
|
773
|
+
for (const provenanceKey of ["_authoredOn", "_authoredOff"]) {
|
|
774
|
+
const properties = attrs[provenanceKey];
|
|
775
|
+
if (Array.isArray(properties) && new Set(properties).size !== properties.length) issues.push({
|
|
776
|
+
path: `runFormattingOverride.attrs.${provenanceKey}`,
|
|
777
|
+
message: "Expected unique authored formatting properties."
|
|
778
|
+
});
|
|
779
|
+
}
|
|
780
|
+
const authoredOn = attrs["_authoredOn"];
|
|
781
|
+
const authoredOff = attrs["_authoredOff"];
|
|
782
|
+
if (Array.isArray(authoredOn) && Array.isArray(authoredOff)) {
|
|
783
|
+
const off = new Set(authoredOff);
|
|
784
|
+
for (const property of authoredOn) if (off.has(property)) issues.push({
|
|
785
|
+
path: "runFormattingOverride.attrs._authoredOff",
|
|
786
|
+
message: "Expected authored formatting to be either on or off, not both."
|
|
787
|
+
});
|
|
788
|
+
}
|
|
692
789
|
return attrsResult(attrs, issues);
|
|
693
790
|
};
|
|
694
791
|
const expectRunFormattingOverrideMarkAttrs = (mark) => expectCachedMarkAttrs(mark, runFormattingOverrideAttrsCache, readRunFormattingOverrideMarkAttrs, "run formatting override attrs");
|
|
@@ -918,6 +1015,16 @@ const optionalOneOf = (attrs, key, path, issues, allowed) => {
|
|
|
918
1015
|
message: `Expected one of ${allowed.join(", ")}.`
|
|
919
1016
|
});
|
|
920
1017
|
};
|
|
1018
|
+
const LINE_SPACING_PROVENANCE_VALUES = [
|
|
1019
|
+
"value",
|
|
1020
|
+
"rule",
|
|
1021
|
+
"both"
|
|
1022
|
+
];
|
|
1023
|
+
const optionalLineSpacingProvenance = (attrs, key, path, issues) => {
|
|
1024
|
+
const value = attrs[key];
|
|
1025
|
+
if (value === void 0 || value === null || typeof value === "boolean") return;
|
|
1026
|
+
optionalOneOf(attrs, key, path, issues, LINE_SPACING_PROVENANCE_VALUES);
|
|
1027
|
+
};
|
|
921
1028
|
const optionalShapeLineEnd = (attrs, key, path, issues) => {
|
|
922
1029
|
const value = attrs[key];
|
|
923
1030
|
if (value === void 0 || value === null) return;
|
|
@@ -1005,6 +1112,7 @@ const optionalTableRowRevision = (attrs, key, issues) => {
|
|
|
1005
1112
|
requiredNumber(value, "revisionId", `${path}.revisionId`, issues);
|
|
1006
1113
|
requiredString(value, "author", `${path}.author`, issues);
|
|
1007
1114
|
optionalString(value, "date", `${path}.date`, issues);
|
|
1115
|
+
optionalString(value, "utcDate", `${path}.utcDate`, issues);
|
|
1008
1116
|
optionalString(value, "initials", `${path}.initials`, issues);
|
|
1009
1117
|
optionalOneOf(value, "provenance", `${path}.provenance`, issues, TRACKED_CHANGE_PROVENANCE_VALUES);
|
|
1010
1118
|
optionalString(value, "suggestionId", `${path}.suggestionId`, issues);
|
|
@@ -1036,6 +1144,7 @@ const optionalTableCellRevision = (attrs, issues) => {
|
|
|
1036
1144
|
requiredNumber(info, "revisionId", `${path}.info.revisionId`, issues);
|
|
1037
1145
|
requiredString(info, "author", `${path}.info.author`, issues);
|
|
1038
1146
|
optionalString(info, "date", `${path}.info.date`, issues);
|
|
1147
|
+
optionalString(info, "utcDate", `${path}.info.utcDate`, issues);
|
|
1039
1148
|
optionalString(info, "initials", `${path}.info.initials`, issues);
|
|
1040
1149
|
if (value["kind"] === "merge") {
|
|
1041
1150
|
if (info["provenance"] !== void 0) issues.push({
|
|
@@ -1424,8 +1533,8 @@ const PARAGRAPH_FORMATTING_NUMBER_KEYS = [
|
|
|
1424
1533
|
const validateParagraphFormatting = (value, path, issues) => {
|
|
1425
1534
|
optionalOneOf(value, "alignment", `${path}.alignment`, issues, PARAGRAPH_ALIGNMENT_VALUES);
|
|
1426
1535
|
for (const key of PARAGRAPH_FORMATTING_BOOLEAN_KEYS) optionalBoolean(value, key, `${path}.${key}`, issues);
|
|
1536
|
+
optionalLineSpacingProvenance(value, "lineSpacingExplicit", `${path}.lineSpacingExplicit`, issues);
|
|
1427
1537
|
for (const key of [
|
|
1428
|
-
"lineSpacingExplicit",
|
|
1429
1538
|
"listIsBullet",
|
|
1430
1539
|
"listIsLegal",
|
|
1431
1540
|
"listMarkerHidden",
|
|
@@ -1442,6 +1551,7 @@ const validateParagraphFormatting = (value, path, issues) => {
|
|
|
1442
1551
|
optionalString(value, "styleId", `${path}.styleId`, issues);
|
|
1443
1552
|
optionalOneOf(value, "listNumFmt", `${path}.listNumFmt`, issues, NUMBER_FORMAT_VALUES);
|
|
1444
1553
|
optionalString(value, "listMarker", `${path}.listMarker`, issues);
|
|
1554
|
+
optionalString(value, "listMarkerTemplate", `${path}.listMarkerTemplate`, issues);
|
|
1445
1555
|
optionalTextFormatting(value, "listMarkerFormatting", `${path}.listMarkerFormatting`, issues);
|
|
1446
1556
|
optionalOneOf(value, "listMarkerAlignment", `${path}.listMarkerAlignment`, issues, [
|
|
1447
1557
|
"left",
|
|
@@ -1568,7 +1678,18 @@ const validatePropertyChangeInfo = (value, path, issues) => {
|
|
|
1568
1678
|
requiredNumber(value, "id", `${path}.id`, issues);
|
|
1569
1679
|
requiredString(value, "author", `${path}.author`, issues);
|
|
1570
1680
|
optionalString(value, "date", `${path}.date`, issues);
|
|
1681
|
+
const utcDate = value["utcDate"];
|
|
1682
|
+
if (utcDate !== void 0) if (!isRecord(utcDate)) issues.push({
|
|
1683
|
+
path: `${path}.utcDate`,
|
|
1684
|
+
message: "Expected an object."
|
|
1685
|
+
});
|
|
1686
|
+
else {
|
|
1687
|
+
requiredString(utcDate, "attribute", `${path}.utcDate.attribute`, issues);
|
|
1688
|
+
requiredString(utcDate, "value", `${path}.utcDate.value`, issues);
|
|
1689
|
+
}
|
|
1571
1690
|
optionalString(value, "rsid", `${path}.rsid`, issues);
|
|
1691
|
+
optionalOneOf(value, "provenance", `${path}.provenance`, issues, TRACKED_CHANGE_PROVENANCE_VALUES);
|
|
1692
|
+
optionalString(value, "suggestionId", `${path}.suggestionId`, issues);
|
|
1572
1693
|
};
|
|
1573
1694
|
const optionalImagePosition = (attrs, key, path, issues) => {
|
|
1574
1695
|
const value = attrs[key];
|
|
@@ -1729,4 +1850,4 @@ const optionalEmptyHyperlinkArray = (value, issues) => {
|
|
|
1729
1850
|
}
|
|
1730
1851
|
};
|
|
1731
1852
|
//#endregion
|
|
1732
|
-
export { expectBlockSdtAttrs, expectCharacterSpacingMarkAttrs, expectCharacterStyleMarkAttrs, expectCommentMarkAttrs, expectEmphasisMarkAttrs, expectFieldAttrs, expectFontFamilyMarkAttrs, expectFontSizeMarkAttrs, expectFootnoteRefMarkAttrs, expectHardBreakAttrs, expectHighlightMarkAttrs, expectHyperlinkMarkAttrs, expectImageAttrs, expectLanguageMarkAttrs, expectMathAttrs, expectParagraphAttrs, expectRunFormattingOverrideMarkAttrs, expectRunPropertyChangeMarkAttrs, expectRunShadingMarkAttrs, expectSdtAttrs, expectShapeAttrs, expectStrikeMarkAttrs, expectSymbolAttrs, expectTabAttrs, expectTableAttrs, expectTableCellAttrs, expectTableRowAttrs, expectTextBoxAttrs, expectTextColorMarkAttrs, expectTextEffectMarkAttrs, expectTrackedChangeMarkAttrs, expectUnderlineMarkAttrs, mergeImageAttrs, mergeParagraphAttrs, mergeTableAttrs, mergeTableCellAttrs, mergeTableRowAttrs, readBlockSdtAttrs, readCharacterSpacingMarkAttrs, readCharacterStyleMarkAttrs, readCommentMarkAttrs, readEmphasisMarkAttrs, readFieldAttrs, readFontFamilyMarkAttrs, readFontSizeMarkAttrs, readFootnoteRefMarkAttrs, readHardBreakAttrs, readHighlightMarkAttrs, readHyperlinkMarkAttrs, readImageAttrs, readLanguageMarkAttrs, readMathAttrs, readParagraphAttrs, readRunFormattingOverrideMarkAttrs, readRunPropertyChangeMarkAttrs, readRunShadingMarkAttrs, readSdtAttrs, readShapeAttrs, readStrikeMarkAttrs, readSymbolAttrs, readTabAttrs, readTableAttrs, readTableCellAttrs, readTableRowAttrs, readTextBoxAttrs, readTextColorMarkAttrs, readTextEffectMarkAttrs, readTrackedChangeMarkAttrs, readUnderlineMarkAttrs };
|
|
1853
|
+
export { expectBlockSdtAttrs, expectCharacterSpacingMarkAttrs, expectCharacterStyleMarkAttrs, expectCommentMarkAttrs, expectEmphasisMarkAttrs, expectFieldAttrs, expectFontFamilyMarkAttrs, expectFontSizeMarkAttrs, expectFootnoteRefMarkAttrs, expectHardBreakAttrs, expectHighlightMarkAttrs, expectHyperlinkMarkAttrs, expectImageAttrs, expectLanguageMarkAttrs, expectMathAttrs, expectPageBreakRunAttrs, expectPageBreakRunOwnerMarkAttrs, expectParagraphAttrs, expectRunFormattingOverrideMarkAttrs, expectRunPropertyChangeMarkAttrs, expectRunShadingMarkAttrs, expectSdtAttrs, expectShapeAttrs, expectStrikeMarkAttrs, expectSymbolAttrs, expectTabAttrs, expectTableAttrs, expectTableCellAttrs, expectTableRowAttrs, expectTextBoxAttrs, expectTextColorMarkAttrs, expectTextEffectMarkAttrs, expectTrackedChangeMarkAttrs, expectUnderlineMarkAttrs, mergeImageAttrs, mergeParagraphAttrs, mergeTableAttrs, mergeTableCellAttrs, mergeTableRowAttrs, 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 };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region src/prosemirror/bookmarkBoundaryIntegrity.d.ts
|
|
2
|
+
type BookmarkBoundaryOccurrence = {
|
|
3
|
+
id: number;
|
|
4
|
+
type: "start" | "end";
|
|
5
|
+
position: number;
|
|
6
|
+
};
|
|
7
|
+
declare const findInvalidBookmarkBoundaryIds: (occurrences: readonly BookmarkBoundaryOccurrence[], reservedIds?: ReadonlySet<number>) => ReadonlySet<number>;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { BookmarkBoundaryOccurrence, findInvalidBookmarkBoundaryIds };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//#region src/prosemirror/bookmarkBoundaryIntegrity.ts
|
|
2
|
+
const findInvalidBookmarkBoundaryIds = (occurrences, reservedIds = /* @__PURE__ */ new Set()) => {
|
|
3
|
+
const summaries = /* @__PURE__ */ new Map();
|
|
4
|
+
for (const occurrence of occurrences) {
|
|
5
|
+
const summary = summaries.get(occurrence.id) ?? {
|
|
6
|
+
startPositions: [],
|
|
7
|
+
endPositions: []
|
|
8
|
+
};
|
|
9
|
+
if (occurrence.type === "start") summary.startPositions.push(occurrence.position);
|
|
10
|
+
else summary.endPositions.push(occurrence.position);
|
|
11
|
+
summaries.set(occurrence.id, summary);
|
|
12
|
+
}
|
|
13
|
+
const invalidIds = /* @__PURE__ */ new Set();
|
|
14
|
+
for (const [id, summary] of summaries) {
|
|
15
|
+
const start = summary.startPositions.at(0);
|
|
16
|
+
const end = summary.endPositions.at(0);
|
|
17
|
+
if (reservedIds.has(id) || summary.startPositions.length !== 1 || summary.endPositions.length !== 1 || start === void 0 || end === void 0 || start >= end) invalidIds.add(id);
|
|
18
|
+
}
|
|
19
|
+
return invalidIds;
|
|
20
|
+
};
|
|
21
|
+
//#endregion
|
|
22
|
+
export { findInvalidBookmarkBoundaryIds };
|
|
@@ -8,6 +8,7 @@ declare function addCommentMark(commentId: number): Command;
|
|
|
8
8
|
* Remove a comment mark by ID from the entire document.
|
|
9
9
|
*/
|
|
10
10
|
declare function removeCommentMark(commentId: number): Command;
|
|
11
|
+
type ResolveMode = "accept" | "reject";
|
|
11
12
|
type ParagraphBoundaryChange = {
|
|
12
13
|
from: number;
|
|
13
14
|
to: number;
|
|
@@ -37,6 +38,14 @@ declare function acceptAllChanges(): Command;
|
|
|
37
38
|
* Reject all tracked changes in the document.
|
|
38
39
|
*/
|
|
39
40
|
declare function rejectAllChanges(): Command;
|
|
41
|
+
/**
|
|
42
|
+
* Resolve a complete state synchronously for a headless reader or writer.
|
|
43
|
+
*
|
|
44
|
+
* @internal The replacement transaction is consumed here and never exposed:
|
|
45
|
+
* it is deliberately not an editor command and must not be transported or
|
|
46
|
+
* mapped through concurrent edits.
|
|
47
|
+
*/
|
|
48
|
+
declare function resolveAllChangesInHeadlessState(state: EditorState, mode: ResolveMode): EditorState;
|
|
40
49
|
/**
|
|
41
50
|
* Find the document range covered by all revision carriers with any of the
|
|
42
51
|
* given ids. Returns null when none are present (already accepted/rejected, or
|
|
@@ -165,4 +174,4 @@ declare function findNextChange(state: EditorState, startPos: number): ChangeRan
|
|
|
165
174
|
*/
|
|
166
175
|
declare function findPreviousChange(state: EditorState, startPos: number): ChangeRange | null;
|
|
167
176
|
//#endregion
|
|
168
|
-
export { AcceptSuggestionOptions, FolioSuggestion, ParagraphBoundaryChange, SuggestionAppliedAs, SuggestionKind, acceptAIEditRevision, acceptAllChanges, acceptAllSuggestions, acceptChange, acceptSuggestion, addCommentMark, findAIEditRevisionRange, findChangeAtPosition, findNextChange, findParagraphBoundaryChangeAtPosition, findPreviousChange, findSuggestionRange, getSuggestions, rejectAIEditRevision, rejectAllChanges, rejectAllSuggestions, rejectChange, rejectSuggestion, removeCommentMark };
|
|
177
|
+
export { AcceptSuggestionOptions, FolioSuggestion, ParagraphBoundaryChange, SuggestionAppliedAs, SuggestionKind, acceptAIEditRevision, acceptAllChanges, acceptAllSuggestions, acceptChange, acceptSuggestion, addCommentMark, findAIEditRevisionRange, findChangeAtPosition, findNextChange, findParagraphBoundaryChangeAtPosition, findPreviousChange, findSuggestionRange, getSuggestions, rejectAIEditRevision, rejectAllChanges, rejectAllSuggestions, rejectChange, rejectSuggestion, removeCommentMark, resolveAllChangesInHeadlessState };
|