@stll/folio-core 0.66.1 → 0.67.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai-edits/apply.d.ts +13 -1
- package/dist/ai-edits/apply.js +572 -140
- package/dist/ai-edits/batch-claims.d.ts +26 -0
- package/dist/ai-edits/batch-claims.js +32 -5
- package/dist/ai-edits/clean-text.js +4 -1
- package/dist/ai-edits/headless.d.ts +6 -0
- package/dist/ai-edits/headless.js +25 -3
- package/dist/ai-edits/newListNumbering.d.ts +4 -1
- package/dist/ai-edits/newListNumbering.js +4 -2
- package/dist/ai-edits/read.js +6 -4
- package/dist/ai-edits/snapshot.js +24 -14
- package/dist/ai-edits/table-cell-mutations.js +3 -2
- package/dist/ai-edits/table-row-column-mutations.js +20 -6
- package/dist/ai-edits/types.d.ts +1 -1
- package/dist/controller/canonicalComposition.d.ts +1 -1
- package/dist/controller/canonicalComposition.js +76 -18
- package/dist/controller/canonicalInput.d.ts +0 -1
- package/dist/controller/canonicalInput.js +19 -1
- package/dist/controller/canonicalSession.js +1 -2
- package/dist/controller/hiddenEditorManager.d.ts +6 -0
- package/dist/controller/hiddenEditorManager.js +3 -1
- package/dist/controller/layoutPipeline.d.ts +2 -0
- package/dist/controller/layoutPipeline.js +7 -3
- package/dist/controller/layoutSession.d.ts +1 -0
- package/dist/display-list/build/tablePrimitives.d.ts +3 -1
- package/dist/display-list/build/tablePrimitives.js +29 -13
- package/dist/document-operations.d.ts +13 -1
- package/dist/document-operations.js +11 -4
- package/dist/docx/chartPreview.d.ts +4 -1
- package/dist/docx/chartPreview.js +26 -15
- package/dist/docx/listNumberingInstances.d.ts +6 -4
- package/dist/docx/listNumberingInstances.js +12 -11
- package/dist/docx/mainDocumentPart.d.ts +6 -0
- package/dist/docx/mainDocumentPart.js +65 -0
- package/dist/docx/numberingIds.d.ts +10 -0
- package/dist/docx/numberingIds.js +5 -1
- package/dist/docx/packageParts.d.ts +1 -1
- package/dist/docx/packageParts.js +10 -4
- package/dist/docx/paragraphParser.js +16 -3
- package/dist/docx/paragraphProperties.js +2 -1
- package/dist/docx/previewBudget.d.ts +6 -0
- package/dist/docx/previewBudget.js +7 -1
- package/dist/docx/rezip.js +4 -4
- package/dist/docx/serializer/paragraphSerializer.js +86 -66
- package/dist/docx/shapeAlternateContent.js +19 -0
- package/dist/docx/unzip.js +2 -0
- package/dist/i18n/messages/ar.gen.js +2 -0
- package/dist/i18n/messages/catalogs.gen.d.ts +34 -0
- package/dist/i18n/messages/catalogs.gen.js +34 -0
- package/dist/i18n/messages/cs.gen.js +2 -0
- package/dist/i18n/messages/de.gen.js +2 -0
- package/dist/i18n/messages/en.gen.js +2 -0
- package/dist/i18n/messages/es.gen.js +2 -0
- package/dist/i18n/messages/et.gen.js +2 -0
- package/dist/i18n/messages/fr.gen.js +2 -0
- package/dist/i18n/messages/he.gen.js +2 -0
- package/dist/i18n/messages/hi.gen.js +2 -0
- package/dist/i18n/messages/hu.gen.js +2 -0
- package/dist/i18n/messages/lt.gen.js +2 -0
- package/dist/i18n/messages/lv.gen.js +2 -0
- package/dist/i18n/messages/messages.gen.d.ts +2 -0
- package/dist/i18n/messages/pl.gen.js +2 -0
- package/dist/i18n/messages/pt-BR.gen.js +2 -0
- package/dist/i18n/messages/sk.gen.js +2 -0
- package/dist/i18n/messages/tr.gen.js +2 -0
- package/dist/i18n/messages/zh-CN.gen.js +2 -0
- package/dist/internal/wholeStoryRevisionResolution.d.ts +1 -1
- package/dist/internal/wholeStoryRevisionResolution.js +81 -21
- package/dist/layout-bridge/convert/altChunkPlaceholder.d.ts +10 -0
- package/dist/layout-bridge/convert/altChunkPlaceholder.js +70 -0
- package/dist/layout-bridge/convert/fixedTableColumnWidths.js +2 -1
- package/dist/layout-bridge/convert/flowConversionShared.d.ts +10 -0
- package/dist/layout-bridge/convert/flowConversionShared.js +11 -1
- package/dist/layout-bridge/convert/footnoteLayout.d.ts +1 -0
- package/dist/layout-bridge/convert/footnoteLayout.js +4 -1
- package/dist/layout-bridge/convert/headerFooterLayout.d.ts +1 -0
- package/dist/layout-bridge/convert/headerFooterLayout.js +6 -1
- package/dist/layout-bridge/convert/runMarkFormatting.js +1 -0
- package/dist/layout-bridge/convert/tableConversion.js +6 -2
- package/dist/layout-bridge/convert/toFlowBlocks.js +4 -0
- package/dist/layout-bridge/engine/clickToPosition.js +5 -1
- package/dist/layout-engine/measure/tableCellFloating.d.ts +2 -0
- package/dist/layout-engine/measure/tableCellFloating.js +1 -0
- package/dist/layout-engine/measure/tableVisibleBand.d.ts +16 -0
- package/dist/layout-engine/measure/tableVisibleBand.js +28 -0
- package/dist/layout-engine/tableLayout.js +7 -4
- package/dist/layout-engine/tableRowBreak.d.ts +10 -0
- package/dist/layout-engine/tableRowBreak.js +151 -36
- package/dist/layout-engine/types.d.ts +7 -2
- package/dist/layout-painter/previewSvg.d.ts +8 -0
- package/dist/layout-painter/previewSvg.js +47 -0
- package/dist/layout-painter/renderImage.js +2 -1
- package/dist/layout-painter/renderPage.d.ts +1 -0
- package/dist/layout-painter/renderPage.js +6 -3
- package/dist/layout-painter/renderParagraph.js +3 -2
- package/dist/layout-painter/renderTable.d.ts +5 -2
- package/dist/layout-painter/renderTable.js +33 -19
- package/dist/markdown/renderRuns.js +68 -12
- package/dist/prosemirror/anchoredTextBoxes.d.ts +2 -1
- package/dist/prosemirror/commands/comments.js +22 -7
- package/dist/prosemirror/commands/deleteBesideInlineAnchor.d.ts +9 -0
- package/dist/prosemirror/commands/deleteBesideInlineAnchor.js +36 -0
- package/dist/prosemirror/commands/pastePlainText.d.ts +6 -0
- package/dist/prosemirror/commands/pastePlainText.js +13 -3
- package/dist/prosemirror/commands/resolveAllTableChanges.js +30 -2
- package/dist/prosemirror/commands/resolveParagraphProperties.js +15 -2
- package/dist/prosemirror/commentReferenceIntegrity.d.ts +8 -2
- package/dist/prosemirror/commentReferenceIntegrity.js +19 -4
- package/dist/prosemirror/conversion/fromProseDoc.js +94 -22
- package/dist/prosemirror/conversion/hyphenTextCarriers.d.ts +23 -1
- package/dist/prosemirror/conversion/hyphenTextCarriers.js +46 -1
- package/dist/prosemirror/conversion/toProseDoc.js +21 -13
- package/dist/prosemirror/extensions/StarterKit.js +1 -1
- package/dist/prosemirror/extensions/core/ParagraphExtension.d.ts +3 -1
- package/dist/prosemirror/extensions/core/ParagraphExtension.js +8 -9
- package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.js +46 -11
- package/dist/prosemirror/extensions/features/BaseKeymapExtension.js +3 -2
- package/dist/prosemirror/extensions/features/BidiShortcutExtension.js +2 -3
- package/dist/prosemirror/extensions/features/ListExtension.js +22 -1
- package/dist/prosemirror/extensions/features/pasteCleanup.js +6 -0
- package/dist/prosemirror/extensions/features/pastedHtmlLists.js +2 -1
- package/dist/prosemirror/extensions/markRegistry.d.ts +3 -1
- package/dist/prosemirror/extensions/markRegistry.js +3 -0
- package/dist/prosemirror/extensions/marks/HyperlinkExtension.js +5 -0
- package/dist/prosemirror/extensions/marks/HyphenElementExtension.d.ts +6 -0
- package/dist/prosemirror/extensions/marks/HyphenElementExtension.js +54 -0
- package/dist/prosemirror/extensions/marks/TextColorExtension.js +1 -1
- package/dist/prosemirror/extensions/marks/TrackedChangeExtensions.js +8 -4
- package/dist/prosemirror/extensions/nodes/BookmarkBoundaryExtension.js +5 -1
- package/dist/prosemirror/extensions/nodes/CommentRangeBoundaryExtension.js +2 -1
- package/dist/prosemirror/extensions/nodes/CommentReferenceExtension.js +4 -3
- package/dist/prosemirror/extensions/nodes/MoveRangeBoundaryExtension.js +2 -1
- package/dist/prosemirror/extensions/nodes/NoteMarkerExtension.js +2 -1
- package/dist/prosemirror/extensions/nodes/RangeAnchorExtension.js +2 -1
- package/dist/prosemirror/extensions/nodes/RenderedPageBreakExtension.js +2 -1
- package/dist/prosemirror/extensions/nodes/TableExtension.js +87 -7
- package/dist/prosemirror/extensions/nodes/inlineAnchorDom.d.ts +11 -0
- package/dist/prosemirror/extensions/nodes/inlineAnchorDom.js +21 -0
- package/dist/prosemirror/fieldRepresentation.js +2 -1
- package/dist/prosemirror/hyphenElementAttrs.d.ts +10 -0
- package/dist/prosemirror/hyphenElementAttrs.js +32 -0
- package/dist/prosemirror/keptRangeBoundaries.d.ts +2 -0
- package/dist/prosemirror/keptRangeBoundaries.js +1 -1
- package/dist/prosemirror/listNumbering.js +3 -2
- package/dist/prosemirror/paragraphIndentation.js +2 -1
- package/dist/prosemirror/paragraphPropertyCarry.d.ts +1 -14
- package/dist/prosemirror/paragraphPropertyCarry.js +4 -28
- package/dist/prosemirror/plugins/suggestionMode.d.ts +0 -8
- package/dist/prosemirror/plugins/suggestionMode.js +194 -27
- package/dist/prosemirror/replacedAnnotations.d.ts +1 -0
- package/dist/prosemirror/replacedAnnotations.js +1 -0
- package/dist/prosemirror/rowGridOmissions.d.ts +11 -0
- package/dist/prosemirror/rowGridOmissions.js +21 -0
- package/dist/prosemirror/sectionCarrier.d.ts +8 -0
- package/dist/prosemirror/sectionCarrier.js +29 -1
- package/dist/prosemirror/styles/paragraphStyleCascade.d.ts +10 -0
- package/dist/prosemirror/styles/paragraphStyleCascade.js +12 -2
- package/dist/prosemirror/tableGridMutation.d.ts +19 -2
- package/dist/prosemirror/tableGridMutation.js +118 -15
- package/dist/prosemirror/tablePositionedBookmarks.d.ts +2 -0
- package/dist/prosemirror/tablePositionedBookmarks.js +80 -0
- package/dist/prosemirror/tableRunIn.d.ts +24 -9
- package/dist/prosemirror/tableRunIn.js +107 -21
- package/dist/prosemirror/textInput.js +3 -1
- package/dist/prosemirror/validation.js +7 -1
- package/dist/utils/createDocument.js +11 -8
- package/dist/utils/formatToStyle.js +2 -2
- package/dist/utils/units.d.ts +5 -0
- package/dist/utils/units.js +6 -1
- package/package.json +3 -3
|
@@ -1,26 +1,39 @@
|
|
|
1
1
|
import { splitsSurrogatePair } from "../ai-edits/character-boundaries.js";
|
|
2
|
-
import { RUN_IDENTITY_MARK_NAME } from "../prosemirror/runIdentity.js";
|
|
3
2
|
import { CANONICAL_GAP } from "../types/canonicalCapabilities.js";
|
|
4
3
|
import { setCanonicalInputTimer } from "./canonicalInputTimer.js";
|
|
5
4
|
import { CanonicalSessionError } from "./canonicalSession.js";
|
|
6
5
|
import { Result } from "better-result";
|
|
7
6
|
import { EditorState, TextSelection } from "prosemirror-state";
|
|
8
7
|
// src/controller/canonicalComposition.ts
|
|
8
|
+
const REVIEW_MARK_NAMES = /* @__PURE__ */ new Set(["insertion", "deletion"]);
|
|
9
|
+
/**
|
|
10
|
+
* Whether a native proposal is one plain replacement. The commit is a text
|
|
11
|
+
* replacement over the captured model, so this only has to tell DOM noise from a
|
|
12
|
+
* real change. Reading the DOM back can lose a mark with no parse rule or, through
|
|
13
|
+
* `insertText`, a non-inclusive one. It rebuilds a review mark from fewer attributes,
|
|
14
|
+
* and composed text sits in the DOM wrapper of the tracked run beside it. Gaining
|
|
15
|
+
* any other mark, losing an inclusive one, or another revision is a real change.
|
|
16
|
+
* So is a selected paragraph boundary that does not disappear exactly.
|
|
17
|
+
*/
|
|
9
18
|
const matchesNativeReplacement = ({ baseline, proposed, from, to, text }) => {
|
|
10
19
|
const expected = baseline.tr.insertText(text, from, to);
|
|
11
20
|
if (expected.doc.eq(proposed.doc)) return true;
|
|
12
|
-
|
|
21
|
+
const $from = baseline.doc.resolve(from);
|
|
22
|
+
const $to = baseline.doc.resolve(to);
|
|
13
23
|
if (expected.doc.content.size !== proposed.doc.content.size) return false;
|
|
14
|
-
const markType = baseline.schema.marks[RUN_IDENTITY_MARK_NAME];
|
|
15
|
-
if (markType === void 0) return false;
|
|
16
24
|
const position = expected.doc.resolve(from);
|
|
17
25
|
const paragraph = position.parent;
|
|
18
26
|
const start = position.start();
|
|
19
27
|
const native = proposed.doc.nodeAt(start - 1);
|
|
20
28
|
if (native === null || native.type !== paragraph.type) return false;
|
|
29
|
+
if (!$from.sameParent($to) && native.sameMarkup($to.parent)) expected.setNodeMarkup(start - 1, void 0, native.attrs, native.marks);
|
|
30
|
+
const composedFrom = from;
|
|
31
|
+
const composedTo = from + text.length;
|
|
32
|
+
const types = Object.values(baseline.schema.marks);
|
|
33
|
+
const beside = [$from.nodeBefore, $to.nodeAfter];
|
|
34
|
+
const corrections = [];
|
|
21
35
|
let index = 0;
|
|
22
36
|
let offset = 0;
|
|
23
|
-
const missing = [];
|
|
24
37
|
native.forEach((node, nodeOffset) => {
|
|
25
38
|
const end = nodeOffset + node.nodeSize;
|
|
26
39
|
let cursor = nodeOffset;
|
|
@@ -28,14 +41,21 @@ const matchesNativeReplacement = ({ baseline, proposed, from, to, text }) => {
|
|
|
28
41
|
const authored = paragraph.child(index);
|
|
29
42
|
const authoredEnd = offset + authored.nodeSize;
|
|
30
43
|
const overlapEnd = Math.min(end, authoredEnd);
|
|
31
|
-
if (node.isText && authored.isText
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
type
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
44
|
+
if (node.isText && authored.isText) {
|
|
45
|
+
const rangeFrom = start + cursor;
|
|
46
|
+
const rangeTo = start + overlapEnd;
|
|
47
|
+
for (const type of types) {
|
|
48
|
+
const held = type.isInSet(authored.marks);
|
|
49
|
+
const read = type.isInSet(node.marks);
|
|
50
|
+
if (held && !read) {
|
|
51
|
+
if (type.spec.inclusive === false || (type.spec.parseDOM ?? []).length === 0) corrections.push(() => expected.removeMark(rangeFrom, rangeTo, type));
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
if (!read || !REVIEW_MARK_NAMES.has(type.name)) continue;
|
|
55
|
+
const sameRevision = held?.attrs["revisionId"] === read.attrs["revisionId"];
|
|
56
|
+
const inWrapperBeside = rangeFrom >= composedFrom && rangeTo <= composedTo && beside.some((neighbour) => type.isInSet(neighbour?.marks ?? []));
|
|
57
|
+
if (held ? sameRevision : inWrapperBeside) corrections.push(() => expected.addMark(rangeFrom, rangeTo, read));
|
|
58
|
+
}
|
|
39
59
|
}
|
|
40
60
|
cursor = overlapEnd;
|
|
41
61
|
if (cursor === authoredEnd) {
|
|
@@ -44,7 +64,7 @@ const matchesNativeReplacement = ({ baseline, proposed, from, to, text }) => {
|
|
|
44
64
|
}
|
|
45
65
|
}
|
|
46
66
|
});
|
|
47
|
-
for (const
|
|
67
|
+
for (const correction of corrections) correction();
|
|
48
68
|
return expected.doc.eq(proposed.doc);
|
|
49
69
|
};
|
|
50
70
|
/** Native IME owns the provisional view; the captured canonical projection stays unchanged. */
|
|
@@ -53,6 +73,10 @@ const createCanonicalComposition = (options) => {
|
|
|
53
73
|
let authorizedNativeState = null;
|
|
54
74
|
let completed = { type: "idle" };
|
|
55
75
|
let timer;
|
|
76
|
+
/** The browser began again mid-composition; its proposals no longer say where. */
|
|
77
|
+
let restarted = false;
|
|
78
|
+
let acceptedUpdate = false;
|
|
79
|
+
let explicitFinal = null;
|
|
56
80
|
const clearTimer = () => {
|
|
57
81
|
if (timer !== void 0) clearTimeout(timer);
|
|
58
82
|
timer = void 0;
|
|
@@ -149,6 +173,27 @@ const createCanonicalComposition = (options) => {
|
|
|
149
173
|
semantic: "composition"
|
|
150
174
|
};
|
|
151
175
|
};
|
|
176
|
+
/**
|
|
177
|
+
* The browser can lose its composition range when the projection redraws a
|
|
178
|
+
* neighbouring node, and then starts again from a position it computes itself.
|
|
179
|
+
* Its final text still names what was composed, and the captured selection says
|
|
180
|
+
* where. A proposal that reaches the caret and holds that text is such a restart
|
|
181
|
+
* even when the restart event went unseen.
|
|
182
|
+
*/
|
|
183
|
+
const finalInput = (pending, native) => {
|
|
184
|
+
const { phase, baseline } = pending;
|
|
185
|
+
const final = explicitFinal ?? (phase.type === "ended" ? phase.data : null);
|
|
186
|
+
if (!final || native.text === final) return native;
|
|
187
|
+
const { from, to, empty } = baseline.selection;
|
|
188
|
+
const atCaret = empty && native.from <= from && native.to >= from && native.text.includes(final);
|
|
189
|
+
if (!restarted && !atCaret) return native;
|
|
190
|
+
return {
|
|
191
|
+
from,
|
|
192
|
+
to,
|
|
193
|
+
text: final,
|
|
194
|
+
semantic: "composition"
|
|
195
|
+
};
|
|
196
|
+
};
|
|
152
197
|
const applyNative = (view, transaction) => Result.try({
|
|
153
198
|
try: () => view.state.applyTransaction(transaction),
|
|
154
199
|
catch: (cause) => new CanonicalSessionError({
|
|
@@ -162,8 +207,9 @@ const createCanonicalComposition = (options) => {
|
|
|
162
207
|
authorizedNativeState = null;
|
|
163
208
|
const pending = state;
|
|
164
209
|
if (pending.type === "committed") return { type: "idle" };
|
|
165
|
-
const
|
|
166
|
-
const
|
|
210
|
+
const native = commit && pending.type === "provisional" ? replacement(pending.baseline, view.state) : null;
|
|
211
|
+
const input = native && pending.type === "provisional" ? finalInput(pending, native) : native;
|
|
212
|
+
const committedText = input && input !== native ? input.text : selectedText(pending.baseline, view.state);
|
|
167
213
|
const proposed = view.state;
|
|
168
214
|
const from = pending.baseline.selection.from;
|
|
169
215
|
completed = { type: "idle" };
|
|
@@ -173,7 +219,7 @@ const createCanonicalComposition = (options) => {
|
|
|
173
219
|
view.updateState(pending.baseline);
|
|
174
220
|
}
|
|
175
221
|
options.end();
|
|
176
|
-
if (!commit || view.isDestroyed || pending.phase.type === "ended" && pending.phase.data === "" && pending.phase.completion === "provisional"
|
|
222
|
+
if (!commit || view.isDestroyed || pending.phase.type === "ended" && pending.phase.data === "" && pending.phase.completion === "provisional") return { type: "cancelled" };
|
|
177
223
|
if (pending.type === "refused") return {
|
|
178
224
|
type: "refused",
|
|
179
225
|
text: pending.text
|
|
@@ -215,6 +261,7 @@ const createCanonicalComposition = (options) => {
|
|
|
215
261
|
},
|
|
216
262
|
matchesCancellationRange: (view, range) => {
|
|
217
263
|
if (state.type === "committed" || state.view !== view) return false;
|
|
264
|
+
if (state.type === "refused") return true;
|
|
218
265
|
const text = selectedText(state.baseline, view.state);
|
|
219
266
|
if (text === null || text.length === 0) return false;
|
|
220
267
|
const from = state.baseline.selection.from;
|
|
@@ -226,8 +273,13 @@ const createCanonicalComposition = (options) => {
|
|
|
226
273
|
return view.posAtDOM(selected.startContainer, selected.startOffset) === range.from && view.posAtDOM(selected.endContainer, selected.endOffset) === range.to;
|
|
227
274
|
},
|
|
228
275
|
start: (view) => {
|
|
276
|
+
if (state.type === "provisional" && state.phase.type === "active" && acceptedUpdate) restarted = true;
|
|
229
277
|
if (state.type !== "committed") return;
|
|
230
278
|
if (!options.begin()) return;
|
|
279
|
+
restarted = false;
|
|
280
|
+
acceptedUpdate = false;
|
|
281
|
+
explicitFinal = null;
|
|
282
|
+
if (!view.state.selection.empty) authorizedNativeState = view.state;
|
|
231
283
|
state = {
|
|
232
284
|
type: "provisional",
|
|
233
285
|
baseline: view.state,
|
|
@@ -287,7 +339,8 @@ const createCanonicalComposition = (options) => {
|
|
|
287
339
|
};
|
|
288
340
|
return true;
|
|
289
341
|
},
|
|
290
|
-
authorizeNative: (view, completion) => {
|
|
342
|
+
authorizeNative: (view, completion, finalText) => {
|
|
343
|
+
if (completion === "explicitFinal" && typeof finalText === "string") explicitFinal = finalText;
|
|
291
344
|
authorizedNativeState = view.state;
|
|
292
345
|
if (state.type !== "committed" && completion === "explicitFinal") state.phase = state.phase.type === "active" ? {
|
|
293
346
|
type: "active",
|
|
@@ -359,6 +412,10 @@ const createCanonicalComposition = (options) => {
|
|
|
359
412
|
view.updateState(state.baseline);
|
|
360
413
|
return true;
|
|
361
414
|
}
|
|
415
|
+
if (restarted) {
|
|
416
|
+
view.updateState(state.baseline);
|
|
417
|
+
return true;
|
|
418
|
+
}
|
|
362
419
|
if (typeof transaction.getMeta("composition") !== "number" && authorizedNativeState !== view.state) {
|
|
363
420
|
options.refuse("Other edits must wait until composition finishes.");
|
|
364
421
|
return true;
|
|
@@ -389,6 +446,7 @@ const createCanonicalComposition = (options) => {
|
|
|
389
446
|
options.refuse("Composition changed unsupported content; the canonical document was restored.");
|
|
390
447
|
return true;
|
|
391
448
|
}
|
|
449
|
+
acceptedUpdate = true;
|
|
392
450
|
view.updateState(applied.value.state);
|
|
393
451
|
return true;
|
|
394
452
|
}
|
|
@@ -25,7 +25,6 @@ type CanonicalInputOptions = {
|
|
|
25
25
|
redo: () => boolean;
|
|
26
26
|
refuse: (reason: string) => void;
|
|
27
27
|
};
|
|
28
|
-
/** Native changes require a preceding, classified input event at the same state. */
|
|
29
28
|
export declare const createCanonicalInputBoundary: (options: CanonicalInputOptions) => {
|
|
30
29
|
reset: () => void;
|
|
31
30
|
readonly isComposing: boolean;
|
|
@@ -11,6 +11,23 @@ const CANONICAL_COMPOSITION_INPUT_TYPES = [
|
|
|
11
11
|
"deleteByComposition"
|
|
12
12
|
];
|
|
13
13
|
/** Native changes require a preceding, classified input event at the same state. */
|
|
14
|
+
/**
|
|
15
|
+
* ProseMirror treats the end of one text node and the start of the next run as
|
|
16
|
+
* one position, so it leaves whichever the browser holds. Chromium's IME can
|
|
17
|
+
* resolve that caret against the start of the document, even when it reports the
|
|
18
|
+
* right node, until the selection is set again. A composition starts where the
|
|
19
|
+
* model's caret is: in the text before it, or at a paragraph's start in the first.
|
|
20
|
+
*/
|
|
21
|
+
const placeCompositionCaret = (view) => {
|
|
22
|
+
const { selection } = view.state;
|
|
23
|
+
const native = view.dom.ownerDocument.getSelection();
|
|
24
|
+
if (!selection.empty || !native?.isCollapsed) return;
|
|
25
|
+
const before = view.domAtPos(selection.from, -1);
|
|
26
|
+
const { node, offset } = before.node.nodeType === before.node.TEXT_NODE ? before : view.domAtPos(selection.from, 1);
|
|
27
|
+
if (node.nodeType !== node.TEXT_NODE) return;
|
|
28
|
+
native.removeAllRanges();
|
|
29
|
+
native.collapse(node, offset);
|
|
30
|
+
};
|
|
14
31
|
const createCanonicalInputBoundary = (options) => {
|
|
15
32
|
const composition = createCanonicalComposition({
|
|
16
33
|
begin: () => options.beginComposition?.() ?? true,
|
|
@@ -205,6 +222,7 @@ const createCanonicalInputBoundary = (options) => {
|
|
|
205
222
|
compositionstart: (view) => {
|
|
206
223
|
beginGesture();
|
|
207
224
|
composition.start(view);
|
|
225
|
+
placeCompositionCaret(view);
|
|
208
226
|
return false;
|
|
209
227
|
},
|
|
210
228
|
compositionend: (view, event) => {
|
|
@@ -246,7 +264,7 @@ const createCanonicalInputBoundary = (options) => {
|
|
|
246
264
|
}
|
|
247
265
|
const nativeFinal = view.composing && (event.inputType === "insertText" || event.inputType === "insertReplacementText");
|
|
248
266
|
const nativeStillComposing = view.composing;
|
|
249
|
-
if (nativeFinal) composition.authorizeNative(view, "explicitFinal");
|
|
267
|
+
if (nativeFinal) composition.authorizeNative(view, "explicitFinal", event.data);
|
|
250
268
|
const recovered = composition.recover(view);
|
|
251
269
|
composition.forgetCompleted();
|
|
252
270
|
proposal = { type: "idle" };
|
|
@@ -967,8 +967,7 @@ var CanonicalSession = class {
|
|
|
967
967
|
const second = secondGroup?.paragraphs.at(0);
|
|
968
968
|
if (!first?.paraId || !second?.paraId) return noChange("There is no adjacent paragraph to join.");
|
|
969
969
|
if (this.projection.paragraph(first.paraId)?.container !== this.projection.paragraph(second.paraId)?.container) return noChange("There is no adjacent paragraph to join.");
|
|
970
|
-
|
|
971
|
-
if (current === void 0 || at.value.offset !== (direction === "backward" ? 0 : current.text.length)) return refuse("Join requires a caret at a paragraph boundary.");
|
|
970
|
+
if (!isCanonicalJoinBoundary(state, direction)) return refuse("Join requires a caret at a paragraph boundary.");
|
|
972
971
|
return this.prepareIntent(state, {
|
|
973
972
|
type: "joinParagraphs",
|
|
974
973
|
story: at.value.story,
|
|
@@ -75,6 +75,12 @@ export type HiddenEditorManagerDeps = {
|
|
|
75
75
|
/** Document context for the API's `getDocument` (PM state -> Document). */
|
|
76
76
|
getDocumentContext: () => document_d_exports.Document | null;
|
|
77
77
|
onTransaction: (update: HiddenEditorTransactionUpdate) => void;
|
|
78
|
+
/**
|
|
79
|
+
* A canonical composition ended. A layout pass reads the live view, so one
|
|
80
|
+
* that ran during the composition painted provisional text that only a new
|
|
81
|
+
* pass can replace, and a cancellation publishes no commit that would ask.
|
|
82
|
+
*/
|
|
83
|
+
onCanonicalCompositionEnd: () => void;
|
|
78
84
|
onSelectionChange: (state: EditorState) => void;
|
|
79
85
|
onKeyDown: (view: EditorView, event: KeyboardEvent) => boolean;
|
|
80
86
|
onCopy?: () => void;
|
|
@@ -467,7 +467,9 @@ const createHiddenEditorManager = (deps) => {
|
|
|
467
467
|
return true;
|
|
468
468
|
},
|
|
469
469
|
endComposition: () => {
|
|
470
|
-
if (editorSession.type
|
|
470
|
+
if (editorSession.type !== "canonical") return;
|
|
471
|
+
editorSession.session.endComposition();
|
|
472
|
+
deps.onCanonicalCompositionEnd();
|
|
471
473
|
}
|
|
472
474
|
};
|
|
473
475
|
const input = createCanonicalInputBoundary({
|
|
@@ -80,5 +80,7 @@ export type LayoutPipelineDeps<THfPMs> = {
|
|
|
80
80
|
markupView: DisplayMode;
|
|
81
81
|
/** Independent highlight visibility in All Markup; resolved views always hide comments. */
|
|
82
82
|
showCommentHighlights?: boolean;
|
|
83
|
+
/** Localised text for a `w:altChunk` that has no text of its own to show. */
|
|
84
|
+
altChunkMarkerText?: string;
|
|
83
85
|
};
|
|
84
86
|
export declare function runLayoutPipeline<THfPMs>(deps: LayoutPipelineDeps<THfPMs>, state: EditorState, options?: LayoutRunOptions): LayoutOutcome;
|
|
@@ -45,7 +45,7 @@ const formatEndnoteTexts = (numbers, formatNumber) => {
|
|
|
45
45
|
for (const [id, displayNumber] of numbers) texts.set(id, formatNumber(displayNumber));
|
|
46
46
|
return texts;
|
|
47
47
|
};
|
|
48
|
-
const sameMeasureInputs = (left, right) => left.embeddedFontFamilyMap === right.embeddedFontFamilyMap && left.documentFontFactsCacheIdentity === right.documentFontFactsCacheIdentity && left.styles === right.styles && left.theme === right.theme && left.defaultTabStop === right.defaultTabStop && left.pageContentHeight === right.pageContentHeight && left.fontSet === right.fontSet && left.fontAlternates.size === right.fontAlternates.size && [...left.fontAlternates].every(([name, alternate]) => right.fontAlternates.get(name) === alternate) && left.markupView === right.markupView && left.showCommentHighlights === right.showCommentHighlights;
|
|
48
|
+
const sameMeasureInputs = (left, right) => left.embeddedFontFamilyMap === right.embeddedFontFamilyMap && left.documentFontFactsCacheIdentity === right.documentFontFactsCacheIdentity && left.styles === right.styles && left.theme === right.theme && left.defaultTabStop === right.defaultTabStop && left.pageContentHeight === right.pageContentHeight && left.fontSet === right.fontSet && left.fontAlternates.size === right.fontAlternates.size && [...left.fontAlternates].every(([name, alternate]) => right.fontAlternates.get(name) === alternate) && left.markupView === right.markupView && left.showCommentHighlights === right.showCommentHighlights && left.altChunkMarkerText === right.altChunkMarkerText;
|
|
49
49
|
/**
|
|
50
50
|
* The range an incremental pass re-measures, or `null` for a full measure: the
|
|
51
51
|
* committed measures must come from the same measure inputs, and the range is
|
|
@@ -139,7 +139,7 @@ function runLayoutPipeline(deps, state, options = {}) {
|
|
|
139
139
|
return result;
|
|
140
140
|
}
|
|
141
141
|
function runLayoutPipelineMeasured(deps, state, options) {
|
|
142
|
-
const { contentWidth, columns, pageSize, margins, pageGap, showMarginGuides, marginGuideColor, syncCoordinator, headerContent, footerContent, firstPageHeaderContent, firstPageFooterContent, headerContentRId, footerContentRId, firstPageHeaderContentRId, firstPageFooterContentRId, sectionHeaderFooterRefs, theme: _theme, sectionProperties, document, defaultTabStop, mirrorMargins, styles, layout, hfPMs, painter, pagesContainer, session, renderHfFromContentOrPm, renderHeaderFooterContentByRId, readFontSetSignature, buildFootnoteRenderItems, describeInvalidHighlightMarks, pageRenderer = PAGE_RENDERER.legacy, emptyTemplatePreviewEntries: EMPTY_TEMPLATE_PREVIEW_ENTRIES, emptyTemplatePreviewHidden: EMPTY_TEMPLATE_PREVIEW_HIDDEN, markupView, showCommentHighlights = true } = deps;
|
|
142
|
+
const { contentWidth, columns, pageSize, margins, pageGap, showMarginGuides, marginGuideColor, syncCoordinator, headerContent, footerContent, firstPageHeaderContent, firstPageFooterContent, headerContentRId, footerContentRId, firstPageHeaderContentRId, firstPageFooterContentRId, sectionHeaderFooterRefs, theme: _theme, sectionProperties, document, defaultTabStop, mirrorMargins, styles, layout, hfPMs, painter, pagesContainer, session, renderHfFromContentOrPm, renderHeaderFooterContentByRId, readFontSetSignature, buildFootnoteRenderItems, describeInvalidHighlightMarks, pageRenderer = PAGE_RENDERER.legacy, emptyTemplatePreviewEntries: EMPTY_TEMPLATE_PREVIEW_ENTRIES, emptyTemplatePreviewHidden: EMPTY_TEMPLATE_PREVIEW_HIDDEN, markupView, showCommentHighlights = true, altChunkMarkerText } = deps;
|
|
143
143
|
let outcome = {};
|
|
144
144
|
let pendingArtifacts;
|
|
145
145
|
let pendingTemplatePreview;
|
|
@@ -170,10 +170,12 @@ function runLayoutPipelineMeasured(deps, state, options) {
|
|
|
170
170
|
fontSet,
|
|
171
171
|
fontAlternates,
|
|
172
172
|
markupView,
|
|
173
|
-
showCommentHighlights: displayCommentHighlights
|
|
173
|
+
showCommentHighlights: displayCommentHighlights,
|
|
174
|
+
...altChunkMarkerText === void 0 ? {} : { altChunkMarkerText }
|
|
174
175
|
};
|
|
175
176
|
const flowOpts = {
|
|
176
177
|
showCommentHighlights: displayCommentHighlights,
|
|
178
|
+
...altChunkMarkerText === void 0 ? {} : { altChunkMarkerText },
|
|
177
179
|
...embeddedFontFamilies,
|
|
178
180
|
...documentFontFacts === void 0 ? {} : { documentFontFacts },
|
|
179
181
|
pageContentHeight,
|
|
@@ -258,6 +260,7 @@ function runLayoutPipelineMeasured(deps, state, options) {
|
|
|
258
260
|
return {
|
|
259
261
|
markupView,
|
|
260
262
|
showCommentHighlights: displayCommentHighlights,
|
|
263
|
+
...altChunkMarkerText === void 0 ? {} : { altChunkMarkerText },
|
|
261
264
|
...flowOpts.styles ? { styles: flowOpts.styles } : {},
|
|
262
265
|
...document?.package.numbering === void 0 ? {} : { numbering: document.package.numbering },
|
|
263
266
|
...flowOpts.defaultSize === void 0 ? {} : { defaultSize: flowOpts.defaultSize },
|
|
@@ -394,6 +397,7 @@ function runLayoutPipelineMeasured(deps, state, options) {
|
|
|
394
397
|
const noteOptions = {
|
|
395
398
|
measureBlocks,
|
|
396
399
|
showCommentHighlights: displayCommentHighlights,
|
|
400
|
+
...altChunkMarkerText === void 0 ? {} : { altChunkMarkerText },
|
|
397
401
|
markupView
|
|
398
402
|
};
|
|
399
403
|
if (flowOpts.styles) noteOptions.styles = flowOpts.styles;
|
|
@@ -37,6 +37,7 @@ export type LayoutMeasureInputs = {
|
|
|
37
37
|
/** The review view: each lays out different text, so a measure is reusable only within one. */
|
|
38
38
|
markupView: DisplayMode;
|
|
39
39
|
showCommentHighlights?: boolean;
|
|
40
|
+
altChunkMarkerText?: string;
|
|
40
41
|
};
|
|
41
42
|
export type LayoutSession = {
|
|
42
43
|
embeddedFontFamilyMap?: ReadonlyMap<string, string>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { TableBlock, TableFragment, TableMeasure, TextBoxBlock, TextBoxFragment, TextBoxMeasure } from "../../layout-engine/types.js";
|
|
2
|
+
import { VisibleBand } from "../../layout-engine/measure/tableVisibleBand.js";
|
|
2
3
|
import { BuildContext } from "./buildContext.js";
|
|
3
4
|
import { PageComposer } from "./regions.js";
|
|
4
5
|
type PaintTextBox = (options: {
|
|
@@ -16,9 +17,10 @@ export type TableBlockPaintOptions = {
|
|
|
16
17
|
readonly yPx: number;
|
|
17
18
|
readonly context: BuildContext;
|
|
18
19
|
readonly paintTextBox: PaintTextBox;
|
|
20
|
+
readonly visibleBand?: VisibleBand | undefined;
|
|
19
21
|
};
|
|
20
22
|
/** A whole, unpaginated table: what a nested table inside a cell or box is. */
|
|
21
|
-
export declare const paintTableBlock: ({ composer, block, measure, xPx, yPx, context, paintTextBox }: TableBlockPaintOptions) => void;
|
|
23
|
+
export declare const paintTableBlock: ({ composer, block, measure, xPx, yPx, context, paintTextBox, visibleBand }: TableBlockPaintOptions) => void;
|
|
22
24
|
export type TablePaintOptions = {
|
|
23
25
|
readonly composer: PageComposer;
|
|
24
26
|
readonly fragment: TableFragment;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createTableCellFlowState, placeTableCellBlock } from "../../layout-engine/measure/tableCellFlow.js";
|
|
2
2
|
import { buildTableCellGrid, buildTableCellPlacements, getSourceCellAt, getTableCellSpacingInsetsY } from "../../layout-engine/measure/tableCellGrid.js";
|
|
3
3
|
import { tableFragmentBottomBorders } from "../../layout-engine/measure/tableFragmentBorderGeometry.js";
|
|
4
|
+
import { isOutsideBand, tableHasFloatingCellContent, tableRowPaintBottom } from "../../layout-engine/measure/tableVisibleBand.js";
|
|
4
5
|
import { resolveTableCellPadding } from "../../layout-engine/types.js";
|
|
5
6
|
import { cellTextRotationDegrees } from "../../layout-painter/renderTable.js";
|
|
6
7
|
import { paintsCssBorder } from "../../utils/borderCss.js";
|
|
@@ -35,7 +36,7 @@ const strokeFor = (border, context, label) => {
|
|
|
35
36
|
if (unresolvedColor !== void 0) context.unsupported.report(UNSUPPORTED_CONSTRUCT.unresolvedColor, context.pageIndex, `${label} colour ${unresolvedColor}`);
|
|
36
37
|
return stroke;
|
|
37
38
|
};
|
|
38
|
-
const paintCell = ({ composer, cell, cellMeasure, box, context, paintTextBox, sides }) => {
|
|
39
|
+
const paintCell = ({ composer, cell, cellMeasure, box, context, paintTextBox, visibleBand, sides }) => {
|
|
39
40
|
const primitives = [];
|
|
40
41
|
if (cell.background) {
|
|
41
42
|
const fill = parseDisplayColor(cell.background);
|
|
@@ -119,7 +120,8 @@ const paintCell = ({ composer, cell, cellMeasure, box, context, paintTextBox, si
|
|
|
119
120
|
widthPx: contentWidthPx,
|
|
120
121
|
inlinePictureViewport: cellPictureViewport,
|
|
121
122
|
context,
|
|
122
|
-
paintTextBox
|
|
123
|
+
paintTextBox,
|
|
124
|
+
visibleBand
|
|
123
125
|
});
|
|
124
126
|
const diagonals = [{
|
|
125
127
|
border: borders?.topLeftToBottomRight,
|
|
@@ -146,7 +148,7 @@ const paintCell = ({ composer, cell, cellMeasure, box, context, paintTextBox, si
|
|
|
146
148
|
* A cell's inner blocks, stacked by the same flow state the measurer used, so
|
|
147
149
|
* paragraph spacing collapses in paint exactly where it collapsed in layout.
|
|
148
150
|
*/
|
|
149
|
-
const paintCellBlocks = ({ composer, blocks, measures, xPx, yPx, widthPx, inlinePictureViewport, context, paintTextBox }) => {
|
|
151
|
+
const paintCellBlocks = ({ composer, blocks, measures, xPx, yPx, widthPx, inlinePictureViewport, context, paintTextBox, visibleBand }) => {
|
|
150
152
|
const flowState = createTableCellFlowState();
|
|
151
153
|
for (let index = 0; index < blocks.length; index += 1) {
|
|
152
154
|
const block = blocks[index];
|
|
@@ -156,6 +158,7 @@ const paintCellBlocks = ({ composer, blocks, measures, xPx, yPx, widthPx, inline
|
|
|
156
158
|
continue;
|
|
157
159
|
}
|
|
158
160
|
const placement = placeTableCellBlock(flowState, block, measure);
|
|
161
|
+
if (block.kind === "table" && isOutsideBand(visibleBand, yPx + placement.top, yPx + placement.contentTop + placement.contentHeight)) continue;
|
|
159
162
|
if (block.kind === "paragraph" && measure.kind === "paragraph") {
|
|
160
163
|
const previous = blocks[index - 1];
|
|
161
164
|
const next = blocks[index + 1];
|
|
@@ -210,7 +213,8 @@ const paintCellBlocks = ({ composer, blocks, measures, xPx, yPx, widthPx, inline
|
|
|
210
213
|
...context,
|
|
211
214
|
inlinePictureViewport
|
|
212
215
|
},
|
|
213
|
-
paintTextBox
|
|
216
|
+
paintTextBox,
|
|
217
|
+
visibleBand
|
|
214
218
|
});
|
|
215
219
|
});
|
|
216
220
|
continue;
|
|
@@ -261,7 +265,7 @@ const paintCellBlocks = ({ composer, blocks, measures, xPx, yPx, widthPx, inline
|
|
|
261
265
|
}
|
|
262
266
|
};
|
|
263
267
|
const rowIsPainted = (row) => row !== void 0 && row.hidden !== true;
|
|
264
|
-
const paintTableBody = ({ composer, block, measure, xPx, yPx, fromRow, toRow, headerRowCount, context, paintTextBox }) => {
|
|
268
|
+
const paintTableBody = ({ composer, block, measure, xPx, yPx, fromRow, toRow, headerRowCount, context, paintTextBox, visibleBand }) => {
|
|
265
269
|
const grid = buildTableCellGrid(block.rows, measure.columnWidths.length);
|
|
266
270
|
const placements = buildTableCellPlacements({
|
|
267
271
|
grid,
|
|
@@ -272,10 +276,14 @@ const paintTableBody = ({ composer, block, measure, xPx, yPx, fromRow, toRow, he
|
|
|
272
276
|
const bordersSeparated = (block.cellSpacing ?? 0) > 0;
|
|
273
277
|
const rowTops = [0];
|
|
274
278
|
for (const rowMeasure of measure.rows) rowTops.push((rowTops.at(-1) ?? 0) + rowMeasure.height);
|
|
279
|
+
let firstShownRow;
|
|
275
280
|
const paintRow = (rowIndex, rowYPx) => {
|
|
276
281
|
const row = block.rows[rowIndex];
|
|
277
282
|
const rowMeasure = measure.rows[rowIndex];
|
|
278
283
|
if (!rowIsPainted(row) || !rowMeasure) return;
|
|
284
|
+
const rowTop = rowTops[rowIndex] ?? 0;
|
|
285
|
+
if (isOutsideBand(visibleBand, rowYPx, rowYPx + tableRowPaintBottom(row, rowIndex, rowTops) - rowTop)) return;
|
|
286
|
+
firstShownRow ??= rowIndex;
|
|
279
287
|
composer.region({
|
|
280
288
|
kind: HIT_REGION_KINDS.tableRow,
|
|
281
289
|
rect: {
|
|
@@ -290,6 +298,7 @@ const paintTableBody = ({ composer, block, measure, xPx, yPx, fromRow, toRow, he
|
|
|
290
298
|
});
|
|
291
299
|
};
|
|
292
300
|
const paintRowCells = (row, rowMeasure, rowIndex, rowYPx) => {
|
|
301
|
+
const opensContinuation = visibleBand !== void 0 && rowIndex === firstShownRow && rowYPx >= visibleBand.top;
|
|
293
302
|
for (let cellIndex = 0; cellIndex < row.cells.length; cellIndex += 1) {
|
|
294
303
|
const cell = row.cells[cellIndex];
|
|
295
304
|
const cellMeasure = rowMeasure.cells[cellIndex];
|
|
@@ -328,8 +337,9 @@ const paintTableBody = ({ composer, block, measure, xPx, yPx, fromRow, toRow, he
|
|
|
328
337
|
box,
|
|
329
338
|
context,
|
|
330
339
|
paintTextBox,
|
|
340
|
+
visibleBand,
|
|
331
341
|
sides: {
|
|
332
|
-
top: bordersSeparated || rowIndex === fromRow || !hasVisibleBorder(aboveCell?.borders?.bottom),
|
|
342
|
+
top: bordersSeparated || rowIndex === fromRow || opensContinuation || !hasVisibleBorder(aboveCell?.borders?.bottom),
|
|
333
343
|
bottom: true,
|
|
334
344
|
left: bordersSeparated || isFirstColumn || !hasVisibleBorder(leftCell?.borders?.right),
|
|
335
345
|
right: true
|
|
@@ -375,7 +385,7 @@ const paintFragmentBottomBorders = ({ composer, fragment, block, measure, contex
|
|
|
375
385
|
composer.push(primitives);
|
|
376
386
|
};
|
|
377
387
|
/** A whole, unpaginated table: what a nested table inside a cell or box is. */
|
|
378
|
-
const paintTableBlock = ({ composer, block, measure, xPx, yPx, context, paintTextBox }) => paintTableBody({
|
|
388
|
+
const paintTableBlock = ({ composer, block, measure, xPx, yPx, context, paintTextBox, visibleBand }) => paintTableBody({
|
|
379
389
|
composer,
|
|
380
390
|
block,
|
|
381
391
|
measure,
|
|
@@ -385,7 +395,8 @@ const paintTableBlock = ({ composer, block, measure, xPx, yPx, context, paintTex
|
|
|
385
395
|
toRow: block.rows.length,
|
|
386
396
|
headerRowCount: 0,
|
|
387
397
|
context,
|
|
388
|
-
paintTextBox
|
|
398
|
+
paintTextBox,
|
|
399
|
+
visibleBand
|
|
389
400
|
});
|
|
390
401
|
/**
|
|
391
402
|
* A table fragment's primitives. A fragment that cuts a row mid-content wraps
|
|
@@ -408,11 +419,12 @@ const paintTableFragment = ({ composer, fragment, block, measure, context, paint
|
|
|
408
419
|
toRow: 0,
|
|
409
420
|
headerRowCount,
|
|
410
421
|
context,
|
|
411
|
-
paintTextBox
|
|
422
|
+
paintTextBox,
|
|
423
|
+
visibleBand: void 0
|
|
412
424
|
});
|
|
413
425
|
};
|
|
414
426
|
const topClipPx = fragment.topClip ?? 0;
|
|
415
|
-
const paintBody = (into) => {
|
|
427
|
+
const paintBody = (into, visibleBand) => {
|
|
416
428
|
paintTableBody({
|
|
417
429
|
composer: into,
|
|
418
430
|
block,
|
|
@@ -423,7 +435,8 @@ const paintTableFragment = ({ composer, fragment, block, measure, context, paint
|
|
|
423
435
|
toRow: fragment.toRow,
|
|
424
436
|
headerRowCount: 0,
|
|
425
437
|
context,
|
|
426
|
-
paintTextBox
|
|
438
|
+
paintTextBox,
|
|
439
|
+
visibleBand
|
|
427
440
|
});
|
|
428
441
|
};
|
|
429
442
|
if (fragment.topClip === void 0 && fragment.bottomClip === void 0) {
|
|
@@ -432,14 +445,17 @@ const paintTableFragment = ({ composer, fragment, block, measure, context, paint
|
|
|
432
445
|
return;
|
|
433
446
|
}
|
|
434
447
|
paintHeaders(composer);
|
|
435
|
-
const clipped = createPageComposer();
|
|
436
|
-
paintBody(clipped);
|
|
437
448
|
const clip = {
|
|
438
449
|
xPx: fragment.x,
|
|
439
450
|
yPx: fragment.y + headerHeightPx,
|
|
440
451
|
widthPx: fragment.width,
|
|
441
452
|
heightPx: Math.max(0, fragment.height - headerHeightPx)
|
|
442
453
|
};
|
|
454
|
+
const clipped = createPageComposer();
|
|
455
|
+
paintBody(clipped, tableHasFloatingCellContent(block) ? void 0 : {
|
|
456
|
+
top: clip.yPx,
|
|
457
|
+
bottom: clip.yPx + clip.heightPx
|
|
458
|
+
});
|
|
443
459
|
composer.push([{
|
|
444
460
|
kind: "clipGroup",
|
|
445
461
|
rect: clip,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { NumberingIdsInUse } from "./docx/numberingIds.js";
|
|
1
2
|
import { document_d_exports } from "./types/document.js";
|
|
2
3
|
import { FolioTableTemplates } from "./ai-edits/table-template.js";
|
|
3
4
|
import { FolioAIEditAppliedOperation, FolioAIEditApplyMode, FolioAIEditNormalization, FolioAIEditOperation, FolioAIEditPrecondition, FolioAIEditSkippedOperation, FolioAIEditSnapshot, FolioAITextRangeHandle } from "./ai-edits/types.js";
|
|
@@ -313,5 +314,16 @@ export type ApplyFolioDocumentOperationsOptions = {
|
|
|
313
314
|
*/
|
|
314
315
|
restagesSuggestions?: boolean;
|
|
315
316
|
};
|
|
316
|
-
export declare const applyFolioDocumentOperations: (
|
|
317
|
+
export declare const applyFolioDocumentOperations: (input: ApplyFolioDocumentOperationsOptions) => FolioDocumentOperationResult;
|
|
318
|
+
/**
|
|
319
|
+
* Options of a caller that holds every story of the package: the numbering
|
|
320
|
+
* ids (`w:num`, `w:abstractNum`) the other stories define. A list the batch
|
|
321
|
+
* starts takes none of them, so its id names it in every story and survives a
|
|
322
|
+
* save.
|
|
323
|
+
*/
|
|
324
|
+
type ApplyFolioDocumentOperationsInPackageOptions = ApplyFolioDocumentOperationsOptions & {
|
|
325
|
+
numberingIdsElsewhere: NumberingIdsInUse;
|
|
326
|
+
};
|
|
327
|
+
/** {@link applyFolioDocumentOperations} for a caller holding every story. Internal. */
|
|
328
|
+
export declare const applyFolioDocumentOperationsInPackage: ({ view, snapshot, batch, story, author, createCommentId, createUndoHandle, revisionStamp, wordDiff, tableTemplates, replacementBackground, undefinedReferences, pendingSuggestionIds, numberingIdsElsewhere, restagesSuggestions }: ApplyFolioDocumentOperationsInPackageOptions) => FolioDocumentOperationResult;
|
|
317
329
|
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { applyFolioAIEditOperationsInPackage, previewFolioAIEditOperationsWithResult } from "./ai-edits/apply.js";
|
|
2
2
|
import { describeModelError, findIntroducedModelErrors } from "./ai-edits/result-validation.js";
|
|
3
3
|
import { LIST_KINDS } from "./docx/listNumberingInstances.js";
|
|
4
|
+
import { NO_NUMBERING_IDS_IN_USE } from "./docx/numberingIds.js";
|
|
4
5
|
import { getSuggestions } from "./prosemirror/commands/comments.js";
|
|
5
6
|
import { completeNumberingForDoc } from "./prosemirror/listInstanceReferences.js";
|
|
6
7
|
import { outlineLevelFromAttrValue } from "./prosemirror/outlineLevelAttr.js";
|
|
@@ -1290,7 +1291,12 @@ const inOperationOrder = (operations, skipped) => {
|
|
|
1290
1291
|
const indexById = new Map(operations.map(({ id }, index) => [id, index]));
|
|
1291
1292
|
return [...skipped].sort((left, right) => (indexById.get(left.id) ?? -1) - (indexById.get(right.id) ?? -1));
|
|
1292
1293
|
};
|
|
1293
|
-
const applyFolioDocumentOperations = (
|
|
1294
|
+
const applyFolioDocumentOperations = (input) => applyFolioDocumentOperationsInPackage({
|
|
1295
|
+
...input,
|
|
1296
|
+
numberingIdsElsewhere: NO_NUMBERING_IDS_IN_USE
|
|
1297
|
+
});
|
|
1298
|
+
/** {@link applyFolioDocumentOperations} for a caller holding every story. Internal. */
|
|
1299
|
+
const applyFolioDocumentOperationsInPackage = ({ view, snapshot, batch, story = "main", author, createCommentId, createUndoHandle, revisionStamp, wordDiff, tableTemplates, replacementBackground, undefinedReferences, pendingSuggestionIds, numberingIdsElsewhere, restagesSuggestions }) => {
|
|
1294
1300
|
const validatedBatch = parseFolioDocumentOperationBatch(batch);
|
|
1295
1301
|
const parsedBatch = restagesSuggestions === true ? validatedBatch : withDistinctSuggestionIds(validatedBatch, /* @__PURE__ */ new Set([...getSuggestions(view.state).map(({ suggestionId }) => suggestionId), ...pendingSuggestionIds ?? []]));
|
|
1296
1302
|
const isAtomic = parsedBatch.atomic === true;
|
|
@@ -1306,6 +1312,7 @@ const applyFolioDocumentOperations = ({ view, snapshot, batch, story = "main", a
|
|
|
1306
1312
|
...wordDiff !== void 0 && { wordDiff },
|
|
1307
1313
|
...tableTemplates !== void 0 && { tableTemplates },
|
|
1308
1314
|
...replacementBackground !== void 0 && { replacementBackground },
|
|
1315
|
+
numberingIdsElsewhere,
|
|
1309
1316
|
undefinedReferences
|
|
1310
1317
|
};
|
|
1311
1318
|
if (preview) return {
|
|
@@ -1319,7 +1326,7 @@ const applyFolioDocumentOperations = ({ view, snapshot, batch, story = "main", a
|
|
|
1319
1326
|
const held = {};
|
|
1320
1327
|
const commentIds = [];
|
|
1321
1328
|
return {
|
|
1322
|
-
outcome:
|
|
1329
|
+
outcome: applyFolioAIEditOperationsInPackage({
|
|
1323
1330
|
...common,
|
|
1324
1331
|
view: {
|
|
1325
1332
|
state: view.state,
|
|
@@ -1510,4 +1517,4 @@ const applyFolioDocumentOperations = ({ view, snapshot, batch, story = "main", a
|
|
|
1510
1517
|
undoHandle: result.applied.length > 0 && createUndoHandle !== void 0 ? createUndoHandle() : null
|
|
1511
1518
|
};
|
|
1512
1519
|
};
|
|
1513
|
-
export { FOLIO_DOCUMENT_OPERATION_BATCH_MODES, FOLIO_DOCUMENT_OPERATION_BATCH_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FOLIO_DOCUMENT_OPERATION_KEYS_BY_TYPE, 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_PAGE_BREAK_CLEAR_VALUES, FOLIO_PARAGRAPH_ALIGNMENT_VALUES, InvalidFolioDocumentOperationBatchError, UnsupportedFolioDocumentOperationVersionError, applyFolioDocumentOperations, assertSupportedFolioDocumentOperationVersion, getFolioDocumentOperationCapabilities, getFolioDocumentOperationIssues, getFolioDocumentOperationReceipts, getFolioDocumentOperationReceiptsForStory, isFolioDocumentOperationModeSupported, isSupportedFolioDocumentOperationVersion, parseFolioDocumentOperationBatch };
|
|
1520
|
+
export { FOLIO_DOCUMENT_OPERATION_BATCH_MODES, FOLIO_DOCUMENT_OPERATION_BATCH_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FOLIO_DOCUMENT_OPERATION_KEYS_BY_TYPE, 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_PAGE_BREAK_CLEAR_VALUES, FOLIO_PARAGRAPH_ALIGNMENT_VALUES, InvalidFolioDocumentOperationBatchError, UnsupportedFolioDocumentOperationVersionError, applyFolioDocumentOperations, applyFolioDocumentOperationsInPackage, assertSupportedFolioDocumentOperationVersion, getFolioDocumentOperationCapabilities, getFolioDocumentOperationIssues, getFolioDocumentOperationReceipts, getFolioDocumentOperationReceiptsForStory, isFolioDocumentOperationModeSupported, isSupportedFolioDocumentOperationVersion, parseFolioDocumentOperationBatch };
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { document_d_exports } from "../types/document.js";
|
|
2
2
|
import { XmlElement } from "./xmlParser.js";
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* Describe a chart: the marks of a supported cached chart, or an empty frame of
|
|
5
|
+
* the same size. AlternateContent fallbacks are resolved by the run parser.
|
|
6
|
+
*/
|
|
4
7
|
export declare const parseChartPreview: (drawing: XmlElement, rels?: document_d_exports.RelationshipMap, media?: Map<string, document_d_exports.MediaFile>) => document_d_exports.Image | null;
|