@stll/folio-core 0.60.0 → 0.62.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -0
- package/dist/ai-edits/apply.js +139 -32
- package/dist/ai-edits/headless.d.ts +3 -0
- package/dist/ai-edits/headless.js +70 -75
- package/dist/ai-edits/note-story-inventory.d.ts +7 -0
- package/dist/ai-edits/note-story-inventory.js +11 -0
- package/dist/ai-edits/read.js +16 -9
- package/dist/ai-edits/revisionStretches.js +52 -1
- package/dist/ai-edits/table-row-column-mutations.js +6 -1
- package/dist/compare/reproducible-package.js +2 -1
- package/dist/compare/verification.js +1 -0
- package/dist/compat/eigenpal.d.ts +3 -1
- package/dist/controller/canonicalClipboard.js +2 -1
- package/dist/controller/canonicalListRendering.d.ts +4 -6
- package/dist/controller/canonicalListRendering.js +3 -157
- package/dist/controller/headerFooterEditorManager.d.ts +1 -0
- package/dist/controller/headerFooterEditorManager.js +11 -0
- package/dist/controller/hiddenEditorManager.d.ts +1 -1
- package/dist/controller/hiddenEditorManager.js +3 -1
- package/dist/controller/layoutPipeline.d.ts +3 -1
- package/dist/controller/layoutPipeline.js +13 -4
- package/dist/controller/layoutSession.d.ts +2 -1
- package/dist/controller/noteEditorManager.d.ts +1 -1
- package/dist/display-list/build/imagePrimitives.js +28 -12
- package/dist/display-list/build/paragraphPrimitives.js +15 -2
- package/dist/display-list/dom/renderDisplayListToDom.js +8 -5
- package/dist/display-list/types.d.ts +7 -3
- package/dist/docx/canonicalStoryRepack.js +3 -2
- package/dist/docx/commentTextParagraph.d.ts +6 -0
- package/dist/docx/commentTextParagraph.js +15 -0
- package/dist/docx/conformance.js +6 -1
- package/dist/docx/diagramPreview.js +2 -1
- package/dist/docx/documentParser.d.ts +13 -1
- package/dist/docx/documentParser.js +1 -1
- package/dist/docx/encryption/compoundFile.d.ts +0 -8
- package/dist/docx/encryption/compoundFile.js +2 -1
- package/dist/docx/encryption/cryptoBytes.d.ts +2 -2
- package/dist/docx/encryption/cryptoBytes.js +3 -18
- package/dist/docx/encryption/encryptionInfo.d.ts +0 -5
- package/dist/docx/encryption/encryptionInfo.js +2 -1
- package/dist/docx/ensureParaIds.js +2 -1
- package/dist/docx/groupDrawingParser.js +28 -13
- package/dist/docx/listModelNormalization.d.ts +10 -0
- package/dist/docx/listModelNormalization.js +166 -0
- package/dist/docx/metadataPrivacy.js +3 -2
- package/dist/docx/metafileRaster.js +2 -1
- package/dist/docx/packageParts.js +6 -5
- package/dist/docx/paragraphParser.js +6 -4
- package/dist/docx/parser.js +5 -4
- package/dist/docx/preservedRunContent.js +11 -2
- package/dist/docx/removeHeaderFooterParts.js +8 -7
- package/dist/docx/replyToComment.js +3 -13
- package/dist/docx/rezip.js +88 -89
- package/dist/docx/runParser.js +12 -6
- package/dist/docx/runPropertyPresence.d.ts +11 -0
- package/dist/docx/runPropertyPresence.js +14 -0
- package/dist/docx/selectiveSave.js +15 -14
- package/dist/docx/serializer/runSerializer.js +3 -2
- package/dist/docx/serializer/tableSerializer.js +2 -1
- package/dist/docx/server/applyDocxXmlPatchProposal.js +2 -2
- package/dist/docx/server/boundedArchive.js +2 -1
- package/dist/docx/server/evaluateDocxXmlPatchProposal.js +2 -1
- package/dist/docx/server/inspectDocxPackage.js +5 -1
- package/dist/docx/server/validateDocxConformance.js +2 -1
- package/dist/docx/tableParser.js +7 -4
- package/dist/docx/tableRowPropertyPresence.d.ts +9 -0
- package/dist/docx/tableRowPropertyPresence.js +15 -0
- package/dist/docx/unzip.js +2 -1
- package/dist/docx/xmlEncoding.js +6 -5
- package/dist/fonts/fontsourceFaces.js +2 -1
- package/dist/fonts/sfnt/parse.js +6 -9
- package/dist/fonts/sfnt/subset.js +2 -1
- package/dist/fonts/sfnt/tables.js +2 -3
- package/dist/fonts/sfnt/woff.js +2 -1
- package/dist/i18n/messages/ar.gen.js +1 -0
- package/dist/i18n/messages/catalogs.gen.d.ts +17 -0
- package/dist/i18n/messages/catalogs.gen.js +17 -0
- package/dist/i18n/messages/cs.gen.js +1 -0
- package/dist/i18n/messages/de.gen.js +1 -0
- package/dist/i18n/messages/en.gen.js +1 -0
- package/dist/i18n/messages/es.gen.js +1 -0
- package/dist/i18n/messages/et.gen.js +1 -0
- package/dist/i18n/messages/fr.gen.js +1 -0
- package/dist/i18n/messages/he.gen.js +1 -0
- package/dist/i18n/messages/hi.gen.js +1 -0
- package/dist/i18n/messages/hu.gen.js +1 -0
- package/dist/i18n/messages/lt.gen.js +1 -0
- package/dist/i18n/messages/lv.gen.js +1 -0
- package/dist/i18n/messages/messages.gen.d.ts +1 -0
- package/dist/i18n/messages/pl.gen.js +1 -0
- package/dist/i18n/messages/pt-BR.gen.js +1 -0
- package/dist/i18n/messages/sk.gen.js +1 -0
- package/dist/i18n/messages/tr.gen.js +1 -0
- package/dist/i18n/messages/zh-CN.gen.js +1 -0
- package/dist/index.d.ts +3 -1
- package/dist/internal/revisionResolutionInline.d.ts +2 -1
- package/dist/internal/revisionResolutionInline.js +22 -1
- package/dist/internal/wholeStoryRevisionResolution.js +24 -7
- package/dist/layout-bridge/convert/endnoteLayout.d.ts +1 -1
- package/dist/layout-bridge/convert/endnoteLayout.js +1 -3
- package/dist/layout-bridge/convert/flowConversionShared.d.ts +2 -0
- package/dist/layout-bridge/convert/footnoteLayout.d.ts +4 -0
- package/dist/layout-bridge/convert/footnoteLayout.js +13 -3
- package/dist/layout-bridge/convert/headerFooterLayout.d.ts +5 -0
- package/dist/layout-bridge/convert/headerFooterLayout.js +12 -15
- package/dist/layout-bridge/convert/paragraphRuns.js +2 -1
- package/dist/layout-engine/index.js +2 -2
- package/dist/layout-engine/measure/crossRunWords.js +12 -2
- package/dist/layout-engine/noteAreaFlow.d.ts +4 -4
- package/dist/layout-engine/noteAreaFlow.js +12 -6
- package/dist/layout-engine/types.d.ts +5 -2
- package/dist/layout-painter/index.d.ts +1 -1
- package/dist/managers/AutoSaveManager.js +2 -1
- package/dist/managers/EditorModeManager.d.ts +10 -1
- package/dist/managers/EditorModeManager.js +15 -1
- package/dist/managers/FindReplaceManager.d.ts +13 -6
- package/dist/managers/FindReplaceManager.js +15 -9
- package/dist/managers/TableSelectionManager.d.ts +1 -1
- package/dist/managers/autoSaveCodec.js +2 -6
- package/dist/managers/reviewDisplayMode.d.ts +8 -0
- package/dist/managers/reviewDisplayMode.js +15 -0
- package/dist/paged-layout/editorScrollRoot.d.ts +3 -1
- package/dist/paged-layout/editorScrollRoot.js +2 -2
- package/dist/paged-layout/pageText.d.ts +11 -2
- package/dist/paged-layout/pageText.js +8 -3
- package/dist/pdf/fonts.js +5 -14
- package/dist/pdf/images.js +4 -2
- package/dist/pdf/objects.d.ts +0 -11
- package/dist/pdf/objects.js +7 -9
- package/dist/pdf/writePdf.js +2 -1
- package/dist/prosemirror/commands/comments.js +51 -13
- package/dist/prosemirror/commentRangeInlineAtoms.d.ts +40 -0
- package/dist/prosemirror/commentRangeInlineAtoms.js +33 -0
- package/dist/prosemirror/containerFinalParagraph.d.ts +8 -8
- package/dist/prosemirror/containerFinalParagraph.js +8 -8
- package/dist/prosemirror/conversion/fromProseDoc.js +14 -8
- package/dist/prosemirror/conversion/toProseDoc.js +16 -23
- package/dist/prosemirror/extensions/nodes/CommentReferenceExtension.js +16 -2
- package/dist/prosemirror/fieldRepresentation.js +4 -2
- package/dist/prosemirror/findReplaceSelection.d.ts +48 -2
- package/dist/prosemirror/findReplaceSelection.js +153 -38
- package/dist/prosemirror/inlineDisplayText.d.ts +10 -0
- package/dist/prosemirror/inlineDisplayText.js +29 -0
- package/dist/prosemirror/markupViewProjection.d.ts +10 -1
- package/dist/prosemirror/markupViewProjection.js +21 -3
- package/dist/prosemirror/plugins/transactionInvariants.js +6 -1
- package/dist/prosemirror/replacedAnnotations.d.ts +15 -1
- package/dist/prosemirror/replacedAnnotations.js +71 -12
- package/dist/prosemirror/runFormattingReconciliation.d.ts +3 -1
- package/dist/prosemirror/runFormattingReconciliation.js +10 -2
- package/dist/prosemirror/runIdentityAcrossRevisions.d.ts +5 -7
- package/dist/prosemirror/runIdentityAcrossRevisions.js +66 -38
- package/dist/prosemirror/runPropertyChangeResolution.js +13 -1
- package/dist/prosemirror/trackedRunInlineAtoms.d.ts +1 -1
- package/dist/prosemirror/trackedRunInlineAtoms.js +1 -1
- package/dist/utils/base64.d.ts +1 -31
- package/dist/utils/base64.js +19 -33
- package/dist/utils/clipboard.js +5 -4
- package/dist/utils/colorResolver.js +11 -2
- package/dist/utils/findMatchView.d.ts +32 -0
- package/dist/utils/findMatchView.js +406 -0
- package/dist/utils/findReplace.d.ts +67 -4
- package/dist/utils/findReplace.js +359 -37
- package/dist/utils/findSearchKey.d.ts +29 -0
- package/dist/utils/findSearchKey.js +34 -0
- package/dist/utils/replaceText.js +138 -94
- package/dist/utils/sliceText.d.ts +2 -0
- package/dist/utils/sliceText.js +2 -0
- package/dist/utils/textEncoding.d.ts +2 -0
- package/dist/utils/textEncoding.js +2 -0
- package/dist/utils/tiffConverter.d.ts +0 -9
- package/dist/utils/tiffConverter.js +2 -4
- package/package.json +51 -25
|
@@ -4,8 +4,11 @@ import { stageSectionBoundaryProperties } from "../compare/section-boundary-prop
|
|
|
4
4
|
import { importReferencedStyleDefinitions, styleClosureNumberingReferences } from "../compare/style-resources.js";
|
|
5
5
|
import { applyFolioDocumentOperations } from "../document-operations.js";
|
|
6
6
|
import { applyReplyThreadMarkers } from "../docx/commentReplyMarkers.js";
|
|
7
|
+
import { commentTextParagraph } from "../docx/commentTextParagraph.js";
|
|
8
|
+
import { buildSections } from "../docx/documentParser.js";
|
|
7
9
|
import { rebindDrawingImageRelationship } from "../docx/drawingRelationships.js";
|
|
8
10
|
import { isSeparatorEndnote, isSeparatorFootnote } from "../docx/footnoteParser.js";
|
|
11
|
+
import { normalizeListModelRendering } from "../docx/listModelNormalization.js";
|
|
9
12
|
import { createNumberingIdAllocator } from "../docx/numberingIds.js";
|
|
10
13
|
import { getCachedNumberingMap } from "../docx/numberingParser.js";
|
|
11
14
|
import { recreateProseNodeWithParagraphPropertySource, transferProseParagraphPropertySource } from "../docx/paragraphPropertySource.js";
|
|
@@ -40,6 +43,7 @@ import { deterministicHexId } from "../utils/hexId.js";
|
|
|
40
43
|
import { buildAnnotatedBlockTextWithNoteReferences } from "./clean-text.js";
|
|
41
44
|
import { anchoredCommentIdsInBlocks, anchoredCommentIdsInProseDoc, withoutLostCommentThreads } from "./comment-lifecycle.js";
|
|
42
45
|
import { noteReferenceEditsAllowed } from "./note-references.js";
|
|
46
|
+
import { noteStoryInventory } from "./note-story-inventory.js";
|
|
43
47
|
import { FolioPendingSuggestionRegistry, createPendingSuggestionSourceSnapshot, withoutPendingSuggestionCommentMarks } from "./pending-suggestions.js";
|
|
44
48
|
import { getCommentAnchorsFromDoc, getTrackedChangeGroupIdsFromDoc, getTrackedChangeStatsFromDoc, getTrackedChangesFromDoc, getTrackedChangesFromSnapshot } from "./read.js";
|
|
45
49
|
import { classifyResourceReference } from "./referenceClassification.js";
|
|
@@ -49,6 +53,7 @@ import { tableTemplateCanCrossPackageLosslessly } from "./table-template.js";
|
|
|
49
53
|
import { TaggedError, panic } from "better-result";
|
|
50
54
|
import { REVIEW_CARRIERS } from "@stll/docx-core/model";
|
|
51
55
|
import { Fragment } from "prosemirror-model";
|
|
56
|
+
import { reconcileDocumentPartRelationships } from "@stll/docx-core/ops";
|
|
52
57
|
import { EditorState } from "prosemirror-state";
|
|
53
58
|
import JSZip from "jszip";
|
|
54
59
|
//#region src/ai-edits/headless.ts
|
|
@@ -76,18 +81,7 @@ const createReviewerComment = ({ id, text, author, date }) => ({
|
|
|
76
81
|
id,
|
|
77
82
|
author,
|
|
78
83
|
date: date ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
79
|
-
content: [
|
|
80
|
-
type: "paragraph",
|
|
81
|
-
formatting: {},
|
|
82
|
-
content: [{
|
|
83
|
-
type: "run",
|
|
84
|
-
formatting: {},
|
|
85
|
-
content: [{
|
|
86
|
-
type: "text",
|
|
87
|
-
text
|
|
88
|
-
}]
|
|
89
|
-
}]
|
|
90
|
-
}]
|
|
84
|
+
content: [commentTextParagraph(text)]
|
|
91
85
|
});
|
|
92
86
|
/**
|
|
93
87
|
* Assign a stable `w14:paraId` to every body paragraph that lacks one (or
|
|
@@ -1080,42 +1074,28 @@ var FolioDocxReviewer = class FolioDocxReviewer {
|
|
|
1080
1074
|
* with the sections that show it: `[header first (sections 1, 3)] …`.
|
|
1081
1075
|
*/
|
|
1082
1076
|
getNotesAsText() {
|
|
1083
|
-
const pkg = this.baseDocument.package;
|
|
1084
1077
|
const lines = [];
|
|
1085
1078
|
const placements = this.headerFooterPlacements();
|
|
1086
|
-
const
|
|
1087
|
-
if (
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
const roles = placements.byPart.get(`${
|
|
1096
|
-
|
|
1079
|
+
for (const handle of this.listStoryHandlesInternal()) {
|
|
1080
|
+
if (handle.type === "main") continue;
|
|
1081
|
+
const text = this.getStoryText(handle);
|
|
1082
|
+
if (text.length === 0) continue;
|
|
1083
|
+
switch (handle.type) {
|
|
1084
|
+
case "header":
|
|
1085
|
+
case "footer": {
|
|
1086
|
+
const source = this.getHeaderFooterStory(handle);
|
|
1087
|
+
if (!source) panic("A listed document story no longer exists", { story: handle });
|
|
1088
|
+
const roles = placements.byPart.get(`${handle.type}:${handle.relationshipId}`);
|
|
1089
|
+
const label = roles ? describePlacements(roles, placements.sectionCount) : source.hdrFtrType;
|
|
1090
|
+
lines.push(`[${handle.type} ${label}] ${text}`);
|
|
1091
|
+
break;
|
|
1097
1092
|
}
|
|
1093
|
+
case "footnote":
|
|
1094
|
+
case "endnote":
|
|
1095
|
+
lines.push(`[${handle.type} #${handle.noteId}] ${text}`);
|
|
1096
|
+
break;
|
|
1097
|
+
default: return handle;
|
|
1098
1098
|
}
|
|
1099
|
-
};
|
|
1100
|
-
pushHeaderFooter(pkg.headers, "header");
|
|
1101
|
-
pushHeaderFooter(pkg.footers, "footer");
|
|
1102
|
-
for (const footnote of pkg.footnotes ?? []) {
|
|
1103
|
-
if (isSeparatorFootnote(footnote)) continue;
|
|
1104
|
-
const handle = {
|
|
1105
|
-
type: "footnote",
|
|
1106
|
-
noteId: footnote.id
|
|
1107
|
-
};
|
|
1108
|
-
const text = this.getNoteStoryText(handle, footnote);
|
|
1109
|
-
if (text.length > 0) lines.push(`[footnote #${footnote.id}] ${text}`);
|
|
1110
|
-
}
|
|
1111
|
-
for (const endnote of pkg.endnotes ?? []) {
|
|
1112
|
-
if (isSeparatorEndnote(endnote)) continue;
|
|
1113
|
-
const handle = {
|
|
1114
|
-
type: "endnote",
|
|
1115
|
-
noteId: endnote.id
|
|
1116
|
-
};
|
|
1117
|
-
const text = this.getNoteStoryText(handle, endnote);
|
|
1118
|
-
if (text.length > 0) lines.push(`[endnote #${endnote.id}] ${text}`);
|
|
1119
1099
|
}
|
|
1120
1100
|
return lines.join("\n");
|
|
1121
1101
|
}
|
|
@@ -1138,17 +1118,18 @@ var FolioDocxReviewer = class FolioDocxReviewer {
|
|
|
1138
1118
|
type: "footer",
|
|
1139
1119
|
relationshipId
|
|
1140
1120
|
});
|
|
1141
|
-
|
|
1121
|
+
const notes = noteStoryInventory(pkg, this.removedNoteStories);
|
|
1122
|
+
for (const footnote of notes.footnotes ?? []) if (!isSeparatorFootnote(footnote)) handles.push({
|
|
1142
1123
|
type: "footnote",
|
|
1143
1124
|
noteId: footnote.id
|
|
1144
1125
|
});
|
|
1145
|
-
for (const endnote of
|
|
1126
|
+
for (const endnote of notes.endnotes ?? []) if (!isSeparatorEndnote(endnote)) handles.push({
|
|
1146
1127
|
type: "endnote",
|
|
1147
1128
|
noteId: endnote.id
|
|
1148
1129
|
});
|
|
1149
1130
|
return handles.filter((handle) => {
|
|
1150
1131
|
if (handle.type === "header" || handle.type === "footer") return !this.removedHeaderFooterStories.has(headerFooterStoryKey(handle));
|
|
1151
|
-
return
|
|
1132
|
+
return true;
|
|
1152
1133
|
});
|
|
1153
1134
|
}
|
|
1154
1135
|
/** Discover every readable document story through a typed, serializable handle. */
|
|
@@ -1676,6 +1657,18 @@ var FolioDocxReviewer = class FolioDocxReviewer {
|
|
|
1676
1657
|
})
|
|
1677
1658
|
};
|
|
1678
1659
|
}
|
|
1660
|
+
/** Resolve ordinary revisions on a detached in-memory document. */
|
|
1661
|
+
toResolvedDocument(decision) {
|
|
1662
|
+
const copy = new FolioDocxReviewer({
|
|
1663
|
+
baseDocument: this.toDocument(),
|
|
1664
|
+
originalBuffer: this.originalBuffer,
|
|
1665
|
+
state: this.state,
|
|
1666
|
+
author: this.author
|
|
1667
|
+
});
|
|
1668
|
+
if (decision === "accept") copy.acceptAll();
|
|
1669
|
+
else copy.rejectAll();
|
|
1670
|
+
return copy.toDocument();
|
|
1671
|
+
}
|
|
1679
1672
|
/** The current document model with edits merged back in. */
|
|
1680
1673
|
toDocument() {
|
|
1681
1674
|
const document = this.documentFromStateSnapshot(this.captureReviewerState());
|
|
@@ -1702,10 +1695,20 @@ var FolioDocxReviewer = class FolioDocxReviewer {
|
|
|
1702
1695
|
importedFooters: new Map(this.importedFooters),
|
|
1703
1696
|
createdComments: [...this.createdComments],
|
|
1704
1697
|
resolvedOverrides: new Map(this.resolvedOverrides),
|
|
1705
|
-
resolvedStoryExpectations: [...this.resolvedStoryExpectations.values()]
|
|
1698
|
+
resolvedStoryExpectations: [...this.resolvedStoryExpectations.values()].filter(({ story }) => story.type === "main" || this.secondaryStorySource(story) !== void 0)
|
|
1706
1699
|
};
|
|
1707
1700
|
}
|
|
1708
|
-
documentFromStateSnapshot(
|
|
1701
|
+
documentFromStateSnapshot(authored) {
|
|
1702
|
+
const pendingCommentIds = new Set(this.exportPendingSuggestions().flatMap(({ commentId }) => commentId === void 0 ? [] : [commentId]));
|
|
1703
|
+
const snapshot = {
|
|
1704
|
+
...authored,
|
|
1705
|
+
mainState: withoutPendingSuggestionCommentMarks(rejectSuggestions(authored.mainState), pendingCommentIds),
|
|
1706
|
+
secondaryStoryStates: authored.secondaryStoryStates.map((entry) => ({
|
|
1707
|
+
...entry,
|
|
1708
|
+
state: withoutPendingSuggestionCommentMarks(rejectSuggestions(entry.state), pendingCommentIds)
|
|
1709
|
+
})),
|
|
1710
|
+
createdComments: authored.createdComments.filter(({ id }) => !pendingCommentIds.has(id))
|
|
1711
|
+
};
|
|
1709
1712
|
const sourceDocument = snapshot.importedStyles === void 0 ? this.baseDocument : {
|
|
1710
1713
|
...this.baseDocument,
|
|
1711
1714
|
package: {
|
|
@@ -1717,7 +1720,10 @@ var FolioDocxReviewer = class FolioDocxReviewer {
|
|
|
1717
1720
|
type: "supplied",
|
|
1718
1721
|
styles: snapshot.importedStyles
|
|
1719
1722
|
} });
|
|
1720
|
-
if (snapshot.finalSectionPropertiesOverride !== void 0)
|
|
1723
|
+
if (snapshot.finalSectionPropertiesOverride !== void 0) {
|
|
1724
|
+
document.package.document.finalSectionProperties = snapshot.finalSectionPropertiesOverride;
|
|
1725
|
+
if (document.package.document.sections !== void 0) document.package.document.sections = buildSections(document.package.document.content, snapshot.finalSectionPropertiesOverride);
|
|
1726
|
+
}
|
|
1721
1727
|
if (snapshot.importedStyles !== void 0) document.package.styles = snapshot.importedStyles;
|
|
1722
1728
|
if (snapshot.importedMedia.size > 0) document.package.media = new Map([...document.package.media ?? [], ...snapshot.importedMedia]);
|
|
1723
1729
|
if (snapshot.importedHeaders.size > 0) document.package.headers = new Map([...document.package.headers ?? [], ...snapshot.importedHeaders]);
|
|
@@ -1734,24 +1740,15 @@ var FolioDocxReviewer = class FolioDocxReviewer {
|
|
|
1734
1740
|
const candidates = new Set(snapshot.removedNoteStories.map(noteStoryKey));
|
|
1735
1741
|
const referenced = referencedNotes(document, candidates);
|
|
1736
1742
|
const removed = new Set([...candidates].filter((key) => !referenced.has(key)));
|
|
1737
|
-
|
|
1738
|
-
if (footnotes) document.package.footnotes = footnotes.filter((note) => !removed.has(noteStoryKey({
|
|
1739
|
-
type: "footnote",
|
|
1740
|
-
noteId: note.id
|
|
1741
|
-
})));
|
|
1742
|
-
if (endnotes) document.package.endnotes = endnotes.filter((note) => !removed.has(noteStoryKey({
|
|
1743
|
-
type: "endnote",
|
|
1744
|
-
noteId: note.id
|
|
1745
|
-
})));
|
|
1743
|
+
Object.assign(document.package, noteStoryInventory(document.package, removed));
|
|
1746
1744
|
}
|
|
1747
1745
|
const definitions = [...document.package.document.comments ?? [], ...snapshot.createdComments];
|
|
1748
1746
|
const kept = this.keptCommentThreads(definitions, snapshot.mainState, snapshot.secondaryStoryStates);
|
|
1749
1747
|
if (kept.length !== definitions.length || snapshot.createdComments.length > 0 || snapshot.resolvedOverrides.size > 0) document.package.document.comments = this.withResolvedOverrides(kept, snapshot.resolvedOverrides);
|
|
1750
|
-
return document;
|
|
1748
|
+
return normalizeListModelRendering(reconcileDocumentPartRelationships(document)).document;
|
|
1751
1749
|
}
|
|
1752
1750
|
captureSaveSnapshot() {
|
|
1753
1751
|
const snapshot = this.captureReviewerState();
|
|
1754
|
-
const pendingCommentIds = new Set(this.exportPendingSuggestions().flatMap(({ commentId }) => commentId === void 0 ? [] : [commentId]));
|
|
1755
1752
|
const changedParaIds = new Set(getChangedParagraphIds(snapshot.mainState));
|
|
1756
1753
|
let structuralChange = hasStructuralChanges(snapshot.mainState) || snapshot.finalSectionPropertiesOverride !== void 0 || snapshot.importedStyles !== void 0 || snapshot.importedHeaders.size > 0 || snapshot.importedFooters.size > 0 || snapshot.removedNoteStories.length > 0;
|
|
1757
1754
|
let untrackedChanges = hasUntrackedChanges(snapshot.mainState);
|
|
@@ -1778,15 +1775,7 @@ var FolioDocxReviewer = class FolioDocxReviewer {
|
|
|
1778
1775
|
reason: "untrackedChange"
|
|
1779
1776
|
};
|
|
1780
1777
|
return {
|
|
1781
|
-
document: this.documentFromStateSnapshot(
|
|
1782
|
-
...snapshot,
|
|
1783
|
-
mainState: withoutPendingSuggestionCommentMarks(rejectSuggestions(snapshot.mainState), pendingCommentIds),
|
|
1784
|
-
secondaryStoryStates: snapshot.secondaryStoryStates.map((entry) => ({
|
|
1785
|
-
...entry,
|
|
1786
|
-
state: withoutPendingSuggestionCommentMarks(rejectSuggestions(entry.state), pendingCommentIds)
|
|
1787
|
-
})),
|
|
1788
|
-
createdComments: snapshot.createdComments.filter(({ id }) => !pendingCommentIds.has(id))
|
|
1789
|
-
}),
|
|
1778
|
+
document: this.documentFromStateSnapshot(snapshot),
|
|
1790
1779
|
path,
|
|
1791
1780
|
changedNoteParaIds,
|
|
1792
1781
|
sectionReferenceRemovals: snapshot.sectionReferenceRemovals,
|
|
@@ -1895,6 +1884,7 @@ var FolioDocxReviewer = class FolioDocxReviewer {
|
|
|
1895
1884
|
}
|
|
1896
1885
|
getEditableStoryState(story) {
|
|
1897
1886
|
if (story.type === "main") return this.state;
|
|
1887
|
+
if (!this.secondaryStorySource(story)) return null;
|
|
1898
1888
|
const key = secondaryStoryKey(story);
|
|
1899
1889
|
const existing = this.secondaryStoryStates.get(key);
|
|
1900
1890
|
if (existing) return existing.state;
|
|
@@ -1919,10 +1909,14 @@ var FolioDocxReviewer = class FolioDocxReviewer {
|
|
|
1919
1909
|
* state for a story nothing edits.
|
|
1920
1910
|
*/
|
|
1921
1911
|
readSecondaryStoryDoc(story) {
|
|
1912
|
+
if (!this.secondaryStorySource(story)) return null;
|
|
1922
1913
|
return this.secondaryStoryStates.get(secondaryStoryKey(story))?.state.doc ?? this.secondaryStoryDoc(story);
|
|
1923
1914
|
}
|
|
1915
|
+
secondaryStorySource(story) {
|
|
1916
|
+
return story.type === "header" || story.type === "footer" ? this.getHeaderFooterStory(story) : this.getNoteStory(story);
|
|
1917
|
+
}
|
|
1924
1918
|
secondaryStoryDoc(story) {
|
|
1925
|
-
const source =
|
|
1919
|
+
const source = this.secondaryStorySource(story);
|
|
1926
1920
|
if (!source) return null;
|
|
1927
1921
|
const conversionOptions = {
|
|
1928
1922
|
...this.baseDocument.package.numbering !== void 0 && { numbering: this.baseDocument.package.numbering },
|
|
@@ -2041,8 +2035,9 @@ var FolioDocxReviewer = class FolioDocxReviewer {
|
|
|
2041
2035
|
return snapshot !== null && detachFolioAIEditSnapshotExternalHyperlinks(snapshot) !== null;
|
|
2042
2036
|
}
|
|
2043
2037
|
getNoteStory(story) {
|
|
2044
|
-
|
|
2045
|
-
return
|
|
2038
|
+
const notes = noteStoryInventory(this.baseDocument.package, this.removedNoteStories);
|
|
2039
|
+
if (story.type === "footnote") return notes.footnotes?.find((note) => note.id === story.noteId && !isSeparatorFootnote(note));
|
|
2040
|
+
return notes.endnotes?.find((note) => note.id === story.noteId && !isSeparatorEndnote(note));
|
|
2046
2041
|
}
|
|
2047
2042
|
/**
|
|
2048
2043
|
* A loaded story's blocks, so its text comes from the same walk an unloaded
|
|
@@ -2056,7 +2051,7 @@ var FolioDocxReviewer = class FolioDocxReviewer {
|
|
|
2056
2051
|
* same states, so the text now describes exactly what a save would write.
|
|
2057
2052
|
*/
|
|
2058
2053
|
storyBlocks(state, source) {
|
|
2059
|
-
return state ? proseDocToBlocks(state.doc, source.content, this.baseDocument.package.styles) : source.content;
|
|
2054
|
+
return state ? proseDocToBlocks(rejectSuggestions(state).doc, source.content, this.baseDocument.package.styles) : source.content;
|
|
2060
2055
|
}
|
|
2061
2056
|
getHeaderFooterStoryText(story, source) {
|
|
2062
2057
|
const state = this.secondaryStoryStates.get(headerFooterStoryKey(story))?.state;
|
|
@@ -2178,7 +2173,7 @@ var FolioDocxReviewer = class FolioDocxReviewer {
|
|
|
2178
2173
|
}
|
|
2179
2174
|
for (const handle of this.removedNoteStories.values()) {
|
|
2180
2175
|
const entry = loaded.get(secondaryStoryKey(handle));
|
|
2181
|
-
addAll(anchoredBefore, entry ? anchoredCommentIdsInProseDoc(entry.initialState.doc) : anchoredCommentIdsInBlocks(this.
|
|
2176
|
+
addAll(anchoredBefore, entry ? anchoredCommentIdsInProseDoc(entry.initialState.doc) : anchoredCommentIdsInBlocks((handle.type === "footnote" ? this.baseDocument.package.footnotes : this.baseDocument.package.endnotes)?.find((note) => note.id === handle.noteId)?.content ?? []));
|
|
2182
2177
|
}
|
|
2183
2178
|
return withoutLostCommentThreads(comments, {
|
|
2184
2179
|
anchoredBefore,
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { document_d_exports } from "../types/document.js";
|
|
2
|
+
//#region src/ai-edits/note-story-inventory.d.ts
|
|
3
|
+
type NoteStories = Pick<document_d_exports.Document["package"], "footnotes" | "endnotes">;
|
|
4
|
+
/** The note collections visible to a reviewer or its captured save state. */
|
|
5
|
+
declare const noteStoryInventory: (source: NoteStories, removed: Pick<ReadonlySet<string>, "has" | "size">) => NoteStories;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { noteStoryInventory };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region src/ai-edits/note-story-inventory.ts
|
|
2
|
+
/** The note collections visible to a reviewer or its captured save state. */
|
|
3
|
+
const noteStoryInventory = (source, removed) => {
|
|
4
|
+
if (removed.size === 0) return source;
|
|
5
|
+
return {
|
|
6
|
+
...source.footnotes && { footnotes: source.footnotes.filter((note) => !removed.has(`footnote:${note.id}`)) },
|
|
7
|
+
...source.endnotes && { endnotes: source.endnotes.filter((note) => !removed.has(`endnote:${note.id}`)) }
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
//#endregion
|
|
11
|
+
export { noteStoryInventory };
|
package/dist/ai-edits/read.js
CHANGED
|
@@ -245,10 +245,13 @@ const getTrackedChangeGroupsFromProjectedDoc = (doc, blockStarts) => {
|
|
|
245
245
|
const key = previousKey !== void 0 && previousRange && transparentGap(previousRange.end, pos) ? previousKey : `${path}:${pos}`;
|
|
246
246
|
lastInlineGroupByPath.set(path, key);
|
|
247
247
|
const hyperlink = node.marks.find((candidate) => candidate.type.name === "hyperlink");
|
|
248
|
-
const
|
|
248
|
+
const commentIds = node.marks.flatMap((candidate) => {
|
|
249
|
+
const commentId = candidate.attrs["commentId"];
|
|
250
|
+
return candidate.type.name === "comment" && typeof commentId === "number" ? [commentId] : [];
|
|
251
|
+
});
|
|
249
252
|
const boundary = {
|
|
250
253
|
hyperlink: hyperlink ? String(hyperlink.attrs["href"] ?? "") : null,
|
|
251
|
-
|
|
254
|
+
comments: commentIds.toSorted((left, right) => left - right).join(","),
|
|
252
255
|
revisionParents: JSON.stringify(pathLayers.slice(0, layerIndex))
|
|
253
256
|
};
|
|
254
257
|
const range = inlineRanges.get(key);
|
|
@@ -275,23 +278,27 @@ const getTrackedChangeGroupsFromProjectedDoc = (doc, blockStarts) => {
|
|
|
275
278
|
}
|
|
276
279
|
});
|
|
277
280
|
const groups = [];
|
|
278
|
-
let
|
|
281
|
+
let previousInline = null;
|
|
279
282
|
for (const [key, change] of grouped) {
|
|
280
283
|
const range = inlineRanges.get(key);
|
|
281
|
-
const previous =
|
|
282
|
-
const previousRange =
|
|
283
|
-
if (previous && range && previousRange && previousRange.end <= range.start && transparentGap(previousRange.end, range.start) && previousRange.lastBoundary.revisionParents === range.firstBoundary.revisionParents && (previousRange.lastBoundary.hyperlink !== range.firstBoundary.hyperlink || previousRange.lastBoundary.
|
|
284
|
+
const previous = previousInline?.group;
|
|
285
|
+
const previousRange = previousInline === null ? void 0 : inlineRanges.get(previousInline.key);
|
|
286
|
+
if (previous && range && previousRange && previousRange.end <= range.start && transparentGap(previousRange.end, range.start) && previousRange.lastBoundary.revisionParents === range.firstBoundary.revisionParents && (previousRange.lastBoundary.hyperlink !== range.firstBoundary.hyperlink || previousRange.lastBoundary.comments !== range.firstBoundary.comments || previousRange.end !== range.start) && (change.type === "insertion" || change.type === "deletion") && previous.change.type === change.type && previous.change.author === change.author && previous.change.date === change.date && previous.change.blockId === change.blockId) {
|
|
284
287
|
previous.change.text += change.text;
|
|
285
288
|
previous.ids.push(change.id);
|
|
286
289
|
previousRange.end = range.end;
|
|
287
290
|
previousRange.lastBoundary = range.lastBoundary;
|
|
288
291
|
continue;
|
|
289
292
|
}
|
|
290
|
-
|
|
293
|
+
const group = {
|
|
291
294
|
change: { ...change },
|
|
292
295
|
ids: [change.id]
|
|
293
|
-
}
|
|
294
|
-
|
|
296
|
+
};
|
|
297
|
+
groups.push(group);
|
|
298
|
+
if (range) previousInline = {
|
|
299
|
+
key,
|
|
300
|
+
group
|
|
301
|
+
};
|
|
295
302
|
}
|
|
296
303
|
return groups;
|
|
297
304
|
};
|
|
@@ -1,16 +1,47 @@
|
|
|
1
|
-
import { expectTrackedChangeMarkAttrs } from "../prosemirror/attrs/index.js";
|
|
1
|
+
import { expectRunPropertyChangeMarkAttrs, expectTrackedChangeMarkAttrs } from "../prosemirror/attrs/index.js";
|
|
2
|
+
import { applyMarksToRunFormattingRepresentation, expandRunFormattingCarrier } from "../prosemirror/runFormattingInlineCarriers.js";
|
|
3
|
+
import { panic } from "better-result";
|
|
2
4
|
//#region src/ai-edits/revisionStretches.ts
|
|
3
5
|
const INLINE_REVISION_MARKS = /* @__PURE__ */ new Set(["insertion", "deletion"]);
|
|
4
6
|
const separateRevisionStretches = ({ tr, revisionSeed }) => {
|
|
5
7
|
let nextRevisionId = revisionSeed;
|
|
6
8
|
const minted = [];
|
|
7
9
|
const retargets = [];
|
|
10
|
+
const formattingRetargets = [];
|
|
11
|
+
const formattingIds = /* @__PURE__ */ new Set();
|
|
12
|
+
const formattingRepresentations = /* @__PURE__ */ new Set();
|
|
8
13
|
let stretches = /* @__PURE__ */ new Map();
|
|
9
14
|
tr.doc.descendants((node, pos) => {
|
|
10
15
|
if (node.isTextblock) {
|
|
11
16
|
stretches = /* @__PURE__ */ new Map();
|
|
12
17
|
return true;
|
|
13
18
|
}
|
|
19
|
+
const carrier = node.marks.some(({ type }) => type.name === "runPropertyChange") ? expandRunFormattingCarrier(node, pos) : null;
|
|
20
|
+
for (const representation of carrier?.representations ?? []) {
|
|
21
|
+
if (carrier?.disposition === "structured-field" && representation.role === "owner") continue;
|
|
22
|
+
const mark = representation.node.marks.find(({ type }) => type.name === "runPropertyChange");
|
|
23
|
+
if (!mark) continue;
|
|
24
|
+
if (formattingRepresentations.has(representation.position)) continue;
|
|
25
|
+
formattingRepresentations.add(representation.position);
|
|
26
|
+
const ids = /* @__PURE__ */ new Map();
|
|
27
|
+
for (const { info } of expectRunPropertyChangeMarkAttrs(mark).changes) {
|
|
28
|
+
if (!formattingIds.has(info.id)) {
|
|
29
|
+
formattingIds.add(info.id);
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
const fresh = nextRevisionId++;
|
|
33
|
+
minted.push({
|
|
34
|
+
revisionId: fresh,
|
|
35
|
+
from: info.id
|
|
36
|
+
});
|
|
37
|
+
ids.set(info.id, fresh);
|
|
38
|
+
}
|
|
39
|
+
if (ids.size > 0) formattingRetargets.push({
|
|
40
|
+
representation,
|
|
41
|
+
mark,
|
|
42
|
+
ids
|
|
43
|
+
});
|
|
44
|
+
}
|
|
14
45
|
if (!node.isInline || !(node.isLeaf || node.isText)) return true;
|
|
15
46
|
const layersOf = (mark) => {
|
|
16
47
|
const attrs = expectTrackedChangeMarkAttrs(mark);
|
|
@@ -71,6 +102,26 @@ const separateRevisionStretches = ({ tr, revisionSeed }) => {
|
|
|
71
102
|
...ancestors && { _docxRevisionAncestors: ancestors.map((ancestor) => Object.assign(structuredClone(ancestor), { revisionId: ids.get(ancestor.revisionId) ?? ancestor.revisionId })) }
|
|
72
103
|
}));
|
|
73
104
|
}
|
|
105
|
+
for (const { representation, mark, ids } of formattingRetargets) {
|
|
106
|
+
const live = tr.doc.nodeAt(representation.position);
|
|
107
|
+
if (!live) panic("A formatting revision carrier vanished during normalization");
|
|
108
|
+
const changes = expectRunPropertyChangeMarkAttrs(mark).changes.map((change) => Object.assign({}, change, { info: Object.assign({}, change.info, { id: ids.get(change.info.id) ?? change.info.id }) }));
|
|
109
|
+
const replacement = mark.type.create({
|
|
110
|
+
...mark.attrs,
|
|
111
|
+
changes
|
|
112
|
+
});
|
|
113
|
+
applyMarksToRunFormattingRepresentation({
|
|
114
|
+
tr,
|
|
115
|
+
representation: {
|
|
116
|
+
node: live,
|
|
117
|
+
position: representation.position,
|
|
118
|
+
role: representation.role,
|
|
119
|
+
from: representation.position,
|
|
120
|
+
to: representation.position + representation.node.nodeSize
|
|
121
|
+
},
|
|
122
|
+
marks: replacement.addToSet(live.marks)
|
|
123
|
+
});
|
|
124
|
+
}
|
|
74
125
|
return {
|
|
75
126
|
nextRevisionId,
|
|
76
127
|
minted
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { addTrackedDeletionMark } from "../prosemirror/addTrackedDeletionMark.js";
|
|
2
2
|
import { markStructuralChange } from "../prosemirror/extensions/features/ParagraphChangeTrackerExtension.js";
|
|
3
3
|
import { markRowsEmptiedInBatch, reconcileTableGridAfterColumnInsertion, reconcileTableGridAfterColumnRemoval, removeRowsWithoutCells, removeTableRow } from "../prosemirror/tableGridMutation.js";
|
|
4
|
+
import { sliceText } from "../utils/sliceText.js";
|
|
4
5
|
import { stripBlockIdentityAttrs } from "./block-identity.js";
|
|
5
6
|
import { findEnclosingTableCell, findEnclosingTableRow } from "./table-targets.js";
|
|
6
7
|
import { tableRowFromTemplate } from "./table-template.js";
|
|
@@ -16,7 +17,11 @@ const cellRevision = (revision, index) => ({
|
|
|
16
17
|
revisionId: revision.revisionId + index
|
|
17
18
|
});
|
|
18
19
|
const UNPLACED_TEXT_PREVIEW_LENGTH = 40;
|
|
19
|
-
const previewCellText = (text) => JSON.stringify(text.length > UNPLACED_TEXT_PREVIEW_LENGTH ? `${
|
|
20
|
+
const previewCellText = (text) => JSON.stringify(text.length > UNPLACED_TEXT_PREVIEW_LENGTH ? `${sliceText({
|
|
21
|
+
text,
|
|
22
|
+
units: "codeUnits",
|
|
23
|
+
end: UNPLACED_TEXT_PREVIEW_LENGTH
|
|
24
|
+
})}…` : text);
|
|
20
25
|
/**
|
|
21
26
|
* Name the `cellTexts` a new row or column has no cell for, or `null` when
|
|
22
27
|
* every one of them has a place.
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { decodeText, encodeUtf8 } from "../utils/textEncoding.js";
|
|
1
2
|
import { writeZipPart } from "@stll/docx-core/zip";
|
|
2
3
|
import JSZip from "jszip";
|
|
3
4
|
//#region src/compare/reproducible-package.ts
|
|
@@ -22,7 +23,7 @@ const withFixedPackageDates = async (buffer, date) => {
|
|
|
22
23
|
if (coreProps) writeZipPart({
|
|
23
24
|
zip,
|
|
24
25
|
path: CORE_PROPERTIES_PATH,
|
|
25
|
-
data: withFixedModifiedDate(await coreProps.async("
|
|
26
|
+
data: encodeUtf8(withFixedModifiedDate(await coreProps.async("uint8array").then((bytes) => decodeText(bytes, { ignoreBOM: true })), date)),
|
|
26
27
|
options: {
|
|
27
28
|
compression: "DEFLATE",
|
|
28
29
|
compressionOptions: { level: DOCX_COMPRESSION_LEVEL }
|
|
@@ -307,6 +307,7 @@ const revisedFinalParagraphMarks = (packageModel, { since = 0 } = {}) => {
|
|
|
307
307
|
if (!isRecord(value) || value instanceof Date || ArrayBuffer.isView(value)) return;
|
|
308
308
|
const inADeletedRow = insideADeletedRow || isADeletedTableRow(value);
|
|
309
309
|
for (const [key, item] of Object.entries(value)) {
|
|
310
|
+
if (key === "sections" && Array.isArray(value["content"])) continue;
|
|
310
311
|
trail.push(key);
|
|
311
312
|
visit(item, inADeletedRow);
|
|
312
313
|
trail.pop();
|
|
@@ -39,7 +39,9 @@ import { toMarkdown, toMarkdownResult } from "../markdown/index.js";
|
|
|
39
39
|
import { EmbeddedFont, EmbeddedFontParts, buildEmbeddedFontFamilyMap, extractEmbeddedFonts, getEmbeddedFontFaces, scopeEmbeddedFontFamily } from "../fonts/embeddedFonts.js";
|
|
40
40
|
import { getGoogleFontsEnabled, setGoogleFontsEnabled } from "../utils/fontResolver.js";
|
|
41
41
|
import { FOLIO_YJS_ATTR_SCHEMA_VERSION, FolioYjsAttrSchemaVersion, FolioYjsAttrSchemaVersionError } from "../prosemirror/yjsDocumentMetadata.js";
|
|
42
|
+
import { EditorReadOnlyReason } from "../managers/EditorModeManager.js";
|
|
43
|
+
import { ReviewDisplayMode } from "../managers/reviewDisplayMode.js";
|
|
42
44
|
import { DOCX_CONFORMANCE_CLASSES } from "../index.js";
|
|
43
45
|
type Document = document_d_exports.Document;
|
|
44
46
|
type DocxConformanceClass = document_d_exports.DocxConformanceClass;
|
|
45
|
-
export { type AIBarStatus, type AIChatMode, type AICitation, type AICitationRange, type AICitationSource, type AIGenerateInput, type AISuggestion, type AISuggestionApplyMode, type AISuggestionPreset, type AISuggestionSeverity, type AISuggestionStatus, type AcceptAutocompleteResult, type AnonymizationMatch, type AnonymizationTerm, type ApplyFolioDocumentOperationsOptions, type ApplyResult, type AutocompleteSuggestionPluginOptions, type AutocompleteSuggestionState, type AutocompleteSuggestionStatus, type AutocompleteTriggerCheck, type AutocompleteTriggerOptions, type AutocompleteTriggerSkipReason, type BlockRect, COMPARE_REVISION_FORMATS, COMPARE_UNSUPPORTED_REASONS, COMPARE_VERIFICATION_CAUSES, COMPARE_VERIFICATION_INVARIANTS, type CompareChange, type CompareChangeLocation, type CompareCompatibility, type CompareContentOptions, CompareDocxApplyError, type CompareDocxError, CompareDocxFinalParagraphMarkError, CompareDocxOperationLimitError, type CompareDocxOptions, CompareDocxParseError, CompareDocxRoundTripError, CompareDocxSerializeError, type CompareFolioRequirement, type CompareResult, type CompareRevisionFormat, type CompareUnsupportedPart, type CompareUnsupportedReason, type CompareVerification, type CompareVerificationCause, type CompareVerificationFailure, type CompareVerificationInvariant, type CreateEmptyDocumentOptions, DEFAULT_AI_SUGGESTION_PRESETS, DEFAULT_AUTOCOMPLETE_DEAD_ZONE_NODES, DEFAULT_OUTLINE_DEPTH, DOCUMENT_PRESET_VERSION, DOCUMENT_STYLE_SET_VERSION, DOCX_CONFORMANCE_CLASSES, DRAWING_SAFETY_CLASSES, type DeriveBlockIdInput, type DirectiveKind, type DirectiveRange, type Document, type DocumentPreset, type DocumentPropertiesOptions, type DocumentStyleCatalog, type DocumentStyleCatalogEntry, type DocumentStyleSet, type DocxCompatibility, type DocxCompatibilityContext, type DocxCompatibilityIssue, type DocxCompatibilityLocation, type DocxCompatibilityPart, type DocxConformanceClass, type DocxDrawingClassification, type DrawingSafetyClass, type EmbeddedFont, type EmbeddedFontParts, type ExtractDocumentStyleSetOptions, FOLIO_CONTENT_COMPARISON_LIMITS, FOLIO_DOCUMENT_OPERATION_BATCH_MODES, FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FOLIO_DOCUMENT_OPERATION_MODES, FOLIO_DOCUMENT_OPERATION_MODES_BY_TYPE, FOLIO_DOCUMENT_OPERATION_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_STORIES, FOLIO_DOCUMENT_OPERATION_TYPES, FOLIO_LINE_SPACING_RULE_VALUES, FOLIO_PARAGRAPH_ALIGNMENT_VALUES, FOLIO_YJS_ATTR_SCHEMA_VERSION, type FinalParagraphMarkRevision, type FolioAIBlock, type FolioAIBlockAnchor, type FolioAIBlockKind, type FolioAIBlockPreviewRun, type FolioAIBlockStructuralBoundary, type FolioAIBlockTableLocation, type FolioAIComment, type FolioAIDiagnosticBlock, type FolioAIEditAppliedOperation, type FolioAIEditApplyMode, type FolioAIEditApplyOutcome, type FolioAIEditApplyResult, type FolioAIEditNormalization, type FolioAIEditNormalizationCode, type FolioAIEditOperation, type FolioAIEditPrecondition, type FolioAIEditReviewMeta, type FolioAIEditSeverity, type FolioAIEditSkipReason, type FolioAIEditSkippedOperation, type FolioAIEditSnapshot, type FolioAIInlineBooleanProperty, type FolioAIInlineFormatting, type FolioAIInlineFormattingPatch, type FolioAIParagraphBlock, type FolioAIParagraphSpacing, type FolioAISignatureParty, type FolioBlockId, type FolioContentBlock, type FolioContentBlockProperty, type FolioContentComparison, type FolioContentComparisonError, type FolioContentComparisonEvent, type FolioContentComparisonLimit, FolioContentComparisonLimitError, type FolioContentContainerPathEntry, type FolioContentFormatRange, type FolioContentFormattingChange, type FolioContentIdStability, type FolioContentInlineBooleanProperty, type FolioContentInlineComparisonResult, type FolioContentInlineFormatting, type FolioContentInlineFormattingPatch, FolioContentInlinePresentationProjectionError, type FolioContentLineSpacingRule, type FolioContentParagraphAlignment, type FolioContentParagraphFormattingPatch, type FolioContentParagraphKind, type FolioContentParagraphSpacing, type FolioContentRun, type FolioContentSnapshot, type FolioContentStatedNumbering, type FolioContentStructuralChange, type FolioContentTableLocation, type FolioContentTextSegment, type FolioDocumentOperation, type FolioDocumentOperationAffectedTarget, type FolioDocumentOperationBatch, type FolioDocumentOperationCapabilities, type FolioDocumentOperationIssue, type FolioDocumentOperationMode, type FolioDocumentOperationPrecondition, type FolioDocumentOperationReceipt, type FolioDocumentOperationRecovery, type FolioDocumentOperationResult, type FolioDocumentOperationResultBase, type FolioDocumentOperationStatus, type FolioDocumentOperationStory, type FolioDocumentOperationType, type FolioDocumentOperationUndoFailureReason, type FolioDocumentOperationUndoHandle, type FolioDocumentOperationUndoResult, type FolioDocxCompatibilityHost, type FolioDocxCompatibilityProfile, type FolioRevisionStamp, type FolioUndefinedReferencePolicy, type FolioWordDiffOptions, type FolioYjsAttrSchemaVersion, FolioYjsAttrSchemaVersionError, type ImageMeta, type ImageRef, type InspectDocxCompatibilityOptions, InvalidCompareDocxOptionsError, InvalidFolioContentComparisonError, InvalidFolioDocumentOperationBatchError, MAX_COMPARE_OPERATIONS, type MarkdownOptions, type MarkdownResult, type OutlineDepth, type PositionalText, type ResolvedAnchor, STELLA_STYLE_SET_NAME, type TemplatePreviewHiddenRange, type TemplatePreviewSpan, type TemplatePreviewValue, type TemplatePreviewValues, type TemplateSlashMenuKeyAction, type TemplateSlashMenuState, UnsupportedFolioDocumentOperationVersionError, WORD_DIFF_GRANULARITIES, type WordDiffGranularity, type WordDiffNormalization, type WordDiffOptions, type WordDiffSegment, acceptAutocompleteSuggestion, acceptAutocompleteWord, anonymizationDecorationsKey, appendAutocompleteToken, applyFolioAIEditOperations, applyFolioDocumentOperations, applySuggestions, assertSupportedFolioDocumentOperationVersion, autocompleteSuggestionKey, autocompleteSuggestionPlugin, buildEmbeddedFontFamilyMap, buildPositionalText, clearAutocompleteSuggestion, clearTemplateSlashMenu, compareContent, compareDocx, consumeTemplateSlashQuery, createAICitationDecorationsPlugin, createDocx, createEmptyDocument, createFolioAIEditSnapshot, createStellaStyleDocumentPreset, createStellaStyleSet, currentFolioBlockId, deriveBlockId, diffWordSegments, extractDocumentStyleSet, extractDocumentStyleSetFromDocx, extractEmbeddedFonts, filterHeadingsByDepth, finishAutocompleteSuggestion, fromMarkdown, getAnonymizationMatches, getAutocompleteSuggestion, getEmbeddedFontFaces, getFolioCaretViewportRect, getFolioDocumentOperationCapabilities, getFolioDocumentOperationIssues, getFolioDocumentOperationReceipts, getFolioParaIdFromBlockId, getFolioSelectionViewportRect, getGoogleFontsEnabled, getTemplateDirectives, getTemplateSlashMenu, hashFolioAIBlockText, inspectDocumentStyles, inspectDocumentStylesFromDocx, inspectDocxCompatibility, isFolioAIContentBlock, isFolioBlockId, isFolioDocumentOperationModeSupported, isSequentialFolioBlockId, isSuggestionStale, isSupportedFolioDocumentOperationVersion, mergeDocumentContent, normalizeFolioAIBlockText, parseFolioDocumentOperationBatch, resetTemplateSlashQuery, resolveSuggestionAnchor, scanDirectives, scopeEmbeddedFontFamily, scrollFolioPositionIntoView, setAICitationsMeta, setAISuggestionsMeta, setActiveCitationMeta, setAnonymizationTermsMeta, setFocusedSuggestionMeta, setGoogleFontsEnabled, setTemplatePreviewValues, shouldTriggerAutocomplete, startAutocompleteSuggestion, templateSlashMenuKey, toMarkdown, toMarkdownResult };
|
|
47
|
+
export { type AIBarStatus, type AIChatMode, type AICitation, type AICitationRange, type AICitationSource, type AIGenerateInput, type AISuggestion, type AISuggestionApplyMode, type AISuggestionPreset, type AISuggestionSeverity, type AISuggestionStatus, type AcceptAutocompleteResult, type AnonymizationMatch, type AnonymizationTerm, type ApplyFolioDocumentOperationsOptions, type ApplyResult, type AutocompleteSuggestionPluginOptions, type AutocompleteSuggestionState, type AutocompleteSuggestionStatus, type AutocompleteTriggerCheck, type AutocompleteTriggerOptions, type AutocompleteTriggerSkipReason, type BlockRect, COMPARE_REVISION_FORMATS, COMPARE_UNSUPPORTED_REASONS, COMPARE_VERIFICATION_CAUSES, COMPARE_VERIFICATION_INVARIANTS, type CompareChange, type CompareChangeLocation, type CompareCompatibility, type CompareContentOptions, CompareDocxApplyError, type CompareDocxError, CompareDocxFinalParagraphMarkError, CompareDocxOperationLimitError, type CompareDocxOptions, CompareDocxParseError, CompareDocxRoundTripError, CompareDocxSerializeError, type CompareFolioRequirement, type CompareResult, type CompareRevisionFormat, type CompareUnsupportedPart, type CompareUnsupportedReason, type CompareVerification, type CompareVerificationCause, type CompareVerificationFailure, type CompareVerificationInvariant, type CreateEmptyDocumentOptions, DEFAULT_AI_SUGGESTION_PRESETS, DEFAULT_AUTOCOMPLETE_DEAD_ZONE_NODES, DEFAULT_OUTLINE_DEPTH, DOCUMENT_PRESET_VERSION, DOCUMENT_STYLE_SET_VERSION, DOCX_CONFORMANCE_CLASSES, DRAWING_SAFETY_CLASSES, type DeriveBlockIdInput, type DirectiveKind, type DirectiveRange, type Document, type DocumentPreset, type DocumentPropertiesOptions, type DocumentStyleCatalog, type DocumentStyleCatalogEntry, type DocumentStyleSet, type DocxCompatibility, type DocxCompatibilityContext, type DocxCompatibilityIssue, type DocxCompatibilityLocation, type DocxCompatibilityPart, type DocxConformanceClass, type DocxDrawingClassification, type DrawingSafetyClass, type EditorReadOnlyReason, type EmbeddedFont, type EmbeddedFontParts, type ExtractDocumentStyleSetOptions, FOLIO_CONTENT_COMPARISON_LIMITS, FOLIO_DOCUMENT_OPERATION_BATCH_MODES, FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FOLIO_DOCUMENT_OPERATION_MODES, FOLIO_DOCUMENT_OPERATION_MODES_BY_TYPE, FOLIO_DOCUMENT_OPERATION_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_STORIES, FOLIO_DOCUMENT_OPERATION_TYPES, FOLIO_LINE_SPACING_RULE_VALUES, FOLIO_PARAGRAPH_ALIGNMENT_VALUES, FOLIO_YJS_ATTR_SCHEMA_VERSION, type FinalParagraphMarkRevision, type FolioAIBlock, type FolioAIBlockAnchor, type FolioAIBlockKind, type FolioAIBlockPreviewRun, type FolioAIBlockStructuralBoundary, type FolioAIBlockTableLocation, type FolioAIComment, type FolioAIDiagnosticBlock, type FolioAIEditAppliedOperation, type FolioAIEditApplyMode, type FolioAIEditApplyOutcome, type FolioAIEditApplyResult, type FolioAIEditNormalization, type FolioAIEditNormalizationCode, type FolioAIEditOperation, type FolioAIEditPrecondition, type FolioAIEditReviewMeta, type FolioAIEditSeverity, type FolioAIEditSkipReason, type FolioAIEditSkippedOperation, type FolioAIEditSnapshot, type FolioAIInlineBooleanProperty, type FolioAIInlineFormatting, type FolioAIInlineFormattingPatch, type FolioAIParagraphBlock, type FolioAIParagraphSpacing, type FolioAISignatureParty, type FolioBlockId, type FolioContentBlock, type FolioContentBlockProperty, type FolioContentComparison, type FolioContentComparisonError, type FolioContentComparisonEvent, type FolioContentComparisonLimit, FolioContentComparisonLimitError, type FolioContentContainerPathEntry, type FolioContentFormatRange, type FolioContentFormattingChange, type FolioContentIdStability, type FolioContentInlineBooleanProperty, type FolioContentInlineComparisonResult, type FolioContentInlineFormatting, type FolioContentInlineFormattingPatch, FolioContentInlinePresentationProjectionError, type FolioContentLineSpacingRule, type FolioContentParagraphAlignment, type FolioContentParagraphFormattingPatch, type FolioContentParagraphKind, type FolioContentParagraphSpacing, type FolioContentRun, type FolioContentSnapshot, type FolioContentStatedNumbering, type FolioContentStructuralChange, type FolioContentTableLocation, type FolioContentTextSegment, type FolioDocumentOperation, type FolioDocumentOperationAffectedTarget, type FolioDocumentOperationBatch, type FolioDocumentOperationCapabilities, type FolioDocumentOperationIssue, type FolioDocumentOperationMode, type FolioDocumentOperationPrecondition, type FolioDocumentOperationReceipt, type FolioDocumentOperationRecovery, type FolioDocumentOperationResult, type FolioDocumentOperationResultBase, type FolioDocumentOperationStatus, type FolioDocumentOperationStory, type FolioDocumentOperationType, type FolioDocumentOperationUndoFailureReason, type FolioDocumentOperationUndoHandle, type FolioDocumentOperationUndoResult, type FolioDocxCompatibilityHost, type FolioDocxCompatibilityProfile, type FolioRevisionStamp, type FolioUndefinedReferencePolicy, type FolioWordDiffOptions, type FolioYjsAttrSchemaVersion, FolioYjsAttrSchemaVersionError, type ImageMeta, type ImageRef, type InspectDocxCompatibilityOptions, InvalidCompareDocxOptionsError, InvalidFolioContentComparisonError, InvalidFolioDocumentOperationBatchError, MAX_COMPARE_OPERATIONS, type MarkdownOptions, type MarkdownResult, type OutlineDepth, type PositionalText, type ResolvedAnchor, type ReviewDisplayMode, STELLA_STYLE_SET_NAME, type TemplatePreviewHiddenRange, type TemplatePreviewSpan, type TemplatePreviewValue, type TemplatePreviewValues, type TemplateSlashMenuKeyAction, type TemplateSlashMenuState, UnsupportedFolioDocumentOperationVersionError, WORD_DIFF_GRANULARITIES, type WordDiffGranularity, type WordDiffNormalization, type WordDiffOptions, type WordDiffSegment, acceptAutocompleteSuggestion, acceptAutocompleteWord, anonymizationDecorationsKey, appendAutocompleteToken, applyFolioAIEditOperations, applyFolioDocumentOperations, applySuggestions, assertSupportedFolioDocumentOperationVersion, autocompleteSuggestionKey, autocompleteSuggestionPlugin, buildEmbeddedFontFamilyMap, buildPositionalText, clearAutocompleteSuggestion, clearTemplateSlashMenu, compareContent, compareDocx, consumeTemplateSlashQuery, createAICitationDecorationsPlugin, createDocx, createEmptyDocument, createFolioAIEditSnapshot, createStellaStyleDocumentPreset, createStellaStyleSet, currentFolioBlockId, deriveBlockId, diffWordSegments, extractDocumentStyleSet, extractDocumentStyleSetFromDocx, extractEmbeddedFonts, filterHeadingsByDepth, finishAutocompleteSuggestion, fromMarkdown, getAnonymizationMatches, getAutocompleteSuggestion, getEmbeddedFontFaces, getFolioCaretViewportRect, getFolioDocumentOperationCapabilities, getFolioDocumentOperationIssues, getFolioDocumentOperationReceipts, getFolioParaIdFromBlockId, getFolioSelectionViewportRect, getGoogleFontsEnabled, getTemplateDirectives, getTemplateSlashMenu, hashFolioAIBlockText, inspectDocumentStyles, inspectDocumentStylesFromDocx, inspectDocxCompatibility, isFolioAIContentBlock, isFolioBlockId, isFolioDocumentOperationModeSupported, isSequentialFolioBlockId, isSuggestionStale, isSupportedFolioDocumentOperationVersion, mergeDocumentContent, normalizeFolioAIBlockText, parseFolioDocumentOperationBatch, resetTemplateSlashQuery, resolveSuggestionAnchor, scanDirectives, scopeEmbeddedFontFamily, scrollFolioPositionIntoView, setAICitationsMeta, setAISuggestionsMeta, setActiveCitationMeta, setAnonymizationTermsMeta, setFocusedSuggestionMeta, setGoogleFontsEnabled, setTemplatePreviewValues, shouldTriggerAutocomplete, startAutocompleteSuggestion, templateSlashMenuKey, toMarkdown, toMarkdownResult };
|
|
@@ -9,6 +9,7 @@ import { completeNumberingForDoc } from "../prosemirror/listInstanceReferences.j
|
|
|
9
9
|
import { marksToTextFormatting } from "../prosemirror/runFormattingFromMarks.js";
|
|
10
10
|
import { CANONICAL_GAP } from "../types/canonicalCapabilities.js";
|
|
11
11
|
import { bytesToDataUrl } from "../utils/base64.js";
|
|
12
|
+
import { base64ToBytes } from "../utils/textEncoding.js";
|
|
12
13
|
import { flattenClipboardStyleReferences, importClipboardStyles } from "./canonicalClipboardResources.js";
|
|
13
14
|
import { CanonicalSessionError } from "./canonicalSession.js";
|
|
14
15
|
import { Result } from "better-result";
|
|
@@ -407,7 +408,7 @@ const prepareCanonicalPaste = ({ session, state, slice, plain = false, moveTarge
|
|
|
407
408
|
if (mimeType === void 0 || payload === void 0) return refuse("The clipboard image data is malformed.");
|
|
408
409
|
if (payload.length > Math.ceil(MAX_CLIPBOARD_IMAGE_BYTES * 4 / 3)) return refuse("The clipboard image exceeds the import size limit.");
|
|
409
410
|
const decoded = Result.try({
|
|
410
|
-
try: () =>
|
|
411
|
+
try: () => base64ToBytes(payload),
|
|
411
412
|
catch: () => new CanonicalSessionError({
|
|
412
413
|
gap: CANONICAL_GAP.dispatch,
|
|
413
414
|
message: "The clipboard image data is malformed.",
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { document_d_exports } from "../types/document.js";
|
|
2
|
-
import { DocumentOp } from "@stll/docx-core/ops";
|
|
3
1
|
//#region src/controller/canonicalListRendering.d.ts
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
/** Canonical edits share list model normalization with the headless projection. */
|
|
3
|
+
declare const normalizeCanonicalListRendering: (document: import("@stll/docx-core").Document) => {
|
|
4
|
+
document: import("@stll/docx-core").Document;
|
|
5
|
+
inverse: import("@stll/docx-core/ops").DocumentOp[];
|
|
7
6
|
};
|
|
8
|
-
declare const normalizeCanonicalListRendering: (document: document_d_exports.Document) => CanonicalListNormalization;
|
|
9
7
|
//#endregion
|
|
10
8
|
export { normalizeCanonicalListRendering };
|