@stll/folio-core 0.54.1 → 0.55.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai-edits/apply.d.ts +1 -1
- package/dist/ai-edits/apply.js +40 -32
- package/dist/ai-edits/headless.d.ts +1 -2
- package/dist/ai-edits/headless.js +13 -27
- package/dist/ai-edits/read.d.ts +1 -0
- package/dist/ai-edits/read.js +7 -2
- package/dist/ai-edits/table-mutation-plan.d.ts +2 -1
- package/dist/ai-edits/table-mutation-plan.js +39 -1
- package/dist/ai-suggestions/apply.d.ts +1 -1
- package/dist/ai-suggestions/apply.js +3 -2
- package/dist/compare/compare.js +2 -1
- package/dist/compare/content-types.d.ts +3 -15
- package/dist/controller/canonicalComposition.d.ts +36 -0
- package/dist/controller/canonicalComposition.js +168 -0
- package/dist/controller/canonicalInput.d.ts +45 -0
- package/dist/controller/canonicalInput.js +338 -0
- package/dist/controller/canonicalOperations.d.ts +22 -0
- package/dist/controller/canonicalOperations.js +85 -0
- package/dist/controller/canonicalReview.d.ts +12 -0
- package/dist/controller/canonicalReview.js +19 -0
- package/dist/controller/canonicalSession.d.ts +149 -0
- package/dist/controller/canonicalSession.js +1038 -0
- package/dist/controller/canonicalStoryEditor.d.ts +34 -0
- package/dist/controller/canonicalStoryEditor.js +82 -0
- package/dist/controller/canonicalStructure.d.ts +16 -0
- package/dist/controller/canonicalStructure.js +269 -0
- package/dist/controller/folioEditor.d.ts +1 -1
- package/dist/controller/folioEditor.js +9 -0
- package/dist/controller/headerFooterEditorManager.d.ts +4 -0
- package/dist/controller/headerFooterEditorManager.js +71 -3
- package/dist/controller/hiddenEditorApi.d.ts +35 -0
- package/dist/controller/hiddenEditorApi.js +25 -8
- package/dist/controller/hiddenEditorManager.d.ts +11 -2
- package/dist/controller/hiddenEditorManager.js +456 -30
- package/dist/controller/layoutPipeline.d.ts +1 -1
- package/dist/controller/layoutPipeline.js +2 -0
- package/dist/controller/noteEditorManager.d.ts +4 -0
- package/dist/controller/noteEditorManager.js +113 -15
- package/dist/docx/attributeRemainder.js +1 -0
- package/dist/docx/bookmarkIds.d.ts +11 -0
- package/dist/docx/bookmarkIds.js +33 -0
- package/dist/docx/canonicalSessionInput.d.ts +11 -0
- package/dist/docx/canonicalSessionInput.js +27 -0
- package/dist/docx/canonicalStoryRepack.d.ts +10 -0
- package/dist/docx/canonicalStoryRepack.js +41 -0
- package/dist/docx/contentTypeRegistry.d.ts +8 -0
- package/dist/docx/contentTypeRegistry.js +64 -0
- package/dist/docx/documentParser.d.ts +14 -1
- package/dist/docx/documentParser.js +17 -4
- package/dist/docx/drawingIdNormalization.js +23 -8
- package/dist/docx/ensureParaIds.d.ts +12 -1
- package/dist/docx/ensureParaIds.js +173 -213
- package/dist/docx/foldedListNumberFields.d.ts +85 -0
- package/dist/docx/foldedListNumberFields.js +267 -0
- package/dist/docx/headerFooterVerbatim.d.ts +14 -1
- package/dist/docx/headerFooterVerbatim.js +95 -2
- package/dist/docx/listNumberingInstances.js +11 -9
- package/dist/docx/noteIds.d.ts +9 -0
- package/dist/docx/noteIds.js +17 -0
- package/dist/docx/noteReferenceMark.d.ts +3 -1
- package/dist/docx/noteReferenceMark.js +15 -14
- package/dist/docx/numberingIds.d.ts +14 -0
- package/dist/docx/numberingIds.js +16 -0
- package/dist/docx/numberingParser.d.ts +3 -1
- package/dist/docx/numberingParser.js +17 -3
- package/dist/docx/numericIdAllocator.d.ts +12 -0
- package/dist/docx/numericIdAllocator.js +33 -0
- package/dist/docx/numericIdNormalization.d.ts +16 -0
- package/dist/docx/numericIdNormalization.js +174 -0
- package/dist/docx/packageParts.d.ts +3 -1
- package/dist/docx/packageParts.js +65 -16
- package/dist/docx/paragraphMarkPropertyPresence.d.ts +9 -0
- package/dist/docx/paragraphMarkPropertyPresence.js +21 -0
- package/dist/docx/paragraphParser.js +101 -53
- package/dist/docx/paragraphPropertySource.d.ts +15 -1
- package/dist/docx/paragraphPropertySource.js +76 -22
- package/dist/docx/paragraphTextBoxEnrichment.js +2 -1
- package/dist/docx/parser.js +19 -6
- package/dist/docx/rasterMime.d.ts +64 -0
- package/dist/docx/rasterMime.js +116 -0
- package/dist/docx/replyToComment.js +13 -6
- package/dist/docx/reviewHistoryNamespace.d.ts +4 -0
- package/dist/docx/reviewHistoryNamespace.js +4 -0
- package/dist/docx/reviewResolutionProvenance.d.ts +25 -0
- package/dist/docx/reviewResolutionProvenance.js +153 -0
- package/dist/docx/rezip.d.ts +7 -3
- package/dist/docx/rezip.js +121 -52
- package/dist/docx/runConsolidator.d.ts +2 -58
- package/dist/docx/runConsolidator.js +3 -175
- package/dist/docx/runParser.d.ts +2 -1
- package/dist/docx/runParser.js +156 -116
- package/dist/docx/saveDiagnostics.d.ts +11 -0
- package/dist/docx/saveDiagnostics.js +0 -0
- package/dist/docx/selectiveSave.d.ts +2 -1
- package/dist/docx/selectiveSave.js +14 -1
- package/dist/docx/selectiveXmlPatch.d.ts +16 -8
- package/dist/docx/selectiveXmlPatch.js +74 -2
- package/dist/docx/serializer/headerFooterSerializer.d.ts +5 -1
- package/dist/docx/serializer/headerFooterSerializer.js +19 -11
- package/dist/docx/serializer/noteSerializer.d.ts +2 -2
- package/dist/docx/serializer/noteSerializer.js +24 -8
- package/dist/docx/serializer/paragraphSerializer.js +41 -4
- package/dist/docx/serializer/partNamespaces.js +6 -3
- package/dist/docx/serializer/runSerializer.js +8 -5
- package/dist/docx/serializer/trackedChangeAttributes.js +7 -1
- package/dist/docx/server/build.js +14 -3
- package/dist/docx/server/createBilingualDocument.js +10 -9
- package/dist/docx/settingsHeaderFooterUpdate.d.ts +5 -0
- package/dist/docx/settingsHeaderFooterUpdate.js +90 -0
- package/dist/docx/settingsParser.d.ts +1 -2
- package/dist/docx/settingsParser.js +5 -6
- package/dist/docx/storyBlockReplay.d.ts +11 -0
- package/dist/docx/storyBlockReplay.js +367 -0
- package/dist/docx/streamingXmlParser.d.ts +31 -1
- package/dist/docx/streamingXmlParser.js +136 -21
- package/dist/docx/structuralXmlPatch.js +8 -1
- package/dist/docx/unzip.d.ts +3 -1
- package/dist/docx/unzip.js +36 -16
- package/dist/docx/verbatimCapture.d.ts +3 -1
- package/dist/docx/verbatimCapture.js +49 -6
- package/dist/i18n/messages/ar.gen.d.ts +5 -0
- package/dist/i18n/messages/ar.gen.js +656 -0
- package/dist/i18n/messages/cs.gen.d.ts +5 -0
- package/dist/i18n/messages/cs.gen.js +656 -0
- package/dist/i18n/messages/de.gen.d.ts +5 -0
- package/dist/i18n/messages/de.gen.js +656 -0
- package/dist/i18n/messages/en.gen.d.ts +5 -0
- package/dist/i18n/messages/en.gen.js +656 -0
- package/dist/i18n/messages/es.gen.d.ts +5 -0
- package/dist/i18n/messages/es.gen.js +656 -0
- package/dist/i18n/messages/et.gen.d.ts +5 -0
- package/dist/i18n/messages/et.gen.js +656 -0
- package/dist/i18n/messages/fr.gen.d.ts +5 -0
- package/dist/i18n/messages/fr.gen.js +656 -0
- package/dist/i18n/messages/he.gen.d.ts +5 -0
- package/dist/i18n/messages/he.gen.js +656 -0
- package/dist/i18n/messages/hi.gen.d.ts +5 -0
- package/dist/i18n/messages/hi.gen.js +656 -0
- package/dist/i18n/messages/hu.gen.d.ts +5 -0
- package/dist/i18n/messages/hu.gen.js +656 -0
- package/dist/i18n/messages/locales.d.ts +5 -0
- package/dist/i18n/messages/locales.js +22 -0
- package/dist/i18n/messages/lt.gen.d.ts +5 -0
- package/dist/i18n/messages/lt.gen.js +656 -0
- package/dist/i18n/messages/lv.gen.d.ts +5 -0
- package/dist/i18n/messages/lv.gen.js +656 -0
- package/dist/i18n/messages/pl.gen.d.ts +5 -0
- package/dist/i18n/messages/pl.gen.js +656 -0
- package/dist/i18n/messages/pt-BR.gen.d.ts +5 -0
- package/dist/i18n/messages/pt-BR.gen.js +656 -0
- package/dist/i18n/messages/sk.gen.d.ts +5 -0
- package/dist/i18n/messages/sk.gen.js +656 -0
- package/dist/i18n/messages/tr.gen.d.ts +5 -0
- package/dist/i18n/messages/tr.gen.js +656 -0
- package/dist/i18n/messages/zh-CN.gen.d.ts +5 -0
- package/dist/i18n/messages/zh-CN.gen.js +656 -0
- package/dist/i18n/messages.d.ts +2 -3
- package/dist/i18n/messages.js +1 -19
- package/dist/internal/noteMarkerAttrs.d.ts +8 -0
- package/dist/internal/noteMarkerAttrs.js +16 -0
- package/dist/internal/pageBreakRunSourceDescendantIndex.js +1 -0
- package/dist/internal/prosemirrorAttrBoundary.d.ts +21 -0
- package/dist/internal/prosemirrorAttrBoundary.js +50 -0
- package/dist/layout-bridge/convert/fixedTableColumnWidths.d.ts +6 -0
- package/dist/layout-bridge/convert/fixedTableColumnWidths.js +23 -0
- package/dist/layout-bridge/convert/footnoteLayout.d.ts +1 -0
- package/dist/layout-bridge/convert/footnoteLayout.js +3 -3
- package/dist/layout-bridge/convert/headerFooterLayout.d.ts +1 -0
- package/dist/layout-bridge/convert/headerFooterLayout.js +1 -0
- package/dist/layout-bridge/convert/noteReferences.d.ts +1 -3
- package/dist/layout-bridge/convert/noteReferences.js +1 -6
- package/dist/layout-bridge/convert/paragraphRuns.js +2 -4
- package/dist/layout-bridge/convert/tableConversion.js +4 -1
- package/dist/layout-bridge/convert/toFlowBlocks.d.ts +2 -2
- package/dist/layout-bridge/convert/toFlowBlocks.js +2 -2
- package/dist/layout-painter/index.js +2 -5
- package/dist/managers/DocumentLoaderManager.d.ts +1 -0
- package/dist/managers/DocumentLoaderManager.js +8 -1
- package/dist/markdown/renderBlock.js +15 -1
- package/dist/markdown/renderParagraph.js +9 -13
- package/dist/markdown/renderRuns.js +3 -2
- package/dist/markdown/renderTable.js +2 -0
- package/dist/markdown/types.d.ts +3 -9
- package/dist/paged-layout/editorScrollRoot.d.ts +15 -0
- package/dist/paged-layout/editorScrollRoot.js +72 -0
- package/dist/paged-layout/scrollToPmPosition.js +8 -22
- package/dist/prosemirror/attrs/index.d.ts +2 -12
- package/dist/prosemirror/attrs/index.js +22 -48
- package/dist/prosemirror/bookmarkBoundaryAttrs.d.ts +2 -1
- package/dist/prosemirror/canonicalCommands.d.ts +97 -0
- package/dist/prosemirror/canonicalCommands.js +28 -0
- package/dist/prosemirror/commands/clearParagraphIndent.d.ts +6 -0
- package/dist/prosemirror/commands/clearParagraphIndent.js +25 -0
- package/dist/prosemirror/commands/pageBreak.js +15 -1
- package/dist/prosemirror/commentIdAllocator.d.ts +15 -22
- package/dist/prosemirror/commentIdAllocator.js +50 -25
- package/dist/prosemirror/commentReferenceAttrs.d.ts +2 -1
- package/dist/prosemirror/conversion/fromProseDoc.js +91 -19
- package/dist/prosemirror/conversion/listRenderingDefinition.d.ts +6 -0
- package/dist/prosemirror/conversion/listRenderingDefinition.js +97 -0
- package/dist/prosemirror/conversion/toProseDoc.d.ts +4 -3
- package/dist/prosemirror/conversion/toProseDoc.js +51 -11
- package/dist/prosemirror/executeEditorCommand.d.ts +11 -0
- package/dist/prosemirror/executeEditorCommand.js +26 -0
- package/dist/prosemirror/extensions/StarterKit.js +2 -0
- package/dist/prosemirror/extensions/core/HistoryExtension.js +97 -5
- package/dist/prosemirror/extensions/core/ParagraphExtension.js +53 -20
- package/dist/prosemirror/extensions/features/BaseKeymapExtension.js +22 -28
- package/dist/prosemirror/extensions/features/ListExtension.js +18 -5
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.d.ts +5 -2
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.js +13 -1
- package/dist/prosemirror/extensions/marks/TextColorExtension.js +3 -2
- package/dist/prosemirror/extensions/marks/TrackedChangeExtensions.js +2 -0
- package/dist/prosemirror/extensions/marks/markUtils.js +70 -8
- package/dist/prosemirror/extensions/nodes/NoteMarkerExtension.d.ts +6 -0
- package/dist/prosemirror/extensions/nodes/NoteMarkerExtension.js +36 -0
- package/dist/prosemirror/extensions/nodes/PreservedXmlExtension.js +4 -2
- package/dist/prosemirror/extensions/nodes/ShapeExtension.js +8 -6
- package/dist/prosemirror/listMarker.d.ts +1 -0
- package/dist/prosemirror/listMarker.js +16 -7
- package/dist/prosemirror/listNumbering.js +26 -5
- package/dist/prosemirror/listRenderingAttrs.d.ts +1 -0
- package/dist/prosemirror/listRenderingAttrs.js +3 -0
- package/dist/prosemirror/markupViewNotes.js +3 -2
- package/dist/prosemirror/moveRangeBoundaryAttrs.d.ts +2 -1
- package/dist/prosemirror/noteReferenceReview.js +5 -3
- package/dist/prosemirror/plugins/revisionIds.d.ts +23 -19
- package/dist/prosemirror/plugins/revisionIds.js +110 -29
- package/dist/prosemirror/plugins/suggestionMode.d.ts +2 -2
- package/dist/prosemirror/plugins/suggestionMode.js +246 -42
- package/dist/prosemirror/rangeAnchorAttrs.d.ts +2 -1
- package/dist/prosemirror/runFormattingFromMarks.d.ts +4 -1
- package/dist/prosemirror/runFormattingFromMarks.js +15 -1
- package/dist/prosemirror/runFormattingInlineCarriers.d.ts +2 -1
- package/dist/prosemirror/runFormattingInlineCarriers.js +4 -1
- package/dist/prosemirror/schema/marks.d.ts +2 -0
- package/dist/prosemirror/schema/nodes.d.ts +10 -2
- package/dist/prosemirror/storyListNumbering.js +11 -9
- package/dist/prosemirror/textBoxAnchorAttrs.d.ts +2 -1
- package/dist/prosemirror/textInput.d.ts +6 -1
- package/dist/prosemirror/textInput.js +14 -3
- package/dist/prosemirror/trackedRevisionPath.js +2 -1
- package/dist/prosemirror/trackedRunInlineAtoms.d.ts +1 -0
- package/dist/prosemirror/trackedRunInlineAtoms.js +1 -0
- package/dist/prosemirror/utils/visualLineNavigation.js +6 -8
- package/dist/prosemirror/validation.js +4 -0
- package/dist/types/content.d.ts +2 -2
- package/dist/utils/createDocument.js +2 -2
- package/dist/utils/mergeDocumentContent.d.ts +2 -2
- package/dist/utils/mergeDocumentContent.js +11 -8
- package/package.json +14 -2
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { findBodyPmAnchor, findBodyPmAnchors } from "../layout-bridge/dom/findBodyPmSpans.js";
|
|
2
2
|
import { findPageShellForPmPos } from "../layout-painter/renderPage.js";
|
|
3
|
-
import {
|
|
3
|
+
import { getEditorScrollRoot, scrollEditorElementIntoView } from "./editorScrollRoot.js";
|
|
4
|
+
import { isValidPmScrollPosition } from "./scrollNavigation.js";
|
|
4
5
|
//#region src/paged-layout/scrollToPmPosition.ts
|
|
5
6
|
/** Class on the pages container `PagedEditor` paints into. */
|
|
6
7
|
const PAGES_CONTAINER_CLASS = "paged-editor__pages";
|
|
@@ -9,10 +10,7 @@ const scrollPagesToPmPosition = (pageContainer, pmPos) => {
|
|
|
9
10
|
if (!isValidPmScrollPosition(pmPos)) return;
|
|
10
11
|
const exact = findBodyPmAnchor(pageContainer, pmPos);
|
|
11
12
|
if (exact) {
|
|
12
|
-
exact
|
|
13
|
-
behavior: prefersReducedMotionBehavior(),
|
|
14
|
-
block: "center"
|
|
15
|
-
});
|
|
13
|
+
scrollEditorElementIntoView(exact);
|
|
16
14
|
return;
|
|
17
15
|
}
|
|
18
16
|
let runMatch = null;
|
|
@@ -27,28 +25,19 @@ const scrollPagesToPmPosition = (pageContainer, pmPos) => {
|
|
|
27
25
|
}
|
|
28
26
|
}
|
|
29
27
|
if (runMatch) {
|
|
30
|
-
runMatch
|
|
31
|
-
behavior: prefersReducedMotionBehavior(),
|
|
32
|
-
block: "center"
|
|
33
|
-
});
|
|
28
|
+
scrollEditorElementIntoView(runMatch);
|
|
34
29
|
return;
|
|
35
30
|
}
|
|
36
31
|
const shellHit = findPageShellForPmPos(pageContainer, pmPos);
|
|
37
32
|
if (!shellHit) return;
|
|
38
33
|
const { element: shell } = shellHit;
|
|
39
|
-
shell
|
|
40
|
-
behavior: prefersReducedMotionBehavior(),
|
|
41
|
-
block: "center"
|
|
42
|
-
});
|
|
34
|
+
scrollEditorElementIntoView(shell);
|
|
43
35
|
let attempts = 0;
|
|
44
36
|
const refine = () => {
|
|
45
37
|
attempts++;
|
|
46
38
|
const exactInShell = findBodyPmAnchor(shell, pmPos);
|
|
47
39
|
if (exactInShell) {
|
|
48
|
-
exactInShell
|
|
49
|
-
behavior: prefersReducedMotionBehavior(),
|
|
50
|
-
block: "center"
|
|
51
|
-
});
|
|
40
|
+
scrollEditorElementIntoView(exactInShell);
|
|
52
41
|
return;
|
|
53
42
|
}
|
|
54
43
|
let bestEl = null;
|
|
@@ -68,10 +57,7 @@ const scrollPagesToPmPosition = (pageContainer, pmPos) => {
|
|
|
68
57
|
}
|
|
69
58
|
}
|
|
70
59
|
if (bestEl) {
|
|
71
|
-
bestEl
|
|
72
|
-
behavior: prefersReducedMotionBehavior(),
|
|
73
|
-
block: "center"
|
|
74
|
-
});
|
|
60
|
+
scrollEditorElementIntoView(bestEl);
|
|
75
61
|
return;
|
|
76
62
|
}
|
|
77
63
|
if (attempts < 20) requestAnimationFrame(refine);
|
|
@@ -86,7 +72,7 @@ const scrollPagesToPmPosition = (pageContainer, pmPos) => {
|
|
|
86
72
|
* callers can fall back to coordinate-based scrolling.
|
|
87
73
|
*/
|
|
88
74
|
const scrollFolioPositionIntoView = (view, pmPos) => {
|
|
89
|
-
const pageContainer = view.dom
|
|
75
|
+
const pageContainer = getEditorScrollRoot(view.dom)?.querySelector(`.paged-editor__pages`) ?? null;
|
|
90
76
|
if (!pageContainer) return false;
|
|
91
77
|
scrollPagesToPmPosition(pageContainer, pmPos);
|
|
92
78
|
return true;
|
|
@@ -1,19 +1,9 @@
|
|
|
1
1
|
import { CharacterSpacingAttrs, CharacterStyleAttrs, CommentAttrs, EmphasisMarkAttrs, FontFamilyAttrs, FontSizeAttrs, FootnoteRefAttrs, HighlightAttrs, HyperlinkAttrs, InlineWrapperAttrs, InlineWrapperLayer, LanguageAttrs, RunFormattingOverrideAttrs, RunIdentityMarkAttrs, RunPropertyChangeMarkAttrs, RunShadingAttrs, StrikeAttrs, TextColorAttrs, TextEffectAttrs, TrackedChangeMarkAttrs, TrackedRevisionAncestor, UnderlineAttrs } from "../schema/marks.js";
|
|
2
2
|
import { BlockCustomXmlAttrs, BlockSdtAttrs, FieldAttrs, HardBreakAttrs, ImageAttrs, MathAttrs, PageBreakRunAttrs, ParagraphAttrs, PreservedBlockAttrs, PreservedXmlAttrs, SdtAttrs, ShapeAttrs, SymbolAttrs, TabAttrs, TableAttrs, TableCellAttrs, TableRowAttrs, TextBoxAttrs } from "../schema/nodes.js";
|
|
3
3
|
import "../schema/index.js";
|
|
4
|
+
import { ProseMirrorAttrIssue, ReadProseMirrorAttrsResult } from "../../internal/prosemirrorAttrBoundary.js";
|
|
4
5
|
import { Mark, Node } from "prosemirror-model";
|
|
5
6
|
//#region src/prosemirror/attrs/index.d.ts
|
|
6
|
-
type ProseMirrorAttrIssue = {
|
|
7
|
-
readonly path: string;
|
|
8
|
-
readonly message: string;
|
|
9
|
-
};
|
|
10
|
-
type ReadProseMirrorAttrsResult<T> = {
|
|
11
|
-
ok: true;
|
|
12
|
-
value: T;
|
|
13
|
-
} | {
|
|
14
|
-
ok: false;
|
|
15
|
-
issues: readonly ProseMirrorAttrIssue[];
|
|
16
|
-
};
|
|
17
7
|
declare const readParagraphAttrs: (node: Node) => ReadProseMirrorAttrsResult<Readonly<ParagraphAttrs>>;
|
|
18
8
|
declare const expectParagraphAttrs: (node: Node) => Readonly<ParagraphAttrs>;
|
|
19
9
|
declare const readHardBreakAttrs: (node: Node) => ReadProseMirrorAttrsResult<HardBreakAttrs>;
|
|
@@ -123,4 +113,4 @@ declare const mergeTableRowAttrs: (node: Node, patch: NodeAttrPatch<TableRowAttr
|
|
|
123
113
|
*/
|
|
124
114
|
declare const mergeTableCellAttrs: (node: Node, patch: NodeAttrPatch<TableCellAttrs>) => TableCellAttrs;
|
|
125
115
|
//#endregion
|
|
126
|
-
export { ProseMirrorAttrIssue, ReadProseMirrorAttrsResult, expectBlockCustomXmlAttrs, expectBlockSdtAttrs, expectCharacterSpacingMarkAttrs, expectCharacterStyleMarkAttrs, expectCommentMarkAttrs, expectEmphasisMarkAttrs, expectFieldAttrs, expectFontFamilyMarkAttrs, expectFontSizeMarkAttrs, expectFootnoteRefMarkAttrs, expectHardBreakAttrs, expectHighlightMarkAttrs, expectHyperlinkMarkAttrs, expectImageAttrs, expectInlineWrapperMarkAttrs, expectLanguageMarkAttrs, expectMathAttrs, expectPageBreakRunAttrs, expectParagraphAttrs, expectPreservedBlockAttrs, expectPreservedXmlAttrs, expectRunFormattingOverrideMarkAttrs, expectRunIdentityMarkAttrs, expectRunPropertyChangeMarkAttrs, expectRunShadingMarkAttrs, expectSdtAttrs, expectShapeAttrs, expectStrikeMarkAttrs, expectSymbolAttrs, expectTabAttrs, expectTableAttrs, expectTableCellAttrs, expectTableRowAttrs, expectTextBoxAttrs, expectTextColorMarkAttrs, expectTextEffectMarkAttrs, expectTrackedChangeMarkAttrs, expectUnderlineMarkAttrs, isTrackedRevisionAncestorArray, isValidEmptyFieldResultRuns, isValidFieldCode, mergeImageAttrs, mergeParagraphAttrs, mergeTableAttrs, mergeTableCellAttrs, mergeTableRowAttrs, readBlockCustomXmlAttrs, readBlockSdtAttrs, readCharacterSpacingMarkAttrs, readCharacterStyleMarkAttrs, readCommentMarkAttrs, readEmphasisMarkAttrs, readFieldAttrs, readFontFamilyMarkAttrs, readFontSizeMarkAttrs, readFootnoteRefMarkAttrs, readHardBreakAttrs, readHighlightMarkAttrs, readHyperlinkMarkAttrs, readImageAttrs, readInlineWrapperMarkAttrs, readInlineWrapperStack, readLanguageMarkAttrs, readMathAttrs, readPageBreakRunAttrs, readParagraphAttrs, readPreservedBlockAttrs, readPreservedXmlAttrs, readRunFormattingOverrideMarkAttrs, readRunIdentityMarkAttrs, readRunPropertyChangeMarkAttrs, readRunShadingMarkAttrs, readSdtAttrs, readShapeAttrs, readStrikeMarkAttrs, readSymbolAttrs, readTabAttrs, readTableAttrs, readTableCellAttrs, readTableRowAttrs, readTextBoxAttrs, readTextColorMarkAttrs, readTextEffectMarkAttrs, readTrackedChangeMarkAttrs, readUnderlineMarkAttrs };
|
|
116
|
+
export { type ProseMirrorAttrIssue, type ReadProseMirrorAttrsResult, expectBlockCustomXmlAttrs, expectBlockSdtAttrs, expectCharacterSpacingMarkAttrs, expectCharacterStyleMarkAttrs, expectCommentMarkAttrs, expectEmphasisMarkAttrs, expectFieldAttrs, expectFontFamilyMarkAttrs, expectFontSizeMarkAttrs, expectFootnoteRefMarkAttrs, expectHardBreakAttrs, expectHighlightMarkAttrs, expectHyperlinkMarkAttrs, expectImageAttrs, expectInlineWrapperMarkAttrs, expectLanguageMarkAttrs, expectMathAttrs, expectPageBreakRunAttrs, expectParagraphAttrs, expectPreservedBlockAttrs, expectPreservedXmlAttrs, expectRunFormattingOverrideMarkAttrs, expectRunIdentityMarkAttrs, expectRunPropertyChangeMarkAttrs, expectRunShadingMarkAttrs, expectSdtAttrs, expectShapeAttrs, expectStrikeMarkAttrs, expectSymbolAttrs, expectTabAttrs, expectTableAttrs, expectTableCellAttrs, expectTableRowAttrs, expectTextBoxAttrs, expectTextColorMarkAttrs, expectTextEffectMarkAttrs, expectTrackedChangeMarkAttrs, expectUnderlineMarkAttrs, isTrackedRevisionAncestorArray, isValidEmptyFieldResultRuns, isValidFieldCode, mergeImageAttrs, mergeParagraphAttrs, mergeTableAttrs, mergeTableCellAttrs, mergeTableRowAttrs, readBlockCustomXmlAttrs, readBlockSdtAttrs, readCharacterSpacingMarkAttrs, readCharacterStyleMarkAttrs, readCommentMarkAttrs, readEmphasisMarkAttrs, readFieldAttrs, readFontFamilyMarkAttrs, readFontSizeMarkAttrs, readFootnoteRefMarkAttrs, readHardBreakAttrs, readHighlightMarkAttrs, readHyperlinkMarkAttrs, readImageAttrs, readInlineWrapperMarkAttrs, readInlineWrapperStack, readLanguageMarkAttrs, readMathAttrs, readPageBreakRunAttrs, readParagraphAttrs, readPreservedBlockAttrs, readPreservedXmlAttrs, readRunFormattingOverrideMarkAttrs, readRunIdentityMarkAttrs, readRunPropertyChangeMarkAttrs, readRunShadingMarkAttrs, readSdtAttrs, readShapeAttrs, readStrikeMarkAttrs, readSymbolAttrs, readTabAttrs, readTableAttrs, readTableCellAttrs, readTableRowAttrs, readTextBoxAttrs, readTextColorMarkAttrs, readTextEffectMarkAttrs, readTrackedChangeMarkAttrs, readUnderlineMarkAttrs };
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { isSerializablePreservedAttribute } from "../../docx/attributeRemainder.js";
|
|
2
2
|
import { DRAWING_ANCHOR_FLAG_KEYS } from "../../docx/drawingAnchor.js";
|
|
3
|
+
import { isFoldedListNumber } from "../../docx/foldedListNumberFields.js";
|
|
3
4
|
import { GRAPHIC_FRAME_LOCK_KEYS } from "../../docx/graphicFrameLocks.js";
|
|
4
5
|
import { allowsDirectDrawingEdit, isDrawingRawXmlMode } from "../../docx/imageRawXml.js";
|
|
6
|
+
import { isParagraphMarkResolutionJoin, isResolutionJoins } from "../../docx/reviewResolutionProvenance.js";
|
|
7
|
+
import { attrsRecord, attrsResult, expectAttrs, expectCachedNodeAttrs, expectNodeType, isRecord } from "../../internal/prosemirrorAttrBoundary.js";
|
|
5
8
|
import { COUNTER_FORMAT_VALUES, 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, 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_VERTICAL_ALIGNMENT_VALUES, TABLE_JUSTIFICATION_VALUES, TABLE_ROW_HEIGHT_RULE_VALUES, TABLE_WIDTH_TYPE_VALUES, TAB_LEADER_VALUES, TAB_STOP_ALIGNMENT_VALUES, TEXT_DIRECTION_VALUES, TEXT_EFFECT_VALUES, UNDERLINE_STYLE_VALUES } from "../../types/documentEnumValues.js";
|
|
6
9
|
import { canonicalJson } from "../../utils/canonicalJson.js";
|
|
7
10
|
import { normalizeHorizontalScalePercent } from "../../utils/horizontalScale.js";
|
|
@@ -10,7 +13,6 @@ import { outlineLevelFromAttrValue } from "../outlineLevelAttr.js";
|
|
|
10
13
|
import { isParagraphDirection } from "../paragraphDirection.js";
|
|
11
14
|
import { COMPLEX_SCRIPT_RUN_PROPERTY_KEYS, RUN_FORMATTING_BOOLEAN_PROPERTIES, RUN_FORMATTING_VALUE_PROPERTIES, TRACKED_CHANGE_PROVENANCE_VALUES } from "../schema/marks.js";
|
|
12
15
|
import { PRESERVED_XML_LEVELS, TEXT_BOX_TEXT_BODY_CONTENT_STATE_TYPES } from "../schema/nodes.js";
|
|
13
|
-
import { panic } from "better-result";
|
|
14
16
|
import { DRAWING_RAW_XML_MODES, THEME_COLORS, isOoxmlSymbolCharacter } from "@stll/docx-core/model";
|
|
15
17
|
import { isSafePreservedChildXml, isWithinPreservedMarkupBudget } from "@stll/docx-core/schema";
|
|
16
18
|
//#region src/prosemirror/attrs/index.ts
|
|
@@ -216,6 +218,11 @@ const readParagraphAttrsUncached = (node) => {
|
|
|
216
218
|
const attrs = attrsRecord(node.attrs);
|
|
217
219
|
const issues = [];
|
|
218
220
|
expectNodeType(node, "paragraph", issues);
|
|
221
|
+
const paragraphMark = attrs["pPrMark"];
|
|
222
|
+
if (isRecord(paragraphMark) && paragraphMark["resolutionJoin"] !== void 0 && !isParagraphMarkResolutionJoin(paragraphMark["resolutionJoin"])) issues.push({
|
|
223
|
+
path: "paragraph.attrs.pPrMark.resolutionJoin",
|
|
224
|
+
message: "Expected a non-negative bounded paragraph cut depth."
|
|
225
|
+
});
|
|
219
226
|
optionalString(attrs, "paraId", "paragraph.attrs.paraId", issues);
|
|
220
227
|
optionalString(attrs, "_docxParagraphSourceToken", "paragraph.attrs._docxParagraphSourceToken", issues);
|
|
221
228
|
optionalString(attrs, "textId", "paragraph.attrs.textId", issues);
|
|
@@ -243,6 +250,7 @@ const readParagraphAttrsUncached = (node) => {
|
|
|
243
250
|
optionalBoolean(attrs, "listIsLegal", "paragraph.attrs.listIsLegal", issues);
|
|
244
251
|
optionalString(attrs, "listMarker", "paragraph.attrs.listMarker", issues);
|
|
245
252
|
optionalString(attrs, "listMarkerTemplate", "paragraph.attrs.listMarkerTemplate", issues);
|
|
253
|
+
optionalString(attrs, "listFoldedMarkerSuffix", "paragraph.attrs.listFoldedMarkerSuffix", issues);
|
|
246
254
|
optionalBoolean(attrs, "listMarkerHidden", "paragraph.attrs.listMarkerHidden", issues);
|
|
247
255
|
optionalTextFormatting(attrs, "listMarkerFormatting", "paragraph.attrs.listMarkerFormatting", issues);
|
|
248
256
|
optionalOneOf(attrs, "listMarkerAlignment", "paragraph.attrs.listMarkerAlignment", issues, [
|
|
@@ -362,6 +370,11 @@ const readPreservedXmlAttrs = (node) => {
|
|
|
362
370
|
expectNodeType(node, "preservedXml", issues);
|
|
363
371
|
requiredString(attrs, "xml", "preservedXml.attrs.xml", issues);
|
|
364
372
|
requiredString(attrs, "text", "preservedXml.attrs.text", issues);
|
|
373
|
+
const folded = attrs["foldedListNumber"];
|
|
374
|
+
if (folded !== void 0 && folded !== null && !isFoldedListNumber(folded)) issues.push({
|
|
375
|
+
path: "preservedXml.attrs.foldedListNumber",
|
|
376
|
+
message: "Expected a folded list-number field or tab."
|
|
377
|
+
});
|
|
365
378
|
if (!PRESERVED_XML_LEVEL_VALUES.has(attrs["level"])) issues.push({
|
|
366
379
|
path: "preservedXml.attrs.level",
|
|
367
380
|
message: `Expected one of ${[...PRESERVED_XML_LEVEL_VALUES].join(", ")}.`
|
|
@@ -580,6 +593,7 @@ const isFieldCodeContent = (value) => {
|
|
|
580
593
|
case "symbol": return typeof value["font"] === "string" && typeof value["char"] === "string";
|
|
581
594
|
case "footnoteRef":
|
|
582
595
|
case "endnoteRef": return typeof value["id"] === "number";
|
|
596
|
+
case "noteMarker": return value["kind"] === "footnote" || value["kind"] === "endnote";
|
|
583
597
|
case "drawing": return isRecord(value["image"]);
|
|
584
598
|
case "shape": return isRecord(value["shape"]);
|
|
585
599
|
case "tab":
|
|
@@ -953,7 +967,7 @@ const readCommentMarkAttrs = (mark) => {
|
|
|
953
967
|
return attrsResult(attrs, issues);
|
|
954
968
|
};
|
|
955
969
|
const expectCommentMarkAttrs = (mark) => expectCachedMarkAttrs(mark, commentAttrsCache, readCommentMarkAttrs, "comment attrs");
|
|
956
|
-
const isTrackedRevisionAncestorArray = (value) => Array.isArray(value) && value.length > 0 && value.every((ancestor) => isRecord(ancestor) && TRACKED_REVISION_ANCESTOR_TYPES.some((type) => type === ancestor["type"]) && typeof ancestor["revisionId"] === "number" && Number.isSafeInteger(ancestor["revisionId"]) && ancestor["revisionId"] >= 0 && typeof ancestor["author"] === "string" && (ancestor["date"] === void 0 || typeof ancestor["date"] === "string") && (ancestor["utcDate"] === void 0 || typeof ancestor["utcDate"] === "string") && (ancestor["initials"] === void 0 || typeof ancestor["initials"] === "string") && typeof ancestor["outerWrapperCount"] === "number" && Number.isSafeInteger(ancestor["outerWrapperCount"]) && ancestor["outerWrapperCount"] >= 0);
|
|
970
|
+
const isTrackedRevisionAncestorArray = (value) => Array.isArray(value) && value.length > 0 && value.every((ancestor) => isRecord(ancestor) && TRACKED_REVISION_ANCESTOR_TYPES.some((type) => type === ancestor["type"]) && typeof ancestor["revisionId"] === "number" && Number.isSafeInteger(ancestor["revisionId"]) && ancestor["revisionId"] >= 0 && typeof ancestor["author"] === "string" && (ancestor["date"] === void 0 || typeof ancestor["date"] === "string") && (ancestor["utcDate"] === void 0 || typeof ancestor["utcDate"] === "string") && (ancestor["initials"] === void 0 || typeof ancestor["initials"] === "string") && typeof ancestor["outerWrapperCount"] === "number" && Number.isSafeInteger(ancestor["outerWrapperCount"]) && ancestor["outerWrapperCount"] >= 0 && (ancestor["resolutionJoins"] === void 0 || isResolutionJoins(ancestor["resolutionJoins"])));
|
|
957
971
|
const readTrackedChangeMarkAttrs = (mark) => {
|
|
958
972
|
const attrs = attrsRecord(mark.attrs);
|
|
959
973
|
const issues = [];
|
|
@@ -969,6 +983,11 @@ const readTrackedChangeMarkAttrs = (mark) => {
|
|
|
969
983
|
message: "Expected a non-negative safe integer."
|
|
970
984
|
});
|
|
971
985
|
const ancestors = attrs["_docxRevisionAncestors"];
|
|
986
|
+
const resolutionJoins = attrs["_docxResolutionJoins"];
|
|
987
|
+
if (resolutionJoins !== void 0 && resolutionJoins !== null && !isResolutionJoins(resolutionJoins)) issues.push({
|
|
988
|
+
path: `${mark.type.name}.attrs._docxResolutionJoins`,
|
|
989
|
+
message: "Expected valid tracked-resolution provenance."
|
|
990
|
+
});
|
|
972
991
|
if (ancestors !== void 0 && ancestors !== null && !isTrackedRevisionAncestorArray(ancestors)) issues.push({
|
|
973
992
|
path: `${mark.type.name}.attrs._docxRevisionAncestors`,
|
|
974
993
|
message: "Expected a non-empty array of valid revision ancestors."
|
|
@@ -1310,46 +1329,6 @@ const mergeTableCellAttrs = (node, patch) => {
|
|
|
1310
1329
|
}
|
|
1311
1330
|
};
|
|
1312
1331
|
};
|
|
1313
|
-
const attrsRecord = (attrs) => {
|
|
1314
|
-
if (isRecord(attrs)) return attrs;
|
|
1315
|
-
return {};
|
|
1316
|
-
};
|
|
1317
|
-
const isRecord = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
1318
|
-
const attrsResult = (attrs, issues) => {
|
|
1319
|
-
if (issues.length > 0) return {
|
|
1320
|
-
ok: false,
|
|
1321
|
-
issues
|
|
1322
|
-
};
|
|
1323
|
-
let normalizedAttrs;
|
|
1324
|
-
return {
|
|
1325
|
-
ok: true,
|
|
1326
|
-
get value() {
|
|
1327
|
-
if (normalizedAttrs !== void 0) return normalizedAttrs;
|
|
1328
|
-
const presentAttrs = {};
|
|
1329
|
-
for (const key in attrs) {
|
|
1330
|
-
if (!Object.hasOwn(attrs, key)) continue;
|
|
1331
|
-
const value = attrs[key];
|
|
1332
|
-
if (value !== null) presentAttrs[key] = value;
|
|
1333
|
-
}
|
|
1334
|
-
normalizedAttrs = presentAttrs;
|
|
1335
|
-
return normalizedAttrs;
|
|
1336
|
-
},
|
|
1337
|
-
set value(value) {
|
|
1338
|
-
normalizedAttrs = value;
|
|
1339
|
-
}
|
|
1340
|
-
};
|
|
1341
|
-
};
|
|
1342
|
-
const expectAttrs = (result, label) => {
|
|
1343
|
-
if (result.ok) return result.value;
|
|
1344
|
-
panic(`Invalid ProseMirror ${label}:\n${result.issues.map((issue) => `${issue.path}: ${issue.message}`).join("\n")}`);
|
|
1345
|
-
};
|
|
1346
|
-
function expectCachedNodeAttrs(node, cache, reader, label) {
|
|
1347
|
-
const cached = cache.get(node);
|
|
1348
|
-
if (cached) return cached;
|
|
1349
|
-
const value = expectAttrs(reader(node), label);
|
|
1350
|
-
cache.set(node, value);
|
|
1351
|
-
return value;
|
|
1352
|
-
}
|
|
1353
1332
|
function expectCachedMarkAttrs(mark, cache, reader, label) {
|
|
1354
1333
|
const cached = cache.get(mark);
|
|
1355
1334
|
if (cached) return cached;
|
|
@@ -1357,12 +1336,6 @@ function expectCachedMarkAttrs(mark, cache, reader, label) {
|
|
|
1357
1336
|
cache.set(mark, value);
|
|
1358
1337
|
return value;
|
|
1359
1338
|
}
|
|
1360
|
-
const expectNodeType = (node, expected, issues) => {
|
|
1361
|
-
if (node.type.name !== expected) issues.push({
|
|
1362
|
-
path: "node.type.name",
|
|
1363
|
-
message: `Expected ${expected}, got ${node.type.name}.`
|
|
1364
|
-
});
|
|
1365
|
-
};
|
|
1366
1339
|
const expectNodeTypeOneOf = (node, expected, issues) => {
|
|
1367
1340
|
if (!expected.includes(node.type.name)) issues.push({
|
|
1368
1341
|
path: "node.type.name",
|
|
@@ -2408,6 +2381,7 @@ const validateParagraphFormatting = (value, path, issues) => {
|
|
|
2408
2381
|
optionalOneOf(value, "listNumFmt", `${path}.listNumFmt`, issues, COUNTER_FORMAT_VALUES);
|
|
2409
2382
|
optionalString(value, "listMarker", `${path}.listMarker`, issues);
|
|
2410
2383
|
optionalString(value, "listMarkerTemplate", `${path}.listMarkerTemplate`, issues);
|
|
2384
|
+
optionalString(value, "listFoldedMarkerSuffix", `${path}.listFoldedMarkerSuffix`, issues);
|
|
2411
2385
|
optionalTextFormatting(value, "listMarkerFormatting", `${path}.listMarkerFormatting`, issues);
|
|
2412
2386
|
optionalOneOf(value, "listMarkerAlignment", `${path}.listMarkerAlignment`, issues, [
|
|
2413
2387
|
"left",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { document_d_exports } from "../types/document.js";
|
|
2
2
|
import { BookmarkBoundaryAttrs } from "./schema/nodes.js";
|
|
3
|
-
import { ReadProseMirrorAttrsResult } from "
|
|
3
|
+
import { ReadProseMirrorAttrsResult } from "../internal/prosemirrorAttrBoundary.js";
|
|
4
|
+
import "./attrs/index.js";
|
|
4
5
|
import { Node } from "prosemirror-model";
|
|
5
6
|
//#region src/prosemirror/bookmarkBoundaryAttrs.d.ts
|
|
6
7
|
declare const isDisplacedByCustomXml: (value: unknown) => value is document_d_exports.DisplacedByCustomXml;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { Node } from "prosemirror-model";
|
|
2
|
+
import { Command, EditorState } from "prosemirror-state";
|
|
3
|
+
import { ParagraphPropsPatch, RunPropsPatch } from "@stll/docx-core/ops";
|
|
4
|
+
//#region src/prosemirror/canonicalCommands.d.ts
|
|
5
|
+
/** Command meaning before canonical positions are resolved by the session. */
|
|
6
|
+
type CanonicalCommandIntent = {
|
|
7
|
+
type: "formatRun";
|
|
8
|
+
from: number;
|
|
9
|
+
to: number;
|
|
10
|
+
patch: RunPropsPatch;
|
|
11
|
+
} | {
|
|
12
|
+
type: "formatParagraph";
|
|
13
|
+
at: number;
|
|
14
|
+
patch: ParagraphPropsPatch;
|
|
15
|
+
} | {
|
|
16
|
+
type: "toggleList";
|
|
17
|
+
kind: "bullet" | "decimal";
|
|
18
|
+
} | {
|
|
19
|
+
type: "changeListLevel";
|
|
20
|
+
direction: "increase" | "decrease";
|
|
21
|
+
} | {
|
|
22
|
+
type: "removeList";
|
|
23
|
+
} | {
|
|
24
|
+
type: "restartNumbering";
|
|
25
|
+
start?: number;
|
|
26
|
+
} | {
|
|
27
|
+
type: "continueNumbering";
|
|
28
|
+
} | {
|
|
29
|
+
type: "insertBreak";
|
|
30
|
+
from: number;
|
|
31
|
+
to: number;
|
|
32
|
+
breakType: "page" | "textWrapping";
|
|
33
|
+
};
|
|
34
|
+
type CanonicalCommandDescriptor = (state: EditorState) => readonly CanonicalCommandIntent[];
|
|
35
|
+
/** Registration leaves execution and side-effect-free command probes unchanged. */
|
|
36
|
+
declare const withCanonicalCommand: (command: Command, descriptor: CanonicalCommandDescriptor) => Command;
|
|
37
|
+
declare const getCanonicalCommandIntents: (command: Command, state: EditorState) => readonly CanonicalCommandIntent[] | undefined;
|
|
38
|
+
declare const canonicalRunFormatting: (state: EditorState, patch: RunPropsPatch) => readonly [{
|
|
39
|
+
readonly type: "formatRun";
|
|
40
|
+
readonly from: number;
|
|
41
|
+
readonly to: number;
|
|
42
|
+
readonly patch: import("@stll/docx-core/ops").FormattingPatch<{
|
|
43
|
+
bold?: boolean | undefined;
|
|
44
|
+
boldCs?: boolean | undefined;
|
|
45
|
+
italic?: boolean | undefined;
|
|
46
|
+
italicCs?: boolean | undefined;
|
|
47
|
+
underline?: {
|
|
48
|
+
style: import("@stll/docx-core/model").UnderlineStyle;
|
|
49
|
+
color?: import("@stll/docx-core/model").ColorValue;
|
|
50
|
+
} | undefined;
|
|
51
|
+
strike?: boolean | undefined;
|
|
52
|
+
doubleStrike?: boolean | undefined;
|
|
53
|
+
vertAlign?: "baseline" | "superscript" | "subscript" | undefined;
|
|
54
|
+
smallCaps?: boolean | undefined;
|
|
55
|
+
allCaps?: boolean | undefined;
|
|
56
|
+
hidden?: boolean | undefined;
|
|
57
|
+
noProof?: boolean | undefined;
|
|
58
|
+
color?: import("@stll/docx-core/model").ColorValue | undefined;
|
|
59
|
+
highlight?: "black" | "blue" | "cyan" | "darkBlue" | "darkCyan" | "darkGray" | "darkGreen" | "darkMagenta" | "darkRed" | "darkYellow" | "green" | "lightGray" | "magenta" | "none" | "red" | "white" | "yellow" | undefined;
|
|
60
|
+
shading?: import("@stll/docx-core/model").ShadingProperties | undefined;
|
|
61
|
+
fontSize?: number | undefined;
|
|
62
|
+
fontSizeCs?: number | undefined;
|
|
63
|
+
fontFamily?: {
|
|
64
|
+
ascii?: string;
|
|
65
|
+
hAnsi?: string;
|
|
66
|
+
eastAsia?: string;
|
|
67
|
+
cs?: string;
|
|
68
|
+
hint?: "default" | "eastAsia" | "cs";
|
|
69
|
+
asciiTheme?: "majorAscii" | "majorHAnsi" | "majorEastAsia" | "majorBidi" | "minorAscii" | "minorHAnsi" | "minorEastAsia" | "minorBidi";
|
|
70
|
+
hAnsiTheme?: string;
|
|
71
|
+
eastAsiaTheme?: string;
|
|
72
|
+
csTheme?: string;
|
|
73
|
+
} | undefined;
|
|
74
|
+
language?: {
|
|
75
|
+
val?: string;
|
|
76
|
+
eastAsia?: string;
|
|
77
|
+
bidi?: string;
|
|
78
|
+
} | undefined;
|
|
79
|
+
spacing?: number | undefined;
|
|
80
|
+
position?: number | undefined;
|
|
81
|
+
scale?: number | undefined;
|
|
82
|
+
kerning?: number | undefined;
|
|
83
|
+
effect?: import("@stll/docx-core/model").TextEffect | undefined;
|
|
84
|
+
emphasisMark?: import("@stll/docx-core/model").EmphasisMark | undefined;
|
|
85
|
+
emboss?: boolean | undefined;
|
|
86
|
+
imprint?: boolean | undefined;
|
|
87
|
+
outline?: boolean | undefined;
|
|
88
|
+
shadow?: boolean | undefined;
|
|
89
|
+
rtl?: boolean | undefined;
|
|
90
|
+
cs?: boolean | undefined;
|
|
91
|
+
styleId?: string | undefined;
|
|
92
|
+
preserved?: import("@stll/docx-core/model").PreservedMarkup | undefined;
|
|
93
|
+
}>;
|
|
94
|
+
}];
|
|
95
|
+
declare const withCanonicalParagraphFormatting: (command: Command, patch: ParagraphPropsPatch | ((paragraph: Node) => ParagraphPropsPatch)) => Command;
|
|
96
|
+
//#endregion
|
|
97
|
+
export { CanonicalCommandIntent, canonicalRunFormatting, getCanonicalCommandIntents, withCanonicalCommand, withCanonicalParagraphFormatting };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
//#region src/prosemirror/canonicalCommands.ts
|
|
2
|
+
const descriptors = /* @__PURE__ */ new WeakMap();
|
|
3
|
+
/** Registration leaves execution and side-effect-free command probes unchanged. */
|
|
4
|
+
const withCanonicalCommand = (command, descriptor) => {
|
|
5
|
+
descriptors.set(command, descriptor);
|
|
6
|
+
return command;
|
|
7
|
+
};
|
|
8
|
+
const getCanonicalCommandIntents = (command, state) => descriptors.get(command)?.(state);
|
|
9
|
+
const canonicalRunFormatting = (state, patch) => [{
|
|
10
|
+
type: "formatRun",
|
|
11
|
+
from: state.selection.from,
|
|
12
|
+
to: state.selection.to,
|
|
13
|
+
patch
|
|
14
|
+
}];
|
|
15
|
+
const withCanonicalParagraphFormatting = (command, patch) => withCanonicalCommand(command, (state) => {
|
|
16
|
+
const intents = [];
|
|
17
|
+
state.doc.nodesBetween(state.selection.from, state.selection.to, (node, position) => {
|
|
18
|
+
if (node.type.name !== "paragraph") return;
|
|
19
|
+
intents.push({
|
|
20
|
+
type: "formatParagraph",
|
|
21
|
+
at: position + 1,
|
|
22
|
+
patch: typeof patch === "function" ? patch(node) : patch
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
return intents;
|
|
26
|
+
});
|
|
27
|
+
//#endregion
|
|
28
|
+
export { canonicalRunFormatting, getCanonicalCommandIntents, withCanonicalCommand, withCanonicalParagraphFormatting };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Command } from "prosemirror-state";
|
|
2
|
+
//#region src/prosemirror/commands/clearParagraphIndent.d.ts
|
|
3
|
+
/** Clear indentation at paragraph start before Backspace joins paragraphs. */
|
|
4
|
+
declare const clearIndentOnBackspace: Command;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { clearIndentOnBackspace };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { expectParagraphAttrs } from "../attrs/index.js";
|
|
2
|
+
import { TextSelection } from "prosemirror-state";
|
|
3
|
+
//#region src/prosemirror/commands/clearParagraphIndent.ts
|
|
4
|
+
/** Clear indentation at paragraph start before Backspace joins paragraphs. */
|
|
5
|
+
const clearIndentOnBackspace = (state, dispatch) => {
|
|
6
|
+
if (!(state.selection instanceof TextSelection)) return false;
|
|
7
|
+
const { $cursor } = state.selection;
|
|
8
|
+
if (!$cursor || $cursor.parentOffset !== 0 || $cursor.parent.type.name !== "paragraph") return false;
|
|
9
|
+
const attrs = expectParagraphAttrs($cursor.parent);
|
|
10
|
+
const hasFirstLine = typeof attrs.indentFirstLine === "number" && attrs.indentFirstLine > 0;
|
|
11
|
+
const hasIndentLeft = typeof attrs.indentLeft === "number" && attrs.indentLeft > 0;
|
|
12
|
+
if (!hasFirstLine && !attrs.hangingIndent && !hasIndentLeft) return false;
|
|
13
|
+
if (dispatch) {
|
|
14
|
+
const position = $cursor.before();
|
|
15
|
+
dispatch(state.tr.setNodeMarkup(position, void 0, {
|
|
16
|
+
...attrs,
|
|
17
|
+
indentFirstLine: null,
|
|
18
|
+
hangingIndent: null,
|
|
19
|
+
indentLeft: null
|
|
20
|
+
}).scrollIntoView());
|
|
21
|
+
}
|
|
22
|
+
return true;
|
|
23
|
+
};
|
|
24
|
+
//#endregion
|
|
25
|
+
export { clearIndentOnBackspace };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { withCanonicalCommand } from "../canonicalCommands.js";
|
|
1
2
|
import { pageBreakRunParagraphProjectionDisposition } from "../pageBreakRunProjection.js";
|
|
2
3
|
//#region src/prosemirror/commands/pageBreak.ts
|
|
3
4
|
const UNSUPPORTED_PAGE_BREAK_RUN_ANCESTORS = /* @__PURE__ */ new Set([
|
|
@@ -23,7 +24,7 @@ const hasTextBoxAnchorAtOrAfter = (paragraph, contentStart, position) => {
|
|
|
23
24
|
* position among neighbouring run content. Block-level `pageBreak` remains a
|
|
24
25
|
* legacy input boundary and is never emitted by this command.
|
|
25
26
|
*/
|
|
26
|
-
const
|
|
27
|
+
const insertPageBreakCommand = (state, dispatch) => {
|
|
27
28
|
const { schema } = state;
|
|
28
29
|
const pageBreakRunType = schema.nodes["pageBreakRun"];
|
|
29
30
|
const { $from } = state.selection;
|
|
@@ -36,5 +37,18 @@ const insertPageBreak = (state, dispatch) => {
|
|
|
36
37
|
}
|
|
37
38
|
return true;
|
|
38
39
|
};
|
|
40
|
+
/**
|
|
41
|
+
* Insert a page-break run at the current text cursor.
|
|
42
|
+
*
|
|
43
|
+
* Keeping the atom inline preserves its authored run, revision marks, and exact
|
|
44
|
+
* position among neighbouring run content. Block-level `pageBreak` remains a
|
|
45
|
+
* legacy input boundary and is never emitted by this command.
|
|
46
|
+
*/
|
|
47
|
+
const insertPageBreak = withCanonicalCommand(insertPageBreakCommand, (state) => insertPageBreakCommand(state) ? [{
|
|
48
|
+
type: "insertBreak",
|
|
49
|
+
from: state.selection.from,
|
|
50
|
+
to: state.selection.to,
|
|
51
|
+
breakType: "page"
|
|
52
|
+
}] : []);
|
|
39
53
|
//#endregion
|
|
40
54
|
export { insertPageBreak };
|
|
@@ -3,30 +3,23 @@ import { EditorView } from "prosemirror-view";
|
|
|
3
3
|
//#region src/prosemirror/commentIdAllocator.d.ts
|
|
4
4
|
/** Sentinel ID for a comment that hasn't been persisted yet (anchored to selection). */
|
|
5
5
|
declare const PENDING_COMMENT_ID = -1;
|
|
6
|
+
declare const CommentIdSpaceExhaustedError_base: import("better-result").TaggedErrorClass<"CommentIdSpaceExhaustedError">;
|
|
7
|
+
declare class CommentIdSpaceExhaustedError extends CommentIdSpaceExhaustedError_base<{
|
|
8
|
+
message: string;
|
|
9
|
+
}> {}
|
|
10
|
+
/** Allocate a valid, unused comment ID in this realm. */
|
|
11
|
+
declare function allocateCommentId(): number;
|
|
12
|
+
/** Reserve a loaded ID and advance past it when the upper bound permits. */
|
|
13
|
+
declare function seedCommentIdAbove(id: number): void;
|
|
6
14
|
type CommentIdAllocator = {
|
|
7
|
-
/** Allocate the next ID
|
|
15
|
+
/** Allocate the next unused ID. */
|
|
8
16
|
next(): number;
|
|
9
|
-
/**
|
|
10
|
-
|
|
11
|
-
* loaded comments and tracked-change marks so subsequent allocations don't
|
|
12
|
-
* collide with already-present IDs.
|
|
13
|
-
*/
|
|
14
|
-
seedAbove(maxId: number): void;
|
|
17
|
+
/** Reserve a loaded ID and seed above it when possible. */
|
|
18
|
+
seedAbove(id: number): void;
|
|
15
19
|
};
|
|
16
|
-
/**
|
|
17
|
-
* Create an instance-scoped monotonic comment/revision ID allocator. IDs are
|
|
18
|
-
* never reused (deleting a comment does not free its ID), and the counter is
|
|
19
|
-
* private to this allocator — multiple editors get independent ID spaces.
|
|
20
|
-
*/
|
|
20
|
+
/** Every handle uses the same counter, including separate editor instances. */
|
|
21
21
|
declare function createCommentIdAllocator(): CommentIdAllocator;
|
|
22
|
-
/**
|
|
23
|
-
|
|
24
|
-
* — comment objects (including replies, which carry no mark) plus
|
|
25
|
-
* tracked-change `revisionId` marks. Because `seedAbove` only ever raises the
|
|
26
|
-
* counter, this is safe to call on load (React) or before each allocation
|
|
27
|
-
* (Vue): new IDs never collide with or reuse an existing one, and the comment
|
|
28
|
-
* and revision ID spaces stay unified.
|
|
29
|
-
*/
|
|
30
|
-
declare function seedCommentAllocator(allocator: CommentIdAllocator, comments: Comment[] | undefined, view: EditorView | null): void;
|
|
22
|
+
/** Seed from comments, replies, and the document's conservative annotation maximum. */
|
|
23
|
+
declare function seedCommentAllocator(allocator: CommentIdAllocator, comments: Comment[] | undefined, view: Pick<EditorView, "state"> | null): void;
|
|
31
24
|
//#endregion
|
|
32
|
-
export { CommentIdAllocator, PENDING_COMMENT_ID, createCommentIdAllocator, seedCommentAllocator };
|
|
25
|
+
export { CommentIdAllocator, CommentIdSpaceExhaustedError, PENDING_COMMENT_ID, allocateCommentId, createCommentIdAllocator, seedCommentAllocator, seedCommentIdAbove };
|
|
@@ -1,40 +1,65 @@
|
|
|
1
1
|
import { maxAnnotationIdInDoc, seedRevisionIdsAbove } from "./plugins/revisionIds.js";
|
|
2
|
+
import { readRangeAnchorAttrs } from "./rangeAnchorAttrs.js";
|
|
3
|
+
import { TaggedError } from "better-result";
|
|
2
4
|
import { MAX_REVISION_ID } from "@stll/docx-core/model";
|
|
3
5
|
//#region src/prosemirror/commentIdAllocator.ts
|
|
4
|
-
/** Sentinel ID for a comment that hasn't been persisted yet (anchored to selection). */
|
|
5
|
-
const PENDING_COMMENT_ID = -1;
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* private to this allocator — multiple editors get independent ID spaces.
|
|
7
|
+
* Realm-wide comment ID allocation, shared by live editors and headless reviewers.
|
|
8
|
+
* Loaded and issued IDs stay reserved even when a comment is deleted.
|
|
10
9
|
*/
|
|
10
|
+
/** Sentinel ID for a comment that hasn't been persisted yet (anchored to selection). */
|
|
11
|
+
const PENDING_COMMENT_ID = -1;
|
|
12
|
+
var CommentIdSpaceExhaustedError = class extends TaggedError("CommentIdSpaceExhaustedError") {};
|
|
13
|
+
let nextId = 1;
|
|
14
|
+
const reservedIds = /* @__PURE__ */ new Set();
|
|
15
|
+
/** Allocate a valid, unused comment ID in this realm. */
|
|
16
|
+
function allocateCommentId() {
|
|
17
|
+
if (reservedIds.size >= MAX_REVISION_ID) throw new CommentIdSpaceExhaustedError({ message: "The OOXML comment ID space is exhausted." });
|
|
18
|
+
while (reservedIds.has(nextId)) nextId = nextId === MAX_REVISION_ID ? 1 : nextId + 1;
|
|
19
|
+
const id = nextId;
|
|
20
|
+
reservedIds.add(id);
|
|
21
|
+
nextId = id === MAX_REVISION_ID ? 1 : id + 1;
|
|
22
|
+
return id;
|
|
23
|
+
}
|
|
24
|
+
/** Reserve a loaded ID and advance past it when the upper bound permits. */
|
|
25
|
+
function seedCommentIdAbove(id) {
|
|
26
|
+
if (!Number.isInteger(id) || id < 0 || id > MAX_REVISION_ID) return;
|
|
27
|
+
if (id > 0) reservedIds.add(id);
|
|
28
|
+
if (id >= nextId) nextId = id === MAX_REVISION_ID ? 1 : id + 1;
|
|
29
|
+
}
|
|
30
|
+
/** Every handle uses the same counter, including separate editor instances. */
|
|
11
31
|
function createCommentIdAllocator() {
|
|
12
|
-
let nextId = 1;
|
|
13
32
|
return {
|
|
14
|
-
next:
|
|
15
|
-
|
|
16
|
-
return nextId++;
|
|
17
|
-
},
|
|
18
|
-
seedAbove(maxId) {
|
|
19
|
-
if (!Number.isInteger(maxId) || maxId < 0 || maxId >= MAX_REVISION_ID) return;
|
|
20
|
-
if (maxId >= nextId) nextId = maxId + 1;
|
|
21
|
-
}
|
|
33
|
+
next: allocateCommentId,
|
|
34
|
+
seedAbove: seedCommentIdAbove
|
|
22
35
|
};
|
|
23
36
|
}
|
|
24
|
-
/**
|
|
25
|
-
* Seed an allocator above every comment/revision ID currently in the document
|
|
26
|
-
* — comment objects (including replies, which carry no mark) plus
|
|
27
|
-
* tracked-change `revisionId` marks. Because `seedAbove` only ever raises the
|
|
28
|
-
* counter, this is safe to call on load (React) or before each allocation
|
|
29
|
-
* (Vue): new IDs never collide with or reuse an existing one, and the comment
|
|
30
|
-
* and revision ID spaces stay unified.
|
|
31
|
-
*/
|
|
37
|
+
/** Seed from comments, replies, and the document's conservative annotation maximum. */
|
|
32
38
|
function seedCommentAllocator(allocator, comments, view) {
|
|
33
39
|
let max = 0;
|
|
34
|
-
for (const comment of comments ?? [])
|
|
35
|
-
|
|
40
|
+
for (const comment of comments ?? []) {
|
|
41
|
+
allocator.seedAbove(comment.id);
|
|
42
|
+
if (Number.isInteger(comment.id) && comment.id > max && comment.id <= MAX_REVISION_ID) max = comment.id;
|
|
43
|
+
}
|
|
44
|
+
if (view) {
|
|
45
|
+
view.state.doc.descendants((node) => {
|
|
46
|
+
for (const mark of node.marks) {
|
|
47
|
+
const id = mark.attrs["commentId"];
|
|
48
|
+
if (typeof id === "number") allocator.seedAbove(id);
|
|
49
|
+
}
|
|
50
|
+
if (node.type.name === "commentReference") {
|
|
51
|
+
const id = node.attrs["commentId"];
|
|
52
|
+
if (typeof id === "number") allocator.seedAbove(id);
|
|
53
|
+
}
|
|
54
|
+
if (node.type.name === "rangeAnchor") {
|
|
55
|
+
const attrs = readRangeAnchorAttrs(node);
|
|
56
|
+
if (attrs.ok && attrs.value.start.type === "commentRangeStart") allocator.seedAbove(attrs.value.start.id);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
max = Math.max(max, maxAnnotationIdInDoc(view.state.doc));
|
|
60
|
+
}
|
|
36
61
|
allocator.seedAbove(max);
|
|
37
62
|
seedRevisionIdsAbove(max);
|
|
38
63
|
}
|
|
39
64
|
//#endregion
|
|
40
|
-
export { PENDING_COMMENT_ID, createCommentIdAllocator, seedCommentAllocator };
|
|
65
|
+
export { CommentIdSpaceExhaustedError, PENDING_COMMENT_ID, allocateCommentId, createCommentIdAllocator, seedCommentAllocator, seedCommentIdAbove };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CommentReferenceAttrs } from "./schema/nodes.js";
|
|
2
|
-
import { ReadProseMirrorAttrsResult } from "
|
|
2
|
+
import { ReadProseMirrorAttrsResult } from "../internal/prosemirrorAttrBoundary.js";
|
|
3
|
+
import "./attrs/index.js";
|
|
3
4
|
import { Node } from "prosemirror-model";
|
|
4
5
|
//#region src/prosemirror/commentReferenceAttrs.d.ts
|
|
5
6
|
declare const readCommentReferenceAttrs: (node: Node) => ReadProseMirrorAttrsResult<CommentReferenceAttrs>;
|