@stll/folio-core 0.71.1 → 0.72.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.
Files changed (31) hide show
  1. package/README.md +2 -2
  2. package/dist/compat/eigenpal.d.ts +1 -2
  3. package/dist/compat/eigenpal.js +1 -2
  4. package/dist/controller/canonicalYjsRoom.d.ts +1 -1
  5. package/dist/controller/headerFooterEditorManager.d.ts +11 -7
  6. package/dist/controller/headerFooterEditorManager.js +39 -151
  7. package/dist/controller/hiddenEditorManager.d.ts +2 -37
  8. package/dist/controller/hiddenEditorManager.js +100 -293
  9. package/dist/controller/noteEditorManager.d.ts +3 -10
  10. package/dist/controller/noteEditorManager.js +33 -206
  11. package/dist/index.d.ts +1 -2
  12. package/dist/index.js +1 -2
  13. package/dist/managers/DocumentLoaderManager.d.ts +0 -4
  14. package/dist/managers/DocumentLoaderManager.js +4 -12
  15. package/dist/prosemirror/numberingAttr.d.ts +1 -2
  16. package/dist/prosemirror/numberingAttr.js +1 -2
  17. package/dist/prosemirror/outlineLevelAttr.d.ts +1 -2
  18. package/dist/prosemirror/outlineLevelAttr.js +1 -2
  19. package/dist/server.d.ts +1 -4
  20. package/dist/server.js +1 -4
  21. package/package.json +1 -3
  22. package/dist/controller/collaborationModules.d.ts +0 -3
  23. package/dist/controller/collaborationModules.js +0 -14
  24. package/dist/docx/server/materializeYjsDocx.d.ts +0 -30
  25. package/dist/docx/server/materializeYjsDocx.js +0 -96
  26. package/dist/docx/server/migrateYjsAttrSchema.d.ts +0 -53
  27. package/dist/docx/server/migrateYjsAttrSchema.js +0 -111
  28. package/dist/prosemirror/plugins/derivedFields.d.ts +0 -8
  29. package/dist/prosemirror/plugins/derivedFields.js +0 -52
  30. package/dist/prosemirror/yjsDocumentMetadata.d.ts +0 -89
  31. package/dist/prosemirror/yjsDocumentMetadata.js +0 -697
