noteloom 0.3.3 → 0.4.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 (104) hide show
  1. package/README.md +284 -55
  2. package/bin/noteloom.mjs +139 -0
  3. package/dist/canvas.cjs +2 -0
  4. package/dist/canvas.cjs.map +1 -0
  5. package/dist/canvas.d.ts +2 -0
  6. package/dist/canvas.js +5 -0
  7. package/dist/canvas.js.map +1 -0
  8. package/dist/collab.cjs +2 -0
  9. package/dist/collab.cjs.map +1 -0
  10. package/dist/collab.d.ts +19 -0
  11. package/dist/collab.js +379 -0
  12. package/dist/collab.js.map +1 -0
  13. package/dist/comments.cjs +2 -0
  14. package/dist/comments.cjs.map +1 -0
  15. package/dist/comments.d.ts +17 -0
  16. package/dist/comments.js +19 -0
  17. package/dist/comments.js.map +1 -0
  18. package/dist/index.cjs +2 -0
  19. package/dist/index.cjs.map +1 -0
  20. package/dist/index.d.ts +372 -33
  21. package/dist/index.js +3983 -0
  22. package/dist/index.js.map +1 -0
  23. package/dist/persistence.cjs +2 -0
  24. package/dist/persistence.cjs.map +1 -0
  25. package/dist/persistence.d.ts +11 -0
  26. package/dist/persistence.js +12 -0
  27. package/dist/persistence.js.map +1 -0
  28. package/dist/shared/CommentAvatar-TKqsM8vG.js +53 -0
  29. package/dist/shared/CommentAvatar-TKqsM8vG.js.map +1 -0
  30. package/dist/shared/CommentAvatar-V457IgoQ.cjs +2 -0
  31. package/dist/shared/CommentAvatar-V457IgoQ.cjs.map +1 -0
  32. package/dist/shared/CommentThreadCard-CAJ3oPdr.cjs +2 -0
  33. package/dist/shared/CommentThreadCard-CAJ3oPdr.cjs.map +1 -0
  34. package/dist/shared/CommentThreadCard-Cxf8GwHJ.js +213 -0
  35. package/dist/shared/CommentThreadCard-Cxf8GwHJ.js.map +1 -0
  36. package/dist/shared/CommentsPanel-BwVVyMOC.js +76 -0
  37. package/dist/shared/CommentsPanel-BwVVyMOC.js.map +1 -0
  38. package/dist/shared/CommentsPanel-CES4uzye.cjs +2 -0
  39. package/dist/shared/CommentsPanel-CES4uzye.cjs.map +1 -0
  40. package/dist/shared/VersionHistory-Bg6fufP5.js +1120 -0
  41. package/dist/shared/VersionHistory-Bg6fufP5.js.map +1 -0
  42. package/dist/shared/VersionHistory-DELa2Wbq.cjs +12 -0
  43. package/dist/shared/VersionHistory-DELa2Wbq.cjs.map +1 -0
  44. package/dist/shared/VoiceListeningIndicator-BOfVmLK0.js +338 -0
  45. package/dist/shared/VoiceListeningIndicator-BOfVmLK0.js.map +1 -0
  46. package/dist/shared/VoiceListeningIndicator-DNX8JlQM.cjs +2 -0
  47. package/dist/shared/VoiceListeningIndicator-DNX8JlQM.cjs.map +1 -0
  48. package/dist/shared/fieldRegistry-BoYyW3GH.cjs +2 -0
  49. package/dist/shared/fieldRegistry-BoYyW3GH.cjs.map +1 -0
  50. package/dist/shared/fieldRegistry-PjJWXFoB.js +223 -0
  51. package/dist/shared/fieldRegistry-PjJWXFoB.js.map +1 -0
  52. package/dist/shared/icons-C1_s0jKK.js +4269 -0
  53. package/dist/shared/icons-C1_s0jKK.js.map +1 -0
  54. package/dist/shared/icons-DtCsXuU6.cjs +3531 -0
  55. package/dist/shared/icons-DtCsXuU6.cjs.map +1 -0
  56. package/dist/shared/index-B9jyyL8u.js +2145 -0
  57. package/dist/shared/index-B9jyyL8u.js.map +1 -0
  58. package/dist/shared/index-D9WEXpYM.cjs +2 -0
  59. package/dist/shared/index-D9WEXpYM.cjs.map +1 -0
  60. package/dist/shared/indexedDbPersistence-BKlGPFTP.js +112 -0
  61. package/dist/shared/indexedDbPersistence-BKlGPFTP.js.map +1 -0
  62. package/dist/shared/indexedDbPersistence-BWJ1h5Vp.cjs +2 -0
  63. package/dist/shared/indexedDbPersistence-BWJ1h5Vp.cjs.map +1 -0
  64. package/dist/shared/leafBlockFactory-A9eUhSe-.js +335 -0
  65. package/dist/shared/leafBlockFactory-A9eUhSe-.js.map +1 -0
  66. package/dist/shared/leafBlockFactory-Dp382eP8.cjs +2 -0
  67. package/dist/shared/leafBlockFactory-Dp382eP8.cjs.map +1 -0
  68. package/dist/shared/serialize-DWEfk0vU.cjs +3 -0
  69. package/dist/shared/serialize-DWEfk0vU.cjs.map +1 -0
  70. package/dist/shared/serialize-T9Odwx24.js +86 -0
  71. package/dist/shared/serialize-T9Odwx24.js.map +1 -0
  72. package/dist/shared/starter-kit-CY5wzYDf.js +4980 -0
  73. package/dist/shared/starter-kit-CY5wzYDf.js.map +1 -0
  74. package/dist/shared/starter-kit-lPN-NpJ5.cjs +27 -0
  75. package/dist/shared/starter-kit-lPN-NpJ5.cjs.map +1 -0
  76. package/dist/shared/usePopoverEdgeClamp-CDG26jBM.cjs +2 -0
  77. package/dist/shared/usePopoverEdgeClamp-CDG26jBM.cjs.map +1 -0
  78. package/dist/shared/usePopoverEdgeClamp-gmFm0CnI.js +109 -0
  79. package/dist/shared/usePopoverEdgeClamp-gmFm0CnI.js.map +1 -0
  80. package/dist/shared/useServiceWorkerUpdate-BduabXv6.js +94 -0
  81. package/dist/shared/useServiceWorkerUpdate-BduabXv6.js.map +1 -0
  82. package/dist/shared/useServiceWorkerUpdate-DQboGesi.cjs +2 -0
  83. package/dist/shared/useServiceWorkerUpdate-DQboGesi.cjs.map +1 -0
  84. package/dist/starter-kit.cjs +2 -0
  85. package/dist/starter-kit.cjs.map +1 -0
  86. package/dist/starter-kit.d.ts +9 -0
  87. package/dist/starter-kit.js +10 -0
  88. package/dist/starter-kit.js.map +1 -0
  89. package/dist/style.css +3529 -3283
  90. package/dist/versions.cjs +2 -0
  91. package/dist/versions.cjs.map +1 -0
  92. package/dist/versions.d.ts +11 -0
  93. package/dist/versions.js +13 -0
  94. package/dist/versions.js.map +1 -0
  95. package/dist/voice.cjs +2 -0
  96. package/dist/voice.cjs.map +1 -0
  97. package/dist/voice.d.ts +7 -0
  98. package/dist/voice.js +8 -0
  99. package/dist/voice.js.map +1 -0
  100. package/package.json +159 -92
  101. package/dist/noteloom.cjs +0 -3292
  102. package/dist/noteloom.cjs.map +0 -1
  103. package/dist/noteloom.es.js +0 -15047
  104. package/dist/noteloom.es.js.map +0 -1
