@notectl/core 0.0.2 → 0.0.6

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.
@@ -1,1090 +0,0 @@
1
- /**
2
- * Apply or remove a mark across a range
3
- */
4
- export declare interface ApplyMarkOp extends BaseOperation {
5
- op: 'apply_mark';
6
- range: Range_2;
7
- mark: Mark;
8
- add: boolean;
9
- }
10
-
11
- /**
12
- * Attribute specification
13
- */
14
- export declare interface AttributeSpec {
15
- default?: unknown;
16
- validate?: (value: unknown) => boolean;
17
- required?: boolean;
18
- }
19
-
20
- /**
21
- * Base operation interface
22
- */
23
- declare interface BaseOperation {
24
- op: string;
25
- }
26
-
27
- /**
28
- * Base plugin class for convenience
29
- */
30
- export declare abstract class BasePlugin implements Plugin_2 {
31
- abstract id: string;
32
- abstract name: string;
33
- abstract version: string;
34
- dependencies?: string[];
35
- protected context?: PluginContext;
36
- init(context: PluginContext): Promise<void>;
37
- destroy(): Promise<void>;
38
- protected getContext(): PluginContext;
39
- }
40
-
41
- /**
42
- * Block node attributes
43
- */
44
- export declare interface BlockAttrs {
45
- align?: 'left' | 'center' | 'right' | 'justify';
46
- level?: number;
47
- alt?: string;
48
- src?: string;
49
- decorative?: boolean;
50
- dir?: 'ltr' | 'rtl' | 'auto';
51
- locale?: string;
52
- [key: string]: unknown;
53
- }
54
-
55
- /**
56
- * Core type definitions for Notectl editor
57
- */
58
- /**
59
- * Unique identifier for blocks (UUID/ULID)
60
- */
61
- export declare type BlockId = string;
62
-
63
- /**
64
- * Block node (structural element)
65
- */
66
- export declare interface BlockNode {
67
- id: BlockId;
68
- type: NodeType;
69
- attrs?: BlockAttrs;
70
- children?: Node_2[];
71
- }
72
-
73
- /**
74
- * Check if two deltas can be safely composed
75
- */
76
- export declare function canCompose(deltaA: Delta, deltaB: Delta): boolean;
77
-
78
- /**
79
- * Command handler function
80
- */
81
- export declare type CommandHandler = (...args: unknown[]) => unknown;
82
-
83
- /**
84
- * Compose two deltas into a single delta
85
- * Applies deltaB after deltaA
86
- */
87
- export declare function composeDelta(deltaA: Delta, deltaB: Delta): Delta;
88
-
89
- /**
90
- * Compute inverse operations for undo
91
- * This is a simplified implementation - full implementation would inspect document state
92
- */
93
- export declare function computeInverse(delta: Delta): Operation[];
94
-
95
- /**
96
- * Create default Notectl schema
97
- */
98
- export declare function createDefaultSchema(): Schema;
99
-
100
- /**
101
- * Utility function to create a delta builder
102
- */
103
- export declare function createDelta(clientId: string, baseVersion: number): DeltaBuilder;
104
-
105
- export declare function createEditor(container: HTMLElement, config?: EditorConfig): NotectlEditor;
106
-
107
- /**
108
- * Create a node factory with the given schema
109
- */
110
- export declare function createNodeFactory(schema: Schema): NodeFactory;
111
-
112
- /**
113
- * Delete a block
114
- */
115
- export declare interface DeleteBlockOp extends BaseOperation {
116
- op: 'delete_block';
117
- target: {
118
- blockId: BlockId;
119
- };
120
- }
121
-
122
- /**
123
- * Delete text across a range
124
- */
125
- export declare interface DeleteRangeOp extends BaseOperation {
126
- op: 'delete_range';
127
- range: Range_2;
128
- }
129
-
130
- /**
131
- * Delta envelope containing operations and metadata
132
- */
133
- export declare interface Delta {
134
- txnId: string;
135
- clientId: string;
136
- timestamp: string;
137
- baseVersion: number;
138
- ltime: number;
139
- intent: 'edit' | 'comment' | 'format' | 'import' | string;
140
- undoGroup?: string;
141
- ops: Operation[];
142
- inverseOps?: Operation[];
143
- validation?: DeltaValidation;
144
- }
145
-
146
- /**
147
- * Delta class for creating and managing deltas
148
- */
149
- export declare class DeltaBuilder {
150
- private delta;
151
- private operations;
152
- constructor(clientId: string, baseVersion: number);
153
- /**
154
- * Set the intent of this delta
155
- */
156
- setIntent(intent: Delta['intent']): this;
157
- /**
158
- * Set the undo group for batch operations
159
- */
160
- setUndoGroup(group: string): this;
161
- /**
162
- * Add an operation to this delta
163
- */
164
- addOperation(op: Operation): this;
165
- /**
166
- * Add multiple operations
167
- */
168
- addOperations(ops: Operation[]): this;
169
- /**
170
- * Set inverse operations for fast undo
171
- */
172
- setInverseOps(inverseOps: Operation[]): this;
173
- /**
174
- * Set validation constraints
175
- */
176
- setValidation(validation: DeltaValidation): this;
177
- /**
178
- * Build the final delta
179
- */
180
- build(): Delta;
181
- /**
182
- * Generate a unique transaction ID
183
- */
184
- private generateTxnId;
185
- }
186
-
187
- /**
188
- * Validation metadata for delta
189
- */
190
- export declare interface DeltaValidation {
191
- requiresSchemaVersion: string;
192
- constraints: ValidationConstraint[];
193
- }
194
-
195
- /**
196
- * Document structure
197
- */
198
- declare interface Document_2 {
199
- version: number;
200
- schemaVersion: string;
201
- children: BlockNode[];
202
- }
203
- export { Document_2 as Document }
204
-
205
- /**
206
- * Editor API interface
207
- * Public methods exposed by the NotectlEditor class
208
- */
209
- export declare interface EditorAPI {
210
- configure(config: EditorConfig): void;
211
- getContent(): Document_2 | string;
212
- setContent(content: string, allowHTML?: boolean): void;
213
- getHTML(): string;
214
- setHTML(html: string): void;
215
- getJSON(): Document_2;
216
- setJSON(doc: Document_2): void;
217
- exportHTML(): string;
218
- getState(): unknown;
219
- undo(): void;
220
- redo(): void;
221
- on(event: EditorEvent, callback: EditorEventCallback): void;
222
- off(event: EditorEvent, callback: EditorEventCallback): void;
223
- registerCommand(name: string, handler: (...args: unknown[]) => unknown): void;
224
- executeCommand(name: string, ...args: unknown[]): unknown;
225
- registerPlugin(plugin: unknown): Promise<void>;
226
- unregisterPlugin(pluginId: string): Promise<void>;
227
- focus(): void;
228
- blur(): void;
229
- destroy(): void;
230
- }
231
-
232
- /**
233
- * Editor configuration options
234
- */
235
- export declare interface EditorConfig {
236
- initialContent?: Document_2;
237
- placeholder?: string;
238
- readonly?: boolean;
239
- autofocus?: boolean;
240
- sanitizeHTML?: boolean;
241
- maxHistoryDepth?: number;
242
- [key: string]: unknown;
243
- }
244
-
245
- /**
246
- * Editor event types
247
- */
248
- export declare type EditorEvent = 'change' | 'selection-change' | 'content-change' | 'focus' | 'blur' | 'ready' | 'error' | 'plugin-registered' | 'plugin-unregistered';
249
-
250
- /**
251
- * Editor event callback
252
- */
253
- export declare type EditorEventCallback<T = unknown> = (data: T) => void;
254
-
255
- /**
256
- * Editor state class
257
- */
258
- export declare class EditorState {
259
- private document;
260
- private selection;
261
- private history;
262
- private historyIndex;
263
- private maxHistoryDepth;
264
- readonly schema: Schema;
265
- readonly nodeFactory: NodeFactory;
266
- constructor(initialDoc?: Document_2, schema?: Schema, options?: {
267
- maxHistoryDepth?: number;
268
- });
269
- /**
270
- * Get current document
271
- */
272
- getDocument(): Document_2;
273
- /**
274
- * Get document version
275
- */
276
- getVersion(): number;
277
- /**
278
- * Get current selection
279
- */
280
- getSelection(): Selection_2 | null;
281
- /**
282
- * Set selection
283
- */
284
- setSelection(selection: Selection_2 | null): void;
285
- /**
286
- * Apply a delta to the state
287
- */
288
- applyDelta(delta: Delta): void;
289
- /**
290
- * Apply a single operation
291
- */
292
- private applyOperation;
293
- /**
294
- * Apply insert text operation
295
- */
296
- private applyInsertText;
297
- /**
298
- * Apply delete range operation
299
- */
300
- private applyDeleteRange;
301
- /**
302
- * Apply mark operation
303
- */
304
- private applyMark;
305
- /**
306
- * Apply insert block after operation
307
- */
308
- private applyInsertBlockAfter;
309
- /**
310
- * Apply insert block before operation
311
- */
312
- private applyInsertBlockBefore;
313
- /**
314
- * Apply delete block operation
315
- */
316
- private applyDeleteBlock;
317
- /**
318
- * Apply set attributes operation
319
- */
320
- private applySetAttrs;
321
- /**
322
- * Find a block by ID
323
- */
324
- findBlock(blockId: BlockId): BlockNode | undefined;
325
- /**
326
- * Add delta to history
327
- */
328
- private addToHistory;
329
- /**
330
- * Undo last change
331
- */
332
- canUndo(): boolean;
333
- undo(): Delta | null;
334
- /**
335
- * Redo last undone change
336
- */
337
- canRedo(): boolean;
338
- redo(): Delta | null;
339
- /**
340
- * Export state as JSON
341
- */
342
- toJSON(): Document_2;
343
- /**
344
- * Create state from JSON
345
- */
346
- static fromJSON(json: Document_2, schema?: Schema): EditorState;
347
- }
348
-
349
- /**
350
- * Error response envelope
351
- */
352
- export declare interface ErrorEnvelope {
353
- error: {
354
- code: string;
355
- message: string;
356
- details?: unknown;
357
- };
358
- }
359
-
360
- /**
361
- * Generate a unique block ID
362
- */
363
- export declare function generateBlockId(): BlockId;
364
-
365
- /**
366
- * Insert a block after another block
367
- */
368
- export declare interface InsertBlockAfterOp extends BaseOperation {
369
- op: 'insert_block_after';
370
- after: BlockId;
371
- block: BlockNode;
372
- }
373
-
374
- /**
375
- * Insert a block before another block
376
- */
377
- export declare interface InsertBlockBeforeOp extends BaseOperation {
378
- op: 'insert_block_before';
379
- before: BlockId;
380
- block: BlockNode;
381
- }
382
-
383
- /**
384
- * Insert text at a position
385
- */
386
- export declare interface InsertTextOp extends BaseOperation {
387
- op: 'insert_text';
388
- target: Position;
389
- text: string;
390
- marks?: Mark[];
391
- }
392
-
393
- export declare function isBlockOperation(op: Operation): op is InsertBlockBeforeOp | InsertBlockAfterOp | DeleteBlockOp | SetAttrsOp;
394
-
395
- export declare function isSelectionOperation(op: Operation): op is UpdateSelectionOp;
396
-
397
- export declare function isTableOperation(op: Operation): boolean;
398
-
399
- /**
400
- * Type guard for operation types
401
- */
402
- export declare function isTextOperation(op: Operation): op is InsertTextOp | DeleteRangeOp | ApplyMarkOp;
403
-
404
- /**
405
- * Lift blocks out of their container
406
- */
407
- export declare interface LiftOutOp extends BaseOperation {
408
- op: 'lift_out';
409
- blockIds: BlockId[];
410
- }
411
-
412
- /**
413
- * Text mark (inline formatting)
414
- */
415
- export declare interface Mark {
416
- type: 'bold' | 'italic' | 'underline' | 'strikethrough' | 'code' | 'link' | string;
417
- attrs?: Record<string, unknown>;
418
- }
419
-
420
- /**
421
- * Mark specification in the schema
422
- */
423
- export declare interface MarkSpec {
424
- type: string;
425
- attrs?: Record<string, AttributeSpec>;
426
- inclusive?: boolean;
427
- excludes?: string;
428
- group?: string;
429
- spanning?: boolean;
430
- toDOM?: (mark: Mark) => [string, Record<string, string>];
431
- parseDOM?: Array<{
432
- tag?: string;
433
- style?: string;
434
- attrs?: Record<string, unknown>;
435
- }>;
436
- }
437
-
438
- /**
439
- * Union of all node types
440
- */
441
- declare type Node_2 = TextNode | BlockNode;
442
- export { Node_2 as Node }
443
-
444
- /**
445
- * Node factory for creating valid nodes
446
- */
447
- export declare class NodeFactory {
448
- private schema;
449
- constructor(schema: Schema);
450
- /**
451
- * Create a text node
452
- */
453
- text(text: string, marks?: Mark[]): TextNode;
454
- /**
455
- * Create a paragraph node
456
- */
457
- paragraph(content?: TextNode[], attrs?: BlockAttrs): BlockNode;
458
- /**
459
- * Create a heading node
460
- */
461
- heading(level: number, content?: TextNode[], attrs?: BlockAttrs): BlockNode;
462
- /**
463
- * Create a list node
464
- */
465
- list(items: BlockNode[], attrs?: BlockAttrs): BlockNode;
466
- /**
467
- * Create a list item node
468
- */
469
- listItem(content: BlockNode[], attrs?: BlockAttrs): BlockNode;
470
- /**
471
- * Create a table node
472
- */
473
- table(rows: BlockNode[], attrs?: BlockAttrs): BlockNode;
474
- /**
475
- * Create a table row node
476
- */
477
- tableRow(cells: BlockNode[], attrs?: BlockAttrs): BlockNode;
478
- /**
479
- * Create a table cell node
480
- */
481
- tableCell(content: BlockNode[], attrs?: BlockAttrs): BlockNode;
482
- /**
483
- * Create an image node
484
- */
485
- image(src: string, alt?: string, attrs?: BlockAttrs): BlockNode;
486
- /**
487
- * Create a code block node
488
- */
489
- codeBlock(content: string, attrs?: BlockAttrs): BlockNode;
490
- /**
491
- * Create a generic block node
492
- */
493
- block(type: NodeType, attrs?: BlockAttrs, children?: (TextNode | BlockNode)[]): BlockNode;
494
- /**
495
- * Create a mark
496
- */
497
- mark(type: string, attrs?: Record<string, unknown>): Mark;
498
- /**
499
- * Clone a node with new children
500
- */
501
- cloneNode(node: BlockNode, children?: (TextNode | BlockNode)[]): BlockNode;
502
- }
503
-
504
- /**
505
- * Node specification in the schema
506
- */
507
- export declare interface NodeSpec {
508
- type: NodeType;
509
- group?: 'block' | 'inline' | 'table';
510
- content?: string;
511
- marks?: string;
512
- attrs?: Record<string, AttributeSpec>;
513
- defining?: boolean;
514
- isolating?: boolean;
515
- toDOM?: (node: Node_2) => HTMLElement | [string, Record<string, string>, ...unknown[]];
516
- parseDOM?: Array<{
517
- tag?: string;
518
- attrs?: Record<string, unknown>;
519
- }>;
520
- }
521
-
522
- /**
523
- * Node types in the document
524
- */
525
- export declare type NodeType = 'text' | 'paragraph' | 'heading' | 'list' | 'list_item' | 'table' | 'table_row' | 'table_cell' | 'image' | 'code_block' | string;
526
-
527
- /**
528
- * NotectlEditor custom element
529
- */
530
- export declare class NotectlEditor extends HTMLElement {
531
- private state;
532
- private pluginManager;
533
- private eventListeners;
534
- private commands;
535
- private contentElement;
536
- private pluginContainerTop;
537
- private pluginContainerBottom;
538
- private config;
539
- private keyboardShortcutCleanup?;
540
- private ariaLiveRegion;
541
- constructor();
542
- /**
543
- * Observed attributes for the web component
544
- */
545
- static get observedAttributes(): string[];
546
- /**
547
- * Called when element is connected to DOM
548
- */
549
- connectedCallback(): void;
550
- /**
551
- * Called when element is disconnected from DOM
552
- */
553
- disconnectedCallback(): void;
554
- /**
555
- * Called when attributes change
556
- */
557
- attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
558
- /**
559
- * Render the editor UI
560
- */
561
- private render;
562
- /**
563
- * Render document content
564
- */
565
- private renderContent;
566
- /**
567
- * Convert document to HTML
568
- */
569
- private documentToHTML;
570
- /**
571
- * Convert block to HTML (simplified)
572
- */
573
- private blockToHTML;
574
- /**
575
- * Convert children to HTML
576
- */
577
- private childrenToHTML;
578
- /**
579
- * Apply mark as HTML
580
- */
581
- private applyMarkHTML;
582
- /**
583
- * Escape HTML
584
- */
585
- private escapeHTML;
586
- /**
587
- * Setup accessibility features
588
- */
589
- private setupAccessibility;
590
- /**
591
- * Setup keyboard shortcuts with screen reader announcements
592
- */
593
- private setupKeyboardShortcuts;
594
- /**
595
- * Toggle formatting
596
- */
597
- private toggleFormat;
598
- /**
599
- * Insert table at current selection
600
- */
601
- insertTable(rows?: number, cols?: number): void;
602
- /**
603
- * Announce message to screen readers
604
- */
605
- private announceToScreenReader;
606
- /**
607
- * Attach event listeners
608
- */
609
- private attachEventListeners;
610
- /**
611
- * Detach event listeners
612
- */
613
- private detachEventListeners;
614
- /**
615
- * Handle input event
616
- */
617
- private handleInput;
618
- /**
619
- * Handle keydown event
620
- */
621
- private handleKeydown;
622
- /**
623
- * Handle focus event
624
- */
625
- private handleFocus;
626
- /**
627
- * Handle blur event
628
- */
629
- private handleBlur;
630
- /**
631
- * Update placeholder visibility
632
- */
633
- private updatePlaceholder;
634
- /**
635
- * Sync content from DOM to state
636
- */
637
- private syncContentToState;
638
- /**
639
- * Convert HTML to document structure
640
- */
641
- private htmlToDocument;
642
- /**
643
- * Convert DOM node to block
644
- */
645
- private nodeToBlock;
646
- /**
647
- * Parse children nodes
648
- */
649
- private parseChildren;
650
- /**
651
- * Parse inline element with marks
652
- */
653
- private parseInlineElement;
654
- /**
655
- * Update readonly state
656
- */
657
- private updateReadonly;
658
- /**
659
- * Register a plugin
660
- */
661
- registerPlugin(plugin: Plugin_2): Promise<void>;
662
- /**
663
- * Unregister a plugin
664
- */
665
- unregisterPlugin(pluginId: string): Promise<void>;
666
- /**
667
- * Create plugin context
668
- */
669
- private createPluginContext;
670
- /**
671
- * Apply a delta
672
- */
673
- applyDelta(delta: Delta): void;
674
- /**
675
- * Register event listener
676
- */
677
- on(event: EditorEvent, callback: EditorEventCallback): void;
678
- /**
679
- * Unregister event listener
680
- */
681
- off(event: EditorEvent, callback: EditorEventCallback): void;
682
- /**
683
- * Emit event
684
- */
685
- private emit;
686
- /**
687
- * Register command
688
- */
689
- registerCommand(name: string, handler: CommandHandler): void;
690
- /**
691
- * Execute command
692
- */
693
- executeCommand(name: string, ...args: unknown[]): unknown;
694
- /**
695
- * Undo last change
696
- */
697
- undo(): void;
698
- /**
699
- * Redo last undone change
700
- */
701
- redo(): void;
702
- /**
703
- * Configure editor options
704
- * @param config - Configuration options to apply
705
- */
706
- configure(config: EditorConfig): void;
707
- /**
708
- * Destroy the editor and clean up resources
709
- */
710
- destroy(): void;
711
- /**
712
- * Get current content as string or JSON
713
- * @returns Current document content
714
- */
715
- getContent(): Document_2 | string;
716
- /**
717
- * Get current state
718
- */
719
- getState(): EditorState;
720
- /**
721
- * Get document as JSON
722
- */
723
- getJSON(): Document_2;
724
- /**
725
- * Set document from JSON
726
- */
727
- setJSON(doc: Document_2): void;
728
- /**
729
- * Get HTML content (sanitized)
730
- */
731
- getHTML(): string;
732
- /**
733
- * Set HTML content (with sanitization)
734
- * @param html - HTML content to set
735
- */
736
- setHTML(html: string): void;
737
- /**
738
- * Set content from string (with sanitization)
739
- * @param content - Content to set
740
- * @param allowHTML - Allow HTML tags
741
- */
742
- setContent(content: string, allowHTML?: boolean): void;
743
- /**
744
- * Export HTML content (sanitized)
745
- * @returns Sanitized HTML
746
- */
747
- exportHTML(): string;
748
- /**
749
- * Focus the editor
750
- */
751
- focus(): void;
752
- /**
753
- * Blur the editor
754
- */
755
- blur(): void;
756
- }
757
-
758
- /**
759
- * Union of all operation types
760
- */
761
- export declare type Operation = InsertTextOp | DeleteRangeOp | ApplyMarkOp | InsertBlockBeforeOp | InsertBlockAfterOp | DeleteBlockOp | SetAttrsOp | WrapInOp | LiftOutOp | TableInsertRowOp | TableDeleteRowOp | TableInsertColOp | TableDeleteColOp | TableMergeCellsOp | TableSplitCellOp | UpdateSelectionOp;
762
-
763
- /**
764
- * Plugin interface
765
- */
766
- declare interface Plugin_2 {
767
- /**
768
- * Unique plugin identifier
769
- */
770
- id: string;
771
- /**
772
- * Plugin name
773
- */
774
- name: string;
775
- /**
776
- * Plugin version
777
- */
778
- version: string;
779
- /**
780
- * Plugin dependencies (optional)
781
- */
782
- dependencies?: string[];
783
- /**
784
- * Initialize the plugin
785
- */
786
- init(context: PluginContext): Promise<void> | void;
787
- /**
788
- * Cleanup the plugin
789
- */
790
- destroy?(): Promise<void> | void;
791
- /**
792
- * Handle state updates (optional)
793
- */
794
- onStateUpdate?(oldState: EditorState, newState: EditorState): void;
795
- /**
796
- * Handle delta application (optional)
797
- */
798
- onDeltaApplied?(delta: Delta): void;
799
- }
800
- export { Plugin_2 as Plugin }
801
-
802
- /**
803
- * Plugin context provided to plugins
804
- */
805
- export declare interface PluginContext {
806
- /**
807
- * Get current editor state
808
- */
809
- getState(): EditorState;
810
- /**
811
- * Apply a delta to the editor
812
- */
813
- applyDelta(delta: Delta): void;
814
- /**
815
- * Register event listener
816
- */
817
- on(event: string, callback: (data: unknown) => void): void;
818
- /**
819
- * Unregister event listener
820
- */
821
- off(event: string, callback: (data: unknown) => void): void;
822
- /**
823
- * Emit an event
824
- */
825
- emit(event: string, data?: unknown): void;
826
- /**
827
- * Register a command
828
- */
829
- registerCommand(name: string, handler: CommandHandler): void;
830
- /**
831
- * Execute a command
832
- */
833
- executeCommand(name: string, ...args: unknown[]): unknown;
834
- /**
835
- * Access DOM container (editable area)
836
- */
837
- getContainer(): HTMLElement;
838
- /**
839
- * Access plugin container for UI elements (toolbar, etc.)
840
- * @param position - 'top' or 'bottom'
841
- */
842
- getPluginContainer(position: 'top' | 'bottom'): HTMLElement;
843
- }
844
-
845
- /**
846
- * Plugin factory function type
847
- */
848
- export declare type PluginFactory<TConfig = unknown> = (config?: TConfig) => Plugin_2;
849
-
850
- /**
851
- * Plugin manager class
852
- */
853
- export declare class PluginManager {
854
- private plugins;
855
- private initializationOrder;
856
- constructor();
857
- /**
858
- * Register a plugin
859
- */
860
- register(plugin: Plugin_2, context: PluginContext): Promise<void>;
861
- /**
862
- * Unregister a plugin
863
- */
864
- unregister(pluginId: string, context: PluginContext): Promise<void>;
865
- /**
866
- * Get a plugin by ID
867
- */
868
- get(pluginId: string): Plugin_2 | undefined;
869
- /**
870
- * Check if a plugin is registered
871
- */
872
- has(pluginId: string): boolean;
873
- /**
874
- * Get all registered plugins
875
- */
876
- getAll(): Plugin_2[];
877
- /**
878
- * Notify plugins of state update
879
- */
880
- notifyStateUpdate(oldState: EditorState, newState: EditorState): void;
881
- /**
882
- * Notify plugins of delta application
883
- */
884
- notifyDeltaApplied(delta: Delta): void;
885
- /**
886
- * Destroy all plugins
887
- */
888
- destroyAll(): Promise<void>;
889
- }
890
-
891
- /**
892
- * Text position within a block (code point offset)
893
- */
894
- export declare interface Position {
895
- blockId: BlockId;
896
- offset: number;
897
- }
898
-
899
- /**
900
- * Range of text across blocks
901
- */
902
- declare interface Range_2 {
903
- start: Position;
904
- end: Position;
905
- }
906
- export { Range_2 as Range }
907
-
908
- /**
909
- * Document schema
910
- */
911
- export declare class Schema {
912
- nodes: Map<NodeType, NodeSpec>;
913
- marks: Map<string, MarkSpec>;
914
- topNode: NodeType;
915
- constructor(config: {
916
- nodes: NodeSpec[];
917
- marks: MarkSpec[];
918
- topNode?: NodeType;
919
- });
920
- /**
921
- * Get node specification
922
- */
923
- node(type: NodeType): NodeSpec | undefined;
924
- /**
925
- * Get mark specification
926
- */
927
- mark(type: string): MarkSpec | undefined;
928
- /**
929
- * Validate if a node conforms to the schema
930
- */
931
- validateNode(node: Node_2): {
932
- valid: boolean;
933
- errors: string[];
934
- };
935
- /**
936
- * Check if a mark is allowed on a node
937
- */
938
- markAllowedOn(markType: string, nodeType: NodeType): boolean;
939
- /**
940
- * Check if two marks can coexist
941
- */
942
- marksCompatible(markA: string, markB: string): boolean;
943
- }
944
-
945
- /**
946
- * Selection state
947
- */
948
- declare interface Selection_2 {
949
- anchor: Position;
950
- head: Position;
951
- }
952
- export { Selection_2 as Selection }
953
-
954
- /**
955
- * Set attributes on a block
956
- */
957
- export declare interface SetAttrsOp extends BaseOperation {
958
- op: 'set_attrs';
959
- target: {
960
- blockId: BlockId;
961
- };
962
- attrs: BlockAttrs;
963
- }
964
-
965
- /**
966
- * Table operation: delete column
967
- */
968
- export declare interface TableDeleteColOp extends BaseOperation {
969
- op: 'table_delete_col';
970
- target: {
971
- tableId: BlockId;
972
- colIndex: number;
973
- };
974
- }
975
-
976
- /**
977
- * Table operation: delete row
978
- */
979
- export declare interface TableDeleteRowOp extends BaseOperation {
980
- op: 'table_delete_row';
981
- target: {
982
- tableId: BlockId;
983
- rowIndex: number;
984
- };
985
- }
986
-
987
- /**
988
- * Table operation: insert column
989
- */
990
- export declare interface TableInsertColOp extends BaseOperation {
991
- op: 'table_insert_col';
992
- target: {
993
- tableId: BlockId;
994
- colIndex: number;
995
- };
996
- }
997
-
998
- /**
999
- * Table operation: insert row
1000
- */
1001
- export declare interface TableInsertRowOp extends BaseOperation {
1002
- op: 'table_insert_row';
1003
- target: {
1004
- tableId: BlockId;
1005
- rowIndex: number;
1006
- };
1007
- row: BlockNode;
1008
- }
1009
-
1010
- /**
1011
- * Table operation: merge cells
1012
- */
1013
- export declare interface TableMergeCellsOp extends BaseOperation {
1014
- op: 'table_merge_cells';
1015
- target: {
1016
- tableId: BlockId;
1017
- cells: BlockId[];
1018
- };
1019
- }
1020
-
1021
- /**
1022
- * Table operation: split cell
1023
- */
1024
- export declare interface TableSplitCellOp extends BaseOperation {
1025
- op: 'table_split_cell';
1026
- target: {
1027
- tableId: BlockId;
1028
- cellId: BlockId;
1029
- };
1030
- }
1031
-
1032
- /**
1033
- * Text node
1034
- */
1035
- export declare interface TextNode {
1036
- type: 'text';
1037
- text: string;
1038
- marks?: Mark[];
1039
- }
1040
-
1041
- /**
1042
- * Transform a delta against another delta
1043
- * Returns transformed version of deltaA that can be applied after deltaB
1044
- */
1045
- export declare function transformDelta(deltaA: Delta, deltaB: Delta, side?: 'left' | 'right'): Delta;
1046
-
1047
- /**
1048
- * Transform operation A against operation B
1049
- * Returns transformed version of A that can be applied after B
1050
- */
1051
- export declare function transformOperation(opA: Operation, opB: Operation, side: 'left' | 'right'): Operation;
1052
-
1053
- /**
1054
- * Update selection/cursor
1055
- */
1056
- export declare interface UpdateSelectionOp extends BaseOperation {
1057
- op: 'update_selection';
1058
- actorId: string;
1059
- selection: {
1060
- anchor: Position;
1061
- head: Position;
1062
- };
1063
- }
1064
-
1065
- /**
1066
- * Validate a delta against constraints
1067
- */
1068
- export declare function validateDelta(delta: Delta): {
1069
- valid: boolean;
1070
- errors: string[];
1071
- };
1072
-
1073
- /**
1074
- * Validation constraint types
1075
- */
1076
- export declare type ValidationConstraint = 'noDanglingRefs' | 'tableGridConsistent' | 'altOrDecorative' | 'rtlIntegrity' | string;
1077
-
1078
- export declare const VERSION = "0.0.1";
1079
-
1080
- /**
1081
- * Wrap blocks in a container
1082
- */
1083
- export declare interface WrapInOp extends BaseOperation {
1084
- op: 'wrap_in';
1085
- blockIds: BlockId[];
1086
- wrapperType: string;
1087
- wrapperAttrs?: BlockAttrs;
1088
- }
1089
-
1090
- export { }