@stll/folio-core 0.59.0 → 0.61.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 +23 -1
- package/dist/ai-edits/apply.js +139 -32
- package/dist/ai-edits/headless.d.ts +3 -0
- package/dist/ai-edits/headless.js +57 -63
- 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 +4 -2
- package/dist/compat/eigenpal.js +2 -2
- 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/canonicalSession.js +3 -2
- package/dist/controller/canonicalStructure.js +10 -7
- package/dist/controller/fontReadiness.js +1 -1
- 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 +19 -4
- package/dist/controller/layoutSession.d.ts +4 -1
- package/dist/display-list/build/fontTable.js +7 -5
- package/dist/display-list/build/furniture.d.ts +1 -0
- package/dist/display-list/build/furniture.js +1 -0
- package/dist/display-list/build/imagePrimitives.js +3 -6
- package/dist/display-list/build/watermarkPrimitives.d.ts +2 -1
- package/dist/display-list/build/watermarkPrimitives.js +9 -3
- package/dist/display-list/editor/pageRenderer.js +1 -0
- package/dist/docx/bookmarkIdNormalization.d.ts +10 -0
- package/dist/docx/bookmarkIdNormalization.js +100 -0
- package/dist/docx/bookmarkParser.js +4 -2
- 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 +6 -1
- package/dist/docx/importedIdCollisions.d.ts +136 -0
- package/dist/docx/importedIdCollisions.js +215 -0
- 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/numberingParser.js +2 -2
- package/dist/docx/packageParts.js +6 -5
- package/dist/docx/paragraphParser.js +6 -4
- package/dist/docx/paragraphPropertySource.js +1 -2
- package/dist/docx/parseContext.d.ts +2 -1
- package/dist/docx/parseContext.js +1 -0
- package/dist/docx/parseWarningMessage.js +1 -0
- package/dist/docx/parser.js +10 -5
- package/dist/docx/preservedRunContent.js +11 -2
- package/dist/docx/relsParser.js +1 -1
- package/dist/docx/removeHeaderFooterParts.js +8 -7
- package/dist/docx/replyToComment.js +3 -13
- package/dist/docx/rezip.js +90 -90
- 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/selectedXmlIdentityScan.d.ts +10 -0
- package/dist/docx/selectedXmlIdentityScan.js +36 -0
- package/dist/docx/selectiveSave.js +19 -17
- package/dist/docx/selectiveXmlPatch.js +44 -52
- package/dist/docx/serializer/commentSerializer.d.ts +3 -1
- package/dist/docx/serializer/commentSerializer.js +11 -2
- package/dist/docx/serializer/runSerializer.js +5 -4
- package/dist/docx/serializer/tableSerializer.js +2 -1
- package/dist/docx/serializer/trackedChangeAttributes.d.ts +1 -3
- package/dist/docx/serializer/trackedChangeAttributes.js +1 -11
- 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/embeddedFontFingerprint.d.ts +5 -0
- package/dist/fonts/embeddedFontFingerprint.js +18 -0
- package/dist/fonts/embeddedFonts.d.ts +1 -1
- package/dist/fonts/embeddedFonts.js +1 -1
- package/dist/fonts/fontsourceFaces.js +2 -1
- package/dist/fonts/headlessMeasure.js +0 -0
- 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/headless-layout.js +1 -0
- package/dist/index.d.ts +4 -2
- package/dist/index.js +2 -2
- 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/flowConversionShared.d.ts +4 -0
- package/dist/layout-bridge/convert/footnoteLayout.d.ts +5 -1
- package/dist/layout-bridge/convert/footnoteLayout.js +16 -3
- package/dist/layout-bridge/convert/headerFooterLayout.d.ts +6 -0
- package/dist/layout-bridge/convert/headerFooterLayout.js +13 -14
- package/dist/layout-bridge/convert/paragraphConversion.js +8 -1
- package/dist/layout-bridge/convert/paragraphRuns.js +2 -1
- package/dist/layout-bridge/convert/toFlowBlocks.js +25 -1
- package/dist/layout-engine/measure/cache.js +39 -7
- package/dist/layout-engine/measure/crossRunWords.js +12 -2
- package/dist/layout-engine/measure/lineTypography.js +1 -0
- package/dist/layout-engine/measure/listMarkerWidth.d.ts +1 -0
- package/dist/layout-engine/measure/listMarkerWidth.js +1 -0
- package/dist/layout-engine/measure/measureContainer.js +3 -4
- package/dist/layout-engine/measure/measureHelpers.d.ts +6 -9
- package/dist/layout-engine/measure/measureHelpers.js +21 -18
- package/dist/layout-engine/measure/measureParagraph.js +2 -0
- package/dist/layout-engine/measure/measureTypes.d.ts +2 -0
- package/dist/layout-engine/types.d.ts +4 -1
- package/dist/layout-painter/renderPage.d.ts +1 -0
- package/dist/layout-painter/renderPage.js +11 -3
- package/dist/layout-painter/renderParagraph.js +13 -3
- package/dist/layout-painter/renderWatermark.d.ts +1 -0
- package/dist/layout-painter/renderWatermark.js +7 -3
- 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/TableSelectionManager.d.ts +1 -1
- package/dist/managers/autoSaveCodec.js +2 -6
- package/dist/managers/editorShortcuts.d.ts +2 -1
- package/dist/managers/editorShortcuts.js +2 -1
- package/dist/managers/reviewDisplayMode.d.ts +8 -0
- package/dist/managers/reviewDisplayMode.js +15 -0
- 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 +3 -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/canonicalSelectionRange.d.ts +4 -1
- package/dist/prosemirror/canonicalSelectionRange.js +9 -3
- package/dist/prosemirror/commands/comments.js +51 -13
- package/dist/prosemirror/containerFinalParagraph.d.ts +8 -8
- package/dist/prosemirror/containerFinalParagraph.js +8 -8
- package/dist/prosemirror/conversion/fromProseDoc.js +9 -4
- package/dist/prosemirror/conversion/toProseDoc.js +4 -4
- package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.d.ts +8 -2
- package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.js +39 -3
- package/dist/prosemirror/extensions/features/EmptyParagraphFormatExtension.d.ts +8 -2
- package/dist/prosemirror/extensions/features/EmptyParagraphFormatExtension.js +4 -3
- package/dist/prosemirror/extensions/features/ImageDragExtension.js +4 -3
- package/dist/prosemirror/extensions/features/JoinedRunStyleExtension.js +4 -3
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.d.ts +9 -3
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.js +6 -5
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.d.ts +8 -2
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.js +11 -3
- package/dist/prosemirror/extensions/marks/RunIdentityExtension.js +4 -3
- package/dist/prosemirror/extensions/marks/markUtils.js +1 -1
- package/dist/prosemirror/extensions/nodes/CommentReferenceExtension.js +16 -2
- package/dist/prosemirror/findReplaceSelection.d.ts +11 -1
- package/dist/prosemirror/findReplaceSelection.js +15 -1
- package/dist/prosemirror/markupViewProjection.d.ts +10 -1
- package/dist/prosemirror/markupViewProjection.js +21 -3
- package/dist/prosemirror/pluginKeyOwner.d.ts +13 -0
- package/dist/prosemirror/pluginKeyOwner.js +35 -0
- package/dist/prosemirror/plugins/aiCitationDecorations.d.ts +11 -4
- package/dist/prosemirror/plugins/aiCitationDecorations.js +16 -3
- package/dist/prosemirror/plugins/aiSuggestionDecorations.d.ts +11 -4
- package/dist/prosemirror/plugins/aiSuggestionDecorations.js +18 -3
- package/dist/prosemirror/plugins/anonymizationDecorations.d.ts +11 -11
- package/dist/prosemirror/plugins/anonymizationDecorations.js +23 -13
- package/dist/prosemirror/plugins/autocompleteSuggestion.d.ts +8 -2
- package/dist/prosemirror/plugins/autocompleteSuggestion.js +27 -5
- package/dist/prosemirror/plugins/contentControlWidgets.d.ts +8 -2
- package/dist/prosemirror/plugins/contentControlWidgets.js +4 -3
- package/dist/prosemirror/plugins/createDocScanPlugin.d.ts +6 -5
- package/dist/prosemirror/plugins/createDocScanPlugin.js +1 -1
- package/dist/prosemirror/plugins/documentNumbering.js +5 -3
- package/dist/prosemirror/plugins/documentStyleState.d.ts +8 -2
- package/dist/prosemirror/plugins/documentStyleState.js +2 -2
- package/dist/prosemirror/plugins/documentStyles.js +1 -1
- package/dist/prosemirror/plugins/selectionTracker.d.ts +8 -2
- package/dist/prosemirror/plugins/selectionTracker.js +4 -3
- package/dist/prosemirror/plugins/suggestionMode.d.ts +8 -2
- package/dist/prosemirror/plugins/suggestionMode.js +4 -3
- package/dist/prosemirror/plugins/templateDirectives.d.ts +8 -2
- package/dist/prosemirror/plugins/templateDirectives.js +19 -4
- package/dist/prosemirror/plugins/templatePreviewValues.d.ts +8 -2
- package/dist/prosemirror/plugins/templatePreviewValues.js +27 -5
- package/dist/prosemirror/plugins/templateSlashMenu.d.ts +8 -2
- package/dist/prosemirror/plugins/templateSlashMenu.js +23 -5
- package/dist/prosemirror/plugins/transactionInvariants.js +29 -4
- 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/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/findReplace.d.ts +5 -0
- package/dist/utils/fontLoader.d.ts +2 -2
- package/dist/utils/fontLoader.js +2 -7
- package/dist/utils/fontResolver.d.ts +7 -3
- package/dist/utils/fontResolver.js +6 -8
- package/dist/utils/replaceText.js +21 -4
- 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 +73 -31
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();
|
|
@@ -37,9 +37,11 @@ import { ImageMeta, ImageRef, MarkdownOptions, MarkdownResult } from "../markdow
|
|
|
37
37
|
import { fromMarkdown } from "../markdown/fromMarkdown.js";
|
|
38
38
|
import { toMarkdown, toMarkdownResult } from "../markdown/index.js";
|
|
39
39
|
import { EmbeddedFont, EmbeddedFontParts, buildEmbeddedFontFamilyMap, extractEmbeddedFonts, getEmbeddedFontFaces, scopeEmbeddedFontFamily } from "../fonts/embeddedFonts.js";
|
|
40
|
-
import { getGoogleFontsEnabled,
|
|
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,
|
|
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 };
|
package/dist/compat/eigenpal.js
CHANGED
|
@@ -32,7 +32,7 @@ import { STELLA_STYLE_SET_NAME, createStellaStyleDocumentPreset, createStellaSty
|
|
|
32
32
|
import { DOCUMENT_PRESET_VERSION, DOCUMENT_STYLE_SET_VERSION } from "../style-sets/types.js";
|
|
33
33
|
import { currentFolioBlockId, deriveBlockId, getFolioParaIdFromBlockId, isFolioBlockId, isSequentialFolioBlockId } from "../types/block-id.js";
|
|
34
34
|
import { createEmptyDocument } from "../utils/createDocument.js";
|
|
35
|
-
import { getGoogleFontsEnabled,
|
|
35
|
+
import { getGoogleFontsEnabled, setGoogleFontsEnabled } from "../utils/fontResolver.js";
|
|
36
36
|
import { mergeDocumentContent } from "../utils/mergeDocumentContent.js";
|
|
37
37
|
import { DEFAULT_OUTLINE_DEPTH, filterHeadingsByDepth } from "../utils/outlineDepth.js";
|
|
38
|
-
export { COMPARE_REVISION_FORMATS, COMPARE_UNSUPPORTED_REASONS, COMPARE_VERIFICATION_CAUSES, COMPARE_VERIFICATION_INVARIANTS, CompareDocxApplyError, CompareDocxFinalParagraphMarkError, CompareDocxOperationLimitError, CompareDocxParseError, CompareDocxRoundTripError, CompareDocxSerializeError, 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, 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, FolioContentComparisonLimitError, FolioContentInlinePresentationProjectionError, FolioYjsAttrSchemaVersionError, InvalidCompareDocxOptionsError, InvalidFolioContentComparisonError, InvalidFolioDocumentOperationBatchError, MAX_COMPARE_OPERATIONS, STELLA_STYLE_SET_NAME, UnsupportedFolioDocumentOperationVersionError, WORD_DIFF_GRANULARITIES, 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,
|
|
38
|
+
export { COMPARE_REVISION_FORMATS, COMPARE_UNSUPPORTED_REASONS, COMPARE_VERIFICATION_CAUSES, COMPARE_VERIFICATION_INVARIANTS, CompareDocxApplyError, CompareDocxFinalParagraphMarkError, CompareDocxOperationLimitError, CompareDocxParseError, CompareDocxRoundTripError, CompareDocxSerializeError, 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, 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, FolioContentComparisonLimitError, FolioContentInlinePresentationProjectionError, FolioYjsAttrSchemaVersionError, InvalidCompareDocxOptionsError, InvalidFolioContentComparisonError, InvalidFolioDocumentOperationBatchError, MAX_COMPARE_OPERATIONS, STELLA_STYLE_SET_NAME, UnsupportedFolioDocumentOperationVersionError, WORD_DIFF_GRANULARITIES, 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 };
|
|
@@ -1,160 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { computeListMarker } from "../docx/listMarkerComputation.js";
|
|
3
|
-
import { listRenderingDefinitionsMatch } from "../docx/listRendering.js";
|
|
4
|
-
import { computeListRendering, getCachedNumberingMap } from "../docx/numberingParser.js";
|
|
5
|
-
import { assignParagraphIndentationProjection, cloneParagraphWithPropertySource, paragraphFormattingWithAuthoredIndentation, sameParagraphIndentationProjection } from "../docx/paragraphPropertySource.js";
|
|
6
|
-
import { effectiveParagraphNumberingReference, paragraphNumberingSourcesFromBoundary } from "../prosemirror/numberingAttr.js";
|
|
7
|
-
import { paragraphIndentationFromFormatting } from "../prosemirror/paragraphIndentation.js";
|
|
8
|
-
import { listIndentationProvenancePatch } from "../prosemirror/styles/resolvedStyleAttrs.js";
|
|
9
|
-
import { createStyleResolver } from "../prosemirror/styles/styleResolver.js";
|
|
10
|
-
import { canonicalJson } from "../utils/canonicalJson.js";
|
|
11
|
-
import { panic } from "better-result";
|
|
12
|
-
import { DOCUMENT_OP_TYPES, EMPTY_PROPERTY_SETS, OP_STORIES, registerParagraphPropertySnapshot, withBodyContent } from "@stll/docx-core/ops";
|
|
1
|
+
import { normalizeListModelRendering } from "../docx/listModelNormalization.js";
|
|
13
2
|
//#region src/controller/canonicalListRendering.ts
|
|
14
|
-
/** Canonical edits
|
|
15
|
-
const normalizeCanonicalListRendering =
|
|
16
|
-
const inverse = [];
|
|
17
|
-
const styles = createStyleResolver(document.package.styles);
|
|
18
|
-
const numbering = document.package.numbering === void 0 ? null : getCachedNumberingMap(document.package.numbering);
|
|
19
|
-
const normalizeBody = (body, story) => {
|
|
20
|
-
const counters = {
|
|
21
|
-
numbering,
|
|
22
|
-
listCounters: /* @__PURE__ */ new Map(),
|
|
23
|
-
abstractCounters: /* @__PURE__ */ new Map(),
|
|
24
|
-
restartedNumIds: /* @__PURE__ */ new Set(),
|
|
25
|
-
previousList: {
|
|
26
|
-
abstractNumId: null,
|
|
27
|
-
fromStyle: false,
|
|
28
|
-
numId: null
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
const content = body.content.map((paragraph) => {
|
|
32
|
-
if (paragraph.type !== "paragraph") return paragraph;
|
|
33
|
-
registerParagraphPropertySnapshot({
|
|
34
|
-
paragraph,
|
|
35
|
-
snapshot: paragraphFormattingWithAuthoredIndentation(paragraph)
|
|
36
|
-
});
|
|
37
|
-
const formatting = paragraph.formatting;
|
|
38
|
-
const next = cloneParagraphWithPropertySource(paragraph, {});
|
|
39
|
-
if (formatting?.numPrFromStyle !== void 0 && (formatting.numPr?.kind === "reference" || formatting.numPr?.kind === "none")) {
|
|
40
|
-
next.formatting = { ...formatting };
|
|
41
|
-
delete next.formatting.numPrFromStyle;
|
|
42
|
-
inverse.push({
|
|
43
|
-
type: DOCUMENT_OP_TYPES.SET_PARAGRAPH_PROPS,
|
|
44
|
-
story,
|
|
45
|
-
blockId: paragraph.paraId ?? panic("Canonical numbering normalization requires paragraph identities."),
|
|
46
|
-
patch: { numPrFromStyle: formatting.numPrFromStyle }
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
const numPr = effectiveParagraphNumberingReference(paragraphNumberingSourcesFromBoundary({
|
|
50
|
-
numPr: next.formatting?.numPr,
|
|
51
|
-
numPrFromStyle: next.formatting?.numPrFromStyle
|
|
52
|
-
}));
|
|
53
|
-
if (paragraph.listRendering === void 0 && formatting?.numPrFromStyle === void 0 && (numPr?.kind !== "reference" || numbering === null)) {
|
|
54
|
-
computeListMarker(paragraph, counters);
|
|
55
|
-
return paragraph;
|
|
56
|
-
}
|
|
57
|
-
const definition = numPr?.kind === "reference" && numbering !== null ? computeListRendering(numPr, numbering) : null;
|
|
58
|
-
const cached = paragraph.listRendering;
|
|
59
|
-
const rendering = definition !== null && cached !== void 0 && listRenderingDefinitionsMatch(cached, definition) ? { ...cached } : definition;
|
|
60
|
-
const authoredFormatting = paragraphFormattingWithAuthoredIndentation(next);
|
|
61
|
-
assignParagraphIndentationProjection({
|
|
62
|
-
paragraph: next,
|
|
63
|
-
authored: authoredFormatting,
|
|
64
|
-
inherited: paragraphIndentationFromFormatting(listIndentationProvenancePatch({
|
|
65
|
-
direct: paragraphIndentationFromFormatting(authoredFormatting),
|
|
66
|
-
styleFormatting: styles.resolveParagraphStyle(next.formatting?.styleId).paragraphFormatting,
|
|
67
|
-
numberingSource: next.formatting?.numPr?.kind === "reference" || next.formatting?.numPrFromStyle === void 0 ? "paragraph" : "style",
|
|
68
|
-
numPr: numPr?.kind === "reference" ? {
|
|
69
|
-
numId: numPr.numId,
|
|
70
|
-
ilvl: numPr.ilvl ?? 0
|
|
71
|
-
} : void 0,
|
|
72
|
-
numbering
|
|
73
|
-
})._resolvedFormatting) ?? {}
|
|
74
|
-
});
|
|
75
|
-
if (canonicalJson(paragraphIndentationFromFormatting(next.formatting)) !== canonicalJson(paragraphIndentationFromFormatting(formatting))) inverse.unshift({
|
|
76
|
-
type: DOCUMENT_OP_TYPES.SET_PARAGRAPH_PROPS,
|
|
77
|
-
story,
|
|
78
|
-
blockId: paragraph.paraId ?? panic("Canonical numbering normalization requires paragraph identities."),
|
|
79
|
-
patch: {
|
|
80
|
-
indentLeft: formatting?.indentLeft ?? null,
|
|
81
|
-
indentRight: formatting?.indentRight ?? null,
|
|
82
|
-
indentFirstLine: formatting?.indentFirstLine ?? null,
|
|
83
|
-
hangingIndent: formatting?.hangingIndent ?? null
|
|
84
|
-
},
|
|
85
|
-
whenEmpty: formatting === void 0 ? EMPTY_PROPERTY_SETS.OMIT : EMPTY_PROPERTY_SETS.KEEP
|
|
86
|
-
});
|
|
87
|
-
if (rendering === null) delete next.listRendering;
|
|
88
|
-
else {
|
|
89
|
-
const fields = foldListNumberFields(paragraph.content.map(unfoldedListNumberContent), () => void 0).fieldCount;
|
|
90
|
-
if (fields === 0) delete rendering.implicitChildLevelAdvances;
|
|
91
|
-
else rendering.implicitChildLevelAdvances = fields;
|
|
92
|
-
const template = rendering.markerTemplate ?? rendering.marker;
|
|
93
|
-
const fold = planParagraphListNumberFold(paragraph.content, !rendering.isBullet && template !== "" && !template.includes(" "));
|
|
94
|
-
if (fold.suffix === void 0) delete rendering.foldedMarkerSuffix;
|
|
95
|
-
else rendering.foldedMarkerSuffix = fold.suffix;
|
|
96
|
-
const child = numbering?.getLevel(rendering.numId, rendering.level + 1)?.pPr;
|
|
97
|
-
if (fold.suffix !== void 0 && child?.hangingIndent === true && child.indentFirstLine !== void 0 && child.indentFirstLine < 0) rendering.markerSecondSlotOffsetTwips = -child.indentFirstLine;
|
|
98
|
-
else delete rendering.markerSecondSlotOffsetTwips;
|
|
99
|
-
rendering.marker = rendering.foldedMarkerSuffix !== void 0 && !template.includes(" ") ? `${template}\t${rendering.foldedMarkerSuffix}` : template;
|
|
100
|
-
next.listRendering = rendering;
|
|
101
|
-
}
|
|
102
|
-
computeListMarker(next, counters);
|
|
103
|
-
registerParagraphPropertySnapshot({
|
|
104
|
-
paragraph: next,
|
|
105
|
-
snapshot: authoredFormatting
|
|
106
|
-
});
|
|
107
|
-
if (sameParagraphIndentationProjection({
|
|
108
|
-
left: next,
|
|
109
|
-
right: paragraph
|
|
110
|
-
}) && canonicalJson(next.formatting) === canonicalJson(formatting) && canonicalJson(next.listRendering) === canonicalJson(cached)) return paragraph;
|
|
111
|
-
return next;
|
|
112
|
-
});
|
|
113
|
-
return content.every((paragraph, index) => paragraph === body.content[index]) ? body : {
|
|
114
|
-
...body,
|
|
115
|
-
...withBodyContent(body, content)
|
|
116
|
-
};
|
|
117
|
-
};
|
|
118
|
-
const pkg = document.package;
|
|
119
|
-
const body = normalizeBody(pkg.document, OP_STORIES.MAIN);
|
|
120
|
-
const normalizeParts = (parts, kind) => {
|
|
121
|
-
if (parts === void 0) return parts;
|
|
122
|
-
const normalized = new Map([...parts].map(([id, part]) => [id, normalizeBody(part, {
|
|
123
|
-
kind,
|
|
124
|
-
rId: id
|
|
125
|
-
})]));
|
|
126
|
-
return [...normalized].every(([id, part]) => part === parts.get(id)) ? parts : normalized;
|
|
127
|
-
};
|
|
128
|
-
const normalizeNotes = (notes, kind) => {
|
|
129
|
-
if (notes === void 0) return notes;
|
|
130
|
-
const normalized = notes.map((note) => normalizeBody(note, {
|
|
131
|
-
kind,
|
|
132
|
-
id: note.id
|
|
133
|
-
}));
|
|
134
|
-
return normalized.every((note, index) => note === notes[index]) ? notes : normalized;
|
|
135
|
-
};
|
|
136
|
-
const headers = normalizeParts(pkg.headers, "header");
|
|
137
|
-
const footers = normalizeParts(pkg.footers, "footer");
|
|
138
|
-
const footnotes = normalizeNotes(pkg.footnotes, "footnote");
|
|
139
|
-
const endnotes = normalizeNotes(pkg.endnotes, "endnote");
|
|
140
|
-
if (body === pkg.document && headers === pkg.headers && footers === pkg.footers && footnotes === pkg.footnotes && endnotes === pkg.endnotes) return {
|
|
141
|
-
document,
|
|
142
|
-
inverse
|
|
143
|
-
};
|
|
144
|
-
return {
|
|
145
|
-
inverse,
|
|
146
|
-
document: {
|
|
147
|
-
...document,
|
|
148
|
-
package: {
|
|
149
|
-
...pkg,
|
|
150
|
-
document: body,
|
|
151
|
-
...headers === void 0 ? {} : { headers },
|
|
152
|
-
...footers === void 0 ? {} : { footers },
|
|
153
|
-
...footnotes === void 0 ? {} : { footnotes },
|
|
154
|
-
...endnotes === void 0 ? {} : { endnotes }
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
};
|
|
158
|
-
};
|
|
3
|
+
/** Canonical edits share list model normalization with the headless projection. */
|
|
4
|
+
const normalizeCanonicalListRendering = normalizeListModelRendering;
|
|
159
5
|
//#endregion
|
|
160
6
|
export { normalizeCanonicalListRendering };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { splitsGraphemeCluster, splitsSurrogatePair } from "../ai-edits/character-boundaries.js";
|
|
2
2
|
import { rangedCommentIds, visitCommentMarkers } from "../docx/commentAnchorIndex.js";
|
|
3
3
|
import { cloneDocumentWithParagraphPropertySources, copyDocumentParagraphPropertySourceContract, copyParagraphPropertySource, restoreParagraphIndentationProjection } from "../docx/paragraphPropertySource.js";
|
|
4
|
-
import { canonicalSelectionRange } from "../prosemirror/canonicalSelectionRange.js";
|
|
4
|
+
import { canonicalContentPosition, canonicalSelectionRange } from "../prosemirror/canonicalSelectionRange.js";
|
|
5
5
|
import { collectPairedBookmarkIds, footnoteToProseDoc, headerFooterToProseDoc, toProseDoc } from "../prosemirror/conversion/toProseDoc.js";
|
|
6
6
|
import { markPackageChange } from "../prosemirror/extensions/features/ParagraphChangeTrackerExtension.js";
|
|
7
7
|
import { runFormattingPatchFromMarks } from "../prosemirror/runFormattingFromMarks.js";
|
|
@@ -147,6 +147,7 @@ var CanonicalProjection = class {
|
|
|
147
147
|
}
|
|
148
148
|
addressAt(position) {
|
|
149
149
|
if (!Number.isInteger(position)) return refuse("The input position is not an integer.");
|
|
150
|
+
position = canonicalContentPosition(this.doc, position);
|
|
150
151
|
const paragraph = this.paragraphs.find(({ start, node }) => position >= start && position <= start + node.content.size);
|
|
151
152
|
if (paragraph === void 0) return refuse("The input is outside a plain paragraph.");
|
|
152
153
|
const relative = position - paragraph.start;
|
|
@@ -169,7 +170,7 @@ var CanonicalProjection = class {
|
|
|
169
170
|
if (paragraph === void 0) panic("Input lost its paragraph.");
|
|
170
171
|
let destination = position;
|
|
171
172
|
paragraph.node.forEach((node, start) => {
|
|
172
|
-
if (node.marks.some((mark) => mark.type.name === "deletion") &&
|
|
173
|
+
if (node.marks.some((mark) => mark.type.name === "deletion") && destination >= paragraph.start + start && destination < paragraph.start + start + node.nodeSize) destination = paragraph.start + start + node.nodeSize;
|
|
173
174
|
});
|
|
174
175
|
return destination === position ? address : this.addressAt(destination);
|
|
175
176
|
}
|
|
@@ -5,9 +5,9 @@ import { effectiveParagraphNumbering, paragraphNumberingSourcesFromBoundary } fr
|
|
|
5
5
|
import { CANONICAL_GAP } from "../types/canonicalCapabilities.js";
|
|
6
6
|
import { collectHeadings } from "../utils/headingCollector.js";
|
|
7
7
|
import { CanonicalSessionError } from "./canonicalSession.js";
|
|
8
|
-
import { Result } from "better-result";
|
|
8
|
+
import { Result, panic } from "better-result";
|
|
9
9
|
import { headingOutlineLevel, paragraphNumberingReference } from "@stll/docx-core/model";
|
|
10
|
-
import { OP_STORIES } from "@stll/docx-core/ops";
|
|
10
|
+
import { OP_STORIES, editorParagraphGroups, editorPositionAtPhysicalPosition, physicalPositionAtEditorOffset } from "@stll/docx-core/ops";
|
|
11
11
|
//#region src/controller/canonicalStructure.ts
|
|
12
12
|
const DEFAULT_TOC_PAGE_WIDTH_TWIPS = 12240;
|
|
13
13
|
const DEFAULT_TOC_MARGIN_TWIPS = 1440;
|
|
@@ -322,17 +322,20 @@ const prepareCanonicalAutoformat = (session, state, { from, to, text }) => {
|
|
|
322
322
|
if (text !== " " || from !== to) return void 0;
|
|
323
323
|
const at = session.projection.addressAt(from);
|
|
324
324
|
if (at.isErr()) return void 0;
|
|
325
|
-
const
|
|
325
|
+
const logical = editorPositionAtPhysicalPosition(session.document, at.value);
|
|
326
|
+
const address = session.projection.paragraph(logical.blockId);
|
|
326
327
|
if (address === void 0 || effectiveNumbering(address.source)?.kind === "reference") return void 0;
|
|
328
|
+
const group = editorParagraphGroups(session.document, logical.story).find(({ blockId }) => blockId === logical.blockId);
|
|
329
|
+
if (group === void 0) panic("Autoformat lost its logical paragraph");
|
|
327
330
|
const source = address.source;
|
|
328
|
-
const prefix =
|
|
331
|
+
const prefix = group.text.slice(0, logical.offset) + text;
|
|
329
332
|
const requests = listRequestsForMarker(prefix);
|
|
330
333
|
const heading = /^(?<hashes>#{1,6}) $/u.exec(prefix)?.groups?.["hashes"];
|
|
331
334
|
if (requests === null && heading === void 0) return void 0;
|
|
332
|
-
const start = {
|
|
333
|
-
...
|
|
335
|
+
const start = physicalPositionAtEditorOffset(session.document, {
|
|
336
|
+
...logical,
|
|
334
337
|
offset: 0
|
|
335
|
-
};
|
|
338
|
+
});
|
|
336
339
|
const request = requests?.at(0);
|
|
337
340
|
const styleId = `Heading${heading?.length ?? 1}`;
|
|
338
341
|
if (request === void 0 && !session.hasStyle(styleId)) return void 0;
|
|
@@ -227,7 +227,7 @@ function addLayoutFontFamilyNameFace(faces, family, descriptor, fontAlternates)
|
|
|
227
227
|
* the painter and the measurer put in `ctx.font` and `style.fontFamily`.
|
|
228
228
|
*/
|
|
229
229
|
function resolvedStackFamilies(family, alternate) {
|
|
230
|
-
const { cssFallback } = resolveFontFamily(family, alternate);
|
|
230
|
+
const { cssFallback } = resolveFontFamily(family, { alternateFontName: alternate });
|
|
231
231
|
return parseFontFamilyList(cssFallback).filter((name) => !CSS_GENERIC_FONT_FAMILIES.has(name));
|
|
232
232
|
}
|
|
233
233
|
function addLayoutFontFace(faces, family, descriptor) {
|
|
@@ -18,6 +18,7 @@ type HeaderFooterEditorTransaction = {
|
|
|
18
18
|
type HeaderFooterEditorManagerDeps = {
|
|
19
19
|
createView?: ((mountNode: HTMLElement, props: DirectEditorProps) => EditorView) | undefined;
|
|
20
20
|
getDocument: () => document_d_exports.Document | null;
|
|
21
|
+
getReadOnly?: (() => boolean) | undefined;
|
|
21
22
|
getCanonicalApi?: (() => HiddenEditorApi | null) | undefined;
|
|
22
23
|
getExperimentalSession?: (() => "canonical" | undefined) | undefined;
|
|
23
24
|
onSessionRefusal?: ((reason: string, gap: CanonicalGap, error?: Error) => void) | undefined;
|
|
@@ -91,6 +91,15 @@ const createHeaderFooterEditorManager = (deps) => {
|
|
|
91
91
|
const sync = () => {
|
|
92
92
|
const host = deps.getHost();
|
|
93
93
|
if (!host) return;
|
|
94
|
+
const getReadOnly = deps.getReadOnly;
|
|
95
|
+
if (getReadOnly) {
|
|
96
|
+
const readOnly = getReadOnly();
|
|
97
|
+
for (const part of mounted.values()) {
|
|
98
|
+
const expectedEditable = !readOnly;
|
|
99
|
+
if (part.view.editable === expectedEditable) continue;
|
|
100
|
+
part.view.setProps({ editable: () => !getReadOnly() });
|
|
101
|
+
}
|
|
102
|
+
}
|
|
94
103
|
if (usesCanonicalSession(deps.getExperimentalSession?.(), CANONICAL_GAP.authorityRouting) && !deps.getCanonicalApi?.()?.getCanonicalStoryProjection(OP_STORIES.MAIN)) return;
|
|
95
104
|
const document = getOwnedDocument();
|
|
96
105
|
const styles = deps.getStyles();
|
|
@@ -179,11 +188,13 @@ const createHeaderFooterEditorManager = (deps) => {
|
|
|
179
188
|
}
|
|
180
189
|
const view = (deps.createView ?? createEditorView)(mountNode, {
|
|
181
190
|
...canonical.props,
|
|
191
|
+
editable: () => !(deps.getReadOnly?.() ?? false),
|
|
182
192
|
state: canonicalProjection ? EditorState.create({
|
|
183
193
|
doc: canonicalProjection,
|
|
184
194
|
plugins: [createDocumentStyleContextPlugin(styles), createDocumentNumberingPlugin(numbering)]
|
|
185
195
|
}) : buildInitialState(headerFooter, styles, theme, numbering, manager),
|
|
186
196
|
dispatchTransaction(transaction) {
|
|
197
|
+
if ((deps.getReadOnly?.() ?? false) && transaction.docChanged) return;
|
|
187
198
|
if (canonical.dispatch(transaction)) return;
|
|
188
199
|
const nextState = view.state.apply(transaction);
|
|
189
200
|
const docChanged = !nextState.doc.eq(view.state.doc);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { document_d_exports } from "../types/document.js";
|
|
2
2
|
import { CanonicalGap } from "../types/canonicalCapabilities.js";
|
|
3
|
+
import { EditorMode } from "../managers/EditorModeManager.js";
|
|
3
4
|
import { HiddenEditorApi } from "./hiddenEditorApi.js";
|
|
4
5
|
import { HiddenEditorStateReason } from "../layout-engine/layoutInstrumentation.js";
|
|
5
6
|
import { ExtensionManager } from "../prosemirror/extensions/ExtensionManager.js";
|
|
6
7
|
import { RemoteSelection } from "../types/remote-selection.js";
|
|
7
|
-
import { EditorMode } from "../managers/EditorModeManager.js";
|
|
8
8
|
import { EditorState, Plugin, Transaction } from "prosemirror-state";
|
|
9
9
|
import { EditorView } from "prosemirror-view";
|
|
10
10
|
import * as Yjs from "yjs";
|
|
@@ -812,7 +812,9 @@ const createHiddenEditorManager = (deps) => {
|
|
|
812
812
|
};
|
|
813
813
|
const syncEditable = () => {
|
|
814
814
|
if (!view) return;
|
|
815
|
-
|
|
815
|
+
const readOnly = deps.getReadOnly();
|
|
816
|
+
if (view.editable !== !readOnly) view.setProps({ editable: () => !deps.getReadOnly() });
|
|
817
|
+
syncHiddenEditorAccessibility(view, readOnly);
|
|
816
818
|
};
|
|
817
819
|
const publishStoryCommit = (storyView, commit) => {
|
|
818
820
|
if (!view || editorSession.type !== "canonical") return false;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { document_d_exports } from "../types/document.js";
|
|
2
2
|
import { TemplatePreviewEntry, TemplatePreviewHiddenRange } from "../prosemirror/plugins/templatePreviewValues.js";
|
|
3
|
+
import { DisplayMode } from "../managers/EditorModeManager.js";
|
|
3
4
|
import { ColumnLayout, FlowBlock, FootnoteContent, HeaderFooterContent, Layout, Measure, PageHeaderFooterRefs, PageMargins } from "../layout-engine/types.js";
|
|
4
5
|
import { LayoutRunOptions } from "./layoutRunOptions.js";
|
|
5
|
-
import { DisplayMode } from "../managers/EditorModeManager.js";
|
|
6
6
|
import { LayoutSession } from "./layoutSession.js";
|
|
7
7
|
import { HyphenationReadiness } from "./hyphenationReadiness.js";
|
|
8
8
|
import { ConvertHeaderFooterOptions, HeaderFooterMetrics } from "../layout-bridge/convert/headerFooterLayout.js";
|
|
@@ -79,6 +79,8 @@ type LayoutPipelineDeps<THfPMs> = {
|
|
|
79
79
|
* authored text with runs hidden afterwards.
|
|
80
80
|
*/
|
|
81
81
|
markupView: DisplayMode;
|
|
82
|
+
/** Independent highlight visibility in All Markup; resolved views always hide comments. */
|
|
83
|
+
showCommentHighlights?: boolean;
|
|
82
84
|
};
|
|
83
85
|
declare function runLayoutPipeline<THfPMs>(deps: LayoutPipelineDeps<THfPMs>, state: EditorState, options?: LayoutRunOptions): LayoutOutcome;
|
|
84
86
|
//#endregion
|