@stll/folio-core 0.72.0 → 0.74.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -6
- package/dist/ai-edits/applyTypes.d.ts +85 -0
- package/dist/ai-edits/applyTypes.js +24 -0
- package/dist/ai-edits/clean-text.d.ts +7 -1
- package/dist/ai-edits/clean-text.js +23 -2
- package/dist/ai-edits/finalSectionReview.d.ts +1 -1
- package/dist/ai-edits/headless.d.ts +29 -147
- package/dist/ai-edits/headless.js +215 -1639
- package/dist/ai-edits/index.d.ts +3 -3
- package/dist/ai-edits/index.js +2 -3
- package/dist/ai-edits/pending-suggestions.d.ts +14 -4
- package/dist/ai-edits/pending-suggestions.js +183 -90
- package/dist/ai-edits/pendingJoin.js +6 -1
- package/dist/ai-edits/retired-comment-receipts.d.ts +1 -1
- package/dist/ai-edits/snapshot.js +9 -4
- package/dist/ai-edits/table-cell-mutations.d.ts +1 -1
- package/dist/ai-edits/table-cell-mutations.js +2 -2
- package/dist/ai-edits/table-geometry.d.ts +1 -1
- package/dist/ai-edits/table-geometry.js +1 -1
- package/dist/ai-edits/table-row-column-mutations.d.ts +1 -1
- package/dist/ai-edits/table-row-column-mutations.js +1 -1
- package/dist/ai-edits/tableNodes.d.ts +38 -0
- package/dist/ai-edits/tableNodes.js +86 -0
- package/dist/ai-edits/tracked-batch-fidelity.d.ts +1 -1
- package/dist/ai-edits/tracked-batch-fidelity.js +1 -1
- package/dist/ai-edits/undefinedReferences.d.ts +7 -0
- package/dist/canonical/batchCommentReferences.js +1 -0
- package/dist/canonical/canonicalInlineGaps.d.ts +56 -0
- package/dist/canonical/canonicalInlineGaps.js +118 -0
- package/dist/canonical/canonicalInlineProjection.d.ts +4 -13
- package/dist/canonical/canonicalInlineProjection.js +5 -27
- package/dist/canonical/canonicalProjectionBlocks.d.ts +4 -4
- package/dist/canonical/canonicalPublicOperations.js +282 -75
- package/dist/canonical/canonicalSelection.js +1 -1
- package/dist/canonical/canonicalSession.d.ts +9 -1
- package/dist/canonical/canonicalSession.js +106 -33
- package/dist/compare/compare.d.ts +1 -1
- package/dist/compare/inline-atoms-model.d.ts +1 -1
- package/dist/compare/inline-atoms.d.ts +2 -2
- package/dist/compare/inline-provenance-model.d.ts +1 -1
- package/dist/compare/inline-provenance.d.ts +2 -2
- package/dist/compat/eigenpal.d.ts +3 -3
- package/dist/compat/eigenpal.js +2 -3
- package/dist/controller/autocompleteSuggestion.js +1 -1
- package/dist/controller/canonicalClipboard.d.ts +13 -3
- package/dist/controller/canonicalClipboard.js +186 -50
- package/dist/controller/canonicalClipboardResources.d.ts +9 -1
- package/dist/controller/canonicalClipboardResources.js +22 -2
- package/dist/controller/canonicalComposition.js +1 -1
- package/dist/controller/canonicalInput.js +1 -1
- package/dist/controller/canonicalPresence.js +1 -1
- package/dist/controller/canonicalReview.d.ts +1 -1
- package/dist/controller/canonicalReview.js +1 -1
- package/dist/controller/canonicalRoomAuthority.js +1 -1
- package/dist/controller/canonicalRoomWire.js +1 -1
- package/dist/controller/canonicalStructure.js +1 -1
- package/dist/controller/canonicalTabRoom.js +1 -1
- package/dist/controller/canonicalWatermark.d.ts +10 -0
- package/dist/controller/canonicalWatermark.js +37 -0
- package/dist/controller/canonicalYjsRoom.js +1 -1
- package/dist/controller/hiddenEditorApi.d.ts +1 -1
- package/dist/controller/hiddenEditorApi.js +2 -17
- package/dist/controller/hiddenEditorManager.d.ts +4 -3
- package/dist/controller/hiddenEditorManager.js +79 -23
- package/dist/document-operations.d.ts +1 -14
- package/dist/document-operations.js +1 -278
- package/dist/docx/canonicalSave.d.ts +1 -1
- package/dist/docx/canonicalSave.js +1 -1
- package/dist/docx/canonicalSessionInput.js +1 -1
- package/dist/docx/containerChildren.js +1 -1
- package/dist/docx/createDocx.d.ts +4 -0
- package/dist/docx/createDocx.js +6 -0
- package/dist/docx/paragraphParser.js +2 -2
- package/dist/docx/paragraphPropertySource.d.ts +1 -1
- package/dist/docx/parser.js +1 -1
- package/dist/docx/reviewResolutionProvenance.d.ts +3 -2
- package/dist/docx/reviewResolutionProvenance.js +31 -8
- package/dist/docx/revisionIdNormalization.js +30 -7
- package/dist/docx/rezip.d.ts +1 -1
- package/dist/docx/rezip.js +1 -1
- package/dist/docx/serializer/tableSerializer.js +4 -36
- package/dist/docx/server/templatePlan/apply.d.ts +15 -0
- package/dist/docx/server/templatePlan/apply.js +658 -0
- package/dist/docx/server/templatePlan/blocks.d.ts +97 -0
- package/dist/docx/server/templatePlan/blocks.js +355 -0
- package/dist/docx/server/templatePlan/builders.d.ts +72 -0
- package/dist/docx/server/templatePlan/builders.js +237 -0
- package/dist/docx/server/templatePlan/emit.d.ts +118 -0
- package/dist/docx/server/templatePlan/emit.js +466 -0
- package/dist/docx/server/templatePlan/emphasis.d.ts +62 -0
- package/dist/docx/server/templatePlan/emphasis.js +173 -0
- package/dist/docx/server/templatePlan/inspect.d.ts +22 -0
- package/dist/docx/server/templatePlan/inspect.js +230 -0
- package/dist/docx/server/templatePlan/labels.d.ts +45 -0
- package/dist/docx/server/templatePlan/labels.js +155 -0
- package/dist/docx/server/templatePlan/package.d.ts +34 -0
- package/dist/docx/server/templatePlan/package.js +99 -0
- package/dist/docx/server/templatePlan/plan.d.ts +145 -0
- package/dist/docx/server/templatePlan/plan.js +875 -0
- package/dist/docx/server/templatePlan/planShape.d.ts +9 -0
- package/dist/docx/server/templatePlan/planShape.js +180 -0
- package/dist/docx/server/templatePlan/resources.d.ts +41 -0
- package/dist/docx/server/templatePlan/resources.js +136 -0
- package/dist/docx/server/templatePlan/story.d.ts +128 -0
- package/dist/docx/server/templatePlan/story.js +440 -0
- package/dist/docx/server/templatePlan/types.d.ts +442 -0
- package/dist/docx/server/templatePlan/types.js +29 -0
- package/dist/docx/server/templatePlan/verify.d.ts +40 -0
- package/dist/docx/server/templatePlan/verify.js +976 -0
- package/dist/docx/server/templatePlan/xml.d.ts +74 -0
- package/dist/docx/server/templatePlan/xml.js +125 -0
- package/dist/docx/settingsHeaderFooterUpdate.d.ts +9 -0
- package/dist/docx/settingsHeaderFooterUpdate.js +45 -10
- package/dist/docx/structuralXmlPatch.js +9 -1
- package/dist/docx/tableGridXml.d.ts +30 -0
- package/dist/docx/tableGridXml.js +54 -0
- package/dist/docx/tableParser.js +7 -0
- package/dist/i18n/loadMessages.d.ts +5 -0
- package/dist/i18n/loadMessages.js +46 -0
- package/dist/i18n/locales.d.ts +3 -0
- package/dist/i18n/locales.js +17 -0
- package/dist/i18n/messages.d.ts +3 -2
- package/dist/i18n/messages.js +4 -16
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -3
- package/dist/internal/clipboardTransformPlugin.d.ts +3 -0
- package/dist/internal/clipboardTransformPlugin.js +13 -0
- package/dist/internal/extensionRuntime.d.ts +7 -0
- package/dist/internal/extensionRuntime.js +28 -0
- package/dist/internal/starterKitExtensions.d.ts +20 -0
- package/dist/internal/starterKitExtensions.js +123 -0
- package/dist/internal/wholeStoryRevisionResolution.js +1 -1
- package/dist/managers/ContextMenuManager.js +2 -1
- package/dist/managers/editorShortcuts.d.ts +1 -1
- package/dist/prosemirror/anchoredTextBoxes.d.ts +1 -1
- package/dist/prosemirror/attrs/index.js +1 -1
- package/dist/prosemirror/canonicalCommands.d.ts +1 -1
- package/dist/prosemirror/canonicalSelectionRange.d.ts +1 -1
- package/dist/prosemirror/canonicalSelectionRange.js +1 -1
- package/dist/prosemirror/canonicalTableCommands.js +3 -3
- package/dist/prosemirror/commands/comments.js +4 -4
- package/dist/prosemirror/commands/contentControls.d.ts +1 -1
- package/dist/prosemirror/commands/contentControls.js +1 -1
- package/dist/prosemirror/commands/formatPainter.d.ts +1 -1
- package/dist/prosemirror/commands/formatting.d.ts +1 -1
- package/dist/prosemirror/commands/pastePlainText.d.ts +1 -1
- package/dist/prosemirror/commands/pastePlainText.js +2 -3
- package/dist/prosemirror/commands/replaceRangeText.js +1 -1
- package/dist/prosemirror/commands/sectionBreak.js +1 -1
- package/dist/prosemirror/commands/tableCellMergeResolution.d.ts +1 -1
- package/dist/prosemirror/commands/tableMergeFoldDecisions.d.ts +1 -1
- package/dist/prosemirror/commentRecords.d.ts +1 -1
- package/dist/prosemirror/commentRecords.js +2 -2
- package/dist/prosemirror/contentControlRevisions.d.ts +1 -1
- package/dist/prosemirror/conversion/fromProseDoc.d.ts +0 -5
- package/dist/prosemirror/conversion/fromProseDoc.js +2 -9
- package/dist/prosemirror/conversion/index.d.ts +2 -2
- package/dist/prosemirror/conversion/index.js +2 -2
- package/dist/prosemirror/documentStructureCounts.d.ts +24 -0
- package/dist/prosemirror/documentStructureCounts.js +76 -0
- package/dist/prosemirror/extensions/ExtensionManager.d.ts +1 -1
- package/dist/prosemirror/extensions/ExtensionManager.js +4 -22
- package/dist/prosemirror/extensions/StarterKit.d.ts +4 -27
- package/dist/prosemirror/extensions/StarterKit.js +29 -115
- package/dist/prosemirror/extensions/core/ParagraphExtension.js +1 -1
- package/dist/prosemirror/extensions/core/historyCommands.d.ts +16 -0
- package/dist/prosemirror/extensions/core/historyCommands.js +19 -0
- package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.js +1 -1
- package/dist/prosemirror/extensions/features/BaseKeymapExtension.js +1 -1
- package/dist/prosemirror/extensions/features/ListExtension.js +7 -2
- package/dist/prosemirror/extensions/features/pastedCellSections.d.ts +1 -1
- package/dist/prosemirror/extensions/index.d.ts +2 -1
- package/dist/prosemirror/extensions/marks/FootnoteRefExtension.js +8 -3
- package/dist/prosemirror/extensions/marks/markUtils.d.ts +1 -1
- package/dist/prosemirror/extensions/nodes/TableExtension.d.ts +1 -1
- package/dist/prosemirror/extensions/nodes/TableExtension.js +8 -41
- package/dist/prosemirror/extensions/types.d.ts +1 -1
- package/dist/prosemirror/findReplaceSelection.d.ts +1 -1
- package/dist/prosemirror/hyperlinkRemoval.d.ts +1 -1
- package/dist/prosemirror/hyperlinkRemoval.js +7 -2
- package/dist/prosemirror/index.d.ts +3 -3
- package/dist/prosemirror/index.js +3 -3
- package/dist/prosemirror/insertionGaps.d.ts +1 -1
- package/dist/prosemirror/keptRangeBoundaries.d.ts +1 -1
- package/dist/prosemirror/keptRangeBoundaries.js +1 -1
- package/dist/prosemirror/listNumbering.d.ts +1 -1
- package/dist/prosemirror/listNumbering.js +1 -1
- package/dist/prosemirror/lockedControls.d.ts +1 -1
- package/dist/prosemirror/markupViewProjection.d.ts +1 -1
- package/dist/prosemirror/noteReferenceOccurrences.d.ts +1 -1
- package/dist/prosemirror/noteReferenceOccurrences.js +1 -1
- package/dist/prosemirror/noteReferenceReview.d.ts +2 -56
- package/dist/prosemirror/noteReferenceReview.js +2 -243
- package/dist/prosemirror/{extensions/features/ParaIdAllocatorExtension.d.ts → paraIds.d.ts} +13 -23
- package/dist/prosemirror/paraIds.js +152 -0
- package/dist/prosemirror/paragraphChangeTrackerMeta.d.ts +97 -0
- package/dist/prosemirror/paragraphChangeTrackerMeta.js +87 -0
- package/dist/prosemirror/paragraphMarkJoin.d.ts +1 -1
- package/dist/prosemirror/paragraphPropertyCarry.d.ts +1 -1
- package/dist/prosemirror/pastedCommentCopies.d.ts +1 -1
- package/dist/prosemirror/plugins/createDocScanPlugin.d.ts +1 -1
- package/dist/prosemirror/plugins/documentNumbering.d.ts +1 -1
- package/dist/prosemirror/plugins/documentNumbering.js +1 -1
- package/dist/prosemirror/plugins/documentStyles.js +1 -1
- package/dist/prosemirror/plugins/templateDirectives.d.ts +1 -1
- package/dist/prosemirror/rebaseParagraphRunFormatting.d.ts +1 -1
- package/dist/prosemirror/rebaseParagraphRuns.d.ts +1 -1
- package/dist/prosemirror/rejoinRunCarriers.d.ts +1 -1
- package/dist/prosemirror/replacedAnnotations.d.ts +1 -1
- package/dist/prosemirror/replacedAnnotations.js +17 -2
- package/dist/prosemirror/revisionCarriers.d.ts +1 -1
- package/dist/prosemirror/runFormattingInlineCarriers.d.ts +1 -1
- package/dist/prosemirror/sectionMarkEdits.d.ts +1 -1
- package/dist/prosemirror/selectionBounds.d.ts +10 -0
- package/dist/prosemirror/selectionBounds.js +22 -0
- package/dist/prosemirror/storyListNumbering.d.ts +1 -1
- package/dist/prosemirror/suggestionCommands.d.ts +47 -0
- package/dist/prosemirror/suggestionCommands.js +31 -0
- package/dist/prosemirror/tableCellPaste.d.ts +1 -1
- package/dist/prosemirror/tableCellPaste.js +1 -1
- package/dist/prosemirror/tableGridMutation.d.ts +1 -1
- package/dist/prosemirror/tableRunIn.js +1 -1
- package/dist/prosemirror/textInput.d.ts +1 -1
- package/dist/prosemirror/textInput.js +1 -1
- package/dist/server.d.ts +7 -2
- package/dist/server.js +6 -1
- package/dist/types/canonicalCapabilities.d.ts +13 -92
- package/dist/types/canonicalCapabilities.js +11 -85
- package/package.json +4 -4
- package/dist/ai-edits/apply.d.ts +0 -202
- package/dist/ai-edits/apply.js +0 -6759
- package/dist/ai-edits/note-story-inventory.d.ts +0 -5
- package/dist/ai-edits/note-story-inventory.js +0 -10
- package/dist/ai-edits/revisionStretches.d.ts +0 -32
- package/dist/ai-edits/revisionStretches.js +0 -147
- package/dist/prosemirror/extensions/core/HistoryExtension.d.ts +0 -18
- package/dist/prosemirror/extensions/core/HistoryExtension.js +0 -122
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.js +0 -408
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.d.ts +0 -135
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.js +0 -566
- package/dist/prosemirror/plugins/suggestionMode.d.ts +0 -92
- package/dist/prosemirror/plugins/suggestionMode.js +0 -1515
- package/dist/prosemirror/tablePositionedBookmarks.d.ts +0 -8
- package/dist/prosemirror/tablePositionedBookmarks.js +0 -80
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { document_d_exports } from "../types/document.js";
|
|
2
|
+
import { Node } from "prosemirror-model";
|
|
3
|
+
export type DocumentStructureCounts = {
|
|
4
|
+
blockStructureFingerprint: string;
|
|
5
|
+
sectionRecords: ReadonlySet<document_d_exports.SectionProperties>;
|
|
6
|
+
paragraphs: number;
|
|
7
|
+
/**
|
|
8
|
+
* Distinct section records the paragraphs carry, which is the number of
|
|
9
|
+
* `w:sectPr` the package states for them. A split copies a node's attrs, so
|
|
10
|
+
* both halves of a split section-ending paragraph hold one record until the
|
|
11
|
+
* from-leg keeps it on the trailing half: one section, not two.
|
|
12
|
+
*/
|
|
13
|
+
sectionEndpoints: number;
|
|
14
|
+
sectionEndpointFingerprint: string;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Count the structural values the tracker compares for every transaction.
|
|
18
|
+
*
|
|
19
|
+
* Each top-level block's records are kept for the block node, so a keystroke
|
|
20
|
+
* recomputes only the block it changed. The fingerprint joins the blocks'
|
|
21
|
+
* records in order: two documents' fingerprints are equal exactly when their
|
|
22
|
+
* full record lists (every block and nested block with its path) are.
|
|
23
|
+
*/
|
|
24
|
+
export declare function countDocumentStructure(doc: Node): DocumentStructureCounts;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { canonicalJson } from "../utils/canonicalJson.js";
|
|
2
|
+
import { sectionPropertiesOf } from "./sectionCarrier.js";
|
|
3
|
+
// src/prosemirror/documentStructureCounts.ts
|
|
4
|
+
const blockStructures = /* @__PURE__ */ new WeakMap();
|
|
5
|
+
const relativePath = (parentPath, index) => parentPath.length === 0 ? `${index}` : `${parentPath}.${index}`;
|
|
6
|
+
const blockStructureOf = (block) => {
|
|
7
|
+
const cached = blockStructures.get(block);
|
|
8
|
+
if (cached) return cached;
|
|
9
|
+
const records = [];
|
|
10
|
+
const endpoints = [];
|
|
11
|
+
let paragraphs = 0;
|
|
12
|
+
const visit = (node, path) => {
|
|
13
|
+
records.push(node.type.name === "paragraph" ? [
|
|
14
|
+
path,
|
|
15
|
+
node.type.name,
|
|
16
|
+
node.attrs["paraId"] ?? null
|
|
17
|
+
] : [
|
|
18
|
+
path,
|
|
19
|
+
node.type.name,
|
|
20
|
+
canonicalJson(node.attrs)
|
|
21
|
+
]);
|
|
22
|
+
if (node.type.name === "paragraph") {
|
|
23
|
+
paragraphs++;
|
|
24
|
+
const sectionProperties = sectionPropertiesOf(node);
|
|
25
|
+
if (sectionProperties !== null) endpoints.push({
|
|
26
|
+
path,
|
|
27
|
+
paraId: node.attrs["paraId"] ?? null,
|
|
28
|
+
sectionProperties
|
|
29
|
+
});
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
node.forEach((child, _offset, index) => visit(child, relativePath(path, index)));
|
|
33
|
+
};
|
|
34
|
+
visit(block, "");
|
|
35
|
+
const structure = {
|
|
36
|
+
records: JSON.stringify(records),
|
|
37
|
+
paragraphs,
|
|
38
|
+
endpoints
|
|
39
|
+
};
|
|
40
|
+
blockStructures.set(block, structure);
|
|
41
|
+
return structure;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Count the structural values the tracker compares for every transaction.
|
|
45
|
+
*
|
|
46
|
+
* Each top-level block's records are kept for the block node, so a keystroke
|
|
47
|
+
* recomputes only the block it changed. The fingerprint joins the blocks'
|
|
48
|
+
* records in order: two documents' fingerprints are equal exactly when their
|
|
49
|
+
* full record lists (every block and nested block with its path) are.
|
|
50
|
+
*/
|
|
51
|
+
function countDocumentStructure(doc) {
|
|
52
|
+
let paragraphs = 0;
|
|
53
|
+
const sectionRecords = /* @__PURE__ */ new Set();
|
|
54
|
+
const blockRecords = [];
|
|
55
|
+
const endpointRecords = [];
|
|
56
|
+
doc.forEach((block, _offset, index) => {
|
|
57
|
+
const structure = blockStructureOf(block);
|
|
58
|
+
blockRecords.push(structure.records);
|
|
59
|
+
paragraphs += structure.paragraphs;
|
|
60
|
+
for (const endpoint of structure.endpoints) {
|
|
61
|
+
sectionRecords.add(endpoint.sectionProperties);
|
|
62
|
+
endpointRecords.push({
|
|
63
|
+
...endpoint,
|
|
64
|
+
path: endpoint.path.length === 0 ? `${index}` : `${index}.${endpoint.path}`
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
return {
|
|
69
|
+
blockStructureFingerprint: blockRecords.join(""),
|
|
70
|
+
sectionRecords,
|
|
71
|
+
paragraphs,
|
|
72
|
+
sectionEndpoints: sectionRecords.size,
|
|
73
|
+
sectionEndpointFingerprint: canonicalJson(endpointRecords)
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
export { countDocumentStructure };
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
* 2. initializeRuntime() — calls onSchemaReady() on each extension, collects plugins/commands/keymaps
|
|
7
7
|
*/
|
|
8
8
|
import { AnyExtension, CommandFactory, CommandMap, FolioCommandArguments, FolioCommandName } from "./types.js";
|
|
9
|
-
import { Schema } from "prosemirror-model";
|
|
10
9
|
import { Plugin } from "prosemirror-state";
|
|
10
|
+
import { Schema } from "prosemirror-model";
|
|
11
11
|
export declare class ExtensionManager {
|
|
12
12
|
private readonly extensions;
|
|
13
13
|
private schema;
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { areTransactionInvariantsEnabled, createTransactionInvariantPlugin } from "../plugins/transactionInvariants.js";
|
|
3
|
-
import { createTextInputPlugin } from "../textInput.js";
|
|
1
|
+
import { createExtensionRuntime } from "../../internal/extensionRuntime.js";
|
|
4
2
|
import { panic } from "better-result";
|
|
5
3
|
import { Schema } from "prosemirror-model";
|
|
6
|
-
import { keymap } from "prosemirror-keymap";
|
|
7
4
|
// src/prosemirror/extensions/ExtensionManager.ts
|
|
8
5
|
/**
|
|
9
6
|
* Extension Manager
|
|
@@ -39,24 +36,9 @@ var ExtensionManager = class {
|
|
|
39
36
|
*/
|
|
40
37
|
initializeRuntime() {
|
|
41
38
|
if (!this.schema) panic("ExtensionManager: buildSchema() must be called before initializeRuntime()");
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const allCommands = {};
|
|
46
|
-
for (const ext of this.extensions) {
|
|
47
|
-
const runtime = ext.onSchemaReady(ctx);
|
|
48
|
-
if (runtime.commands) Object.assign(allCommands, runtime.commands);
|
|
49
|
-
if (runtime.keyboardShortcuts) allKeyboardShortcuts.push(runtime.keyboardShortcuts);
|
|
50
|
-
if (runtime.plugins) allPlugins.push(...runtime.plugins);
|
|
51
|
-
}
|
|
52
|
-
this.plugins = [
|
|
53
|
-
createTextInputPlugin(),
|
|
54
|
-
createNativeNavigationPlugin(),
|
|
55
|
-
...allPlugins,
|
|
56
|
-
...allKeyboardShortcuts.map((shortcuts) => keymap(shortcuts)),
|
|
57
|
-
...areTransactionInvariantsEnabled() ? [createTransactionInvariantPlugin()] : []
|
|
58
|
-
];
|
|
59
|
-
this.commands = allCommands;
|
|
39
|
+
const runtime = createExtensionRuntime(this.extensions, this.schema);
|
|
40
|
+
this.plugins = runtime.plugins;
|
|
41
|
+
this.commands = runtime.commandRegistry;
|
|
60
42
|
}
|
|
61
43
|
/**
|
|
62
44
|
* Get the built schema
|
|
@@ -1,28 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
* StarterKit — bundles all extensions into a ready-to-use set
|
|
3
|
-
*
|
|
4
|
-
* Usage:
|
|
5
|
-
* const extensions = createStarterKit();
|
|
6
|
-
* const manager = new ExtensionManager(extensions);
|
|
7
|
-
* manager.buildSchema();
|
|
8
|
-
* manager.initializeRuntime();
|
|
9
|
-
*/
|
|
10
|
-
import { SelectionChangeCallback } from "../plugins/selectionTracker.js";
|
|
11
|
-
import { HistoryShortcutOwner } from "./core/HistoryExtension.js";
|
|
1
|
+
import { StarterKitOptions } from "../../internal/starterKitExtensions.js";
|
|
12
2
|
import { AnyExtension } from "./types.js";
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
/** History depth (default: 100) */
|
|
17
|
-
historyDepth?: number;
|
|
18
|
-
/** History new group delay (default: 500) */
|
|
19
|
-
historyNewGroupDelay?: number;
|
|
20
|
-
/** Who answers the undo and redo keys (default: `"editor"`). */
|
|
21
|
-
historyShortcuts?: HistoryShortcutOwner;
|
|
22
|
-
/** Selection change callback */
|
|
23
|
-
onSelectionChange?: SelectionChangeCallback;
|
|
24
|
-
};
|
|
25
|
-
/**
|
|
26
|
-
* Create the full set of extensions for the DOCX editor
|
|
27
|
-
*/
|
|
28
|
-
export declare function createStarterKit(options?: StarterKitOptions): AnyExtension[];
|
|
3
|
+
/** Create the schema, commands, keymaps and clipboard rules for the DOCX editor. */
|
|
4
|
+
export declare function createStarterKit(options?: StarterKitOptions): AnyExtension[];
|
|
5
|
+
export type { StarterKitOptions };
|
|
@@ -1,121 +1,35 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { TextExtension } from "./core/TextExtension.js";
|
|
5
|
-
import { AutoBidiDetectionExtension } from "./features/AutoBidiDetectionExtension.js";
|
|
6
|
-
import { BaseKeymapExtension } from "./features/BaseKeymapExtension.js";
|
|
7
|
-
import { BidiShortcutExtension } from "./features/BidiShortcutExtension.js";
|
|
8
|
-
import { ContentControlWidgetsExtension } from "./features/ContentControlWidgetsExtension.js";
|
|
9
|
-
import { DropCursorExtension } from "./features/DropCursorExtension.js";
|
|
10
|
-
import { EmptyParagraphFormatExtension } from "./features/EmptyParagraphFormatExtension.js";
|
|
11
|
-
import { GapCursorExtension } from "./features/GapCursorExtension.js";
|
|
12
|
-
import { ImageDragExtension } from "./features/ImageDragExtension.js";
|
|
13
|
-
import { ImagePasteExtension } from "./features/ImagePasteExtension.js";
|
|
14
|
-
import { JoinedRunStyleExtension } from "./features/JoinedRunStyleExtension.js";
|
|
15
|
-
import { ListExtension } from "./features/ListExtension.js";
|
|
16
|
-
import { ParaIdAllocatorExtension } from "./features/ParaIdAllocatorExtension.js";
|
|
17
|
-
import { ParagraphChangeTrackerExtension } from "./features/ParagraphChangeTrackerExtension.js";
|
|
18
|
-
import { PasteCleanupExtension } from "./features/PasteCleanupExtension.js";
|
|
19
|
-
import { PasteStyleInlinerExtension } from "./features/PasteStyleInlinerExtension.js";
|
|
20
|
-
import { SelectionTrackerExtension } from "./features/SelectionTrackerExtension.js";
|
|
21
|
-
import { MARK_EXTENSIONS, MARK_NESTING_ORDER } from "./markRegistry.js";
|
|
22
|
-
import { BlockBookmarkBoundaryExtension } from "./nodes/BlockBookmarkBoundaryExtension.js";
|
|
23
|
-
import { BlockCommentRangeBoundaryExtension } from "./nodes/BlockCommentRangeBoundaryExtension.js";
|
|
24
|
-
import { BlockCustomXmlExtension } from "./nodes/BlockCustomXmlExtension.js";
|
|
25
|
-
import { BlockMoveRangeBoundaryExtension } from "./nodes/BlockMoveRangeBoundaryExtension.js";
|
|
26
|
-
import { BlockSdtExtension } from "./nodes/BlockSdtExtension.js";
|
|
27
|
-
import { BookmarkBoundaryExtension } from "./nodes/BookmarkBoundaryExtension.js";
|
|
28
|
-
import { CommentRangeBoundaryExtension } from "./nodes/CommentRangeBoundaryExtension.js";
|
|
29
|
-
import { CommentReferenceExtension } from "./nodes/CommentReferenceExtension.js";
|
|
30
|
-
import { FieldExtension, StructuredFieldExtension } from "./nodes/FieldExtension.js";
|
|
31
|
-
import { HardBreakExtension } from "./nodes/HardBreakExtension.js";
|
|
32
|
-
import { HorizontalRuleExtension } from "./nodes/HorizontalRuleExtension.js";
|
|
33
|
-
import { ImageExtension } from "./nodes/ImageExtension.js";
|
|
34
|
-
import { MathExtension } from "./nodes/MathExtension.js";
|
|
35
|
-
import { MoveRangeBoundaryExtension } from "./nodes/MoveRangeBoundaryExtension.js";
|
|
36
|
-
import { NoteMarkerExtension } from "./nodes/NoteMarkerExtension.js";
|
|
37
|
-
import { PageBreakExtension } from "./nodes/PageBreakExtension.js";
|
|
38
|
-
import { PageBreakRunExtension } from "./nodes/PageBreakRunExtension.js";
|
|
39
|
-
import { PreservedBlockExtension } from "./nodes/PreservedBlockExtension.js";
|
|
40
|
-
import { PreservedXmlExtension } from "./nodes/PreservedXmlExtension.js";
|
|
41
|
-
import { RangeAnchorExtension } from "./nodes/RangeAnchorExtension.js";
|
|
42
|
-
import { RenderedPageBreakExtension } from "./nodes/RenderedPageBreakExtension.js";
|
|
43
|
-
import { SdtExtension } from "./nodes/SdtExtension.js";
|
|
44
|
-
import { ShapeExtension } from "./nodes/ShapeExtension.js";
|
|
45
|
-
import { SymbolExtension } from "./nodes/SymbolExtension.js";
|
|
46
|
-
import { TabExtension } from "./nodes/TabExtension.js";
|
|
47
|
-
import { createTableExtensions } from "./nodes/TableExtension.js";
|
|
48
|
-
import { TextBoxAnchorExtension } from "./nodes/TextBoxAnchorExtension.js";
|
|
49
|
-
import { TextBoxExtension } from "./nodes/TextBoxExtension.js";
|
|
1
|
+
import { clipboardTransformPlugin } from "../../internal/clipboardTransformPlugin.js";
|
|
2
|
+
import { createStarterKitExtensions } from "../../internal/starterKitExtensions.js";
|
|
3
|
+
import { Plugin } from "prosemirror-state";
|
|
50
4
|
// src/prosemirror/extensions/StarterKit.ts
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
5
|
+
const starterKitClipboardPlugins = (props) => {
|
|
6
|
+
const plugins = clipboardTransformPlugin(props);
|
|
7
|
+
const { handlePaste, handleDOMEvents } = props;
|
|
8
|
+
const paste = handleDOMEvents?.paste;
|
|
9
|
+
if (handlePaste !== void 0 || paste !== void 0) plugins.push(new Plugin({ props: {
|
|
10
|
+
...handlePaste === void 0 ? {} : { handlePaste },
|
|
11
|
+
...paste === void 0 ? {} : { handleDOMEvents: { paste } }
|
|
12
|
+
} }));
|
|
13
|
+
return plugins;
|
|
14
|
+
};
|
|
15
|
+
/** Create the schema, commands, keymaps and clipboard rules for the DOCX editor. */
|
|
54
16
|
function createStarterKit(options = {}) {
|
|
55
|
-
const
|
|
56
|
-
const extensions
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
17
|
+
const extensions = createStarterKitExtensions(options);
|
|
18
|
+
for (const extension of extensions) {
|
|
19
|
+
const { onSchemaReady } = extension;
|
|
20
|
+
extension.onSchemaReady = (ctx) => {
|
|
21
|
+
const { plugins, ...runtime } = onSchemaReady(ctx);
|
|
22
|
+
if (plugins === void 0) return runtime;
|
|
23
|
+
if (extension.config.name === "selectionTracker" && options.onSelectionChange) return {
|
|
24
|
+
...runtime,
|
|
25
|
+
plugins
|
|
26
|
+
};
|
|
27
|
+
return {
|
|
28
|
+
...runtime,
|
|
29
|
+
plugins: plugins.flatMap(({ props }) => starterKitClipboardPlugins(props))
|
|
30
|
+
};
|
|
31
|
+
};
|
|
64
32
|
}
|
|
65
|
-
add("doc", DocExtension());
|
|
66
|
-
add("text", TextExtension());
|
|
67
|
-
add("paragraph", ParagraphExtension());
|
|
68
|
-
add("history", HistoryExtension({
|
|
69
|
-
...options.historyDepth !== void 0 ? { depth: options.historyDepth } : {},
|
|
70
|
-
...options.historyNewGroupDelay !== void 0 ? { newGroupDelay: options.historyNewGroupDelay } : {},
|
|
71
|
-
...options.historyShortcuts !== void 0 ? { shortcuts: options.historyShortcuts } : {}
|
|
72
|
-
}));
|
|
73
|
-
for (const name of MARK_NESTING_ORDER) add(name, MARK_EXTENSIONS[name]({ getInternalClipboardToken }));
|
|
74
|
-
add("bookmarkBoundary", BookmarkBoundaryExtension({ getInternalClipboardToken }));
|
|
75
|
-
add("blockBookmarkBoundary", BlockBookmarkBoundaryExtension({ getInternalClipboardToken }));
|
|
76
|
-
add("blockMoveRangeBoundary", BlockMoveRangeBoundaryExtension({ getInternalClipboardToken }));
|
|
77
|
-
add("blockCommentRangeBoundary", BlockCommentRangeBoundaryExtension());
|
|
78
|
-
add("commentReference", CommentReferenceExtension({ getInternalClipboardToken }));
|
|
79
|
-
add("commentRangeBoundary", CommentRangeBoundaryExtension({ getInternalClipboardToken }));
|
|
80
|
-
add("moveRangeBoundary", MoveRangeBoundaryExtension({ getInternalClipboardToken }));
|
|
81
|
-
add("rangeAnchor", RangeAnchorExtension({ getInternalClipboardToken }));
|
|
82
|
-
add("hardBreak", HardBreakExtension());
|
|
83
|
-
add("tab", TabExtension());
|
|
84
|
-
add("symbol", SymbolExtension());
|
|
85
|
-
add("preservedXml", PreservedXmlExtension());
|
|
86
|
-
add("noteMarker", NoteMarkerExtension());
|
|
87
|
-
add("image", ImageExtension());
|
|
88
|
-
add("textBox", TextBoxExtension());
|
|
89
|
-
add("textBoxAnchor", TextBoxAnchorExtension({ getInternalClipboardToken }));
|
|
90
|
-
add("shape", ShapeExtension());
|
|
91
|
-
add("imageDrag", ImageDragExtension());
|
|
92
|
-
add("imagePaste", ImagePasteExtension());
|
|
93
|
-
add("dropCursor", DropCursorExtension());
|
|
94
|
-
add("gapCursor", GapCursorExtension());
|
|
95
|
-
add("horizontalRule", HorizontalRuleExtension());
|
|
96
|
-
add("pageBreak", PageBreakExtension());
|
|
97
|
-
add("pageBreakRun", PageBreakRunExtension());
|
|
98
|
-
add("renderedPageBreak", RenderedPageBreakExtension());
|
|
99
|
-
add("field", FieldExtension({ getInternalClipboardToken }));
|
|
100
|
-
add("field", StructuredFieldExtension({ getInternalClipboardToken }));
|
|
101
|
-
add("sdt", SdtExtension());
|
|
102
|
-
add("blockSdt", BlockSdtExtension());
|
|
103
|
-
add("blockCustomXml", BlockCustomXmlExtension());
|
|
104
|
-
add("preservedBlock", PreservedBlockExtension());
|
|
105
|
-
add("math", MathExtension());
|
|
106
|
-
if (!disabled.has("table")) extensions.push(...createTableExtensions());
|
|
107
|
-
add("pasteCleanup", PasteCleanupExtension({ getInternalClipboardToken }));
|
|
108
|
-
add("pasteStyleInliner", PasteStyleInlinerExtension());
|
|
109
|
-
add("list", ListExtension());
|
|
110
|
-
add("baseKeymap", BaseKeymapExtension());
|
|
111
|
-
add("emptyParagraphFormat", EmptyParagraphFormatExtension());
|
|
112
|
-
add("joinedRunStyle", JoinedRunStyleExtension());
|
|
113
|
-
add("selectionTracker", options.onSelectionChange === void 0 ? SelectionTrackerExtension() : SelectionTrackerExtension({ onSelectionChange: options.onSelectionChange }));
|
|
114
|
-
add("paraIdAllocator", ParaIdAllocatorExtension());
|
|
115
|
-
add("paragraphChangeTracker", ParagraphChangeTrackerExtension());
|
|
116
|
-
add("bidiShortcut", BidiShortcutExtension());
|
|
117
|
-
add("autoBidiDetection", AutoBidiDetectionExtension());
|
|
118
|
-
add("contentControlWidgets", ContentControlWidgetsExtension());
|
|
119
33
|
return extensions;
|
|
120
34
|
}
|
|
121
35
|
export { createStarterKit };
|
|
@@ -20,10 +20,10 @@ import { recordReplacedParagraphProperties } from "../../paragraphPropertyCarry.
|
|
|
20
20
|
import { directParagraphSpacing, withDirectParagraphSpacing } from "../../paragraphSpacing.js";
|
|
21
21
|
import { getDocumentNumbering } from "../../plugins/documentNumbering.js";
|
|
22
22
|
import { getDocumentBuiltInStyles, getDocumentStyleResolver } from "../../plugins/documentStyleState.js";
|
|
23
|
-
import { SUGGESTION_META, makeRevisionInfo } from "../../plugins/suggestionMode.js";
|
|
24
23
|
import { rebaseParagraphRuns } from "../../rebaseParagraphRuns.js";
|
|
25
24
|
import { mintSectionProperties, parseSectionBreakType, sectionBreakTypeOf } from "../../sectionCarrier.js";
|
|
26
25
|
import { listAttrsFromResolvedStyle, listIndentationProvenancePatch, paragraphAttrsFromResolvedStyle } from "../../styles/resolvedStyleAttrs.js";
|
|
26
|
+
import { SUGGESTION_META, makeRevisionInfo } from "../../suggestionCommands.js";
|
|
27
27
|
import { createNodeExtension } from "../create.js";
|
|
28
28
|
import { headingOutlineLevel } from "@stll/docx-core/model";
|
|
29
29
|
import { Fragment } from "prosemirror-model";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Undo and redo: the commands and the keys that run them, apart from the
|
|
3
|
+
* `prosemirror-history` plugin that keeps the stack.
|
|
4
|
+
*/
|
|
5
|
+
import { KeyboardShortcutMap } from "../types.js";
|
|
6
|
+
import { Command } from "prosemirror-state";
|
|
7
|
+
/**
|
|
8
|
+
* Who answers the undo and redo keys (Mod-z, Mod-y, Mod-Shift-z).
|
|
9
|
+
* - `"editor"`: the extension binds them. Default.
|
|
10
|
+
* - `"host"`: nothing binds them. The host keeps its own undo stack and runs
|
|
11
|
+
* the `undo` / `redo` commands itself, so one press never undoes twice.
|
|
12
|
+
*/
|
|
13
|
+
export type HistoryShortcutOwner = "editor" | "host";
|
|
14
|
+
export declare const undoCommand: () => Command;
|
|
15
|
+
export declare const redoCommand: () => Command;
|
|
16
|
+
export declare const historyKeyboardShortcuts: KeyboardShortcutMap;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { withCanonicalHistory } from "../../canonicalCommands.js";
|
|
2
|
+
import { redo, undo } from "prosemirror-history";
|
|
3
|
+
// src/prosemirror/extensions/core/historyCommands.ts
|
|
4
|
+
/**
|
|
5
|
+
* Undo and redo: the commands and the keys that run them, apart from the
|
|
6
|
+
* `prosemirror-history` plugin that keeps the stack.
|
|
7
|
+
*/
|
|
8
|
+
const undoCommand = () => withCanonicalHistory(undo, "undo");
|
|
9
|
+
const redoCommand = () => withCanonicalHistory(redo, "redo");
|
|
10
|
+
const consumeHistoryShortcut = (command) => (state, dispatch, view) => {
|
|
11
|
+
command(state, dispatch, view);
|
|
12
|
+
return true;
|
|
13
|
+
};
|
|
14
|
+
const historyKeyboardShortcuts = {
|
|
15
|
+
"Mod-z": consumeHistoryShortcut(undo),
|
|
16
|
+
"Mod-y": consumeHistoryShortcut(redo),
|
|
17
|
+
"Mod-Shift-z": consumeHistoryShortcut(redo)
|
|
18
|
+
};
|
|
19
|
+
export { historyKeyboardShortcuts, redoCommand, undoCommand };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { setProseParagraphMarkupWithPropertySource } from "../../../docx/paragraphPropertySource.js";
|
|
2
2
|
import { getTransactionDirtyRange } from "../../../paged-layout/transactionDirtyRange.js";
|
|
3
3
|
import { detectBaseDirection } from "../../../utils/baseDirection.js";
|
|
4
|
+
import { ignoreTrackedChanges } from "../../paragraphChangeTrackerMeta.js";
|
|
4
5
|
import { directionIsAutoManaged } from "../../paragraphDirection.js";
|
|
5
6
|
import { createPluginKeyOwner } from "../../pluginKeyOwner.js";
|
|
6
7
|
import { afterNativeCompositionFlush } from "../../textInput.js";
|
|
7
8
|
import { createExtension } from "../create.js";
|
|
8
|
-
import { ignoreTrackedChanges } from "./ParagraphChangeTrackerExtension.js";
|
|
9
9
|
import { Plugin } from "prosemirror-state";
|
|
10
10
|
// src/prosemirror/extensions/features/AutoBidiDetectionExtension.ts
|
|
11
11
|
/**
|
|
@@ -10,8 +10,8 @@ import { paragraphAttrsFromResolvedStyle } from "../../styles/resolvedStyleAttrs
|
|
|
10
10
|
import { createExtension } from "../create.js";
|
|
11
11
|
import { marksToTextFormatting, textFormattingToMarks } from "../marks/markUtils.js";
|
|
12
12
|
import { Priority } from "../types.js";
|
|
13
|
-
import { EditorState, TextSelection } from "prosemirror-state";
|
|
14
13
|
import { baseKeymap, deleteSelection, joinBackward, joinForward, selectAll, selectParentNode, splitBlock } from "prosemirror-commands";
|
|
14
|
+
import { EditorState, TextSelection } from "prosemirror-state";
|
|
15
15
|
// src/prosemirror/extensions/features/BaseKeymapExtension.ts
|
|
16
16
|
/**
|
|
17
17
|
* Base Keymap Extension — wraps prosemirror-commands baseKeymap
|
|
@@ -7,8 +7,8 @@ import { applyParagraphUpdates, continueNumbering, listItemAttrs, resolveListTar
|
|
|
7
7
|
import { resolveListState } from "../../listState.js";
|
|
8
8
|
import { effectiveParagraphNumberingReference, paragraphNumberingSourcesFromBoundary, removedNumberingAttr } from "../../numberingAttr.js";
|
|
9
9
|
import { getDocumentNumbering } from "../../plugins/documentNumbering.js";
|
|
10
|
-
import { SUGGESTION_META, makeRevisionInfo, suggestRangeDeletion } from "../../plugins/suggestionMode.js";
|
|
11
10
|
import { listLevelAttrPatch, listLevelIndentRemovalPatch } from "../../styles/resolvedStyleAttrs.js";
|
|
11
|
+
import { SUGGESTION_META, makeRevisionInfo, suggestRangeDeletion } from "../../suggestionCommands.js";
|
|
12
12
|
import { createExtension } from "../create.js";
|
|
13
13
|
import { goToNextCell, goToPrevCell } from "../nodes/TableExtension.js";
|
|
14
14
|
import { Priority } from "../types.js";
|
|
@@ -421,7 +421,12 @@ const suggestedListAutoformat = (autoformat) => new Plugin({ appendTransaction(t
|
|
|
421
421
|
if (!requests) return null;
|
|
422
422
|
const start = $head.start();
|
|
423
423
|
const tr = state.tr;
|
|
424
|
-
if (!suggestRangeDeletion(
|
|
424
|
+
if (!suggestRangeDeletion({
|
|
425
|
+
state,
|
|
426
|
+
tr,
|
|
427
|
+
from: start,
|
|
428
|
+
to: $head.pos
|
|
429
|
+
})) return null;
|
|
425
430
|
const from = tr.mapping.map(start);
|
|
426
431
|
if (!numberParagraphs({
|
|
427
432
|
state,
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* in a cell, or that stands in a pasted cell, comes without the break it ended
|
|
6
6
|
* its own section with.
|
|
7
7
|
*/
|
|
8
|
-
import { Node, Slice } from "prosemirror-model";
|
|
9
8
|
import { Transaction } from "prosemirror-state";
|
|
9
|
+
import { Node, Slice } from "prosemirror-model";
|
|
10
10
|
import { EditorView } from "prosemirror-view";
|
|
11
11
|
/**
|
|
12
12
|
* Where a drop put a section break in a table cell. The drop's target is not
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { StarterKitOptions } from "../../internal/starterKitExtensions.js";
|
|
1
2
|
import { ExtensionManager } from "./ExtensionManager.js";
|
|
2
|
-
import {
|
|
3
|
+
import { createStarterKit } from "./StarterKit.js";
|
|
3
4
|
export { ExtensionManager, type StarterKitOptions, createStarterKit };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { expectFootnoteRefMarkAttrs } from "../../attrs/index.js";
|
|
2
2
|
import { withCanonicalCommand } from "../../canonicalCommands.js";
|
|
3
3
|
import { mintNoteReferenceOccurrenceId, noteReferenceOccurrencePlugin } from "../../noteReferenceOccurrences.js";
|
|
4
|
-
import {
|
|
4
|
+
import { isSuggestionModeActive, suggestRangeDeletion } from "../../suggestionCommands.js";
|
|
5
5
|
import { createMarkExtension } from "../create.js";
|
|
6
6
|
import { expandNoteReferenceDeletionRange, noteReferenceRanges } from "./noteReferenceDeletion.js";
|
|
7
7
|
import { panic } from "better-result";
|
|
@@ -72,7 +72,7 @@ const FootnoteRefExtension = createMarkExtension({
|
|
|
72
72
|
},
|
|
73
73
|
onSchemaReady() {
|
|
74
74
|
const deleteWholeNoteReference = (direction) => (state, dispatch) => {
|
|
75
|
-
if (
|
|
75
|
+
if (isSuggestionModeActive(state)) return false;
|
|
76
76
|
const { from, to, empty } = state.selection;
|
|
77
77
|
const range = expandNoteReferenceDeletionRange(state.doc, empty && direction === "backward" ? Math.max(0, from - 1) : from, empty && direction === "forward" ? Math.min(state.doc.content.size, to + 1) : to);
|
|
78
78
|
if (!range) return false;
|
|
@@ -110,7 +110,12 @@ const FootnoteRefExtension = createMarkExtension({
|
|
|
110
110
|
if (references.length === 0) return false;
|
|
111
111
|
if (!dispatch) return true;
|
|
112
112
|
const tr = state.tr;
|
|
113
|
-
for (const reference of references.toReversed()) if (!suggestRangeDeletion(
|
|
113
|
+
for (const reference of references.toReversed()) if (!suggestRangeDeletion({
|
|
114
|
+
state,
|
|
115
|
+
tr,
|
|
116
|
+
from: reference.from,
|
|
117
|
+
to: reference.to
|
|
118
|
+
})) tr.delete(reference.from, reference.to);
|
|
114
119
|
dispatch(tr.scrollIntoView());
|
|
115
120
|
return true;
|
|
116
121
|
};
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
import { document_d_exports } from "../../../types/document.js";
|
|
8
8
|
import { DeepReadonly } from "../../../types/documentModel.js";
|
|
9
9
|
import { CanonicalCommandIntent } from "../../canonicalCommands.js";
|
|
10
|
-
import { Attrs, Mark, MarkType, Schema } from "prosemirror-model";
|
|
11
10
|
import { Command, EditorState } from "prosemirror-state";
|
|
11
|
+
import { Attrs, Mark, MarkType, Schema } from "prosemirror-model";
|
|
12
12
|
import { FormattingPatch } from "@stll/docx-core/ops";
|
|
13
13
|
type MarkAttrs = Record<string, unknown>;
|
|
14
14
|
export declare const withRunFormattingLock: (command: Command, describe: (state: EditorState) => readonly CanonicalCommandIntent[] | undefined) => Command;
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
import { ColorValue } from "../../../types/colors.js";
|
|
8
8
|
import { DeepReadonly } from "../../../types/documentModel.js";
|
|
9
9
|
import { AnyExtension, Extension, NodeExtension } from "../types.js";
|
|
10
|
-
import { Node } from "prosemirror-model";
|
|
11
10
|
import { Command, EditorState } from "prosemirror-state";
|
|
11
|
+
import { Node } from "prosemirror-model";
|
|
12
12
|
export type TableContextInfo = {
|
|
13
13
|
isInTable: boolean;
|
|
14
14
|
table?: Node;
|
|
@@ -8,16 +8,14 @@ import { textFlowCss } from "../../../utils/textDirectionFlow.js";
|
|
|
8
8
|
import { expectTableAttrs, expectTableCellAttrs, expectTableRowAttrs, mergeTableAttrs, mergeTableCellAttrs, mergeTableRowAttrs } from "../../attrs/index.js";
|
|
9
9
|
import { withCanonicalCellMerge, withCanonicalCellSplit, withCanonicalColumnDeletion, withCanonicalColumnInsertion, withCanonicalRowDeletion, withCanonicalRowInsertion, withCanonicalSelectionCommand, withCanonicalTableAttributeCommand, withCanonicalTableDeletion, withCanonicalTableInsertion } from "../../canonicalTableCommands.js";
|
|
10
10
|
import { mintRevisionId } from "../../plugins/revisionIds.js";
|
|
11
|
-
import { makeRevisionInfo } from "../../
|
|
11
|
+
import { makeRevisionInfo } from "../../suggestionCommands.js";
|
|
12
12
|
import { pasteTableCells, pastedSliceWithNewTableCells } from "../../tableCellPaste.js";
|
|
13
13
|
import { insertTableColumn, removeTableColumns, removeTableRow } from "../../tableGridMutation.js";
|
|
14
|
-
import { tablePositionedBookmarksPlugin } from "../../tablePositionedBookmarks.js";
|
|
15
14
|
import { createExtension, createNodeExtension } from "../create.js";
|
|
16
15
|
import { panic } from "better-result";
|
|
17
16
|
import { statesNoBorder } from "@stll/docx-core/model";
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import { Decoration, DecorationSet } from "prosemirror-view";
|
|
17
|
+
import { Plugin, Selection, TextSelection } from "prosemirror-state";
|
|
18
|
+
import { CellSelection, TableMap, mergeCells, selectedRect, splitCell, tableNodeTypes } from "prosemirror-tables";
|
|
21
19
|
// src/prosemirror/extensions/nodes/TableExtension.ts
|
|
22
20
|
/**
|
|
23
21
|
* Table Extension — 4 node specs + plugins + commands
|
|
@@ -1964,42 +1962,11 @@ const TablePluginExtension = createExtension({
|
|
|
1964
1962
|
return false;
|
|
1965
1963
|
};
|
|
1966
1964
|
}
|
|
1967
|
-
const activeCellKey = new PluginKey("activeCell");
|
|
1968
|
-
const activeCellPlugin = new Plugin({
|
|
1969
|
-
key: activeCellKey,
|
|
1970
|
-
props: { decorations(state) {
|
|
1971
|
-
const { selection } = state;
|
|
1972
|
-
if (selection instanceof CellSelection) return DecorationSet.empty;
|
|
1973
|
-
const { $from } = selection;
|
|
1974
|
-
for (let d = $from.depth; d > 0; d--) {
|
|
1975
|
-
const node = $from.node(d);
|
|
1976
|
-
if (node.type.name === "tableCell" || node.type.name === "tableHeader") {
|
|
1977
|
-
const pos = $from.before(d);
|
|
1978
|
-
return DecorationSet.create(state.doc, [Decoration.node(pos, pos + node.nodeSize, { class: "activeCell" })]);
|
|
1979
|
-
}
|
|
1980
|
-
}
|
|
1981
|
-
return DecorationSet.empty;
|
|
1982
|
-
} }
|
|
1983
|
-
});
|
|
1984
|
-
const tableCellPastePlugin = new Plugin({
|
|
1985
|
-
key: new PluginKey("tableCellPaste"),
|
|
1986
|
-
props: {
|
|
1987
|
-
transformPasted: (slice) => pastedSliceWithNewTableCells(slice),
|
|
1988
|
-
handlePaste: (view, _event, slice) => pasteTableCells(view.state, slice, view.dispatch)
|
|
1989
|
-
}
|
|
1990
|
-
});
|
|
1991
1965
|
return {
|
|
1992
|
-
plugins: [
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
lastColumnResizable: true
|
|
1997
|
-
}),
|
|
1998
|
-
tableCellPastePlugin,
|
|
1999
|
-
tableEditing(),
|
|
2000
|
-
tablePositionedBookmarksPlugin(),
|
|
2001
|
-
activeCellPlugin
|
|
2002
|
-
],
|
|
1966
|
+
plugins: [new Plugin({ props: {
|
|
1967
|
+
transformPasted: pastedSliceWithNewTableCells,
|
|
1968
|
+
handlePaste: (view, _event, slice) => pasteTableCells(view.state, slice, view.dispatch)
|
|
1969
|
+
} })],
|
|
2003
1970
|
keyboardShortcuts: {
|
|
2004
1971
|
Backspace: chainCommands(deleteTableIfSelected(), preventTableMergeAtGap()),
|
|
2005
1972
|
Delete: chainCommands(deleteTableIfSelected(), preventTableMergeAtGap())
|
|
@@ -2028,7 +1995,7 @@ const TablePluginExtension = createExtension({
|
|
|
2028
1995
|
setRowHeight: (height, rule) => withCanonicalTableAttributeCommand(setRowHeight(height, rule)),
|
|
2029
1996
|
toggleHeaderRow: () => withCanonicalTableAttributeCommand(toggleHeaderRow()),
|
|
2030
1997
|
distributeColumns: () => withCanonicalTableAttributeCommand(distributeColumns()),
|
|
2031
|
-
autoFitContents: () => autoFitContents(),
|
|
1998
|
+
autoFitContents: () => withCanonicalTableAttributeCommand(autoFitContents()),
|
|
2032
1999
|
setTableProperties: (props) => withCanonicalTableAttributeCommand(setTableProperties(props)),
|
|
2033
2000
|
applyTableStyle: (styleData) => withCanonicalTableAttributeCommand(applyTableStyle(styleData)),
|
|
2034
2001
|
setCellFillColor: (color) => withCanonicalTableAttributeCommand(setCellFillColor(color)),
|
|
@@ -14,8 +14,8 @@ import { TextColorAttrs } from "../schema/marks.js";
|
|
|
14
14
|
import { SectionBreakType } from "../sectionCarrier.js";
|
|
15
15
|
import { GenerateTableOfContentsOptions, ResolvedStyleAttrs } from "./core/ParagraphExtension.js";
|
|
16
16
|
import { BorderPreset, TableBorderPreset } from "./nodes/TableExtension.js";
|
|
17
|
-
import { MarkSpec, NodeSpec, Schema } from "prosemirror-model";
|
|
18
17
|
import { Command, Plugin } from "prosemirror-state";
|
|
18
|
+
import { MarkSpec, NodeSpec, Schema } from "prosemirror-model";
|
|
19
19
|
/**
|
|
20
20
|
* A border a host asks folio to apply.
|
|
21
21
|
*
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { DisplayMode } from "../managers/EditorModeManager.js";
|
|
2
2
|
import { document_d_exports } from "../types/document.js";
|
|
3
3
|
import { FindMatch, FindOptions, FindSearchContext } from "../utils/findReplace.js";
|
|
4
|
-
import { Node } from "prosemirror-model";
|
|
5
4
|
import { EditorState } from "prosemirror-state";
|
|
5
|
+
import { Node } from "prosemirror-model";
|
|
6
6
|
/**
|
|
7
7
|
* Positional fields of a document search match that the range resolver needs.
|
|
8
8
|
*
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
* the plain text an untracked removal leaves.
|
|
12
12
|
*/
|
|
13
13
|
import { TaggedErrorClass } from "better-result";
|
|
14
|
-
import { Node } from "prosemirror-model";
|
|
15
14
|
import { EditorState, Transaction } from "prosemirror-state";
|
|
15
|
+
import { Node } from "prosemirror-model";
|
|
16
16
|
declare const HyperlinkRemovalRefusalBase: TaggedErrorClass<"HyperlinkRemovalRefusal">;
|
|
17
17
|
export declare class HyperlinkRemovalRefusal extends HyperlinkRemovalRefusalBase<{
|
|
18
18
|
message: string;
|