@stll/folio-core 0.67.0 → 0.68.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 +9 -1
- package/dist/ai-edits/apply.js +94 -8
- package/dist/ai-edits/headless.d.ts +36 -21
- package/dist/ai-edits/headless.js +104 -34
- package/dist/ai-edits/index.d.ts +2 -2
- package/dist/ai-edits/note-references.d.ts +6 -0
- package/dist/ai-edits/note-references.js +7 -1
- package/dist/ai-edits/read.d.ts +19 -0
- package/dist/ai-edits/snapshot.d.ts +6 -0
- package/dist/ai-edits/snapshot.js +8 -3
- package/dist/ai-edits/types.d.ts +9 -1
- package/dist/ai-suggestions/apply.js +13 -4
- package/dist/compare/compare.js +2 -1
- package/dist/compare/inserted-resource-snapshot.d.ts +4 -1
- package/dist/compare/inserted-resource-snapshot.js +7 -3
- package/dist/controller/canonicalClipboard.js +29 -12
- package/dist/controller/canonicalComposition.js +1 -1
- package/dist/controller/canonicalInlineProjection.d.ts +35 -10
- package/dist/controller/canonicalInlineProjection.js +192 -28
- package/dist/controller/canonicalInput.d.ts +2 -1
- package/dist/controller/canonicalInput.js +28 -1
- package/dist/controller/canonicalListRendering.d.ts +2 -1
- package/dist/controller/canonicalListRendering.js +1 -1
- package/dist/controller/canonicalLockGuard.d.ts +8 -0
- package/dist/controller/canonicalLockGuard.js +88 -0
- package/dist/controller/canonicalPublicOperations.d.ts +12 -4
- package/dist/controller/canonicalPublicOperations.js +274 -20
- package/dist/controller/canonicalSession.d.ts +87 -7
- package/dist/controller/canonicalSession.js +327 -73
- package/dist/controller/canonicalStoryEditor.d.ts +3 -2
- package/dist/controller/canonicalStoryEditor.js +4 -3
- package/dist/controller/canonicalStructure.d.ts +2 -1
- package/dist/controller/canonicalStructure.js +129 -7
- package/dist/controller/contentControlWidgetController.d.ts +5 -0
- package/dist/controller/contentControlWidgetController.js +13 -1
- package/dist/controller/folioEditor.js +1 -0
- package/dist/controller/headerFooterEditorManager.d.ts +2 -2
- package/dist/controller/headerFooterEditorManager.js +5 -5
- package/dist/controller/hiddenEditorApi.d.ts +6 -0
- package/dist/controller/hiddenEditorApi.js +1 -0
- package/dist/controller/hiddenEditorManager.d.ts +4 -3
- package/dist/controller/hiddenEditorManager.js +91 -37
- package/dist/controller/layoutPipeline.js +48 -15
- package/dist/controller/noteEditorManager.d.ts +2 -2
- package/dist/controller/noteEditorManager.js +5 -5
- package/dist/display-list/build/pageFurniture.js +41 -19
- package/dist/display-list/build/tablePrimitives.js +23 -4
- package/dist/display-list/dom/renderDisplayListToDom.js +4 -4
- package/dist/document-operations.d.ts +8 -0
- package/dist/document-operations.js +4 -3
- package/dist/docx/blockContentParser.d.ts +7 -3
- package/dist/docx/blockContentParser.js +2 -3
- package/dist/docx/blockPlainText.js +2 -0
- package/dist/docx/bookmarkRangeJoin.d.ts +6 -0
- package/dist/docx/bookmarkRangeJoin.js +43 -0
- package/dist/docx/canonicalSave.js +5 -1
- package/dist/docx/canonicalSessionInput.d.ts +5 -1
- package/dist/docx/canonicalSessionInput.js +7 -2
- package/dist/docx/commentAnchorIndex.d.ts +21 -5
- package/dist/docx/commentAnchorIndex.js +39 -11
- package/dist/docx/commentRangeIntegrity.js +30 -24
- package/dist/docx/commentRangeJoin.d.ts +4 -0
- package/dist/docx/commentRangeJoin.js +26 -12
- package/dist/docx/commentReferenceCompletion.js +5 -4
- package/dist/docx/commentReferenceNormalization.js +40 -18
- package/dist/docx/compatibility.js +9 -2
- package/dist/docx/containerChildren.js +22 -1
- package/dist/docx/encryption/compoundFile.js +9 -1
- package/dist/docx/encryption/encryptionInfo.js +16 -2
- package/dist/docx/ensureParaIds.js +46 -7
- package/dist/docx/ensureUniqueControlIds.d.ts +25 -0
- package/dist/docx/ensureUniqueControlIds.js +110 -0
- package/dist/docx/headerFooterVerbatim.d.ts +7 -0
- package/dist/docx/headerFooterVerbatim.js +13 -2
- package/dist/docx/hostCommentThreads.d.ts +17 -0
- package/dist/docx/hostCommentThreads.js +49 -0
- package/dist/docx/hyperlinkParser.js +9 -2
- package/dist/docx/inlineWrapperContent.d.ts +8 -1
- package/dist/docx/inlineWrapperContent.js +9 -2
- package/dist/docx/listMarkerComputation.d.ts +35 -1
- package/dist/docx/listMarkerComputation.js +39 -1
- package/dist/docx/listModelNormalization.d.ts +44 -1
- package/dist/docx/listModelNormalization.js +227 -96
- package/dist/docx/markupRangeMarker.d.ts +14 -0
- package/dist/docx/markupRangeMarker.js +15 -1
- package/dist/docx/metadataPrivacy.js +43 -22
- package/dist/docx/normalizeBaseDirection.js +3 -1
- package/dist/docx/paragraphParser.js +159 -48
- package/dist/docx/paragraphPropertySource.d.ts +7 -0
- package/dist/docx/paragraphPropertySource.js +22 -1
- package/dist/docx/paragraphTextBoxEnrichment.js +2 -1
- package/dist/docx/paragraphTraversal.js +2 -0
- package/dist/docx/parseWarningMessage.js +2 -1
- package/dist/docx/parser.js +6 -0
- package/dist/docx/renderedPageBreakNormalization.js +1 -1
- package/dist/docx/reviewProvenanceDiagnostics.d.ts +7 -0
- package/dist/docx/reviewProvenanceDiagnostics.js +39 -0
- package/dist/docx/reviewResolutionProvenance.d.ts +29 -3
- package/dist/docx/reviewResolutionProvenance.js +110 -25
- package/dist/docx/rezip.d.ts +6 -0
- package/dist/docx/rezip.js +38 -21
- package/dist/docx/selectiveSave.js +6 -10
- package/dist/docx/selectiveXmlPatch.d.ts +5 -4
- package/dist/docx/selectiveXmlPatch.js +11 -7
- package/dist/docx/serializer/documentSerializer.js +3 -1
- package/dist/docx/serializer/headerFooterSerializer.js +3 -1
- package/dist/docx/serializer/markupRangeAttributes.d.ts +6 -1
- package/dist/docx/serializer/markupRangeAttributes.js +6 -1
- package/dist/docx/serializer/noteSerializer.d.ts +17 -4
- package/dist/docx/serializer/noteSerializer.js +23 -16
- package/dist/docx/serializer/paragraphSerializer.js +56 -12
- package/dist/docx/serializer/runSerializer.d.ts +1 -3
- package/dist/docx/serializer/runSerializer.js +2 -2
- package/dist/docx/serializer/tableSerializer.d.ts +4 -0
- package/dist/docx/serializer/tableSerializer.js +4 -2
- package/dist/docx/server/applyDocxXmlPatchProposal.js +8 -4
- package/dist/docx/server/createBilingualDocument.js +27 -5
- package/dist/docx/server/migrateYjsAttrSchema.js +4 -0
- package/dist/docx/sessionListPruning.d.ts +2 -0
- package/dist/docx/sessionListPruning.js +50 -0
- package/dist/docx/splitRevisionPieces.d.ts +10 -0
- package/dist/docx/splitRevisionPieces.js +14 -0
- package/dist/docx/storyBlockReplay.js +4 -0
- package/dist/docx/structuralXmlPatch.js +19 -7
- package/dist/docx/tableParser.d.ts +6 -2
- package/dist/docx/tableParser.js +2 -3
- package/dist/docx/textBoxContentParser.d.ts +11 -0
- package/dist/docx/textBoxContentParser.js +51 -0
- package/dist/docx/textBoxParser.d.ts +0 -5
- package/dist/docx/textBoxParser.js +1 -23
- package/dist/docx/verticalMergeProjection.js +1 -1
- package/dist/fonts/fontsourceFaces.d.ts +2 -8
- package/dist/fonts/fontsourceFaces.js +1 -7
- 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/acceptedBlockProjection.js +2 -0
- package/dist/internal/pageBreakRunSourceDescendantIndex.d.ts +5 -0
- package/dist/internal/pageBreakRunSourceDescendantIndex.js +5 -0
- package/dist/internal/revisionResolutionInline.js +1 -2
- package/dist/layout-bridge/convert/tableConversion.js +19 -8
- package/dist/layout-bridge/engine/blockIndex.d.ts +7 -0
- package/dist/layout-bridge/engine/blockIndex.js +12 -0
- package/dist/layout-bridge/engine/hitTest.js +9 -10
- package/dist/layout-bridge/engine/selectionRects.js +6 -6
- package/dist/layout-engine/footnoteContinuation.d.ts +36 -0
- package/dist/layout-engine/footnoteContinuation.js +210 -0
- package/dist/layout-engine/index.d.ts +2 -2
- package/dist/layout-engine/index.js +7 -2
- package/dist/layout-engine/measure/cache.js +10 -5
- package/dist/layout-engine/measure/measureParagraph.js +1 -1
- package/dist/layout-engine/tableLayout.js +29 -5
- package/dist/layout-engine/tableRowBreak.d.ts +36 -0
- package/dist/layout-engine/tableRowBreak.js +43 -1
- package/dist/layout-engine/types.d.ts +36 -1
- package/dist/layout-painter/renderPage.d.ts +4 -4
- package/dist/layout-painter/renderPage.js +46 -17
- package/dist/layout-painter/renderTable.js +7 -4
- package/dist/managers/AutoSaveManager.d.ts +5 -1
- package/dist/managers/FindReplaceManager.js +3 -10
- package/dist/markdown/escape.d.ts +20 -1
- package/dist/markdown/escape.js +43 -1
- package/dist/markdown/renderBlock.js +4 -1
- package/dist/markdown/renderParagraph.js +13 -27
- package/dist/markdown/renderTable.js +6 -2
- package/dist/markdown/trailers.js +1 -0
- package/dist/pdf/images.d.ts +17 -1
- package/dist/pdf/images.js +22 -4
- package/dist/pdf/writePdf.js +4 -2
- package/dist/prosemirror/attrs/index.js +1 -0
- package/dist/prosemirror/canonicalCommands.d.ts +39 -1
- package/dist/prosemirror/canonicalTableCommands.d.ts +28 -0
- package/dist/prosemirror/canonicalTableCommands.js +362 -0
- package/dist/prosemirror/commands/comments.d.ts +25 -0
- package/dist/prosemirror/commands/comments.js +102 -11
- package/dist/prosemirror/commands/formatting.d.ts +1 -1
- package/dist/prosemirror/commands/index.d.ts +1 -1
- package/dist/prosemirror/commentIdAllocator.js +2 -2
- package/dist/prosemirror/commentRangeBoundaryAttrs.d.ts +6 -0
- package/dist/prosemirror/commentRangeBoundaryAttrs.js +9 -3
- package/dist/prosemirror/commentReferenceIntegrity.js +3 -4
- package/dist/prosemirror/conversion/fromProseDoc.d.ts +2 -0
- package/dist/prosemirror/conversion/fromProseDoc.js +76 -31
- package/dist/prosemirror/conversion/index.d.ts +1 -1
- package/dist/prosemirror/conversion/toProseDoc.d.ts +128 -1
- package/dist/prosemirror/conversion/toProseDoc.js +319 -51
- package/dist/prosemirror/extensions/StarterKit.js +2 -0
- package/dist/prosemirror/extensions/core/DocExtension.js +1 -1
- package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.d.ts +1 -1
- package/dist/prosemirror/extensions/features/JoinedRunStyleExtension.d.ts +1 -1
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.d.ts +1 -1
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.d.ts +1 -1
- package/dist/prosemirror/extensions/features/pastedHtmlLists.js +5 -4
- package/dist/prosemirror/extensions/marks/CommentExtension.js +6 -3
- package/dist/prosemirror/extensions/nodes/BlockCommentRangeBoundaryExtension.d.ts +4 -0
- package/dist/prosemirror/extensions/nodes/BlockCommentRangeBoundaryExtension.js +49 -0
- package/dist/prosemirror/extensions/nodes/ImageExtension.js +12 -3
- package/dist/prosemirror/extensions/nodes/TableExtension.js +32 -31
- package/dist/prosemirror/extensions/nodes/TextBoxExtension.js +1 -1
- package/dist/prosemirror/index.d.ts +2 -2
- package/dist/prosemirror/listLabels.js +3 -2
- package/dist/prosemirror/listNumbering.d.ts +6 -0
- package/dist/prosemirror/listNumbering.js +12 -9
- package/dist/prosemirror/lockedControls.d.ts +13 -0
- package/dist/prosemirror/lockedControls.js +106 -0
- package/dist/prosemirror/markupViewProjection.js +1 -1
- package/dist/prosemirror/noteReferenceReview.js +2 -2
- package/dist/prosemirror/plugins/documentNumbering.js +4 -1
- package/dist/prosemirror/plugins/suggestionMode.js +20 -9
- package/dist/prosemirror/plugins/templatePreviewValues.js +16 -1
- package/dist/prosemirror/rebaseParagraphRuns.js +1 -1
- package/dist/prosemirror/replacedAnnotations.js +1 -0
- package/dist/prosemirror/runFormattingFromMarks.d.ts +0 -1
- package/dist/prosemirror/runFormattingFromMarks.js +2 -4
- package/dist/prosemirror/runFormattingReconciliation.js +2 -2
- package/dist/prosemirror/runPropertyChangeResolution.js +1 -2
- package/dist/prosemirror/runStyleFormatting.d.ts +14 -4
- package/dist/prosemirror/runStyleFormatting.js +16 -13
- package/dist/prosemirror/schema/marks.d.ts +6 -0
- package/dist/prosemirror/styles/paragraphStyleCascade.js +2 -2
- package/dist/prosemirror/validation.js +1 -0
- package/dist/redline.js +23 -9
- package/dist/server.d.ts +2 -2
- package/dist/style-sets/extract.js +2 -2
- package/dist/types/canonicalCapabilities.d.ts +29 -8
- package/dist/types/canonicalCapabilities.js +13 -9
- package/dist/utils/cssString.d.ts +7 -0
- package/dist/utils/cssString.js +9 -0
- package/dist/utils/fontResolver.js +4 -1
- package/dist/utils/replaceText.d.ts +11 -0
- package/dist/utils/replaceText.js +39 -7
- package/dist/version-comparison.d.ts +9 -1
- package/dist/version-comparison.js +11 -5
- package/package.json +2 -2
|
@@ -17,7 +17,7 @@ import { createDocumentStyleContextPlugin, createDocumentStylesPlugin } from "..
|
|
|
17
17
|
import { schema } from "../prosemirror/schema/index.js";
|
|
18
18
|
import { createTextInputPlugin } from "../prosemirror/textInput.js";
|
|
19
19
|
import { applyAttrSchemaMigrations, proseDocumentParagraphSourceContract, readYjsAttrSchemaVersion, readYjsParagraphSourceContract, withParagraphSourceContract, writeYjsDocumentMetadata } from "../prosemirror/yjsDocumentMetadata.js";
|
|
20
|
-
import { CANONICAL_GAP, usesCanonicalSession } from "../types/canonicalCapabilities.js";
|
|
20
|
+
import { CANONICAL_GAP, CANONICAL_RULE, usesCanonicalSession } from "../types/canonicalCapabilities.js";
|
|
21
21
|
import { prepareCanonicalPaste } from "./canonicalClipboard.js";
|
|
22
22
|
import { canonicalCommentBody, compileCanonicalComments } from "./canonicalComments.js";
|
|
23
23
|
import { createCanonicalInputBoundary } from "./canonicalInput.js";
|
|
@@ -29,11 +29,13 @@ import { prepareCanonicalAutoformat, prepareCanonicalCommands } from "./canonica
|
|
|
29
29
|
import { createHiddenEditorApi } from "./hiddenEditorApi.js";
|
|
30
30
|
import { handleReadOnlySelectionKeyDown } from "./readOnlySelection.js";
|
|
31
31
|
import { Result, TaggedError, panic } from "better-result";
|
|
32
|
+
import { CellSelection } from "prosemirror-tables";
|
|
32
33
|
import { OP_STORIES, freshCommentId } from "@stll/docx-core/ops";
|
|
33
34
|
import { EditorState, Plugin } from "prosemirror-state";
|
|
34
35
|
import { EditorView } from "prosemirror-view";
|
|
35
36
|
// src/controller/hiddenEditorManager.ts
|
|
36
37
|
const CanonicalSessionRefusalErrorBase = TaggedError("CanonicalSessionRefusalError");
|
|
38
|
+
/** A refused input, with whether the session lacks the capability or the document forbids it. */
|
|
37
39
|
var CanonicalSessionRefusalError = class extends CanonicalSessionRefusalErrorBase {};
|
|
38
40
|
const normalizeSeedState = (state) => ensureBaseDirectionInState(ensureParaIdsInState(state));
|
|
39
41
|
const normalizeLocalSeedState = (state) => ensureBaseDirectionInState(state);
|
|
@@ -121,12 +123,11 @@ function createHiddenEditorState(options) {
|
|
|
121
123
|
recordHiddenEditorPhase(reason, "to-prose-doc", performance.now() - startedAt);
|
|
122
124
|
} else localDoc = ensureParaIdsInDoc(localDoc);
|
|
123
125
|
const styleResolverPlugin = createDocumentStylesPlugin(styles ?? document?.package.styles);
|
|
124
|
-
const numberingPlugin = createDocumentNumberingPlugin(document?.package.numbering);
|
|
125
126
|
const plugins = [
|
|
127
|
+
createDocumentNumberingPlugin(document?.package.numbering),
|
|
126
128
|
...externalPlugins,
|
|
127
129
|
...manager?.getPlugins() ?? [createTextInputPlugin()],
|
|
128
|
-
styleResolverPlugin
|
|
129
|
-
numberingPlugin
|
|
130
|
+
styleResolverPlugin
|
|
130
131
|
];
|
|
131
132
|
if (collaboration) {
|
|
132
133
|
if (!collaborationModules) panic("Collaboration modules must be loaded before creating collaborative editor state.");
|
|
@@ -222,11 +223,11 @@ const createHiddenEditorManager = (deps) => {
|
|
|
222
223
|
author: deps.getSuggestionAuthor?.() ?? "User"
|
|
223
224
|
} : { type: "editing" }));
|
|
224
225
|
};
|
|
225
|
-
const refuse = (reason,
|
|
226
|
+
const refuse = (reason, ground = { gap: CANONICAL_GAP.dispatch }) => {
|
|
226
227
|
const message = reason;
|
|
227
|
-
if (deps.onSessionRefusal) deps.onSessionRefusal(message,
|
|
228
|
+
if (deps.onSessionRefusal) deps.onSessionRefusal(message, ground);
|
|
228
229
|
else throw new CanonicalSessionRefusalError({
|
|
229
|
-
|
|
230
|
+
ground,
|
|
230
231
|
message
|
|
231
232
|
});
|
|
232
233
|
};
|
|
@@ -244,7 +245,7 @@ const createHiddenEditorManager = (deps) => {
|
|
|
244
245
|
reason,
|
|
245
246
|
documentIdentity
|
|
246
247
|
};
|
|
247
|
-
refuse(reason, CANONICAL_GAP.collaboration);
|
|
248
|
+
refuse(reason, { gap: CANONICAL_GAP.collaboration });
|
|
248
249
|
return false;
|
|
249
250
|
}
|
|
250
251
|
const result = createCanonicalSession(document, deps.getStyles());
|
|
@@ -254,7 +255,7 @@ const createHiddenEditorManager = (deps) => {
|
|
|
254
255
|
reason: result.error.message,
|
|
255
256
|
documentIdentity
|
|
256
257
|
};
|
|
257
|
-
refuse(result.error.message, result.error.
|
|
258
|
+
refuse(result.error.message, result.error.ground);
|
|
258
259
|
return false;
|
|
259
260
|
}
|
|
260
261
|
editorSession = {
|
|
@@ -269,9 +270,9 @@ const createHiddenEditorManager = (deps) => {
|
|
|
269
270
|
const canonicalState = (session) => EditorState.create({
|
|
270
271
|
doc: session.projection.doc,
|
|
271
272
|
plugins: [
|
|
273
|
+
createDocumentNumberingPlugin(session.document.package.numbering),
|
|
272
274
|
createParagraphChangeTrackerPlugin(),
|
|
273
275
|
createDocumentStyleContextPlugin(deps.getStyles() ?? session.document.package.styles),
|
|
274
|
-
createDocumentNumberingPlugin(session.document.package.numbering),
|
|
275
276
|
...[...deps.getExtensionManager()?.getPlugins() ?? [], ...deps.getExternalPlugins()].flatMap(({ props }) => props.transformPastedHTML === void 0 && props.transformPasted === void 0 && props.transformCopied === void 0 && props.clipboardTextSerializer === void 0 ? [] : [new Plugin({ props: {
|
|
276
277
|
...props.transformCopied === void 0 ? {} : { transformCopied: props.transformCopied },
|
|
277
278
|
...props.clipboardTextSerializer === void 0 ? {} : { clipboardTextSerializer: props.clipboardTextSerializer },
|
|
@@ -289,7 +290,7 @@ const createHiddenEditorManager = (deps) => {
|
|
|
289
290
|
session
|
|
290
291
|
});
|
|
291
292
|
if (result.isErr()) {
|
|
292
|
-
reportRefusal(result.error.message, result.error.
|
|
293
|
+
reportRefusal(result.error.message, result.error.ground);
|
|
293
294
|
return false;
|
|
294
295
|
}
|
|
295
296
|
const staged = result.value;
|
|
@@ -308,7 +309,7 @@ const createHiddenEditorManager = (deps) => {
|
|
|
308
309
|
if (direction === "undo" ? !session.canUndo : !session.canRedo) return false;
|
|
309
310
|
const prepared = direction === "undo" ? session.prepareUndo(view.state) : session.prepareRedo(view.state);
|
|
310
311
|
if (prepared.isErr()) {
|
|
311
|
-
if (prepared.error.reason !== "noChange") refuse(prepared.error.message, prepared.error.
|
|
312
|
+
if (prepared.error.reason !== "noChange") refuse(prepared.error.message, prepared.error.ground);
|
|
312
313
|
return false;
|
|
313
314
|
}
|
|
314
315
|
return publishCommit(prepared.value);
|
|
@@ -329,10 +330,10 @@ const createHiddenEditorManager = (deps) => {
|
|
|
329
330
|
if (described.isErr()) {
|
|
330
331
|
if (!(described.error instanceof HyperlinkRemovalRefusal)) throw described.error;
|
|
331
332
|
const refusal = new CanonicalSessionRefusalError({
|
|
332
|
-
gap: CANONICAL_GAP.commands,
|
|
333
|
+
ground: { gap: CANONICAL_GAP.commands },
|
|
333
334
|
message: described.error.message
|
|
334
335
|
});
|
|
335
|
-
refuse(refusal.message, refusal.
|
|
336
|
+
refuse(refusal.message, refusal.ground);
|
|
336
337
|
return false;
|
|
337
338
|
}
|
|
338
339
|
const intents = described.value;
|
|
@@ -344,7 +345,7 @@ const createHiddenEditorManager = (deps) => {
|
|
|
344
345
|
}, view);
|
|
345
346
|
const prepared = prepareCanonicalCommands(editorSession.session, view.state, intents);
|
|
346
347
|
if (prepared.isErr()) {
|
|
347
|
-
if (prepared.error.reason !== "noChange") refuse(prepared.error.message, prepared.error.
|
|
348
|
+
if (prepared.error.reason !== "noChange") refuse(prepared.error.message, prepared.error.ground);
|
|
348
349
|
return false;
|
|
349
350
|
}
|
|
350
351
|
return publishCommit(prepared.value);
|
|
@@ -364,7 +365,7 @@ const createHiddenEditorManager = (deps) => {
|
|
|
364
365
|
if (mark !== void 0) command = name === "toggleUnderline" ? toggleUnderlineMark(mark) : toggleMarkForAllScripts(mark, name === "toggleBold" ? "bold" : "italic");
|
|
365
366
|
}
|
|
366
367
|
if (command === void 0) {
|
|
367
|
-
refuse("The formatting command is unavailable.", CANONICAL_GAP.commands);
|
|
368
|
+
refuse("The formatting command is unavailable.", { gap: CANONICAL_GAP.commands });
|
|
368
369
|
return;
|
|
369
370
|
}
|
|
370
371
|
if (executeCanonicalCommand(command) === void 0) command(view.state, (transaction) => view?.dispatch(transaction), view);
|
|
@@ -372,11 +373,47 @@ const createHiddenEditorManager = (deps) => {
|
|
|
372
373
|
structure: (type) => {
|
|
373
374
|
if (!view || deps.getReadOnly() || editorSession.type !== "canonical") return;
|
|
374
375
|
syncCanonicalMode();
|
|
376
|
+
if (type === "deleteTable") {
|
|
377
|
+
const command = deps.getExtensionManager()?.getCommand("deleteTable")?.();
|
|
378
|
+
if (command === void 0) refuse("Deleting the table is unavailable.", { gap: CANONICAL_GAP.commands });
|
|
379
|
+
else executeCanonicalCommand(command);
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
375
382
|
const session = editorSession.session;
|
|
376
383
|
const state = view.state;
|
|
384
|
+
if (state.selection instanceof CellSelection && (type === "split" || type === "tab" || type === "lineBreak" || type === "pageBreak")) {
|
|
385
|
+
const overCells = session.prepareCellSelectionStructure(state, (at) => type === "split" ? {
|
|
386
|
+
type: "replaceFragment",
|
|
387
|
+
from: at,
|
|
388
|
+
to: at,
|
|
389
|
+
paragraphs: [{
|
|
390
|
+
type: "paragraph",
|
|
391
|
+
content: []
|
|
392
|
+
}, {
|
|
393
|
+
type: "paragraph",
|
|
394
|
+
content: []
|
|
395
|
+
}],
|
|
396
|
+
openStart: 1,
|
|
397
|
+
openEnd: 1
|
|
398
|
+
} : {
|
|
399
|
+
type: "insertAtom",
|
|
400
|
+
from: at,
|
|
401
|
+
to: at,
|
|
402
|
+
atom: type === "tab" ? { type: "tab" } : {
|
|
403
|
+
type: "break",
|
|
404
|
+
breakType: type === "pageBreak" ? "page" : "textWrapping"
|
|
405
|
+
}
|
|
406
|
+
});
|
|
407
|
+
if (overCells.isErr()) {
|
|
408
|
+
if (overCells.error.reason !== "noChange") refuse(overCells.error.message, overCells.error.ground);
|
|
409
|
+
return;
|
|
410
|
+
}
|
|
411
|
+
publishCommit(overCells.value);
|
|
412
|
+
return;
|
|
413
|
+
}
|
|
377
414
|
const selection = session.projection.selectionAt(state);
|
|
378
415
|
if (selection.isErr()) {
|
|
379
|
-
refuse(selection.error.message, selection.error.
|
|
416
|
+
refuse(selection.error.message, selection.error.ground);
|
|
380
417
|
return;
|
|
381
418
|
}
|
|
382
419
|
let prepared;
|
|
@@ -426,11 +463,11 @@ const createHiddenEditorManager = (deps) => {
|
|
|
426
463
|
const from = session.projection.addressAt(state.selection.from);
|
|
427
464
|
const to = session.projection.addressAt(state.selection.to);
|
|
428
465
|
if (from.isErr()) {
|
|
429
|
-
refuse(from.error.message, from.error.
|
|
466
|
+
refuse(from.error.message, from.error.ground);
|
|
430
467
|
return;
|
|
431
468
|
}
|
|
432
469
|
if (to.isErr()) {
|
|
433
|
-
refuse(to.error.message, to.error.
|
|
470
|
+
refuse(to.error.message, to.error.ground);
|
|
434
471
|
return;
|
|
435
472
|
}
|
|
436
473
|
prepared = session.prepareIntent(state, {
|
|
@@ -447,7 +484,7 @@ const createHiddenEditorManager = (deps) => {
|
|
|
447
484
|
default: return type;
|
|
448
485
|
}
|
|
449
486
|
if (prepared.isErr()) {
|
|
450
|
-
if (prepared.error.reason !== "noChange") refuse(prepared.error.message, prepared.error.
|
|
487
|
+
if (prepared.error.reason !== "noChange") refuse(prepared.error.message, prepared.error.ground);
|
|
451
488
|
return;
|
|
452
489
|
}
|
|
453
490
|
publishCommit(prepared.value);
|
|
@@ -461,7 +498,7 @@ const createHiddenEditorManager = (deps) => {
|
|
|
461
498
|
if (deps.getReadOnly() || editorSession.type !== "canonical") return false;
|
|
462
499
|
const begun = editorSession.session.beginComposition();
|
|
463
500
|
if (begun.isErr()) {
|
|
464
|
-
refuse(begun.error.message, begun.error.
|
|
501
|
+
refuse(begun.error.message, begun.error.ground);
|
|
465
502
|
return false;
|
|
466
503
|
}
|
|
467
504
|
return true;
|
|
@@ -501,7 +538,7 @@ const createHiddenEditorManager = (deps) => {
|
|
|
501
538
|
semantic: "replacement"
|
|
502
539
|
});
|
|
503
540
|
if (prepared.isErr()) {
|
|
504
|
-
refuse(prepared.error.message, prepared.error.
|
|
541
|
+
refuse(prepared.error.message, prepared.error.ground);
|
|
505
542
|
return true;
|
|
506
543
|
}
|
|
507
544
|
const copied = Result.try({
|
|
@@ -511,11 +548,11 @@ const createHiddenEditorManager = (deps) => {
|
|
|
511
548
|
event.clipboardData?.setData("text/plain", serialized.text);
|
|
512
549
|
},
|
|
513
550
|
catch: () => new CanonicalSessionRefusalError({
|
|
514
|
-
gap: CANONICAL_GAP.dispatch,
|
|
551
|
+
ground: { gap: CANONICAL_GAP.dispatch },
|
|
515
552
|
message: "The clipboard could not receive the cut content."
|
|
516
553
|
})
|
|
517
554
|
});
|
|
518
|
-
if (copied.isErr()) refuse(copied.error.message, copied.error.
|
|
555
|
+
if (copied.isErr()) refuse(copied.error.message, copied.error.ground);
|
|
519
556
|
else publishCommit(prepared.value);
|
|
520
557
|
return true;
|
|
521
558
|
},
|
|
@@ -527,7 +564,7 @@ const createHiddenEditorManager = (deps) => {
|
|
|
527
564
|
const rule = prepareCanonicalAutoformat(editorSession.session, view.state, intent);
|
|
528
565
|
const prepared = rule ?? editorSession.session.prepareReplace(view.state, intent);
|
|
529
566
|
if (prepared.isErr()) {
|
|
530
|
-
if (prepared.error.reason !== "noChange") refuse(prepared.error.message, prepared.error.
|
|
567
|
+
if (prepared.error.reason !== "noChange") refuse(prepared.error.message, prepared.error.ground);
|
|
531
568
|
return;
|
|
532
569
|
}
|
|
533
570
|
const session = editorSession.session;
|
|
@@ -597,7 +634,7 @@ const createHiddenEditorManager = (deps) => {
|
|
|
597
634
|
if (modules && transaction.getMeta(modules.yProseMirror.ySyncPluginKey) !== void 0) markNoteReferenceReplay(transaction);
|
|
598
635
|
const applied = view.state.applyTransaction(transaction);
|
|
599
636
|
const noteIssue = noteReferenceTransactionIssue(transaction);
|
|
600
|
-
if (noteIssue) deps.onSessionRefusal?.(noteIssue.message, CANONICAL_GAP.dispatch, noteIssue);
|
|
637
|
+
if (noteIssue) deps.onSessionRefusal?.(noteIssue.message, { gap: CANONICAL_GAP.dispatch }, noteIssue);
|
|
601
638
|
if (editorSession.type === "canonical" && !applied.state.doc.eq(view.state.doc)) {
|
|
602
639
|
refuse("A plugin attempted an unclassified canonical document mutation.");
|
|
603
640
|
return;
|
|
@@ -626,6 +663,7 @@ const createHiddenEditorManager = (deps) => {
|
|
|
626
663
|
return deps.onKeyDown(pmView, event);
|
|
627
664
|
},
|
|
628
665
|
handleTextInput: (pmView, from, to, text) => editorSession.type === "canonical" ? input.handleTextInput(pmView, from, to, text) : false,
|
|
666
|
+
handleKeyPress: (pmView, event) => editorSession.type === "canonical" && !deps.getReadOnly() && input.handleKeyPress(pmView, event),
|
|
629
667
|
handlePaste: (pmView, _event, slice) => {
|
|
630
668
|
if (editorSession.type !== "canonical") return false;
|
|
631
669
|
if (deps.getReadOnly()) {
|
|
@@ -639,7 +677,7 @@ const createHiddenEditorManager = (deps) => {
|
|
|
639
677
|
slice
|
|
640
678
|
});
|
|
641
679
|
if (prepared.isErr()) {
|
|
642
|
-
if (prepared.error.reason !== "noChange") refuse(prepared.error.message, prepared.error.
|
|
680
|
+
if (prepared.error.reason !== "noChange") refuse(prepared.error.message, prepared.error.ground);
|
|
643
681
|
} else publishCommit(prepared.value);
|
|
644
682
|
return true;
|
|
645
683
|
},
|
|
@@ -682,7 +720,7 @@ const createHiddenEditorManager = (deps) => {
|
|
|
682
720
|
} : { pasteTarget: target }
|
|
683
721
|
});
|
|
684
722
|
if (prepared.isErr()) {
|
|
685
|
-
if (prepared.error.reason !== "noChange") refuse(prepared.error.message, prepared.error.
|
|
723
|
+
if (prepared.error.reason !== "noChange") refuse(prepared.error.message, prepared.error.ground);
|
|
686
724
|
} else publishCommit(prepared.value);
|
|
687
725
|
return true;
|
|
688
726
|
},
|
|
@@ -746,7 +784,7 @@ const createHiddenEditorManager = (deps) => {
|
|
|
746
784
|
plain
|
|
747
785
|
});
|
|
748
786
|
if (prepared.isErr()) {
|
|
749
|
-
if (prepared.error.reason !== "noChange") refuse(prepared.error.message, prepared.error.
|
|
787
|
+
if (prepared.error.reason !== "noChange") refuse(prepared.error.message, prepared.error.ground);
|
|
750
788
|
return false;
|
|
751
789
|
}
|
|
752
790
|
return publishCommit(prepared.value);
|
|
@@ -850,7 +888,7 @@ const createHiddenEditorManager = (deps) => {
|
|
|
850
888
|
session
|
|
851
889
|
});
|
|
852
890
|
if (staged.isErr()) {
|
|
853
|
-
refuse(staged.error.message, staged.error.
|
|
891
|
+
refuse(staged.error.message, staged.error.ground);
|
|
854
892
|
return false;
|
|
855
893
|
}
|
|
856
894
|
storyView.updateState(staged.value.state);
|
|
@@ -910,7 +948,23 @@ const createHiddenEditorManager = (deps) => {
|
|
|
910
948
|
resolution
|
|
911
949
|
});
|
|
912
950
|
if (prepared.isErr()) {
|
|
913
|
-
if (prepared.error.reason !== "noChange") refuse(prepared.error.message, prepared.error.
|
|
951
|
+
if (prepared.error.reason !== "noChange") refuse(prepared.error.message, prepared.error.ground);
|
|
952
|
+
return false;
|
|
953
|
+
}
|
|
954
|
+
const published = publishCommit(prepared.value);
|
|
955
|
+
if (prepared.value.lockHeld !== void 0) refuse(`Revisions ${prepared.value.lockHeld.join(", ")} stay pending: resolving them changes a locked content control.`, { rule: CANONICAL_RULE.contentControlLock });
|
|
956
|
+
return published;
|
|
957
|
+
},
|
|
958
|
+
resolveCanonicalSuggestion: (suggestionId, resolution, author) => {
|
|
959
|
+
if (!view || deps.getReadOnly() || editorSession.type !== "canonical") return false;
|
|
960
|
+
const prepared = editorSession.session.prepareSuggestion(view.state, {
|
|
961
|
+
suggestionId,
|
|
962
|
+
resolution,
|
|
963
|
+
author,
|
|
964
|
+
date: (/* @__PURE__ */ new Date()).toISOString()
|
|
965
|
+
});
|
|
966
|
+
if (prepared.isErr()) {
|
|
967
|
+
if (prepared.error.reason !== "noChange") refuse(prepared.error.message, prepared.error.ground);
|
|
914
968
|
return false;
|
|
915
969
|
}
|
|
916
970
|
return publishCommit(prepared.value);
|
|
@@ -926,7 +980,7 @@ const createHiddenEditorManager = (deps) => {
|
|
|
926
980
|
applyCanonicalSectionProperties: (patch) => {
|
|
927
981
|
ensureView();
|
|
928
982
|
const fail = (message) => {
|
|
929
|
-
refuse(message, CANONICAL_GAP.sectionProperties);
|
|
983
|
+
refuse(message, { gap: CANONICAL_GAP.sectionProperties });
|
|
930
984
|
return {
|
|
931
985
|
status: "refused",
|
|
932
986
|
gap: CANONICAL_GAP.sectionProperties,
|
|
@@ -955,7 +1009,7 @@ const createHiddenEditorManager = (deps) => {
|
|
|
955
1009
|
applyCanonicalComment: (request) => {
|
|
956
1010
|
ensureView();
|
|
957
1011
|
const fail = (message, retry = "never") => {
|
|
958
|
-
if (retry === "never") refuse(message, CANONICAL_GAP.comments);
|
|
1012
|
+
if (retry === "never") refuse(message, { gap: CANONICAL_GAP.comments });
|
|
959
1013
|
return {
|
|
960
1014
|
status: "refused",
|
|
961
1015
|
gap: CANONICAL_GAP.comments,
|
|
@@ -1076,7 +1130,7 @@ const createHiddenEditorManager = (deps) => {
|
|
|
1076
1130
|
if (direction === "undo" ? !session.canUndo : !session.canRedo) return false;
|
|
1077
1131
|
const prepared = direction === "undo" ? session.prepareUndo(storyView.state, story) : session.prepareRedo(storyView.state, story);
|
|
1078
1132
|
if (prepared.isErr()) {
|
|
1079
|
-
refuse(prepared.error.message, prepared.error.
|
|
1133
|
+
refuse(prepared.error.message, prepared.error.ground);
|
|
1080
1134
|
return false;
|
|
1081
1135
|
}
|
|
1082
1136
|
return publishStoryCommit(storyView, prepared.value);
|
|
@@ -1086,7 +1140,7 @@ const createHiddenEditorManager = (deps) => {
|
|
|
1086
1140
|
if (!view || editorSession.type !== "canonical" || deps.getReadOnly()) return false;
|
|
1087
1141
|
const prepared = editorSession.session.prepareOperations(view.state, ops);
|
|
1088
1142
|
if (prepared.isErr()) {
|
|
1089
|
-
refuse(prepared.error.message, prepared.error.
|
|
1143
|
+
refuse(prepared.error.message, prepared.error.ground);
|
|
1090
1144
|
return false;
|
|
1091
1145
|
}
|
|
1092
1146
|
return publishCommit(prepared.value);
|
|
@@ -1096,7 +1150,7 @@ const createHiddenEditorManager = (deps) => {
|
|
|
1096
1150
|
if (editorSession.type !== "canonical" || editorSession.session.isComposing) return null;
|
|
1097
1151
|
const result = editorSession.session.projectStory(story);
|
|
1098
1152
|
if (result.isErr()) {
|
|
1099
|
-
refuse(result.error.message, result.error.
|
|
1153
|
+
refuse(result.error.message, result.error.ground);
|
|
1100
1154
|
return null;
|
|
1101
1155
|
}
|
|
1102
1156
|
return result.value.doc;
|
|
@@ -1109,7 +1163,7 @@ const createHiddenEditorManager = (deps) => {
|
|
|
1109
1163
|
story
|
|
1110
1164
|
});
|
|
1111
1165
|
if (prepared.isErr()) {
|
|
1112
|
-
refuse(prepared.error.message, prepared.error.
|
|
1166
|
+
refuse(prepared.error.message, prepared.error.ground);
|
|
1113
1167
|
return false;
|
|
1114
1168
|
}
|
|
1115
1169
|
return publishStoryCommit(storyView, prepared.value);
|
|
@@ -17,6 +17,7 @@ import { applyTemplatePreviewToBlocks } from "../layout-bridge/convert/templateP
|
|
|
17
17
|
import { toFlowBlocks } from "../layout-bridge/convert/toFlowBlocks.js";
|
|
18
18
|
import { getColumns } from "../layout-bridge/sectionColumns.js";
|
|
19
19
|
import { resolveAnchorLayoutInCellCompatibility } from "../layout-engine/anchorLayoutInCellCompatibility.js";
|
|
20
|
+
import { applyFootnoteContinuation, footnoteContinuationSettled, planFootnoteContinuation } from "../layout-engine/footnoteContinuation.js";
|
|
20
21
|
import { layoutDocument } from "../layout-engine/index.js";
|
|
21
22
|
import { resolveJustificationCompatibility } from "../layout-engine/justificationCompatibility.js";
|
|
22
23
|
import { recordLayoutComplete, recordLayoutError, recordLayoutPhase, recordLayoutStart, recordMarkupViewIncomplete } from "../layout-engine/layoutInstrumentation.js";
|
|
@@ -40,6 +41,7 @@ import { diffAgainstCommittedLayout } from "./committedLayoutDiff.js";
|
|
|
40
41
|
import { LAYOUT_MEASURE } from "./layoutRunOptions.js";
|
|
41
42
|
import { survivingComments } from "@stll/docx-core/ops";
|
|
42
43
|
// src/controller/layoutPipeline.ts
|
|
44
|
+
const MAX_FOOTNOTE_CONTINUATION_ROUNDS = 4;
|
|
43
45
|
const formatEndnoteTexts = (numbers, formatNumber) => {
|
|
44
46
|
const texts = /* @__PURE__ */ new Map();
|
|
45
47
|
for (const [id, displayNumber] of numbers) texts.set(id, formatNumber(displayNumber));
|
|
@@ -431,6 +433,16 @@ function runLayoutPipelineMeasured(deps, state, options) {
|
|
|
431
433
|
noteAreas: endnoteAreas.noteAreas
|
|
432
434
|
});
|
|
433
435
|
};
|
|
436
|
+
const withFootnoteHeights = (nextLayoutOpts) => {
|
|
437
|
+
if (!hasFootnotes) return nextLayoutOpts;
|
|
438
|
+
const footnoteHeightById = /* @__PURE__ */ new Map();
|
|
439
|
+
for (const [id, content] of footnoteContentMap) footnoteHeightById.set(id, content.height + 0);
|
|
440
|
+
return {
|
|
441
|
+
...nextLayoutOpts,
|
|
442
|
+
footnoteHeightById,
|
|
443
|
+
footnoteContinuation: nextLayoutOpts.footnoteContinuation ?? { trailingPages: 0 }
|
|
444
|
+
};
|
|
445
|
+
};
|
|
434
446
|
phaseStartedAt = performance.now();
|
|
435
447
|
let newLayout;
|
|
436
448
|
let pageFootnoteMap = /* @__PURE__ */ new Map();
|
|
@@ -470,12 +482,7 @@ function runLayoutPipelineMeasured(deps, state, options) {
|
|
|
470
482
|
let layoutOptsUsed = layoutOpts;
|
|
471
483
|
if (hasFootnotes) {
|
|
472
484
|
footnoteContentMap = buildFootnoteContentMap(documentFootnotes, footnoteRefs, contentWidth, buildNoteOptions());
|
|
473
|
-
|
|
474
|
-
for (const [id, content] of footnoteContentMap) footnoteHeightById.set(id, content.height + 0);
|
|
475
|
-
layoutOptsUsed = {
|
|
476
|
-
...layoutOpts,
|
|
477
|
-
footnoteHeightById
|
|
478
|
-
};
|
|
485
|
+
layoutOptsUsed = withFootnoteHeights(layoutOpts);
|
|
479
486
|
newLayout = layoutWithNoteAreas(newMeasures, layoutOptsUsed);
|
|
480
487
|
pageFootnoteMap = /* @__PURE__ */ new Map();
|
|
481
488
|
for (const page of newLayout.pages) if (page.footnoteIds && page.footnoteIds.length > 0) pageFootnoteMap.set(page.number, page.footnoteIds);
|
|
@@ -484,15 +491,6 @@ function runLayoutPipelineMeasured(deps, state, options) {
|
|
|
484
491
|
pageFootnoteMap = /* @__PURE__ */ new Map();
|
|
485
492
|
for (const page of newLayout.pages) if (page.footnoteIds && page.footnoteIds.length > 0) pageFootnoteMap.set(page.number, page.footnoteIds);
|
|
486
493
|
};
|
|
487
|
-
const withFootnoteHeights = (nextLayoutOpts) => {
|
|
488
|
-
if (!hasFootnotes) return nextLayoutOpts;
|
|
489
|
-
const footnoteHeightById = /* @__PURE__ */ new Map();
|
|
490
|
-
for (const [id, content] of footnoteContentMap) footnoteHeightById.set(id, content.height + 0);
|
|
491
|
-
return {
|
|
492
|
-
...nextLayoutOpts,
|
|
493
|
-
footnoteHeightById
|
|
494
|
-
};
|
|
495
|
-
};
|
|
496
494
|
const relayoutWithCurrentMeasures = (nextLayoutOpts) => {
|
|
497
495
|
layoutOptsUsed = withFootnoteHeights(nextLayoutOpts);
|
|
498
496
|
newLayout = layoutWithNoteAreas(newMeasures, layoutOptsUsed);
|
|
@@ -553,6 +551,41 @@ function runLayoutPipelineMeasured(deps, state, options) {
|
|
|
553
551
|
};
|
|
554
552
|
let stabilizedFieldValues;
|
|
555
553
|
stabilizeFieldWidths();
|
|
554
|
+
if (hasFootnotes) {
|
|
555
|
+
const usedTrailingPages = () => layoutOptsUsed.footnoteContinuation?.trailingPages ?? 0;
|
|
556
|
+
const planContinuation = () => planFootnoteContinuation({
|
|
557
|
+
pages: newLayout.pages,
|
|
558
|
+
contentById: footnoteContentMap,
|
|
559
|
+
trailingPages: usedTrailingPages()
|
|
560
|
+
});
|
|
561
|
+
const relayoutFor = (reservedHeights, trailingPages) => {
|
|
562
|
+
relayoutWithCurrentMeasures({
|
|
563
|
+
...layoutOptsUsed,
|
|
564
|
+
...reservedHeights === void 0 ? {} : { footnoteReservedHeights: reservedHeights },
|
|
565
|
+
footnoteContinuation: { trailingPages }
|
|
566
|
+
});
|
|
567
|
+
stabilizeFieldWidths();
|
|
568
|
+
};
|
|
569
|
+
let continuation = planContinuation();
|
|
570
|
+
for (let round = 0; round < MAX_FOOTNOTE_CONTINUATION_ROUNDS && !footnoteContinuationSettled({
|
|
571
|
+
reservedHeights: layoutOptsUsed.footnoteReservedHeights,
|
|
572
|
+
trailingPages: usedTrailingPages()
|
|
573
|
+
}, continuation); round += 1) {
|
|
574
|
+
relayoutFor(continuation.reservedHeights, continuation.trailingPages);
|
|
575
|
+
continuation = planContinuation();
|
|
576
|
+
}
|
|
577
|
+
while (continuation.extraPages > 0) {
|
|
578
|
+
relayoutFor(layoutOptsUsed.footnoteReservedHeights, continuation.trailingPages);
|
|
579
|
+
continuation = planContinuation();
|
|
580
|
+
}
|
|
581
|
+
if (continuation.pages.size > 0) {
|
|
582
|
+
newLayout = {
|
|
583
|
+
...newLayout,
|
|
584
|
+
pages: applyFootnoteContinuation(newLayout.pages, continuation)
|
|
585
|
+
};
|
|
586
|
+
rebuildFootnotePageMap();
|
|
587
|
+
}
|
|
588
|
+
}
|
|
556
589
|
newLayout = attachAuthoredMarginsToLayoutPages(newLayout, {
|
|
557
590
|
authoredMargins: margins,
|
|
558
591
|
mirrorMargins,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { document_d_exports } from "../types/document.js";
|
|
2
|
-
import {
|
|
2
|
+
import { CanonicalRefusalGround } from "../types/canonicalCapabilities.js";
|
|
3
3
|
import { NoteStoryKey } from "../types/editor-story.js";
|
|
4
4
|
import { HiddenEditorApi } from "./hiddenEditorApi.js";
|
|
5
5
|
import { Plugin } from "prosemirror-state";
|
|
@@ -15,7 +15,7 @@ export type NoteEditorManagerDeps = {
|
|
|
15
15
|
getDocument: () => document_d_exports.Document | null;
|
|
16
16
|
getCanonicalApi?: (() => HiddenEditorApi | null) | undefined;
|
|
17
17
|
getExperimentalSession?: (() => "canonical" | undefined) | undefined;
|
|
18
|
-
onSessionRefusal?: ((reason: string,
|
|
18
|
+
onSessionRefusal?: ((reason: string, ground: CanonicalRefusalGround, error?: Error) => void) | undefined;
|
|
19
19
|
getHost: () => HTMLElement | null;
|
|
20
20
|
getPlugins?: (() => Plugin[]) | undefined;
|
|
21
21
|
getStyles: () => document_d_exports.StyleDefinitions | null | undefined;
|
|
@@ -40,10 +40,10 @@ const buildInitialState = (document, styles, numbering, manager, externalPlugins
|
|
|
40
40
|
doc: document,
|
|
41
41
|
schema,
|
|
42
42
|
plugins: [
|
|
43
|
+
createDocumentNumberingPlugin(numbering),
|
|
43
44
|
...manager.getPlugins(),
|
|
44
45
|
...externalPlugins,
|
|
45
|
-
createDocumentStylesPlugin(styles)
|
|
46
|
-
createDocumentNumberingPlugin(numbering)
|
|
46
|
+
createDocumentStylesPlugin(styles)
|
|
47
47
|
]
|
|
48
48
|
})));
|
|
49
49
|
};
|
|
@@ -200,7 +200,7 @@ const createNoteEditorManager = (deps) => {
|
|
|
200
200
|
...canonical.props,
|
|
201
201
|
state: canonicalProjection ? EditorState.create({
|
|
202
202
|
doc: canonicalProjection,
|
|
203
|
-
plugins: [
|
|
203
|
+
plugins: [createDocumentNumberingPlugin(numbering), createDocumentStyleContextPlugin(styles)]
|
|
204
204
|
}) : buildInitialState(proseDocument, styles, numbering, manager, externalPlugins),
|
|
205
205
|
dispatchTransaction(transaction) {
|
|
206
206
|
if (canonical.dispatch(transaction)) return;
|
|
@@ -208,7 +208,7 @@ const createNoteEditorManager = (deps) => {
|
|
|
208
208
|
const docChanged = !nextState.doc.eq(view.state.doc);
|
|
209
209
|
view.updateState(nextState);
|
|
210
210
|
const noteIssue = noteReferenceTransactionIssue(transaction);
|
|
211
|
-
if (noteIssue) deps.onSessionRefusal?.(noteIssue.message, CANONICAL_GAP.dispatch, noteIssue);
|
|
211
|
+
if (noteIssue) deps.onSessionRefusal?.(noteIssue.message, { gap: CANONICAL_GAP.dispatch }, noteIssue);
|
|
212
212
|
const mountedStory = mounted.get(key);
|
|
213
213
|
if (mountedStory && docChanged) mountedStory.dirty = true;
|
|
214
214
|
deps.onTransaction?.({
|
|
@@ -257,7 +257,7 @@ const createNoteEditorManager = (deps) => {
|
|
|
257
257
|
const canonical = deps.getCanonicalApi?.()?.getCanonicalDocument();
|
|
258
258
|
if (canonical) return canonical;
|
|
259
259
|
throw new CanonicalSessionError({
|
|
260
|
-
gap: CANONICAL_GAP.authorityRouting,
|
|
260
|
+
ground: { gap: CANONICAL_GAP.authorityRouting },
|
|
261
261
|
reason: "refused",
|
|
262
262
|
message: "Canonical story snapshot is unavailable."
|
|
263
263
|
});
|
|
@@ -2,6 +2,7 @@ import { NOTE_SEPARATOR_RULE_THICKNESS, NOTE_SEPARATOR_WIDTH_FRACTION } from "..
|
|
|
2
2
|
import { calculateFootnoteAreaRenderHeight } from "../../layout-painter/renderPage.js";
|
|
3
3
|
import { HIT_REGION_KINDS } from "../primitives.js";
|
|
4
4
|
import { DOC_CANVAS_TEXT } from "./colors.js";
|
|
5
|
+
import { createPageComposer } from "./regions.js";
|
|
5
6
|
import { paintFootnoteBlocks } from "./storyPrimitives.js";
|
|
6
7
|
import { UNSUPPORTED_CONSTRUCT } from "./unsupported.js";
|
|
7
8
|
// src/display-list/build/pageFurniture.ts
|
|
@@ -93,6 +94,7 @@ const paintFootnoteArea = ({ composer, page, context, contentById }) => {
|
|
|
93
94
|
}));
|
|
94
95
|
const missing = bodies.flatMap(({ noteId, content }) => content === void 0 ? [noteId] : []);
|
|
95
96
|
if (missing.length > 0) context.unsupported.report(UNSUPPORTED_CONSTRUCT.footnoteContent, context.pageIndex, `footnote bodies ${missing.join(", ")} were not supplied to the builder, so the band reserves their height and paints nothing`);
|
|
97
|
+
const noteWindowOf = (noteId) => page.footnoteWindows?.find((candidate) => candidate.noteId === noteId);
|
|
96
98
|
const items = bodies.map(({ noteId, content }) => ({
|
|
97
99
|
noteId,
|
|
98
100
|
displayNumber: String(content?.displayNumber ?? noteId),
|
|
@@ -104,7 +106,7 @@ const paintFootnoteArea = ({ composer, page, context, contentById }) => {
|
|
|
104
106
|
}));
|
|
105
107
|
const contentHeightPx = page.size.h - page.margins.top - page.margins.bottom;
|
|
106
108
|
const contentWidthPx = page.size.w - page.margins.left - page.margins.right;
|
|
107
|
-
const bandHeightPx = Math.max(reservedHeightPx, calculateFootnoteAreaRenderHeight(items));
|
|
109
|
+
const bandHeightPx = Math.max(reservedHeightPx, calculateFootnoteAreaRenderHeight(items, page.footnoteWindows));
|
|
108
110
|
const areaTopPx = page.margins.top + Math.max(-page.margins.top, contentHeightPx - bandHeightPx);
|
|
109
111
|
const primitives = [{
|
|
110
112
|
kind: "rect",
|
|
@@ -119,38 +121,58 @@ const paintFootnoteArea = ({ composer, page, context, contentById }) => {
|
|
|
119
121
|
composer.push(primitives);
|
|
120
122
|
for (const [index, { noteId, content }] of bodies.entries()) {
|
|
121
123
|
if (content === void 0) continue;
|
|
122
|
-
const offsetPx = calculateFootnoteAreaRenderHeight(items.slice(0, index));
|
|
124
|
+
const offsetPx = calculateFootnoteAreaRenderHeight(items.slice(0, index), page.footnoteWindows);
|
|
123
125
|
const story = {
|
|
124
126
|
kind: "footnote",
|
|
125
127
|
id: noteId
|
|
126
128
|
};
|
|
129
|
+
const noteWindow = noteWindowOf(noteId);
|
|
127
130
|
composer.region({
|
|
128
131
|
kind: HIT_REGION_KINDS.note,
|
|
129
132
|
rect: {
|
|
130
133
|
xPx: page.margins.left,
|
|
131
134
|
yPx: areaTopPx + offsetPx,
|
|
132
135
|
widthPx: contentWidthPx,
|
|
133
|
-
heightPx: content.height
|
|
136
|
+
heightPx: noteWindow ? noteWindow.to - noteWindow.from : content.height
|
|
134
137
|
},
|
|
135
138
|
model: { story }
|
|
136
139
|
}, () => {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
140
|
+
const paintBlocks = (target) => {
|
|
141
|
+
paintFootnoteBlocks({
|
|
142
|
+
composer: target,
|
|
143
|
+
blocks: content.blocks,
|
|
144
|
+
measures: content.measures,
|
|
145
|
+
xPx: page.margins.left,
|
|
146
|
+
yPx: areaTopPx + offsetPx - (noteWindow?.from ?? 0),
|
|
147
|
+
widthPx: contentWidthPx,
|
|
148
|
+
context: {
|
|
149
|
+
...context,
|
|
150
|
+
story,
|
|
151
|
+
inlinePictureViewport: {
|
|
152
|
+
left: page.margins.left,
|
|
153
|
+
right: page.size.w - page.margins.right
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
label: `footnote ${content.displayNumber}`
|
|
157
|
+
});
|
|
158
|
+
};
|
|
159
|
+
if (!noteWindow) {
|
|
160
|
+
paintBlocks(composer);
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
const clipped = createPageComposer();
|
|
164
|
+
paintBlocks(clipped);
|
|
165
|
+
composer.push([{
|
|
166
|
+
kind: "clipGroup",
|
|
167
|
+
rect: {
|
|
168
|
+
xPx: page.margins.left,
|
|
169
|
+
yPx: areaTopPx + offsetPx,
|
|
170
|
+
widthPx: contentWidthPx,
|
|
171
|
+
heightPx: noteWindow.to - noteWindow.from
|
|
151
172
|
},
|
|
152
|
-
|
|
153
|
-
|
|
173
|
+
children: [...clipped.primitives()],
|
|
174
|
+
regions: [...clipped.regions()]
|
|
175
|
+
}]);
|
|
154
176
|
});
|
|
155
177
|
}
|
|
156
178
|
};
|