import { Editor } from '../../core/Editor.js'; import { NOTE_TOMBSTONE_EVENT, SessionManagedNoteIds } from '../../core/parts/adapters/notes-part-descriptor.js'; /** * Collaborative sync for SD-3400 note tombstones. * * Interactive footnote/endnote inserts and deletes register the note id as * "session-managed" on the local converter (`converter.sessionManagedNoteIds`). * Export prunes ids that are registered AND unreferenced in the body, and * revision-story enumeration hides them the same way. For a single-client * session that local registry is sufficient. * * In a collaborative room the marker delete propagates through y-prosemirror, * so every peer's body loses the reference, but the provenance ("this id was * managed by this session") lives only on the originating peer's converter. * Without sharing it, peer B — and any late joiner — would re-export the now * orphaned note text and re-enumerate the dead note as a revision-capable * story. * * This module shares that provenance through the Yjs `meta` map using flat, * add-only keys (`noteTombstone::`). Flat per-id keys merge cleanly * under Yjs CRDT semantics — concurrent adds from different peers touch * different keys, and repeated adds of the same id are idempotent — and late * joiners hydrate simply by reading the existing keys. * * The `meta` map is collaboration-only state; it is never written into the * exported DOCX, so tombstone bookkeeping stays out of the file. */ import type * as Y from 'yjs'; export { NOTE_TOMBSTONE_EVENT }; /** Meta-map key prefix for a single shared note tombstone. */ export declare const NOTE_TOMBSTONE_META_PREFIX = "noteTombstone:"; export type NoteType = 'footnote' | 'endnote'; /** Build the meta-map key for a note tombstone. */ export declare function noteTombstoneKey(type: NoteType, noteId: string): string; /** Parse a meta-map key back into a note tombstone, or `null` when it is not one. */ export declare function parseNoteTombstoneKey(key: string): { type: NoteType; noteId: string; } | null; /** Publish one tombstone to the shared meta map (add-only, idempotent). */ export declare function publishNoteTombstone(ydoc: Y.Doc, type: NoteType, noteId: string): void; /** * Remove every shared tombstone key from the meta map. * * Used by authoritative room/file replacement so note tombstones from the * previous document cannot leak into the next one when a collaborative Y.Doc * instance is reused. */ export declare function clearNoteTombstonesFromMeta(ydoc: Y.Doc): void; /** Publish every locally tracked session-managed note id into the shared meta map. */ export declare function publishSessionManagedNoteIds(ydoc: Y.Doc, registry: SessionManagedNoteIds | null | undefined): void; /** Merge every shared tombstone from the meta map into the local converter registry. */ export declare function hydrateNoteTombstonesFromMeta(editor: Editor, ydoc: Y.Doc): void; export interface NoteTombstoneSyncHandle { destroy(): void; } /** * Wire collaborative note-tombstone sharing for one editor session. * * - Local inserts/deletes emit `note-tombstoned`; we publish the id to `meta`. * - Remote tombstone keys merge into this peer's converter registry. * - Initial hydration (deferred until the provider is synced) seeds late * joiners from tombstones already present in the room. */ export declare function registerNoteTombstoneSync(editor: Editor, ydoc: Y.Doc): NoteTombstoneSyncHandle; //# sourceMappingURL=note-tombstone-sync.d.ts.map