package/README.md CHANGED
@@ -23,12 +23,12 @@ Part of [stella](https://github.com/stella/stella), an open-source legal workspa
23
23
  bun add @stll/folio-core \
24
24
  prosemirror-commands@^1.7.1 prosemirror-dropcursor@^1.8.2 prosemirror-gapcursor@^1.4.1 prosemirror-history@^1.5.0 \
25
25
  prosemirror-inputrules@^1.5.0 prosemirror-keymap@^1.2.3 prosemirror-model@^1.25.9 prosemirror-state@^1.4.4 \
26
- prosemirror-tables@^1.8.5 prosemirror-transform@^1.12.0 prosemirror-view@^1.42.6 y-prosemirror@^1.3.7 \
26
+ prosemirror-tables@^1.8.5 prosemirror-transform@^1.12.0 prosemirror-view@^1.42.6 \
27
27
  y-protocols@^1.0.6 yjs@^13.6.31
28
28
  ```
29
29
 
30
30
  ProseMirror and Yjs packages are required peers, including the collaboration
31
- packages `y-prosemirror` and `y-protocols`. Install one compatible copy of each in the host
31
+ package `y-protocols`. Install one compatible copy of each in the host
32
32
  application so schemas, plugins, editor states, and collaborative documents share
33
33
  the same runtime. The command above includes the complete editor peer closure.
34
34
 
@@ -31,7 +31,6 @@ import { setAISuggestionsMeta, setFocusedSuggestionMeta } from "../prosemirror/p
31
31
  import { DirectiveKind, DirectiveRange, getTemplateDirectives, scanDirectives } from "../prosemirror/plugins/templateDirectives.js";
32
32
  import { TemplatePreviewHiddenRange, TemplatePreviewSpan, TemplatePreviewValue, TemplatePreviewValues, setTemplatePreviewValues } from "../prosemirror/plugins/templatePreviewValues.js";
33
33
  import { TemplateSlashMenuKeyAction, TemplateSlashMenuState, clearTemplateSlashMenu, consumeTemplateSlashQuery, getTemplateSlashMenu, resetTemplateSlashQuery, templateSlashMenuKey } from "../prosemirror/plugins/templateSlashMenu.js";
34
- import { FOLIO_YJS_ATTR_SCHEMA_VERSION, FolioYjsAttrSchemaVersion, FolioYjsAttrSchemaVersionError } from "../prosemirror/yjsDocumentMetadata.js";
35
34
  import { DocumentStyleCatalog, DocumentStyleCatalogEntry, ExtractDocumentStyleSetOptions, extractDocumentStyleSet, extractDocumentStyleSetFromDocx, inspectDocumentStyles, inspectDocumentStylesFromDocx } from "../style-sets/extract.js";
36
35
  import { STELLA_STYLE_SET_NAME, createStellaStyleDocumentPreset, createStellaStyleSet } from "../style-sets/stellaStyle.js";
37
36
  import { DOCUMENT_PRESET_VERSION, DOCUMENT_STYLE_SET_VERSION, DocumentPreset, DocumentStyleSet } from "../style-sets/types.js";
@@ -46,4 +45,4 @@ import { mergeDocumentContent } from "../utils/mergeDocumentContent.js";
46
45
  import { DEFAULT_OUTLINE_DEPTH, OutlineDepth, filterHeadingsByDepth } from "../utils/outlineDepth.js";
47
46
  type Document = document_d_exports.Document;
48
47
  type DocxConformanceClass = document_d_exports.DocxConformanceClass;
49
- export { type AIBarStatus, type AIChatMode, type AICitation, type AICitationRange, type AICitationSource, type AIGenerateInput, type AISuggestion, type AISuggestionApplyMode, type AISuggestionPreset, type AISuggestionSeverity, type AISuggestionStatus, type ApplyFolioDocumentOperationsOptions, type ApplyResult, type BlockRect, COMPARE_REVISION_FORMATS, COMPARE_UNSUPPORTED_REASONS, COMPARE_VERIFICATION_CAUSES, COMPARE_VERIFICATION_INVARIANTS, type CompareChange, type CompareChangeLocation, type CompareCompatibility, type CompareContentOptions, CompareDocxApplyError, type CompareDocxError, CompareDocxFinalParagraphMarkError, CompareDocxOperationLimitError, type CompareDocxOptions, CompareDocxParseError, CompareDocxRoundTripError, CompareDocxSerializeError, type CompareFolioRequirement, type CompareResult, type CompareRevisionFormat, type CompareUnsupportedPart, type CompareUnsupportedReason, type CompareVerification, type CompareVerificationCause, type CompareVerificationFailure, type CompareVerificationInvariant, type CreateEmptyDocumentOptions, DEFAULT_AI_SUGGESTION_PRESETS, DEFAULT_OUTLINE_DEPTH, DOCUMENT_PRESET_VERSION, DOCUMENT_STYLE_SET_VERSION, DOCX_CONFORMANCE_CLASSES, DRAWING_SAFETY_CLASSES, type DeriveBlockIdInput, type DirectiveKind, type DirectiveRange, type Document, type DocumentPreset, type DocumentPropertiesOptions, type DocumentStyleCatalog, type DocumentStyleCatalogEntry, type DocumentStyleSet, type DocxCompatibility, type DocxCompatibilityContext, type DocxCompatibilityIssue, type DocxCompatibilityLocation, type DocxCompatibilityPart, type DocxConformanceClass, type DocxDrawingClassification, type DrawingSafetyClass, type EditorReadOnlyReason, type EmbeddedFont, type EmbeddedFontParts, type ExtractDocumentStyleSetOptions, FOLIO_CONTENT_COMPARISON_LIMITS, FOLIO_DOCUMENT_OPERATION_BATCH_MODES, FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FOLIO_DOCUMENT_OPERATION_MODES, FOLIO_DOCUMENT_OPERATION_MODES_BY_TYPE, FOLIO_DOCUMENT_OPERATION_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_STORIES, FOLIO_DOCUMENT_OPERATION_TYPES, FOLIO_HIGHLIGHT_COLOR_VALUES, FOLIO_LINE_SPACING_RULE_VALUES, FOLIO_PARAGRAPH_ALIGNMENT_VALUES, FOLIO_YJS_ATTR_SCHEMA_VERSION, type FinalParagraphMarkRevision, type FolioAIBlock, type FolioAIBlockAnchor, type FolioAIBlockKind, type FolioAIBlockPreviewRun, type FolioAIBlockStructuralBoundary, type FolioAIBlockTableLocation, type FolioAIComment, type FolioAIDiagnosticBlock, type FolioAIEditAppliedOperation, type FolioAIEditApplyMode, type FolioAIEditApplyOutcome, type FolioAIEditApplyResult, type FolioAIEditNormalization, type FolioAIEditNormalizationCode, type FolioAIEditOperation, type FolioAIEditParagraphIdentity, type FolioAIEditPrecondition, type FolioAIEditReviewMeta, type FolioAIEditSeverity, type FolioAIEditSkipReason, type FolioAIEditSkippedOperation, type FolioAIEditSnapshot, type FolioAIInlineBooleanProperty, type FolioAIInlineFormatting, type FolioAIInlineFormattingPatch, type FolioAIParagraphBlock, type FolioAIParagraphSpacing, type FolioAISignatureParty, type FolioAnonymizationMatch, type FolioAnonymizationTerm, type FolioAutocompleteApi, type FolioAutocompleteState, type FolioBlockId, type FolioContentBlock, type FolioContentBlockProperty, type FolioContentComparison, type FolioContentComparisonError, type FolioContentComparisonEvent, type FolioContentComparisonLimit, FolioContentComparisonLimitError, type FolioContentContainerPathEntry, type FolioContentFormatRange, type FolioContentFormattingChange, type FolioContentIdStability, type FolioContentInlineBooleanProperty, type FolioContentInlineComparisonResult, type FolioContentInlineFormatting, type FolioContentInlineFormattingPatch, FolioContentInlinePresentationProjectionError, type FolioContentLineSpacingRule, type FolioContentParagraphAlignment, type FolioContentParagraphFormattingPatch, type FolioContentParagraphKind, type FolioContentParagraphSpacing, type FolioContentRun, type FolioContentSnapshot, type FolioContentStatedNumbering, type FolioContentStructuralChange, type FolioContentTableLocation, type FolioContentTextSegment, type FolioDerivedFields, type FolioDocumentOperation, type FolioDocumentOperationAffectedTarget, type FolioDocumentOperationBatch, type FolioDocumentOperationBatchInput, type FolioDocumentOperationCapabilities, type FolioDocumentOperationIssue, type FolioDocumentOperationMode, type FolioDocumentOperationPrecondition, type FolioDocumentOperationReceipt, type FolioDocumentOperationRecovery, type FolioDocumentOperationResult, type FolioDocumentOperationResultBase, type FolioDocumentOperationStatus, type FolioDocumentOperationStory, type FolioDocumentOperationType, type FolioDocumentOperationUndoFailureReason, type FolioDocumentOperationUndoHandle, type FolioDocumentOperationUndoResult, type FolioDocxCompatibilityHost, type FolioDocxCompatibilityProfile, type FolioFieldInsertion, type FolioRevisionStamp, type FolioUndefinedReferencePolicy, type FolioWordDiffOptions, type FolioYjsAttrSchemaVersion, FolioYjsAttrSchemaVersionError, type ImageMeta, type ImageRef, type InspectDocxCompatibilityOptions, InvalidCompareDocxOptionsError, InvalidFolioContentComparisonError, InvalidFolioDocumentOperationBatchError, MAX_COMPARE_OPERATIONS, type MarkdownOptions, type MarkdownResult, OP_STORIES, type OpStory, type OutlineDepth, type PositionalText, type ResolvedAnchor, type ReviewDisplayMode, STELLA_STYLE_SET_NAME, type TemplatePreviewHiddenRange, type TemplatePreviewSpan, type TemplatePreviewValue, type TemplatePreviewValues, type TemplateSlashMenuKeyAction, type TemplateSlashMenuState, type TextPosition, UnsupportedFolioDocumentOperationVersionError, WORD_DIFF_GRANULARITIES, type WordDiffGranularity, type WordDiffNormalization, type WordDiffOptions, type WordDiffSegment, applyFolioAIEditOperations, applyFolioDocumentOperations, applySuggestions, assertSupportedFolioDocumentOperationVersion, buildEmbeddedFontFamilyMap, buildPositionalText, clearTemplateSlashMenu, compareContent, compareDocx, consumeTemplateSlashQuery, createAICitationDecorationsPlugin, createDocx, createEmptyDocument, createFolioAIEditSnapshot, createStellaStyleDocumentPreset, createStellaStyleSet, currentFolioBlockId, deriveBlockId, diffWordSegments, extractDocumentStyleSet, extractDocumentStyleSetFromDocx, extractEmbeddedFonts, filterHeadingsByDepth, fromMarkdown, getEmbeddedFontFaces, getFolioCaretViewportRect, getFolioDocumentOperationCapabilities, getFolioDocumentOperationIssues, getFolioDocumentOperationReceipts, getFolioParaIdFromBlockId, getFolioSelectionViewportRect, getGoogleFontsEnabled, getTemplateDirectives, getTemplateSlashMenu, hashFolioAIBlockText, inspectDocumentStyles, inspectDocumentStylesFromDocx, inspectDocxCompatibility, isFolioAIContentBlock, isFolioBlockId, isFolioDocumentOperationModeSupported, isSequentialFolioBlockId, isSuggestionStale, isSupportedFolioDocumentOperationVersion, mergeDocumentContent, normalizeFolioAIBlockText, parseFolioDocumentOperationBatch, resetTemplateSlashQuery, resolveSuggestionAnchor, scanDirectives, scopeEmbeddedFontFamily, scrollFolioPositionIntoView, setAICitationsMeta, setAISuggestionsMeta, setActiveCitationMeta, setFocusedSuggestionMeta, setGoogleFontsEnabled, setTemplatePreviewValues, templateSlashMenuKey, toMarkdown, toMarkdownResult };
48
+ export { type AIBarStatus, type AIChatMode, type AICitation, type AICitationRange, type AICitationSource, type AIGenerateInput, type AISuggestion, type AISuggestionApplyMode, type AISuggestionPreset, type AISuggestionSeverity, type AISuggestionStatus, type ApplyFolioDocumentOperationsOptions, type ApplyResult, type BlockRect, COMPARE_REVISION_FORMATS, COMPARE_UNSUPPORTED_REASONS, COMPARE_VERIFICATION_CAUSES, COMPARE_VERIFICATION_INVARIANTS, type CompareChange, type CompareChangeLocation, type CompareCompatibility, type CompareContentOptions, CompareDocxApplyError, type CompareDocxError, CompareDocxFinalParagraphMarkError, CompareDocxOperationLimitError, type CompareDocxOptions, CompareDocxParseError, CompareDocxRoundTripError, CompareDocxSerializeError, type CompareFolioRequirement, type CompareResult, type CompareRevisionFormat, type CompareUnsupportedPart, type CompareUnsupportedReason, type CompareVerification, type CompareVerificationCause, type CompareVerificationFailure, type CompareVerificationInvariant, type CreateEmptyDocumentOptions, DEFAULT_AI_SUGGESTION_PRESETS, DEFAULT_OUTLINE_DEPTH, DOCUMENT_PRESET_VERSION, DOCUMENT_STYLE_SET_VERSION, DOCX_CONFORMANCE_CLASSES, DRAWING_SAFETY_CLASSES, type DeriveBlockIdInput, type DirectiveKind, type DirectiveRange, type Document, type DocumentPreset, type DocumentPropertiesOptions, type DocumentStyleCatalog, type DocumentStyleCatalogEntry, type DocumentStyleSet, type DocxCompatibility, type DocxCompatibilityContext, type DocxCompatibilityIssue, type DocxCompatibilityLocation, type DocxCompatibilityPart, type DocxConformanceClass, type DocxDrawingClassification, type DrawingSafetyClass, type EditorReadOnlyReason, type EmbeddedFont, type EmbeddedFontParts, type ExtractDocumentStyleSetOptions, FOLIO_CONTENT_COMPARISON_LIMITS, FOLIO_DOCUMENT_OPERATION_BATCH_MODES, FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FOLIO_DOCUMENT_OPERATION_MODES, FOLIO_DOCUMENT_OPERATION_MODES_BY_TYPE, FOLIO_DOCUMENT_OPERATION_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_STORIES, FOLIO_DOCUMENT_OPERATION_TYPES, FOLIO_HIGHLIGHT_COLOR_VALUES, FOLIO_LINE_SPACING_RULE_VALUES, FOLIO_PARAGRAPH_ALIGNMENT_VALUES, type FinalParagraphMarkRevision, type FolioAIBlock, type FolioAIBlockAnchor, type FolioAIBlockKind, type FolioAIBlockPreviewRun, type FolioAIBlockStructuralBoundary, type FolioAIBlockTableLocation, type FolioAIComment, type FolioAIDiagnosticBlock, type FolioAIEditAppliedOperation, type FolioAIEditApplyMode, type FolioAIEditApplyOutcome, type FolioAIEditApplyResult, type FolioAIEditNormalization, type FolioAIEditNormalizationCode, type FolioAIEditOperation, type FolioAIEditParagraphIdentity, type FolioAIEditPrecondition, type FolioAIEditReviewMeta, type FolioAIEditSeverity, type FolioAIEditSkipReason, type FolioAIEditSkippedOperation, type FolioAIEditSnapshot, type FolioAIInlineBooleanProperty, type FolioAIInlineFormatting, type FolioAIInlineFormattingPatch, type FolioAIParagraphBlock, type FolioAIParagraphSpacing, type FolioAISignatureParty, type FolioAnonymizationMatch, type FolioAnonymizationTerm, type FolioAutocompleteApi, type FolioAutocompleteState, type FolioBlockId, type FolioContentBlock, type FolioContentBlockProperty, type FolioContentComparison, type FolioContentComparisonError, type FolioContentComparisonEvent, type FolioContentComparisonLimit, FolioContentComparisonLimitError, type FolioContentContainerPathEntry, type FolioContentFormatRange, type FolioContentFormattingChange, type FolioContentIdStability, type FolioContentInlineBooleanProperty, type FolioContentInlineComparisonResult, type FolioContentInlineFormatting, type FolioContentInlineFormattingPatch, FolioContentInlinePresentationProjectionError, type FolioContentLineSpacingRule, type FolioContentParagraphAlignment, type FolioContentParagraphFormattingPatch, type FolioContentParagraphKind, type FolioContentParagraphSpacing, type FolioContentRun, type FolioContentSnapshot, type FolioContentStatedNumbering, type FolioContentStructuralChange, type FolioContentTableLocation, type FolioContentTextSegment, type FolioDerivedFields, type FolioDocumentOperation, type FolioDocumentOperationAffectedTarget, type FolioDocumentOperationBatch, type FolioDocumentOperationBatchInput, type FolioDocumentOperationCapabilities, type FolioDocumentOperationIssue, type FolioDocumentOperationMode, type FolioDocumentOperationPrecondition, type FolioDocumentOperationReceipt, type FolioDocumentOperationRecovery, type FolioDocumentOperationResult, type FolioDocumentOperationResultBase, type FolioDocumentOperationStatus, type FolioDocumentOperationStory, type FolioDocumentOperationType, type FolioDocumentOperationUndoFailureReason, type FolioDocumentOperationUndoHandle, type FolioDocumentOperationUndoResult, type FolioDocxCompatibilityHost, type FolioDocxCompatibilityProfile, type FolioFieldInsertion, type FolioRevisionStamp, type FolioUndefinedReferencePolicy, type FolioWordDiffOptions, type ImageMeta, type ImageRef, type InspectDocxCompatibilityOptions, InvalidCompareDocxOptionsError, InvalidFolioContentComparisonError, InvalidFolioDocumentOperationBatchError, MAX_COMPARE_OPERATIONS, type MarkdownOptions, type MarkdownResult, OP_STORIES, type OpStory, type OutlineDepth, type PositionalText, type ResolvedAnchor, type ReviewDisplayMode, STELLA_STYLE_SET_NAME, type TemplatePreviewHiddenRange, type TemplatePreviewSpan, type TemplatePreviewValue, type TemplatePreviewValues, type TemplateSlashMenuKeyAction, type TemplateSlashMenuState, type TextPosition, UnsupportedFolioDocumentOperationVersionError, WORD_DIFF_GRANULARITIES, type WordDiffGranularity, type WordDiffNormalization, type WordDiffOptions, type WordDiffSegment, applyFolioAIEditOperations, applyFolioDocumentOperations, applySuggestions, assertSupportedFolioDocumentOperationVersion, buildEmbeddedFontFamilyMap, buildPositionalText, clearTemplateSlashMenu, compareContent, compareDocx, consumeTemplateSlashQuery, createAICitationDecorationsPlugin, createDocx, createEmptyDocument, createFolioAIEditSnapshot, createStellaStyleDocumentPreset, createStellaStyleSet, currentFolioBlockId, deriveBlockId, diffWordSegments, extractDocumentStyleSet, extractDocumentStyleSetFromDocx, extractEmbeddedFonts, filterHeadingsByDepth, fromMarkdown, getEmbeddedFontFaces, getFolioCaretViewportRect, getFolioDocumentOperationCapabilities, getFolioDocumentOperationIssues, getFolioDocumentOperationReceipts, getFolioParaIdFromBlockId, getFolioSelectionViewportRect, getGoogleFontsEnabled, getTemplateDirectives, getTemplateSlashMenu, hashFolioAIBlockText, inspectDocumentStyles, inspectDocumentStylesFromDocx, inspectDocxCompatibility, isFolioAIContentBlock, isFolioBlockId, isFolioDocumentOperationModeSupported, isSequentialFolioBlockId, isSuggestionStale, isSupportedFolioDocumentOperationVersion, mergeDocumentContent, normalizeFolioAIBlockText, parseFolioDocumentOperationBatch, resetTemplateSlashQuery, resolveSuggestionAnchor, scanDirectives, scopeEmbeddedFontFamily, scrollFolioPositionIntoView, setAICitationsMeta, setAISuggestionsMeta, setActiveCitationMeta, setFocusedSuggestionMeta, setGoogleFontsEnabled, setTemplatePreviewValues, templateSlashMenuKey, toMarkdown, toMarkdownResult };
@@ -24,7 +24,6 @@ import { setAISuggestionsMeta, setFocusedSuggestionMeta } from "../prosemirror/p
24
24
  import { getTemplateDirectives, scanDirectives } from "../prosemirror/plugins/templateDirectives.js";
25
25
  import { setTemplatePreviewValues } from "../prosemirror/plugins/templatePreviewValues.js";
26
26
  import { clearTemplateSlashMenu, consumeTemplateSlashQuery, getTemplateSlashMenu, resetTemplateSlashQuery, templateSlashMenuKey } from "../prosemirror/plugins/templateSlashMenu.js";
27
- import { FOLIO_YJS_ATTR_SCHEMA_VERSION, FolioYjsAttrSchemaVersionError } from "../prosemirror/yjsDocumentMetadata.js";
28
27
  import { extractDocumentStyleSet, extractDocumentStyleSetFromDocx, inspectDocumentStyles, inspectDocumentStylesFromDocx } from "../style-sets/extract.js";
29
28
  import { STELLA_STYLE_SET_NAME, createStellaStyleDocumentPreset, createStellaStyleSet } from "../style-sets/stellaStyle.js";
30
29
  import { DOCUMENT_PRESET_VERSION, DOCUMENT_STYLE_SET_VERSION } from "../style-sets/types.js";
@@ -33,4 +32,4 @@ import { createEmptyDocument } from "../utils/createDocument.js";
33
32
  import { getGoogleFontsEnabled, setGoogleFontsEnabled } from "../utils/fontResolver.js";
34
33
  import { mergeDocumentContent } from "../utils/mergeDocumentContent.js";
35
34
  import { DEFAULT_OUTLINE_DEPTH, filterHeadingsByDepth } from "../utils/outlineDepth.js";
36
- export { COMPARE_REVISION_FORMATS, COMPARE_UNSUPPORTED_REASONS, COMPARE_VERIFICATION_CAUSES, COMPARE_VERIFICATION_INVARIANTS, CompareDocxApplyError, CompareDocxFinalParagraphMarkError, CompareDocxOperationLimitError, CompareDocxParseError, CompareDocxRoundTripError, CompareDocxSerializeError, DEFAULT_AI_SUGGESTION_PRESETS, DEFAULT_OUTLINE_DEPTH, DOCUMENT_PRESET_VERSION, DOCUMENT_STYLE_SET_VERSION, DOCX_CONFORMANCE_CLASSES, DRAWING_SAFETY_CLASSES, FOLIO_CONTENT_COMPARISON_LIMITS, FOLIO_DOCUMENT_OPERATION_BATCH_MODES, FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FOLIO_DOCUMENT_OPERATION_MODES, FOLIO_DOCUMENT_OPERATION_MODES_BY_TYPE, FOLIO_DOCUMENT_OPERATION_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_STORIES, FOLIO_DOCUMENT_OPERATION_TYPES, FOLIO_HIGHLIGHT_COLOR_VALUES, FOLIO_LINE_SPACING_RULE_VALUES, FOLIO_PARAGRAPH_ALIGNMENT_VALUES, FOLIO_YJS_ATTR_SCHEMA_VERSION, FolioContentComparisonLimitError, FolioContentInlinePresentationProjectionError, FolioYjsAttrSchemaVersionError, InvalidCompareDocxOptionsError, InvalidFolioContentComparisonError, InvalidFolioDocumentOperationBatchError, MAX_COMPARE_OPERATIONS, OP_STORIES, STELLA_STYLE_SET_NAME, UnsupportedFolioDocumentOperationVersionError, WORD_DIFF_GRANULARITIES, applyFolioAIEditOperations, applyFolioDocumentOperations, applySuggestions, assertSupportedFolioDocumentOperationVersion, buildEmbeddedFontFamilyMap, buildPositionalText, clearTemplateSlashMenu, compareContent, compareDocx, consumeTemplateSlashQuery, createAICitationDecorationsPlugin, createDocx, createEmptyDocument, createFolioAIEditSnapshot, createStellaStyleDocumentPreset, createStellaStyleSet, currentFolioBlockId, deriveBlockId, diffWordSegments, extractDocumentStyleSet, extractDocumentStyleSetFromDocx, extractEmbeddedFonts, filterHeadingsByDepth, fromMarkdown, getEmbeddedFontFaces, getFolioCaretViewportRect, getFolioDocumentOperationCapabilities, getFolioDocumentOperationIssues, getFolioDocumentOperationReceipts, getFolioParaIdFromBlockId, getFolioSelectionViewportRect, getGoogleFontsEnabled, getTemplateDirectives, getTemplateSlashMenu, hashFolioAIBlockText, inspectDocumentStyles, inspectDocumentStylesFromDocx, inspectDocxCompatibility, isFolioAIContentBlock, isFolioBlockId, isFolioDocumentOperationModeSupported, isSequentialFolioBlockId, isSuggestionStale, isSupportedFolioDocumentOperationVersion, mergeDocumentContent, normalizeFolioAIBlockText, parseFolioDocumentOperationBatch, resetTemplateSlashQuery, resolveSuggestionAnchor, scanDirectives, scopeEmbeddedFontFamily, scrollFolioPositionIntoView, setAICitationsMeta, setAISuggestionsMeta, setActiveCitationMeta, setFocusedSuggestionMeta, setGoogleFontsEnabled, setTemplatePreviewValues, templateSlashMenuKey, toMarkdown, toMarkdownResult };
35
+ export { COMPARE_REVISION_FORMATS, COMPARE_UNSUPPORTED_REASONS, COMPARE_VERIFICATION_CAUSES, COMPARE_VERIFICATION_INVARIANTS, CompareDocxApplyError, CompareDocxFinalParagraphMarkError, CompareDocxOperationLimitError, CompareDocxParseError, CompareDocxRoundTripError, CompareDocxSerializeError, DEFAULT_AI_SUGGESTION_PRESETS, DEFAULT_OUTLINE_DEPTH, DOCUMENT_PRESET_VERSION, DOCUMENT_STYLE_SET_VERSION, DOCX_CONFORMANCE_CLASSES, DRAWING_SAFETY_CLASSES, FOLIO_CONTENT_COMPARISON_LIMITS, FOLIO_DOCUMENT_OPERATION_BATCH_MODES, FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FOLIO_DOCUMENT_OPERATION_MODES, FOLIO_DOCUMENT_OPERATION_MODES_BY_TYPE, FOLIO_DOCUMENT_OPERATION_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_STORIES, FOLIO_DOCUMENT_OPERATION_TYPES, FOLIO_HIGHLIGHT_COLOR_VALUES, FOLIO_LINE_SPACING_RULE_VALUES, FOLIO_PARAGRAPH_ALIGNMENT_VALUES, FolioContentComparisonLimitError, FolioContentInlinePresentationProjectionError, InvalidCompareDocxOptionsError, InvalidFolioContentComparisonError, InvalidFolioDocumentOperationBatchError, MAX_COMPARE_OPERATIONS, OP_STORIES, STELLA_STYLE_SET_NAME, UnsupportedFolioDocumentOperationVersionError, WORD_DIFF_GRANULARITIES, applyFolioAIEditOperations, applyFolioDocumentOperations, applySuggestions, assertSupportedFolioDocumentOperationVersion, buildEmbeddedFontFamilyMap, buildPositionalText, clearTemplateSlashMenu, compareContent, compareDocx, consumeTemplateSlashQuery, createAICitationDecorationsPlugin, createDocx, createEmptyDocument, createFolioAIEditSnapshot, createStellaStyleDocumentPreset, createStellaStyleSet, currentFolioBlockId, deriveBlockId, diffWordSegments, extractDocumentStyleSet, extractDocumentStyleSetFromDocx, extractEmbeddedFonts, filterHeadingsByDepth, fromMarkdown, getEmbeddedFontFaces, getFolioCaretViewportRect, getFolioDocumentOperationCapabilities, getFolioDocumentOperationIssues, getFolioDocumentOperationReceipts, getFolioParaIdFromBlockId, getFolioSelectionViewportRect, getGoogleFontsEnabled, getTemplateDirectives, getTemplateSlashMenu, hashFolioAIBlockText, inspectDocumentStyles, inspectDocumentStylesFromDocx, inspectDocxCompatibility, isFolioAIContentBlock, isFolioBlockId, isFolioDocumentOperationModeSupported, isSequentialFolioBlockId, isSuggestionStale, isSupportedFolioDocumentOperationVersion, mergeDocumentContent, normalizeFolioAIBlockText, parseFolioDocumentOperationBatch, resetTemplateSlashQuery, resolveSuggestionAnchor, scanDirectives, scopeEmbeddedFontFamily, scrollFolioPositionIntoView, setAICitationsMeta, setAISuggestionsMeta, setActiveCitationMeta, setFocusedSuggestionMeta, setGoogleFontsEnabled, setTemplatePreviewValues, templateSlashMenuKey, toMarkdown, toMarkdownResult };
@@ -2,8 +2,8 @@ import { document_d_exports } from "../types/document.js";
2
2
  import { CanonicalRoomTransport } from "./canonicalRoomTransport.js";
3
3
  import { Result, TaggedErrorClass } from "better-result";
4
4
  import { IdLeaseState, SequencedBatch } from "@stll/docx-core/ops";
5
- import * as Y from "yjs";
6
5
  import { Awareness } from "y-protocols/awareness";
6
+ import * as Y from "yjs";
7
7
  /** The Yjs client id the authority writes the journal under, unless the host picks another. */
8
8
  export declare const CANONICAL_YJS_AUTHORITY = 1179601993;
9
9
  /**
@@ -1,4 +1,12 @@
1
- import { CanonicalRefusalGround, EditorSession } from "../types/canonicalCapabilities.js";
1
+ /**
2
+ * Framework-neutral lifecycle owner for persistent header/footer EditorViews.
3
+ *
4
+ * Each distinct relationship id owns one off-screen ProseMirror view. Painted
5
+ * header/footer instances that share that relationship therefore share live
6
+ * editor state, and adapters only decide when to synchronize or destroy the
7
+ * manager.
8
+ */
9
+ import { CanonicalRefusalGround } from "../types/canonicalCapabilities.js";
2
10
  import { document_d_exports } from "../types/document.js";
3
11
  import { DeepReadonly, ReadonlyDocument } from "../types/documentModel.js";
4
12
  import { HiddenEditorApi } from "./hiddenEditorApi.js";
@@ -17,7 +25,6 @@ export type HeaderFooterEditorTransaction = {
17
25
  };
18
26
  export type HeaderFooterEditorManagerDeps = {
19
27
  createView?: ((mountNode: HTMLElement, props: DirectEditorProps) => EditorView) | undefined;
20
- getDocument: () => ReadonlyDocument | null;
21
28
  getReadOnly?: (() => boolean) | undefined;
22
29
  getCanonicalApi?: (() => HiddenEditorApi | null) | undefined;
23
30
  /**
@@ -25,11 +32,9 @@ export type HeaderFooterEditorManagerDeps = {
25
32
  * `HiddenEditorManager.readCanonicalDocument`); null outside a session.
26
33
  */
27
34
  readCanonicalDocument: () => ReadonlyDocument | null;
28
- getExperimentalSession?: (() => EditorSession | undefined) | undefined;
29
35
  onSessionRefusal?: ((reason: string, ground: CanonicalRefusalGround, error?: Error) => void) | undefined;
30
36
  getHost: () => HTMLElement | null;
31
37
  getStyles: () => DeepReadonly<document_d_exports.StyleDefinitions> | null | undefined;
32
- getTheme: () => DeepReadonly<document_d_exports.Theme> | null | undefined;
33
38
  onTransaction?: ((transaction: HeaderFooterEditorTransaction) => void) | undefined;
34
39
  };
35
40
  export type HeaderFooterEditorManager = {
@@ -37,11 +42,10 @@ export type HeaderFooterEditorManager = {
37
42
  getView: (rId: string) => EditorView | null;
38
43
  listSlots: () => HeaderFooterPartKey[];
39
44
  /**
40
- * The model with the edited parts written back. It shares what no edit
41
- * touched with `model` and with the mounted editors, so it is read-only: a
45
+ * The session's document with every story's edits. It is read-only: a
42
46
  * writer copies it first (`cloneDocumentWithParagraphPropertySources`).
43
47
  */
44
- snapshotDocument: (model: ReadonlyDocument) => ReadonlyDocument;
48
+ snapshotDocument: () => ReadonlyDocument;
45
49
  sync: () => void;
46
50
  };
47
51
  export declare const enumerateHeaderFooterParts: ({ headers, footers }: {
@@ -1,54 +1,24 @@
1
1
  import { CanonicalSessionError } from "../canonical/canonicalSession.js";
2
- import { clearHeaderFooterVerbatimXml } from "../docx/headerFooterVerbatim.js";
3
- import { cloneParagraphWithPropertySource } from "../docx/paragraphPropertySource.js";
4
- import { proseDocToBlocks } from "../prosemirror/conversion/fromProseDoc.js";
5
- import { storyConversionOptions } from "../prosemirror/conversion/storyConversionOptions.js";
6
- import { headerFooterToProseDoc } from "../prosemirror/conversion/toProseDoc.js";
7
- import { ExtensionManager } from "../prosemirror/extensions/ExtensionManager.js";
8
- import { createStarterKit } from "../prosemirror/extensions/StarterKit.js";
9
- import { ensureBaseDirectionInState } from "../prosemirror/extensions/features/AutoBidiDetectionExtension.js";
10
- import { ensureParaIdsInState } from "../prosemirror/extensions/features/ParaIdAllocatorExtension.js";
11
2
  import { createNativeNavigationPlugin, createNativeSelectionRefreshPlugin } from "../prosemirror/nativeSelection.js";
12
3
  import { noteReferenceTransactionIssue } from "../prosemirror/noteReferenceOccurrences.js";
13
4
  import { createDocumentNumberingPlugin } from "../prosemirror/plugins/documentNumbering.js";
14
- import { createDocumentStyleContextPlugin, createDocumentStylesPlugin } from "../prosemirror/plugins/documentStyles.js";
15
- import { schema } from "../prosemirror/schema/index.js";
16
- import { storyListNumbering } from "../prosemirror/storyListNumbering.js";
17
- import { CANONICAL_GAP, usesCanonicalSession } from "../types/canonicalCapabilities.js";
5
+ import { createDocumentStyleContextPlugin } from "../prosemirror/plugins/documentStyles.js";
6
+ import { CANONICAL_GAP } from "../types/canonicalCapabilities.js";
18
7
  import { readModel } from "../types/documentModel.js";
19
8
  import { createCanonicalStoryEditor, refreshCanonicalStoryView } from "./canonicalStoryEditor.js";
20
9
  import { OP_STORIES } from "@stll/docx-core/ops";
21
10
  import { EditorState } from "prosemirror-state";
22
11
  import { EditorView } from "prosemirror-view";
23
12
  // src/controller/headerFooterEditorManager.ts
13
+ /**
14
+ * Framework-neutral lifecycle owner for persistent header/footer EditorViews.
15
+ *
16
+ * Each distinct relationship id owns one off-screen ProseMirror view. Painted
17
+ * header/footer instances that share that relationship therefore share live
18
+ * editor state, and adapters only decide when to synchronize or destroy the
19
+ * manager.
20
+ */
24
21
  const createEditorView = (mountNode, props) => new EditorView(mountNode, props);
25
- const DETACHED_WATERMARK_HOST = Symbol.for("stll.detachedWatermarkHost");
26
- const headerFooterToProseDocWithDetachedWatermarkHost = (headerFooter, options) => {
27
- const markedContent = headerFooter.content.map((block, blockIndex) => {
28
- if (blockIndex !== headerFooter.watermarkBlockIndex || block.type !== "paragraph") return block;
29
- const marked = cloneParagraphWithPropertySource(block, {});
30
- Reflect.set(marked, DETACHED_WATERMARK_HOST, true);
31
- return marked;
32
- });
33
- return headerFooterToProseDoc(markedContent, options);
34
- };
35
- const buildInitialState = (headerFooter, styles, theme, numbering, manager) => {
36
- const proseDocOptions = storyConversionOptions({
37
- styles,
38
- theme,
39
- numbering
40
- });
41
- const document = headerFooter.watermarkBlockIndex === void 0 ? headerFooterToProseDoc(headerFooter.content, proseDocOptions) : headerFooterToProseDocWithDetachedWatermarkHost(headerFooter, proseDocOptions);
42
- return ensureBaseDirectionInState(ensureParaIdsInState(EditorState.create({
43
- doc: document,
44
- schema,
45
- plugins: [
46
- createDocumentNumberingPlugin(numbering),
47
- ...manager.getPlugins(),
48
- createDocumentStylesPlugin(styles)
49
- ]
50
- })));
51
- };
52
22
  const enumerateHeaderFooterParts = ({ headers, footers }) => {
53
23
  const parts = [];
54
24
  if (headers) for (const rId of headers.keys()) parts.push({
@@ -77,14 +47,12 @@ const createHeaderFooterEditorManager = (deps) => {
77
47
  const mounted = /* @__PURE__ */ new Map();
78
48
  const destroyMounted = (part) => {
79
49
  part.view.destroy();
80
- part.manager.destroy();
81
50
  part.mountNode.remove();
82
51
  };
83
52
  const destroy = () => {
84
53
  for (const part of mounted.values()) destroyMounted(part);
85
54
  mounted.clear();
86
55
  };
87
- const getOwnedDocument = () => usesCanonicalSession(deps.getExperimentalSession?.(), CANONICAL_GAP.authorityRouting) ? deps.readCanonicalDocument() : deps.getDocument();
88
56
  const sync = () => {
89
57
  const host = deps.getHost();
90
58
  if (!host) return;
@@ -97,11 +65,10 @@ const createHeaderFooterEditorManager = (deps) => {
97
65
  part.view.setProps({ editable: () => !getReadOnly() });
98
66
  }
99
67
  }
100
- if (usesCanonicalSession(deps.getExperimentalSession?.(), CANONICAL_GAP.authorityRouting) && !deps.getCanonicalApi?.()?.getCanonicalStoryProjection(OP_STORIES.MAIN)) return;
101
- const owned = getOwnedDocument();
68
+ if (!deps.getCanonicalApi?.()?.getCanonicalStoryProjection(OP_STORIES.MAIN)) return;
69
+ const owned = deps.readCanonicalDocument();
102
70
  const document = owned && readModel(owned);
103
71
  const styles = deps.getStyles();
104
- const theme = deps.getTheme();
105
72
  const numbering = document?.package.numbering;
106
73
  const wanted = new Map(enumerateDocumentHeaderFooterParts(document).map((part) => [part.rId, part]));
107
74
  for (const [rId, part] of mounted) {
@@ -110,47 +77,20 @@ const createHeaderFooterEditorManager = (deps) => {
110
77
  mounted.delete(rId);
111
78
  }
112
79
  for (const part of wanted.values()) {
113
- const headerFooter = resolveHeaderFooter(document, part);
114
- if (!headerFooter) continue;
80
+ if (!resolveHeaderFooter(document, part)) continue;
115
81
  const existing = mounted.get(part.rId);
116
82
  if (existing) {
117
83
  if (existing.mountNode.parentElement !== host) host.append(existing.mountNode);
118
- if (usesCanonicalSession(deps.getExperimentalSession?.(), CANONICAL_GAP.authorityRouting)) {
119
- refreshCanonicalStoryView({
120
- view: existing.view,
121
- story: {
122
- kind: part.kind,
123
- rId: part.rId
124
- },
125
- api: deps.getCanonicalApi?.()
126
- });
127
- existing.appliedHeaderFooter = headerFooter;
128
- existing.appliedContent = headerFooter.content;
129
- existing.appliedStyles = styles;
130
- existing.appliedTheme = theme;
131
- existing.appliedNumbering = numbering;
132
- existing.dirty = false;
133
- continue;
134
- }
135
- const contentIsCurrent = existing.appliedHeaderFooter === headerFooter && existing.appliedContent === headerFooter.content;
136
- const contextIsCurrent = existing.appliedStyles === styles && existing.appliedTheme === theme && existing.appliedNumbering === numbering;
137
- if (contentIsCurrent && contextIsCurrent) continue;
138
- existing.view.updateState(buildInitialState(headerFooter, styles, theme, numbering, existing.manager));
139
- existing.appliedHeaderFooter = headerFooter;
140
- existing.appliedContent = headerFooter.content;
141
- existing.appliedStyles = styles;
142
- existing.appliedTheme = theme;
143
- existing.appliedNumbering = numbering;
144
- existing.dirty = false;
84
+ refreshCanonicalStoryView({
85
+ view: existing.view,
86
+ story: {
87
+ kind: part.kind,
88
+ rId: part.rId
89
+ },
90
+ api: deps.getCanonicalApi?.()
91
+ });
145
92
  continue;
146
93
  }
147
- const manager = new ExtensionManager(createStarterKit());
148
- manager.buildSchema();
149
- manager.initializeRuntime();
150
- const mountNode = host.ownerDocument.createElement("div");
151
- mountNode.dataset["hfRId"] = part.rId;
152
- mountNode.dataset["hfKind"] = part.kind;
153
- host.append(mountNode);
154
94
  const canonical = createCanonicalStoryEditor({
155
95
  story: {
156
96
  kind: part.kind,
@@ -158,7 +98,7 @@ const createHeaderFooterEditorManager = (deps) => {
158
98
  },
159
99
  getView: () => view,
160
100
  getApi: () => deps.getCanonicalApi?.() ?? null,
161
- enabled: () => usesCanonicalSession(deps.getExperimentalSession?.(), CANONICAL_GAP.authorityRouting),
101
+ enabled: () => true,
162
102
  onRefusal: deps.onSessionRefusal,
163
103
  onSelectionChange: () => deps.onTransaction?.({
164
104
  kind: part.kind,
@@ -168,19 +108,19 @@ const createHeaderFooterEditorManager = (deps) => {
168
108
  selectionChanged: true
169
109
  })
170
110
  });
171
- const canonicalProjection = usesCanonicalSession(deps.getExperimentalSession?.(), CANONICAL_GAP.authorityRouting) ? deps.getCanonicalApi?.()?.getCanonicalStoryProjection({
111
+ const canonicalProjection = deps.getCanonicalApi?.()?.getCanonicalStoryProjection({
172
112
  kind: part.kind,
173
113
  rId: part.rId
174
- }) : null;
175
- if (usesCanonicalSession(deps.getExperimentalSession?.(), CANONICAL_GAP.authorityRouting) && !canonicalProjection) {
176
- manager.destroy();
177
- mountNode.remove();
178
- continue;
179
- }
114
+ });
115
+ if (!canonicalProjection) continue;
116
+ const mountNode = host.ownerDocument.createElement("div");
117
+ mountNode.dataset["hfRId"] = part.rId;
118
+ mountNode.dataset["hfKind"] = part.kind;
119
+ host.append(mountNode);
180
120
  const view = (deps.createView ?? createEditorView)(mountNode, {
181
121
  ...canonical.props,
182
122
  editable: () => !(deps.getReadOnly?.() ?? false),
183
- state: canonicalProjection ? EditorState.create({
123
+ state: EditorState.create({
184
124
  doc: canonicalProjection,
185
125
  plugins: [
186
126
  createDocumentNumberingPlugin(numbering),
@@ -188,7 +128,7 @@ const createHeaderFooterEditorManager = (deps) => {
188
128
  createNativeSelectionRefreshPlugin(),
189
129
  createNativeNavigationPlugin()
190
130
  ]
191
- }) : buildInitialState(headerFooter, styles, theme, numbering, manager),
131
+ }),
192
132
  dispatchTransaction(transaction) {
193
133
  if ((deps.getReadOnly?.() ?? false) && transaction.docChanged) return;
194
134
  if (canonical.dispatch(transaction)) return;
@@ -197,8 +137,6 @@ const createHeaderFooterEditorManager = (deps) => {
197
137
  const noteIssue = noteReferenceTransactionIssue(transaction);
198
138
  if (noteIssue) deps.onSessionRefusal?.(noteIssue.message, { gap: CANONICAL_GAP.dispatch }, noteIssue);
199
139
  view.updateState(nextState);
200
- const mountedPart = mounted.get(part.rId);
201
- if (mountedPart && docChanged) mountedPart.dirty = true;
202
140
  deps.onTransaction?.({
203
141
  docChanged,
204
142
  kind: part.kind,
@@ -209,14 +147,7 @@ const createHeaderFooterEditorManager = (deps) => {
209
147
  }
210
148
  });
211
149
  mounted.set(part.rId, {
212
- appliedContent: headerFooter.content,
213
- appliedHeaderFooter: headerFooter,
214
- appliedNumbering: numbering,
215
- appliedStyles: styles,
216
- appliedTheme: theme,
217
- dirty: false,
218
150
  kind: part.kind,
219
- manager,
220
151
  mountNode,
221
152
  rId: part.rId,
222
153
  view
@@ -230,57 +161,14 @@ const createHeaderFooterEditorManager = (deps) => {
230
161
  kind,
231
162
  rId
232
163
  })),
233
- snapshotDocument: (model) => {
234
- if (usesCanonicalSession(deps.getExperimentalSession?.(), CANONICAL_GAP.authorityRouting)) {
235
- const canonical = deps.getCanonicalApi?.()?.getCanonicalDocument();
236
- if (canonical) return canonical;
237
- throw new CanonicalSessionError({
238
- ground: { gap: CANONICAL_GAP.authorityRouting },
239
- reason: "refused",
240
- message: "Canonical story snapshot is unavailable."
241
- });
242
- }
243
- const document = readModel(model);
244
- let headers = document.package.headers;
245
- let footers = document.package.footers;
246
- let headersChanged = false;
247
- let footersChanged = false;
248
- let numbering = document.package.numbering;
249
- for (const { dirty, kind, rId, view } of mounted.values()) {
250
- if (!dirty) continue;
251
- const source = kind === "header" ? headers : footers;
252
- const existing = source?.get(rId);
253
- if (!source || !existing) continue;
254
- const story = storyListNumbering(view.state, numbering);
255
- numbering = story.numbering;
256
- const updated = {
257
- ...existing,
258
- content: proseDocToBlocks(story.doc, existing.content, document.package.styles)
259
- };
260
- clearHeaderFooterVerbatimXml(updated);
261
- if (kind === "header") {
262
- if (!headersChanged) {
263
- headers = new Map(headers);
264
- headersChanged = true;
265
- }
266
- headers?.set(rId, updated);
267
- } else {
268
- if (!footersChanged) {
269
- footers = new Map(footers);
270
- footersChanged = true;
271
- }
272
- footers?.set(rId, updated);
273
- }
274
- }
275
- if (!headersChanged && !footersChanged) return model;
276
- const packageWithSnapshots = { ...document.package };
277
- if (numbering) packageWithSnapshots.numbering = numbering;
278
- if (headersChanged && headers) packageWithSnapshots.headers = headers;
279
- if (footersChanged && footers) packageWithSnapshots.footers = footers;
280
- return {
281
- ...document,
282
- package: packageWithSnapshots
283
- };
164
+ snapshotDocument: () => {
165
+ const canonical = deps.getCanonicalApi?.()?.getCanonicalDocument();
166
+ if (canonical) return canonical;
167
+ throw new CanonicalSessionError({
168
+ ground: { gap: CANONICAL_GAP.authorityRouting },
169
+ reason: "refused",
170
+ message: "Canonical story snapshot is unavailable."
171
+ });
284
172
  },
285
173
  sync
286
174
  };
@@ -4,7 +4,7 @@ import { EditorMode } from "../managers/EditorModeManager.js";
4
4
  import { ExtensionManager } from "../prosemirror/extensions/ExtensionManager.js";
5
5
  import { HistoryShortcutOwner } from "../prosemirror/extensions/core/HistoryExtension.js";
6
6
  import { FolioAnonymizationTerm } from "../types/anonymization.js";
7
- import { CanonicalRefusalGround, EditorSession } from "../types/canonicalCapabilities.js";
7
+ import { CanonicalRefusalGround } from "../types/canonicalCapabilities.js";
8
8
  import { document_d_exports } from "../types/document.js";
9
9
  import { DeepReadonly, ReadonlyDocument } from "../types/documentModel.js";
10
10
  import { FolioDerivedFields } from "../types/fields.js";
@@ -15,35 +15,13 @@ import { HiddenEditorApi } from "./hiddenEditorApi.js";
15
15
  import { TaggedErrorClass } from "better-result";
16
16
  import { EditorState, Plugin, Transaction } from "prosemirror-state";
17
17
  import { EditorView } from "prosemirror-view";
18
- import * as Yjs from "yjs";
19
- import { XmlFragment } from "yjs";
20
- import * as YProseMirror from "y-prosemirror";
21
18
  declare const CanonicalSessionRefusalErrorBase: TaggedErrorClass<"CanonicalSessionRefusalError">;
22
19
  /** A refused input, with whether the session lacks the capability or the document forbids it. */
23
20
  export declare class CanonicalSessionRefusalError extends CanonicalSessionRefusalErrorBase<{
24
21
  ground: CanonicalRefusalGround;
25
22
  message: string;
26
23
  }> {}
27
- type YProseMirrorModule = typeof YProseMirror;
28
- type YjsModule = typeof Yjs;
29
- export type CollaborationModules = {
30
- yProseMirror: YProseMirrorModule;
31
- yjs: YjsModule;
32
- };
33
- type CollaborationAwareness = {
34
- clientID: number;
35
- getStates: () => Map<number, unknown>;
36
- off: (event: "change" | "update", handler: () => void) => void;
37
- on: (event: "change" | "update", handler: () => void) => void;
38
- };
39
- export type HiddenProseMirrorCollaboration = {
40
- awareness?: CollaborationAwareness | undefined;
41
- onSeeded?: (() => void) | undefined;
42
- shouldSeed?: boolean | undefined;
43
- yXmlFragment: XmlFragment;
44
- };
45
24
  export type HiddenProseMirrorRemoteSelection = RemoteSelection;
46
- export declare const collectRemoteSelections: (state: EditorState, awareness: CollaborationAwareness, collaborationModules: CollaborationModules) => HiddenProseMirrorRemoteSelection[];
47
25
  /**
48
26
  * Create ProseMirror state from document
49
27
  *
@@ -56,8 +34,6 @@ export type CreateHiddenEditorStateOptions = {
56
34
  styles?: DeepReadonly<document_d_exports.StyleDefinitions> | null | undefined;
57
35
  manager?: ExtensionManager | undefined;
58
36
  externalPlugins?: Plugin[] | undefined;
59
- collaboration?: HiddenProseMirrorCollaboration | undefined;
60
- collaborationModules?: CollaborationModules | null | undefined;
61
37
  reason?: HiddenEditorStateReason | undefined;
62
38
  };
63
39
  export declare function createHiddenEditorState(options: CreateHiddenEditorStateOptions): EditorState;
@@ -67,20 +43,9 @@ export type HiddenEditorManagerDeps = {
67
43
  getStyles: () => DeepReadonly<document_d_exports.StyleDefinitions> | null | undefined;
68
44
  getExtensionManager: () => ExtensionManager | undefined;
69
45
  getExternalPlugins: () => Plugin[];
70
- /** The Yjs fragment a legacy session edits. */
71
- getCollaboration: () => HiddenProseMirrorCollaboration | undefined;
72
- getCollaborationModules: () => CollaborationModules | null;
73
- /** The room a canonical session joins. */
46
+ /** The room the session joins. */
74
47
  getCanonicalRoom?: () => CanonicalRoomCollaboration | undefined;
75
- /**
76
- * The state the adapter converted from the document for its pages before a
77
- * view existed. Read only when the view is built from the document: a
78
- * canonical session seeds the view with its own projection, so an adapter
79
- * that converts on this read converts the document once per open.
80
- */
81
- getPrecomputedInitialState: () => EditorState | null | undefined;
82
48
  getReadOnly: () => boolean;
83
- getExperimentalSession?: () => EditorSession | undefined;
84
49
  /** The terms the host wants highlighted; none when unset. */
85
50
  getAnonymizationTerms?: () => readonly FolioAnonymizationTerm[];
86
51
  /** The fields whose display text the host derives; none when unset. */