@stll/folio-core 0.43.0 → 0.45.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai-edits/__fixtures__/paragraphs.js +2 -2
- package/dist/ai-edits/headless.js +7 -5
- package/dist/ai-edits/index.d.ts +2 -2
- package/dist/ai-edits/index.js +2 -2
- package/dist/ai-edits/snapshot.js +13 -9
- package/dist/compare/content-alignment.js +94 -54
- package/dist/compare/inline-atoms.js +34 -20
- package/dist/compare/style-resources.js +6 -0
- package/dist/content-controls/mutateContentControls.js +4 -2
- package/dist/display-list/dom/renderDisplayListToDom.js +8 -8
- package/dist/document-operations.js +14 -3
- package/dist/docx/appVersionNormalization.d.ts +0 -18
- package/dist/docx/blockContentParser.js +8 -0
- package/dist/docx/blockRangeMarkers.d.ts +36 -0
- package/dist/docx/blockRangeMarkers.js +59 -0
- package/dist/docx/bookmarkParser.d.ts +2 -20
- package/dist/docx/bookmarkParser.js +6 -30
- package/dist/docx/borderParser.d.ts +13 -0
- package/dist/docx/borderParser.js +71 -0
- package/dist/docx/builtInStyles.d.ts +165 -0
- package/dist/docx/builtInStyles.js +239 -0
- package/dist/docx/commentIdNormalization.d.ts +3 -1
- package/dist/docx/commentIdNormalization.js +18 -1
- package/dist/docx/commentParser.d.ts +2 -1
- package/dist/docx/commentParser.js +80 -42
- package/dist/docx/commentReferenceNormalization.d.ts +4 -1
- package/dist/docx/commentReferenceNormalization.js +23 -14
- package/dist/docx/commentThreadKey.d.ts +18 -0
- package/dist/docx/commentThreadKey.js +22 -0
- package/dist/docx/danglingRelationshipReferences.d.ts +15 -0
- package/dist/docx/danglingRelationshipReferences.js +30 -0
- package/dist/docx/defaultParagraphStyle.d.ts +18 -1
- package/dist/docx/defaultParagraphStyle.js +23 -1
- package/dist/docx/diagramPreview.js +87 -27
- package/dist/docx/documentParser.d.ts +2 -1
- package/dist/docx/documentParser.js +2 -2
- package/dist/docx/drawingUtils.d.ts +8 -1
- package/dist/docx/drawingUtils.js +12 -3
- package/dist/docx/fieldParser.js +3 -5
- package/dist/docx/footnoteParser.d.ts +3 -2
- package/dist/docx/footnoteParser.js +19 -4
- package/dist/docx/groupDrawingParser.js +4 -4
- package/dist/docx/headerFooterRefParser.d.ts +4 -3
- package/dist/docx/headerFooterRefParser.js +42 -12
- package/dist/docx/headerFooterReferenceNormalization.d.ts +4 -1
- package/dist/docx/headerFooterReferenceNormalization.js +5 -1
- package/dist/docx/hyperlinkParser.js +13 -17
- package/dist/docx/imageParser.d.ts +10 -2
- package/dist/docx/imageParser.js +80 -30
- package/dist/docx/imageRawXml.d.ts +14 -1
- package/dist/docx/imageRawXml.js +35 -11
- package/dist/docx/markupRangeMarker.d.ts +15 -0
- package/dist/docx/markupRangeMarker.js +44 -0
- package/dist/docx/mathToMathml.js +12 -14
- package/dist/docx/nonVisualDrawingProps.d.ts +34 -0
- package/dist/docx/nonVisualDrawingProps.js +46 -0
- package/dist/docx/noteReferenceStyles.d.ts +29 -0
- package/dist/docx/noteReferenceStyles.js +70 -0
- package/dist/docx/numberingReferenceNormalization.d.ts +4 -1
- package/dist/docx/numberingReferenceNormalization.js +20 -1
- package/dist/docx/paraIdRangeNormalization.d.ts +0 -19
- package/dist/docx/paragraphParser.js +66 -99
- package/dist/docx/paragraphPropertySource.js +1 -0
- package/dist/docx/paragraphTextBoxEnrichment.js +3 -0
- package/dist/docx/paragraphTraversal.d.ts +37 -1
- package/dist/docx/paragraphTraversal.js +84 -1
- package/dist/docx/parseContext.d.ts +37 -0
- package/dist/docx/parseContext.js +67 -0
- package/dist/docx/parseWarningMessage.d.ts +6 -0
- package/dist/docx/parseWarningMessage.js +44 -0
- package/dist/docx/parser.js +83 -29
- package/dist/docx/previewBudget.d.ts +64 -0
- package/dist/docx/previewBudget.js +88 -0
- package/dist/docx/relsParser.d.ts +28 -11
- package/dist/docx/relsParser.js +26 -13
- package/dist/docx/revisionIdNormalization.js +96 -10
- package/dist/docx/rezip.js +80 -40
- package/dist/docx/runConsolidator.js +1 -2
- package/dist/docx/runParser.d.ts +8 -1
- package/dist/docx/runParser.js +30 -48
- package/dist/docx/sdtPropertiesPatch.js +24 -18
- package/dist/docx/sectionParser.d.ts +2 -1
- package/dist/docx/sectionParser.js +21 -65
- package/dist/docx/sectionReferenceHistory.js +2 -2
- package/dist/docx/selectiveSave.js +6 -6
- package/dist/docx/serializer/blockSdtSerializer.js +38 -26
- package/dist/docx/serializer/borderSerializer.d.ts +2 -3
- package/dist/docx/serializer/borderSerializer.js +13 -12
- package/dist/docx/serializer/commentSerializer.d.ts +41 -16
- package/dist/docx/serializer/commentSerializer.js +82 -72
- package/dist/docx/serializer/documentSerializer.d.ts +1 -5
- package/dist/docx/serializer/documentSerializer.js +6 -16
- package/dist/docx/serializer/fontTableSerializer.js +6 -6
- package/dist/docx/serializer/headerFooterSerializer.js +10 -5
- package/dist/docx/serializer/markupRangeAttributes.d.ts +8 -0
- package/dist/docx/serializer/markupRangeAttributes.js +24 -0
- package/dist/docx/serializer/noteSerializer.js +5 -0
- package/dist/docx/serializer/numberingSerializer.js +7 -6
- package/dist/docx/serializer/paragraphSerializer.d.ts +1 -5
- package/dist/docx/serializer/paragraphSerializer.js +47 -52
- package/dist/docx/serializer/partNamespaces.js +2 -2
- package/dist/docx/serializer/runSerializer.js +57 -31
- package/dist/docx/serializer/sectionPropertiesSerializer.js +11 -10
- package/dist/docx/serializer/settingsSerializer.js +4 -3
- package/dist/docx/serializer/stylesSerializer.js +6 -6
- package/dist/docx/serializer/tableSerializer.js +37 -21
- package/dist/docx/serializer/textFormattingSerializer.d.ts +2 -3
- package/dist/docx/serializer/textFormattingSerializer.js +29 -28
- package/dist/docx/serializer/themeSerializer.js +6 -6
- package/dist/docx/serializer/trackedChangeAttributes.js +2 -2
- package/dist/docx/serializer/xmlUtils.d.ts +1 -2
- package/dist/docx/serializer/xmlUtils.js +1 -13
- package/dist/docx/server/boundedArchive.d.ts +12 -0
- package/dist/docx/server/boundedArchive.js +20 -1
- package/dist/docx/server/build.js +8 -1
- package/dist/docx/server/createBilingualDocument.js +10 -18
- package/dist/docx/server/extractDocxText.js +3 -4
- package/dist/docx/server/validateDocxConformance.js +22 -1
- package/dist/docx/shadingParser.d.ts +6 -0
- package/dist/docx/shadingParser.js +32 -0
- package/dist/docx/shapeParser.js +10 -8
- package/dist/docx/styleParser.js +13 -87
- package/dist/docx/styleReferenceResolution.d.ts +36 -0
- package/dist/docx/styleReferenceResolution.js +51 -0
- package/dist/docx/tableLook.d.ts +57 -0
- package/dist/docx/tableLook.js +63 -0
- package/dist/docx/tableParser.d.ts +7 -9
- package/dist/docx/tableParser.js +64 -110
- package/dist/docx/textBoxParser.js +11 -6
- package/dist/docx/trackedMoveRangeNormalization.d.ts +3 -1
- package/dist/docx/trackedMoveRangeNormalization.js +11 -21
- package/dist/docx/transitionalSpelling.d.ts +13 -2
- package/dist/docx/transitionalSpelling.js +23 -1
- package/dist/docx/unzip.d.ts +23 -0
- package/dist/docx/unzip.js +32 -22
- package/dist/docx/verbatimCapture.js +5 -12
- package/dist/docx/vmlImageParser.js +5 -4
- package/dist/docx/vmlPreview.d.ts +1 -3
- package/dist/docx/vmlPreview.js +2 -30
- package/dist/docx/watermarkParser.js +2 -2
- package/dist/docx/xmlParser.d.ts +38 -33
- package/dist/docx/xmlParser.js +92 -47
- package/dist/docx/xmlResourceLimits.d.ts +89 -9
- package/dist/docx/xmlResourceLimits.js +105 -24
- package/dist/internal/pageBreakRunSourceDescendantIndex.js +2 -1
- package/dist/internal/paragraphFormattingSerialization.d.ts +2 -3
- package/dist/internal/paragraphFormattingSerialization.js +29 -8
- package/dist/layout-bridge/convert/footnoteLayout.js +2 -7
- package/dist/layout-engine/index.d.ts +2 -2
- package/dist/layout-engine/index.js +2 -2
- package/dist/layout-engine/measure/measureBlocks.js +1 -6
- package/dist/layout-engine/types.d.ts +8 -2
- package/dist/layout-engine/types.js +35 -2
- package/dist/layout-painter/renderImage.js +4 -3
- package/dist/layout-painter/renderParagraph.js +4 -3
- package/dist/managers/autoSaveCodec.js +2 -8
- package/dist/markdown/images.js +1 -4
- package/dist/markdown/index.js +1 -1
- package/dist/markdown/internals.d.ts +6 -1
- package/dist/markdown/internals.js +14 -1
- package/dist/markdown/renderBlock.js +35 -21
- package/dist/markdown/renderParagraph.js +14 -5
- package/dist/markdown/renderRuns.js +4 -3
- package/dist/markdown/renderTable.js +4 -3
- package/dist/markdown/trailers.js +41 -7
- package/dist/markdown/types.d.ts +3 -7
- package/dist/prosemirror/attrs/index.js +71 -5
- package/dist/prosemirror/bookmarkBoundaryAttrs.d.ts +11 -1
- package/dist/prosemirror/bookmarkBoundaryAttrs.js +18 -3
- package/dist/prosemirror/commands/image.js +1 -0
- package/dist/prosemirror/commands/index.d.ts +3 -3
- package/dist/prosemirror/commands/index.js +2 -2
- package/dist/prosemirror/commands/paragraph.d.ts +3 -3
- package/dist/prosemirror/commands/paragraph.js +2 -2
- package/dist/prosemirror/commentIdAllocator.js +2 -7
- package/dist/prosemirror/conversion/fromProseDoc.js +197 -68
- package/dist/prosemirror/conversion/toProseDoc.d.ts +1 -14
- package/dist/prosemirror/conversion/toProseDoc.js +458 -335
- package/dist/prosemirror/extensions/core/ParagraphExtension.d.ts +14 -1
- package/dist/prosemirror/extensions/core/ParagraphExtension.js +11 -6
- package/dist/prosemirror/extensions/features/EmptyParagraphFormatExtension.js +3 -3
- package/dist/prosemirror/extensions/features/PasteCleanupExtension.d.ts +4 -1
- package/dist/prosemirror/extensions/features/PasteCleanupExtension.js +6 -2
- package/dist/prosemirror/extensions/features/pastedHeadingStyles.d.ts +7 -0
- package/dist/prosemirror/extensions/features/pastedHeadingStyles.js +74 -0
- package/dist/prosemirror/extensions/marks/HyperlinkExtension.js +2 -3
- package/dist/prosemirror/extensions/marks/markUtils.d.ts +11 -3
- package/dist/prosemirror/extensions/marks/markUtils.js +98 -19
- package/dist/prosemirror/extensions/nodes/BookmarkBoundaryExtension.js +7 -3
- package/dist/prosemirror/extensions/nodes/ImageExtension.js +6 -1
- package/dist/prosemirror/extensions/nodes/ShapeExtension.js +8 -2
- package/dist/prosemirror/extensions/nodes/TableExtension.js +15 -1
- package/dist/prosemirror/extensions/nodes/TextBoxExtension.js +8 -4
- package/dist/prosemirror/extensions/types.d.ts +2 -2
- package/dist/prosemirror/index.d.ts +3 -3
- package/dist/prosemirror/index.js +3 -3
- package/dist/prosemirror/insertOperations.d.ts +9 -2
- package/dist/prosemirror/insertOperations.js +9 -4
- package/dist/prosemirror/paragraphFormattingProvenance.d.ts +162 -0
- package/dist/prosemirror/paragraphFormattingProvenance.js +115 -0
- package/dist/prosemirror/plugins/documentStyles.d.ts +9 -1
- package/dist/prosemirror/plugins/documentStyles.js +11 -1
- package/dist/prosemirror/plugins/index.d.ts +2 -2
- package/dist/prosemirror/plugins/index.js +2 -2
- package/dist/prosemirror/plugins/revisionIds.d.ts +11 -2
- package/dist/prosemirror/plugins/revisionIds.js +21 -6
- package/dist/prosemirror/runFormattingReconciliation.js +3 -2
- package/dist/prosemirror/runStyleFormatting.d.ts +1 -1
- package/dist/prosemirror/schema/nodes.d.ts +81 -1
- package/dist/prosemirror/styles/resolvedStyleAttrs.js +2 -0
- package/dist/prosemirror/styles/styleResolver.d.ts +9 -0
- package/dist/prosemirror/styles/styleResolver.js +12 -0
- package/dist/style-engine/styleEngine.d.ts +3 -0
- package/dist/style-engine/styleEngine.js +3 -0
- package/dist/style-sets/extract.js +1 -23
- package/dist/style-sets/stellaStyle.js +46 -39
- package/dist/style-sets/styleSetNormalization.d.ts +19 -0
- package/dist/style-sets/styleSetNormalization.js +99 -0
- package/dist/types/content.d.ts +2 -2
- package/dist/utils/base64.d.ts +36 -0
- package/dist/utils/base64.js +40 -0
- package/dist/utils/clipboard.js +2 -1
- package/dist/utils/createDocument.js +145 -20
- package/dist/utils/headingCollector.d.ts +8 -5
- package/dist/utils/headingCollector.js +23 -25
- package/dist/utils/tableOfContentsStyle.js +9 -2
- package/dist/utils/units.d.ts +10 -1
- package/dist/utils/units.js +12 -1
- package/dist/utils/urlSecurity.d.ts +8 -2
- package/dist/utils/urlSecurity.js +21 -3
- package/package.json +2 -2
- package/dist/docx/textWhitespace.d.ts +0 -4
- package/dist/docx/textWhitespace.js +0 -4
- package/dist/layout-bridge/engine/tableWidthUtils.d.ts +0 -6
- package/dist/layout-bridge/engine/tableWidthUtils.js +0 -25
- package/dist/markdown/headings.d.ts +0 -13
- package/dist/markdown/headings.js +0 -20
|
@@ -2,7 +2,7 @@ import { PAINTABLE_MARK_NAMES, applyFormatMarks, captureFormatMarks } from "./co
|
|
|
2
2
|
import { clearFontFamily, clearFontSize, clearHighlight, clearTextColor, insertHyperlink, removeHyperlink, setFontFamily, setFontSize, setHighlight, setHyperlink, setTextColor, toggleBold, toggleItalic, toggleStrike, toggleSubscript, toggleSuperscript, toggleUnderline } from "./commands/formatting.js";
|
|
3
3
|
import { insertImageFromFile } from "./commands/image.js";
|
|
4
4
|
import { insertPageBreak } from "./commands/pageBreak.js";
|
|
5
|
-
import { addTabStop, alignCenter, alignJustify, alignLeft, alignRight, applyStyle, clearStyle, decreaseIndent, decreaseListLevel,
|
|
5
|
+
import { addTabStop, alignCenter, alignJustify, alignLeft, alignRight, applyStyle, clearStyle, decreaseIndent, decreaseListLevel, generateTableOfContents, increaseIndent, increaseListLevel, removeList, removeTabStop, setAlignment, setIndentFirstLine, setIndentLeft, setIndentRight, setLineSpacing, setLtr, 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
7
|
import { fromProseDoc, updateDocumentContent } from "./conversion/fromProseDoc.js";
|
|
8
8
|
import { createEmptyDoc, toProseDoc } from "./conversion/toProseDoc.js";
|
|
@@ -13,11 +13,11 @@ import { getHyperlinkAttrs, getSelectedText, isHyperlinkActive } from "./extensi
|
|
|
13
13
|
import { clearFormatting, getMarkAttr, isMarkActive } from "./extensions/marks/markUtils.js";
|
|
14
14
|
import { getTableContext, isInTable as isInTableCell } from "./extensions/nodes/TableExtension.js";
|
|
15
15
|
import { insertPageBreakInView, insertTableInView, insertTableOfContentsInView } from "./insertOperations.js";
|
|
16
|
-
import { createDocumentStylesPlugin, documentStylesKey, getDocumentStyleResolver } from "./plugins/documentStyles.js";
|
|
16
|
+
import { createDocumentStylesPlugin, documentStylesKey, getDocumentBuiltInStyles, getDocumentStyleResolver } from "./plugins/documentStyles.js";
|
|
17
17
|
import { createSelectionTrackerPlugin, extractSelectionContext, getSelectionContext, selectionTrackerKey } from "./plugins/selectionTracker.js";
|
|
18
18
|
import { schema, singletonManager } from "./schema/index.js";
|
|
19
19
|
import { extractSelectionState } from "./selectionState.js";
|
|
20
20
|
import { StyleResolver, createStyleResolver } from "./styles/styleResolver.js";
|
|
21
21
|
import { assertValidProseMirrorDocument, formatProseMirrorDocumentIssues, validateProseMirrorDocument } from "./validation.js";
|
|
22
22
|
import { TextSelection } from "prosemirror-state";
|
|
23
|
-
export { 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, createDocumentStylesPlugin, createEmptyDoc, createSelectionTrackerPlugin, createStyleResolver, decreaseIndent, decreaseListLevel, deleteColumn, deleteRow, deleteTable, distributeColumns, documentStylesKey, ensureParaIdsInState, extractSelectionContext, extractSelectionState, formatProseMirrorDocumentIssues, fromProseDoc,
|
|
23
|
+
export { 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, 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, isInTableCell as isInTable, isMarkActive, mergeCells, removeHyperlink, removeList, removeTabStop, removeTableBorders, schema, selectColumn, selectRow, selectTable, selectionTrackerKey, setAlignment, setAllTableBorders, setCellBorder, setCellFillColor, setCellMargins, setCellTextDirection, setCellVerticalAlign, setFontFamily, setFontSize, setHighlight, setHyperlink, setIndentFirstLine, setIndentLeft, setIndentRight, setInsideTableBorders, setLineSpacing, setLtr, setOutsideTableBorders, setRowHeight, setRtl, setTableBorderColor, setTableBorderPreset, setTableBorderWidth, setTableBorders, setTableProperties, setTextColor, singletonManager, splitCell, toProseDoc, toggleBidi, toggleBold, toggleBulletList, toggleHeaderRow, toggleItalic, toggleNoWrap, toggleNumberedList, toggleStrike, toggleSubscript, toggleSuperscript, toggleUnderline, updateDocumentContent, validateProseMirrorDocument };
|
|
@@ -1,11 +1,18 @@
|
|
|
1
|
+
import { GenerateTableOfContentsOptions } from "./extensions/core/ParagraphExtension.js";
|
|
1
2
|
import { insertImageFromFile } from "./commands/image.js";
|
|
3
|
+
import "./commands/index.js";
|
|
2
4
|
import { EditorView } from "prosemirror-view";
|
|
3
5
|
//#region src/prosemirror/insertOperations.d.ts
|
|
4
6
|
/** Insert a `rows × columns` table at the current selection. */
|
|
5
7
|
declare function insertTableInView(view: EditorView, rows: number, columns: number): boolean;
|
|
6
8
|
/** Insert a page break at the current selection. */
|
|
7
9
|
declare function insertPageBreakInView(view: EditorView): boolean;
|
|
8
|
-
/**
|
|
9
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Generate (or refresh) a table of contents from the document's headings.
|
|
12
|
+
*
|
|
13
|
+
* `title` is the caller's because this layer has no locale — see
|
|
14
|
+
* {@link GenerateTableOfContentsOptions}.
|
|
15
|
+
*/
|
|
16
|
+
declare function insertTableOfContentsInView(view: EditorView, options: GenerateTableOfContentsOptions): boolean;
|
|
10
17
|
//#endregion
|
|
11
18
|
export { insertImageFromFile, insertPageBreakInView, insertTableInView, insertTableOfContentsInView };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { insertImageFromFile } from "./commands/image.js";
|
|
2
2
|
import { insertPageBreak } from "./commands/pageBreak.js";
|
|
3
|
-
import {
|
|
3
|
+
import { generateTableOfContents } from "./commands/paragraph.js";
|
|
4
4
|
import { insertTable } from "./commands/table.js";
|
|
5
5
|
//#region src/prosemirror/insertOperations.ts
|
|
6
6
|
/** Insert a `rows × columns` table at the current selection. */
|
|
@@ -11,9 +11,14 @@ function insertTableInView(view, rows, columns) {
|
|
|
11
11
|
function insertPageBreakInView(view) {
|
|
12
12
|
return insertPageBreak(view.state, view.dispatch);
|
|
13
13
|
}
|
|
14
|
-
/**
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Generate (or refresh) a table of contents from the document's headings.
|
|
16
|
+
*
|
|
17
|
+
* `title` is the caller's because this layer has no locale — see
|
|
18
|
+
* {@link GenerateTableOfContentsOptions}.
|
|
19
|
+
*/
|
|
20
|
+
function insertTableOfContentsInView(view, options) {
|
|
21
|
+
return generateTableOfContents(options)(view.state, view.dispatch);
|
|
17
22
|
}
|
|
18
23
|
//#endregion
|
|
19
24
|
export { insertImageFromFile, insertPageBreakInView, insertTableInView, insertTableOfContentsInView };
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { document_d_exports } from "../types/document.js";
|
|
2
|
+
import { ParagraphAttrs } from "./schema/nodes.js";
|
|
3
|
+
//#region src/prosemirror/paragraphFormattingProvenance.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* How each `w:pPr` field reaches the saved model from paragraph attrs.
|
|
6
|
+
*
|
|
7
|
+
* - `style-resolved-attr`: the named attr holds the effective value, so the
|
|
8
|
+
* write-back filters it against `ParagraphAttrs._resolvedFormatting`.
|
|
9
|
+
* - `direct-provenance`: the field has its own provenance channel and reader
|
|
10
|
+
* (`alignmentFromStyle`, `spacingFromDocDefaults`, `numPrFromStyle`, …).
|
|
11
|
+
* - `derived`: not authored; recomputed from another field on load and save.
|
|
12
|
+
* - `original-only`: no editor attr writes it back; it survives through
|
|
13
|
+
* `ParagraphAttrs._originalFormatting`.
|
|
14
|
+
*/
|
|
15
|
+
type ParagraphFieldWriteBack = {
|
|
16
|
+
kind: "style-resolved-attr";
|
|
17
|
+
attr: keyof ParagraphAttrs;
|
|
18
|
+
} | {
|
|
19
|
+
kind: "direct-provenance";
|
|
20
|
+
} | {
|
|
21
|
+
kind: "derived";
|
|
22
|
+
} | {
|
|
23
|
+
kind: "original-only";
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Total over `ParagraphFormatting`, so a new `w:pPr` field cannot land without
|
|
27
|
+
* a decision about how a save tells its authored value from its inherited one.
|
|
28
|
+
*/
|
|
29
|
+
declare const PARAGRAPH_FORMATTING_WRITE_BACK: {
|
|
30
|
+
readonly alignment: {
|
|
31
|
+
readonly kind: "direct-provenance";
|
|
32
|
+
};
|
|
33
|
+
readonly bidi: {
|
|
34
|
+
readonly kind: "style-resolved-attr";
|
|
35
|
+
readonly attr: "direction";
|
|
36
|
+
};
|
|
37
|
+
readonly kinsoku: {
|
|
38
|
+
readonly kind: "style-resolved-attr";
|
|
39
|
+
readonly attr: "kinsoku";
|
|
40
|
+
};
|
|
41
|
+
readonly overflowPunctuation: {
|
|
42
|
+
readonly kind: "style-resolved-attr";
|
|
43
|
+
readonly attr: "overflowPunctuation";
|
|
44
|
+
};
|
|
45
|
+
readonly spaceBefore: {
|
|
46
|
+
readonly kind: "direct-provenance";
|
|
47
|
+
};
|
|
48
|
+
readonly spaceAfter: {
|
|
49
|
+
readonly kind: "direct-provenance";
|
|
50
|
+
};
|
|
51
|
+
readonly lineSpacing: {
|
|
52
|
+
readonly kind: "direct-provenance";
|
|
53
|
+
};
|
|
54
|
+
readonly lineSpacingRule: {
|
|
55
|
+
readonly kind: "direct-provenance";
|
|
56
|
+
};
|
|
57
|
+
readonly snapToGrid: {
|
|
58
|
+
readonly kind: "style-resolved-attr";
|
|
59
|
+
readonly attr: "snapToGrid";
|
|
60
|
+
};
|
|
61
|
+
readonly beforeAutospacing: {
|
|
62
|
+
readonly kind: "direct-provenance";
|
|
63
|
+
};
|
|
64
|
+
readonly afterAutospacing: {
|
|
65
|
+
readonly kind: "direct-provenance";
|
|
66
|
+
};
|
|
67
|
+
readonly spacingExplicit: {
|
|
68
|
+
readonly kind: "derived";
|
|
69
|
+
};
|
|
70
|
+
readonly indentLeft: {
|
|
71
|
+
readonly kind: "style-resolved-attr";
|
|
72
|
+
readonly attr: "indentLeft";
|
|
73
|
+
};
|
|
74
|
+
readonly indentRight: {
|
|
75
|
+
readonly kind: "style-resolved-attr";
|
|
76
|
+
readonly attr: "indentRight";
|
|
77
|
+
};
|
|
78
|
+
readonly indentFirstLine: {
|
|
79
|
+
readonly kind: "style-resolved-attr";
|
|
80
|
+
readonly attr: "indentFirstLine";
|
|
81
|
+
};
|
|
82
|
+
readonly hangingIndent: {
|
|
83
|
+
readonly kind: "direct-provenance";
|
|
84
|
+
};
|
|
85
|
+
readonly borders: {
|
|
86
|
+
readonly kind: "style-resolved-attr";
|
|
87
|
+
readonly attr: "borders";
|
|
88
|
+
};
|
|
89
|
+
readonly shading: {
|
|
90
|
+
readonly kind: "style-resolved-attr";
|
|
91
|
+
readonly attr: "shading";
|
|
92
|
+
};
|
|
93
|
+
readonly tabs: {
|
|
94
|
+
readonly kind: "style-resolved-attr";
|
|
95
|
+
readonly attr: "tabs";
|
|
96
|
+
};
|
|
97
|
+
readonly keepNext: {
|
|
98
|
+
readonly kind: "style-resolved-attr";
|
|
99
|
+
readonly attr: "keepNext";
|
|
100
|
+
};
|
|
101
|
+
readonly keepLines: {
|
|
102
|
+
readonly kind: "style-resolved-attr";
|
|
103
|
+
readonly attr: "keepLines";
|
|
104
|
+
};
|
|
105
|
+
readonly widowControl: {
|
|
106
|
+
readonly kind: "style-resolved-attr";
|
|
107
|
+
readonly attr: "widowControl";
|
|
108
|
+
};
|
|
109
|
+
readonly pageBreakBefore: {
|
|
110
|
+
readonly kind: "style-resolved-attr";
|
|
111
|
+
readonly attr: "pageBreakBefore";
|
|
112
|
+
};
|
|
113
|
+
readonly contextualSpacing: {
|
|
114
|
+
readonly kind: "style-resolved-attr";
|
|
115
|
+
readonly attr: "contextualSpacing";
|
|
116
|
+
};
|
|
117
|
+
readonly numPr: {
|
|
118
|
+
readonly kind: "direct-provenance";
|
|
119
|
+
};
|
|
120
|
+
readonly numPrFromStyle: {
|
|
121
|
+
readonly kind: "derived";
|
|
122
|
+
};
|
|
123
|
+
readonly numberingChangeXml: {
|
|
124
|
+
readonly kind: "original-only";
|
|
125
|
+
};
|
|
126
|
+
readonly outlineLevel: {
|
|
127
|
+
readonly kind: "style-resolved-attr";
|
|
128
|
+
readonly attr: "outlineLevel";
|
|
129
|
+
};
|
|
130
|
+
readonly styleId: {
|
|
131
|
+
readonly kind: "direct-provenance";
|
|
132
|
+
};
|
|
133
|
+
readonly frame: {
|
|
134
|
+
readonly kind: "original-only";
|
|
135
|
+
};
|
|
136
|
+
readonly suppressLineNumbers: {
|
|
137
|
+
readonly kind: "original-only";
|
|
138
|
+
};
|
|
139
|
+
readonly suppressAutoHyphens: {
|
|
140
|
+
readonly kind: "style-resolved-attr";
|
|
141
|
+
readonly attr: "suppressAutoHyphens";
|
|
142
|
+
};
|
|
143
|
+
readonly runProperties: {
|
|
144
|
+
readonly kind: "original-only";
|
|
145
|
+
};
|
|
146
|
+
readonly runInWithNext: {
|
|
147
|
+
readonly kind: "style-resolved-attr";
|
|
148
|
+
readonly attr: "runInWithNext";
|
|
149
|
+
};
|
|
150
|
+
};
|
|
151
|
+
type StyleResolvedParagraphField = { [Field in keyof typeof PARAGRAPH_FORMATTING_WRITE_BACK]: (typeof PARAGRAPH_FORMATTING_WRITE_BACK)[Field] extends {
|
|
152
|
+
kind: "style-resolved-attr";
|
|
153
|
+
} ? Field : never; }[keyof typeof PARAGRAPH_FORMATTING_WRITE_BACK];
|
|
154
|
+
declare const STYLE_RESOLVED_PARAGRAPH_FIELDS: StyleResolvedParagraphField[];
|
|
155
|
+
/**
|
|
156
|
+
* The part of a resolved style cascade a save needs to keep out of direct
|
|
157
|
+
* `w:pPr`. Narrowed to the governed fields so an ordinary paragraph, whose
|
|
158
|
+
* cascade supplies only spacing, stores nothing at all.
|
|
159
|
+
*/
|
|
160
|
+
declare const styleResolvedParagraphFormatting: (resolved: document_d_exports.ParagraphFormatting | undefined) => document_d_exports.ParagraphFormatting | undefined;
|
|
161
|
+
//#endregion
|
|
162
|
+
export { PARAGRAPH_FORMATTING_WRITE_BACK, ParagraphFieldWriteBack, STYLE_RESOLVED_PARAGRAPH_FIELDS, StyleResolvedParagraphField, styleResolvedParagraphFormatting };
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
//#region src/prosemirror/paragraphFormattingProvenance.ts
|
|
2
|
+
/**
|
|
3
|
+
* Total over `ParagraphFormatting`, so a new `w:pPr` field cannot land without
|
|
4
|
+
* a decision about how a save tells its authored value from its inherited one.
|
|
5
|
+
*/
|
|
6
|
+
const PARAGRAPH_FORMATTING_WRITE_BACK = {
|
|
7
|
+
alignment: { kind: "direct-provenance" },
|
|
8
|
+
bidi: {
|
|
9
|
+
kind: "style-resolved-attr",
|
|
10
|
+
attr: "direction"
|
|
11
|
+
},
|
|
12
|
+
kinsoku: {
|
|
13
|
+
kind: "style-resolved-attr",
|
|
14
|
+
attr: "kinsoku"
|
|
15
|
+
},
|
|
16
|
+
overflowPunctuation: {
|
|
17
|
+
kind: "style-resolved-attr",
|
|
18
|
+
attr: "overflowPunctuation"
|
|
19
|
+
},
|
|
20
|
+
spaceBefore: { kind: "direct-provenance" },
|
|
21
|
+
spaceAfter: { kind: "direct-provenance" },
|
|
22
|
+
lineSpacing: { kind: "direct-provenance" },
|
|
23
|
+
lineSpacingRule: { kind: "direct-provenance" },
|
|
24
|
+
snapToGrid: {
|
|
25
|
+
kind: "style-resolved-attr",
|
|
26
|
+
attr: "snapToGrid"
|
|
27
|
+
},
|
|
28
|
+
beforeAutospacing: { kind: "direct-provenance" },
|
|
29
|
+
afterAutospacing: { kind: "direct-provenance" },
|
|
30
|
+
spacingExplicit: { kind: "derived" },
|
|
31
|
+
indentLeft: {
|
|
32
|
+
kind: "style-resolved-attr",
|
|
33
|
+
attr: "indentLeft"
|
|
34
|
+
},
|
|
35
|
+
indentRight: {
|
|
36
|
+
kind: "style-resolved-attr",
|
|
37
|
+
attr: "indentRight"
|
|
38
|
+
},
|
|
39
|
+
indentFirstLine: {
|
|
40
|
+
kind: "style-resolved-attr",
|
|
41
|
+
attr: "indentFirstLine"
|
|
42
|
+
},
|
|
43
|
+
hangingIndent: { kind: "direct-provenance" },
|
|
44
|
+
borders: {
|
|
45
|
+
kind: "style-resolved-attr",
|
|
46
|
+
attr: "borders"
|
|
47
|
+
},
|
|
48
|
+
shading: {
|
|
49
|
+
kind: "style-resolved-attr",
|
|
50
|
+
attr: "shading"
|
|
51
|
+
},
|
|
52
|
+
tabs: {
|
|
53
|
+
kind: "style-resolved-attr",
|
|
54
|
+
attr: "tabs"
|
|
55
|
+
},
|
|
56
|
+
keepNext: {
|
|
57
|
+
kind: "style-resolved-attr",
|
|
58
|
+
attr: "keepNext"
|
|
59
|
+
},
|
|
60
|
+
keepLines: {
|
|
61
|
+
kind: "style-resolved-attr",
|
|
62
|
+
attr: "keepLines"
|
|
63
|
+
},
|
|
64
|
+
widowControl: {
|
|
65
|
+
kind: "style-resolved-attr",
|
|
66
|
+
attr: "widowControl"
|
|
67
|
+
},
|
|
68
|
+
pageBreakBefore: {
|
|
69
|
+
kind: "style-resolved-attr",
|
|
70
|
+
attr: "pageBreakBefore"
|
|
71
|
+
},
|
|
72
|
+
contextualSpacing: {
|
|
73
|
+
kind: "style-resolved-attr",
|
|
74
|
+
attr: "contextualSpacing"
|
|
75
|
+
},
|
|
76
|
+
numPr: { kind: "direct-provenance" },
|
|
77
|
+
numPrFromStyle: { kind: "derived" },
|
|
78
|
+
numberingChangeXml: { kind: "original-only" },
|
|
79
|
+
outlineLevel: {
|
|
80
|
+
kind: "style-resolved-attr",
|
|
81
|
+
attr: "outlineLevel"
|
|
82
|
+
},
|
|
83
|
+
styleId: { kind: "direct-provenance" },
|
|
84
|
+
frame: { kind: "original-only" },
|
|
85
|
+
suppressLineNumbers: { kind: "original-only" },
|
|
86
|
+
suppressAutoHyphens: {
|
|
87
|
+
kind: "style-resolved-attr",
|
|
88
|
+
attr: "suppressAutoHyphens"
|
|
89
|
+
},
|
|
90
|
+
runProperties: { kind: "original-only" },
|
|
91
|
+
runInWithNext: {
|
|
92
|
+
kind: "style-resolved-attr",
|
|
93
|
+
attr: "runInWithNext"
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
const STYLE_RESOLVED_PARAGRAPH_FIELDS = Object.keys(PARAGRAPH_FORMATTING_WRITE_BACK).filter((field) => PARAGRAPH_FORMATTING_WRITE_BACK[field].kind === "style-resolved-attr");
|
|
97
|
+
/**
|
|
98
|
+
* The part of a resolved style cascade a save needs to keep out of direct
|
|
99
|
+
* `w:pPr`. Narrowed to the governed fields so an ordinary paragraph, whose
|
|
100
|
+
* cascade supplies only spacing, stores nothing at all.
|
|
101
|
+
*/
|
|
102
|
+
const styleResolvedParagraphFormatting = (resolved) => {
|
|
103
|
+
if (!resolved) return;
|
|
104
|
+
const governed = {};
|
|
105
|
+
let found = false;
|
|
106
|
+
for (const field of STYLE_RESOLVED_PARAGRAPH_FIELDS) {
|
|
107
|
+
const value = resolved[field];
|
|
108
|
+
if (value === void 0) continue;
|
|
109
|
+
Reflect.set(governed, field, value);
|
|
110
|
+
found = true;
|
|
111
|
+
}
|
|
112
|
+
return found ? governed : void 0;
|
|
113
|
+
};
|
|
114
|
+
//#endregion
|
|
115
|
+
export { PARAGRAPH_FORMATTING_WRITE_BACK, STYLE_RESOLVED_PARAGRAPH_FIELDS, styleResolvedParagraphFormatting };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { document_d_exports } from "../../types/document.js";
|
|
2
|
+
import { BuiltInStyleIndex } from "../../docx/builtInStyles.js";
|
|
2
3
|
import { StyleResolver } from "../styles/styleResolver.js";
|
|
3
4
|
import { EditorState, Plugin, PluginKey } from "prosemirror-state";
|
|
4
5
|
//#region src/prosemirror/plugins/documentStyles.d.ts
|
|
@@ -13,7 +14,14 @@ declare const documentStylesKey: PluginKey<StyleResolver | null>;
|
|
|
13
14
|
declare function createDocumentStylesPlugin(styles: document_d_exports.StyleDefinitions | StyleResolver | null | undefined): Plugin;
|
|
14
15
|
/** Read the document's StyleResolver, or null when the plugin isn't installed. */
|
|
15
16
|
declare function getDocumentStyleResolver(state: EditorState): StyleResolver | null;
|
|
17
|
+
/**
|
|
18
|
+
* Read the document's built-in style index, for the callers that classify
|
|
19
|
+
* paragraphs (heading collection, markdown export, the AI snapshot). Without
|
|
20
|
+
* the plugin every lookup misses, which degrades classification to the
|
|
21
|
+
* paragraph's own outline level rather than to English style ids.
|
|
22
|
+
*/
|
|
23
|
+
declare function getDocumentBuiltInStyles(state: EditorState): BuiltInStyleIndex;
|
|
16
24
|
/** Reconfigure so ProseMirror replaces the keyed plugin's resolver state. */
|
|
17
25
|
declare const withDocumentStyles: (state: EditorState, styles: document_d_exports.StyleDefinitions | StyleResolver | null | undefined) => EditorState;
|
|
18
26
|
//#endregion
|
|
19
|
-
export { createDocumentStylesPlugin, documentStylesKey, getDocumentStyleResolver, withDocumentStyles };
|
|
27
|
+
export { createDocumentStylesPlugin, documentStylesKey, getDocumentBuiltInStyles, getDocumentStyleResolver, withDocumentStyles };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { EMPTY_BUILT_IN_STYLE_INDEX } from "../../docx/builtInStyles.js";
|
|
1
2
|
import { StyleResolver, createStyleResolver } from "../styles/styleResolver.js";
|
|
2
3
|
import { Plugin, PluginKey } from "prosemirror-state";
|
|
3
4
|
//#region src/prosemirror/plugins/documentStyles.ts
|
|
@@ -42,6 +43,15 @@ function createDocumentStylesPlugin(styles) {
|
|
|
42
43
|
function getDocumentStyleResolver(state) {
|
|
43
44
|
return documentStylesKey.getState(state) ?? null;
|
|
44
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* Read the document's built-in style index, for the callers that classify
|
|
48
|
+
* paragraphs (heading collection, markdown export, the AI snapshot). Without
|
|
49
|
+
* the plugin every lookup misses, which degrades classification to the
|
|
50
|
+
* paragraph's own outline level rather than to English style ids.
|
|
51
|
+
*/
|
|
52
|
+
function getDocumentBuiltInStyles(state) {
|
|
53
|
+
return getDocumentStyleResolver(state)?.builtInStyles ?? EMPTY_BUILT_IN_STYLE_INDEX;
|
|
54
|
+
}
|
|
45
55
|
/** Reconfigure so ProseMirror replaces the keyed plugin's resolver state. */
|
|
46
56
|
const withDocumentStyles = (state, styles) => {
|
|
47
57
|
const previous = documentStylesKey.get(state);
|
|
@@ -49,4 +59,4 @@ const withDocumentStyles = (state, styles) => {
|
|
|
49
59
|
return state.reconfigure({ plugins: retained }).reconfigure({ plugins: [...retained, createDocumentStylesPlugin(styles)] });
|
|
50
60
|
};
|
|
51
61
|
//#endregion
|
|
52
|
-
export { createDocumentStylesPlugin, documentStylesKey, getDocumentStyleResolver, withDocumentStyles };
|
|
62
|
+
export { createDocumentStylesPlugin, documentStylesKey, getDocumentBuiltInStyles, getDocumentStyleResolver, withDocumentStyles };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { SelectionChangeCallback, SelectionContext, createSelectionTrackerPlugin, extractSelectionContext, getSelectionContext, selectionTrackerKey } from "./selectionTracker.js";
|
|
2
|
-
import { createDocumentStylesPlugin, documentStylesKey, getDocumentStyleResolver } from "./documentStyles.js";
|
|
3
|
-
export { type SelectionChangeCallback, type SelectionContext, createDocumentStylesPlugin, createSelectionTrackerPlugin, documentStylesKey, extractSelectionContext, getDocumentStyleResolver, getSelectionContext, selectionTrackerKey };
|
|
2
|
+
import { createDocumentStylesPlugin, documentStylesKey, getDocumentBuiltInStyles, getDocumentStyleResolver } from "./documentStyles.js";
|
|
3
|
+
export { type SelectionChangeCallback, type SelectionContext, createDocumentStylesPlugin, createSelectionTrackerPlugin, documentStylesKey, extractSelectionContext, getDocumentBuiltInStyles, getDocumentStyleResolver, getSelectionContext, selectionTrackerKey };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { createDocumentStylesPlugin, documentStylesKey, getDocumentStyleResolver } from "./documentStyles.js";
|
|
1
|
+
import { createDocumentStylesPlugin, documentStylesKey, getDocumentBuiltInStyles, getDocumentStyleResolver } from "./documentStyles.js";
|
|
2
2
|
import { createSelectionTrackerPlugin, extractSelectionContext, getSelectionContext, selectionTrackerKey } from "./selectionTracker.js";
|
|
3
|
-
export { createDocumentStylesPlugin, createSelectionTrackerPlugin, documentStylesKey, extractSelectionContext, getDocumentStyleResolver, getSelectionContext, selectionTrackerKey };
|
|
3
|
+
export { createDocumentStylesPlugin, createSelectionTrackerPlugin, documentStylesKey, extractSelectionContext, getDocumentBuiltInStyles, getDocumentStyleResolver, getSelectionContext, selectionTrackerKey };
|
|
@@ -14,9 +14,18 @@ declare function mintRevisionId(): number;
|
|
|
14
14
|
*/
|
|
15
15
|
declare function seedRevisionIdsAbove(maxId: number): void;
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
17
|
+
* The highest id in `doc` from any part of the annotation space.
|
|
18
|
+
*
|
|
19
|
+
* A revision, a comment and a bookmark draw their `w:id` from one space, so a
|
|
20
|
+
* counter seeded above its own kind alone still mints over another kind's id.
|
|
21
|
+
* Both allocators seed from this, and the save-time normalization avoids the
|
|
22
|
+
* same space, so the three agree on what is taken.
|
|
23
|
+
*/
|
|
24
|
+
declare function maxAnnotationIdInDoc(doc: Node): number;
|
|
25
|
+
/**
|
|
26
|
+
* Raise the counter above every annotation id already present in `doc`.
|
|
18
27
|
* Called from the suggestion-mode plugin's `state.init`.
|
|
19
28
|
*/
|
|
20
29
|
declare function seedRevisionIdsFromDoc(doc: Node): void;
|
|
21
30
|
//#endregion
|
|
22
|
-
export { mintRevisionId, seedRevisionIdsAbove, seedRevisionIdsFromDoc };
|
|
31
|
+
export { maxAnnotationIdInDoc, mintRevisionId, seedRevisionIdsAbove, seedRevisionIdsFromDoc };
|
|
@@ -31,16 +31,24 @@ function seedRevisionIdsAbove(maxId) {
|
|
|
31
31
|
/** Node attrs that carry a revision id directly (`revisionId` field). */
|
|
32
32
|
const DIRECT_REVISION_ATTR_KEYS = ["trIns", "trDel"];
|
|
33
33
|
/**
|
|
34
|
-
*
|
|
35
|
-
*
|
|
34
|
+
* The highest id in `doc` from any part of the annotation space.
|
|
35
|
+
*
|
|
36
|
+
* A revision, a comment and a bookmark draw their `w:id` from one space, so a
|
|
37
|
+
* counter seeded above its own kind alone still mints over another kind's id.
|
|
38
|
+
* Both allocators seed from this, and the save-time normalization avoids the
|
|
39
|
+
* same space, so the three agree on what is taken.
|
|
36
40
|
*/
|
|
37
|
-
function
|
|
41
|
+
function maxAnnotationIdInDoc(doc) {
|
|
38
42
|
let max = 0;
|
|
39
43
|
const consider = (id) => {
|
|
40
44
|
if (typeof id === "number" && Number.isInteger(id) && id > max && id <= MAX_REVISION_ID) max = id;
|
|
41
45
|
};
|
|
42
46
|
doc.descendants((node) => {
|
|
43
|
-
for (const mark of node.marks)
|
|
47
|
+
for (const mark of node.marks) {
|
|
48
|
+
consider(mark.attrs["revisionId"]);
|
|
49
|
+
consider(mark.attrs["commentId"]);
|
|
50
|
+
}
|
|
51
|
+
if (node.type.name === "bookmarkBoundary") consider(node.attrs["id"]);
|
|
44
52
|
const attrs = node.attrs;
|
|
45
53
|
const pPrMark = attrs["pPrMark"];
|
|
46
54
|
if (pPrMark?.info) consider(pPrMark.info.id);
|
|
@@ -51,7 +59,14 @@ function seedRevisionIdsFromDoc(doc) {
|
|
|
51
59
|
const cellMarker = attrs["cellMarker"];
|
|
52
60
|
if (cellMarker?.info) consider(cellMarker.info.revisionId);
|
|
53
61
|
});
|
|
54
|
-
|
|
62
|
+
return max;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Raise the counter above every annotation id already present in `doc`.
|
|
66
|
+
* Called from the suggestion-mode plugin's `state.init`.
|
|
67
|
+
*/
|
|
68
|
+
function seedRevisionIdsFromDoc(doc) {
|
|
69
|
+
seedRevisionIdsAbove(maxAnnotationIdInDoc(doc));
|
|
55
70
|
}
|
|
56
71
|
//#endregion
|
|
57
|
-
export { mintRevisionId, seedRevisionIdsAbove, seedRevisionIdsFromDoc };
|
|
72
|
+
export { maxAnnotationIdInDoc, mintRevisionId, seedRevisionIdsAbove, seedRevisionIdsFromDoc };
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { mergeTextFormatting } from "../utils/textFormattingMerge.js";
|
|
2
2
|
import { expectCharacterStyleMarkAttrs } from "./attrs/index.js";
|
|
3
3
|
import { marksToTextFormatting } from "./conversion/fromProseDoc.js";
|
|
4
|
-
import { textFormattingToMarks } from "./
|
|
4
|
+
import { textFormattingToMarks } from "./extensions/marks/markUtils.js";
|
|
5
5
|
import { RUN_FORMATTING_MARK_NAMES } from "./runFormattingMarkNames.js";
|
|
6
6
|
import { getParagraphMarkSuppressionOverrides, hasDirectRunFormatting, paragraphFormattingForRun, resolveEffectiveRunStyleFormatting } from "./runStyleFormatting.js";
|
|
7
|
+
import { schema } from "./schema/index.js";
|
|
7
8
|
import { Mark } from "prosemirror-model";
|
|
8
9
|
//#region src/prosemirror/runFormattingReconciliation.ts
|
|
9
10
|
/** Read authored run properties without confusing inherited visuals for direct formatting. */
|
|
@@ -36,7 +37,7 @@ const reconcileRunFormattingMarks = ({ authoredFormatting, context, node, styleR
|
|
|
36
37
|
marks: styleResolutionMarks,
|
|
37
38
|
paragraphFormatting,
|
|
38
39
|
...styleResolver !== void 0 ? { styleResolver } : {}
|
|
39
|
-
}), authoredFormatting), {
|
|
40
|
+
}), authoredFormatting), schema, {
|
|
40
41
|
overrideFormatting: mergeTextFormatting(getParagraphMarkSuppressionOverrides({
|
|
41
42
|
directFormatting: authoredFormatting,
|
|
42
43
|
paragraphMarkFormatting: context.paragraphMarkFormatting,
|
|
@@ -26,7 +26,7 @@ type ParagraphRunStyleContext = {
|
|
|
26
26
|
paragraphMarkFormatting: document_d_exports.TextFormatting | undefined;
|
|
27
27
|
paragraphMarkPrecedesStyle: boolean;
|
|
28
28
|
};
|
|
29
|
-
type RunStyleResolver = Pick<StyleEngine, "getDefaultCharacterStyle" | "getDefaultParagraphStyle" | "getDocDefaults" | "getRunStyleOwnProperties" | "getStyle" | "resolveParagraphStyle">;
|
|
29
|
+
type RunStyleResolver = Pick<StyleEngine, "builtInStyles" | "getDefaultCharacterStyle" | "getDefaultParagraphStyle" | "getDocDefaults" | "getRunStyleOwnProperties" | "getStyle" | "resolveParagraphStyle">;
|
|
30
30
|
type ResolveParagraphBodyRunFormattingOptions = {
|
|
31
31
|
styleId: string | undefined;
|
|
32
32
|
styleResolver?: RunStyleResolver | null | undefined;
|