@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
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { sameRunStyleContext } from "./rebaseParagraphRuns.js";
|
|
1
2
|
import { expandRunFormattingCarrier } from "./runFormattingInlineCarriers.js";
|
|
2
3
|
import { RUN_FORMATTING_MARK_NAMES } from "./runFormattingMarkNames.js";
|
|
3
4
|
import { readAuthoredRunFormatting, reconcileRunFormattingMarks } from "./runFormattingReconciliation.js";
|
|
@@ -5,18 +6,23 @@ import { paragraphRunStyleContext } from "./runStyleFormatting.js";
|
|
|
5
6
|
import { panic } from "better-result";
|
|
6
7
|
import { Mark } from "prosemirror-model";
|
|
7
8
|
//#region src/prosemirror/rebaseParagraphRunFormatting.ts
|
|
8
|
-
|
|
9
|
-
* Change paragraph attrs and re-resolve inherited run marks in the new style
|
|
10
|
-
* context without turning the old rendered style into direct run formatting.
|
|
11
|
-
*/
|
|
12
|
-
const setParagraphAttrsWithRebasedRunFormatting = ({ nextAttrs, paragraphPosition, shouldRebase, styleResolver, tr }) => {
|
|
9
|
+
const paragraphAt = (tr, paragraphPosition) => {
|
|
13
10
|
const paragraph = tr.doc.nodeAt(paragraphPosition);
|
|
14
11
|
if (!paragraph || paragraph.type.name !== "paragraph") return panic("Cannot rebase run formatting outside a paragraph", {
|
|
15
12
|
nodeType: paragraph?.type.name,
|
|
16
13
|
paragraphPosition
|
|
17
14
|
});
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
return paragraph;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Re-resolve the inherited marks of runs resolved in `previousContext` in the
|
|
19
|
+
* paragraph's current style context: direct formatting stays direct, and what
|
|
20
|
+
* the old context lent the runs goes with it.
|
|
21
|
+
*/
|
|
22
|
+
const rebaseParagraphRuns = ({ previousContext, paragraphPosition, range, shouldRebase, styleResolver, tr }) => {
|
|
23
|
+
const paragraph = paragraphAt(tr, paragraphPosition);
|
|
24
|
+
const nextContext = paragraphRunStyleContext(paragraph, styleResolver);
|
|
25
|
+
if (sameRunStyleContext(previousContext, nextContext)) return tr;
|
|
20
26
|
const changes = [];
|
|
21
27
|
const collectRebasedRepresentation = ({ node, position }) => {
|
|
22
28
|
if (shouldRebase && !shouldRebase(node)) return;
|
|
@@ -31,23 +37,28 @@ const setParagraphAttrsWithRebasedRunFormatting = ({ nextAttrs, paragraphPositio
|
|
|
31
37
|
styleResolver
|
|
32
38
|
});
|
|
33
39
|
if (Mark.sameSet(node.marks, nextMarks)) return;
|
|
40
|
+
const start = paragraphPosition + 1;
|
|
41
|
+
const from = node.isText && range ? Math.max(position, start + range.from) : position;
|
|
42
|
+
const to = node.isText && range ? Math.min(position + node.nodeSize, start + range.to) : position + node.nodeSize;
|
|
43
|
+
if (to <= from) return;
|
|
34
44
|
changes.push({
|
|
35
45
|
attrs: node.attrs,
|
|
36
46
|
currentFormattingMarks: node.marks.filter(({ type }) => RUN_FORMATTING_MARK_NAMES.has(type.name)),
|
|
37
|
-
from
|
|
47
|
+
from,
|
|
38
48
|
isText: node.isText,
|
|
39
49
|
marks: nextMarks,
|
|
40
|
-
to
|
|
50
|
+
to
|
|
41
51
|
});
|
|
42
52
|
};
|
|
43
|
-
|
|
53
|
+
const visit = (node, relativePosition) => {
|
|
44
54
|
if (!node.isInline) return true;
|
|
45
55
|
const carrier = expandRunFormattingCarrier(node, paragraphPosition + 1 + relativePosition);
|
|
46
56
|
if (!carrier) return !node.isAtom;
|
|
47
57
|
for (const representation of carrier.representations) collectRebasedRepresentation(representation);
|
|
48
58
|
return false;
|
|
49
|
-
}
|
|
50
|
-
|
|
59
|
+
};
|
|
60
|
+
if (range === void 0) paragraph.descendants(visit);
|
|
61
|
+
else paragraph.nodesBetween(range.from, range.to, visit);
|
|
51
62
|
for (const { attrs, currentFormattingMarks, from, isText, marks, to } of changes) {
|
|
52
63
|
if (!isText) {
|
|
53
64
|
tr = tr.setNodeMarkup(from, void 0, attrs, marks);
|
|
@@ -58,5 +69,20 @@ const setParagraphAttrsWithRebasedRunFormatting = ({ nextAttrs, paragraphPositio
|
|
|
58
69
|
}
|
|
59
70
|
return tr;
|
|
60
71
|
};
|
|
72
|
+
/**
|
|
73
|
+
* Change paragraph attrs and re-resolve inherited run marks in the new style
|
|
74
|
+
* context without turning the old rendered style into direct run formatting.
|
|
75
|
+
*/
|
|
76
|
+
const setParagraphAttrsWithRebasedRunFormatting = ({ nextAttrs, paragraphPosition, shouldRebase, styleResolver, tr }) => {
|
|
77
|
+
const previousContext = paragraphRunStyleContext(paragraphAt(tr, paragraphPosition), styleResolver);
|
|
78
|
+
tr = tr.setNodeMarkup(paragraphPosition, void 0, nextAttrs);
|
|
79
|
+
return rebaseParagraphRuns({
|
|
80
|
+
previousContext,
|
|
81
|
+
paragraphPosition,
|
|
82
|
+
...shouldRebase ? { shouldRebase } : {},
|
|
83
|
+
styleResolver,
|
|
84
|
+
tr
|
|
85
|
+
});
|
|
86
|
+
};
|
|
61
87
|
//#endregion
|
|
62
|
-
export { setParagraphAttrsWithRebasedRunFormatting };
|
|
88
|
+
export { rebaseParagraphRuns, setParagraphAttrsWithRebasedRunFormatting };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ParagraphRunStyleContext, RunStyleResolver } from "./runStyleFormatting.js";
|
|
2
|
+
import { Fragment, Mark, Node } from "prosemirror-model";
|
|
3
|
+
import { Transaction } from "prosemirror-state";
|
|
4
|
+
//#region src/prosemirror/rebaseParagraphRuns.d.ts
|
|
5
|
+
/** Two contexts that lend runs the same formatting: rebasing between them changes nothing. */
|
|
6
|
+
declare const sameRunStyleContext: (source: ParagraphRunStyleContext, target: ParagraphRunStyleContext) => boolean;
|
|
7
|
+
type RebaseParagraphRunsOptions = {
|
|
8
|
+
tr: Transaction;
|
|
9
|
+
position: number;
|
|
10
|
+
previous: Node;
|
|
11
|
+
target?: Node;
|
|
12
|
+
styleResolver: RunStyleResolver | null;
|
|
13
|
+
range?: {
|
|
14
|
+
from: number;
|
|
15
|
+
to: number;
|
|
16
|
+
};
|
|
17
|
+
storedMarks?: readonly Mark[] | null;
|
|
18
|
+
};
|
|
19
|
+
/** Rebuild rendered marks after the paragraph's style cascade changes. */
|
|
20
|
+
declare const rebaseParagraphRuns: ({ tr, position, previous, target, styleResolver, range, storedMarks: initialStoredMarks }: RebaseParagraphRunsOptions) => Transaction;
|
|
21
|
+
type RebasedRunFormatting = {
|
|
22
|
+
before: Node;
|
|
23
|
+
after: Node;
|
|
24
|
+
position: number;
|
|
25
|
+
};
|
|
26
|
+
type RebaseParagraphRunContentOptions = {
|
|
27
|
+
paragraph: Node;
|
|
28
|
+
target: Node;
|
|
29
|
+
position: number;
|
|
30
|
+
styleResolver: RunStyleResolver | null;
|
|
31
|
+
onRebased: (resolution: RebasedRunFormatting) => void;
|
|
32
|
+
};
|
|
33
|
+
/** Rebase an immutable paragraph chunk once, before assembling a resolved join chain. */
|
|
34
|
+
declare const rebaseParagraphRunContent: ({ paragraph, target, position, styleResolver, onRebased }: RebaseParagraphRunContentOptions) => Fragment;
|
|
35
|
+
//#endregion
|
|
36
|
+
export { rebaseParagraphRunContent, rebaseParagraphRuns, sameRunStyleContext };
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { recreateProseNodeWithParagraphPropertySource } from "../docx/paragraphPropertySource.js";
|
|
2
|
+
import { formattingEquals } from "../docx/runConsolidator.js";
|
|
3
|
+
import { applyMarksToRunFormattingRepresentation, selectRunFormattingCarrierRepresentations } from "./runFormattingInlineCarriers.js";
|
|
4
|
+
import { readAuthoredRunFormatting, reconcileRunFormattingMarks } from "./runFormattingReconciliation.js";
|
|
5
|
+
import { paragraphRunStyleContext } from "./runStyleFormatting.js";
|
|
6
|
+
import { Mark } from "prosemirror-model";
|
|
7
|
+
//#region src/prosemirror/rebaseParagraphRuns.ts
|
|
8
|
+
/** Two contexts that lend runs the same formatting: rebasing between them changes nothing. */
|
|
9
|
+
const sameRunStyleContext = (source, target) => source.paragraphMarkPrecedesStyle === target.paragraphMarkPrecedesStyle && formattingEquals(source.baseParagraphFormatting, target.baseParagraphFormatting) && formattingEquals(source.paragraphFormatting, target.paragraphFormatting) && formattingEquals(source.paragraphMarkFormatting, target.paragraphMarkFormatting);
|
|
10
|
+
/** Rebuild rendered marks after the paragraph's style cascade changes. */
|
|
11
|
+
const rebaseParagraphRuns = ({ tr, position, previous, target, styleResolver, range, storedMarks: initialStoredMarks }) => {
|
|
12
|
+
const paragraph = tr.doc.nodeAt(position);
|
|
13
|
+
if (!paragraph) return tr;
|
|
14
|
+
const storedMarks = initialStoredMarks ?? tr.storedMarks ?? tr.selection.$from.marks();
|
|
15
|
+
const sourceContext = paragraphRunStyleContext(previous, styleResolver);
|
|
16
|
+
const targetContext = paragraphRunStyleContext(target ?? paragraph, styleResolver);
|
|
17
|
+
const sameCascade = sameRunStyleContext(sourceContext, targetContext);
|
|
18
|
+
const representations = sameCascade ? [] : selectRunFormattingCarrierRepresentations({
|
|
19
|
+
doc: tr.doc,
|
|
20
|
+
from: range?.from ?? position + 1,
|
|
21
|
+
to: range?.to ?? position + paragraph.nodeSize - 1
|
|
22
|
+
});
|
|
23
|
+
for (const representation of representations) applyMarksToRunFormattingRepresentation({
|
|
24
|
+
tr,
|
|
25
|
+
representation,
|
|
26
|
+
marks: reconcileRunFormattingMarks({
|
|
27
|
+
authoredFormatting: readAuthoredRunFormatting({
|
|
28
|
+
context: sourceContext,
|
|
29
|
+
marks: representation.node.marks,
|
|
30
|
+
styleResolver
|
|
31
|
+
}),
|
|
32
|
+
context: targetContext,
|
|
33
|
+
node: representation.node,
|
|
34
|
+
styleResolver
|
|
35
|
+
})
|
|
36
|
+
});
|
|
37
|
+
if (target === void 0 && range === void 0 && tr.selection.empty && tr.selection.from > position && tr.selection.from < position + paragraph.nodeSize) {
|
|
38
|
+
const node = paragraph.type.schema.text(" ", storedMarks);
|
|
39
|
+
tr.setStoredMarks(sameCascade ? storedMarks : reconcileRunFormattingMarks({
|
|
40
|
+
authoredFormatting: readAuthoredRunFormatting({
|
|
41
|
+
context: sourceContext,
|
|
42
|
+
marks: node.marks,
|
|
43
|
+
styleResolver
|
|
44
|
+
}),
|
|
45
|
+
context: targetContext,
|
|
46
|
+
node,
|
|
47
|
+
styleResolver
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
return tr;
|
|
51
|
+
};
|
|
52
|
+
/** Rebase an immutable paragraph chunk once, before assembling a resolved join chain. */
|
|
53
|
+
const rebaseParagraphRunContent = ({ paragraph, target, position, styleResolver, onRebased }) => {
|
|
54
|
+
const sourceContext = paragraphRunStyleContext(paragraph, styleResolver);
|
|
55
|
+
const targetContext = paragraphRunStyleContext(target, styleResolver);
|
|
56
|
+
if (sameRunStyleContext(sourceContext, targetContext)) return paragraph.content;
|
|
57
|
+
const replacements = /* @__PURE__ */ new Map();
|
|
58
|
+
const representations = selectRunFormattingCarrierRepresentations({
|
|
59
|
+
doc: paragraph,
|
|
60
|
+
from: 0,
|
|
61
|
+
to: paragraph.content.size
|
|
62
|
+
});
|
|
63
|
+
for (const representation of representations) {
|
|
64
|
+
const marks = reconcileRunFormattingMarks({
|
|
65
|
+
authoredFormatting: readAuthoredRunFormatting({
|
|
66
|
+
context: sourceContext,
|
|
67
|
+
marks: representation.node.marks,
|
|
68
|
+
styleResolver
|
|
69
|
+
}),
|
|
70
|
+
context: targetContext,
|
|
71
|
+
node: representation.node,
|
|
72
|
+
styleResolver
|
|
73
|
+
});
|
|
74
|
+
if (Mark.sameSet(marks, representation.node.marks)) continue;
|
|
75
|
+
const rebased = representation.node.mark(marks);
|
|
76
|
+
replacements.set(representation.node, rebased);
|
|
77
|
+
onRebased({
|
|
78
|
+
before: representation.node,
|
|
79
|
+
after: rebased,
|
|
80
|
+
position: position + 1 + representation.position
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
if (replacements.size === 0) return paragraph.content;
|
|
84
|
+
const rebuild = (node) => {
|
|
85
|
+
const replacement = replacements.get(node) ?? node;
|
|
86
|
+
if (node.isLeaf) return replacement;
|
|
87
|
+
const children = [];
|
|
88
|
+
let changed = false;
|
|
89
|
+
replacement.forEach((child) => {
|
|
90
|
+
const next = rebuild(child);
|
|
91
|
+
children.push(next);
|
|
92
|
+
changed ||= next !== child;
|
|
93
|
+
});
|
|
94
|
+
return changed ? recreateProseNodeWithParagraphPropertySource(replacement, { content: children }) : replacement;
|
|
95
|
+
};
|
|
96
|
+
return rebuild(paragraph).content;
|
|
97
|
+
};
|
|
98
|
+
//#endregion
|
|
99
|
+
export { rebaseParagraphRunContent, rebaseParagraphRuns, sameRunStyleContext };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { document_d_exports } from "../types/document.js";
|
|
2
|
+
import { RunStyleResolver } from "./runStyleFormatting.js";
|
|
3
|
+
import { Mark } from "prosemirror-model";
|
|
4
|
+
//#region src/prosemirror/runFormattingFromMarks.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Convert ProseMirror marks to TextFormatting
|
|
7
|
+
*/
|
|
8
|
+
type MarksToTextFormattingOptions = {
|
|
9
|
+
baseParagraphFormatting?: document_d_exports.TextFormatting | undefined;
|
|
10
|
+
inheritedFormatting?: document_d_exports.TextFormatting | undefined;
|
|
11
|
+
paragraphMarkFormatting?: document_d_exports.TextFormatting | undefined;
|
|
12
|
+
paragraphMarkPrecedesStyle?: boolean | undefined;
|
|
13
|
+
styleResolver?: RunStyleResolver | null | undefined;
|
|
14
|
+
};
|
|
15
|
+
declare const sameFormattingValue: (left: unknown, right: unknown) => boolean;
|
|
16
|
+
declare function marksToTextFormatting(marks: readonly Mark[], options?: MarksToTextFormattingOptions): document_d_exports.TextFormatting;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { MarksToTextFormattingOptions, marksToTextFormatting, sameFormattingValue };
|