@stll/folio-core 0.53.0 → 0.54.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai-edits/apply.js +390 -166
- package/dist/ai-edits/batch-claims.d.ts +21 -6
- package/dist/ai-edits/batch-claims.js +47 -16
- package/dist/ai-edits/headless.d.ts +20 -0
- package/dist/ai-edits/headless.js +140 -11
- package/dist/ai-edits/pending-suggestions.js +1 -1
- package/dist/ai-edits/read.d.ts +5 -3
- package/dist/ai-edits/read.js +97 -47
- package/dist/ai-edits/revisionStretches.d.ts +17 -0
- package/dist/ai-edits/revisionStretches.js +80 -0
- package/dist/ai-edits/snapshot.js +3 -2
- package/dist/ai-edits/table-cell-mutations.d.ts +3 -1
- package/dist/ai-edits/table-cell-mutations.js +2 -1
- package/dist/ai-edits/table-row-column-mutations.d.ts +6 -1
- package/dist/ai-edits/table-row-column-mutations.js +27 -10
- package/dist/compare/content-alignment.d.ts +5 -1
- package/dist/compare/content-alignment.js +39 -32
- package/dist/compare/inline-provenance.js +1 -1
- package/dist/controller/layoutPipeline.js +3 -2
- package/dist/docx/archiveInflation.d.ts +127 -0
- package/dist/docx/archiveInflation.js +181 -0
- package/dist/docx/metadataPrivacy.js +24 -1
- package/dist/docx/noteReferenceMark.d.ts +15 -0
- package/dist/docx/noteReferenceMark.js +48 -0
- package/dist/docx/paragraphParser.js +5 -3
- package/dist/docx/paragraphPropertySource.d.ts +1 -1
- package/dist/docx/paragraphPropertySource.js +3 -1
- package/dist/docx/parser.js +2 -2
- package/dist/docx/rezip.js +4 -2
- package/dist/docx/selectiveXmlPatch.d.ts +3 -1
- package/dist/docx/selectiveXmlPatch.js +81 -3
- package/dist/docx/server/boundedArchive.d.ts +8 -13
- package/dist/docx/server/boundedArchive.js +70 -59
- package/dist/docx/server/extractDocxText.d.ts +8 -2
- package/dist/docx/server/extractDocxText.js +2 -2
- package/dist/docx/server/validateDocxConformance.d.ts +1 -1
- package/dist/docx/server/validateDocxConformance.js +1 -0
- package/dist/docx/unzip.d.ts +19 -2
- package/dist/docx/unzip.js +135 -24
- package/dist/fonts/embeddedFonts.js +1 -1
- package/dist/i18n/messages/catalogs.gen.d.ts +34 -34
- package/dist/i18n/messages/catalogs.gen.js +34 -34
- package/dist/i18n/messages/messages.gen.d.ts +2 -2
- package/dist/internal/wholeStoryRevisionResolution.js +95 -25
- package/dist/layout-engine/measure/measureParagraph.js +2 -2
- package/dist/layout-engine/measure/paragraphMeasureShared.d.ts +12 -1
- package/dist/layout-engine/measure/paragraphMeasureShared.js +14 -1
- package/dist/markdown/escape.d.ts +2 -2
- package/dist/markdown/escape.js +4 -5
- package/dist/markdown/renderBlock.js +91 -25
- package/dist/markdown/renderRuns.d.ts +10 -1
- package/dist/markdown/renderRuns.js +320 -59
- package/dist/prosemirror/clearRunColor.d.ts +6 -0
- package/dist/prosemirror/clearRunColor.js +46 -0
- package/dist/prosemirror/commands/comments.js +56 -21
- package/dist/prosemirror/commands/formatPainter.js +1 -1
- package/dist/prosemirror/commands/hyperlink.js +2 -1
- package/dist/prosemirror/commands/propertyChangeScope.d.ts +3 -2
- package/dist/prosemirror/commands/propertyChangeScope.js +24 -3
- package/dist/prosemirror/commands/resolveAllTableChanges.js +46 -41
- package/dist/prosemirror/commands/resolveParagraphProperties.js +20 -6
- package/dist/prosemirror/commands/tableCellMergeResolution.d.ts +8 -1
- package/dist/prosemirror/commands/tableCellMergeResolution.js +23 -7
- package/dist/prosemirror/containerFinalParagraph.d.ts +11 -5
- package/dist/prosemirror/containerFinalParagraph.js +7 -6
- package/dist/prosemirror/conversion/fromProseDoc.d.ts +2 -13
- package/dist/prosemirror/conversion/fromProseDoc.js +12 -590
- package/dist/prosemirror/conversion/toProseDoc.d.ts +4 -11
- package/dist/prosemirror/conversion/toProseDoc.js +31 -150
- package/dist/prosemirror/documentSchema.d.ts +8 -0
- package/dist/prosemirror/documentSchema.js +18 -0
- package/dist/prosemirror/extensions/StarterKit.js +2 -0
- package/dist/prosemirror/extensions/core/ParagraphExtension.js +104 -63
- package/dist/prosemirror/extensions/features/BaseKeymapExtension.js +1 -1
- package/dist/prosemirror/extensions/features/EmptyParagraphFormatExtension.js +24 -3
- package/dist/prosemirror/extensions/features/JoinedRunStyleExtension.d.ts +20 -0
- package/dist/prosemirror/extensions/features/JoinedRunStyleExtension.js +43 -0
- package/dist/prosemirror/extensions/features/ListExtension.js +10 -9
- package/dist/prosemirror/extensions/features/pastedHeadingStyles.js +1 -1
- package/dist/prosemirror/extensions/features/pastedHtmlLists.js +2 -4
- package/dist/prosemirror/extensions/marks/FootnoteRefExtension.js +14 -8
- package/dist/prosemirror/extensions/marks/HyperlinkExtension.js +8 -4
- package/dist/prosemirror/extensions/marks/StrikeExtension.js +2 -2
- package/dist/prosemirror/extensions/marks/SubscriptExtension.js +2 -2
- package/dist/prosemirror/extensions/marks/SuperscriptExtension.js +2 -2
- package/dist/prosemirror/extensions/marks/TextColorExtension.js +4 -3
- package/dist/prosemirror/extensions/marks/markUtils.d.ts +8 -6
- package/dist/prosemirror/extensions/marks/markUtils.js +17 -8
- package/dist/prosemirror/extensions/marks/noteReferenceDeletion.d.ts +3 -1
- package/dist/prosemirror/extensions/marks/noteReferenceDeletion.js +12 -1
- package/dist/prosemirror/extensions/nodes/CommentReferenceExtension.js +2 -2
- package/dist/prosemirror/extensions/nodes/HardBreakExtension.js +5 -3
- package/dist/prosemirror/extensions/nodes/TableExtension.js +104 -210
- package/dist/prosemirror/extensions/types.d.ts +7 -0
- package/dist/prosemirror/hyperlinkRemoval.d.ts +9 -0
- package/dist/prosemirror/hyperlinkRemoval.js +129 -0
- package/dist/prosemirror/index.d.ts +2 -1
- package/dist/prosemirror/index.js +2 -1
- package/dist/prosemirror/listNumbering.d.ts +3 -21
- package/dist/prosemirror/listNumbering.js +10 -25
- package/dist/prosemirror/listRendering.d.ts +27 -0
- package/dist/prosemirror/listRendering.js +27 -0
- package/dist/prosemirror/markupViewNotes.d.ts +8 -0
- package/dist/prosemirror/markupViewNotes.js +49 -0
- package/dist/prosemirror/markupViewProjection.d.ts +3 -1
- package/dist/prosemirror/markupViewProjection.js +7 -2
- package/dist/prosemirror/noteReferenceReview.d.ts +77 -0
- package/dist/prosemirror/noteReferenceReview.js +332 -0
- package/dist/prosemirror/paragraphIndentation.js +5 -2
- package/dist/prosemirror/paragraphMarkJoin.d.ts +6 -4
- package/dist/prosemirror/paragraphMarkJoin.js +21 -19
- package/dist/prosemirror/paragraphPropertyCarry.d.ts +64 -0
- package/dist/prosemirror/paragraphPropertyCarry.js +158 -0
- package/dist/prosemirror/plugins/documentStyleState.d.ts +26 -0
- package/dist/prosemirror/plugins/documentStyleState.js +32 -0
- package/dist/prosemirror/plugins/documentStyles.d.ts +2 -21
- package/dist/prosemirror/plugins/documentStyles.js +66 -29
- package/dist/prosemirror/plugins/index.d.ts +2 -1
- package/dist/prosemirror/plugins/index.js +2 -1
- package/dist/prosemirror/plugins/paragraphStyleResolution.d.ts +15 -0
- package/dist/prosemirror/plugins/paragraphStyleResolution.js +230 -0
- package/dist/prosemirror/plugins/suggestionMode.d.ts +12 -2
- package/dist/prosemirror/plugins/suggestionMode.js +391 -28
- package/dist/prosemirror/rebaseParagraphRunFormatting.d.ts +22 -2
- package/dist/prosemirror/rebaseParagraphRunFormatting.js +39 -13
- package/dist/prosemirror/rebaseParagraphRuns.d.ts +36 -0
- package/dist/prosemirror/rebaseParagraphRuns.js +99 -0
- package/dist/prosemirror/runFormattingFromMarks.d.ts +18 -0
- package/dist/prosemirror/runFormattingFromMarks.js +567 -0
- package/dist/prosemirror/runFormattingReconciliation.js +10 -9
- package/dist/prosemirror/schema/nodes.d.ts +2 -0
- package/dist/prosemirror/styles/paragraphStyleCascade.d.ts +59 -0
- package/dist/prosemirror/styles/paragraphStyleCascade.js +145 -0
- package/dist/prosemirror/styles/resolvedStyleAttrs.d.ts +21 -2
- package/dist/prosemirror/styles/resolvedStyleAttrs.js +38 -1
- package/dist/prosemirror/styles/tableStyleRegions.d.ts +31 -0
- package/dist/prosemirror/styles/tableStyleRegions.js +55 -0
- package/dist/prosemirror/tableCellPaste.d.ts +74 -0
- package/dist/prosemirror/tableCellPaste.js +525 -0
- package/dist/prosemirror/tableGridMutation.d.ts +53 -14
- package/dist/prosemirror/tableGridMutation.js +166 -18
- package/dist/prosemirror/tableRunIn.d.ts +51 -0
- package/dist/prosemirror/tableRunIn.js +165 -0
- package/dist/prosemirror/textInput.js +11 -2
- package/dist/prosemirror/trackedRevisionPath.d.ts +17 -0
- package/dist/prosemirror/trackedRevisionPath.js +32 -0
- package/dist/server.d.ts +2 -2
- package/package.json +5 -5
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { mergeParagraphNumbering, paragraphNumberingReferenceId } from "../../docx/numberingReference.js";
|
|
2
|
+
import { mergeParagraphFormatting, mergeParagraphTabStops } from "../../utils/paragraphFormattingMerge.js";
|
|
3
|
+
import { mergeTextFormatting } from "../../utils/textFormattingMerge.js";
|
|
4
|
+
import { paragraphNumberingAttr } from "../numberingAttr.js";
|
|
5
|
+
import { directionFromBidi } from "../paragraphDirection.js";
|
|
6
|
+
import { styleResolvedParagraphFormatting } from "../paragraphFormattingProvenance.js";
|
|
7
|
+
import { lineSpacingProvenanceFromSpacing } from "../paragraphSpacing.js";
|
|
8
|
+
import { stripParagraphMarkOnlyFormatting } from "../runStyleFormatting.js";
|
|
9
|
+
import { cascadeStyleTextFormatting } from "./styleToggleCascade.js";
|
|
10
|
+
//#region src/prosemirror/styles/paragraphStyleCascade.ts
|
|
11
|
+
function resolveRunFormattingWithoutDefaults(formatting, styleResolver) {
|
|
12
|
+
if (!formatting || !styleResolver) return formatting;
|
|
13
|
+
return cascadeStyleTextFormatting([{
|
|
14
|
+
formatting: formatting.styleId ? styleResolver.getRunStyleOwnProperties(formatting.styleId) : void 0,
|
|
15
|
+
type: "style"
|
|
16
|
+
}, {
|
|
17
|
+
formatting,
|
|
18
|
+
type: "direct"
|
|
19
|
+
}]).formatting;
|
|
20
|
+
}
|
|
21
|
+
/** @internal Recompute a paragraph's inherited run defaults from authored package state. */
|
|
22
|
+
function resolveParagraphDefaultTextFormatting(styleId, formatting, styleResolver, options = {}) {
|
|
23
|
+
const style = styleId ? styleResolver.getStyle(styleId) ?? styleResolver.getDefaultParagraphStyle() : styleResolver.getDefaultParagraphStyle();
|
|
24
|
+
const paragraphStyleRpr = style?.type === "paragraph" ? style.rPr : void 0;
|
|
25
|
+
const rawParagraphMarkRpr = options.includeParagraphMarkRunProperties === false ? void 0 : formatting?.runProperties;
|
|
26
|
+
const paragraphRunProperties = rawParagraphMarkRpr ? stripParagraphMarkOnlyFormatting(resolveRunFormattingWithoutDefaults(rawParagraphMarkRpr, styleResolver) ?? {}) : void 0;
|
|
27
|
+
const orderedBodyToggleFormatting = cascadeStyleTextFormatting([
|
|
28
|
+
{
|
|
29
|
+
formatting: styleResolver.getDocDefaults()?.rPr,
|
|
30
|
+
type: "defaults"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
formatting: paragraphStyleRpr,
|
|
34
|
+
type: "style"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
formatting: styleResolver.getDefaultCharacterStyle()?.rPr,
|
|
38
|
+
type: "style"
|
|
39
|
+
}
|
|
40
|
+
], { ordinaryFormatting: mergeTextFormatting(mergeTextFormatting(styleResolver.getDocDefaults()?.rPr, styleResolver.getDefaultCharacterStyle()?.rPr), paragraphStyleRpr) });
|
|
41
|
+
const bodyRunDefaults = orderedBodyToggleFormatting.formatting;
|
|
42
|
+
return cascadeStyleTextFormatting([{
|
|
43
|
+
cascade: orderedBodyToggleFormatting,
|
|
44
|
+
type: "carried"
|
|
45
|
+
}, {
|
|
46
|
+
formatting: paragraphRunProperties,
|
|
47
|
+
type: "direct"
|
|
48
|
+
}], { ordinaryFormatting: mergeTextFormatting(bodyRunDefaults, paragraphRunProperties) }).formatting;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Project a paragraph's style cascade onto its editor attrs: each field the
|
|
52
|
+
* paragraph states wins, every other field reads the cascade, and the
|
|
53
|
+
* provenance attrs record which is which.
|
|
54
|
+
*/
|
|
55
|
+
function paragraphStyleCascadeAttrs({ styleId, formatting, styleResolver, tableParagraphOverlay, includeParagraphMarkRunProperties }) {
|
|
56
|
+
const attrs = {};
|
|
57
|
+
const set = (key, val) => {
|
|
58
|
+
if (val !== void 0) attrs[key] = val;
|
|
59
|
+
};
|
|
60
|
+
const stylePpr = styleResolver.resolveParagraphStyleInTable(styleId, tableParagraphOverlay).paragraphFormatting;
|
|
61
|
+
const resolvedFormatting = styleResolvedParagraphFormatting(stylePpr);
|
|
62
|
+
if (resolvedFormatting) attrs._resolvedFormatting = resolvedFormatting;
|
|
63
|
+
set("alignment", formatting?.alignment ?? stylePpr?.alignment);
|
|
64
|
+
set("alignmentFromStyle", stylePpr?.alignment);
|
|
65
|
+
set("spaceBefore", formatting?.spaceBefore ?? stylePpr?.spaceBefore);
|
|
66
|
+
set("spaceAfter", formatting?.spaceAfter ?? stylePpr?.spaceAfter);
|
|
67
|
+
set("lineSpacing", formatting?.lineSpacing ?? stylePpr?.lineSpacing);
|
|
68
|
+
set("lineSpacingRule", formatting?.lineSpacingRule ?? stylePpr?.lineSpacingRule);
|
|
69
|
+
set("lineSpacingExplicit", lineSpacingProvenanceFromSpacing(formatting));
|
|
70
|
+
set("snapToGrid", formatting?.snapToGrid ?? stylePpr?.snapToGrid);
|
|
71
|
+
set("spacingExplicit", formatting?.spacingExplicit);
|
|
72
|
+
const paragraphStyle = styleId ? styleResolver.getStyle(styleId) ?? styleResolver.getDefaultParagraphStyle() : styleResolver.getDefaultParagraphStyle();
|
|
73
|
+
const docDefaultSpacing = styleResolver.getDocDefaults()?.pPr;
|
|
74
|
+
const spacingFromStyle = {};
|
|
75
|
+
if (formatting?.spaceBefore === void 0 && stylePpr?.spaceBefore !== void 0) spacingFromStyle.before = true;
|
|
76
|
+
if (formatting?.spaceAfter === void 0 && stylePpr?.spaceAfter !== void 0) spacingFromStyle.after = true;
|
|
77
|
+
if (spacingFromStyle.before || spacingFromStyle.after) attrs.spacingFromImplicitDefaultStyle = spacingFromStyle;
|
|
78
|
+
const spacingFromDocDefaults = {};
|
|
79
|
+
if (formatting?.spaceBefore === void 0 && tableParagraphOverlay?.spaceBefore === void 0 && paragraphStyle?.pPr?.spaceBefore === void 0 && docDefaultSpacing?.spaceBefore !== void 0) spacingFromDocDefaults.before = true;
|
|
80
|
+
if (formatting?.spaceAfter === void 0 && tableParagraphOverlay?.spaceAfter === void 0 && paragraphStyle?.pPr?.spaceAfter === void 0 && docDefaultSpacing?.spaceAfter !== void 0) spacingFromDocDefaults.after = true;
|
|
81
|
+
if (spacingFromDocDefaults.before || spacingFromDocDefaults.after) attrs.spacingFromDocDefaults = spacingFromDocDefaults;
|
|
82
|
+
const effectiveIndent = mergeParagraphFormatting(formatting?.numPr?.kind === "none" && paragraphNumberingReferenceId(stylePpr?.numPr) !== void 0 ? void 0 : stylePpr, formatting);
|
|
83
|
+
set("indentLeft", effectiveIndent?.indentLeft);
|
|
84
|
+
set("indentRight", formatting?.indentRight ?? stylePpr?.indentRight);
|
|
85
|
+
set("indentFirstLine", effectiveIndent?.indentFirstLine);
|
|
86
|
+
set("hangingIndent", effectiveIndent?.hangingIndent);
|
|
87
|
+
set("borders", formatting?.borders ?? stylePpr?.borders);
|
|
88
|
+
set("shading", formatting?.shading ?? stylePpr?.shading);
|
|
89
|
+
set("tabs", mergeParagraphTabStops(stylePpr?.tabs, formatting?.tabs));
|
|
90
|
+
set("kinsoku", formatting?.kinsoku ?? stylePpr?.kinsoku);
|
|
91
|
+
set("overflowPunctuation", formatting?.overflowPunctuation ?? stylePpr?.overflowPunctuation);
|
|
92
|
+
set("suppressAutoHyphens", formatting?.suppressAutoHyphens ?? stylePpr?.suppressAutoHyphens);
|
|
93
|
+
set("pageBreakBefore", formatting?.pageBreakBefore ?? stylePpr?.pageBreakBefore);
|
|
94
|
+
set("keepNext", formatting?.keepNext ?? stylePpr?.keepNext);
|
|
95
|
+
set("keepLines", formatting?.keepLines ?? stylePpr?.keepLines);
|
|
96
|
+
set("widowControl", formatting?.widowControl ?? stylePpr?.widowControl);
|
|
97
|
+
set("contextualSpacing", formatting?.contextualSpacing ?? stylePpr?.contextualSpacing);
|
|
98
|
+
set("runInWithNext", formatting?.runInWithNext ?? stylePpr?.runInWithNext);
|
|
99
|
+
set("outlineLevel", formatting?.outlineLevel ?? stylePpr?.outlineLevel);
|
|
100
|
+
set("direction", directionFromBidi(formatting?.bidi ?? stylePpr?.bidi));
|
|
101
|
+
set("defaultTextFormatting", resolveParagraphDefaultTextFormatting(styleId, formatting, styleResolver, { includeParagraphMarkRunProperties }));
|
|
102
|
+
const styleNumbering = stylePpr?.numPr;
|
|
103
|
+
if (styleNumbering?.kind === "reference" && (formatting?.numPr === void 0 || formatting.numPr.kind === "levelOnly")) {
|
|
104
|
+
const merged = mergeParagraphNumbering(styleNumbering, formatting?.numPr);
|
|
105
|
+
if (merged !== void 0) attrs.numPr = paragraphNumberingAttr(merged);
|
|
106
|
+
attrs.numPrFromStyle = paragraphNumberingAttr(styleNumbering);
|
|
107
|
+
}
|
|
108
|
+
return {
|
|
109
|
+
attrs,
|
|
110
|
+
stylePpr
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Pick the modeled paragraph fields out of a table style's (or conditional
|
|
115
|
+
* region's) `w:pPr` for use as the cell-paragraph cascade overlay.
|
|
116
|
+
*/
|
|
117
|
+
function extractTableParagraphOverlay(pPr) {
|
|
118
|
+
if (!pPr) return;
|
|
119
|
+
const overlay = {};
|
|
120
|
+
if (pPr.spaceBefore !== void 0) overlay.spaceBefore = pPr.spaceBefore;
|
|
121
|
+
if (pPr.spaceAfter !== void 0) overlay.spaceAfter = pPr.spaceAfter;
|
|
122
|
+
if (pPr.lineSpacing !== void 0) overlay.lineSpacing = pPr.lineSpacing;
|
|
123
|
+
if (pPr.lineSpacingRule !== void 0) overlay.lineSpacingRule = pPr.lineSpacingRule;
|
|
124
|
+
if (pPr.contextualSpacing !== void 0) overlay.contextualSpacing = pPr.contextualSpacing;
|
|
125
|
+
if (pPr.frame !== void 0) overlay.frame = pPr.frame;
|
|
126
|
+
return Object.keys(overlay).length > 0 ? overlay : void 0;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* The paragraph overlay a table style gives one cell's paragraphs: its base
|
|
130
|
+
* `w:pPr`, then each applicable region's (`regions`, lowest precedence first,
|
|
131
|
+
* from `tableCellStyleRegions`). A table naming no style, or a style the part
|
|
132
|
+
* does not define, reads the default table style (ECMA-376 §17.7.6).
|
|
133
|
+
*/
|
|
134
|
+
function tableCellParagraphOverlay(styleResolver, tableStyleId, regions) {
|
|
135
|
+
const style = (tableStyleId ? styleResolver.getStyle(tableStyleId) : void 0) ?? styleResolver.getDefaultTableStyle();
|
|
136
|
+
if (!style) return;
|
|
137
|
+
let overlay = extractTableParagraphOverlay(style.pPr);
|
|
138
|
+
for (const region of regions) {
|
|
139
|
+
const conditional = style.tblStylePr?.find(({ type }) => type === region);
|
|
140
|
+
overlay = mergeParagraphFormatting(overlay, extractTableParagraphOverlay(conditional?.pPr));
|
|
141
|
+
}
|
|
142
|
+
return overlay;
|
|
143
|
+
}
|
|
144
|
+
//#endregion
|
|
145
|
+
export { extractTableParagraphOverlay, paragraphStyleCascadeAttrs, resolveParagraphDefaultTextFormatting, resolveRunFormattingWithoutDefaults, tableCellParagraphOverlay };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { ParagraphAttrsPatch } from "../schema/nodes.js";
|
|
1
|
+
import { ParagraphAttrs, ParagraphAttrsPatch } from "../schema/nodes.js";
|
|
2
2
|
import { ResolvedParagraphStyle } from "./styleResolver.js";
|
|
3
3
|
import { NumberingMap } from "../../docx/numberingParser.js";
|
|
4
|
+
import { DirectParagraphIndentation } from "../paragraphIndentation.js";
|
|
4
5
|
//#region src/prosemirror/styles/resolvedStyleAttrs.d.ts
|
|
5
6
|
type ResolvedStyleIdentity = {
|
|
6
7
|
styleId: string;
|
|
@@ -37,6 +38,24 @@ declare function listAttrsFromNumbering(numPr: {
|
|
|
37
38
|
numId: number;
|
|
38
39
|
ilvl: number;
|
|
39
40
|
}, numbering: NumberingMap | null | undefined): ParagraphAttrsPatch;
|
|
41
|
+
/**
|
|
42
|
+
* The numbering level's indentation a directly numbered paragraph reads as its
|
|
43
|
+
* own where it states none: the load path folds the level's `w:ind` into the
|
|
44
|
+
* paragraph (a direct `w:ind` wins per group, left vs first line/hanging), so
|
|
45
|
+
* a paragraph a command numbers carries it too, and the save writes it where a
|
|
46
|
+
* reopen reads it back.
|
|
47
|
+
*/
|
|
48
|
+
declare function listLevelIndentAttrPatch(stated: DirectParagraphIndentation | undefined, numPr: {
|
|
49
|
+
numId: number;
|
|
50
|
+
ilvl: number;
|
|
51
|
+
}, numbering: NumberingMap | null | undefined): ParagraphAttrsPatch;
|
|
52
|
+
/**
|
|
53
|
+
* The indentation a paragraph leaving its list keeps: the level's indentation
|
|
54
|
+
* it only read from its numbering goes with the numbering, back to what its
|
|
55
|
+
* style gives, while an indentation of its own stays. The inverse of
|
|
56
|
+
* {@link listLevelIndentAttrPatch}.
|
|
57
|
+
*/
|
|
58
|
+
declare function listLevelIndentRemovalPatch(attrs: Readonly<ParagraphAttrs>, numbering: NumberingMap | null | undefined): ParagraphAttrsPatch;
|
|
40
59
|
/** Recompute every level-dependent attr when a paragraph changes list level. */
|
|
41
60
|
declare function listLevelAttrPatch(attrs: {
|
|
42
61
|
listImplicitChildLevelAdvances?: number | null;
|
|
@@ -45,4 +64,4 @@ declare function listLevelAttrPatch(attrs: {
|
|
|
45
64
|
ilvl: number;
|
|
46
65
|
}, numbering: NumberingMap | null | undefined): ParagraphAttrsPatch;
|
|
47
66
|
//#endregion
|
|
48
|
-
export { listAttrsFromNumbering, listAttrsFromResolvedStyle, listLevelAttrPatch, paragraphAttrsFromResolvedStyle };
|
|
67
|
+
export { listAttrsFromNumbering, listAttrsFromResolvedStyle, listLevelAttrPatch, listLevelIndentAttrPatch, listLevelIndentRemovalPatch, paragraphAttrsFromResolvedStyle };
|
|
@@ -112,6 +112,43 @@ function listAttrsFromNumbering(numPr, numbering) {
|
|
|
112
112
|
...rendering && listRenderingAttrPatch(rendering)
|
|
113
113
|
};
|
|
114
114
|
}
|
|
115
|
+
/**
|
|
116
|
+
* The numbering level's indentation a directly numbered paragraph reads as its
|
|
117
|
+
* own where it states none: the load path folds the level's `w:ind` into the
|
|
118
|
+
* paragraph (a direct `w:ind` wins per group, left vs first line/hanging), so
|
|
119
|
+
* a paragraph a command numbers carries it too, and the save writes it where a
|
|
120
|
+
* reopen reads it back.
|
|
121
|
+
*/
|
|
122
|
+
function listLevelIndentAttrPatch(stated, numPr, numbering) {
|
|
123
|
+
const level = numbering?.getLevel(numPr.numId, numPr.ilvl);
|
|
124
|
+
if (!level?.pPr) return {};
|
|
125
|
+
const patch = {};
|
|
126
|
+
if (stated?.indentLeft === void 0 && level.pPr.indentLeft !== void 0) patch.indentLeft = level.pPr.indentLeft;
|
|
127
|
+
if (stated?.indentFirstLine === void 0 && numberingLevelHasMarkerSlot(level)) {
|
|
128
|
+
if (level.pPr.indentFirstLine !== void 0) patch.indentFirstLine = level.pPr.indentFirstLine;
|
|
129
|
+
if (level.pPr.hangingIndent !== void 0) patch.hangingIndent = level.pPr.hangingIndent;
|
|
130
|
+
}
|
|
131
|
+
return patch;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* The indentation a paragraph leaving its list keeps: the level's indentation
|
|
135
|
+
* it only read from its numbering goes with the numbering, back to what its
|
|
136
|
+
* style gives, while an indentation of its own stays. The inverse of
|
|
137
|
+
* {@link listLevelIndentAttrPatch}.
|
|
138
|
+
*/
|
|
139
|
+
function listLevelIndentRemovalPatch(attrs, numbering) {
|
|
140
|
+
if (attrs.numPr?.kind !== "reference") return {};
|
|
141
|
+
const level = numbering?.getLevel(attrs.numPr.numId, attrs.numPr.ilvl ?? 0);
|
|
142
|
+
if (!level?.pPr) return {};
|
|
143
|
+
const resolved = attrs.numPrFromStyle != null ? void 0 : attrs._resolvedFormatting;
|
|
144
|
+
const patch = {};
|
|
145
|
+
if (level.pPr.indentLeft !== void 0 && attrs.indentLeft === level.pPr.indentLeft) patch.indentLeft = resolved?.indentLeft ?? null;
|
|
146
|
+
if (level.pPr.indentFirstLine !== void 0 && attrs.indentFirstLine === level.pPr.indentFirstLine && attrs.hangingIndent === (level.pPr.hangingIndent ?? false)) {
|
|
147
|
+
patch.indentFirstLine = resolved?.indentFirstLine ?? null;
|
|
148
|
+
patch.hangingIndent = resolved?.hangingIndent ?? false;
|
|
149
|
+
}
|
|
150
|
+
return patch;
|
|
151
|
+
}
|
|
115
152
|
/** Recompute every level-dependent attr when a paragraph changes list level. */
|
|
116
153
|
function listLevelAttrPatch(attrs, numPr, numbering) {
|
|
117
154
|
const level = numbering?.getLevel(numPr.numId, numPr.ilvl);
|
|
@@ -125,4 +162,4 @@ function listLevelAttrPatch(attrs, numPr, numbering) {
|
|
|
125
162
|
};
|
|
126
163
|
}
|
|
127
164
|
//#endregion
|
|
128
|
-
export { listAttrsFromNumbering, listAttrsFromResolvedStyle, listLevelAttrPatch, paragraphAttrsFromResolvedStyle };
|
|
165
|
+
export { listAttrsFromNumbering, listAttrsFromResolvedStyle, listLevelAttrPatch, listLevelIndentAttrPatch, listLevelIndentRemovalPatch, paragraphAttrsFromResolvedStyle };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { document_d_exports } from "../../types/document.js";
|
|
2
|
+
import "../../types/index.js";
|
|
3
|
+
import { ResolvedTableLook } from "../../docx/tableLook.js";
|
|
4
|
+
//#region src/prosemirror/styles/tableStyleRegions.d.ts
|
|
5
|
+
type TableStyleRegion = "wholeTable" | "band1Horz" | "band2Horz" | "band1Vert" | "band2Vert" | "firstCol" | "lastCol" | "firstRow" | "lastRow" | "nwCell" | "neCell" | "swCell" | "seCell";
|
|
6
|
+
/**
|
|
7
|
+
* The horizontal band a row takes by position: every row but a styled first
|
|
8
|
+
* or last row alternates, starting with band 1.
|
|
9
|
+
*/
|
|
10
|
+
declare const tableRowBand: (look: ResolvedTableLook, rowIndex: number, totalRows: number) => "band1Horz" | "band2Horz" | undefined;
|
|
11
|
+
type TableCellPlacement = {
|
|
12
|
+
look: ResolvedTableLook;
|
|
13
|
+
rowIndex: number;
|
|
14
|
+
totalRows: number;
|
|
15
|
+
/** The first grid column the cell covers. */
|
|
16
|
+
column: number;
|
|
17
|
+
colspan: number;
|
|
18
|
+
totalColumns: number;
|
|
19
|
+
/** The band `tableRowBand` gives the cell's row. */
|
|
20
|
+
rowBand: "band1Horz" | "band2Horz" | undefined;
|
|
21
|
+
rowConditionalFormat?: document_d_exports.ConditionalFormatStyle | undefined;
|
|
22
|
+
cellConditionalFormat?: document_d_exports.ConditionalFormatStyle | undefined;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* The regions that apply to one cell, lowest precedence first: the whole
|
|
26
|
+
* table, banding, columns, rows, then corners (ECMA-376 §17.7.6). A cell's or
|
|
27
|
+
* row's `w:cnfStyle` overrides what its position implies.
|
|
28
|
+
*/
|
|
29
|
+
declare const tableCellStyleRegions: ({ look, rowIndex, totalRows, column, colspan, totalColumns, rowBand, rowConditionalFormat: rowCnf, cellConditionalFormat: cellCnf }: TableCellPlacement) => TableStyleRegion[];
|
|
30
|
+
//#endregion
|
|
31
|
+
export { TableCellPlacement, TableStyleRegion, tableCellStyleRegions, tableRowBand };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
//#region src/prosemirror/styles/tableStyleRegions.ts
|
|
2
|
+
/**
|
|
3
|
+
* The horizontal band a row takes by position: every row but a styled first
|
|
4
|
+
* or last row alternates, starting with band 1.
|
|
5
|
+
*/
|
|
6
|
+
const tableRowBand = (look, rowIndex, totalRows) => {
|
|
7
|
+
if (look.noHBand) return;
|
|
8
|
+
const styledFirstRow = rowIndex === 0 && look.firstRow;
|
|
9
|
+
const styledLastRow = rowIndex === totalRows - 1 && look.lastRow;
|
|
10
|
+
if (styledFirstRow || styledLastRow) return;
|
|
11
|
+
return (look.firstRow && rowIndex > 0 ? rowIndex - 1 : rowIndex) % 2 === 0 ? "band1Horz" : "band2Horz";
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* The regions that apply to one cell, lowest precedence first: the whole
|
|
15
|
+
* table, banding, columns, rows, then corners (ECMA-376 §17.7.6). A cell's or
|
|
16
|
+
* row's `w:cnfStyle` overrides what its position implies.
|
|
17
|
+
*/
|
|
18
|
+
const tableCellStyleRegions = ({ look, rowIndex, totalRows, column, colspan, totalColumns, rowBand, rowConditionalFormat: rowCnf, cellConditionalFormat: cellCnf }) => {
|
|
19
|
+
const rowIsFirstRow = rowCnf?.firstRow ?? rowIndex === 0;
|
|
20
|
+
const rowIsLastRow = rowCnf?.lastRow ?? rowIndex === totalRows - 1;
|
|
21
|
+
const isFirstRow = cellCnf?.firstRow ?? rowIsFirstRow;
|
|
22
|
+
const isLastRow = cellCnf?.lastRow ?? rowIsLastRow;
|
|
23
|
+
const isFirstCol = cellCnf?.firstColumn ?? column === 0;
|
|
24
|
+
const isLastCol = cellCnf?.lastColumn ?? column + colspan === totalColumns;
|
|
25
|
+
let verticalBand;
|
|
26
|
+
if (!look.noVBand) {
|
|
27
|
+
const bandColumn = column - (look.firstColumn ? 1 : 0);
|
|
28
|
+
if (bandColumn >= 0 && !(look.lastColumn && isLastCol) && !(look.firstColumn && isFirstCol)) verticalBand = bandColumn % 2 === 0 ? "band1Vert" : "band2Vert";
|
|
29
|
+
}
|
|
30
|
+
if (cellCnf?.oddVBand) verticalBand = "band1Vert";
|
|
31
|
+
else if (cellCnf?.evenVBand) verticalBand = "band2Vert";
|
|
32
|
+
let horizontalBand = rowBand;
|
|
33
|
+
if (rowCnf?.oddHBand) horizontalBand = "band1Horz";
|
|
34
|
+
else if (rowCnf?.evenHBand) horizontalBand = "band2Horz";
|
|
35
|
+
if (cellCnf?.oddHBand) horizontalBand = "band1Horz";
|
|
36
|
+
else if (cellCnf?.evenHBand) horizontalBand = "band2Horz";
|
|
37
|
+
const firstRowOn = look.firstRow || rowCnf?.firstRow === true || cellCnf?.firstRow === true;
|
|
38
|
+
const lastRowOn = look.lastRow || rowCnf?.lastRow === true || cellCnf?.lastRow === true;
|
|
39
|
+
const firstColOn = look.firstColumn || rowCnf?.firstColumn === true || cellCnf?.firstColumn === true;
|
|
40
|
+
const lastColOn = look.lastColumn || rowCnf?.lastColumn === true || cellCnf?.lastColumn === true;
|
|
41
|
+
const regions = ["wholeTable"];
|
|
42
|
+
if (horizontalBand) regions.push(horizontalBand);
|
|
43
|
+
if (verticalBand) regions.push(verticalBand);
|
|
44
|
+
if (isFirstCol && firstColOn) regions.push("firstCol");
|
|
45
|
+
if (isLastCol && lastColOn) regions.push("lastCol");
|
|
46
|
+
if (isFirstRow && firstRowOn) regions.push("firstRow");
|
|
47
|
+
if (isLastRow && lastRowOn) regions.push("lastRow");
|
|
48
|
+
if (isFirstRow && isFirstCol && firstRowOn && firstColOn) regions.push("nwCell");
|
|
49
|
+
if (isFirstRow && isLastCol && firstRowOn && lastColOn) regions.push("neCell");
|
|
50
|
+
if (isLastRow && isFirstCol && lastRowOn && firstColOn) regions.push("swCell");
|
|
51
|
+
if (isLastRow && isLastCol && lastRowOn && lastColOn) regions.push("seCell");
|
|
52
|
+
return regions;
|
|
53
|
+
};
|
|
54
|
+
//#endregion
|
|
55
|
+
export { tableCellStyleRegions, tableRowBand };
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { Fragment, Node, Slice } from "prosemirror-model";
|
|
2
|
+
import { EditorState, Transaction } from "prosemirror-state";
|
|
3
|
+
import { CellSelection, Rect } from "prosemirror-tables";
|
|
4
|
+
//#region src/prosemirror/tableCellPaste.d.ts
|
|
5
|
+
/** A rectangular block of cells, one fragment of cells per row. */
|
|
6
|
+
type PastedCells = {
|
|
7
|
+
width: number;
|
|
8
|
+
height: number;
|
|
9
|
+
rows: Fragment[];
|
|
10
|
+
};
|
|
11
|
+
/** What a tracked paste records its changes as. */
|
|
12
|
+
type TableCellPasteRevision = {
|
|
13
|
+
revisionId: number;
|
|
14
|
+
author: string;
|
|
15
|
+
date: string;
|
|
16
|
+
};
|
|
17
|
+
type TableCellPasteHooks = {
|
|
18
|
+
/**
|
|
19
|
+
* The revision a split merge, a grown row or a grown column is tracked
|
|
20
|
+
* under; untracked when absent.
|
|
21
|
+
*/
|
|
22
|
+
revision?: TableCellPasteRevision;
|
|
23
|
+
/**
|
|
24
|
+
* Replace the content of the cell at `cellPos` with `slice`. Untracked
|
|
25
|
+
* pastes replace it outright; a tracked paste keeps the old content as a
|
|
26
|
+
* deletion.
|
|
27
|
+
*/
|
|
28
|
+
replaceCellContent?: CellContentReplacer;
|
|
29
|
+
};
|
|
30
|
+
type CellContentReplacer = (tr: Transaction, cellPos: number, slice: Slice) => void;
|
|
31
|
+
/**
|
|
32
|
+
* A pasted slice whose table cells are new cells: a copy of a cell must not
|
|
33
|
+
* claim the source cell's identity, revisions, or the continuation cells its
|
|
34
|
+
* merge stored, whatever the paste lands on.
|
|
35
|
+
*/
|
|
36
|
+
declare const pastedSliceWithNewTableCells: (slice: Slice) => Slice;
|
|
37
|
+
/** The cells a slice holds, or null when it holds none (it is not table content). */
|
|
38
|
+
declare const pastedCells: (slice: Slice) => PastedCells | null;
|
|
39
|
+
/**
|
|
40
|
+
* The range of a cell's content a paste replaces. A block of whole paragraphs
|
|
41
|
+
* (a pasted cell's content) replaces all of it; open content (text, or
|
|
42
|
+
* paragraphs cut from a longer run) goes from the start of the first paragraph
|
|
43
|
+
* to the end of the last, so it takes on the cell's paragraph formatting the
|
|
44
|
+
* way a paste into a paragraph does.
|
|
45
|
+
*/
|
|
46
|
+
declare const cellPasteRange: (cell: Node, cellPos: number, slice: Slice) => {
|
|
47
|
+
from: number;
|
|
48
|
+
to: number;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Paste a block of cells into the table at `tableStart` from (`top`, `left`):
|
|
52
|
+
* grow the table to hold it, split the merges its edges cut through, then give
|
|
53
|
+
* each cell the block covers its pasted cell. Where the block's cells have the
|
|
54
|
+
* table's shapes the table keeps its cells, with their formatting and
|
|
55
|
+
* identity, and takes the pasted content; otherwise the block's cells replace
|
|
56
|
+
* them, except in a tracked paste, which keeps the table's shape. Selects the
|
|
57
|
+
* pasted block.
|
|
58
|
+
*/
|
|
59
|
+
declare const insertTableCells: (tr: Transaction, tableStart: number, { top, left }: Pick<Rect, "top" | "left">, cells: PastedCells, { revision, replaceCellContent }?: TableCellPasteHooks) => Transaction;
|
|
60
|
+
/**
|
|
61
|
+
* Paste into every cell of a cell selection: each takes the pasted cell at its
|
|
62
|
+
* place in the block, the block repeating to cover the selection, or the
|
|
63
|
+
* pasted content itself when it holds no cells. The table keeps its shape.
|
|
64
|
+
*/
|
|
65
|
+
declare const fillSelectedCells: (tr: Transaction, selection: CellSelection, slice: Slice, { replaceCellContent }?: TableCellPasteHooks) => Transaction;
|
|
66
|
+
/**
|
|
67
|
+
* Paste `slice` into the table the selection is in: into every selected cell
|
|
68
|
+
* of a cell selection, or, when the slice holds cells, as a block of cells
|
|
69
|
+
* from the cell holding the cursor. False otherwise, so the paste falls
|
|
70
|
+
* through to the ordinary one.
|
|
71
|
+
*/
|
|
72
|
+
declare const pasteTableCells: (state: EditorState, slice: Slice, dispatch?: (tr: Transaction) => void, hooks?: TableCellPasteHooks) => boolean;
|
|
73
|
+
//#endregion
|
|
74
|
+
export { CellContentReplacer, PastedCells, TableCellPasteHooks, TableCellPasteRevision, cellPasteRange, fillSelectedCells, insertTableCells, pasteTableCells, pastedCells, pastedSliceWithNewTableCells };
|