@stll/folio-core 0.36.0 → 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 +545 -296
- 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 +133 -71
- 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 +99 -19
- 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 +45 -57
- 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 +41 -5
- 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 +169 -567
- package/dist/compare/scenario.d.ts +2 -2
- package/dist/compare/types.d.ts +3 -3
- package/dist/compare/verification.d.ts +2 -2
- package/dist/compare/verification.js +25 -8
- package/dist/compat/eigenpal.d.ts +5 -3
- package/dist/compat/eigenpal.js +3 -2
- package/dist/controller/headerFooterEditorManager.js +14 -6
- 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 +6 -4
- package/dist/document-operations.js +77 -12
- package/dist/docx/blockContentParser.js +6 -27
- package/dist/docx/ensureParaIds.js +9 -4
- package/dist/docx/numberingParser.d.ts +3 -1
- package/dist/docx/numberingParser.js +4 -1
- package/dist/docx/paragraphParser.js +7 -6
- 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/runParser.js +4 -2
- package/dist/docx/serializer/paragraphSerializer.js +2 -0
- package/dist/docx/serializer/runSerializer.js +5 -3
- package/dist/docx/serializer/trackedChangeAttributes.d.ts +3 -1
- package/dist/docx/serializer/trackedChangeAttributes.js +11 -1
- package/dist/docx/server/build.d.ts +1 -1
- 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 +48 -5
- package/dist/layout-bridge/convert/toFlowBlocks.d.ts +4 -0
- package/dist/layout-bridge/convert/toFlowBlocks.js +379 -75
- 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/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 +113 -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 +190 -59
- 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 +7 -5
- package/dist/prosemirror/commands/propertyChangeScope.js +27 -18
- package/dist/prosemirror/conversion/fromProseDoc.d.ts +7 -2
- package/dist/prosemirror/conversion/fromProseDoc.js +809 -209
- package/dist/prosemirror/conversion/runShadingMark.js +2 -2
- package/dist/prosemirror/conversion/toProseDoc.d.ts +26 -1
- package/dist/prosemirror/conversion/toProseDoc.js +416 -283
- package/dist/prosemirror/extensions/StarterKit.js +4 -0
- package/dist/prosemirror/extensions/core/ParagraphExtension.js +12 -8
- package/dist/prosemirror/extensions/features/ListExtension.js +95 -123
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.js +1 -1
- 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/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/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 +8 -10
- 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 +82 -9
- package/dist/prosemirror/schema/marks.js +73 -1
- package/dist/prosemirror/schema/nodes.d.ts +18 -5
- package/dist/prosemirror/styles/resolvedStyleAttrs.d.ts +14 -2
- package/dist/prosemirror/styles/resolvedStyleAttrs.js +44 -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/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/version-comparison.d.ts +38 -44
- package/dist/version-comparison.js +270 -401
- package/package.json +3 -2
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { RUN_FORMATTING_BOOLEAN_PROPERTIES, RUN_FORMATTING_PROPERTY_SPECS, RUN_FORMATTING_VALUE_PROPERTIES } from "./schema/marks.js";
|
|
2
|
+
//#region src/prosemirror/runFormattingProvenance.ts
|
|
3
|
+
const isRunFormattingProperty = (property) => Object.hasOwn(RUN_FORMATTING_PROPERTY_SPECS, property);
|
|
4
|
+
const hasAuthoredRunFormattingProvenance = ({ _authoredOff, _authoredOn, _authoredValues }) => Array.isArray(_authoredOn) || Array.isArray(_authoredOff) || _authoredValues != null && Object.keys(_authoredValues).length > 0;
|
|
5
|
+
/** Whether an override mark still carries any rendering or authorship signal. */
|
|
6
|
+
const hasRunFormattingOverrideAttrs = (attrs) => {
|
|
7
|
+
if (hasAuthoredRunFormattingProvenance(attrs)) return true;
|
|
8
|
+
return Object.values(attrs).some((value) => {
|
|
9
|
+
if (Array.isArray(value)) return value.length > 0;
|
|
10
|
+
if (typeof value === "object" && value !== null) return Object.keys(value).length > 0;
|
|
11
|
+
return value !== null && value !== void 0;
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
/** Reconstruct the last imported/reconciled direct baseline; inherited values never enter here. */
|
|
15
|
+
const authoredRunFormattingFromAttrs = (attrs) => {
|
|
16
|
+
if (!hasAuthoredRunFormattingProvenance(attrs)) return;
|
|
17
|
+
const formatting = {};
|
|
18
|
+
for (const property of attrs._authoredOn ?? []) Reflect.set(formatting, property, true);
|
|
19
|
+
for (const property of attrs._authoredOff ?? []) Reflect.set(formatting, property, false);
|
|
20
|
+
for (const [property, value] of Object.entries(attrs._authoredValues ?? {})) if (value !== void 0 && isRunFormattingProperty(property)) Reflect.set(formatting, property, value);
|
|
21
|
+
return formatting;
|
|
22
|
+
};
|
|
23
|
+
/** Replace the direct baseline while preserving current rendering attributes. */
|
|
24
|
+
const withAuthoredRunFormatting = (attrs, formatting) => {
|
|
25
|
+
const authoredOn = [];
|
|
26
|
+
const authoredOff = [];
|
|
27
|
+
const authoredValues = {};
|
|
28
|
+
for (const property of RUN_FORMATTING_BOOLEAN_PROPERTIES) {
|
|
29
|
+
const value = formatting?.[property];
|
|
30
|
+
if (value === true) authoredOn.push(property);
|
|
31
|
+
else if (value === false) authoredOff.push(property);
|
|
32
|
+
}
|
|
33
|
+
for (const property of RUN_FORMATTING_VALUE_PROPERTIES) {
|
|
34
|
+
const value = formatting?.[property];
|
|
35
|
+
if (value !== void 0) Reflect.set(authoredValues, property, value);
|
|
36
|
+
}
|
|
37
|
+
const next = { ...attrs };
|
|
38
|
+
delete next._authoredOn;
|
|
39
|
+
delete next._authoredOff;
|
|
40
|
+
delete next._authoredValues;
|
|
41
|
+
if (authoredOn.length > 0) next._authoredOn = authoredOn;
|
|
42
|
+
if (authoredOff.length > 0) next._authoredOff = authoredOff;
|
|
43
|
+
if (Object.keys(authoredValues).length > 0) next._authoredValues = authoredValues;
|
|
44
|
+
if (authoredOn.length === 0 && authoredOff.length === 0 && Object.keys(authoredValues).length === 0) next._authoredOn = [];
|
|
45
|
+
return next;
|
|
46
|
+
};
|
|
47
|
+
//#endregion
|
|
48
|
+
export { authoredRunFormattingFromAttrs, hasAuthoredRunFormattingProvenance, hasRunFormattingOverrideAttrs, withAuthoredRunFormatting };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { document_d_exports } from "../types/document.js";
|
|
2
|
+
import { ParagraphRunStyleContext, RunStyleResolver } from "./runStyleFormatting.js";
|
|
3
|
+
import { Mark, Node } from "prosemirror-model";
|
|
4
|
+
//#region src/prosemirror/runFormattingReconciliation.d.ts
|
|
5
|
+
type ReadAuthoredRunFormattingOptions = {
|
|
6
|
+
context: ParagraphRunStyleContext;
|
|
7
|
+
marks: readonly Mark[];
|
|
8
|
+
styleResolver?: RunStyleResolver | null;
|
|
9
|
+
};
|
|
10
|
+
/** Read authored run properties without confusing inherited visuals for direct formatting. */
|
|
11
|
+
declare const readAuthoredRunFormatting: ({ context, marks, styleResolver }: ReadAuthoredRunFormattingOptions) => document_d_exports.TextFormatting;
|
|
12
|
+
type ReconcileRunFormattingMarksOptions = {
|
|
13
|
+
authoredFormatting: document_d_exports.TextFormatting;
|
|
14
|
+
context: ParagraphRunStyleContext;
|
|
15
|
+
node: Node;
|
|
16
|
+
styleResolver?: RunStyleResolver | null;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Rebuild a run's physical formatting marks from its authored properties and
|
|
20
|
+
* current style context. This is the inverse of {@link readAuthoredRunFormatting}:
|
|
21
|
+
* direct provenance stays direct while inherited formatting remains visual only.
|
|
22
|
+
*/
|
|
23
|
+
declare const reconcileRunFormattingMarks: ({ authoredFormatting, context, node, styleResolver }: ReconcileRunFormattingMarksOptions) => readonly Mark[];
|
|
24
|
+
//#endregion
|
|
25
|
+
export { readAuthoredRunFormatting, reconcileRunFormattingMarks };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { mergeTextFormatting } from "../utils/textFormattingMerge.js";
|
|
2
|
+
import { expectCharacterStyleMarkAttrs } from "./attrs/index.js";
|
|
3
|
+
import { marksToTextFormatting } from "./conversion/fromProseDoc.js";
|
|
4
|
+
import { textFormattingToMarks } from "./conversion/toProseDoc.js";
|
|
5
|
+
import { RUN_FORMATTING_MARK_NAMES } from "./runFormattingMarkNames.js";
|
|
6
|
+
import { getParagraphMarkSuppressionOverrides, hasDirectRunFormatting, paragraphFormattingForRun, resolveEffectiveRunStyleFormatting } from "./runStyleFormatting.js";
|
|
7
|
+
import { Mark } from "prosemirror-model";
|
|
8
|
+
//#region src/prosemirror/runFormattingReconciliation.ts
|
|
9
|
+
/** Read authored run properties without confusing inherited visuals for direct formatting. */
|
|
10
|
+
const readAuthoredRunFormatting = ({ context, marks, styleResolver }) => marksToTextFormatting(marks, {
|
|
11
|
+
baseParagraphFormatting: context.baseParagraphFormatting,
|
|
12
|
+
inheritedFormatting: context.paragraphFormatting,
|
|
13
|
+
paragraphMarkFormatting: context.paragraphMarkFormatting,
|
|
14
|
+
paragraphMarkPrecedesStyle: context.paragraphMarkPrecedesStyle,
|
|
15
|
+
...styleResolver !== void 0 ? { styleResolver } : {}
|
|
16
|
+
});
|
|
17
|
+
/**
|
|
18
|
+
* Rebuild a run's physical formatting marks from its authored properties and
|
|
19
|
+
* current style context. This is the inverse of {@link readAuthoredRunFormatting}:
|
|
20
|
+
* direct provenance stays direct while inherited formatting remains visual only.
|
|
21
|
+
*/
|
|
22
|
+
const reconcileRunFormattingMarks = ({ authoredFormatting, context, node, styleResolver }) => {
|
|
23
|
+
const { marks } = node;
|
|
24
|
+
const currentCharacterStyle = marks.find(({ type }) => type.name === "characterStyle");
|
|
25
|
+
const currentCharacterStyleAttrs = currentCharacterStyle ? expectCharacterStyleMarkAttrs(currentCharacterStyle) : void 0;
|
|
26
|
+
const characterStyleType = node.type.schema.marks["characterStyle"];
|
|
27
|
+
const characterStyle = authoredFormatting.styleId !== void 0 && characterStyleType ? characterStyleType.create(currentCharacterStyleAttrs?.styleId === authoredFormatting.styleId ? currentCharacterStyleAttrs : { styleId: authoredFormatting.styleId }) : void 0;
|
|
28
|
+
const directCarrierType = node.type.schema.marks["runFormattingOverride"];
|
|
29
|
+
const styleResolutionMarks = [...hasDirectRunFormatting(authoredFormatting) && directCarrierType ? [directCarrierType.create()] : [], ...characterStyle ? [characterStyle] : []];
|
|
30
|
+
const paragraphFormatting = paragraphFormattingForRun({
|
|
31
|
+
marks: styleResolutionMarks,
|
|
32
|
+
context,
|
|
33
|
+
directFormatting: authoredFormatting
|
|
34
|
+
});
|
|
35
|
+
const formattingMarks = textFormattingToMarks(mergeTextFormatting(resolveEffectiveRunStyleFormatting({
|
|
36
|
+
marks: styleResolutionMarks,
|
|
37
|
+
paragraphFormatting,
|
|
38
|
+
...styleResolver !== void 0 ? { styleResolver } : {}
|
|
39
|
+
}), authoredFormatting), {
|
|
40
|
+
overrideFormatting: mergeTextFormatting(getParagraphMarkSuppressionOverrides({
|
|
41
|
+
directFormatting: authoredFormatting,
|
|
42
|
+
paragraphMarkFormatting: context.paragraphMarkFormatting,
|
|
43
|
+
suppressedFormatting: paragraphFormatting
|
|
44
|
+
}), authoredFormatting),
|
|
45
|
+
directFormatting: authoredFormatting
|
|
46
|
+
});
|
|
47
|
+
return Mark.setFrom([
|
|
48
|
+
...marks.filter(({ type }) => !RUN_FORMATTING_MARK_NAMES.has(type.name)),
|
|
49
|
+
...formattingMarks,
|
|
50
|
+
...characterStyle ? [characterStyle] : []
|
|
51
|
+
]);
|
|
52
|
+
};
|
|
53
|
+
//#endregion
|
|
54
|
+
export { readAuthoredRunFormatting, reconcileRunFormattingMarks };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { document_d_exports } from "../types/document.js";
|
|
2
|
+
import { ParagraphRunStyleContext, RunStyleResolver } from "./runStyleFormatting.js";
|
|
3
|
+
import { Mark, Node } from "prosemirror-model";
|
|
4
|
+
//#region src/prosemirror/runPropertyChangeResolution.d.ts
|
|
5
|
+
type ReconstructRejectedRunFormattingMarksOptions = {
|
|
6
|
+
node: Node;
|
|
7
|
+
paragraphContext: ParagraphRunStyleContext;
|
|
8
|
+
previousFormatting: document_d_exports.RunPropertyChange["previousFormatting"];
|
|
9
|
+
styleResolver?: RunStyleResolver | null;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Rebuild the pre-change run marks against the paragraph's live style cascade.
|
|
13
|
+
* Both granular editor commands and the headless linear rewriter use this
|
|
14
|
+
* owner so their reject semantics cannot diverge at the bulk threshold.
|
|
15
|
+
*/
|
|
16
|
+
declare const reconstructRejectedRunFormattingMarks: ({ node, paragraphContext, previousFormatting, styleResolver }: ReconstructRejectedRunFormattingMarksOptions) => readonly Mark[];
|
|
17
|
+
//#endregion
|
|
18
|
+
export { reconstructRejectedRunFormattingMarks };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { RUN_FORMATTING_MARK_NAMES } from "./runFormattingMarkNames.js";
|
|
2
|
+
import { reconcileRunFormattingMarks } from "./runFormattingReconciliation.js";
|
|
3
|
+
//#region src/prosemirror/runPropertyChangeResolution.ts
|
|
4
|
+
/**
|
|
5
|
+
* Rebuild the pre-change run marks against the paragraph's live style cascade.
|
|
6
|
+
* Both granular editor commands and the headless linear rewriter use this
|
|
7
|
+
* owner so their reject semantics cannot diverge at the bulk threshold.
|
|
8
|
+
*/
|
|
9
|
+
const reconstructRejectedRunFormattingMarks = ({ node, paragraphContext, previousFormatting, styleResolver }) => {
|
|
10
|
+
return reconcileRunFormattingMarks({
|
|
11
|
+
authoredFormatting: previousFormatting ?? {},
|
|
12
|
+
context: paragraphContext,
|
|
13
|
+
node,
|
|
14
|
+
...styleResolver !== void 0 ? { styleResolver } : {}
|
|
15
|
+
}).filter(({ type }) => RUN_FORMATTING_MARK_NAMES.has(type.name));
|
|
16
|
+
};
|
|
17
|
+
//#endregion
|
|
18
|
+
export { reconstructRejectedRunFormattingMarks };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { document_d_exports } from "../types/document.js";
|
|
2
|
+
import { StyleEngine } from "../style-engine/styleEngine.js";
|
|
3
|
+
import "../style-engine/index.js";
|
|
4
|
+
import { Mark, Node } from "prosemirror-model";
|
|
5
|
+
//#region src/prosemirror/runStyleFormatting.d.ts
|
|
6
|
+
declare const hasDirectRunFormatting: (formatting: document_d_exports.TextFormatting | undefined) => boolean;
|
|
7
|
+
declare const stripParagraphMarkOnlyFormatting: (formatting: document_d_exports.TextFormatting) => document_d_exports.TextFormatting | undefined;
|
|
8
|
+
declare const stripParagraphMarkFormattingForBodyRuns: (formatting: document_d_exports.TextFormatting) => document_d_exports.TextFormatting | undefined;
|
|
9
|
+
type SuppressParagraphMarkFormattingOptions = {
|
|
10
|
+
baseFormatting: document_d_exports.TextFormatting | undefined;
|
|
11
|
+
directFormatting: document_d_exports.TextFormatting | undefined;
|
|
12
|
+
paragraphMarkFormatting: document_d_exports.TextFormatting | undefined;
|
|
13
|
+
paragraphMarkPrecedesStyle?: boolean;
|
|
14
|
+
};
|
|
15
|
+
declare const suppressParagraphMarkFormatting: ({ baseFormatting, directFormatting, paragraphMarkFormatting, paragraphMarkPrecedesStyle }: SuppressParagraphMarkFormattingOptions) => document_d_exports.TextFormatting | undefined;
|
|
16
|
+
type GetParagraphMarkSuppressionOverridesOptions = {
|
|
17
|
+
directFormatting: document_d_exports.TextFormatting | undefined;
|
|
18
|
+
paragraphMarkFormatting: document_d_exports.TextFormatting | undefined;
|
|
19
|
+
suppressedFormatting: document_d_exports.TextFormatting | undefined;
|
|
20
|
+
};
|
|
21
|
+
declare const getParagraphMarkSuppressionOverrides: ({ directFormatting, paragraphMarkFormatting, suppressedFormatting }: GetParagraphMarkSuppressionOverridesOptions) => document_d_exports.TextFormatting | undefined;
|
|
22
|
+
type ParagraphRunStyleContext = {
|
|
23
|
+
baseParagraphFormatting: document_d_exports.TextFormatting | undefined;
|
|
24
|
+
paragraphFormatting: document_d_exports.TextFormatting | undefined;
|
|
25
|
+
paragraphMarkFormatting: document_d_exports.TextFormatting | undefined;
|
|
26
|
+
paragraphMarkPrecedesStyle: boolean;
|
|
27
|
+
};
|
|
28
|
+
type RunStyleResolver = Pick<StyleEngine, "getDefaultCharacterStyle" | "getDocDefaults" | "getRunStyleOwnProperties" | "resolveParagraphStyle">;
|
|
29
|
+
declare const paragraphRunStyleContext: (paragraph: Node, styleResolver?: RunStyleResolver | null) => ParagraphRunStyleContext;
|
|
30
|
+
type ParagraphFormattingForRunOptions = {
|
|
31
|
+
context: ParagraphRunStyleContext;
|
|
32
|
+
directFormatting?: document_d_exports.TextFormatting;
|
|
33
|
+
marks: readonly Mark[];
|
|
34
|
+
};
|
|
35
|
+
declare const paragraphFormattingForRun: ({ context, directFormatting, marks }: ParagraphFormattingForRunOptions) => document_d_exports.TextFormatting | undefined;
|
|
36
|
+
type ParagraphRunStyleContextAtOptions = {
|
|
37
|
+
doc: Node;
|
|
38
|
+
pos: number;
|
|
39
|
+
styleResolver?: RunStyleResolver | null;
|
|
40
|
+
};
|
|
41
|
+
declare const paragraphRunStyleContextAt: ({ doc, pos, styleResolver }: ParagraphRunStyleContextAtOptions) => ParagraphRunStyleContext;
|
|
42
|
+
type ResolveEffectiveRunStyleFormattingOptions = {
|
|
43
|
+
marks: readonly Mark[];
|
|
44
|
+
paragraphFormatting: document_d_exports.TextFormatting | undefined;
|
|
45
|
+
styleResolver?: RunStyleResolver | null;
|
|
46
|
+
};
|
|
47
|
+
/** Resolve the non-direct run cascade from shared document styles and the current paragraph. */
|
|
48
|
+
declare const resolveEffectiveRunStyleFormatting: ({ marks, paragraphFormatting, styleResolver }: ResolveEffectiveRunStyleFormattingOptions) => document_d_exports.TextFormatting | undefined;
|
|
49
|
+
//#endregion
|
|
50
|
+
export { ParagraphRunStyleContext, RunStyleResolver, getParagraphMarkSuppressionOverrides, hasDirectRunFormatting, paragraphFormattingForRun, paragraphRunStyleContext, paragraphRunStyleContextAt, resolveEffectiveRunStyleFormatting, stripParagraphMarkFormattingForBodyRuns, stripParagraphMarkOnlyFormatting, suppressParagraphMarkFormatting };
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { STYLE_TOGGLE_KEYS, mergeTextFormatting } from "../utils/textFormattingMerge.js";
|
|
2
|
+
import { expectCharacterStyleMarkAttrs, expectParagraphAttrs } from "./attrs/index.js";
|
|
3
|
+
import { cascadeStyleFromResolvedBase, cascadeStyleTextFormatting } from "./styles/styleToggleCascade.js";
|
|
4
|
+
//#region src/prosemirror/runStyleFormatting.ts
|
|
5
|
+
const PARAGRAPH_MARK_BOOLEAN_KEYS = [
|
|
6
|
+
"bold",
|
|
7
|
+
"italic",
|
|
8
|
+
"strike",
|
|
9
|
+
"doubleStrike",
|
|
10
|
+
"allCaps",
|
|
11
|
+
"smallCaps",
|
|
12
|
+
"hidden",
|
|
13
|
+
"emboss",
|
|
14
|
+
"imprint",
|
|
15
|
+
"shadow",
|
|
16
|
+
"outline",
|
|
17
|
+
"rtl"
|
|
18
|
+
];
|
|
19
|
+
const hasDirectRunFormatting = (formatting) => {
|
|
20
|
+
if (!formatting) return false;
|
|
21
|
+
return Object.entries(formatting).some(([property, value]) => property !== "styleId" && value !== void 0);
|
|
22
|
+
};
|
|
23
|
+
const stripParagraphMarkOnlyFormatting = (formatting) => {
|
|
24
|
+
const { allCaps: _allCaps, highlight: _highlight, shading: _shading, smallCaps: _smallCaps, vertAlign: _vertAlign, ...formattingForBody } = formatting;
|
|
25
|
+
return Object.keys(formattingForBody).length > 0 ? formattingForBody : void 0;
|
|
26
|
+
};
|
|
27
|
+
const stripParagraphMarkFormattingForBodyRuns = (formatting) => {
|
|
28
|
+
const paragraphMarkFormatting = stripParagraphMarkOnlyFormatting(formatting);
|
|
29
|
+
if (!paragraphMarkFormatting) return;
|
|
30
|
+
const { fontFamily: _fontFamily, ...bodyRunFormatting } = paragraphMarkFormatting;
|
|
31
|
+
return Object.keys(bodyRunFormatting).length > 0 ? bodyRunFormatting : void 0;
|
|
32
|
+
};
|
|
33
|
+
const suppressParagraphMarkFormatting = ({ baseFormatting, directFormatting, paragraphMarkFormatting, paragraphMarkPrecedesStyle = false }) => {
|
|
34
|
+
if (!paragraphMarkFormatting) return baseFormatting;
|
|
35
|
+
const result = (paragraphMarkPrecedesStyle ? mergeTextFormatting(paragraphMarkFormatting, baseFormatting) : mergeTextFormatting(baseFormatting, paragraphMarkFormatting)) ?? {};
|
|
36
|
+
for (const property of PARAGRAPH_MARK_BOOLEAN_KEYS) if (paragraphMarkFormatting[property] !== void 0 && directFormatting?.[property] === void 0) Reflect.set(result, property, baseFormatting?.[property] ?? false);
|
|
37
|
+
for (const property of ["fontSize", "fontSizeCs"]) if (paragraphMarkFormatting[property] !== void 0 && directFormatting?.[property] === void 0 && baseFormatting?.[property] !== void 0) result[property] = baseFormatting[property];
|
|
38
|
+
if (paragraphMarkFormatting.underline !== void 0 && directFormatting?.underline === void 0) result.underline = { style: "none" };
|
|
39
|
+
if (paragraphMarkFormatting.spacing !== void 0 && directFormatting?.spacing === void 0) result.spacing = 0;
|
|
40
|
+
return Object.keys(result).length > 0 ? result : void 0;
|
|
41
|
+
};
|
|
42
|
+
const getParagraphMarkSuppressionOverrides = ({ directFormatting, paragraphMarkFormatting, suppressedFormatting }) => {
|
|
43
|
+
if (!paragraphMarkFormatting) return;
|
|
44
|
+
const overrides = {};
|
|
45
|
+
for (const property of PARAGRAPH_MARK_BOOLEAN_KEYS) if (paragraphMarkFormatting[property] !== void 0 && directFormatting?.[property] === void 0 && suppressedFormatting?.[property] === false) Reflect.set(overrides, property, false);
|
|
46
|
+
if (paragraphMarkFormatting.underline !== void 0 && directFormatting?.underline === void 0 && suppressedFormatting?.underline?.style === "none") overrides.underline = { style: "none" };
|
|
47
|
+
return Object.keys(overrides).length > 0 ? overrides : void 0;
|
|
48
|
+
};
|
|
49
|
+
const paragraphRunStyleContext = (paragraph, styleResolver) => {
|
|
50
|
+
const attrs = expectParagraphAttrs(paragraph);
|
|
51
|
+
const paragraphMarkFormatting = attrs._originalFormatting?.runProperties;
|
|
52
|
+
const resolvedParagraphMarkFormatting = cascadeStyleTextFormatting([{
|
|
53
|
+
formatting: paragraphMarkFormatting?.styleId ? styleResolver?.getRunStyleOwnProperties(paragraphMarkFormatting.styleId) : void 0,
|
|
54
|
+
type: "style"
|
|
55
|
+
}, {
|
|
56
|
+
formatting: paragraphMarkFormatting,
|
|
57
|
+
type: "direct"
|
|
58
|
+
}]).formatting;
|
|
59
|
+
const inheritableParagraphMarkFormatting = resolvedParagraphMarkFormatting ? stripParagraphMarkFormattingForBodyRuns(resolvedParagraphMarkFormatting) : void 0;
|
|
60
|
+
return {
|
|
61
|
+
baseParagraphFormatting: styleResolver?.resolveParagraphStyle(attrs.styleId).runFormatting,
|
|
62
|
+
paragraphFormatting: attrs.defaultTextFormatting ?? void 0,
|
|
63
|
+
paragraphMarkFormatting: inheritableParagraphMarkFormatting,
|
|
64
|
+
paragraphMarkPrecedesStyle: attrs.styleId !== void 0
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
const paragraphFormattingForRun = ({ context, directFormatting, marks }) => {
|
|
68
|
+
if (!marks.some(({ type }) => type.name === "runFormattingOverride" || type.name === "characterStyle")) return context.paragraphFormatting;
|
|
69
|
+
return suppressParagraphMarkFormatting({
|
|
70
|
+
baseFormatting: context.baseParagraphFormatting,
|
|
71
|
+
directFormatting,
|
|
72
|
+
paragraphMarkFormatting: context.paragraphMarkFormatting,
|
|
73
|
+
paragraphMarkPrecedesStyle: context.paragraphMarkPrecedesStyle
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
const paragraphRunStyleContextAt = ({ doc, pos, styleResolver }) => {
|
|
77
|
+
const resolved = doc.resolve(pos);
|
|
78
|
+
for (let depth = resolved.depth; depth >= 0; depth--) {
|
|
79
|
+
const ancestor = resolved.node(depth);
|
|
80
|
+
if (ancestor.type.name === "paragraph") return paragraphRunStyleContext(ancestor, styleResolver);
|
|
81
|
+
}
|
|
82
|
+
return {
|
|
83
|
+
baseParagraphFormatting: void 0,
|
|
84
|
+
paragraphFormatting: void 0,
|
|
85
|
+
paragraphMarkFormatting: void 0,
|
|
86
|
+
paragraphMarkPrecedesStyle: false
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
/** Resolve the non-direct run cascade from shared document styles and the current paragraph. */
|
|
90
|
+
const resolveEffectiveRunStyleFormatting = ({ marks, paragraphFormatting, styleResolver }) => {
|
|
91
|
+
const characterStyle = marks.find(({ type }) => type.name === "characterStyle");
|
|
92
|
+
const hasDirectFormattingCarrier = marks.some(({ type }) => type.name === "runFormattingOverride");
|
|
93
|
+
let styleFormatting;
|
|
94
|
+
if (characterStyle) styleFormatting = styleResolver?.getRunStyleOwnProperties(expectCharacterStyleMarkAttrs(characterStyle).styleId);
|
|
95
|
+
else if (hasDirectFormattingCarrier) styleFormatting = styleResolver?.getDefaultCharacterStyle()?.rPr;
|
|
96
|
+
if (!styleFormatting) return paragraphFormatting;
|
|
97
|
+
const docDefaults = styleResolver?.getDocDefaults()?.rPr;
|
|
98
|
+
return cascadeStyleFromResolvedBase({
|
|
99
|
+
baseFormatting: paragraphFormatting,
|
|
100
|
+
defaultsActiveProperties: STYLE_TOGGLE_KEYS.filter((property) => docDefaults?.[property] === true),
|
|
101
|
+
styleFormatting
|
|
102
|
+
});
|
|
103
|
+
};
|
|
104
|
+
//#endregion
|
|
105
|
+
export { getParagraphMarkSuppressionOverrides, hasDirectRunFormatting, paragraphFormattingForRun, paragraphRunStyleContext, paragraphRunStyleContextAt, resolveEffectiveRunStyleFormatting, stripParagraphMarkFormattingForBodyRuns, stripParagraphMarkOnlyFormatting, suppressParagraphMarkFormatting };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CharacterSpacingAttrs, CharacterStyleAttrs, CommentAttrs, EmphasisMarkAttrs, FontFamilyAttrs, FontSizeAttrs, FootnoteRefAttrs, HighlightAttrs, HyperlinkAttrs, LanguageAttrs, RunFormattingOverrideAttrs, RunPropertyChangeMarkAttrs, RunShadingAttrs, StrikeAttrs, TextColorAttrs, TextEffectAttrs, TrackedChangeMarkAttrs, UnderlineAttrs } from "./marks.js";
|
|
2
|
-
import { BlockSdtAttrs, BookmarkBoundaryAttrs, FieldAttrs, HardBreakAttrs, ImageAttrs, ImagePositionAttrs, MathAttrs, ParagraphAttrs, ParagraphPropertyChangeAttrs, SdtAttrs, ShapeAttrs, SymbolAttrs, TabAttrs, TableAttrs, TableCellAttrs, TableRowAttrs, TextBoxAttrs } from "./nodes.js";
|
|
1
|
+
import { CharacterSpacingAttrs, CharacterStyleAttrs, CommentAttrs, EmphasisMarkAttrs, FontFamilyAttrs, FontSizeAttrs, FootnoteRefAttrs, HighlightAttrs, HyperlinkAttrs, LanguageAttrs, PageBreakRunOwnerMarkAttrs, RunFormattingOverrideAttrs, RunPropertyChangeMarkAttrs, RunShadingAttrs, StrikeAttrs, TextColorAttrs, TextEffectAttrs, TrackedChangeMarkAttrs, UnderlineAttrs } from "./marks.js";
|
|
2
|
+
import { BlockSdtAttrs, BookmarkBoundaryAttrs, FieldAttrs, HardBreakAttrs, ImageAttrs, ImagePositionAttrs, MathAttrs, PageBreakRunAttrs, ParagraphAttrs, ParagraphPropertyChangeAttrs, SdtAttrs, ShapeAttrs, SymbolAttrs, TabAttrs, TableAttrs, TableCellAttrs, TableRowAttrs, TextBoxAttrs } from "./nodes.js";
|
|
3
3
|
import { ExtensionManager } from "../extensions/ExtensionManager.js";
|
|
4
4
|
//#region src/prosemirror/schema/index.d.ts
|
|
5
5
|
declare const singletonManager: ExtensionManager;
|
|
@@ -11,4 +11,4 @@ type DocxSchema = typeof schema;
|
|
|
11
11
|
type DocxNode = ReturnType<typeof schema.node>;
|
|
12
12
|
type DocxMark = ReturnType<typeof schema.mark>;
|
|
13
13
|
//#endregion
|
|
14
|
-
export { type BlockSdtAttrs, type BookmarkBoundaryAttrs, type CharacterSpacingAttrs, type CharacterStyleAttrs, type CommentAttrs, DocxMark, DocxNode, DocxSchema, type EmphasisMarkAttrs, type FieldAttrs, type FontFamilyAttrs, type FontSizeAttrs, type FootnoteRefAttrs, type HardBreakAttrs, type HighlightAttrs, type HyperlinkAttrs, type ImageAttrs, type ImagePositionAttrs, type LanguageAttrs, type MathAttrs, type ParagraphAttrs, type ParagraphPropertyChangeAttrs, type RunFormattingOverrideAttrs, type RunPropertyChangeMarkAttrs, type RunShadingAttrs, type SdtAttrs, type ShapeAttrs, type StrikeAttrs, type SymbolAttrs, type TabAttrs, type TableAttrs, type TableCellAttrs, type TableRowAttrs, type TextBoxAttrs, type TextColorAttrs, type TextEffectAttrs, type TrackedChangeMarkAttrs, type UnderlineAttrs, schema, singletonManager };
|
|
14
|
+
export { type BlockSdtAttrs, type BookmarkBoundaryAttrs, type CharacterSpacingAttrs, type CharacterStyleAttrs, type CommentAttrs, DocxMark, DocxNode, DocxSchema, type EmphasisMarkAttrs, type FieldAttrs, type FontFamilyAttrs, type FontSizeAttrs, type FootnoteRefAttrs, type HardBreakAttrs, type HighlightAttrs, type HyperlinkAttrs, type ImageAttrs, type ImagePositionAttrs, type LanguageAttrs, type MathAttrs, type PageBreakRunAttrs, type PageBreakRunOwnerMarkAttrs, type ParagraphAttrs, type ParagraphPropertyChangeAttrs, type RunFormattingOverrideAttrs, type RunPropertyChangeMarkAttrs, type RunShadingAttrs, type SdtAttrs, type ShapeAttrs, type StrikeAttrs, type SymbolAttrs, type TabAttrs, type TableAttrs, type TableCellAttrs, type TableRowAttrs, type TextBoxAttrs, type TextColorAttrs, type TextEffectAttrs, type TrackedChangeMarkAttrs, type UnderlineAttrs, schema, singletonManager };
|
|
@@ -123,28 +123,101 @@ type RunPropertyChangeMarkAttrs = {
|
|
|
123
123
|
provenance: TrackedChangeProvenance;
|
|
124
124
|
suggestionId?: string;
|
|
125
125
|
};
|
|
126
|
-
|
|
126
|
+
/** Editor-only identity for one authored run that contains an explicit page break. */
|
|
127
|
+
type PageBreakRunOwnerMarkAttrs = {
|
|
128
|
+
id: number;
|
|
129
|
+
};
|
|
130
|
+
declare const COMPLEX_SCRIPT_RUN_PROPERTY_KEYS: readonly ["boldCs", "italicCs", "fontSizeCs"];
|
|
131
|
+
type ComplexScriptRunPropertyKey = (typeof COMPLEX_SCRIPT_RUN_PROPERTY_KEYS)[number];
|
|
132
|
+
declare const RUN_FORMATTING_BOOLEAN_PROPERTIES: readonly ["bold", "boldCs", "italic", "italicCs", "strike", "doubleStrike", "smallCaps", "allCaps", "hidden", "emboss", "imprint", "outline", "shadow", "rtl", "cs"];
|
|
133
|
+
declare const RUN_FORMATTING_VALUE_PROPERTIES: readonly ["underline", "vertAlign", "color", "highlight", "shading", "fontSize", "fontSizeCs", "fontFamily", "language", "spacing", "position", "scale", "kerning", "effect", "emphasisMark"];
|
|
134
|
+
type RunFormattingBooleanProperty = (typeof RUN_FORMATTING_BOOLEAN_PROPERTIES)[number];
|
|
135
|
+
type RunFormattingValueProperty = (typeof RUN_FORMATTING_VALUE_PROPERTIES)[number];
|
|
136
|
+
declare const RUN_FORMATTING_PROPERTY_SPECS: {
|
|
137
|
+
readonly bold: "boolean";
|
|
138
|
+
readonly boldCs: "boolean";
|
|
139
|
+
readonly italic: "boolean";
|
|
140
|
+
readonly italicCs: "boolean";
|
|
141
|
+
readonly underline: "value";
|
|
142
|
+
readonly strike: "boolean";
|
|
143
|
+
readonly doubleStrike: "boolean";
|
|
144
|
+
readonly vertAlign: "value";
|
|
145
|
+
readonly smallCaps: "boolean";
|
|
146
|
+
readonly allCaps: "boolean";
|
|
147
|
+
readonly hidden: "boolean";
|
|
148
|
+
readonly color: "value";
|
|
149
|
+
readonly highlight: "value";
|
|
150
|
+
readonly shading: "value";
|
|
151
|
+
readonly fontSize: "value";
|
|
152
|
+
readonly fontSizeCs: "value";
|
|
153
|
+
readonly fontFamily: "value";
|
|
154
|
+
readonly language: "value";
|
|
155
|
+
readonly spacing: "value";
|
|
156
|
+
readonly position: "value";
|
|
157
|
+
readonly scale: "value";
|
|
158
|
+
readonly kerning: "value";
|
|
159
|
+
readonly effect: "value";
|
|
160
|
+
readonly emphasisMark: "value";
|
|
161
|
+
readonly emboss: "boolean";
|
|
162
|
+
readonly imprint: "boolean";
|
|
163
|
+
readonly outline: "boolean";
|
|
164
|
+
readonly shadow: "boolean";
|
|
165
|
+
readonly rtl: "boolean";
|
|
166
|
+
readonly cs: "boolean";
|
|
167
|
+
readonly styleId: "style";
|
|
168
|
+
};
|
|
169
|
+
type AuthoredRunFormattingValues = Partial<Pick<document_d_exports.TextFormatting, RunFormattingValueProperty>>;
|
|
170
|
+
type RunFormattingOverrideAttrs = {
|
|
171
|
+
allCaps?: boolean;
|
|
172
|
+
bold?: boolean;
|
|
173
|
+
boldCs?: boolean;
|
|
174
|
+
cs?: boolean;
|
|
175
|
+
emboss?: boolean;
|
|
176
|
+
hidden?: boolean;
|
|
177
|
+
imprint?: boolean;
|
|
178
|
+
italic?: boolean;
|
|
179
|
+
italicCs?: boolean;
|
|
180
|
+
outline?: boolean;
|
|
181
|
+
shadow?: boolean;
|
|
182
|
+
smallCaps?: boolean;
|
|
183
|
+
strike?: boolean;
|
|
184
|
+
/** Imported/reconciled direct-positive baseline; current PM signals may diverge after edits. */
|
|
185
|
+
_authoredOn?: readonly RunFormattingBooleanProperty[];
|
|
186
|
+
/** Imported/reconciled direct-negative baseline; absence means the property was inherited. */
|
|
187
|
+
_authoredOff?: readonly RunFormattingBooleanProperty[];
|
|
188
|
+
/** Imported/reconciled direct value baseline, including nested slot identity and sentinels. */
|
|
189
|
+
_authoredValues?: AuthoredRunFormattingValues;
|
|
127
190
|
directFontProperties?: readonly ("fontFamily" | "fontSize" | "color")[];
|
|
191
|
+
/** Current complex-script mirrors explicitly omitted by the run. */
|
|
192
|
+
complexScriptPropertyAbsences?: readonly ComplexScriptRunPropertyKey[];
|
|
193
|
+
color?: "auto";
|
|
128
194
|
doubleStrike?: false;
|
|
195
|
+
effect?: "none";
|
|
196
|
+
emphasisMark?: "none";
|
|
197
|
+
highlight?: "none";
|
|
198
|
+
kerning?: 0;
|
|
199
|
+
position?: 0;
|
|
129
200
|
rtl?: false;
|
|
201
|
+
scale?: 100;
|
|
202
|
+
shading?: ShadingProperties & {
|
|
203
|
+
pattern: "nil";
|
|
204
|
+
};
|
|
205
|
+
spacing?: 0;
|
|
130
206
|
fontSizeCs?: number;
|
|
131
207
|
underline?: "none";
|
|
208
|
+
vertAlign?: "baseline";
|
|
132
209
|
};
|
|
133
210
|
/**
|
|
134
211
|
* Character style mark attributes (w:rStyle).
|
|
135
212
|
*
|
|
136
213
|
* `styleId` is the OOXML character style reference, carried so a styled run
|
|
137
214
|
* re-serializes as a style reference instead of losing the semantic link.
|
|
138
|
-
*
|
|
139
|
-
*
|
|
140
|
-
*
|
|
141
|
-
* baked into the run as direct formatting on save. It is absent when the
|
|
142
|
-
* style was unknown at load — nothing was resolved, so nothing is subtracted
|
|
143
|
-
* and the reference round-trips verbatim.
|
|
215
|
+
* Style formatting is resolved once per document through the style engine;
|
|
216
|
+
* duplicating it on every styled run bloats collaborative state and becomes
|
|
217
|
+
* stale when a run moves between paragraph contexts.
|
|
144
218
|
*/
|
|
145
219
|
type CharacterStyleAttrs = {
|
|
146
220
|
styleId: string;
|
|
147
|
-
_styleRPr?: document_d_exports.TextFormatting;
|
|
148
221
|
};
|
|
149
222
|
/**
|
|
150
223
|
* Hyperlink mark attributes
|
|
@@ -156,4 +229,4 @@ type HyperlinkAttrs = {
|
|
|
156
229
|
_docxHyperlinkIndex?: number;
|
|
157
230
|
};
|
|
158
231
|
//#endregion
|
|
159
|
-
export { CharacterSpacingAttrs, CharacterStyleAttrs, CommentAttrs, EmphasisMarkAttrs, FontFamilyAttrs, FontSizeAttrs, FootnoteRefAttrs, HighlightAttrs, HyperlinkAttrs, LanguageAttrs, RunFormattingOverrideAttrs, RunPropertyChangeMarkAttrs, RunShadingAttrs, StrikeAttrs, TRACKED_CHANGE_PROVENANCE_VALUES, TextColorAttrs, TextEffectAttrs, TrackedChangeMarkAttrs, TrackedChangeProvenance, UnderlineAttrs };
|
|
232
|
+
export { AuthoredRunFormattingValues, COMPLEX_SCRIPT_RUN_PROPERTY_KEYS, CharacterSpacingAttrs, CharacterStyleAttrs, CommentAttrs, ComplexScriptRunPropertyKey, EmphasisMarkAttrs, FontFamilyAttrs, FontSizeAttrs, FootnoteRefAttrs, HighlightAttrs, HyperlinkAttrs, LanguageAttrs, PageBreakRunOwnerMarkAttrs, RUN_FORMATTING_BOOLEAN_PROPERTIES, RUN_FORMATTING_PROPERTY_SPECS, RUN_FORMATTING_VALUE_PROPERTIES, RunFormattingBooleanProperty, RunFormattingOverrideAttrs, RunFormattingValueProperty, RunPropertyChangeMarkAttrs, RunShadingAttrs, StrikeAttrs, TRACKED_CHANGE_PROVENANCE_VALUES, TextColorAttrs, TextEffectAttrs, TrackedChangeMarkAttrs, TrackedChangeProvenance, UnderlineAttrs };
|
|
@@ -11,5 +11,77 @@
|
|
|
11
11
|
* DOCX can only ever produce `"user"` marks.
|
|
12
12
|
*/
|
|
13
13
|
const TRACKED_CHANGE_PROVENANCE_VALUES = ["user", "suggested"];
|
|
14
|
+
const COMPLEX_SCRIPT_RUN_PROPERTY_KEYS = [
|
|
15
|
+
"boldCs",
|
|
16
|
+
"italicCs",
|
|
17
|
+
"fontSizeCs"
|
|
18
|
+
];
|
|
19
|
+
const RUN_FORMATTING_BOOLEAN_PROPERTIES = [
|
|
20
|
+
"bold",
|
|
21
|
+
"boldCs",
|
|
22
|
+
"italic",
|
|
23
|
+
"italicCs",
|
|
24
|
+
"strike",
|
|
25
|
+
"doubleStrike",
|
|
26
|
+
"smallCaps",
|
|
27
|
+
"allCaps",
|
|
28
|
+
"hidden",
|
|
29
|
+
"emboss",
|
|
30
|
+
"imprint",
|
|
31
|
+
"outline",
|
|
32
|
+
"shadow",
|
|
33
|
+
"rtl",
|
|
34
|
+
"cs"
|
|
35
|
+
];
|
|
36
|
+
const RUN_FORMATTING_VALUE_PROPERTIES = [
|
|
37
|
+
"underline",
|
|
38
|
+
"vertAlign",
|
|
39
|
+
"color",
|
|
40
|
+
"highlight",
|
|
41
|
+
"shading",
|
|
42
|
+
"fontSize",
|
|
43
|
+
"fontSizeCs",
|
|
44
|
+
"fontFamily",
|
|
45
|
+
"language",
|
|
46
|
+
"spacing",
|
|
47
|
+
"position",
|
|
48
|
+
"scale",
|
|
49
|
+
"kerning",
|
|
50
|
+
"effect",
|
|
51
|
+
"emphasisMark"
|
|
52
|
+
];
|
|
53
|
+
const RUN_FORMATTING_PROPERTY_SPECS = {
|
|
54
|
+
bold: "boolean",
|
|
55
|
+
boldCs: "boolean",
|
|
56
|
+
italic: "boolean",
|
|
57
|
+
italicCs: "boolean",
|
|
58
|
+
underline: "value",
|
|
59
|
+
strike: "boolean",
|
|
60
|
+
doubleStrike: "boolean",
|
|
61
|
+
vertAlign: "value",
|
|
62
|
+
smallCaps: "boolean",
|
|
63
|
+
allCaps: "boolean",
|
|
64
|
+
hidden: "boolean",
|
|
65
|
+
color: "value",
|
|
66
|
+
highlight: "value",
|
|
67
|
+
shading: "value",
|
|
68
|
+
fontSize: "value",
|
|
69
|
+
fontSizeCs: "value",
|
|
70
|
+
fontFamily: "value",
|
|
71
|
+
language: "value",
|
|
72
|
+
spacing: "value",
|
|
73
|
+
position: "value",
|
|
74
|
+
scale: "value",
|
|
75
|
+
kerning: "value",
|
|
76
|
+
effect: "value",
|
|
77
|
+
emphasisMark: "value",
|
|
78
|
+
emboss: "boolean",
|
|
79
|
+
imprint: "boolean",
|
|
80
|
+
outline: "boolean",
|
|
81
|
+
shadow: "boolean",
|
|
82
|
+
rtl: "boolean",
|
|
83
|
+
cs: "boolean",
|
|
84
|
+
styleId: "style"
|
|
85
|
+
};
|
|
14
86
|
//#endregion
|
|
15
|
-
export { TRACKED_CHANGE_PROVENANCE_VALUES };
|
|
87
|
+
export { COMPLEX_SCRIPT_RUN_PROPERTY_KEYS, RUN_FORMATTING_BOOLEAN_PROPERTIES, RUN_FORMATTING_PROPERTY_SPECS, RUN_FORMATTING_VALUE_PROPERTIES, TRACKED_CHANGE_PROVENANCE_VALUES };
|
|
@@ -6,7 +6,13 @@ import { SpacingExplicit } from "../../types/formatting.js";
|
|
|
6
6
|
import { ParagraphDirection } from "../paragraphDirection.js";
|
|
7
7
|
//#region src/prosemirror/schema/nodes.d.ts
|
|
8
8
|
type HardBreakAttrs = {
|
|
9
|
-
|
|
9
|
+
/** Absent means the source `w:br` omitted `w:type`. */
|
|
10
|
+
breakType?: "column" | "textWrapping";
|
|
11
|
+
clear?: "none" | "left" | "right" | "all";
|
|
12
|
+
};
|
|
13
|
+
/** Attributes preserved from an authored `<w:br w:type="page"/>`. */
|
|
14
|
+
type PageBreakRunAttrs = {
|
|
15
|
+
clear?: "none" | "left" | "right" | "all";
|
|
10
16
|
};
|
|
11
17
|
type TabAttrs = {
|
|
12
18
|
positional?: document_d_exports.PositionalTab;
|
|
@@ -44,12 +50,17 @@ type ParagraphAttrs = {
|
|
|
44
50
|
spaceAfter?: number;
|
|
45
51
|
lineSpacing?: number;
|
|
46
52
|
lineSpacingRule?: document_d_exports.LineSpacingRule;
|
|
47
|
-
|
|
53
|
+
/**
|
|
54
|
+
* Which line-spacing attributes came from this paragraph's own `w:spacing`.
|
|
55
|
+
* `true` is accepted for editor states written before provenance became
|
|
56
|
+
* field-specific; newly created state uses the exact discriminator.
|
|
57
|
+
*/
|
|
58
|
+
lineSpacingExplicit?: boolean | "value" | "rule" | "both";
|
|
48
59
|
snapToGrid?: boolean;
|
|
49
60
|
spacingExplicit?: SpacingExplicit;
|
|
50
61
|
/** Layout provenance: document defaults survive on empty paragraphs. */
|
|
51
62
|
spacingFromDocDefaults?: SpacingExplicit;
|
|
52
|
-
/** Layout provenance:
|
|
63
|
+
/** Layout provenance: resolved paragraph/table-style spacing survives on empty paragraphs. */
|
|
53
64
|
spacingFromImplicitDefaultStyle?: SpacingExplicit;
|
|
54
65
|
indentLeft?: number;
|
|
55
66
|
indentRight?: number;
|
|
@@ -79,6 +90,8 @@ type ParagraphAttrs = {
|
|
|
79
90
|
listIsLegal?: boolean;
|
|
80
91
|
/** Computed list marker text (e.g., "1.", "1.1.", "•") */
|
|
81
92
|
listMarker?: string;
|
|
93
|
+
/** Source numbering pattern used to compute markers for inserted list siblings. */
|
|
94
|
+
listMarkerTemplate?: string;
|
|
82
95
|
/** Whether the list marker is hidden (w:vanish on numbering level rPr) */
|
|
83
96
|
listMarkerHidden?: boolean;
|
|
84
97
|
/** Canonical numbering-level marker typography, in OOXML units. */
|
|
@@ -215,7 +228,7 @@ type ParagraphPropertyChangeAttrs = Omit<document_d_exports.ParagraphPropertyCha
|
|
|
215
228
|
};
|
|
216
229
|
previousFormatting?: Omit<document_d_exports.ParagraphFormatting, "numPr"> & {
|
|
217
230
|
numPr?: document_d_exports.ParagraphFormatting["numPr"] | null;
|
|
218
|
-
} & Partial<Pick<ParagraphAttrs, "listIsBullet" | "listIsLegal" | "listNumFmt" | "listMarker" | "listMarkerHidden" | "listMarkerFormatting" | "listMarkerAlignment" | "listMarkerSuffix" | "listLevelNumFmts" | "listLevelStarts" | "listAbstractNumId" | "listStartOverride" | "lineSpacingExplicit" | "direction" | "_autospacingBase">>;
|
|
231
|
+
} & Partial<Pick<ParagraphAttrs, "listIsBullet" | "listIsLegal" | "listNumFmt" | "listMarker" | "listMarkerTemplate" | "listMarkerHidden" | "listMarkerFormatting" | "listMarkerAlignment" | "listMarkerSuffix" | "listMarkerAllCaps" | "listImplicitChildLevelAdvances" | "listMarkerSecondSlotOffsetTwips" | "listLevelNumFmts" | "listLevelStarts" | "listAbstractNumId" | "listStartOverride" | "lineSpacingExplicit" | "direction" | "_autospacingBase">>;
|
|
219
232
|
currentFormatting?: document_d_exports.ParagraphFormatting;
|
|
220
233
|
};
|
|
221
234
|
/**
|
|
@@ -755,4 +768,4 @@ type TableCellAttrs = {
|
|
|
755
768
|
_docxVMergeContinuationCells?: document_d_exports.TableCell[];
|
|
756
769
|
};
|
|
757
770
|
//#endregion
|
|
758
|
-
export { BlockSdtAttrs, BookmarkBoundaryAttrs, FieldAttrs, HardBreakAttrs, ImageAttrs, ImagePositionAttrs, MathAttrs, ParagraphAttrs, ParagraphPropertyChangeAttrs, SdtAttrs, ShapeAttrs, SuggestedStructuralMarker, SymbolAttrs, TabAttrs, TableAttrs, TableCellAttrs, TableRowAttrs, TextBoxAnchorAttrs, TextBoxAttrs };
|
|
771
|
+
export { BlockSdtAttrs, BookmarkBoundaryAttrs, FieldAttrs, HardBreakAttrs, ImageAttrs, ImagePositionAttrs, MathAttrs, PageBreakRunAttrs, ParagraphAttrs, ParagraphPropertyChangeAttrs, SdtAttrs, ShapeAttrs, SuggestedStructuralMarker, SymbolAttrs, TabAttrs, TableAttrs, TableCellAttrs, TableRowAttrs, TextBoxAnchorAttrs, TextBoxAttrs };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { NumberingMap } from "../../docx/numberingParser.js";
|
|
2
1
|
import { ResolvedParagraphStyle } from "./styleResolver.js";
|
|
2
|
+
import { NumberingMap } from "../../docx/numberingParser.js";
|
|
3
3
|
//#region src/prosemirror/styles/resolvedStyleAttrs.d.ts
|
|
4
4
|
type ResolvedStyleIdentity = {
|
|
5
5
|
styleId: string;
|
|
@@ -31,5 +31,17 @@ declare function paragraphAttrsFromResolvedStyle(resolved: ResolvedParagraphStyl
|
|
|
31
31
|
* subsequent save + reload re-derives them from the document content.
|
|
32
32
|
*/
|
|
33
33
|
declare function listAttrsFromResolvedStyle(resolved: ResolvedParagraphStyle, numbering: NumberingMap | null | undefined): Record<string, unknown> | null;
|
|
34
|
+
/** Project one resolved numbering level into the complete editor attr group. */
|
|
35
|
+
declare function listAttrsFromNumbering(numPr: {
|
|
36
|
+
numId: number;
|
|
37
|
+
ilvl: number;
|
|
38
|
+
}, numbering: NumberingMap | null | undefined): Record<string, unknown>;
|
|
39
|
+
/** Recompute every level-dependent attr when a paragraph changes list level. */
|
|
40
|
+
declare function listLevelAttrPatch(attrs: {
|
|
41
|
+
listImplicitChildLevelAdvances?: number | null;
|
|
42
|
+
}, numPr: {
|
|
43
|
+
numId: number;
|
|
44
|
+
ilvl: number;
|
|
45
|
+
}, numbering: NumberingMap | null | undefined): Record<string, unknown>;
|
|
34
46
|
//#endregion
|
|
35
|
-
export { listAttrsFromResolvedStyle, paragraphAttrsFromResolvedStyle };
|
|
47
|
+
export { listAttrsFromNumbering, listAttrsFromResolvedStyle, listLevelAttrPatch, paragraphAttrsFromResolvedStyle };
|