@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 { document_d_exports } from "../../types/document.js";
|
|
1
2
|
import { Command, EditorState } from "prosemirror-state";
|
|
2
3
|
import { Mark } from "prosemirror-model";
|
|
3
4
|
//#region src/prosemirror/commands/formatPainter.d.ts
|
|
@@ -9,22 +10,56 @@ import { Mark } from "prosemirror-model";
|
|
|
9
10
|
* text direction or hide content, which is surprising for a formatting brush.
|
|
10
11
|
*/
|
|
11
12
|
declare const PAINTABLE_MARK_NAMES: ReadonlySet<string>;
|
|
13
|
+
type PaintableFormatting = {
|
|
14
|
+
allCaps?: document_d_exports.TextFormatting["allCaps"];
|
|
15
|
+
bold?: document_d_exports.TextFormatting["bold"];
|
|
16
|
+
boldCs?: document_d_exports.TextFormatting["boldCs"];
|
|
17
|
+
color?: document_d_exports.TextFormatting["color"];
|
|
18
|
+
cs?: document_d_exports.TextFormatting["cs"];
|
|
19
|
+
doubleStrike?: document_d_exports.TextFormatting["doubleStrike"];
|
|
20
|
+
effect?: document_d_exports.TextFormatting["effect"];
|
|
21
|
+
emboss?: document_d_exports.TextFormatting["emboss"];
|
|
22
|
+
emphasisMark?: document_d_exports.TextFormatting["emphasisMark"];
|
|
23
|
+
fontFamily?: document_d_exports.TextFormatting["fontFamily"];
|
|
24
|
+
fontSize?: document_d_exports.TextFormatting["fontSize"];
|
|
25
|
+
fontSizeCs?: document_d_exports.TextFormatting["fontSizeCs"];
|
|
26
|
+
highlight?: document_d_exports.TextFormatting["highlight"];
|
|
27
|
+
imprint?: document_d_exports.TextFormatting["imprint"];
|
|
28
|
+
italic?: document_d_exports.TextFormatting["italic"];
|
|
29
|
+
italicCs?: document_d_exports.TextFormatting["italicCs"];
|
|
30
|
+
kerning?: document_d_exports.TextFormatting["kerning"];
|
|
31
|
+
outline?: document_d_exports.TextFormatting["outline"];
|
|
32
|
+
position?: document_d_exports.TextFormatting["position"];
|
|
33
|
+
scale?: document_d_exports.TextFormatting["scale"];
|
|
34
|
+
shading?: document_d_exports.TextFormatting["shading"];
|
|
35
|
+
shadow?: document_d_exports.TextFormatting["shadow"];
|
|
36
|
+
smallCaps?: document_d_exports.TextFormatting["smallCaps"];
|
|
37
|
+
spacing?: document_d_exports.TextFormatting["spacing"];
|
|
38
|
+
strike?: document_d_exports.TextFormatting["strike"];
|
|
39
|
+
underline?: document_d_exports.TextFormatting["underline"];
|
|
40
|
+
vertAlign?: document_d_exports.TextFormatting["vertAlign"];
|
|
41
|
+
};
|
|
42
|
+
type CapturedTextFormatting = Readonly<{
|
|
43
|
+
effectiveFormatting: Readonly<PaintableFormatting>;
|
|
44
|
+
marks: readonly Mark[];
|
|
45
|
+
type: "capturedTextFormatting";
|
|
46
|
+
}>;
|
|
12
47
|
/**
|
|
13
|
-
* Capture the paintable character
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
48
|
+
* Capture the paintable character formatting active over the current selection.
|
|
49
|
+
* An empty selection reads the stored/insertion marks; a range reads its leading
|
|
50
|
+
* run. The discriminated result deliberately represents an effectively plain run:
|
|
51
|
+
* `null` belongs to the host's “nothing captured” state, not this command.
|
|
17
52
|
*/
|
|
18
|
-
declare function captureFormatMarks(state: EditorState):
|
|
53
|
+
declare function captureFormatMarks(state: EditorState): CapturedTextFormatting;
|
|
19
54
|
/**
|
|
20
55
|
* Apply captured marks onto the current selection's range: clear every paintable
|
|
21
56
|
* mark type first (replace, not merge — so painting Georgia-12-bold onto
|
|
22
57
|
* Arial-10 leaves only Georgia-12-bold), then lay down the captured marks.
|
|
23
58
|
*
|
|
24
|
-
* Best-effort: a collapsed selection
|
|
25
|
-
*
|
|
26
|
-
*
|
|
59
|
+
* Best-effort: a collapsed selection, no capture, or a target-relative delta
|
|
60
|
+
* that cannot be represented without guessing document defaults is a no-op.
|
|
61
|
+
* Returns false so a keymap binding stays unclaimed; never partially mutates.
|
|
27
62
|
*/
|
|
28
|
-
declare function applyFormatMarks(
|
|
63
|
+
declare function applyFormatMarks(captured: CapturedTextFormatting | null): Command;
|
|
29
64
|
//#endregion
|
|
30
|
-
export { PAINTABLE_MARK_NAMES, applyFormatMarks, captureFormatMarks };
|
|
65
|
+
export { CapturedTextFormatting, PAINTABLE_MARK_NAMES, applyFormatMarks, captureFormatMarks };
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { mergeTextFormatting } from "../../utils/textFormattingMerge.js";
|
|
2
|
+
import { expectCharacterStyleMarkAttrs } from "../attrs/index.js";
|
|
3
|
+
import { getDocumentStyleResolver } from "../plugins/documentStyles.js";
|
|
4
|
+
import { readAuthoredRunFormatting, reconcileRunFormattingMarks } from "../runFormattingReconciliation.js";
|
|
5
|
+
import { paragraphFormattingForRun, paragraphRunStyleContext, paragraphRunStyleContextAt, resolveEffectiveRunStyleFormatting } from "../runStyleFormatting.js";
|
|
2
6
|
//#region src/prosemirror/commands/formatPainter.ts
|
|
3
7
|
/**
|
|
4
8
|
* Character-formatting marks the painter copies. Structural marks — comments,
|
|
@@ -61,76 +65,288 @@ function sanitizeOverrideMark(mark) {
|
|
|
61
65
|
}
|
|
62
66
|
kept[key] = value;
|
|
63
67
|
}
|
|
68
|
+
for (const provenanceKey of ["_authoredOn", "_authoredOff"]) {
|
|
69
|
+
const properties = kept[provenanceKey];
|
|
70
|
+
if (!Array.isArray(properties)) continue;
|
|
71
|
+
const paintableProperties = properties.filter((property) => typeof property === "string" && !NON_PAINTABLE_FORMATS.has(property));
|
|
72
|
+
if (paintableProperties.length !== properties.length) {
|
|
73
|
+
kept[provenanceKey] = paintableProperties;
|
|
74
|
+
removedExcluded = true;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
64
77
|
if (!removedExcluded) return mark;
|
|
65
78
|
if (Object.keys(kept).length === 0) return null;
|
|
66
79
|
return mark.type.create(kept);
|
|
67
80
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
81
|
+
/**
|
|
82
|
+
* Every effective property represented by a paintable mark has one target-context
|
|
83
|
+
* policy. Adding a new paintable formatting field therefore requires an explicit
|
|
84
|
+
* decision: an OOXML off sentinel, a neutral scalar, or a source value that cannot
|
|
85
|
+
* be synthesized without flattening document defaults.
|
|
86
|
+
*/
|
|
87
|
+
const TARGET_RELATIVE_FORMATTING_POLICIES = {
|
|
88
|
+
allCaps: {
|
|
89
|
+
type: "boolean",
|
|
90
|
+
override: "allCaps"
|
|
91
|
+
},
|
|
92
|
+
bold: {
|
|
93
|
+
type: "boolean",
|
|
94
|
+
override: "bold"
|
|
95
|
+
},
|
|
96
|
+
boldCs: {
|
|
97
|
+
type: "boolean",
|
|
98
|
+
override: "boldCs",
|
|
99
|
+
fallback: "bold"
|
|
100
|
+
},
|
|
101
|
+
color: {
|
|
102
|
+
type: "sentinel",
|
|
103
|
+
override: "color",
|
|
104
|
+
inactive: "auto",
|
|
105
|
+
cancellation: { auto: true }
|
|
106
|
+
},
|
|
107
|
+
cs: {
|
|
108
|
+
type: "boolean",
|
|
109
|
+
override: "cs"
|
|
110
|
+
},
|
|
111
|
+
doubleStrike: {
|
|
112
|
+
type: "boolean",
|
|
113
|
+
override: "doubleStrike"
|
|
114
|
+
},
|
|
115
|
+
effect: {
|
|
116
|
+
type: "sentinel",
|
|
117
|
+
override: "effect",
|
|
118
|
+
inactive: "none",
|
|
119
|
+
cancellation: "none"
|
|
120
|
+
},
|
|
121
|
+
emboss: {
|
|
122
|
+
type: "boolean",
|
|
123
|
+
override: "emboss"
|
|
124
|
+
},
|
|
125
|
+
emphasisMark: {
|
|
126
|
+
type: "sentinel",
|
|
127
|
+
override: "emphasisMark",
|
|
128
|
+
inactive: "none",
|
|
129
|
+
cancellation: "none"
|
|
130
|
+
},
|
|
131
|
+
fontFamily: { type: "source-value-required" },
|
|
132
|
+
fontSize: { type: "source-value-required" },
|
|
133
|
+
fontSizeCs: {
|
|
134
|
+
type: "source-value-required",
|
|
135
|
+
fallback: "fontSize"
|
|
136
|
+
},
|
|
137
|
+
highlight: {
|
|
138
|
+
type: "sentinel",
|
|
139
|
+
override: "highlight",
|
|
140
|
+
inactive: "none",
|
|
141
|
+
cancellation: "none"
|
|
142
|
+
},
|
|
143
|
+
imprint: {
|
|
144
|
+
type: "boolean",
|
|
145
|
+
override: "imprint"
|
|
146
|
+
},
|
|
147
|
+
italic: {
|
|
148
|
+
type: "boolean",
|
|
149
|
+
override: "italic"
|
|
150
|
+
},
|
|
151
|
+
italicCs: {
|
|
152
|
+
type: "boolean",
|
|
153
|
+
override: "italicCs",
|
|
154
|
+
fallback: "italic"
|
|
155
|
+
},
|
|
156
|
+
kerning: {
|
|
157
|
+
type: "sentinel",
|
|
158
|
+
override: "kerning",
|
|
159
|
+
inactive: 0,
|
|
160
|
+
cancellation: 0
|
|
161
|
+
},
|
|
162
|
+
outline: {
|
|
163
|
+
type: "boolean",
|
|
164
|
+
override: "outline"
|
|
165
|
+
},
|
|
166
|
+
position: {
|
|
167
|
+
type: "sentinel",
|
|
168
|
+
override: "position",
|
|
169
|
+
inactive: 0,
|
|
170
|
+
cancellation: 0
|
|
171
|
+
},
|
|
172
|
+
scale: {
|
|
173
|
+
type: "sentinel",
|
|
174
|
+
override: "scale",
|
|
175
|
+
inactive: 100,
|
|
176
|
+
cancellation: 100
|
|
177
|
+
},
|
|
178
|
+
shading: {
|
|
179
|
+
type: "sentinel",
|
|
180
|
+
override: "shading",
|
|
181
|
+
inactive: "nil",
|
|
182
|
+
cancellation: { pattern: "nil" },
|
|
183
|
+
projection: "shading"
|
|
184
|
+
},
|
|
185
|
+
shadow: {
|
|
186
|
+
type: "boolean",
|
|
187
|
+
override: "shadow"
|
|
188
|
+
},
|
|
189
|
+
smallCaps: {
|
|
190
|
+
type: "boolean",
|
|
191
|
+
override: "smallCaps"
|
|
192
|
+
},
|
|
193
|
+
spacing: {
|
|
194
|
+
type: "sentinel",
|
|
195
|
+
override: "spacing",
|
|
196
|
+
inactive: 0,
|
|
197
|
+
cancellation: 0
|
|
198
|
+
},
|
|
199
|
+
strike: {
|
|
200
|
+
type: "boolean",
|
|
201
|
+
override: "strike"
|
|
202
|
+
},
|
|
203
|
+
underline: {
|
|
204
|
+
type: "sentinel",
|
|
205
|
+
override: "underline",
|
|
206
|
+
inactive: "none",
|
|
207
|
+
cancellation: { style: "none" },
|
|
208
|
+
projection: "style"
|
|
209
|
+
},
|
|
210
|
+
vertAlign: {
|
|
211
|
+
type: "sentinel",
|
|
212
|
+
override: "vertAlign",
|
|
213
|
+
inactive: "baseline",
|
|
214
|
+
cancellation: "baseline"
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
const PAINTABLE_FORMATTING_KEYS = Object.keys(TARGET_RELATIVE_FORMATTING_POLICIES);
|
|
218
|
+
const targetRelativeFormattingPolicy = (key) => TARGET_RELATIVE_FORMATTING_POLICIES[key];
|
|
219
|
+
function pickPaintableFormatting(formatting) {
|
|
220
|
+
const result = {};
|
|
221
|
+
if (!formatting) return result;
|
|
222
|
+
for (const key of PAINTABLE_FORMATTING_KEYS) {
|
|
223
|
+
const value = formatting[key];
|
|
224
|
+
if (value !== void 0) Reflect.set(result, key, value);
|
|
91
225
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
226
|
+
return result;
|
|
227
|
+
}
|
|
228
|
+
function resolveEffectiveFormatting({ context, marks, styleResolver }) {
|
|
229
|
+
const authoredFormatting = readAuthoredRunFormatting({
|
|
230
|
+
context,
|
|
231
|
+
marks,
|
|
232
|
+
styleResolver
|
|
99
233
|
});
|
|
100
|
-
|
|
234
|
+
const effectiveFormatting = mergeTextFormatting(resolveEffectiveRunStyleFormatting({
|
|
235
|
+
marks,
|
|
236
|
+
paragraphFormatting: paragraphFormattingForRun({
|
|
237
|
+
context,
|
|
238
|
+
directFormatting: authoredFormatting,
|
|
239
|
+
marks
|
|
240
|
+
}),
|
|
241
|
+
styleResolver
|
|
242
|
+
}), authoredFormatting) ?? {};
|
|
243
|
+
if (authoredFormatting.shading?.pattern === "nil") effectiveFormatting.shading = authoredFormatting.shading;
|
|
244
|
+
if (authoredFormatting.underline?.style === "none") effectiveFormatting.underline = authoredFormatting.underline;
|
|
245
|
+
return pickPaintableFormatting(effectiveFormatting);
|
|
101
246
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
247
|
+
function resolveCopiedStyleFormatting({ context, marks, styleResolver }) {
|
|
248
|
+
if (marks.some((mark) => mark.type.name === "characterStyle") && !styleResolver) return null;
|
|
249
|
+
return pickPaintableFormatting(resolveEffectiveRunStyleFormatting({
|
|
250
|
+
marks,
|
|
251
|
+
paragraphFormatting: paragraphFormattingForRun({
|
|
252
|
+
context,
|
|
253
|
+
marks
|
|
254
|
+
}),
|
|
255
|
+
styleResolver
|
|
256
|
+
}));
|
|
257
|
+
}
|
|
258
|
+
function sameFormattingValue(left, right) {
|
|
259
|
+
if (Object.is(left, right)) return true;
|
|
260
|
+
if (left === null || right === null || typeof left !== "object" || typeof right !== "object") return false;
|
|
261
|
+
if (Array.isArray(left) || Array.isArray(right)) return Array.isArray(left) && Array.isArray(right) && left.length === right.length && left.every((value, index) => sameFormattingValue(value, right.at(index)));
|
|
262
|
+
const leftEntries = Object.entries(left);
|
|
263
|
+
const rightKeys = Object.keys(right);
|
|
264
|
+
return leftEntries.length === rightKeys.length && leftEntries.every(([property, value]) => Object.hasOwn(right, property) && sameFormattingValue(value, Reflect.get(right, property)));
|
|
265
|
+
}
|
|
266
|
+
function policyValue(formatting, key, policy) {
|
|
267
|
+
const own = formatting[key];
|
|
268
|
+
const value = own ?? (policy.type !== "sentinel" ? formatting[policy.fallback ?? key] : own);
|
|
269
|
+
if (policy.type !== "sentinel") return value;
|
|
270
|
+
if (policy.projection === "style") return typeof value === "object" && value !== null ? Reflect.get(value, "style") : void 0;
|
|
271
|
+
if (policy.projection === "shading") {
|
|
272
|
+
if (typeof value !== "object" || value === null) return;
|
|
273
|
+
return Reflect.get(value, "pattern") === "nil" ? "nil" : value;
|
|
274
|
+
}
|
|
275
|
+
if (key === "color") return typeof value === "object" && value !== null && Reflect.get(value, "auto") === true ? "auto" : value;
|
|
276
|
+
return value;
|
|
277
|
+
}
|
|
278
|
+
function materializeTargetRelativeMarks({ captured, context, node, styleResolver }) {
|
|
279
|
+
const targetStyleFormatting = resolveCopiedStyleFormatting({
|
|
280
|
+
context,
|
|
281
|
+
marks: captured.marks,
|
|
282
|
+
styleResolver
|
|
283
|
+
});
|
|
284
|
+
if (!targetStyleFormatting) return null;
|
|
285
|
+
const targetRelativeFormatting = {};
|
|
286
|
+
for (const key of PAINTABLE_FORMATTING_KEYS) {
|
|
287
|
+
const policy = targetRelativeFormattingPolicy(key);
|
|
288
|
+
const sourceValue = policyValue(captured.effectiveFormatting, key, policy);
|
|
289
|
+
const targetValue = policyValue(targetStyleFormatting, key, policy);
|
|
290
|
+
if ((key === "boldCs" || key === "italicCs" || key === "fontSizeCs") && captured.effectiveFormatting[key] === void 0 && targetStyleFormatting[key] === void 0) continue;
|
|
291
|
+
if (policy.type === "source-value-required") {
|
|
292
|
+
if (sourceValue === void 0 && targetValue !== void 0) return null;
|
|
293
|
+
if (sourceValue !== void 0 && !sameFormattingValue(sourceValue, targetValue)) Reflect.set(targetRelativeFormatting, key, sourceValue);
|
|
294
|
+
continue;
|
|
295
|
+
}
|
|
296
|
+
if (policy.type === "boolean") {
|
|
297
|
+
const sourceIsOn = sourceValue === true;
|
|
298
|
+
if (sourceIsOn !== (targetValue === true)) Reflect.set(targetRelativeFormatting, policy.override, sourceIsOn);
|
|
299
|
+
continue;
|
|
300
|
+
}
|
|
301
|
+
const sourceIsInactive = sourceValue === void 0 || sourceValue === policy.inactive;
|
|
302
|
+
const targetIsInactive = targetValue === void 0 || targetValue === policy.inactive;
|
|
303
|
+
if (sourceIsInactive) {
|
|
304
|
+
if (!targetIsInactive) Reflect.set(targetRelativeFormatting, policy.override, captured.effectiveFormatting[key] ?? policy.cancellation);
|
|
305
|
+
continue;
|
|
306
|
+
}
|
|
307
|
+
if (!sameFormattingValue(sourceValue, targetValue)) {
|
|
308
|
+
const formattingValue = captured.effectiveFormatting[key];
|
|
309
|
+
if (formattingValue === void 0) return null;
|
|
310
|
+
Reflect.set(targetRelativeFormatting, policy.override, formattingValue);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
const characterStyle = captured.marks.find((mark) => mark.type.name === "characterStyle");
|
|
314
|
+
const characterStyleId = characterStyle ? expectCharacterStyleMarkAttrs(characterStyle).styleId : void 0;
|
|
315
|
+
return reconcileRunFormattingMarks({
|
|
316
|
+
authoredFormatting: {
|
|
317
|
+
...targetRelativeFormatting,
|
|
318
|
+
...characterStyleId !== void 0 ? { styleId: characterStyleId } : {}
|
|
319
|
+
},
|
|
320
|
+
context,
|
|
321
|
+
node,
|
|
322
|
+
styleResolver
|
|
323
|
+
}).filter(isPaintableMark);
|
|
324
|
+
}
|
|
325
|
+
function firstTextFormatting(state, from, to) {
|
|
326
|
+
let formatting = null;
|
|
327
|
+
state.doc.nodesBetween(from, to, (node, position) => {
|
|
328
|
+
if (formatting) return false;
|
|
111
329
|
if (node.isText) {
|
|
112
|
-
|
|
330
|
+
formatting = {
|
|
331
|
+
marks: node.marks,
|
|
332
|
+
position: state.doc.resolve(position)
|
|
333
|
+
};
|
|
113
334
|
return false;
|
|
114
335
|
}
|
|
115
336
|
return true;
|
|
116
337
|
});
|
|
117
|
-
return
|
|
118
|
-
}
|
|
119
|
-
function paragraphDefaultTextFormatting(position) {
|
|
120
|
-
for (let depth = position.depth; depth >= 0; depth -= 1) {
|
|
121
|
-
const ancestor = position.node(depth);
|
|
122
|
-
if (ancestor.type.name === "paragraph") return expectParagraphAttrs(ancestor).defaultTextFormatting;
|
|
123
|
-
}
|
|
338
|
+
return formatting;
|
|
124
339
|
}
|
|
125
340
|
/**
|
|
126
|
-
* Capture the paintable character
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
*
|
|
341
|
+
* Capture the paintable character formatting active over the current selection.
|
|
342
|
+
* An empty selection reads the stored/insertion marks; a range reads its leading
|
|
343
|
+
* run. The discriminated result deliberately represents an effectively plain run:
|
|
344
|
+
* `null` belongs to the host's “nothing captured” state, not this command.
|
|
130
345
|
*/
|
|
131
346
|
function captureFormatMarks(state) {
|
|
132
347
|
const { empty, $from, from, to } = state.selection;
|
|
133
|
-
const
|
|
348
|
+
const firstText = empty ? null : firstTextFormatting(state, from, to);
|
|
349
|
+
const source = empty ? state.storedMarks ?? $from.marks() : firstText?.marks ?? [];
|
|
134
350
|
const captured = [];
|
|
135
351
|
for (const mark of source) {
|
|
136
352
|
if (!isPaintableMark(mark)) continue;
|
|
@@ -141,31 +357,71 @@ function captureFormatMarks(state) {
|
|
|
141
357
|
}
|
|
142
358
|
captured.push(mark);
|
|
143
359
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
360
|
+
const styleResolver = getDocumentStyleResolver(state);
|
|
361
|
+
return {
|
|
362
|
+
effectiveFormatting: resolveEffectiveFormatting({
|
|
363
|
+
context: paragraphRunStyleContextAt({
|
|
364
|
+
doc: state.doc,
|
|
365
|
+
pos: (firstText?.position ?? $from).pos,
|
|
366
|
+
styleResolver
|
|
367
|
+
}),
|
|
368
|
+
marks: captured,
|
|
369
|
+
styleResolver
|
|
370
|
+
}),
|
|
371
|
+
marks: captured,
|
|
372
|
+
type: "capturedTextFormatting"
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
function targetParagraphSegments(state, from, to, styleResolver) {
|
|
376
|
+
const segments = [];
|
|
377
|
+
state.doc.nodesBetween(from, to, (node, position) => {
|
|
378
|
+
if (node.type.name !== "paragraph") return true;
|
|
379
|
+
const contentFrom = position + 1;
|
|
380
|
+
const segmentFrom = Math.max(from, contentFrom);
|
|
381
|
+
const segmentTo = Math.min(to, contentFrom + node.content.size);
|
|
382
|
+
if (segmentTo > segmentFrom) segments.push({
|
|
383
|
+
context: paragraphRunStyleContext(node, styleResolver),
|
|
384
|
+
from: segmentFrom,
|
|
385
|
+
to: segmentTo
|
|
386
|
+
});
|
|
387
|
+
return false;
|
|
147
388
|
});
|
|
389
|
+
return segments;
|
|
148
390
|
}
|
|
149
391
|
/**
|
|
150
392
|
* Apply captured marks onto the current selection's range: clear every paintable
|
|
151
393
|
* mark type first (replace, not merge — so painting Georgia-12-bold onto
|
|
152
394
|
* Arial-10 leaves only Georgia-12-bold), then lay down the captured marks.
|
|
153
395
|
*
|
|
154
|
-
* Best-effort: a collapsed selection
|
|
155
|
-
*
|
|
156
|
-
*
|
|
396
|
+
* Best-effort: a collapsed selection, no capture, or a target-relative delta
|
|
397
|
+
* that cannot be represented without guessing document defaults is a no-op.
|
|
398
|
+
* Returns false so a keymap binding stays unclaimed; never partially mutates.
|
|
157
399
|
*/
|
|
158
|
-
function applyFormatMarks(
|
|
400
|
+
function applyFormatMarks(captured) {
|
|
159
401
|
return (state, dispatch) => {
|
|
160
402
|
const { from, to, empty } = state.selection;
|
|
161
|
-
if (empty ||
|
|
403
|
+
if (empty || captured?.type !== "capturedTextFormatting") return false;
|
|
404
|
+
const styleResolver = getDocumentStyleResolver(state);
|
|
405
|
+
const segments = targetParagraphSegments(state, from, to, styleResolver);
|
|
406
|
+
const node = state.schema.text("format-painter");
|
|
407
|
+
const targetMarks = segments.map((segment) => materializeTargetRelativeMarks({
|
|
408
|
+
captured,
|
|
409
|
+
context: segment.context,
|
|
410
|
+
node,
|
|
411
|
+
styleResolver
|
|
412
|
+
}));
|
|
413
|
+
if (segments.length === 0 || targetMarks.some((marks) => marks === null)) return false;
|
|
162
414
|
if (!dispatch) return true;
|
|
163
415
|
let tr = state.tr;
|
|
164
416
|
for (const name of PAINTABLE_MARK_NAMES) {
|
|
165
417
|
const markType = state.schema.marks[name];
|
|
166
418
|
if (markType) tr = tr.removeMark(from, to, markType);
|
|
167
419
|
}
|
|
168
|
-
for (const
|
|
420
|
+
for (const [index, segment] of segments.entries()) {
|
|
421
|
+
const marks = targetMarks[index];
|
|
422
|
+
if (!marks) continue;
|
|
423
|
+
for (const mark of marks) tr = tr.addMark(segment.from, segment.to, mark);
|
|
424
|
+
}
|
|
169
425
|
dispatch(tr.scrollIntoView());
|
|
170
426
|
return true;
|
|
171
427
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ResolvedStyleAttrs, getParagraphAlignment, getParagraphBidi, getStyleId } from "../extensions/core/ParagraphExtension.js";
|
|
2
2
|
import { BorderPreset, TableBorderPreset, TableContextInfo, getTableContext, isInTable as isInTableCell } from "../extensions/nodes/TableExtension.js";
|
|
3
3
|
import { AcceptSuggestionOptions, FolioSuggestion, SuggestionAppliedAs, SuggestionKind, acceptAIEditRevision, acceptAllChanges, acceptAllSuggestions, acceptChange, acceptSuggestion, addCommentMark, findAIEditRevisionRange, findNextChange, findPreviousChange, findSuggestionRange, getSuggestions, rejectAIEditRevision, rejectAllChanges, rejectAllSuggestions, rejectChange, rejectSuggestion, removeCommentMark } from "./comments.js";
|
|
4
|
-
import { PAINTABLE_MARK_NAMES, applyFormatMarks, captureFormatMarks } from "./formatPainter.js";
|
|
4
|
+
import { CapturedTextFormatting, PAINTABLE_MARK_NAMES, applyFormatMarks, captureFormatMarks } from "./formatPainter.js";
|
|
5
5
|
import { clearFormatting, createRemoveMarkCommand, createSetMarkCommand, getMarkAttr, isMarkActive } from "../extensions/marks/markUtils.js";
|
|
6
6
|
import { getHyperlinkAttrs, getSelectedText, isHyperlinkActive } from "../extensions/marks/HyperlinkExtension.js";
|
|
7
7
|
import { clearFontFamily, clearFontSize, clearHighlight, clearTextColor, insertHyperlink, removeHyperlink, setFontFamily, setFontSize, setHighlight, setHyperlink, setTextColor, setUnderlineStyle, toggleBold, toggleItalic, toggleStrike, toggleSubscript, toggleSuperscript, toggleUnderline } from "./formatting.js";
|
|
@@ -10,4 +10,4 @@ import { addTabStop, alignCenter, alignJustify, alignLeft, alignRight, applyStyl
|
|
|
10
10
|
import { addColumnLeft, addColumnRight, addRowAbove, addRowBelow, applyTableStyle, autoFitContents, deleteColumn, deleteRow, deleteTable, distributeColumns, insertTable, mergeCells, removeTableBorders, selectColumn, selectRow, selectTable, setAllTableBorders, setCellBorder, setCellFillColor, setCellMargins, setCellTextDirection, setCellVerticalAlign, setInsideTableBorders, setOutsideTableBorders, setRowHeight, setTableBorderColor, setTableBorderPreset, setTableBorderWidth, setTableBorders, setTableProperties, splitCell, toggleHeaderRow, toggleNoWrap } from "./table.js";
|
|
11
11
|
import { insertPageBreak } from "./pageBreak.js";
|
|
12
12
|
import { CLIPBOARD_READ_ERROR_EVENT, buildPlainTextSlice, pasteWithoutFormatting } from "./pastePlainText.js";
|
|
13
|
-
export { type AcceptSuggestionOptions, type BorderPreset, CLIPBOARD_READ_ERROR_EVENT, type FolioSuggestion, PAINTABLE_MARK_NAMES, type ResolvedStyleAttrs, type SuggestionAppliedAs, type SuggestionKind, type TableBorderPreset, type TableContextInfo, acceptAIEditRevision, acceptAllChanges, acceptAllSuggestions, acceptChange, acceptSuggestion, addColumnLeft, addColumnRight, addCommentMark, addRowAbove, addRowBelow, addTabStop, alignCenter, alignJustify, alignLeft, alignRight, applyFormatMarks, applyStyle, applyTableStyle, autoFitContents, buildPlainTextSlice, captureFormatMarks, clearFontFamily, clearFontSize, clearFormatting, clearHighlight, clearStyle, clearTextColor, createRemoveMarkCommand, createSetMarkCommand, decreaseIndent, decreaseListLevel, deleteColumn, deleteRow, deleteTable, distributeColumns, doubleSpacing, findAIEditRevisionRange, findNextChange, findPreviousChange, findSuggestionRange, generateTOC, getHyperlinkAttrs, getListInfo, getMarkAttr, getParagraphAlignment, getParagraphBidi, getSelectedText, getStyleId, getSuggestions, getTableContext, increaseIndent, increaseListLevel, insertHyperlink, insertPageBreak, insertTable, isHyperlinkActive, isInList, isInTableCell as isInTable, isMarkActive, mergeCells, oneAndHalfSpacing, pasteWithoutFormatting, rejectAIEditRevision, rejectAllChanges, rejectAllSuggestions, rejectChange, rejectSuggestion, removeCommentMark, removeHyperlink, removeList, removeTabStop, removeTableBorders, selectColumn, selectRow, selectTable, setAlignment, setAllTableBorders, setCellBorder, setCellFillColor, setCellMargins, setCellTextDirection, setCellVerticalAlign, setFontFamily, setFontSize, setHighlight, setHyperlink, setIndentFirstLine, setIndentLeft, setIndentRight, setInsideTableBorders, setLineSpacing, setLtr, setOutsideTableBorders, setRowHeight, setRtl, setSpaceAfter, setSpaceBefore, setTableBorderColor, setTableBorderPreset, setTableBorderWidth, setTableBorders, setTableProperties, setTextColor, setUnderlineStyle, singleSpacing, splitCell, toggleBidi, toggleBold, toggleBulletList, toggleHeaderRow, toggleItalic, toggleNoWrap, toggleNumberedList, toggleStrike, toggleSubscript, toggleSuperscript, toggleUnderline };
|
|
13
|
+
export { type AcceptSuggestionOptions, type BorderPreset, CLIPBOARD_READ_ERROR_EVENT, type CapturedTextFormatting, type FolioSuggestion, PAINTABLE_MARK_NAMES, type ResolvedStyleAttrs, type SuggestionAppliedAs, type SuggestionKind, type TableBorderPreset, type TableContextInfo, acceptAIEditRevision, acceptAllChanges, acceptAllSuggestions, acceptChange, acceptSuggestion, addColumnLeft, addColumnRight, addCommentMark, addRowAbove, addRowBelow, addTabStop, alignCenter, alignJustify, alignLeft, alignRight, applyFormatMarks, applyStyle, applyTableStyle, autoFitContents, buildPlainTextSlice, captureFormatMarks, clearFontFamily, clearFontSize, clearFormatting, clearHighlight, clearStyle, clearTextColor, createRemoveMarkCommand, createSetMarkCommand, decreaseIndent, decreaseListLevel, deleteColumn, deleteRow, deleteTable, distributeColumns, doubleSpacing, findAIEditRevisionRange, findNextChange, findPreviousChange, findSuggestionRange, generateTOC, getHyperlinkAttrs, getListInfo, getMarkAttr, getParagraphAlignment, getParagraphBidi, getSelectedText, getStyleId, getSuggestions, getTableContext, increaseIndent, increaseListLevel, insertHyperlink, insertPageBreak, insertTable, isHyperlinkActive, isInList, isInTableCell as isInTable, isMarkActive, mergeCells, oneAndHalfSpacing, pasteWithoutFormatting, rejectAIEditRevision, rejectAllChanges, rejectAllSuggestions, rejectChange, rejectSuggestion, removeCommentMark, removeHyperlink, removeList, removeTabStop, removeTableBorders, selectColumn, selectRow, selectTable, setAlignment, setAllTableBorders, setCellBorder, setCellFillColor, setCellMargins, setCellTextDirection, setCellVerticalAlign, setFontFamily, setFontSize, setHighlight, setHyperlink, setIndentFirstLine, setIndentLeft, setIndentRight, setInsideTableBorders, setLineSpacing, setLtr, setOutsideTableBorders, setRowHeight, setRtl, setSpaceAfter, setSpaceBefore, setTableBorderColor, setTableBorderPreset, setTableBorderWidth, setTableBorders, setTableProperties, setTextColor, setUnderlineStyle, singleSpacing, splitCell, toggleBidi, toggleBold, toggleBulletList, toggleHeaderRow, toggleItalic, toggleNoWrap, toggleNumberedList, toggleStrike, toggleSubscript, toggleSuperscript, toggleUnderline };
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { Command } from "prosemirror-state";
|
|
2
2
|
//#region src/prosemirror/commands/pageBreak.d.ts
|
|
3
3
|
/**
|
|
4
|
-
* Insert a page
|
|
5
|
-
*
|
|
4
|
+
* Insert a page-break run at the current text cursor.
|
|
5
|
+
*
|
|
6
|
+
* Keeping the atom inline preserves its authored run, revision marks, and exact
|
|
7
|
+
* position among neighbouring run content. Block-level `pageBreak` remains a
|
|
8
|
+
* legacy input boundary and is never emitted by this command.
|
|
6
9
|
*/
|
|
7
10
|
declare const insertPageBreak: Command;
|
|
8
11
|
//#endregion
|
|
@@ -1,45 +1,27 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { TextSelection } from "prosemirror-state";
|
|
1
|
+
import { pageBreakRunParagraphProjectionDisposition } from "../pageBreakRunProjection.js";
|
|
3
2
|
//#region src/prosemirror/commands/pageBreak.ts
|
|
3
|
+
const UNSUPPORTED_PAGE_BREAK_RUN_ANCESTORS = /* @__PURE__ */ new Set([
|
|
4
|
+
"tableCell",
|
|
5
|
+
"tableHeader",
|
|
6
|
+
"textBox"
|
|
7
|
+
]);
|
|
4
8
|
/**
|
|
5
|
-
*
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
*
|
|
9
|
-
*
|
|
9
|
+
* Insert a page-break run at the current text cursor.
|
|
10
|
+
*
|
|
11
|
+
* Keeping the atom inline preserves its authored run, revision marks, and exact
|
|
12
|
+
* position among neighbouring run content. Block-level `pageBreak` remains a
|
|
13
|
+
* legacy input boundary and is never emitted by this command.
|
|
10
14
|
*/
|
|
11
15
|
const insertPageBreak = (state, dispatch) => {
|
|
12
16
|
const { schema } = state;
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
if (!
|
|
17
|
+
const pageBreakRunType = schema.nodes["pageBreakRun"];
|
|
18
|
+
const { $from } = state.selection;
|
|
19
|
+
if (!pageBreakRunType || !state.selection.empty || !$from.parent.isTextblock) return false;
|
|
20
|
+
for (let depth = $from.depth; depth >= 0; depth--) if (UNSUPPORTED_PAGE_BREAK_RUN_ANCESTORS.has($from.node(depth).type.name)) return false;
|
|
21
|
+
if ($from.parent.type.name !== "paragraph" || pageBreakRunParagraphProjectionDisposition($from.parent).status === "unsupported") return false;
|
|
16
22
|
if (dispatch) {
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
const pbNode = pageBreakType.create();
|
|
20
|
-
const pbSize = pbNode.nodeSize;
|
|
21
|
-
let cursorPos;
|
|
22
|
-
if ($from.parent.isTextblock) if ($from.parentOffset > 0 && $from.parentOffset < $from.parent.content.size) {
|
|
23
|
-
tr.split($from.pos);
|
|
24
|
-
const mappedPos = tr.mapping.map($from.pos);
|
|
25
|
-
tr.insert(mappedPos, Fragment.from([pbNode, paragraphType.create()]));
|
|
26
|
-
cursorPos = mappedPos + pbSize + 1;
|
|
27
|
-
} else if ($from.parentOffset === $from.parent.content.size) {
|
|
28
|
-
const after = $from.after();
|
|
29
|
-
tr.insert(after, Fragment.from([pbNode, paragraphType.create()]));
|
|
30
|
-
cursorPos = after + pbSize + 1;
|
|
31
|
-
} else {
|
|
32
|
-
const before = $from.before();
|
|
33
|
-
tr.insert(before, pbNode);
|
|
34
|
-
cursorPos = before + pbSize + 1;
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
const pos = $from.pos;
|
|
38
|
-
tr.insert(pos, Fragment.from([pbNode, paragraphType.create()]));
|
|
39
|
-
cursorPos = pos + pbSize + 1;
|
|
40
|
-
}
|
|
41
|
-
tr.setSelection(TextSelection.create(tr.doc, cursorPos));
|
|
42
|
-
dispatch(tr.scrollIntoView());
|
|
23
|
+
const pageBreak = pageBreakRunType.create();
|
|
24
|
+
dispatch(state.tr.replaceSelectionWith(pageBreak).scrollIntoView());
|
|
43
25
|
}
|
|
44
26
|
return true;
|
|
45
27
|
};
|