package/dist/index.d.ts CHANGED
@@ -6,7 +6,14 @@
6
6
  // every export still gets *something* useful rather than `any`. No `.js`/
7
7
  // `.jsx` source was changed to produce this file.
8
8
 
9
- import type { ComponentType, ReactNode, ReactElement, CSSProperties, RefObject, ClipboardEvent } from 'react';
9
+ import type {
10
+ ComponentType,
11
+ ReactNode,
12
+ ReactElement,
13
+ CSSProperties,
14
+ RefObject,
15
+ ClipboardEvent,
16
+ } from 'react';
10
17
 
11
18
  // ---------------------------------------------------------------------------
12
19
  // Document shape
@@ -93,11 +100,20 @@ export const OP: {
93
100
  };
94
101
 
95
102
  export namespace operations {
96
- export function insertBlock(block: Block, parentId: string, index: number, subtree?: { blocks: Block[]; runs: Run[] }): Operation;
103
+ export function insertBlock(
104
+ block: Block,
105
+ parentId: string,
106
+ index: number,
107
+ subtree?: { blocks: Block[]; runs: Run[] },
108
+ ): Operation;
97
109
  export function removeBlock(id: string): Operation;
98
110
  export function moveBlock(id: string, toParentId: string, toIndex: number): Operation;
99
111
  export function updateBlockProps(id: string, patch: Record<string, unknown>): Operation;
100
- export function changeBlockType(id: string, blockType: string, props: Record<string, unknown>): Operation;
112
+ export function changeBlockType(
113
+ id: string,
114
+ blockType: string,
115
+ props: Record<string, unknown>,
116
+ ): Operation;
101
117
  export function updateRun(id: string, patch: Record<string, unknown>): Operation;
102
118
  export function setBlockContentIds(blockId: string, contentIds: string[]): Operation;
103
119
  export function replaceRunSpan(blockId: string, oldRunIds: string[], newRuns: Run[]): Operation;
@@ -285,13 +301,21 @@ export function encodeMessage(message: unknown): string;
285
301
  export function decodeMessage(raw: string): unknown;
286
302
 
287
303
  export class PeerConnection {
288
- constructor(options: { peerConnection: RTCPeerConnection; dataChannel?: RTCDataChannel; onMessage?: (message: unknown) => void });
304
+ constructor(options: {
305
+ peerConnection: RTCPeerConnection;
306
+ dataChannel?: RTCDataChannel;
307
+ onMessage?: (message: unknown) => void;
308
+ });
289
309
  send(message: unknown): void;
290
310
  close(): void;
291
311
  }
292
312
 
293
313
  export class CollabSession {
294
- constructor(options: { history: History | EditorStore; signaling: SignalingChannel; presenceThrottleMs?: number });
314
+ constructor(options: {
315
+ history: History | EditorStore;
316
+ signaling: SignalingChannel;
317
+ presenceThrottleMs?: number;
318
+ });
295
319
  connect(remotePeerId: string, options: { initiator: boolean }): void;
296
320
  disconnect(remotePeerId: string): void;
297
321
  destroy(): void;
@@ -346,7 +370,10 @@ export function loadTemplate(id: string): Promise<StoredTemplate | null>;
346
370
  export function deleteTemplate(id: string): Promise<void>;
347
371
  export function listTemplates(): Promise<StoredTemplate[]>;
348
372
 
349
- export function captureBlockTemplate(store: EditorStore | History, blockIds: string[]): BlockTemplate;
373
+ export function captureBlockTemplate(
374
+ store: EditorStore | History,
375
+ blockIds: string[],
376
+ ): BlockTemplate;
350
377
  export function insertBlockTemplate(
351
378
  store: EditorStore | History,
352
379
  template: BlockTemplate,
@@ -364,7 +391,10 @@ export interface BlockTemplateDefinition {
364
391
  }
365
392
 
366
393
  /** Registers block templates as slash commands, discoverable/insertable via "/" alongside every built-in block — no SlashMenu/BlockRegistry changes needed. */
367
- export function registerBlockTemplates(registry: BlockRegistry, templates: BlockTemplateDefinition[]): void;
394
+ export function registerBlockTemplates(
395
+ registry: BlockRegistry,
396
+ templates: BlockTemplateDefinition[],
397
+ ): void;
368
398
 
369
399
  export function useTemplates(options?: { scope?: 'document' | 'block' }): {
370
400
  templates: StoredTemplate[];
@@ -434,7 +464,10 @@ export function useDocumentVersions(docId: string | null | undefined): {
434
464
  * `.be-version-diff-removed` spans. Used internally by `<VersionHistory>`'s
435
465
  * "Changes" tab; exported for building a custom version-history UI.
436
466
  */
437
- export function diffDocumentsHTML(prevDoc: DocumentJSON | null | undefined, nextDoc: DocumentJSON): string;
467
+ export function diffDocumentsHTML(
468
+ prevDoc: DocumentJSON | null | undefined,
469
+ nextDoc: DocumentJSON,
470
+ ): string;
438
471
 
439
472
  export interface VersionHistoryProps {
440
473
  docId: string;
@@ -458,18 +491,37 @@ export interface CommentRange {
458
491
  }
459
492
 
460
493
  /** Creates a comment thread anchored to `range`, highlighting it and creating the thread as one atomic undo step. Returns the new comment's id. */
461
- export function addComment(store: EditorStore | History, range: CommentRange, message: { authorId: string; text: string }): string;
494
+ export function addComment(
495
+ store: EditorStore | History,
496
+ range: CommentRange,
497
+ message: { authorId: string; text: string },
498
+ ): string;
462
499
  /** Appends a reply to an existing thread. Returns the new message's id. */
463
- export function replyToComment(store: EditorStore | History, commentId: string, message: { authorId: string; text: string }): string;
500
+ export function replyToComment(
501
+ store: EditorStore | History,
502
+ commentId: string,
503
+ message: { authorId: string; text: string },
504
+ ): string;
464
505
  /** Flips a thread's resolved flag (defaults to true). */
465
- export function resolveComment(store: EditorStore | History, commentId: string, resolved?: boolean): void;
506
+ export function resolveComment(
507
+ store: EditorStore | History,
508
+ commentId: string,
509
+ resolved?: boolean,
510
+ ): void;
466
511
  /** Removes a thread and strips its highlight from every run that still carries it, as one atomic undo step. */
467
512
  export function deleteComment(store: EditorStore | History, commentId: string): void;
468
513
 
469
514
  /** Computes (does not apply) the op that highlights `range` with `commentId` -- for advanced use; addComment already calls this. Returns null for a collapsed/unresolvable range. */
470
- export function addCommentMarkOverRange(store: EditorStore | History, range: CommentRange, commentId: string): Operation | null;
515
+ export function addCommentMarkOverRange(
516
+ store: EditorStore | History,
517
+ range: CommentRange,
518
+ commentId: string,
519
+ ): Operation | null;
471
520
  /** Computes (does not apply) the ops that strip `commentId` from every run in the document that carries it. */
472
- export function removeCommentMarkEverywhere(store: EditorStore | History, commentId: string): Operation[];
521
+ export function removeCommentMarkEverywhere(
522
+ store: EditorStore | History,
523
+ commentId: string,
524
+ ): Operation[];
473
525
 
474
526
  export function useComments(): CommentThread[];
475
527
 
@@ -555,7 +607,10 @@ export type BlockTypeDefinition = BlockTypeEntry;
555
607
  export type InlineTypeDefinition = InlineTypeEntry;
556
608
 
557
609
  export function registerBuiltInBlocks(registry: BlockRegistry): void;
558
- export function registerBlocks(registry: BlockRegistry, types: Record<string, BlockTypeDefinition>): void;
610
+ export function registerBlocks(
611
+ registry: BlockRegistry,
612
+ types: Record<string, BlockTypeDefinition>,
613
+ ): void;
559
614
  export const TABLE_BLOCKS: Record<string, BlockTypeDefinition>;
560
615
  export const LAYOUT_BLOCKS: Record<string, BlockTypeDefinition>;
561
616
 
@@ -577,7 +632,10 @@ export const embedBlockType: BlockTypeDefinition;
577
632
  export const canvasBlockType: BlockTypeDefinition;
578
633
 
579
634
  export function registerBuiltInInlineTypes(inlineRegistry: InlineRegistry): void;
580
- export function registerInlineTypes(inlineRegistry: InlineRegistry, types: Record<string, InlineTypeDefinition>): void;
635
+ export function registerInlineTypes(
636
+ inlineRegistry: InlineRegistry,
637
+ types: Record<string, InlineTypeDefinition>,
638
+ ): void;
581
639
  export const TABLE_SELECT_INLINE_TYPES: Record<string, InlineTypeDefinition>;
582
640
 
583
641
  export const selectInlineType: InlineTypeDefinition;
@@ -586,6 +644,120 @@ export const checkboxInlineType: InlineTypeDefinition;
586
644
  export const tableSelectInlineType: InlineTypeDefinition;
587
645
  export const emojiInlineType: InlineTypeDefinition;
588
646
 
647
+ // ---------------------------------------------------------------------------
648
+ // registry/define.js, starter-kit.js — the defineBlock/defineInline factories
649
+ // ---------------------------------------------------------------------------
650
+
651
+ export interface DefineBlockConfig {
652
+ /** Unique — used as the block `type`. */
653
+ name: string;
654
+ /** React component, receives `{ id }`. */
655
+ component: ComponentType<{ id: string }>;
656
+ /** 'blocks' (default, holds child blocks) | 'runs' | 'void' (both leaves). */
657
+ contentModel?: 'blocks' | 'runs' | 'void';
658
+ /** Escape hatch — set `isLeaf` directly instead of `contentModel`. */
659
+ isLeaf?: boolean;
660
+ defaultProps?: Record<string, unknown>;
661
+ toHTML?: (block: Block, ctx: unknown) => string;
662
+ fromHTML?: (node: unknown, ctx: unknown) => unknown;
663
+ toPlainText?: (block: Block, ctx: unknown) => string;
664
+ toMarkdown?: (block: Block, ctx: unknown) => string;
665
+ slashCommand?: unknown;
666
+ slashCommands?: unknown[];
667
+ [key: string]: unknown;
668
+ }
669
+
670
+ export interface DefineInlineConfig {
671
+ name: string;
672
+ component: ComponentType<{ id: string }>;
673
+ /** Only `true` (the default) is supported today. */
674
+ atomic?: boolean;
675
+ isAtomic?: boolean;
676
+ toHTML?: (run: Run, ctx: unknown) => string;
677
+ fromHTML?: (node: unknown, ctx: unknown) => unknown;
678
+ toPlainText?: (run: Run, ctx: unknown) => string;
679
+ slashCommand?: unknown;
680
+ slashCommands?: unknown[];
681
+ atCommand?: unknown;
682
+ atCommands?: unknown[];
683
+ [key: string]: unknown;
684
+ }
685
+
686
+ /** A `defineBlock()` result — a `BlockRegistry` entry tagged `kind: 'block'`. */
687
+ export type BlockDefinition = BlockTypeDefinition & { name: string; kind: 'block' };
688
+ /** A `defineInline()` result — an `InlineRegistry` entry tagged `kind: 'inline'`. */
689
+ export type InlineDefinition = InlineTypeDefinition & { name: string; kind: 'inline' };
690
+ /** A `defineExtension()` result — a named bundle of block/inline definitions and/or behavior. */
691
+ export interface ExtensionBundle {
692
+ name: string;
693
+ kind: 'extension';
694
+ blocks: BlockDefinition[];
695
+ inlineTypes: InlineDefinition[];
696
+ keymap?: Record<string, KeymapHandler>;
697
+ onBeforeInput?: ExtensionEventHandler;
698
+ onPaste?: ExtensionEventHandler;
699
+ setup?: (ctx: ExtensionCtx) => void | (() => void);
700
+ [key: string]: unknown;
701
+ }
702
+ export type Extension = BlockDefinition | InlineDefinition | ExtensionBundle;
703
+
704
+ /** The stable facade passed to every `defineExtension()` behavior handler. */
705
+ export interface ExtensionCtx {
706
+ store: EditorStore | History;
707
+ registry: BlockRegistry;
708
+ inlineRegistry: InlineRegistry;
709
+ /** The editor's root element (null before mount). */
710
+ readonly container: HTMLElement | null;
711
+ getBlock(id: string): Block | undefined;
712
+ getRun(id: string): Run | undefined;
713
+ getRootId(): string | null;
714
+ /** Apply an operation, flushing React synchronously so the DOM is current before `setCaret`. */
715
+ applyOperation(op: Operation): void;
716
+ applyOperations(ops: Operation[]): void;
717
+ getSelection(): { blockId: string; runId: string; startOffset: number; endOffset: number } | null;
718
+ getCaret(): { blockId: string; runId: string; offset: number } | null;
719
+ setCaret(runId: string, offset: number): void;
720
+ subscribe(listener: () => void): () => void;
721
+ }
722
+
723
+ /** A keymap handler — return truthy to mark the key handled. */
724
+ export type KeymapHandler = (ctx: ExtensionCtx, event: KeyboardEvent) => boolean | void;
725
+ /** A beforeinput/paste handler — return truthy to mark the event handled. */
726
+ export type ExtensionEventHandler = (ctx: ExtensionCtx, event: Event) => boolean | void;
727
+
728
+ export interface DefineExtensionConfig {
729
+ /** Label for the bundle / diagnostics. */
730
+ name: string;
731
+ blocks?: BlockDefinition[];
732
+ inlineTypes?: InlineDefinition[];
733
+ /** `{ 'Mod-Shift-x': (ctx, event) => boolean }` — `Mod` is Ctrl/Cmd. */
734
+ keymap?: Record<string, KeymapHandler>;
735
+ onBeforeInput?: ExtensionEventHandler;
736
+ onPaste?: ExtensionEventHandler;
737
+ /** Runs once on mount; may return a cleanup function. */
738
+ setup?: (ctx: ExtensionCtx) => void | (() => void);
739
+ [key: string]: unknown;
740
+ }
741
+
742
+ export function defineBlock(config: DefineBlockConfig): BlockDefinition;
743
+ export function defineInline(config: DefineInlineConfig): InlineDefinition;
744
+ /** Groups block/inline definitions and/or behavior (keymap/onBeforeInput/onPaste/setup) under one name. */
745
+ export function defineExtension(config: DefineExtensionConfig): ExtensionBundle;
746
+
747
+ /** Opt-in typing behavior: straight quotes -> curly. */
748
+ export function smartQuotes(): ExtensionBundle;
749
+ /** Opt-in typing behavior: auto-close `(` `[` `{`. */
750
+ export function autoPairBrackets(): ExtensionBundle;
751
+
752
+ /** Registers a flat/nested array of `defineBlock()` / `defineInline()` results (and `defineExtension()` bundles) onto the given registries. */
753
+ export function registerExtensions(
754
+ extensions: ReadonlyArray<Extension | ReadonlyArray<Extension>>,
755
+ registries: { registry?: BlockRegistry; inlineRegistry?: InlineRegistry },
756
+ ): void;
757
+
758
+ /** Every built-in block + inline type as an `extensions` array. `exclude` drops types by name. */
759
+ export function starterKit(options?: { exclude?: string[] }): Extension[];
760
+
589
761
  // ---------------------------------------------------------------------------
590
762
  // react/ — provider, core hooks
591
763
  // ---------------------------------------------------------------------------
@@ -604,7 +776,10 @@ export interface EditorProviderProps {
604
776
  /** Whether CodeBlock renders its line-number gutter -- see useShowLineNumbers. */
605
777
  showLineNumbers?: boolean;
606
778
  /** Sends a picked/dropped EmbedBlock file somewhere real (local disk, S3, any other cloud storage) instead of inlining it as a data: URL -- see useFileUpload's own doc comment for the full contract. */
607
- uploadFile?: (file: File, ctx: { kind: 'image' | 'video' | 'audio' | 'file' }) => Promise<{ src: string; name?: string; mimeType?: string }>;
779
+ uploadFile?: (
780
+ file: File,
781
+ ctx: { kind: 'image' | 'video' | 'audio' | 'file' },
782
+ ) => Promise<{ src: string; name?: string; mimeType?: string }>;
608
783
  /** Byte cap for the in-document data: URL fallback ONLY (no effect once uploadFile is configured) -- an oversized file is rejected with a clear error instead of bloating the document. */
609
784
  maxFileSize?: number;
610
785
  children?: ReactNode;
@@ -624,7 +799,10 @@ export function useCommentAuthorId(): string | undefined;
624
799
  export function useShowLineNumbers(): boolean;
625
800
  /** `{ uploadFile, maxFileSize }` from EditorProvider -- see EditorProviderProps and useFileUpload's own doc comment for the full contract. */
626
801
  export function useFileUpload(): {
627
- uploadFile?: (file: File, ctx: { kind: 'image' | 'video' | 'audio' | 'file' }) => Promise<{ src: string; name?: string; mimeType?: string }>;
802
+ uploadFile?: (
803
+ file: File,
804
+ ctx: { kind: 'image' | 'video' | 'audio' | 'file' },
805
+ ) => Promise<{ src: string; name?: string; mimeType?: string }>;
628
806
  maxFileSize?: number;
629
807
  };
630
808
  export function useFieldTypeEditor(): {
@@ -632,7 +810,10 @@ export function useFieldTypeEditor(): {
632
810
  openFieldTypeEditor: (id: string | null) => void;
633
811
  closeFieldTypeEditor: () => void;
634
812
  };
635
- export function useBlockClassName(baseClassName: string | undefined, block: Block): string | undefined;
813
+ export function useBlockClassName(
814
+ baseClassName: string | undefined,
815
+ block: Block,
816
+ ): string | undefined;
636
817
 
637
818
  export function injectDefaultStyles(): void;
638
819
 
@@ -661,7 +842,9 @@ export function usePersistedDocument(options: {
661
842
  onSave?: () => void;
662
843
  }): { isLoaded: boolean; save: () => Promise<void> };
663
844
 
664
- export function usePresence(session: CollabSession | null | undefined): Map<string, Record<string, unknown>>;
845
+ export function usePresence(
846
+ session: CollabSession | null | undefined,
847
+ ): Map<string, Record<string, unknown>>;
665
848
 
666
849
  export function useServiceWorkerUpdate(): { updateAvailable: boolean; applyUpdate: () => void };
667
850
 
@@ -694,7 +877,12 @@ export const MobileActionBar: ComponentType<{ containerRef: RefObject<HTMLElemen
694
877
  export const MobileBlockPickerSheet: ComponentType<Record<string, unknown>>;
695
878
  export const MobileBlockOptionsSheet: ComponentType<Record<string, unknown>>;
696
879
  export const EditableBlockContent: ComponentType<Record<string, unknown>>;
697
- export const Modal: ComponentType<{ isOpen?: boolean; onClose?: () => void; children?: ReactNode; [key: string]: unknown }>;
880
+ export const Modal: ComponentType<{
881
+ isOpen?: boolean;
882
+ onClose?: () => void;
883
+ children?: ReactNode;
884
+ [key: string]: unknown;
885
+ }>;
698
886
  export const Select: ComponentType<Record<string, unknown>>;
699
887
  export const EditorTrailingSpace: ComponentType<Record<string, unknown>>;
700
888
 
@@ -729,11 +917,47 @@ export function deserializeClipboard(...args: unknown[]): unknown;
729
917
  export function walkDomToBlocks(...args: unknown[]): unknown;
730
918
  export function textToParagraphs(...args: unknown[]): unknown;
731
919
  /** Returns a JSON *string* (pretty-printed by default) — parse it (`JSON.parse`) to get back a plain `{ version, rootId, blocks, runs }` object usable as `useEditor({ doc })`. */
732
- export function exportDocumentJSON(store: EditorStore | History, options?: { pretty?: boolean }): string;
920
+ export function exportDocumentJSON(
921
+ store: EditorStore | History,
922
+ options?: { pretty?: boolean },
923
+ ): string;
733
924
  export function exportDocumentHTML(store: EditorStore | History, registry: BlockRegistry): string;
734
925
  export function exportDocumentText(store: EditorStore | History, registry: BlockRegistry): string;
735
- export function exportDocumentSimpleJSON(store: EditorStore | History, registry: BlockRegistry, inlineRegistry: InlineRegistry): unknown;
736
- export function importDocumentSimpleJSON(json: unknown, registry: BlockRegistry, inlineRegistry: InlineRegistry): DocumentJSON;
926
+ export function exportDocumentMarkdown(
927
+ store: EditorStore | History,
928
+ registry: BlockRegistry,
929
+ inlineRegistry?: InlineRegistry,
930
+ ): string;
931
+ export function exportDocumentWordHTML(
932
+ store: EditorStore | History,
933
+ registry: BlockRegistry,
934
+ inlineRegistry?: InlineRegistry,
935
+ ): string;
936
+ /** A `{ id, type, data, children? }` block in the simple document format. */
937
+ export interface SimpleBlock {
938
+ id: string;
939
+ type: string;
940
+ data: Record<string, unknown>;
941
+ children?: SimpleBlock[];
942
+ }
943
+ /** The canonical interchange format — see docs/document.schema.json. */
944
+ export interface SimpleDocument {
945
+ version: 1;
946
+ blocks: SimpleBlock[];
947
+ }
948
+ export function exportDocumentSimpleJSON(
949
+ store: EditorStore | History,
950
+ registry: BlockRegistry,
951
+ inlineRegistry: InlineRegistry,
952
+ options?: { pretty?: boolean },
953
+ ): string;
954
+ export function importDocumentSimpleJSON(
955
+ json: string | SimpleDocument,
956
+ registry: BlockRegistry,
957
+ inlineRegistry: InlineRegistry,
958
+ ): DocumentJSON;
959
+ /** True when `doc` is a `SimpleDocument` rather than the internal `DocumentJSON` shape. */
960
+ export function isSimpleDocument(doc: unknown): doc is SimpleDocument;
737
961
  export const DocumentExportButton: ComponentType<Record<string, unknown>>;
738
962
 
739
963
  // ---------------------------------------------------------------------------
@@ -761,9 +985,15 @@ export interface SlashMenuProps {
761
985
  }
762
986
 
763
987
  export const SlashMenu: ComponentType<SlashMenuProps>;
764
- export function useSlashMenuTrigger(containerRef: RefObject<HTMLElement | null>): CommandMenuTriggerState;
765
- export function useEmojiMenuTrigger(containerRef: RefObject<HTMLElement | null>): CommandMenuTriggerState;
766
- export function useAtMenuTrigger(containerRef: RefObject<HTMLElement | null>): CommandMenuTriggerState;
988
+ export function useSlashMenuTrigger(
989
+ containerRef: RefObject<HTMLElement | null>,
990
+ ): CommandMenuTriggerState;
991
+ export function useEmojiMenuTrigger(
992
+ containerRef: RefObject<HTMLElement | null>,
993
+ ): CommandMenuTriggerState;
994
+ export function useAtMenuTrigger(
995
+ containerRef: RefObject<HTMLElement | null>,
996
+ ): CommandMenuTriggerState;
767
997
 
768
998
  export interface FloatingToolbarProps {
769
999
  isOpen: boolean;
@@ -802,6 +1032,12 @@ export function renameColumn(...args: unknown[]): unknown;
802
1032
  export function setColumnType(...args: unknown[]): unknown;
803
1033
  export function setColumnOptions(...args: unknown[]): unknown;
804
1034
  export function setColumnWidth(...args: unknown[]): unknown;
1035
+ export function sortTableByColumn(...args: unknown[]): unknown;
1036
+ export function setColumnAggregate(...args: unknown[]): unknown;
1037
+ export function computeColumnAggregate(...args: unknown[]): unknown;
1038
+ export function formatAggregateValue(value: number | null): string;
1039
+ export const AGGREGATE_TYPES: string[];
1040
+ export const AGGREGATE_LABELS: Record<string, string>;
805
1041
  export function resolveColumns(...args: unknown[]): unknown;
806
1042
  export function createDefaultColumns(...args: unknown[]): unknown;
807
1043
  export function createCellForColumn(...args: unknown[]): unknown;
@@ -853,8 +1089,14 @@ export function copyBlockRangeToClipboard(...args: unknown[]): unknown;
853
1089
  // ---------------------------------------------------------------------------
854
1090
 
855
1091
  export function createSelectFieldType(options: Record<string, unknown>): InlineTypeDefinition;
856
- export function registerStoredFieldTypes(inlineRegistry: InlineRegistry, fieldTypes: FieldType[]): void;
857
- export function useRegisterFieldTypes(inlineRegistry: InlineRegistry, fieldTypes: FieldType[]): void;
1092
+ export function registerStoredFieldTypes(
1093
+ inlineRegistry: InlineRegistry,
1094
+ fieldTypes: FieldType[],
1095
+ ): void;
1096
+ export function useRegisterFieldTypes(
1097
+ inlineRegistry: InlineRegistry,
1098
+ fieldTypes: FieldType[],
1099
+ ): void;
858
1100
  export const FieldTypeEditorModal: ComponentType<Record<string, unknown>>;
859
1101
 
860
1102
  // ---------------------------------------------------------------------------
@@ -862,15 +1104,17 @@ export const FieldTypeEditorModal: ComponentType<Record<string, unknown>>;
862
1104
  // ---------------------------------------------------------------------------
863
1105
 
864
1106
  export interface UseEditorOptions {
865
- /** Starting document; defaults to one empty paragraph. */
866
- doc?: DocumentJSON;
1107
+ /** Starting document; defaults to one empty paragraph. Accepts either the simple format (`SimpleDocument`, what `editor.toJSON()` returns) or the internal engine shape (`DocumentJSON`) — auto-detected. */
1108
+ doc?: DocumentJSON | SimpleDocument;
867
1109
  /** true (default): store is undo/redo-aware (a History instance). false: a plain EditorStore. */
868
1110
  history?: boolean;
869
1111
  /** Stamped as every edit's actorId (History's defaultActorId) -- used by createAutoVersionHistory/VersionHistory for "who changed this", with no separate identity plumbing needed. Ignored when history: false. */
870
1112
  currentUserId?: string | null;
871
- /** Replaces registerBuiltInBlocks for an opt-in subset of block types. */
1113
+ /** Recommended: an array of `defineBlock()` / `defineInline()` results (nesting allowed), e.g. `[...starterKit(), myBlock]`. Passing it turns off automatic built-in registration; `registerBlocks`/`registerInlineTypes`, if also given, still run afterward. */
1114
+ extensions?: ReadonlyArray<Extension | ReadonlyArray<Extension>>;
1115
+ /** Callback form: replaces registerBuiltInBlocks for an opt-in subset of block types. Runs after `extensions` if both are given. */
872
1116
  registerBlocks?: (registry: BlockRegistry) => void;
873
- /** Replaces registerBuiltInInlineTypes for an opt-in subset of inline types. */
1117
+ /** Callback form: replaces registerBuiltInInlineTypes for an opt-in subset of inline types. Runs after `extensions` if both are given. */
874
1118
  registerInlineTypes?: (inlineRegistry: InlineRegistry) => void;
875
1119
  }
876
1120
 
@@ -878,6 +1122,10 @@ export interface UseEditorResult {
878
1122
  store: History | EditorStore;
879
1123
  registry: BlockRegistry;
880
1124
  inlineRegistry: InlineRegistry;
1125
+ /** The flattened `extensions` list, forwarded to `<NoteloomEditor>` for the behavior half. */
1126
+ extensions: Extension[];
1127
+ /** Read the live document out. `'simple'` (default) → `SimpleDocument`; `'internal'` → `DocumentJSON`. */
1128
+ toJSON(options?: { format?: 'simple' | 'internal' }): SimpleDocument | DocumentJSON;
881
1129
  }
882
1130
 
883
1131
  /** The one-call path to a working editor — see the README's Quick start. */
@@ -896,7 +1144,10 @@ export interface NoteloomEditorProps {
896
1144
  /** Renders CommentsPanel (right-side, Notion/Google Docs-style thread list) automatically. */
897
1145
  showCommentsPanel?: boolean;
898
1146
  /** Sends a picked/dropped EmbedBlock file somewhere real (local disk, S3, any other cloud storage) instead of inlining it as a data: URL -- see useFileUpload's own doc comment for the full contract. */
899
- uploadFile?: (file: File, ctx: { kind: 'image' | 'video' | 'audio' | 'file' }) => Promise<{ src: string; name?: string; mimeType?: string }>;
1147
+ uploadFile?: (
1148
+ file: File,
1149
+ ctx: { kind: 'image' | 'video' | 'audio' | 'file' },
1150
+ ) => Promise<{ src: string; name?: string; mimeType?: string }>;
900
1151
  /** Byte cap for the in-document data: URL fallback ONLY (no effect once uploadFile is configured). */
901
1152
  maxFileSize?: number;
902
1153
  children?: ReactNode;
@@ -904,3 +1155,91 @@ export interface NoteloomEditorProps {
904
1155
 
905
1156
  /** Renders the object useEditor() returned, with every built-in interaction wired up. */
906
1157
  export function NoteloomEditor(props: NoteloomEditorProps): ReactElement;
1158
+
1159
+ export interface FindMatch {
1160
+ blockId: string;
1161
+ runId: string;
1162
+ offset: number;
1163
+ length: number;
1164
+ }
1165
+
1166
+ /** Finds every occurrence of `query` in the document, in reading order — single-run matches only (see the implementation's own doc comment for scope). */
1167
+ export function findMatches(
1168
+ store: EditorStore | History,
1169
+ query: string,
1170
+ options?: { caseSensitive?: boolean; wholeWord?: boolean },
1171
+ ): FindMatch[];
1172
+ /** Replaces one match's own slice of its run's text, one atomic write. */
1173
+ export function replaceMatch(
1174
+ store: EditorStore | History,
1175
+ match: FindMatch,
1176
+ replacement: string,
1177
+ ): void;
1178
+ /** Replaces every given match, one write per affected run, one atomic undo step. */
1179
+ export function replaceAllMatches(
1180
+ store: EditorStore | History,
1181
+ matches: FindMatch[],
1182
+ replacement: string,
1183
+ ): void;
1184
+
1185
+ export interface UseFindInDocumentResult {
1186
+ isOpen: boolean;
1187
+ open: () => void;
1188
+ close: () => void;
1189
+ query: string;
1190
+ setQuery: (value: string) => void;
1191
+ caseSensitive: boolean;
1192
+ setCaseSensitive: (value: boolean) => void;
1193
+ wholeWord: boolean;
1194
+ setWholeWord: (value: boolean) => void;
1195
+ isReplaceOpen: boolean;
1196
+ setIsReplaceOpen: (value: boolean) => void;
1197
+ replacement: string;
1198
+ setReplacement: (value: string) => void;
1199
+ matches: FindMatch[];
1200
+ currentIndex: number;
1201
+ next: () => void;
1202
+ prev: () => void;
1203
+ replaceCurrent: () => void;
1204
+ replaceAll: () => void;
1205
+ queryInputRef: RefObject<HTMLInputElement | null>;
1206
+ }
1207
+
1208
+ /** Ctrl/Cmd+F (while `containerRef` has focus) find/replace — see NoteloomEditor's own doc comment for scope. Pair with `<FindBar>`, or build custom chrome off this hook's returned state/actions directly. */
1209
+ export function useFindInDocument(
1210
+ containerRef: RefObject<HTMLElement | null>,
1211
+ ): UseFindInDocumentResult;
1212
+ export function FindBar(props: UseFindInDocumentResult): ReactElement | null;
1213
+
1214
+ // ---------------------------------------------------------------------------
1215
+ // people/people.js, react/usePeople.js — a document's own people list
1216
+ // ---------------------------------------------------------------------------
1217
+
1218
+ export interface Person {
1219
+ id: string;
1220
+ name: string;
1221
+ color?: string;
1222
+ [key: string]: unknown;
1223
+ }
1224
+
1225
+ export function addPerson(
1226
+ store: EditorStore | History,
1227
+ person: { name: string; color?: string },
1228
+ ): string;
1229
+ export function updatePerson(
1230
+ store: EditorStore | History,
1231
+ id: string,
1232
+ patch: Partial<Person>,
1233
+ ): void;
1234
+ export function removePerson(store: EditorStore | History, id: string): void;
1235
+ /** Reactive view of the document's `people` collection. */
1236
+ export function usePeople(): Person[];
1237
+
1238
+ // ---------------------------------------------------------------------------
1239
+ // react/useSmartQuotes.js, react/useAutoPairBrackets.js — optional typing behaviors
1240
+ // ---------------------------------------------------------------------------
1241
+
1242
+ /** Straight `"`/`'` typed while composing becomes the contextually correct curly quote (one char in, one out). */
1243
+ export function useSmartQuotes(): void;
1244
+ /** Typing `(`/`[`/`{` inserts the matching closer and puts the caret between them; excludes quotes (that's `useSmartQuotes`). Off inside `code` blocks. */
1245
+ export function useAutoPairBrackets(): void;