@stll/folio-core 0.55.0 → 0.57.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 +214 -52
- package/dist/ai-edits/batch-claims.d.ts +3 -1
- package/dist/ai-edits/batch-claims.js +25 -1
- package/dist/ai-edits/headless.js +2 -2
- package/dist/ai-edits/table-row-column-mutations.js +17 -3
- package/dist/ai-edits/types.d.ts +7 -1
- package/dist/ai-suggestions/apply.js +20 -1
- package/dist/compare/compare.js +1 -0
- package/dist/compare/inline-atoms.js +40 -16
- package/dist/compare/inline-provenance.js +12 -5
- package/dist/compare/reproducible-package.d.ts +0 -17
- package/dist/compare/reproducible-package.js +12 -18
- package/dist/compat/eigenpal.d.ts +2 -1
- package/dist/compat/eigenpal.js +2 -1
- package/dist/controller/canonicalClipboard.d.ts +23 -0
- package/dist/controller/canonicalClipboard.js +482 -0
- package/dist/controller/canonicalClipboardResources.d.ts +21 -0
- package/dist/controller/canonicalClipboardResources.js +382 -0
- package/dist/controller/canonicalComments.d.ts +41 -0
- package/dist/controller/canonicalComments.js +152 -0
- package/dist/controller/canonicalComposition.d.ts +24 -3
- package/dist/controller/canonicalComposition.js +208 -48
- package/dist/controller/canonicalInlineProjection.d.ts +118 -0
- package/dist/controller/canonicalInlineProjection.js +476 -0
- package/dist/controller/canonicalInput.d.ts +13 -4
- package/dist/controller/canonicalInput.js +62 -14
- package/dist/controller/canonicalInputTimer.d.ts +16 -0
- package/dist/controller/canonicalInputTimer.js +34 -0
- package/dist/controller/canonicalPublicOperations.d.ts +48 -0
- package/dist/controller/canonicalPublicOperations.js +648 -0
- package/dist/controller/canonicalSelection.d.ts +18 -0
- package/dist/controller/canonicalSelection.js +32 -0
- package/dist/controller/canonicalSession.d.ts +27 -6
- package/dist/controller/canonicalSession.js +298 -116
- package/dist/controller/canonicalStoryEditor.d.ts +7 -3
- package/dist/controller/canonicalStoryEditor.js +27 -2
- package/dist/controller/canonicalStructure.js +57 -4
- package/dist/controller/canonicalTocSelection.d.ts +11 -0
- package/dist/controller/canonicalTocSelection.js +43 -0
- package/dist/controller/folioEditor.d.ts +2 -9
- package/dist/controller/folioEditor.js +18 -4
- package/dist/controller/headerFooterEditorManager.d.ts +2 -1
- package/dist/controller/headerFooterEditorManager.js +26 -11
- package/dist/controller/hiddenEditorApi.d.ts +24 -3
- package/dist/controller/hiddenEditorApi.js +8 -0
- package/dist/controller/hiddenEditorManager.d.ts +5 -1
- package/dist/controller/hiddenEditorManager.js +378 -43
- package/dist/controller/noteEditorManager.d.ts +2 -1
- package/dist/controller/noteEditorManager.js +29 -13
- package/dist/document-operations.d.ts +8 -1
- package/dist/document-operations.js +6 -4
- package/dist/docx/blockPlainText.d.ts +1 -1
- package/dist/docx/blockPlainText.js +11 -3
- package/dist/docx/builtInStyles.js +13 -6
- package/dist/docx/canonicalResourceSave.d.ts +16 -0
- package/dist/docx/canonicalResourceSave.js +27 -0
- package/dist/docx/canonicalSave.d.ts +29 -0
- package/dist/docx/canonicalSave.js +101 -0
- package/dist/docx/canonicalStoryRepack.d.ts +1 -1
- package/dist/docx/canonicalStoryRepack.js +38 -5
- package/dist/docx/containerChildren.gen.d.ts +3 -1
- package/dist/docx/containerChildren.gen.js +33 -1
- package/dist/docx/documentParser.d.ts +1 -13
- package/dist/docx/documentParser.js +1 -47
- package/dist/docx/ensureParaIds.js +10 -4
- package/dist/docx/fieldParser.js +14 -2
- package/dist/docx/footnoteParser.d.ts +1 -11
- package/dist/docx/footnoteParser.js +1 -16
- package/dist/docx/headerFooterParser.d.ts +1 -9
- package/dist/docx/headerFooterParser.js +1 -12
- package/dist/docx/headerFooterVerbatim.d.ts +26 -1
- package/dist/docx/headerFooterVerbatim.js +81 -3
- package/dist/docx/hyperlinkParser.d.ts +1 -1
- package/dist/docx/hyperlinkParser.js +20 -1
- package/dist/docx/imageParser.d.ts +13 -1
- package/dist/docx/imageParser.js +20 -11
- package/dist/docx/inlineWrapperContent.d.ts +4 -4
- package/dist/docx/inlineWrapperContent.js +4 -4
- package/dist/docx/linkedSdtPreservation.d.ts +10 -0
- package/dist/docx/linkedSdtPreservation.js +37 -0
- package/dist/docx/metadataPrivacy.js +6 -1
- package/dist/docx/packageParts.js +9 -3
- package/dist/docx/paragraphParser.js +88 -67
- package/dist/docx/paragraphPropertySource.d.ts +22 -1
- package/dist/docx/paragraphPropertySource.js +109 -2
- package/dist/docx/parser.js +2 -1
- package/dist/docx/preservedRunContent.js +2 -1
- package/dist/docx/relsParser.js +26 -2
- package/dist/docx/removeHeaderFooterParts.js +17 -6
- package/dist/docx/rezip.d.ts +49 -5
- package/dist/docx/rezip.js +754 -235
- package/dist/docx/saveDiagnostics.d.ts +11 -0
- package/dist/docx/selectiveSave.d.ts +2 -1
- package/dist/docx/selectiveSave.js +42 -11
- package/dist/docx/selectiveXmlPatch.js +7 -5
- package/dist/docx/serializer/commentSerializer.d.ts +4 -1
- package/dist/docx/serializer/commentSerializer.js +7 -3
- package/dist/docx/serializer/documentSerializer.d.ts +9 -2
- package/dist/docx/serializer/documentSerializer.js +29 -10
- package/dist/docx/serializer/paragraphSerializer.js +207 -94
- package/dist/docx/server/applyDocxXmlPatchProposal.js +14 -9
- package/dist/docx/server/materializeYjsDocx.js +14 -6
- package/dist/docx/server/migrateYjsAttrSchema.js +17 -5
- package/dist/docx/storyBlockReplay.d.ts +21 -1
- package/dist/docx/storyBlockReplay.js +113 -9
- package/dist/docx/storyPlainText.d.ts +20 -0
- package/dist/docx/storyPlainText.js +23 -0
- package/dist/docx/structuralXmlPatch.js +10 -22
- package/dist/docx/styleParser.d.ts +5 -1
- package/dist/docx/styleParser.js +1 -1
- package/dist/docx/tableParser.d.ts +1 -8
- package/dist/docx/tableParser.js +1 -28
- package/dist/docx/textBoxParser.d.ts +1 -5
- package/dist/docx/textBoxParser.js +1 -20
- package/dist/docx/unzip.js +6 -1
- package/dist/i18n/messages/ar.gen.js +4 -0
- package/dist/i18n/messages/catalogs.gen.d.ts +68 -0
- package/dist/i18n/messages/catalogs.gen.js +68 -0
- package/dist/i18n/messages/cs.gen.js +4 -0
- package/dist/i18n/messages/de.gen.js +4 -0
- package/dist/i18n/messages/en.gen.js +4 -0
- package/dist/i18n/messages/es.gen.js +4 -0
- package/dist/i18n/messages/et.gen.js +4 -0
- package/dist/i18n/messages/fr.gen.js +4 -0
- package/dist/i18n/messages/he.gen.js +4 -0
- package/dist/i18n/messages/hi.gen.js +4 -0
- package/dist/i18n/messages/hu.gen.js +4 -0
- package/dist/i18n/messages/lt.gen.js +4 -0
- package/dist/i18n/messages/lv.gen.js +4 -0
- package/dist/i18n/messages/messages.gen.d.ts +4 -0
- package/dist/i18n/messages/pl.gen.js +4 -0
- package/dist/i18n/messages/pt-BR.gen.js +4 -0
- package/dist/i18n/messages/sk.gen.js +4 -0
- package/dist/i18n/messages/tr.gen.js +4 -0
- package/dist/i18n/messages/zh-CN.gen.js +4 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/internal/acceptedBlockProjection.d.ts +12 -0
- package/dist/internal/acceptedBlockProjection.js +45 -0
- package/dist/internal/revisionResolutionInline.js +25 -3
- package/dist/managers/DocumentLoaderManager.js +2 -1
- package/dist/markdown/escape.d.ts +3 -1
- package/dist/markdown/escape.js +9 -2
- package/dist/markdown/renderBlock.js +5 -120
- package/dist/markdown/renderParagraph.js +4 -2
- package/dist/markdown/renderRuns.d.ts +7 -1
- package/dist/markdown/renderRuns.js +33 -24
- package/dist/panel-layout.d.ts +11 -9
- package/dist/panel-layout.js +13 -9
- package/dist/prosemirror/addTrackedDeletionMark.d.ts +18 -0
- package/dist/prosemirror/addTrackedDeletionMark.js +87 -0
- package/dist/prosemirror/attrs/index.js +5 -0
- package/dist/prosemirror/canonicalCommands.d.ts +28 -4
- package/dist/prosemirror/canonicalCommands.js +11 -4
- package/dist/prosemirror/canonicalSelectionRange.d.ts +9 -0
- package/dist/prosemirror/canonicalSelectionRange.js +15 -0
- package/dist/prosemirror/clipboardIntent.d.ts +7 -0
- package/dist/prosemirror/clipboardIntent.js +9 -0
- package/dist/prosemirror/commands/comments.js +60 -35
- package/dist/prosemirror/commands/pageBreak.js +2 -2
- package/dist/prosemirror/commands/pastePlainText.js +2 -1
- package/dist/prosemirror/commands/propertyChangeScope.js +3 -6
- package/dist/prosemirror/commands/resolveParagraphProperties.js +22 -13
- package/dist/prosemirror/commentOps.js +15 -1
- package/dist/prosemirror/conversion/fromProseDoc.js +22 -3
- package/dist/prosemirror/conversion/hyphenTextCarriers.d.ts +8 -0
- package/dist/prosemirror/conversion/hyphenTextCarriers.js +8 -0
- package/dist/prosemirror/conversion/toProseDoc.d.ts +7 -1
- package/dist/prosemirror/conversion/toProseDoc.js +124 -22
- package/dist/prosemirror/extensions/core/ParagraphExtension.js +61 -35
- package/dist/prosemirror/extensions/features/BaseKeymapExtension.js +74 -25
- package/dist/prosemirror/extensions/marks/FootnoteRefExtension.js +11 -0
- package/dist/prosemirror/extensions/marks/HyperlinkExtension.js +65 -29
- package/dist/prosemirror/extensions/marks/markUtils.js +11 -8
- package/dist/prosemirror/extensions/marks/noteReferenceDeletion.js +5 -2
- package/dist/prosemirror/fieldRepresentation.d.ts +8 -0
- package/dist/prosemirror/fieldRepresentation.js +18 -0
- package/dist/prosemirror/hyperlinkRemoval.d.ts +13 -1
- package/dist/prosemirror/hyperlinkRemoval.js +28 -9
- package/dist/prosemirror/insertOperations.js +2 -1
- package/dist/prosemirror/listNumbering.js +11 -5
- package/dist/prosemirror/noteReferenceOccurrenceId.d.ts +5 -0
- package/dist/prosemirror/noteReferenceOccurrenceId.js +5 -0
- package/dist/prosemirror/noteReferenceOccurrences.d.ts +21 -0
- package/dist/prosemirror/noteReferenceOccurrences.js +185 -0
- package/dist/prosemirror/noteReferenceReview.js +14 -1
- package/dist/prosemirror/paragraphPropertyCarry.d.ts +7 -1
- package/dist/prosemirror/paragraphPropertyCarry.js +8 -3
- package/dist/prosemirror/plugins/documentStyles.d.ts +4 -1
- package/dist/prosemirror/plugins/documentStyles.js +17 -10
- package/dist/prosemirror/plugins/suggestionMode.js +48 -48
- package/dist/prosemirror/preservedXmlReview.d.ts +6 -0
- package/dist/prosemirror/preservedXmlReview.js +35 -0
- package/dist/prosemirror/runFormattingFromMarks.js +2 -2
- package/dist/prosemirror/runFormattingReconciliation.js +5 -4
- package/dist/prosemirror/runPropertyChangeResolution.d.ts +8 -1
- package/dist/prosemirror/runPropertyChangeResolution.js +24 -2
- package/dist/prosemirror/runStyleFormatting.d.ts +3 -1
- package/dist/prosemirror/runStyleFormatting.js +3 -1
- package/dist/prosemirror/schema/marks.d.ts +1 -0
- package/dist/prosemirror/schema/nodes.d.ts +2 -0
- package/dist/prosemirror/styles/paragraphStyleCascade.js +4 -1
- package/dist/prosemirror/styles/resolvedStyleAttrs.d.ts +15 -15
- package/dist/prosemirror/styles/resolvedStyleAttrs.js +69 -28
- package/dist/prosemirror/textInput.d.ts +5 -1
- package/dist/prosemirror/textInput.js +3 -3
- package/dist/prosemirror/trackedRevisionPath.d.ts +5 -1
- package/dist/prosemirror/trackedRevisionPath.js +39 -1
- package/dist/prosemirror/validation.js +3 -5
- package/dist/prosemirror/yjsDocumentMetadata.d.ts +9 -3
- package/dist/prosemirror/yjsDocumentMetadata.js +37 -8
- package/dist/types/canonicalCapabilities.d.ts +201 -0
- package/dist/types/canonicalCapabilities.js +198 -0
- package/dist/types/canonicalComments.d.ts +51 -0
- package/dist/types/canonicalComments.js +0 -0
- package/dist/types/canonicalSave.d.ts +11 -0
- package/dist/types/canonicalSave.js +0 -0
- package/dist/types/canonicalSections.d.ts +12 -0
- package/dist/types/canonicalSections.js +0 -0
- package/dist/types/docxSerialization.d.ts +14 -0
- package/dist/types/docxSerialization.js +7 -0
- package/dist/utils/headingCollector.js +45 -4
- package/dist/utils/outlineDepth.d.ts +9 -0
- package/dist/utils/outlineDepth.js +9 -0
- package/package.json +4 -4
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { canonicalSelectionRange } from "./canonicalSelectionRange.js";
|
|
1
2
|
//#region src/prosemirror/canonicalCommands.ts
|
|
2
3
|
const descriptors = /* @__PURE__ */ new WeakMap();
|
|
3
4
|
/** Registration leaves execution and side-effect-free command probes unchanged. */
|
|
@@ -8,11 +9,10 @@ const withCanonicalCommand = (command, descriptor) => {
|
|
|
8
9
|
const getCanonicalCommandIntents = (command, state) => descriptors.get(command)?.(state);
|
|
9
10
|
const canonicalRunFormatting = (state, patch) => [{
|
|
10
11
|
type: "formatRun",
|
|
11
|
-
|
|
12
|
-
to: state.selection.to,
|
|
12
|
+
...canonicalSelectionRange(state),
|
|
13
13
|
patch
|
|
14
14
|
}];
|
|
15
|
-
const
|
|
15
|
+
const canonicalParagraphFormatting = (state, patch) => {
|
|
16
16
|
const intents = [];
|
|
17
17
|
state.doc.nodesBetween(state.selection.from, state.selection.to, (node, position) => {
|
|
18
18
|
if (node.type.name !== "paragraph") return;
|
|
@@ -23,6 +23,13 @@ const withCanonicalParagraphFormatting = (command, patch) => withCanonicalComman
|
|
|
23
23
|
});
|
|
24
24
|
});
|
|
25
25
|
return intents;
|
|
26
|
+
};
|
|
27
|
+
const withCanonicalParagraphFormatting = (command, patch) => withCanonicalCommand(command, (state) => canonicalParagraphFormatting(state, patch));
|
|
28
|
+
/** Commands that read the selection start apply that same patch across selected paragraphs. */
|
|
29
|
+
const withCanonicalStartParagraphFormatting = (command, patch) => withCanonicalCommand(command, (state) => {
|
|
30
|
+
const paragraph = state.selection.$from.parent;
|
|
31
|
+
if (paragraph.type.name !== "paragraph") return [];
|
|
32
|
+
return canonicalParagraphFormatting(state, patch(paragraph));
|
|
26
33
|
});
|
|
27
34
|
//#endregion
|
|
28
|
-
export { canonicalRunFormatting, getCanonicalCommandIntents, withCanonicalCommand, withCanonicalParagraphFormatting };
|
|
35
|
+
export { canonicalRunFormatting, getCanonicalCommandIntents, withCanonicalCommand, withCanonicalParagraphFormatting, withCanonicalStartParagraphFormatting };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { EditorState } from "prosemirror-state";
|
|
2
|
+
//#region src/prosemirror/canonicalSelectionRange.d.ts
|
|
3
|
+
/** Whole-document selection addresses paragraph content rather than document edges. */
|
|
4
|
+
declare const canonicalSelectionRange: ({ doc, selection }: EditorState) => {
|
|
5
|
+
from: number;
|
|
6
|
+
to: number;
|
|
7
|
+
};
|
|
8
|
+
//#endregion
|
|
9
|
+
export { canonicalSelectionRange };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { AllSelection, Selection } from "prosemirror-state";
|
|
2
|
+
//#region src/prosemirror/canonicalSelectionRange.ts
|
|
3
|
+
/** Whole-document selection addresses paragraph content rather than document edges. */
|
|
4
|
+
const canonicalSelectionRange = ({ doc, selection }) => {
|
|
5
|
+
if (selection instanceof AllSelection) return {
|
|
6
|
+
from: Selection.atStart(doc).from,
|
|
7
|
+
to: Selection.atEnd(doc).to
|
|
8
|
+
};
|
|
9
|
+
return {
|
|
10
|
+
from: selection.from,
|
|
11
|
+
to: selection.to
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
//#endregion
|
|
15
|
+
export { canonicalSelectionRange };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Slice } from "prosemirror-model";
|
|
2
|
+
import { EditorView } from "prosemirror-view";
|
|
3
|
+
//#region src/prosemirror/clipboardIntent.d.ts
|
|
4
|
+
declare const registerClipboardIntentHandler: (view: EditorView, handler: (slice: Slice, plain: boolean) => boolean) => void;
|
|
5
|
+
declare const dispatchClipboardIntent: (view: EditorView, slice: Slice) => boolean | undefined;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { dispatchClipboardIntent, registerClipboardIntentHandler };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region src/prosemirror/clipboardIntent.ts
|
|
2
|
+
/** Async clipboard reads resolve against the current owning session and selection. */
|
|
3
|
+
const handlers = /* @__PURE__ */ new WeakMap();
|
|
4
|
+
const registerClipboardIntentHandler = (view, handler) => {
|
|
5
|
+
handlers.set(view, handler);
|
|
6
|
+
};
|
|
7
|
+
const dispatchClipboardIntent = (view, slice) => handlers.get(view)?.(slice, true);
|
|
8
|
+
//#endregion
|
|
9
|
+
export { dispatchClipboardIntent, registerClipboardIntentHandler };
|
|
@@ -10,20 +10,23 @@ import { resolveEmptyFieldResultRuns } from "../emptyFieldResultRuns.js";
|
|
|
10
10
|
import { JOINED_RUNS_RESTYLED_META } from "../extensions/features/JoinedRunStyleExtension.js";
|
|
11
11
|
import { markChangedParagraphRanges, markStructuralChange, markTrackedSectionEndpointRemoval } from "../extensions/features/ParagraphChangeTrackerExtension.js";
|
|
12
12
|
import "../extensions/nodes/SdtExtension.js";
|
|
13
|
+
import { canonicalFieldNode } from "../fieldRepresentation.js";
|
|
13
14
|
import { resolveStateStory } from "../markupViewProjection.js";
|
|
14
15
|
import { joinAtParagraphMark } from "../paragraphMarkJoin.js";
|
|
15
16
|
import { getDocumentNumbering } from "../plugins/documentNumbering.js";
|
|
16
17
|
import { getDocumentStyleResolver } from "../plugins/documentStyleState.js";
|
|
18
|
+
import { resolvedPreservedXmlAttrs } from "../preservedXmlReview.js";
|
|
17
19
|
import { rebaseParagraphRuns, setParagraphAttrsWithRebasedRunFormatting } from "../rebaseParagraphRunFormatting.js";
|
|
18
20
|
import { rejoinRunsAt } from "../rejoinRunCarriers.js";
|
|
19
21
|
import { getFolioNodeRevisionCarriers, nodePropertyRevisionSites } from "../revisionCarriers.js";
|
|
20
22
|
import { RUN_FORMATTING_MARK_NAMES } from "../runFormattingMarkNames.js";
|
|
21
|
-
import { reconstructRejectedRunFormattingMarks } from "../runPropertyChangeResolution.js";
|
|
23
|
+
import { reconstructRejectedRunFormattingMarks, restoreHistoricalRunFormatting } from "../runPropertyChangeResolution.js";
|
|
22
24
|
import { paragraphRunStyleContext, paragraphRunStyleContextAt } from "../runStyleFormatting.js";
|
|
23
25
|
import { getTableCellMergeChange } from "../tableCellMergeRevision.js";
|
|
24
26
|
import { isTableCellRetainedInReviewView } from "../tableCellRevisionVisibility.js";
|
|
25
27
|
import { markRowEmptiedInBatch, reconcileTableGridAfterColumnRemoval, removeRowsWithoutCellsAfterBatch, removeTableRow } from "../tableGridMutation.js";
|
|
26
28
|
import { runInCellPending, runParagraphIntoTable } from "../tableRunIn.js";
|
|
29
|
+
import { retainedTrackedRevisionMark, trackedRevisionPathOf } from "../trackedRevisionPath.js";
|
|
27
30
|
import { holdsNoContent } from "../zeroWidthAnchors.js";
|
|
28
31
|
import { inlineBookmarksForParagraphJoin } from "./paragraphBookmarkJoin.js";
|
|
29
32
|
import { hasSerializableParagraphPropertyChange, paragraphPropertiesSnapshot } from "./propertyChangeScope.js";
|
|
@@ -32,10 +35,16 @@ import { resolveParagraphChangeAttrs } from "./resolveParagraphProperties.js";
|
|
|
32
35
|
import { hasMatchingCollapsedTableCellMerge, resolveCollapsedTableCellMerge, resolveVisibleTableCellMerge } from "./tableCellMergeResolution.js";
|
|
33
36
|
import { panic } from "better-result";
|
|
34
37
|
import { PARAGRAPH_MARK_CHANGE_KINDS, REVIEW_CARRIERS } from "@stll/docx-core/model";
|
|
38
|
+
import { Fragment } from "prosemirror-model";
|
|
35
39
|
import { TableMap } from "prosemirror-tables";
|
|
36
40
|
import { Mapping } from "prosemirror-transform";
|
|
37
41
|
//#region src/prosemirror/commands/comments.ts
|
|
38
42
|
/**
|
|
43
|
+
* Comment and Track Changes Commands
|
|
44
|
+
*
|
|
45
|
+
* PM commands for adding/removing comments and accepting/rejecting tracked changes.
|
|
46
|
+
*/
|
|
47
|
+
/**
|
|
39
48
|
* Add a comment mark to the current selection.
|
|
40
49
|
*/
|
|
41
50
|
function addCommentMark(commentId) {
|
|
@@ -67,21 +76,6 @@ function removeCommentMark(commentId) {
|
|
|
67
76
|
return true;
|
|
68
77
|
};
|
|
69
78
|
}
|
|
70
|
-
const revisionLayerOf = (mark) => {
|
|
71
|
-
const attrs = expectTrackedChangeMarkAttrs(mark);
|
|
72
|
-
let type;
|
|
73
|
-
if (mark.type.name === "insertion") type = attrs.moveKind === "moveTo" ? "moveTo" : "insertion";
|
|
74
|
-
else type = attrs.moveKind === "moveFrom" ? "moveFrom" : "deletion";
|
|
75
|
-
return {
|
|
76
|
-
type,
|
|
77
|
-
revisionId: attrs.revisionId,
|
|
78
|
-
author: attrs.author,
|
|
79
|
-
...attrs.date ? { date: attrs.date } : {},
|
|
80
|
-
...attrs.utcDate ? { utcDate: attrs.utcDate } : {},
|
|
81
|
-
...attrs.initials ? { initials: attrs.initials } : {},
|
|
82
|
-
outerWrapperCount: attrs._docxOuterWrapperCount ?? 0
|
|
83
|
-
};
|
|
84
|
-
};
|
|
85
79
|
const revisionLayerRemovesContent = (layer, mode) => mode === "accept" ? layer.type === "deletion" || layer.type === "moveFrom" : layer.type === "insertion" || layer.type === "moveTo";
|
|
86
80
|
/**
|
|
87
81
|
* Resolve a tracked change: accept or reject.
|
|
@@ -189,6 +183,19 @@ function resolveChange(from, to, mode, revisionIds) {
|
|
|
189
183
|
const runPropertyChangeMark = node.marks.find((mark) => mark.type.name === "runPropertyChange");
|
|
190
184
|
const removesNode = removeType !== void 0 && node.marks.some((mark) => mark.type === removeType && matchesRevision(mark));
|
|
191
185
|
if (removesNode || runPropertyChangeMark !== void 0 || node.marks.some((mark) => (mark.type === insertionType || mark.type === deletionType) && matchesRevision(mark))) resolvedBoundaries.push(rangeFrom, rangeTo);
|
|
186
|
+
if (mode === "reject" && node.marks.find((mark) => mark.type === keepType && matchesRevision(mark) && expectTrackedChangeMarkAttrs(mark)._historicalFormatting && !expectTrackedChangeMarkAttrs(mark)._docxRevisionAncestors?.some((layer) => (layer.type === "deletion" || layer.type === "moveFrom") && revisionSet !== null && !revisionSet.has(layer.revisionId))) && !removesNode) {
|
|
187
|
+
const nextMarks = restoreHistoricalRunFormatting({
|
|
188
|
+
node,
|
|
189
|
+
paragraphContext: paragraphRunStyleContextAt({
|
|
190
|
+
doc: tr.doc,
|
|
191
|
+
pos: rangeFrom,
|
|
192
|
+
styleResolver
|
|
193
|
+
}),
|
|
194
|
+
styleResolver
|
|
195
|
+
});
|
|
196
|
+
for (const mark of node.marks) if (RUN_FORMATTING_MARK_NAMES.has(mark.type.name)) tr.removeMark(rangeFrom, rangeTo, mark);
|
|
197
|
+
for (const mark of nextMarks) if (RUN_FORMATTING_MARK_NAMES.has(mark.type.name)) tr.addMark(rangeFrom, rangeTo, mark);
|
|
198
|
+
}
|
|
192
199
|
if (runPropertyChangeMark) resolveRunPropertyChange({
|
|
193
200
|
tr,
|
|
194
201
|
node,
|
|
@@ -201,7 +208,7 @@ function resolveChange(from, to, mode, revisionIds) {
|
|
|
201
208
|
});
|
|
202
209
|
const nestedMark = node.marks.find((mark) => (mark.type === insertionType || mark.type === deletionType) && (expectTrackedChangeMarkAttrs(mark)._docxRevisionAncestors?.length ?? 0) > 0);
|
|
203
210
|
if (nestedMark) {
|
|
204
|
-
const path =
|
|
211
|
+
const path = trackedRevisionPathOf(nestedMark);
|
|
205
212
|
const selected = (layer) => revisionSet === null || revisionSet.has(layer.revisionId);
|
|
206
213
|
if (path.some(selected)) if (path.some((layer) => selected(layer) && revisionLayerRemovesContent(layer, mode))) deleteRanges.push({
|
|
207
214
|
from: rangeFrom,
|
|
@@ -209,23 +216,13 @@ function resolveChange(from, to, mode, revisionIds) {
|
|
|
209
216
|
});
|
|
210
217
|
else {
|
|
211
218
|
tr.removeMark(rangeFrom, rangeTo, nestedMark);
|
|
212
|
-
const
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
author: active.author,
|
|
220
|
-
date: active.date ?? null,
|
|
221
|
-
utcDate: active.utcDate ?? null,
|
|
222
|
-
initials: active.initials ?? null,
|
|
223
|
-
moveKind: active.type === "moveTo" || active.type === "moveFrom" ? active.type : null,
|
|
224
|
-
_historicalFormatting: active.type === "deletion" || active.type === "moveFrom" ? true : null,
|
|
225
|
-
_docxOuterWrapperCount: active.outerWrapperCount,
|
|
226
|
-
_docxRevisionAncestors: remaining.length > 1 ? remaining.slice(0, -1) : null
|
|
227
|
-
}));
|
|
228
|
-
}
|
|
219
|
+
const retained = retainedTrackedRevisionMark(nestedMark, (layer) => !selected(layer));
|
|
220
|
+
if (retained) tr.addMark(rangeFrom, rangeTo, retained);
|
|
221
|
+
}
|
|
222
|
+
const current = tr.doc.nodeAt(pos);
|
|
223
|
+
if (current) {
|
|
224
|
+
const attrs = resolvedPreservedXmlAttrs(node, current.marks);
|
|
225
|
+
if (attrs !== node.attrs) tr.setNodeMarkup(pos, void 0, attrs);
|
|
229
226
|
}
|
|
230
227
|
return true;
|
|
231
228
|
}
|
|
@@ -233,6 +230,10 @@ function resolveChange(from, to, mode, revisionIds) {
|
|
|
233
230
|
from: rangeFrom,
|
|
234
231
|
to: rangeTo
|
|
235
232
|
});
|
|
233
|
+
if (!removesNode && keepType && node.marks.some((mark) => mark.type === keepType && matchesRevision(mark))) {
|
|
234
|
+
const attrs = resolvedPreservedXmlAttrs(node, node.marks.filter((mark) => !(mark.type === keepType && matchesRevision(mark))));
|
|
235
|
+
if (attrs !== node.attrs) tr.setNodeMarkup(pos, void 0, attrs);
|
|
236
|
+
}
|
|
236
237
|
if (!removeKeptMarksInBulk) {
|
|
237
238
|
for (const mark of node.marks) if (keepType && mark.type === keepType && matchesRevision(mark)) tr.removeMark(rangeFrom, rangeTo, mark);
|
|
238
239
|
}
|
|
@@ -255,7 +256,17 @@ function resolveChange(from, to, mode, revisionIds) {
|
|
|
255
256
|
}
|
|
256
257
|
rangesToDelete = coalescedDeleteRanges;
|
|
257
258
|
}
|
|
258
|
-
for (const range of rangesToDelete.toReversed())
|
|
259
|
+
for (const range of rangesToDelete.toReversed()) {
|
|
260
|
+
const start = tr.doc.resolve(range.from);
|
|
261
|
+
const field = start.parent;
|
|
262
|
+
if (field.type.name === "structuredField" && start.parentOffset === 0 && range.to === start.end()) {
|
|
263
|
+
const position = start.before();
|
|
264
|
+
const empty = canonicalFieldNode(field.copy(Fragment.empty));
|
|
265
|
+
tr.replaceWith(position, position + field.nodeSize, empty);
|
|
266
|
+
continue;
|
|
267
|
+
}
|
|
268
|
+
tr.delete(range.from, range.to);
|
|
269
|
+
}
|
|
259
270
|
if (deleteTextBoxesAnchoredAt(tr, droppedTextBoxAnchorIds(state.doc, tr.doc))) markStructuralChange(tr);
|
|
260
271
|
tableRowStructuralOps.sort((left, right) => right.rowPos - left.rowPos);
|
|
261
272
|
let resolvedTableRowStructure = false;
|
|
@@ -418,6 +429,20 @@ function resolveChange(from, to, mode, revisionIds) {
|
|
|
418
429
|
boundaries: resolvedBoundaries.map((position) => tr.mapping.map(position)).filter((position) => !seams.has(position)),
|
|
419
430
|
styleResolver
|
|
420
431
|
});
|
|
432
|
+
const resolvedFields = [];
|
|
433
|
+
tr.doc.descendants((node, position) => {
|
|
434
|
+
const canonical = canonicalFieldNode(node);
|
|
435
|
+
if (canonical !== node) resolvedFields.push({
|
|
436
|
+
node: canonical,
|
|
437
|
+
position
|
|
438
|
+
});
|
|
439
|
+
});
|
|
440
|
+
for (const { node, position } of resolvedFields.toReversed()) {
|
|
441
|
+
const field = tr.doc.nodeAt(position);
|
|
442
|
+
if (!field) continue;
|
|
443
|
+
if (field.type === node.type) tr.setNodeMarkup(position, void 0, node.attrs, node.marks);
|
|
444
|
+
else tr.replaceWith(position, position + field.nodeSize, node);
|
|
445
|
+
}
|
|
421
446
|
if (tr.steps.length > 0) dispatch(tr);
|
|
422
447
|
}
|
|
423
448
|
return true;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { withCanonicalCommand } from "../canonicalCommands.js";
|
|
2
|
+
import { canonicalSelectionRange } from "../canonicalSelectionRange.js";
|
|
2
3
|
import { pageBreakRunParagraphProjectionDisposition } from "../pageBreakRunProjection.js";
|
|
3
4
|
//#region src/prosemirror/commands/pageBreak.ts
|
|
4
5
|
const UNSUPPORTED_PAGE_BREAK_RUN_ANCESTORS = /* @__PURE__ */ new Set([
|
|
@@ -46,8 +47,7 @@ const insertPageBreakCommand = (state, dispatch) => {
|
|
|
46
47
|
*/
|
|
47
48
|
const insertPageBreak = withCanonicalCommand(insertPageBreakCommand, (state) => insertPageBreakCommand(state) ? [{
|
|
48
49
|
type: "insertBreak",
|
|
49
|
-
|
|
50
|
-
to: state.selection.to,
|
|
50
|
+
...canonicalSelectionRange(state),
|
|
51
51
|
breakType: "page"
|
|
52
52
|
}] : []);
|
|
53
53
|
//#endregion
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { dispatchClipboardIntent } from "../clipboardIntent.js";
|
|
1
2
|
import { Fragment, Slice } from "prosemirror-model";
|
|
2
3
|
//#region src/prosemirror/commands/pastePlainText.ts
|
|
3
4
|
/**
|
|
@@ -54,7 +55,7 @@ const pasteWithoutFormatting = (state, dispatch, view) => {
|
|
|
54
55
|
navigator.clipboard.readText().then((text) => {
|
|
55
56
|
if (!text || view.isDestroyed) return;
|
|
56
57
|
const slice = buildPlainTextSlice(text, schema);
|
|
57
|
-
view.dispatch(view.state.tr.replaceSelection(slice).scrollIntoView());
|
|
58
|
+
if (dispatchClipboardIntent(view, slice) === void 0) view.dispatch(view.state.tr.replaceSelection(slice).scrollIntoView());
|
|
58
59
|
}).catch((error) => {
|
|
59
60
|
if (typeof CustomEvent === "function" && !view.isDestroyed) view.dom.dispatchEvent(new CustomEvent(CLIPBOARD_READ_ERROR_EVENT, {
|
|
60
61
|
detail: { error },
|
|
@@ -4,6 +4,7 @@ import { readParagraphNumberingAttr } from "../numberingAttr.js";
|
|
|
4
4
|
import { directParagraphAlignment } from "../paragraphAlignment.js";
|
|
5
5
|
import { directionFromBidi } from "../paragraphDirection.js";
|
|
6
6
|
import { PARAGRAPH_FORMATTING_WRITE_BACK, STYLE_RESOLVED_PARAGRAPH_FIELDS } from "../paragraphFormattingProvenance.js";
|
|
7
|
+
import { directParagraphIndentation } from "../paragraphIndentation.js";
|
|
7
8
|
import { directParagraphSpacing, paragraphSpacingAttrPatch, paragraphSpacingFromFormatting } from "../paragraphSpacing.js";
|
|
8
9
|
import { sameFormattingValue } from "../runFormattingFromMarks.js";
|
|
9
10
|
//#region src/prosemirror/commands/propertyChangeScope.ts
|
|
@@ -127,18 +128,14 @@ const paragraphPropertiesSnapshot = (node) => {
|
|
|
127
128
|
const attrs = expectParagraphAttrs(node);
|
|
128
129
|
const snapshot = {};
|
|
129
130
|
for (const key of PPR_CHANGE_SCOPED_ATTR_KEYS) {
|
|
130
|
-
if (key === "alignment" || PPR_SPACING_ATTR_KEYS.has(key) || key === "numPr" && isStyleSourcedParagraphNumbering(attrs.numPr, attrs.numPrFromStyle)) continue;
|
|
131
|
+
if (key === "alignment" || key === "indentLeft" || key === "indentRight" || key === "indentFirstLine" || key === "hangingIndent" || PPR_SPACING_ATTR_KEYS.has(key) || key === "numPr" && isStyleSourcedParagraphNumbering(attrs.numPr, attrs.numPrFromStyle)) continue;
|
|
131
132
|
if (styleSuppliedParagraphValue(attrs, key)) continue;
|
|
132
|
-
if (key === "hangingIndent" && styleSuppliedParagraphValue(attrs, "indentFirstLine")) continue;
|
|
133
|
-
if (styleSuppliedParagraphValue(attrs, key)) continue;
|
|
134
|
-
if (key === "hangingIndent" && styleSuppliedParagraphValue(attrs, "indentFirstLine")) continue;
|
|
135
133
|
const value = attrs[key];
|
|
136
|
-
if (key === "hangingIndent" && value === false && attrs._originalFormatting?.hangingIndent === void 0) continue;
|
|
137
134
|
if (value !== null && value !== void 0) snapshot[key] = value;
|
|
138
135
|
}
|
|
139
136
|
const directAlignment = directParagraphAlignment(attrs);
|
|
140
137
|
if (directAlignment !== void 0) snapshot["alignment"] = directAlignment;
|
|
141
|
-
Object.assign(snapshot, directParagraphSpacing(attrs));
|
|
138
|
+
Object.assign(snapshot, directParagraphSpacing(attrs), directParagraphIndentation(attrs));
|
|
142
139
|
return snapshot;
|
|
143
140
|
};
|
|
144
141
|
/**
|
|
@@ -2,8 +2,9 @@ import { resolveParagraphNumbering } from "../../docx/numberingReference.js";
|
|
|
2
2
|
import { expectParagraphAttrs } from "../attrs/index.js";
|
|
3
3
|
import { rejectedListRenderingPatch } from "../listRendering.js";
|
|
4
4
|
import { paragraphNumberingAttr } from "../numberingAttr.js";
|
|
5
|
-
import {
|
|
5
|
+
import { paragraphIndentationFromFormatting } from "../paragraphIndentation.js";
|
|
6
6
|
import { resolveParagraphDefaultTextFormatting } from "../styles/paragraphStyleCascade.js";
|
|
7
|
+
import { listIndentationProvenancePatch } from "../styles/resolvedStyleAttrs.js";
|
|
7
8
|
import { paragraphRejectAttrPatch, paragraphRejectOriginalFormatting, removeParagraphPropertyChanges, sectionRejectProperties } from "./propertyChangeScope.js";
|
|
8
9
|
//#region src/prosemirror/commands/resolveParagraphProperties.ts
|
|
9
10
|
/** Resolve paragraph and section property records before resolving their inline content. */
|
|
@@ -27,24 +28,32 @@ const resolveParagraphChangeAttrs = ({ node, boundaryCovered, mode, revisionSet,
|
|
|
27
28
|
const inheritedAlignment = currentAttrs.alignmentFromStyle;
|
|
28
29
|
const restoredStyleId = rejection.previousFormatting?.styleId ?? void 0;
|
|
29
30
|
const sameStyle = restoredStyleId === (currentAttrs.styleId ?? void 0);
|
|
30
|
-
let previousFormattingFromStyle;
|
|
31
|
-
|
|
32
|
-
if (
|
|
33
|
-
previousFormattingFromStyle = styleResolver.resolveParagraphStyle(restoredStyleId).paragraphFormatting;
|
|
34
|
-
if (!sameStyle) {
|
|
35
|
-
resolvedFromStyle = styleResolvedParagraphFormatting(previousFormattingFromStyle);
|
|
36
|
-
nextAttrs["_resolvedFormatting"] = resolvedFromStyle;
|
|
37
|
-
}
|
|
38
|
-
} else if (inheritedAlignment !== void 0) previousFormattingFromStyle = { alignment: inheritedAlignment };
|
|
39
|
-
const inheritedFormatting = previousFormattingFromStyle === void 0 && resolvedFromStyle === void 0 ? void 0 : {
|
|
31
|
+
let previousFormattingFromStyle = sameStyle ? currentAttrs._styleResolvedFormatting : void 0;
|
|
32
|
+
if (styleResolver) previousFormattingFromStyle = styleResolver.resolveParagraphStyle(restoredStyleId).paragraphFormatting;
|
|
33
|
+
else if (inheritedAlignment !== void 0) previousFormattingFromStyle = {
|
|
40
34
|
...previousFormattingFromStyle,
|
|
41
|
-
|
|
35
|
+
alignment: inheritedAlignment
|
|
42
36
|
};
|
|
43
37
|
let styleNumbering = previousFormattingFromStyle?.numPr;
|
|
44
38
|
if (!styleResolver && sameStyle) styleNumbering = currentAttrs.numPrFromStyle ?? void 0;
|
|
45
39
|
const inheritedNumbering = styleNumbering == null ? null : paragraphNumberingAttr(resolveParagraphNumbering(styleNumbering));
|
|
46
40
|
const recordedNumbering = rejection.previousFormatting?.numPr;
|
|
47
41
|
const restoredNumbering = recordedNumbering ?? inheritedNumbering;
|
|
42
|
+
const restoredFormatting = paragraphRejectOriginalFormatting(rejection.previousFormatting, node.attrs["_originalFormatting"]);
|
|
43
|
+
const indentation = listIndentationProvenancePatch({
|
|
44
|
+
direct: paragraphIndentationFromFormatting(restoredFormatting ?? void 0),
|
|
45
|
+
styleFormatting: previousFormattingFromStyle,
|
|
46
|
+
numberingSource: recordedNumbering == null ? "style" : "paragraph",
|
|
47
|
+
numPr: restoredNumbering?.kind === "reference" ? {
|
|
48
|
+
numId: restoredNumbering.numId,
|
|
49
|
+
ilvl: restoredNumbering.ilvl ?? 0
|
|
50
|
+
} : void 0,
|
|
51
|
+
numbering
|
|
52
|
+
});
|
|
53
|
+
const inheritedFormatting = {
|
|
54
|
+
...previousFormattingFromStyle,
|
|
55
|
+
...indentation._resolvedFormatting
|
|
56
|
+
};
|
|
48
57
|
Object.assign(nextAttrs, paragraphRejectAttrPatch(rejection.previousFormatting, inheritedFormatting), rejectedListRenderingPatch({
|
|
49
58
|
current: expectParagraphAttrs(node),
|
|
50
59
|
previousFormatting: rejection.previousFormatting,
|
|
@@ -54,7 +63,7 @@ const resolveParagraphChangeAttrs = ({ node, boundaryCovered, mode, revisionSet,
|
|
|
54
63
|
numPr: restoredNumbering,
|
|
55
64
|
numPrFromStyle: recordedNumbering == null ? inheritedNumbering : null
|
|
56
65
|
});
|
|
57
|
-
|
|
66
|
+
Object.assign(nextAttrs, indentation);
|
|
58
67
|
nextAttrs["_originalFormatting"] = restoredFormatting;
|
|
59
68
|
if (styleResolver) nextAttrs["defaultTextFormatting"] = resolveParagraphDefaultTextFormatting(rejection.previousFormatting?.styleId, restoredFormatting ?? void 0, styleResolver) ?? null;
|
|
60
69
|
}
|
|
@@ -1,6 +1,14 @@
|
|
|
1
|
+
import { addTrackedDeletionMark } from "./addTrackedDeletionMark.js";
|
|
1
2
|
import { findTextInPmParagraph } from "./paraText.js";
|
|
2
3
|
import { findParagraphByParaId } from "./utils/findParagraphByParaId.js";
|
|
3
4
|
//#region src/prosemirror/commentOps.ts
|
|
5
|
+
/**
|
|
6
|
+
* Comment + tracked-change (proposeChange) PM transaction builders shared by
|
|
7
|
+
* the React and Vue adapters. They locate the target range, apply the mark(s),
|
|
8
|
+
* dispatch, and return a result. ID allocation lives in `commentIdAllocator.ts`
|
|
9
|
+
* and is injected. Adapter-specific state mutation, event emission, and sidebar
|
|
10
|
+
* UI stay in each adapter.
|
|
11
|
+
*/
|
|
4
12
|
/** Build a Comment object with a freshly-allocated ID. */
|
|
5
13
|
function createComment(allocator, text, authorName, parentId) {
|
|
6
14
|
return {
|
|
@@ -95,7 +103,13 @@ function applyProposedChange(view, options, allocator) {
|
|
|
95
103
|
date
|
|
96
104
|
});
|
|
97
105
|
let tr = view.state.tr;
|
|
98
|
-
if (!isInsertion)
|
|
106
|
+
if (!isInsertion) addTrackedDeletionMark({
|
|
107
|
+
insertionPolicy: "preserve-pending",
|
|
108
|
+
tr,
|
|
109
|
+
from: textFrom,
|
|
110
|
+
to: textTo,
|
|
111
|
+
mark: deletionMark
|
|
112
|
+
});
|
|
99
113
|
if (!isDeletion) tr = tr.insert(textTo, schema.text(options.replaceWith, [insertionMark]));
|
|
100
114
|
view.dispatch(tr);
|
|
101
115
|
return true;
|
|
@@ -4,7 +4,7 @@ import { normalizeFoldedListNumbers } from "../../docx/foldedListNumberFields.js
|
|
|
4
4
|
import { EDITED_PREVIEW_FINGERPRINT, imageRawXmlFingerprint } from "../../docx/imageRawXml.js";
|
|
5
5
|
import { isInlineSdtContent, isSimpleFieldContent } from "../../docx/inlineWrapperContent.js";
|
|
6
6
|
import { paragraphNumberingReferenceId as paragraphNumberingReferenceId$1, sameStatedParagraphNumbering as sameStatedParagraphNumbering$1 } from "../../docx/numberingReference.js";
|
|
7
|
-
import { PROSE_PARAGRAPH_SOURCE_CONTRACT_ATTR, ParagraphPropertySourceValidationError, copyDocumentParagraphPropertySourceContract, copyDocumentParagraphPropertySources, copyParagraphPropertyCapture, copyParagraphPropertySource, decodeTableCellParagraphSourcePayload, getDocumentParagraphPropertySourceContract, getParagraphPropertySource, getParagraphPropertySourceCandidate, getParagraphPropertySourceToken, getParagraphPropertySourceTransferId, getProseDocumentParagraphPropertySourceContract, getProseParagraphPropertySourceToken, inspectParagraphSourceIdentity, isParagraphPropertySourceToken, linkParagraphPropertySourceCandidate, paragraphPropertySourceTokenMatchesContract, recreateProseNodeWithParagraphPropertySource, restoreTableCellsWithParagraphPropertySources, visitDocumentStoryParagraphs, visitTableCellParagraphPropertySourceBindings } from "../../docx/paragraphPropertySource.js";
|
|
7
|
+
import { PROSE_PARAGRAPH_SOURCE_CONTRACT_ATTR, ParagraphPropertySourceValidationError, assignParagraphIndentationProjection, copyDocumentParagraphPropertySourceContract, copyDocumentParagraphPropertySources, copyParagraphPropertyCapture, copyParagraphPropertySource, decodeTableCellParagraphSourcePayload, getDocumentParagraphPropertySourceContract, getParagraphPropertySource, getParagraphPropertySourceCandidate, getParagraphPropertySourceToken, getParagraphPropertySourceTransferId, getProseDocumentParagraphPropertySourceContract, getProseParagraphPropertySourceToken, inspectParagraphSourceIdentity, isParagraphPropertySourceToken, linkParagraphPropertySourceCandidate, paragraphFormattingWithAuthoredIndentation, paragraphPropertySourceTokenMatchesContract, recreateProseNodeWithParagraphPropertySource, restoreTableCellsWithParagraphPropertySources, visitDocumentStoryParagraphs, visitTableCellParagraphPropertySourceBindings } from "../../docx/paragraphPropertySource.js";
|
|
8
8
|
import { BLOCK_TREE_DESCENT, visitBlockTreeRecords, visitDocxParagraphs } from "../../docx/paragraphTraversal.js";
|
|
9
9
|
import { refingerprintShapeAlternateContent } from "../../docx/shapeAlternateContent.js";
|
|
10
10
|
import { DATE_UTC_ATTRIBUTE } from "../../docx/trackedChangeInfo.js";
|
|
@@ -33,9 +33,11 @@ import { inlineWrapperMember, inlineWrapperStackKey } from "../inlineWrapperStac
|
|
|
33
33
|
import { completeNumberingForDoc } from "../listInstanceReferences.js";
|
|
34
34
|
import { hasListRendering, listRenderingFromAttrs as listRenderingFromAttrs$1 } from "../listRenderingAttrs.js";
|
|
35
35
|
import { expectMoveRangeBoundaryAttrs } from "../moveRangeBoundaryAttrs.js";
|
|
36
|
+
import { assertNoteReferenceOccurrences, coalesceNoteReferenceOccurrences } from "../noteReferenceOccurrences.js";
|
|
36
37
|
import { resolveNumberedRefFields } from "../numberedRefFields.js";
|
|
37
38
|
import { directParagraphAlignment } from "../paragraphAlignment.js";
|
|
38
39
|
import { directionToAuthoredBidi } from "../paragraphDirection.js";
|
|
40
|
+
import { paragraphIndentationFromFormatting } from "../paragraphIndentation.js";
|
|
39
41
|
import { directParagraphSpacing } from "../paragraphSpacing.js";
|
|
40
42
|
import { expectRangeAnchorAttrs } from "../rangeAnchorAttrs.js";
|
|
41
43
|
import { marksToTextFormatting, sameFormattingValue } from "../runFormattingFromMarks.js";
|
|
@@ -161,6 +163,13 @@ const restoreParagraphPropertySource = (paragraph, baseParagraph) => {
|
|
|
161
163
|
copyParagraphPropertySource(paragraph, baseParagraph);
|
|
162
164
|
const baseFormatting = baseParagraph.formatting;
|
|
163
165
|
if (!baseFormatting) return;
|
|
166
|
+
if (baseFormatting.indentLeft !== void 0 || baseFormatting.indentRight !== void 0 || baseFormatting.indentFirstLine !== void 0 || baseFormatting.hangingIndent !== void 0) {
|
|
167
|
+
const authored = paragraphFormattingWithAuthoredIndentation(baseParagraph);
|
|
168
|
+
if ((authored?.indentLeft !== baseFormatting.indentLeft || authored?.indentRight !== baseFormatting.indentRight || authored?.indentFirstLine !== baseFormatting.indentFirstLine || authored?.hangingIndent !== baseFormatting.hangingIndent) && canonicalJson(modelParagraphFormattingEmission(paragraph.formatting)) === canonicalJson(modelParagraphFormattingEmission(authored))) {
|
|
169
|
+
paragraph.formatting = { ...baseFormatting };
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
164
173
|
const { numPr, numPrFromStyle } = baseFormatting;
|
|
165
174
|
if (!numPr || !numPrFromStyle || !isStyleSourcedParagraphNumbering(numPr, numPrFromStyle)) return;
|
|
166
175
|
if (canonicalJson(modelParagraphFormattingEmission(paragraph.formatting)) !== canonicalJson(modelParagraphFormattingEmission(baseFormatting))) return;
|
|
@@ -263,6 +272,7 @@ const restoreLinkedParagraphPropertySources = (content) => {
|
|
|
263
272
|
};
|
|
264
273
|
/** Convert a ProseMirror document to the document model. */
|
|
265
274
|
function fromProseDoc(pmDoc, baseDocument, { reuse = "none" } = {}) {
|
|
275
|
+
assertNoteReferenceOccurrences(pmDoc);
|
|
266
276
|
switch (reuse) {
|
|
267
277
|
case "none": break;
|
|
268
278
|
case "matched": panic("fromProseDoc: reuse \"matched\" is not implemented");
|
|
@@ -970,6 +980,14 @@ function convertPMParagraph(node, documentCounts, textBoxAnchorMarkers, styleRes
|
|
|
970
980
|
if (attrs.reviewCarrier) paragraph.reviewCarrier = attrs.reviewCarrier;
|
|
971
981
|
const pFormatting = paragraphAttrsToFormatting(attrs);
|
|
972
982
|
if (pFormatting) paragraph.formatting = pFormatting;
|
|
983
|
+
if (attrs.numPr?.kind === "reference") {
|
|
984
|
+
const inheritedIndentation = paragraphIndentationFromFormatting(attrs._resolvedFormatting);
|
|
985
|
+
if (inheritedIndentation) assignParagraphIndentationProjection({
|
|
986
|
+
paragraph,
|
|
987
|
+
authored: pFormatting,
|
|
988
|
+
inherited: inheritedIndentation
|
|
989
|
+
});
|
|
990
|
+
}
|
|
973
991
|
const listRendering = listRenderingFromAttrs(attrs);
|
|
974
992
|
if (listRendering) paragraph.listRendering = listRendering;
|
|
975
993
|
normalizeFoldedListNumbers(paragraph);
|
|
@@ -1373,7 +1391,8 @@ const nestInlineWrapperGroups = (items, groups, hyperlinkIndices, revisionOuterW
|
|
|
1373
1391
|
}
|
|
1374
1392
|
return coalesced;
|
|
1375
1393
|
};
|
|
1376
|
-
function extractParagraphContent(
|
|
1394
|
+
function extractParagraphContent(originalParagraph, _documentCounts, emptyHyperlinks, textBoxAnchorMarkers, skipLeadingRenderedPageBreak = false, inheritedFormattingOverride) {
|
|
1395
|
+
const paragraph = coalesceNoteReferenceOccurrences(originalParagraph);
|
|
1377
1396
|
const content = [];
|
|
1378
1397
|
const paragraphStyleContext = paragraph.type.name === "paragraph" ? paragraphRunStyleContext(paragraph) : void 0;
|
|
1379
1398
|
const formattingContext = inheritedFormattingOverride ?? {
|
|
@@ -2463,7 +2482,7 @@ const synchronizeFieldDisplayText = (content, displayText, fallbackRun) => {
|
|
|
2463
2482
|
visit(child);
|
|
2464
2483
|
continue;
|
|
2465
2484
|
}
|
|
2466
|
-
if (child.type === "hyperlink" || child.type === "inlineWrapper") visitRunsIn(child.type === "hyperlink" ? child.children : child.content, visit);
|
|
2485
|
+
if (child.type === "hyperlink" || child.type === "inlineWrapper" || child.type === "insertion" || child.type === "deletion" || child.type === "moveFrom" || child.type === "moveTo") visitRunsIn(child.type === "hyperlink" ? child.children : child.content, visit);
|
|
2467
2486
|
}
|
|
2468
2487
|
};
|
|
2469
2488
|
const visitRuns = (visit) => {
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
//#region src/prosemirror/conversion/hyphenTextCarriers.d.ts
|
|
2
|
+
/** These source units render as native text while keeping one logical atom each. */
|
|
3
|
+
declare const HYPHEN_TEXT_CARRIERS: {
|
|
4
|
+
readonly softHyphen: "";
|
|
5
|
+
readonly noBreakHyphen: "‑";
|
|
6
|
+
};
|
|
7
|
+
//#endregion
|
|
8
|
+
export { HYPHEN_TEXT_CARRIERS };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
//#region src/prosemirror/conversion/hyphenTextCarriers.ts
|
|
2
|
+
/** These source units render as native text while keeping one logical atom each. */
|
|
3
|
+
const HYPHEN_TEXT_CARRIERS = {
|
|
4
|
+
softHyphen: "",
|
|
5
|
+
noBreakHyphen: "‑"
|
|
6
|
+
};
|
|
7
|
+
//#endregion
|
|
8
|
+
export { HYPHEN_TEXT_CARRIERS };
|
|
@@ -18,6 +18,12 @@ type ToProseDocOptions = {
|
|
|
18
18
|
*/
|
|
19
19
|
warn?: ParseContext["warn"];
|
|
20
20
|
};
|
|
21
|
+
/**
|
|
22
|
+
* Find bookmark pairs across every editable inline wrapper in a document story.
|
|
23
|
+
* Each endpoint is converted at its own structural position, so a range may
|
|
24
|
+
* start outside a hyperlink and end inside it (or the inverse).
|
|
25
|
+
*/
|
|
26
|
+
declare const collectPairedBookmarkIds: (blocks: readonly document_d_exports.BlockContent[]) => ReadonlySet<number>;
|
|
21
27
|
/**
|
|
22
28
|
* Convert a Document to a ProseMirror document
|
|
23
29
|
*
|
|
@@ -40,4 +46,4 @@ declare function footnoteToProseDoc(content: document_d_exports.BlockContent[],
|
|
|
40
46
|
*/
|
|
41
47
|
declare function createEmptyDoc(): Node;
|
|
42
48
|
//#endregion
|
|
43
|
-
export { ToProseDocOptions, createEmptyDoc, footnoteToProseDoc, headerFooterToProseDoc, standaloneTableCellToProseMirror, toProseDoc };
|
|
49
|
+
export { ToProseDocOptions, collectPairedBookmarkIds, createEmptyDoc, footnoteToProseDoc, headerFooterToProseDoc, standaloneTableCellToProseMirror, toProseDoc };
|