@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
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { BUILT_IN_STYLE_NAME } from "../docx/builtInStyles.js";
|
|
2
2
|
import { getDocumentBuiltInStyles, getDocumentStyleResolver } from "./plugins/documentStyleState.js";
|
|
3
|
-
import { isSuggestionModeActive, makeRevisionInfo, suggestRangeDeletion } from "./plugins/suggestionMode.js";
|
|
4
3
|
import { readAuthoredRunFormatting, reconcileRunFormattingMarks } from "./runFormattingReconciliation.js";
|
|
5
4
|
import { paragraphRunStyleContextAt } from "./runStyleFormatting.js";
|
|
5
|
+
import { isSuggestionModeActive, makeRevisionInfo, suggestRangeDeletion } from "./suggestionCommands.js";
|
|
6
6
|
import { TaggedError } from "better-result";
|
|
7
7
|
// src/prosemirror/hyperlinkRemoval.ts
|
|
8
8
|
/**
|
|
@@ -153,7 +153,12 @@ const removeHyperlinkInRange = (state, tr, from, to) => {
|
|
|
153
153
|
const change = previousFormatting && !hasPendingPropertyChange(piece.node.marks) ? propertyChange(previousFormatting) : null;
|
|
154
154
|
setInlineMarks(tr, piece.from, piece.to, piece.node.marks, change ? change.addToSet(marks) : marks);
|
|
155
155
|
}
|
|
156
|
-
suggestRangeDeletion(
|
|
156
|
+
suggestRangeDeletion({
|
|
157
|
+
state,
|
|
158
|
+
tr,
|
|
159
|
+
from: range.from,
|
|
160
|
+
to: range.to
|
|
161
|
+
});
|
|
157
162
|
}
|
|
158
163
|
return tr;
|
|
159
164
|
};
|
|
@@ -15,12 +15,11 @@ import "./commands/index.js";
|
|
|
15
15
|
import { insertPageBreak } from "./commands/pageBreak.js";
|
|
16
16
|
import { addTabStop, alignCenter, alignJustify, alignLeft, alignRight, applyStyle, clearStyle, continueNumbering, decreaseIndent, decreaseListLevel, generateTableOfContents, increaseIndent, increaseListLevel, removeList, removeTabStop, restartNumbering, setAlignment, setIndentFirstLine, setIndentLeft, setIndentRight, setLineSpacing, setLtr, setNumberingValue, setRtl, toggleBidi, toggleBulletList, toggleNumberedList } from "./commands/paragraph.js";
|
|
17
17
|
import { addColumnLeft, addColumnRight, addRowAbove, addRowBelow, applyTableStyle, autoFitContents, deleteColumn, deleteRow, deleteTable, distributeColumns, insertTable, mergeCells, removeTableBorders, selectColumn, selectRow, selectTable, setAllTableBorders, setCellBorder, setCellFillColor, setCellMargins, setCellTextDirection, setCellVerticalAlign, setInsideTableBorders, setOutsideTableBorders, setRowHeight, setTableBorderColor, setTableBorderPreset, setTableBorderWidth, setTableBorders, setTableProperties, splitCell, toggleHeaderRow, toggleNoWrap } from "./commands/table.js";
|
|
18
|
-
import { FromProseDocOptions, ProjectionReuse, fromProseDoc
|
|
18
|
+
import { FromProseDocOptions, ProjectionReuse, fromProseDoc } from "./conversion/fromProseDoc.js";
|
|
19
19
|
import "./conversion/index.js";
|
|
20
20
|
import { ToProseDocOptions, createEmptyDoc, toProseDoc } from "./conversion/toProseDoc.js";
|
|
21
21
|
import { getParagraphAlignment, getParagraphBidi, getStyleId } from "./extensions/core/ParagraphExtension.js";
|
|
22
22
|
import { getListInfo, isInList } from "./extensions/features/ListExtension.js";
|
|
23
|
-
import { ensureParaIdsInState } from "./extensions/features/ParaIdAllocatorExtension.js";
|
|
24
23
|
import { getHyperlinkAttrs, getSelectedText, isHyperlinkActive } from "./extensions/marks/HyperlinkExtension.js";
|
|
25
24
|
import { clearFormatting, getMarkAttr, isMarkActive } from "./extensions/marks/markUtils.js";
|
|
26
25
|
import { BorderPreset, TableBorderPreset, TableContextInfo, getTableContext, isInTable as isInTableCell } from "./extensions/nodes/TableExtension.js";
|
|
@@ -28,6 +27,7 @@ import { TableBorderCommandSpec, TableCellBorderCommandSpec } from "./extensions
|
|
|
28
27
|
import { insertPageBreakInView, insertTableInView, insertTableOfContentsInView } from "./insertOperations.js";
|
|
29
28
|
import { ListNumberingMenuState, NO_LIST_NUMBERING_MENU, listNumberingMenuState } from "./listNumbering.js";
|
|
30
29
|
import { ActiveListState, ListState, ListType, NO_LIST_STATE, isInListState, listStateLevel, resolveListState, sameListState } from "./listState.js";
|
|
30
|
+
import { ensureParaIdsInState } from "./paraIds.js";
|
|
31
31
|
import { documentStylesKey, getDocumentBuiltInStyles, getDocumentStyleResolver } from "./plugins/documentStyleState.js";
|
|
32
32
|
import { createDocumentStylesPlugin } from "./plugins/documentStyles.js";
|
|
33
33
|
import "./plugins/index.js";
|
|
@@ -40,4 +40,4 @@ import "./styles/index.js";
|
|
|
40
40
|
import { ResolvedParagraphStyle, StyleResolver, createStyleResolver } from "./styles/styleResolver.js";
|
|
41
41
|
import { ProseMirrorDocumentValidationIssue, ValidateProseMirrorDocumentResult, assertValidProseMirrorDocument, formatProseMirrorDocumentIssues, validateProseMirrorDocument } from "./validation.js";
|
|
42
42
|
import { TextSelection } from "prosemirror-state";
|
|
43
|
-
export { type ActiveListState, type BorderPreset, type CapturedTextFormatting, type FontFamilyAttrs, type FontSizeAttrs, type FromProseDocOptions, type HyperlinkAttrs, type ImageAttrs, type ListNumberingMenuState, type ListState, type ListType, NO_LIST_NUMBERING_MENU, NO_LIST_STATE, PAINTABLE_MARK_NAMES, type ParagraphAttrs, type ProjectionReuse, type ProseMirrorDocumentValidationIssue, type ResolvedParagraphStyle, type SelectionChangeCallback, type SelectionContext, type SelectionState, StyleResolver, type TableBorderCommandSpec, type TableBorderPreset, type TableCellBorderCommandSpec, type TableContextInfo, type TextColorAttrs, TextSelection, type ToProseDocOptions, type UnderlineAttrs, type ValidateProseMirrorDocumentResult, addColumnLeft, addColumnRight, addRowAbove, addRowBelow, addTabStop, alignCenter, alignJustify, alignLeft, alignRight, applyFormatMarks, applyStyle, applyTableStyle, assertValidProseMirrorDocument, autoFitContents, captureFormatMarks, clearFontFamily, clearFontSize, clearFormatting, clearHighlight, clearStyle, clearTextColor, continueNumbering, createDocumentStylesPlugin, createEmptyDoc, createSelectionTrackerPlugin, createStyleResolver, decreaseIndent, decreaseListLevel, deleteColumn, deleteRow, deleteTable, distributeColumns, documentStylesKey, ensureParaIdsInState, extractSelectionContext, extractSelectionState, formatProseMirrorDocumentIssues, fromProseDoc, generateTableOfContents, getDocumentBuiltInStyles, getDocumentStyleResolver, getHyperlinkAttrs, getListInfo, getMarkAttr, getParagraphAlignment, getParagraphBidi, getSelectedText, getSelectionContext, getStyleId, getTableContext, increaseIndent, increaseListLevel, insertHyperlink, insertImageFromFile, insertPageBreak, insertPageBreakInView, insertTable, insertTableInView, insertTableOfContentsInView, isHyperlinkActive, isInList, isInListState, isInTableCell as isInTable, isMarkActive, listNumberingMenuState, listStateLevel, mergeCells, removeHyperlink, removeList, removeTabStop, removeTableBorders, resolveListState, restartNumbering, sameListState, schema, selectColumn, selectRow, selectTable, selectionTrackerKey, setAlignment, setAllTableBorders, setCellBorder, setCellFillColor, setCellMargins, setCellTextDirection, setCellVerticalAlign, setFontFamily, setFontSize, setHighlight, setHyperlink, setIndentFirstLine, setIndentLeft, setIndentRight, setInsideTableBorders, setLineSpacing, setLtr, setNumberingValue, setOutsideTableBorders, setRowHeight, setRtl, setTableBorderColor, setTableBorderPreset, setTableBorderWidth, setTableBorders, setTableProperties, setTextColor, singletonManager, splitCell, toProseDoc, toggleBidi, toggleBold, toggleBulletList, toggleHeaderRow, toggleItalic, toggleNoWrap, toggleNumberedList, toggleStrike, toggleSubscript, toggleSuperscript, toggleUnderline,
|
|
43
|
+
export { type ActiveListState, type BorderPreset, type CapturedTextFormatting, type FontFamilyAttrs, type FontSizeAttrs, type FromProseDocOptions, type HyperlinkAttrs, type ImageAttrs, type ListNumberingMenuState, type ListState, type ListType, NO_LIST_NUMBERING_MENU, NO_LIST_STATE, PAINTABLE_MARK_NAMES, type ParagraphAttrs, type ProjectionReuse, type ProseMirrorDocumentValidationIssue, type ResolvedParagraphStyle, type SelectionChangeCallback, type SelectionContext, type SelectionState, StyleResolver, type TableBorderCommandSpec, type TableBorderPreset, type TableCellBorderCommandSpec, type TableContextInfo, type TextColorAttrs, TextSelection, type ToProseDocOptions, type UnderlineAttrs, type ValidateProseMirrorDocumentResult, addColumnLeft, addColumnRight, addRowAbove, addRowBelow, addTabStop, alignCenter, alignJustify, alignLeft, alignRight, applyFormatMarks, applyStyle, applyTableStyle, assertValidProseMirrorDocument, autoFitContents, captureFormatMarks, clearFontFamily, clearFontSize, clearFormatting, clearHighlight, clearStyle, clearTextColor, continueNumbering, createDocumentStylesPlugin, createEmptyDoc, createSelectionTrackerPlugin, createStyleResolver, decreaseIndent, decreaseListLevel, deleteColumn, deleteRow, deleteTable, distributeColumns, documentStylesKey, ensureParaIdsInState, extractSelectionContext, extractSelectionState, formatProseMirrorDocumentIssues, fromProseDoc, generateTableOfContents, getDocumentBuiltInStyles, getDocumentStyleResolver, getHyperlinkAttrs, getListInfo, getMarkAttr, getParagraphAlignment, getParagraphBidi, getSelectedText, getSelectionContext, getStyleId, getTableContext, increaseIndent, increaseListLevel, insertHyperlink, insertImageFromFile, insertPageBreak, insertPageBreakInView, insertTable, insertTableInView, insertTableOfContentsInView, isHyperlinkActive, isInList, isInListState, isInTableCell as isInTable, isMarkActive, listNumberingMenuState, listStateLevel, mergeCells, removeHyperlink, removeList, removeTabStop, removeTableBorders, resolveListState, restartNumbering, sameListState, schema, selectColumn, selectRow, selectTable, selectionTrackerKey, setAlignment, setAllTableBorders, setCellBorder, setCellFillColor, setCellMargins, setCellTextDirection, setCellVerticalAlign, setFontFamily, setFontSize, setHighlight, setHyperlink, setIndentFirstLine, setIndentLeft, setIndentRight, setInsideTableBorders, setLineSpacing, setLtr, setNumberingValue, setOutsideTableBorders, setRowHeight, setRtl, setTableBorderColor, setTableBorderPreset, setTableBorderWidth, setTableBorders, setTableProperties, setTextColor, singletonManager, splitCell, toProseDoc, toggleBidi, toggleBold, toggleBulletList, toggleHeaderRow, toggleItalic, toggleNoWrap, toggleNumberedList, toggleStrike, toggleSubscript, toggleSuperscript, toggleUnderline, validateProseMirrorDocument };
|
|
@@ -4,17 +4,17 @@ import { insertImageFromFile } from "./commands/image.js";
|
|
|
4
4
|
import { insertPageBreak } from "./commands/pageBreak.js";
|
|
5
5
|
import { addTabStop, alignCenter, alignJustify, alignLeft, alignRight, applyStyle, clearStyle, continueNumbering, decreaseIndent, decreaseListLevel, generateTableOfContents, increaseIndent, increaseListLevel, removeList, removeTabStop, restartNumbering, setAlignment, setIndentFirstLine, setIndentLeft, setIndentRight, setLineSpacing, setLtr, setNumberingValue, setRtl, toggleBidi, toggleBulletList, toggleNumberedList } from "./commands/paragraph.js";
|
|
6
6
|
import { addColumnLeft, addColumnRight, addRowAbove, addRowBelow, applyTableStyle, autoFitContents, deleteColumn, deleteRow, deleteTable, distributeColumns, insertTable, mergeCells, removeTableBorders, selectColumn, selectRow, selectTable, setAllTableBorders, setCellBorder, setCellFillColor, setCellMargins, setCellTextDirection, setCellVerticalAlign, setInsideTableBorders, setOutsideTableBorders, setRowHeight, setTableBorderColor, setTableBorderPreset, setTableBorderWidth, setTableBorders, setTableProperties, splitCell, toggleHeaderRow, toggleNoWrap } from "./commands/table.js";
|
|
7
|
-
import { fromProseDoc
|
|
7
|
+
import { fromProseDoc } from "./conversion/fromProseDoc.js";
|
|
8
8
|
import { createEmptyDoc, toProseDoc } from "./conversion/toProseDoc.js";
|
|
9
9
|
import { getParagraphAlignment, getParagraphBidi, getStyleId } from "./extensions/core/ParagraphExtension.js";
|
|
10
10
|
import { getListInfo, isInList } from "./extensions/features/ListExtension.js";
|
|
11
|
-
import { ensureParaIdsInState } from "./extensions/features/ParaIdAllocatorExtension.js";
|
|
12
11
|
import { getHyperlinkAttrs, getSelectedText, isHyperlinkActive } from "./extensions/marks/HyperlinkExtension.js";
|
|
13
12
|
import { clearFormatting, getMarkAttr, isMarkActive } from "./extensions/marks/markUtils.js";
|
|
14
13
|
import { getTableContext, isInTable as isInTableCell } from "./extensions/nodes/TableExtension.js";
|
|
15
14
|
import { insertPageBreakInView, insertTableInView, insertTableOfContentsInView } from "./insertOperations.js";
|
|
16
15
|
import { NO_LIST_NUMBERING_MENU, listNumberingMenuState } from "./listNumbering.js";
|
|
17
16
|
import { NO_LIST_STATE, isInListState, listStateLevel, resolveListState, sameListState } from "./listState.js";
|
|
17
|
+
import { ensureParaIdsInState } from "./paraIds.js";
|
|
18
18
|
import { documentStylesKey, getDocumentBuiltInStyles, getDocumentStyleResolver } from "./plugins/documentStyleState.js";
|
|
19
19
|
import { createDocumentStylesPlugin } from "./plugins/documentStyles.js";
|
|
20
20
|
import { createSelectionTrackerPlugin, extractSelectionContext, getSelectionContext, selectionTrackerKey } from "./plugins/selectionTracker.js";
|
|
@@ -23,4 +23,4 @@ import { extractSelectionState } from "./selectionState.js";
|
|
|
23
23
|
import { StyleResolver, createStyleResolver } from "./styles/styleResolver.js";
|
|
24
24
|
import { assertValidProseMirrorDocument, formatProseMirrorDocumentIssues, validateProseMirrorDocument } from "./validation.js";
|
|
25
25
|
import { TextSelection } from "prosemirror-state";
|
|
26
|
-
export { NO_LIST_NUMBERING_MENU, NO_LIST_STATE, PAINTABLE_MARK_NAMES, StyleResolver, TextSelection, addColumnLeft, addColumnRight, addRowAbove, addRowBelow, addTabStop, alignCenter, alignJustify, alignLeft, alignRight, applyFormatMarks, applyStyle, applyTableStyle, assertValidProseMirrorDocument, autoFitContents, captureFormatMarks, clearFontFamily, clearFontSize, clearFormatting, clearHighlight, clearStyle, clearTextColor, continueNumbering, createDocumentStylesPlugin, createEmptyDoc, createSelectionTrackerPlugin, createStyleResolver, decreaseIndent, decreaseListLevel, deleteColumn, deleteRow, deleteTable, distributeColumns, documentStylesKey, ensureParaIdsInState, extractSelectionContext, extractSelectionState, formatProseMirrorDocumentIssues, fromProseDoc, generateTableOfContents, getDocumentBuiltInStyles, getDocumentStyleResolver, getHyperlinkAttrs, getListInfo, getMarkAttr, getParagraphAlignment, getParagraphBidi, getSelectedText, getSelectionContext, getStyleId, getTableContext, increaseIndent, increaseListLevel, insertHyperlink, insertImageFromFile, insertPageBreak, insertPageBreakInView, insertTable, insertTableInView, insertTableOfContentsInView, isHyperlinkActive, isInList, isInListState, isInTableCell as isInTable, isMarkActive, listNumberingMenuState, listStateLevel, mergeCells, removeHyperlink, removeList, removeTabStop, removeTableBorders, resolveListState, restartNumbering, sameListState, schema, selectColumn, selectRow, selectTable, selectionTrackerKey, setAlignment, setAllTableBorders, setCellBorder, setCellFillColor, setCellMargins, setCellTextDirection, setCellVerticalAlign, setFontFamily, setFontSize, setHighlight, setHyperlink, setIndentFirstLine, setIndentLeft, setIndentRight, setInsideTableBorders, setLineSpacing, setLtr, setNumberingValue, setOutsideTableBorders, setRowHeight, setRtl, setTableBorderColor, setTableBorderPreset, setTableBorderWidth, setTableBorders, setTableProperties, setTextColor, singletonManager, splitCell, toProseDoc, toggleBidi, toggleBold, toggleBulletList, toggleHeaderRow, toggleItalic, toggleNoWrap, toggleNumberedList, toggleStrike, toggleSubscript, toggleSuperscript, toggleUnderline,
|
|
26
|
+
export { NO_LIST_NUMBERING_MENU, NO_LIST_STATE, PAINTABLE_MARK_NAMES, StyleResolver, TextSelection, addColumnLeft, addColumnRight, addRowAbove, addRowBelow, addTabStop, alignCenter, alignJustify, alignLeft, alignRight, applyFormatMarks, applyStyle, applyTableStyle, assertValidProseMirrorDocument, autoFitContents, captureFormatMarks, clearFontFamily, clearFontSize, clearFormatting, clearHighlight, clearStyle, clearTextColor, continueNumbering, createDocumentStylesPlugin, createEmptyDoc, createSelectionTrackerPlugin, createStyleResolver, decreaseIndent, decreaseListLevel, deleteColumn, deleteRow, deleteTable, distributeColumns, documentStylesKey, ensureParaIdsInState, extractSelectionContext, extractSelectionState, formatProseMirrorDocumentIssues, fromProseDoc, generateTableOfContents, getDocumentBuiltInStyles, getDocumentStyleResolver, getHyperlinkAttrs, getListInfo, getMarkAttr, getParagraphAlignment, getParagraphBidi, getSelectedText, getSelectionContext, getStyleId, getTableContext, increaseIndent, increaseListLevel, insertHyperlink, insertImageFromFile, insertPageBreak, insertPageBreakInView, insertTable, insertTableInView, insertTableOfContentsInView, isHyperlinkActive, isInList, isInListState, isInTableCell as isInTable, isMarkActive, listNumberingMenuState, listStateLevel, mergeCells, removeHyperlink, removeList, removeTabStop, removeTableBorders, resolveListState, restartNumbering, sameListState, schema, selectColumn, selectRow, selectTable, selectionTrackerKey, setAlignment, setAllTableBorders, setCellBorder, setCellFillColor, setCellMargins, setCellTextDirection, setCellVerticalAlign, setFontFamily, setFontSize, setHighlight, setHyperlink, setIndentFirstLine, setIndentLeft, setIndentRight, setInsideTableBorders, setLineSpacing, setLtr, setNumberingValue, setOutsideTableBorders, setRowHeight, setRtl, setTableBorderColor, setTableBorderPreset, setTableBorderWidth, setTableBorders, setTableProperties, setTextColor, singletonManager, splitCell, toProseDoc, toggleBidi, toggleBold, toggleBulletList, toggleHeaderRow, toggleItalic, toggleNoWrap, toggleNumberedList, toggleStrike, toggleSubscript, toggleSuperscript, toggleUnderline, validateProseMirrorDocument };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Node } from "prosemirror-model";
|
|
2
1
|
import { Transaction } from "prosemirror-state";
|
|
2
|
+
import { Node } from "prosemirror-model";
|
|
3
3
|
/** The gap a block put on `side` of the block at `boundary` lands in. */
|
|
4
4
|
export declare const insertionGap: (doc: Node, boundary: number, side: "before" | "after") => number;
|
|
5
5
|
/**
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
*/
|
|
13
13
|
import { document_d_exports } from "../types/document.js";
|
|
14
14
|
import { TrackedRevisionAncestor } from "./schema/marks.js";
|
|
15
|
-
import { Node } from "prosemirror-model";
|
|
16
15
|
import { Transaction } from "prosemirror-state";
|
|
16
|
+
import { Node } from "prosemirror-model";
|
|
17
17
|
/** A range boundary, as the engine's model writes it. */
|
|
18
18
|
type BoundaryItem = Extract<document_d_exports.ParagraphContent, {
|
|
19
19
|
type: "bookmarkStart" | "bookmarkEnd" | "commentRangeStart" | "commentRangeEnd" | "moveFromRangeStart" | "moveFromRangeEnd" | "moveToRangeStart" | "moveToRangeEnd";
|
|
@@ -12,8 +12,8 @@ import { RANGE_ANCHOR_NODE_NAME } from "./extensions/nodes/RangeAnchorExtension.
|
|
|
12
12
|
import { expectMoveRangeBoundaryAttrs } from "./moveRangeBoundaryAttrs.js";
|
|
13
13
|
import { expectRangeAnchorAttrs } from "./rangeAnchorAttrs.js";
|
|
14
14
|
import { retainedTrackedRevisionMark, trackedRevisionPathOf } from "./trackedRevisionPath.js";
|
|
15
|
-
import { Mark } from "prosemirror-model";
|
|
16
15
|
import { planWellFormedRanges, recordsCopyOrigin } from "@stll/docx-core/ops";
|
|
16
|
+
import { Mark } from "prosemirror-model";
|
|
17
17
|
// src/prosemirror/keptRangeBoundaries.ts
|
|
18
18
|
/**
|
|
19
19
|
* Range boundaries rejecting a change keeps from the content it removes.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ListKind, ListLevelFormat } from "../docx/listNumberingInstances.js";
|
|
2
2
|
import { NumberingMap } from "../docx/numberingParser.js";
|
|
3
3
|
import { ParagraphAttrs } from "./schema/nodes.js";
|
|
4
|
-
import { Node, ResolvedPos } from "prosemirror-model";
|
|
5
4
|
import { Command, EditorState, Transaction } from "prosemirror-state";
|
|
5
|
+
import { Node, ResolvedPos } from "prosemirror-model";
|
|
6
6
|
/** What a list command or typed marker asks for. */
|
|
7
7
|
export type ListRequest = {
|
|
8
8
|
kind: ListKind;
|
|
@@ -11,8 +11,8 @@ import { effectiveParagraphNumbering, effectiveParagraphNumberingReference, para
|
|
|
11
11
|
import { directParagraphIndentation } from "./paragraphIndentation.js";
|
|
12
12
|
import { getDocumentNumbering } from "./plugins/documentNumbering.js";
|
|
13
13
|
import { getDocumentStyleResolver } from "./plugins/documentStyleState.js";
|
|
14
|
-
import { SUGGESTION_META, makeRevisionInfo } from "./plugins/suggestionMode.js";
|
|
15
14
|
import { listAttrsFromNumbering, listIndentationProvenancePatch } from "./styles/resolvedStyleAttrs.js";
|
|
15
|
+
import { SUGGESTION_META, makeRevisionInfo } from "./suggestionCommands.js";
|
|
16
16
|
// src/prosemirror/listNumbering.ts
|
|
17
17
|
const PARAGRAPH_NODE = "paragraph";
|
|
18
18
|
/**
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* document holds, as spans on its position scale, and what a transform did to
|
|
5
5
|
* them.
|
|
6
6
|
*/
|
|
7
|
-
import { Node } from "prosemirror-model";
|
|
8
7
|
import { LockedControlSpan, LockedControlTouch, LockedControlViolation } from "@stll/docx-core/model";
|
|
8
|
+
import { Node } from "prosemirror-model";
|
|
9
9
|
import { Transform } from "prosemirror-transform";
|
|
10
10
|
export declare const lockedControlSpans: (doc: Node) => readonly LockedControlSpan[];
|
|
11
11
|
/** What the locks of `doc` say about `touches`: `null` when they permit them all. */
|
|
@@ -20,8 +20,8 @@ import { RemovedSectionReference } from "../internal/sectionEndpointResolution.j
|
|
|
20
20
|
import { DisplayMode } from "../managers/EditorModeManager.js";
|
|
21
21
|
import { document_d_exports } from "../types/document.js";
|
|
22
22
|
import { DeepReadonly } from "../types/documentModel.js";
|
|
23
|
-
import { Node } from "prosemirror-model";
|
|
24
23
|
import { EditorState } from "prosemirror-state";
|
|
24
|
+
import { Node } from "prosemirror-model";
|
|
25
25
|
import { Mapping, Step, StepMap } from "prosemirror-transform";
|
|
26
26
|
/** Resolve every revision in the state's story with the state's own styles and numbering. */
|
|
27
27
|
export declare const resolveStateStory: (state: EditorState, mode: RevisionResolutionMode) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TaggedErrorClass } from "better-result";
|
|
2
|
-
import { Node } from "prosemirror-model";
|
|
3
2
|
import { Plugin, Transaction } from "prosemirror-state";
|
|
3
|
+
import { Node } from "prosemirror-model";
|
|
4
4
|
declare const NoteReferenceEditRefusalBase: TaggedErrorClass<"NoteReferenceEditRefusal">;
|
|
5
5
|
export declare class NoteReferenceEditRefusal extends NoteReferenceEditRefusalBase<{
|
|
6
6
|
message: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { readFootnoteRefMarkAttrs } from "./attrs/index.js";
|
|
2
2
|
import { Result, TaggedError, panic } from "better-result";
|
|
3
|
-
import { Fragment, Mark, Slice } from "prosemirror-model";
|
|
4
3
|
import { Plugin } from "prosemirror-state";
|
|
4
|
+
import { Fragment, Mark, Slice } from "prosemirror-model";
|
|
5
5
|
import { isHistoryTransaction } from "prosemirror-history";
|
|
6
6
|
// src/prosemirror/noteReferenceOccurrences.ts
|
|
7
7
|
const NoteReferenceEditRefusalBase = TaggedError("NoteReferenceEditRefusal");
|
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A note goes with its reference. Deleting a note's reference while tracking
|
|
3
|
-
* changes deletes the note's text too, so rejecting that deletion must give
|
|
4
|
-
* the note its text back, whichever surface resolves it: the body editor
|
|
5
|
-
* resolves the reference, and this resolves the note's story to match.
|
|
6
|
-
*/
|
|
1
|
+
/** Read note references and retain the corresponding model stories. */
|
|
7
2
|
import { document_d_exports } from "../types/document.js";
|
|
8
|
-
import {
|
|
9
|
-
import { Transform } from "prosemirror-transform";
|
|
3
|
+
import { Node } from "prosemirror-model";
|
|
10
4
|
type NoteKind = "footnote" | "endnote";
|
|
11
5
|
/** `footnote:<id>` or `endnote:<id>`. */
|
|
12
6
|
export type NoteKey = `${NoteKind}:${number}`;
|
|
@@ -15,54 +9,6 @@ export type NoteKey = `${NoteKind}:${number}`;
|
|
|
15
9
|
* deletion: a reference is deleted when every character of it is.
|
|
16
10
|
*/
|
|
17
11
|
export declare const noteReferenceStates: (doc: Node) => Map<NoteKey, "live" | "deleted">;
|
|
18
|
-
/** The notes whose reference a change took from pending deletion back to live. */
|
|
19
|
-
export declare const noteReferencesRestored: (before: Node, after: Node) => NoteKey[];
|
|
20
|
-
/**
|
|
21
|
-
* The revisions that deleted a note along with its reference: its text and
|
|
22
|
-
* its paragraph marks, deleted by the reference deletion's author at its
|
|
23
|
-
* date. A deletion in the note made some other time is a change of its own,
|
|
24
|
-
* which resolving the reference leaves alone.
|
|
25
|
-
*/
|
|
26
|
-
export declare const noteDeletionRevisions: (doc: Node, reference: Mark) => number[];
|
|
27
|
-
/**
|
|
28
|
-
* The document with the named notes' deletions that went with their
|
|
29
|
-
* reference rejected: the notes whose reference's deletion was rejected get
|
|
30
|
-
* their text back. `before` is the body that still had those deletions.
|
|
31
|
-
*/
|
|
32
|
-
export declare const restoreNotes: (document: document_d_exports.Document, keys: Iterable<NoteKey>, before: Node) => document_d_exports.Document;
|
|
33
|
-
/** The deletion each pending-deleted note reference carries. */
|
|
34
|
-
export declare const referenceDeletions: (doc: Node) => Map<NoteKey, Mark>;
|
|
35
|
-
/**
|
|
36
|
-
* Delete a note's text and its paragraph marks along with its reference: by
|
|
37
|
-
* the reference deletion's author at its date, so resolving the reference
|
|
38
|
-
* resolves them too (see {@link noteDeletionRevisions}).
|
|
39
|
-
*/
|
|
40
|
-
export declare const deleteNoteWithReference: <T extends Transform>(transform: T, reference: Mark) => T;
|
|
41
|
-
/**
|
|
42
|
-
* Keeps an editor's notes following their references across body edits. The
|
|
43
|
-
* editor reports the body as it was before the edits it has not yet written
|
|
44
|
-
* back, and reconciles the document it writes back:
|
|
45
|
-
*
|
|
46
|
-
* - a reference whose deletion is rejected gives its note back its text;
|
|
47
|
-
* - a reference deleted again, as undoing that reject does, takes the note's
|
|
48
|
-
* text with it: the note returns to what it was, or, when the note changed
|
|
49
|
-
* since, its text is deleted along with the reference.
|
|
50
|
-
*/
|
|
51
|
-
export type NoteReferenceFollower = {
|
|
52
|
-
/** The body before the edits the next {@link reconcile} writes back. */
|
|
53
|
-
noteBase: (before: Node) => void;
|
|
54
|
-
/** The document to write back, its notes following the body's references. */
|
|
55
|
-
reconcile: (document: document_d_exports.Document, body: Node) => document_d_exports.Document;
|
|
56
|
-
/**
|
|
57
|
-
* `document` with the note changes an earlier {@link reconcile} wrote back
|
|
58
|
-
* and the editor's document has not taken in yet: a save reads the editor
|
|
59
|
-
* right after a write-back, before the host hands the result back.
|
|
60
|
-
*/
|
|
61
|
-
withPending: (document: document_d_exports.Document) => document_d_exports.Document;
|
|
62
|
-
/** Forget the pending base and what earlier restores replaced (a new document). */
|
|
63
|
-
reset: () => void;
|
|
64
|
-
};
|
|
65
|
-
export declare const createNoteReferenceFollower: () => NoteReferenceFollower;
|
|
66
12
|
/** The notes model content refers to, live or pending deletion. */
|
|
67
13
|
export declare const noteKeysReferencedIn: (content: unknown) => Set<NoteKey>;
|
|
68
14
|
/**
|
|
@@ -1,19 +1,8 @@
|
|
|
1
1
|
import { withoutLostCommentThreads } from "../ai-edits/comment-lifecycle.js";
|
|
2
2
|
import { visitCommentMarkers } from "../docx/commentAnchorIndex.js";
|
|
3
3
|
import { isSeparatorEndnote, isSeparatorFootnote } from "../docx/footnoteParser.js";
|
|
4
|
-
import {
|
|
5
|
-
import { addTrackedDeletionMark } from "./addTrackedDeletionMark.js";
|
|
6
|
-
import { expectFootnoteRefMarkAttrs, expectParagraphAttrs } from "./attrs/index.js";
|
|
7
|
-
import { rejectAIEditRevision } from "./commands/comments.js";
|
|
8
|
-
import { proseDocToBlocks } from "./conversion/fromProseDoc.js";
|
|
9
|
-
import { footnoteToProseDoc } from "./conversion/toProseDoc.js";
|
|
10
|
-
import { createDocumentNumberingPlugin } from "./plugins/documentNumbering.js";
|
|
11
|
-
import { createDocumentStylesPlugin } from "./plugins/documentStyles.js";
|
|
12
|
-
import { mintRevisionId } from "./plugins/revisionIds.js";
|
|
13
|
-
import { schema, singletonManager } from "./schema/index.js";
|
|
4
|
+
import { expectFootnoteRefMarkAttrs } from "./attrs/index.js";
|
|
14
5
|
import { setDocumentBodyComments } from "@stll/docx-core/model";
|
|
15
|
-
import { Transform } from "prosemirror-transform";
|
|
16
|
-
import { EditorState } from "prosemirror-state";
|
|
17
6
|
// src/prosemirror/noteReferenceReview.ts
|
|
18
7
|
const noteKey = (kind, id) => `${kind}:${id}`;
|
|
19
8
|
/**
|
|
@@ -34,236 +23,6 @@ const noteReferenceStates = (doc) => {
|
|
|
34
23
|
});
|
|
35
24
|
return states;
|
|
36
25
|
};
|
|
37
|
-
/** The notes whose reference a change took from pending deletion back to live. */
|
|
38
|
-
const noteReferencesRestored = (before, after) => {
|
|
39
|
-
const was = noteReferenceStates(before);
|
|
40
|
-
return [...noteReferenceStates(after)].flatMap(([key, state]) => state === "live" && was.get(key) === "deleted" ? [key] : []);
|
|
41
|
-
};
|
|
42
|
-
/**
|
|
43
|
-
* The revisions that deleted a note along with its reference: its text and
|
|
44
|
-
* its paragraph marks, deleted by the reference deletion's author at its
|
|
45
|
-
* date. A deletion in the note made some other time is a change of its own,
|
|
46
|
-
* which resolving the reference leaves alone.
|
|
47
|
-
*/
|
|
48
|
-
const noteDeletionRevisions = (doc, reference) => {
|
|
49
|
-
const author = String(reference.attrs["author"] ?? "");
|
|
50
|
-
const date = String(reference.attrs["date"] ?? "");
|
|
51
|
-
const ids = /* @__PURE__ */ new Set();
|
|
52
|
-
doc.descendants((node) => {
|
|
53
|
-
if (node.type.name === "paragraph") {
|
|
54
|
-
const mark = expectParagraphAttrs(node).pPrMark;
|
|
55
|
-
if (mark?.kind === "del" && mark.info.author === author && mark.info.date === date) ids.add(mark.info.id);
|
|
56
|
-
}
|
|
57
|
-
for (const mark of node.marks) if (mark.type.name === "deletion" && String(mark.attrs["author"] ?? "") === author && String(mark.attrs["date"] ?? "") === date) {
|
|
58
|
-
const id = mark.attrs["revisionId"];
|
|
59
|
-
if (typeof id === "number") ids.add(id);
|
|
60
|
-
}
|
|
61
|
-
return true;
|
|
62
|
-
});
|
|
63
|
-
return [...ids];
|
|
64
|
-
};
|
|
65
|
-
const restoredNote = (note, document, reference) => {
|
|
66
|
-
const { styles, theme, numbering } = document.package;
|
|
67
|
-
const doc = footnoteToProseDoc(note.content, {
|
|
68
|
-
...styles !== void 0 && { styles },
|
|
69
|
-
...theme !== void 0 && { theme },
|
|
70
|
-
...numbering !== void 0 && { numbering }
|
|
71
|
-
});
|
|
72
|
-
const revisions = noteDeletionRevisions(doc, reference);
|
|
73
|
-
if (revisions.length === 0) return note;
|
|
74
|
-
let state = EditorState.create({
|
|
75
|
-
schema,
|
|
76
|
-
doc,
|
|
77
|
-
plugins: [
|
|
78
|
-
createDocumentNumberingPlugin(numbering),
|
|
79
|
-
...pluginsForHeadlessRevisionResolution(singletonManager.getPlugins()),
|
|
80
|
-
createDocumentStylesPlugin(styles)
|
|
81
|
-
]
|
|
82
|
-
});
|
|
83
|
-
rejectAIEditRevision(revisions)(state, (transaction) => {
|
|
84
|
-
state = state.apply(transaction);
|
|
85
|
-
});
|
|
86
|
-
if (state.doc.eq(doc)) return note;
|
|
87
|
-
return {
|
|
88
|
-
...note,
|
|
89
|
-
content: proseDocToBlocks(state.doc, note.content, styles)
|
|
90
|
-
};
|
|
91
|
-
};
|
|
92
|
-
/**
|
|
93
|
-
* The document with the named notes' deletions that went with their
|
|
94
|
-
* reference rejected: the notes whose reference's deletion was rejected get
|
|
95
|
-
* their text back. `before` is the body that still had those deletions.
|
|
96
|
-
*/
|
|
97
|
-
const restoreNotes = (document, keys, before) => {
|
|
98
|
-
const deletions = referenceDeletions(before);
|
|
99
|
-
const wanted = new Set([...keys].filter((key) => deletions.has(key)));
|
|
100
|
-
if (wanted.size === 0) return document;
|
|
101
|
-
const restore = (kind, notes) => {
|
|
102
|
-
if (!notes?.some((note) => wanted.has(noteKey(kind, note.id)))) return notes;
|
|
103
|
-
return notes.map((note) => {
|
|
104
|
-
const reference = deletions.get(noteKey(kind, note.id));
|
|
105
|
-
return reference ? restoredNote(note, document, reference) : note;
|
|
106
|
-
});
|
|
107
|
-
};
|
|
108
|
-
const footnotes = restore("footnote", document.package.footnotes);
|
|
109
|
-
const endnotes = restore("endnote", document.package.endnotes);
|
|
110
|
-
if (footnotes === document.package.footnotes && endnotes === document.package.endnotes) return document;
|
|
111
|
-
return {
|
|
112
|
-
...document,
|
|
113
|
-
package: {
|
|
114
|
-
...document.package,
|
|
115
|
-
...footnotes !== void 0 && { footnotes },
|
|
116
|
-
...endnotes !== void 0 && { endnotes }
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
};
|
|
120
|
-
/** The deletion each pending-deleted note reference carries. */
|
|
121
|
-
const referenceDeletions = (doc) => {
|
|
122
|
-
const deletions = /* @__PURE__ */ new Map();
|
|
123
|
-
doc.descendants((node) => {
|
|
124
|
-
if (!node.isText) return true;
|
|
125
|
-
const reference = node.marks.find((mark) => mark.type.name === "footnoteRef");
|
|
126
|
-
const deletion = node.marks.find((mark) => mark.type.name === "deletion");
|
|
127
|
-
if (reference && deletion) {
|
|
128
|
-
const { id, noteType } = expectFootnoteRefMarkAttrs(reference);
|
|
129
|
-
deletions.set(noteKey(noteType === "endnote" ? "endnote" : "footnote", Number(id)), deletion);
|
|
130
|
-
}
|
|
131
|
-
return false;
|
|
132
|
-
});
|
|
133
|
-
return deletions;
|
|
134
|
-
};
|
|
135
|
-
/**
|
|
136
|
-
* Delete a note's text and its paragraph marks along with its reference: by
|
|
137
|
-
* the reference deletion's author at its date, so resolving the reference
|
|
138
|
-
* resolves them too (see {@link noteDeletionRevisions}).
|
|
139
|
-
*/
|
|
140
|
-
const deleteNoteWithReference = (transform, reference) => {
|
|
141
|
-
const doc = transform.doc;
|
|
142
|
-
const markInfo = {
|
|
143
|
-
id: mintRevisionId(),
|
|
144
|
-
author: String(reference.attrs["author"] ?? ""),
|
|
145
|
-
date: String(reference.attrs["date"] ?? "")
|
|
146
|
-
};
|
|
147
|
-
const { utcDate, initials } = reference.attrs;
|
|
148
|
-
const deletion = (doc.type.schema.marks["deletion"] ?? reference.type).create({
|
|
149
|
-
revisionId: mintRevisionId(),
|
|
150
|
-
author: markInfo.author,
|
|
151
|
-
date: markInfo.date,
|
|
152
|
-
...utcDate != null && { utcDate },
|
|
153
|
-
...initials != null && { initials }
|
|
154
|
-
});
|
|
155
|
-
doc.descendants((node, position) => {
|
|
156
|
-
if (node.type.name === "paragraph" && expectParagraphAttrs(node).pPrMark == null) transform.setNodeAttribute(position, "pPrMark", {
|
|
157
|
-
kind: "del",
|
|
158
|
-
info: markInfo
|
|
159
|
-
});
|
|
160
|
-
if (node.isInline && !deletion.type.isInSet(node.marks)) addTrackedDeletionMark({
|
|
161
|
-
insertionPolicy: "preserve-pending",
|
|
162
|
-
tr: transform,
|
|
163
|
-
from: position,
|
|
164
|
-
to: position + node.nodeSize,
|
|
165
|
-
mark: deletion
|
|
166
|
-
});
|
|
167
|
-
return !node.isInline;
|
|
168
|
-
});
|
|
169
|
-
return transform;
|
|
170
|
-
};
|
|
171
|
-
/**
|
|
172
|
-
* A note whose reference was deleted: its text and its paragraph marks are
|
|
173
|
-
* deleted too, by the reference's author at the reference's date.
|
|
174
|
-
*/
|
|
175
|
-
const deletedNote = (note, document, reference) => {
|
|
176
|
-
const { styles, theme, numbering } = document.package;
|
|
177
|
-
const doc = footnoteToProseDoc(note.content, {
|
|
178
|
-
...styles !== void 0 && { styles },
|
|
179
|
-
...theme !== void 0 && { theme },
|
|
180
|
-
...numbering !== void 0 && { numbering }
|
|
181
|
-
});
|
|
182
|
-
const transform = deleteNoteWithReference(new Transform(doc), reference);
|
|
183
|
-
if (!transform.docChanged) return note;
|
|
184
|
-
return {
|
|
185
|
-
...note,
|
|
186
|
-
content: proseDocToBlocks(transform.doc, note.content, styles)
|
|
187
|
-
};
|
|
188
|
-
};
|
|
189
|
-
const editNotes = (document, edits) => {
|
|
190
|
-
if (edits.size === 0) return document;
|
|
191
|
-
const edit = (kind, notes) => {
|
|
192
|
-
if (!notes?.some((note) => edits.has(noteKey(kind, note.id)))) return notes;
|
|
193
|
-
return notes.map((note) => edits.get(noteKey(kind, note.id))?.(note) ?? note);
|
|
194
|
-
};
|
|
195
|
-
const footnotes = edit("footnote", document.package.footnotes);
|
|
196
|
-
const endnotes = edit("endnote", document.package.endnotes);
|
|
197
|
-
if (footnotes === document.package.footnotes && endnotes === document.package.endnotes) return document;
|
|
198
|
-
return {
|
|
199
|
-
...document,
|
|
200
|
-
package: {
|
|
201
|
-
...document.package,
|
|
202
|
-
...footnotes !== void 0 && { footnotes },
|
|
203
|
-
...endnotes !== void 0 && { endnotes }
|
|
204
|
-
}
|
|
205
|
-
};
|
|
206
|
-
};
|
|
207
|
-
const createNoteReferenceFollower = () => {
|
|
208
|
-
let base = null;
|
|
209
|
-
const replaced = /* @__PURE__ */ new Map();
|
|
210
|
-
const pending = /* @__PURE__ */ new Map();
|
|
211
|
-
const recorded = (key, edit) => (note) => {
|
|
212
|
-
const result = edit(note);
|
|
213
|
-
if (result !== note) pending.set(key, {
|
|
214
|
-
from: note,
|
|
215
|
-
to: result
|
|
216
|
-
});
|
|
217
|
-
return result;
|
|
218
|
-
};
|
|
219
|
-
return {
|
|
220
|
-
noteBase: (before) => {
|
|
221
|
-
base ??= before;
|
|
222
|
-
},
|
|
223
|
-
reconcile: (document, body) => {
|
|
224
|
-
const before = base;
|
|
225
|
-
base = null;
|
|
226
|
-
if (!before) return document;
|
|
227
|
-
const was = noteReferenceStates(before);
|
|
228
|
-
const now = noteReferenceStates(body);
|
|
229
|
-
const deletions = referenceDeletions(body);
|
|
230
|
-
const rejected = referenceDeletions(before);
|
|
231
|
-
const edits = /* @__PURE__ */ new Map();
|
|
232
|
-
for (const [key, state] of now) {
|
|
233
|
-
const previous = was.get(key);
|
|
234
|
-
const rejectedDeletion = rejected.get(key);
|
|
235
|
-
if (state === "live" && previous === "deleted" && rejectedDeletion) edits.set(key, recorded(key, (note) => {
|
|
236
|
-
const restored = restoredNote(note, document, rejectedDeletion);
|
|
237
|
-
if (restored !== note) replaced.set(key, {
|
|
238
|
-
restored,
|
|
239
|
-
previous: note
|
|
240
|
-
});
|
|
241
|
-
return restored;
|
|
242
|
-
}));
|
|
243
|
-
const reference = deletions.get(key);
|
|
244
|
-
if (state === "deleted" && previous === "live" && reference) edits.set(key, recorded(key, (note) => {
|
|
245
|
-
const earlier = replaced.get(key);
|
|
246
|
-
replaced.delete(key);
|
|
247
|
-
return earlier?.restored === note ? earlier.previous : deletedNote(note, document, reference);
|
|
248
|
-
}));
|
|
249
|
-
}
|
|
250
|
-
return editNotes(document, edits);
|
|
251
|
-
},
|
|
252
|
-
withPending: (document) => {
|
|
253
|
-
const edits = /* @__PURE__ */ new Map();
|
|
254
|
-
for (const [key, { from, to }] of pending) edits.set(key, (note) => {
|
|
255
|
-
if (note !== from) pending.delete(key);
|
|
256
|
-
return note === from ? to : note;
|
|
257
|
-
});
|
|
258
|
-
return editNotes(document, edits);
|
|
259
|
-
},
|
|
260
|
-
reset: () => {
|
|
261
|
-
base = null;
|
|
262
|
-
replaced.clear();
|
|
263
|
-
pending.clear();
|
|
264
|
-
}
|
|
265
|
-
};
|
|
266
|
-
};
|
|
267
26
|
/** The notes model content refers to, live or pending deletion. */
|
|
268
27
|
const noteKeysReferencedIn = (content) => {
|
|
269
28
|
const keys = /* @__PURE__ */ new Set();
|
|
@@ -358,4 +117,4 @@ const withoutUnreferencedNotes = (document, heldUnreferenced) => {
|
|
|
358
117
|
}
|
|
359
118
|
};
|
|
360
119
|
};
|
|
361
|
-
export {
|
|
120
|
+
export { heldUnreferencedNotes, noteKeysReferencedIn, noteReferenceStates, referencedNotes, withoutUnreferencedNotes };
|
|
@@ -1,7 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Paragraph-id allocation shared by load-time seeding and the live
|
|
3
|
+
* allocator plugin (`ParaIdAllocatorExtension`).
|
|
4
|
+
*
|
|
5
|
+
* Split out of
|
|
6
|
+
* https://github.com/eigenpal/docx-editor/blob/main/packages/core/src/prosemirror/extensions/features/ParaIdAllocatorExtension.ts
|
|
7
|
+
* (Apache-2.0); see that module for the id lifecycle rules.
|
|
8
|
+
*/
|
|
3
9
|
import { EditorState, Plugin, PluginKey, Transaction } from "prosemirror-state";
|
|
4
|
-
|
|
10
|
+
import { Node } from "prosemirror-model";
|
|
11
|
+
export type ParagraphPropertySourceSeed = {
|
|
5
12
|
contract: string | null;
|
|
6
13
|
tokens: ReadonlySet<string>;
|
|
7
14
|
};
|
|
@@ -25,23 +32,8 @@ export declare const paraIdAllocatorKey: Readonly<{
|
|
|
25
32
|
export declare const deterministicParaIdSeedKey = "stll.folio.meta.deterministicParaIdSeed";
|
|
26
33
|
/** Ask the allocator to mint reproducible ids for the paragraphs `tr` creates. */
|
|
27
34
|
export declare const requestDeterministicParaIds: (tr: Transaction, seed: string) => Transaction;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
} | {
|
|
31
|
-
pos: number;
|
|
32
|
-
status: "deleted" | "mapped";
|
|
33
|
-
};
|
|
34
|
-
type MappedParagraphKeepers = {
|
|
35
|
-
paraIds: Map<string, number>;
|
|
36
|
-
sourceTokens: Map<string, ParagraphPropertySourceKeeper>;
|
|
37
|
-
};
|
|
38
|
-
/**
|
|
39
|
-
* Where each id's and each seeded source token's owner went: the first
|
|
40
|
-
* occurrence that survives the batch keeps an id.
|
|
41
|
-
*
|
|
42
|
-
* @internal Exported for the per-step equivalence test.
|
|
43
|
-
*/
|
|
44
|
-
export declare const mapParagraphKeepers: (oldDoc: Node, transactions: readonly Transaction[], sourceSeed: ParagraphPropertySourceSeed) => MappedParagraphKeepers;
|
|
35
|
+
export declare const isUsableParaId: (value: unknown) => value is string;
|
|
36
|
+
export declare const visitAuthoredParagraphs: (doc: Node, visit: (node: Node, pos: number) => void) => void;
|
|
45
37
|
/**
|
|
46
38
|
* Allocate initial paragraph IDs before constructing editor state.
|
|
47
39
|
*
|
|
@@ -51,6 +43,4 @@ export declare const mapParagraphKeepers: (oldDoc: Node, transactions: readonly
|
|
|
51
43
|
*/
|
|
52
44
|
export declare const ensureParaIdsInDoc: (doc: Node) => Node;
|
|
53
45
|
/** {@link ensureParaIdsInDoc} for a state that already exists. */
|
|
54
|
-
export declare const ensureParaIdsInState: (state: EditorState) => EditorState;
|
|
55
|
-
export declare const ParaIdAllocatorExtension: (options?: Partial<Record<never, never>> | undefined) => Extension;
|
|
56
|
-
export {};
|
|
46
|
+
export declare const ensureParaIdsInState: (state: EditorState) => EditorState;
|