@notectl/core 0.0.5 → 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.
- package/dist/index.d.ts +1816 -0
- package/dist/notectl-core.js +1046 -2792
- package/dist/notectl-core.js.map +1 -1
- package/dist/notectl-core.mjs +7886 -0
- package/dist/notectl-core.mjs.map +1 -0
- package/package.json +31 -55
- package/dist/notectl-core.umd.cjs +0 -117
- package/dist/notectl-core.umd.cjs.map +0 -1
- package/dist/types/index.d.ts +0 -1469
package/dist/types/index.d.ts
DELETED
|
@@ -1,1469 +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
|
-
* Default timeout for screen reader announcements
|
|
13
|
-
* Used to clear and reset the aria-live region
|
|
14
|
-
*/
|
|
15
|
-
export declare const ARIA_ANNOUNCEMENT_DELAY = 100;
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Attribute specification
|
|
19
|
-
*/
|
|
20
|
-
export declare interface AttributeSpec {
|
|
21
|
-
default?: unknown;
|
|
22
|
-
validate?: (value: unknown) => boolean;
|
|
23
|
-
required?: boolean;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Base operation interface
|
|
28
|
-
*/
|
|
29
|
-
declare interface BaseOperation {
|
|
30
|
-
op: string;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Base plugin class for convenience
|
|
35
|
-
*/
|
|
36
|
-
export declare abstract class BasePlugin implements Plugin_2 {
|
|
37
|
-
abstract id: string;
|
|
38
|
-
abstract name: string;
|
|
39
|
-
abstract version: string;
|
|
40
|
-
dependencies?: string[];
|
|
41
|
-
protected context?: PluginContext;
|
|
42
|
-
init(context: PluginContext): Promise<void>;
|
|
43
|
-
destroy(): Promise<void>;
|
|
44
|
-
protected getContext(): PluginContext;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Block node attributes
|
|
49
|
-
*/
|
|
50
|
-
export declare interface BlockAttrs {
|
|
51
|
-
align?: 'left' | 'center' | 'right' | 'justify';
|
|
52
|
-
level?: number;
|
|
53
|
-
alt?: string;
|
|
54
|
-
src?: string;
|
|
55
|
-
decorative?: boolean;
|
|
56
|
-
dir?: 'ltr' | 'rtl' | 'auto';
|
|
57
|
-
locale?: string;
|
|
58
|
-
[key: string]: unknown;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Block type utilities
|
|
63
|
-
*/
|
|
64
|
-
export declare interface BlockHelpers {
|
|
65
|
-
/**
|
|
66
|
-
* Check if a node is a text node
|
|
67
|
-
*/
|
|
68
|
-
isTextNode(node: Node_2): node is TextNode;
|
|
69
|
-
/**
|
|
70
|
-
* Check if a node is a block node
|
|
71
|
-
*/
|
|
72
|
-
isBlockNode(node: Node_2): node is BlockNode;
|
|
73
|
-
/**
|
|
74
|
-
* Get all text content from a block
|
|
75
|
-
*/
|
|
76
|
-
getTextContent(block: BlockNode): string;
|
|
77
|
-
/**
|
|
78
|
-
* Check if block is empty
|
|
79
|
-
*/
|
|
80
|
-
isEmpty(block: BlockNode): boolean;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Block helper implementation
|
|
85
|
-
*/
|
|
86
|
-
export declare const blockHelpers: BlockHelpers;
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Core type definitions for Notectl editor
|
|
90
|
-
*/
|
|
91
|
-
/**
|
|
92
|
-
* Unique identifier for blocks (UUID/ULID)
|
|
93
|
-
*/
|
|
94
|
-
export declare type BlockId = string;
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Block node (structural element)
|
|
98
|
-
*/
|
|
99
|
-
export declare interface BlockNode {
|
|
100
|
-
id: BlockId;
|
|
101
|
-
type: NodeType;
|
|
102
|
-
attrs?: BlockAttrs;
|
|
103
|
-
children?: Node_2[];
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Check if two deltas can be safely composed
|
|
108
|
-
*/
|
|
109
|
-
export declare function canCompose(deltaA: Delta, deltaB: Delta): boolean;
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Command definition with type safety
|
|
113
|
-
*/
|
|
114
|
-
export declare interface CommandDefinition<TArgs extends unknown[] = unknown[], TReturn = unknown> {
|
|
115
|
-
name: string;
|
|
116
|
-
description?: string;
|
|
117
|
-
handler: CommandHandler_2<TArgs, TReturn>;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Command handler function
|
|
122
|
-
*/
|
|
123
|
-
export declare type CommandHandler = (...args: unknown[]) => unknown;
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Command handler function signature
|
|
127
|
-
*/
|
|
128
|
-
declare type CommandHandler_2<TArgs extends unknown[] = unknown[], TReturn = unknown> = (...args: TArgs) => TReturn | Promise<TReturn>;
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* Built-in command registry
|
|
132
|
-
* Maps command names to their handlers
|
|
133
|
-
*/
|
|
134
|
-
export declare interface CommandRegistry {
|
|
135
|
-
[key: string]: CommandHandler_2<unknown[], unknown>;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* Compose two deltas into a single delta
|
|
140
|
-
* Applies deltaB after deltaA
|
|
141
|
-
*/
|
|
142
|
-
export declare function composeDelta(deltaA: Delta, deltaB: Delta): Delta;
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* Compute inverse operations for undo
|
|
146
|
-
* This is a simplified implementation - full implementation would inspect document state
|
|
147
|
-
*/
|
|
148
|
-
export declare function computeInverse(delta: Delta): Operation[];
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* Create default Notectl schema
|
|
152
|
-
*/
|
|
153
|
-
export declare function createDefaultSchema(): Schema;
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* Utility function to create a delta builder
|
|
157
|
-
*/
|
|
158
|
-
export declare function createDelta(clientId: string, baseVersion: number): DeltaBuilder;
|
|
159
|
-
|
|
160
|
-
export declare function createEditor(container: HTMLElement, config?: EditorConfig): NotectlEditor;
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* Create a node factory with the given schema
|
|
164
|
-
*/
|
|
165
|
-
export declare function createNodeFactory(schema: Schema): NodeFactory;
|
|
166
|
-
|
|
167
|
-
/**
|
|
168
|
-
* Default maximum number of history entries to keep
|
|
169
|
-
*/
|
|
170
|
-
export declare const DEFAULT_MAX_HISTORY_DEPTH = 100;
|
|
171
|
-
|
|
172
|
-
/**
|
|
173
|
-
* Default minimum height for the editor content area
|
|
174
|
-
*/
|
|
175
|
-
export declare const DEFAULT_MIN_HEIGHT = 200;
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
* Delete a block
|
|
179
|
-
*/
|
|
180
|
-
export declare interface DeleteBlockOp extends BaseOperation {
|
|
181
|
-
op: 'delete_block';
|
|
182
|
-
target: {
|
|
183
|
-
blockId: BlockId;
|
|
184
|
-
};
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
* Delete text across a range
|
|
189
|
-
*/
|
|
190
|
-
export declare interface DeleteRangeOp extends BaseOperation {
|
|
191
|
-
op: 'delete_range';
|
|
192
|
-
range: Range_2;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* Delta envelope containing operations and metadata
|
|
197
|
-
*/
|
|
198
|
-
export declare interface Delta {
|
|
199
|
-
txnId: string;
|
|
200
|
-
clientId: string;
|
|
201
|
-
timestamp: string;
|
|
202
|
-
baseVersion: number;
|
|
203
|
-
ltime: number;
|
|
204
|
-
intent: 'edit' | 'comment' | 'format' | 'import' | string;
|
|
205
|
-
undoGroup?: string;
|
|
206
|
-
ops: Operation[];
|
|
207
|
-
inverseOps?: Operation[];
|
|
208
|
-
validation?: DeltaValidation;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
/**
|
|
212
|
-
* Delta class for creating and managing deltas
|
|
213
|
-
*/
|
|
214
|
-
export declare class DeltaBuilder {
|
|
215
|
-
private delta;
|
|
216
|
-
private operations;
|
|
217
|
-
constructor(clientId: string, baseVersion: number);
|
|
218
|
-
/**
|
|
219
|
-
* Set the intent of this delta
|
|
220
|
-
*/
|
|
221
|
-
setIntent(intent: Delta['intent']): this;
|
|
222
|
-
/**
|
|
223
|
-
* Set the undo group for batch operations
|
|
224
|
-
*/
|
|
225
|
-
setUndoGroup(group: string): this;
|
|
226
|
-
/**
|
|
227
|
-
* Add an operation to this delta
|
|
228
|
-
*/
|
|
229
|
-
addOperation(op: Operation): this;
|
|
230
|
-
/**
|
|
231
|
-
* Add multiple operations
|
|
232
|
-
*/
|
|
233
|
-
addOperations(ops: Operation[]): this;
|
|
234
|
-
/**
|
|
235
|
-
* Set inverse operations for fast undo
|
|
236
|
-
*/
|
|
237
|
-
setInverseOps(inverseOps: Operation[]): this;
|
|
238
|
-
/**
|
|
239
|
-
* Set validation constraints
|
|
240
|
-
*/
|
|
241
|
-
setValidation(validation: DeltaValidation): this;
|
|
242
|
-
/**
|
|
243
|
-
* Build the final delta
|
|
244
|
-
*/
|
|
245
|
-
build(): Delta;
|
|
246
|
-
/**
|
|
247
|
-
* Generate a unique transaction ID
|
|
248
|
-
*/
|
|
249
|
-
private generateTxnId;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
/**
|
|
253
|
-
* Validation metadata for delta
|
|
254
|
-
*/
|
|
255
|
-
export declare interface DeltaValidation {
|
|
256
|
-
requiresSchemaVersion: string;
|
|
257
|
-
constraints: ValidationConstraint[];
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
/**
|
|
261
|
-
* Document structure
|
|
262
|
-
*/
|
|
263
|
-
declare interface Document_2 {
|
|
264
|
-
version: number;
|
|
265
|
-
schemaVersion: string;
|
|
266
|
-
children: BlockNode[];
|
|
267
|
-
}
|
|
268
|
-
export { Document_2 as Document }
|
|
269
|
-
|
|
270
|
-
/**
|
|
271
|
-
* Timeout in milliseconds to wait for editor's connectedCallback to complete
|
|
272
|
-
* and render the DOM structure including plugin containers.
|
|
273
|
-
*
|
|
274
|
-
* This is needed when registering plugins immediately after appending the editor
|
|
275
|
-
* to the DOM, as the connectedCallback runs asynchronously.
|
|
276
|
-
*
|
|
277
|
-
* @example
|
|
278
|
-
* ```typescript
|
|
279
|
-
* const editor = document.createElement('notectl-editor');
|
|
280
|
-
* container.appendChild(editor);
|
|
281
|
-
* await new Promise(resolve => setTimeout(resolve, EDITOR_READY_TIMEOUT));
|
|
282
|
-
* await editor.registerPlugin(new ToolbarPlugin());
|
|
283
|
-
* ```
|
|
284
|
-
*/
|
|
285
|
-
export declare const EDITOR_READY_TIMEOUT = 100;
|
|
286
|
-
|
|
287
|
-
/**
|
|
288
|
-
* Editor API interface
|
|
289
|
-
* Public methods exposed by the NotectlEditor class
|
|
290
|
-
*/
|
|
291
|
-
export declare interface EditorAPI {
|
|
292
|
-
configure(config: EditorConfig): void;
|
|
293
|
-
getContent(): Document_2 | string;
|
|
294
|
-
setContent(content: string, allowHTML?: boolean): void;
|
|
295
|
-
getHTML(): string;
|
|
296
|
-
setHTML(html: string): void;
|
|
297
|
-
getJSON(): Document_2;
|
|
298
|
-
setJSON(doc: Document_2): void;
|
|
299
|
-
exportHTML(): string;
|
|
300
|
-
getState(): unknown;
|
|
301
|
-
undo(): void;
|
|
302
|
-
redo(): void;
|
|
303
|
-
on(event: EditorEvent, callback: EditorEventCallback): void;
|
|
304
|
-
off(event: EditorEvent, callback: EditorEventCallback): void;
|
|
305
|
-
registerCommand(name: string, handler: (...args: unknown[]) => unknown): void;
|
|
306
|
-
executeCommand(name: string, ...args: unknown[]): unknown;
|
|
307
|
-
registerPlugin(plugin: unknown): Promise<void>;
|
|
308
|
-
unregisterPlugin(pluginId: string): Promise<void>;
|
|
309
|
-
focus(): void;
|
|
310
|
-
blur(): void;
|
|
311
|
-
destroy(): void;
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
/**
|
|
315
|
-
* Editor configuration options
|
|
316
|
-
*/
|
|
317
|
-
export declare interface EditorConfig {
|
|
318
|
-
initialContent?: Document_2;
|
|
319
|
-
placeholder?: string;
|
|
320
|
-
readonly?: boolean;
|
|
321
|
-
autofocus?: boolean;
|
|
322
|
-
sanitizeHTML?: boolean;
|
|
323
|
-
maxHistoryDepth?: number;
|
|
324
|
-
content?: string | Document_2;
|
|
325
|
-
[key: string]: unknown;
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
/**
|
|
329
|
-
* Editor event types
|
|
330
|
-
*/
|
|
331
|
-
export declare type EditorEvent = 'change' | 'selection-change' | 'content-change' | 'focus' | 'blur' | 'ready' | 'error' | 'plugin-registered' | 'plugin-unregistered';
|
|
332
|
-
|
|
333
|
-
/**
|
|
334
|
-
* Editor event callback
|
|
335
|
-
*/
|
|
336
|
-
export declare type EditorEventCallback<T = unknown> = (data: T) => void;
|
|
337
|
-
|
|
338
|
-
/**
|
|
339
|
-
* Editor state class
|
|
340
|
-
*/
|
|
341
|
-
export declare class EditorState {
|
|
342
|
-
private document;
|
|
343
|
-
private selection;
|
|
344
|
-
private history;
|
|
345
|
-
private historyIndex;
|
|
346
|
-
private maxHistoryDepth;
|
|
347
|
-
readonly schema: Schema;
|
|
348
|
-
readonly nodeFactory: NodeFactory;
|
|
349
|
-
constructor(initialDoc?: Document_2, schema?: Schema, options?: {
|
|
350
|
-
maxHistoryDepth?: number;
|
|
351
|
-
});
|
|
352
|
-
/**
|
|
353
|
-
* Get current document
|
|
354
|
-
*/
|
|
355
|
-
getDocument(): Document_2;
|
|
356
|
-
/**
|
|
357
|
-
* Get document version
|
|
358
|
-
*/
|
|
359
|
-
getVersion(): number;
|
|
360
|
-
/**
|
|
361
|
-
* Get current selection
|
|
362
|
-
*/
|
|
363
|
-
getSelection(): Selection_2 | null;
|
|
364
|
-
/**
|
|
365
|
-
* Set selection
|
|
366
|
-
*/
|
|
367
|
-
setSelection(selection: Selection_2 | null): void;
|
|
368
|
-
/**
|
|
369
|
-
* Apply a delta to the state
|
|
370
|
-
*/
|
|
371
|
-
applyDelta(delta: Delta): void;
|
|
372
|
-
/**
|
|
373
|
-
* Apply a single operation
|
|
374
|
-
*/
|
|
375
|
-
private applyOperation;
|
|
376
|
-
/**
|
|
377
|
-
* Apply insert text operation
|
|
378
|
-
*/
|
|
379
|
-
private applyInsertText;
|
|
380
|
-
/**
|
|
381
|
-
* Apply delete range operation
|
|
382
|
-
*/
|
|
383
|
-
private applyDeleteRange;
|
|
384
|
-
/**
|
|
385
|
-
* Apply mark operation
|
|
386
|
-
*/
|
|
387
|
-
private applyMark;
|
|
388
|
-
/**
|
|
389
|
-
* Apply insert block after operation
|
|
390
|
-
*/
|
|
391
|
-
private applyInsertBlockAfter;
|
|
392
|
-
/**
|
|
393
|
-
* Apply insert block before operation
|
|
394
|
-
*/
|
|
395
|
-
private applyInsertBlockBefore;
|
|
396
|
-
/**
|
|
397
|
-
* Apply delete block operation
|
|
398
|
-
*/
|
|
399
|
-
private applyDeleteBlock;
|
|
400
|
-
/**
|
|
401
|
-
* Apply set attributes operation
|
|
402
|
-
*/
|
|
403
|
-
private applySetAttrs;
|
|
404
|
-
/**
|
|
405
|
-
* Find a block by ID
|
|
406
|
-
*/
|
|
407
|
-
findBlock(blockId: BlockId): BlockNode | undefined;
|
|
408
|
-
/**
|
|
409
|
-
* Add delta to history
|
|
410
|
-
*/
|
|
411
|
-
private addToHistory;
|
|
412
|
-
/**
|
|
413
|
-
* Undo last change
|
|
414
|
-
*/
|
|
415
|
-
canUndo(): boolean;
|
|
416
|
-
undo(): Delta | null;
|
|
417
|
-
/**
|
|
418
|
-
* Redo last undone change
|
|
419
|
-
*/
|
|
420
|
-
canRedo(): boolean;
|
|
421
|
-
redo(): Delta | null;
|
|
422
|
-
/**
|
|
423
|
-
* Export state as JSON
|
|
424
|
-
*/
|
|
425
|
-
toJSON(): Document_2;
|
|
426
|
-
/**
|
|
427
|
-
* Create state from JSON
|
|
428
|
-
*/
|
|
429
|
-
static fromJSON(json: Document_2, schema?: Schema): EditorState;
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
/**
|
|
433
|
-
* Type for error codes
|
|
434
|
-
*/
|
|
435
|
-
export declare type ErrorCode = typeof ErrorCodes[keyof typeof ErrorCodes];
|
|
436
|
-
|
|
437
|
-
/**
|
|
438
|
-
* Error codes for structured error handling
|
|
439
|
-
*/
|
|
440
|
-
export declare const ErrorCodes: {
|
|
441
|
-
readonly PLUGIN_ALREADY_REGISTERED: "PLUGIN_ALREADY_REGISTERED";
|
|
442
|
-
readonly PLUGIN_NOT_FOUND: "PLUGIN_NOT_FOUND";
|
|
443
|
-
readonly PLUGIN_MISSING_DEPENDENCY: "PLUGIN_MISSING_DEPENDENCY";
|
|
444
|
-
readonly PLUGIN_INVALID_CONFIG: "PLUGIN_INVALID_CONFIG";
|
|
445
|
-
readonly PLUGIN_INIT_FAILED: "PLUGIN_INIT_FAILED";
|
|
446
|
-
readonly PLUGIN_DESTROY_FAILED: "PLUGIN_DESTROY_FAILED";
|
|
447
|
-
readonly PLUGIN_DEPENDENCY_CONFLICT: "PLUGIN_DEPENDENCY_CONFLICT";
|
|
448
|
-
readonly EDITOR_NOT_MOUNTED: "EDITOR_NOT_MOUNTED";
|
|
449
|
-
readonly EDITOR_NOT_INITIALIZED: "EDITOR_NOT_INITIALIZED";
|
|
450
|
-
readonly EDITOR_DESTROYED: "EDITOR_DESTROYED";
|
|
451
|
-
readonly COMMAND_NOT_FOUND: "COMMAND_NOT_FOUND";
|
|
452
|
-
readonly COMMAND_ALREADY_REGISTERED: "COMMAND_ALREADY_REGISTERED";
|
|
453
|
-
readonly COMMAND_EXECUTION_FAILED: "COMMAND_EXECUTION_FAILED";
|
|
454
|
-
readonly COMMAND_INVALID_ARGS: "COMMAND_INVALID_ARGS";
|
|
455
|
-
readonly INVALID_CONTENT: "INVALID_CONTENT";
|
|
456
|
-
readonly INVALID_DELTA: "INVALID_DELTA";
|
|
457
|
-
readonly INVALID_DOCUMENT: "INVALID_DOCUMENT";
|
|
458
|
-
readonly SANITIZATION_FAILED: "SANITIZATION_FAILED";
|
|
459
|
-
readonly XSS_DETECTED: "XSS_DETECTED";
|
|
460
|
-
readonly UNSAFE_OPERATION: "UNSAFE_OPERATION";
|
|
461
|
-
readonly INVALID_OPERATION: "INVALID_OPERATION";
|
|
462
|
-
readonly INTERNAL_ERROR: "INTERNAL_ERROR";
|
|
463
|
-
};
|
|
464
|
-
|
|
465
|
-
/**
|
|
466
|
-
* Error response envelope
|
|
467
|
-
*/
|
|
468
|
-
export declare interface ErrorEnvelope {
|
|
469
|
-
error: {
|
|
470
|
-
code: string;
|
|
471
|
-
message: string;
|
|
472
|
-
details?: unknown;
|
|
473
|
-
};
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
/**
|
|
477
|
-
* Generate a unique block ID
|
|
478
|
-
*/
|
|
479
|
-
export declare function generateBlockId(): BlockId;
|
|
480
|
-
|
|
481
|
-
/**
|
|
482
|
-
* Insert a block after another block
|
|
483
|
-
*/
|
|
484
|
-
export declare interface InsertBlockAfterOp extends BaseOperation {
|
|
485
|
-
op: 'insert_block_after';
|
|
486
|
-
after: BlockId;
|
|
487
|
-
block: BlockNode;
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
/**
|
|
491
|
-
* Insert a block before another block
|
|
492
|
-
*/
|
|
493
|
-
export declare interface InsertBlockBeforeOp extends BaseOperation {
|
|
494
|
-
op: 'insert_block_before';
|
|
495
|
-
before: BlockId;
|
|
496
|
-
block: BlockNode;
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
/**
|
|
500
|
-
* Insert text at a position
|
|
501
|
-
*/
|
|
502
|
-
export declare interface InsertTextOp extends BaseOperation {
|
|
503
|
-
op: 'insert_text';
|
|
504
|
-
target: Position;
|
|
505
|
-
text: string;
|
|
506
|
-
marks?: Mark[];
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
export declare function isBlockOperation(op: Operation): op is InsertBlockBeforeOp | InsertBlockAfterOp | DeleteBlockOp | SetAttrsOp;
|
|
510
|
-
|
|
511
|
-
export declare function isSelectionOperation(op: Operation): op is UpdateSelectionOp;
|
|
512
|
-
|
|
513
|
-
export declare function isTableOperation(op: Operation): boolean;
|
|
514
|
-
|
|
515
|
-
/**
|
|
516
|
-
* Type guard for operation types
|
|
517
|
-
*/
|
|
518
|
-
export declare function isTextOperation(op: Operation): op is InsertTextOp | DeleteRangeOp | ApplyMarkOp;
|
|
519
|
-
|
|
520
|
-
/**
|
|
521
|
-
* Lift blocks out of their container
|
|
522
|
-
*/
|
|
523
|
-
export declare interface LiftOutOp extends BaseOperation {
|
|
524
|
-
op: 'lift_out';
|
|
525
|
-
blockIds: BlockId[];
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
/**
|
|
529
|
-
* Text mark (inline formatting)
|
|
530
|
-
*/
|
|
531
|
-
export declare interface Mark {
|
|
532
|
-
type: 'bold' | 'italic' | 'underline' | 'strikethrough' | 'code' | 'link' | string;
|
|
533
|
-
attrs?: Record<string, unknown>;
|
|
534
|
-
}
|
|
535
|
-
|
|
536
|
-
/**
|
|
537
|
-
* Mark specification in the schema
|
|
538
|
-
*/
|
|
539
|
-
export declare interface MarkSpec {
|
|
540
|
-
type: string;
|
|
541
|
-
attrs?: Record<string, AttributeSpec>;
|
|
542
|
-
inclusive?: boolean;
|
|
543
|
-
excludes?: string;
|
|
544
|
-
group?: string;
|
|
545
|
-
spanning?: boolean;
|
|
546
|
-
toDOM?: (mark: Mark) => [string, Record<string, string>];
|
|
547
|
-
parseDOM?: Array<{
|
|
548
|
-
tag?: string;
|
|
549
|
-
style?: string;
|
|
550
|
-
attrs?: Record<string, unknown>;
|
|
551
|
-
}>;
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
/**
|
|
555
|
-
* Union of all node types
|
|
556
|
-
*/
|
|
557
|
-
declare type Node_2 = TextNode | BlockNode;
|
|
558
|
-
export { Node_2 as Node }
|
|
559
|
-
|
|
560
|
-
/**
|
|
561
|
-
* Node factory for creating valid nodes
|
|
562
|
-
*/
|
|
563
|
-
export declare class NodeFactory {
|
|
564
|
-
private schema;
|
|
565
|
-
constructor(schema: Schema);
|
|
566
|
-
/**
|
|
567
|
-
* Create a text node
|
|
568
|
-
*/
|
|
569
|
-
text(text: string, marks?: Mark[]): TextNode;
|
|
570
|
-
/**
|
|
571
|
-
* Create a paragraph node
|
|
572
|
-
*/
|
|
573
|
-
paragraph(content?: TextNode[], attrs?: BlockAttrs): BlockNode;
|
|
574
|
-
/**
|
|
575
|
-
* Create a heading node
|
|
576
|
-
*/
|
|
577
|
-
heading(level: number, content?: TextNode[], attrs?: BlockAttrs): BlockNode;
|
|
578
|
-
/**
|
|
579
|
-
* Create a list node
|
|
580
|
-
*/
|
|
581
|
-
list(items: BlockNode[], attrs?: BlockAttrs): BlockNode;
|
|
582
|
-
/**
|
|
583
|
-
* Create a list item node
|
|
584
|
-
*/
|
|
585
|
-
listItem(content: BlockNode[], attrs?: BlockAttrs): BlockNode;
|
|
586
|
-
/**
|
|
587
|
-
* Create a table node
|
|
588
|
-
*/
|
|
589
|
-
table(rows: BlockNode[], attrs?: BlockAttrs): BlockNode;
|
|
590
|
-
/**
|
|
591
|
-
* Create a table row node
|
|
592
|
-
*/
|
|
593
|
-
tableRow(cells: BlockNode[], attrs?: BlockAttrs): BlockNode;
|
|
594
|
-
/**
|
|
595
|
-
* Create a table cell node
|
|
596
|
-
*/
|
|
597
|
-
tableCell(content: BlockNode[], attrs?: BlockAttrs): BlockNode;
|
|
598
|
-
/**
|
|
599
|
-
* Create an image node
|
|
600
|
-
*/
|
|
601
|
-
image(src: string, alt?: string, attrs?: BlockAttrs): BlockNode;
|
|
602
|
-
/**
|
|
603
|
-
* Create a code block node
|
|
604
|
-
*/
|
|
605
|
-
codeBlock(content: string, attrs?: BlockAttrs): BlockNode;
|
|
606
|
-
/**
|
|
607
|
-
* Create a generic block node
|
|
608
|
-
*/
|
|
609
|
-
block(type: NodeType, attrs?: BlockAttrs, children?: (TextNode | BlockNode)[]): BlockNode;
|
|
610
|
-
/**
|
|
611
|
-
* Create a mark
|
|
612
|
-
*/
|
|
613
|
-
mark(type: string, attrs?: Record<string, unknown>): Mark;
|
|
614
|
-
/**
|
|
615
|
-
* Clone a node with new children
|
|
616
|
-
*/
|
|
617
|
-
cloneNode(node: BlockNode, children?: (TextNode | BlockNode)[]): BlockNode;
|
|
618
|
-
}
|
|
619
|
-
|
|
620
|
-
/**
|
|
621
|
-
* Node specification in the schema
|
|
622
|
-
*/
|
|
623
|
-
export declare interface NodeSpec {
|
|
624
|
-
type: NodeType;
|
|
625
|
-
group?: 'block' | 'inline' | 'table';
|
|
626
|
-
content?: string;
|
|
627
|
-
marks?: string;
|
|
628
|
-
attrs?: Record<string, AttributeSpec>;
|
|
629
|
-
defining?: boolean;
|
|
630
|
-
isolating?: boolean;
|
|
631
|
-
toDOM?: (node: Node_2) => HTMLElement | [string, Record<string, string>, ...unknown[]];
|
|
632
|
-
parseDOM?: Array<{
|
|
633
|
-
tag?: string;
|
|
634
|
-
attrs?: Record<string, unknown>;
|
|
635
|
-
}>;
|
|
636
|
-
}
|
|
637
|
-
|
|
638
|
-
/**
|
|
639
|
-
* Node types in the document
|
|
640
|
-
*/
|
|
641
|
-
export declare type NodeType = 'text' | 'paragraph' | 'heading' | 'list' | 'list_item' | 'table' | 'table_row' | 'table_cell' | 'image' | 'code_block' | string;
|
|
642
|
-
|
|
643
|
-
/**
|
|
644
|
-
* NotectlEditor custom element
|
|
645
|
-
*/
|
|
646
|
-
export declare class NotectlEditor extends HTMLElement {
|
|
647
|
-
private state;
|
|
648
|
-
private pluginManager;
|
|
649
|
-
private eventListeners;
|
|
650
|
-
private commands;
|
|
651
|
-
private contentElement;
|
|
652
|
-
private pluginContainerTop;
|
|
653
|
-
private pluginContainerBottom;
|
|
654
|
-
private config;
|
|
655
|
-
private keyboardShortcutCleanup?;
|
|
656
|
-
private ariaLiveRegion;
|
|
657
|
-
private pendingPlugins;
|
|
658
|
-
private readyPromise;
|
|
659
|
-
private readyResolve?;
|
|
660
|
-
private isReady;
|
|
661
|
-
constructor();
|
|
662
|
-
/**
|
|
663
|
-
* Observed attributes for the web component
|
|
664
|
-
*/
|
|
665
|
-
static get observedAttributes(): string[];
|
|
666
|
-
/**
|
|
667
|
-
* Called when element is connected to DOM
|
|
668
|
-
*/
|
|
669
|
-
connectedCallback(): Promise<void>;
|
|
670
|
-
/**
|
|
671
|
-
* Called when element is disconnected from DOM
|
|
672
|
-
*/
|
|
673
|
-
disconnectedCallback(): void;
|
|
674
|
-
/**
|
|
675
|
-
* Called when attributes change
|
|
676
|
-
*/
|
|
677
|
-
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
678
|
-
/**
|
|
679
|
-
* Render the editor UI
|
|
680
|
-
*/
|
|
681
|
-
private render;
|
|
682
|
-
/**
|
|
683
|
-
* Render document content
|
|
684
|
-
*/
|
|
685
|
-
private renderContent;
|
|
686
|
-
/**
|
|
687
|
-
* Convert document to HTML
|
|
688
|
-
*/
|
|
689
|
-
private documentToHTML;
|
|
690
|
-
/**
|
|
691
|
-
* Convert block to HTML (simplified)
|
|
692
|
-
*/
|
|
693
|
-
private blockToHTML;
|
|
694
|
-
/**
|
|
695
|
-
* Convert children to HTML
|
|
696
|
-
*/
|
|
697
|
-
private childrenToHTML;
|
|
698
|
-
/**
|
|
699
|
-
* Apply mark as HTML
|
|
700
|
-
*/
|
|
701
|
-
private applyMarkHTML;
|
|
702
|
-
/**
|
|
703
|
-
* Escape HTML
|
|
704
|
-
*/
|
|
705
|
-
private escapeHTML;
|
|
706
|
-
private tableToHTML;
|
|
707
|
-
private tableRowToHTML;
|
|
708
|
-
private tableCellToHTML;
|
|
709
|
-
private styleObjectToString;
|
|
710
|
-
/**
|
|
711
|
-
* Setup accessibility features
|
|
712
|
-
*/
|
|
713
|
-
private setupAccessibility;
|
|
714
|
-
/**
|
|
715
|
-
* Setup keyboard shortcuts with screen reader announcements
|
|
716
|
-
*/
|
|
717
|
-
private setupKeyboardShortcuts;
|
|
718
|
-
/**
|
|
719
|
-
* Toggle formatting
|
|
720
|
-
*/
|
|
721
|
-
private toggleFormat;
|
|
722
|
-
/**
|
|
723
|
-
* Insert table at current selection
|
|
724
|
-
*/
|
|
725
|
-
insertTable(rows?: number, cols?: number): void;
|
|
726
|
-
/**
|
|
727
|
-
* Announce message to screen readers
|
|
728
|
-
*/
|
|
729
|
-
private announceToScreenReader;
|
|
730
|
-
/**
|
|
731
|
-
* Attach event listeners
|
|
732
|
-
*/
|
|
733
|
-
private attachEventListeners;
|
|
734
|
-
/**
|
|
735
|
-
* Detach event listeners
|
|
736
|
-
*/
|
|
737
|
-
private detachEventListeners;
|
|
738
|
-
/**
|
|
739
|
-
* Handle input event
|
|
740
|
-
*/
|
|
741
|
-
private handleInput;
|
|
742
|
-
/**
|
|
743
|
-
* Handle keydown event
|
|
744
|
-
*/
|
|
745
|
-
private handleKeydown;
|
|
746
|
-
/**
|
|
747
|
-
* Handle focus event
|
|
748
|
-
*/
|
|
749
|
-
private handleFocus;
|
|
750
|
-
/**
|
|
751
|
-
* Handle blur event
|
|
752
|
-
*/
|
|
753
|
-
private handleBlur;
|
|
754
|
-
private handleContextMenu;
|
|
755
|
-
/**
|
|
756
|
-
* Update placeholder visibility
|
|
757
|
-
*/
|
|
758
|
-
private updatePlaceholder;
|
|
759
|
-
/**
|
|
760
|
-
* Sync content from DOM to state
|
|
761
|
-
*/
|
|
762
|
-
private syncContentToState;
|
|
763
|
-
/**
|
|
764
|
-
* Convert HTML to document structure
|
|
765
|
-
*/
|
|
766
|
-
private htmlToDocument;
|
|
767
|
-
/**
|
|
768
|
-
* Convert DOM node to block
|
|
769
|
-
*/
|
|
770
|
-
private nodeToBlock;
|
|
771
|
-
/**
|
|
772
|
-
* Parse children nodes
|
|
773
|
-
*/
|
|
774
|
-
private parseChildren;
|
|
775
|
-
/**
|
|
776
|
-
* Parse inline element with marks
|
|
777
|
-
*/
|
|
778
|
-
private parseInlineElement;
|
|
779
|
-
/**
|
|
780
|
-
* Update readonly state
|
|
781
|
-
*/
|
|
782
|
-
private updateReadonly;
|
|
783
|
-
/**
|
|
784
|
-
* Register a plugin
|
|
785
|
-
*
|
|
786
|
-
* Plugins can be registered before or after the editor is mounted.
|
|
787
|
-
* If registered before mounting, they will be queued and initialized
|
|
788
|
-
* automatically when the editor connects to the DOM.
|
|
789
|
-
*
|
|
790
|
-
* @param plugin - The plugin to register
|
|
791
|
-
* @returns Promise that resolves when the plugin is registered
|
|
792
|
-
*/
|
|
793
|
-
registerPlugin(plugin: Plugin_2): Promise<void>;
|
|
794
|
-
/**
|
|
795
|
-
* Unregister a plugin
|
|
796
|
-
*/
|
|
797
|
-
unregisterPlugin(pluginId: string): Promise<void>;
|
|
798
|
-
/**
|
|
799
|
-
* Wait for the editor to be ready
|
|
800
|
-
*
|
|
801
|
-
* Returns a Promise that resolves when the editor has been mounted
|
|
802
|
-
* and all pending plugins have been initialized. This is useful when
|
|
803
|
-
* you need to ensure the editor is fully initialized before performing
|
|
804
|
-
* operations that depend on the editor being mounted.
|
|
805
|
-
*
|
|
806
|
-
* @returns Promise that resolves when the editor is ready
|
|
807
|
-
* @example
|
|
808
|
-
* ```typescript
|
|
809
|
-
* const editor = document.createElement('notectl-editor');
|
|
810
|
-
* container.appendChild(editor);
|
|
811
|
-
* await editor.whenReady();
|
|
812
|
-
* // Editor is now fully initialized
|
|
813
|
-
* ```
|
|
814
|
-
*/
|
|
815
|
-
whenReady(): Promise<void>;
|
|
816
|
-
/**
|
|
817
|
-
* Get the block containing the current selection
|
|
818
|
-
*/
|
|
819
|
-
private getSelectedBlock;
|
|
820
|
-
/**
|
|
821
|
-
* Find all blocks of a specific type
|
|
822
|
-
*/
|
|
823
|
-
private findBlocksByType;
|
|
824
|
-
/**
|
|
825
|
-
* Find parent block of a given block
|
|
826
|
-
*/
|
|
827
|
-
private findParentBlock;
|
|
828
|
-
/**
|
|
829
|
-
* Get block at current cursor position
|
|
830
|
-
*/
|
|
831
|
-
private getBlockAtCursor;
|
|
832
|
-
/**
|
|
833
|
-
* Insert a block after another block (Delta-based)
|
|
834
|
-
*/
|
|
835
|
-
private insertBlockAfter;
|
|
836
|
-
/**
|
|
837
|
-
* Insert a block before another block (Delta-based)
|
|
838
|
-
*/
|
|
839
|
-
private insertBlockBefore;
|
|
840
|
-
/**
|
|
841
|
-
* Update block attributes (Delta-based)
|
|
842
|
-
*/
|
|
843
|
-
private updateBlockAttrs;
|
|
844
|
-
/**
|
|
845
|
-
* Delete a block (Delta-based)
|
|
846
|
-
*/
|
|
847
|
-
private deleteBlockById;
|
|
848
|
-
/**
|
|
849
|
-
* Add mark to current selection (Delta-based)
|
|
850
|
-
*/
|
|
851
|
-
private addMarkToSelection;
|
|
852
|
-
/**
|
|
853
|
-
* Remove mark from current selection (Delta-based)
|
|
854
|
-
*/
|
|
855
|
-
private removeMarkFromSelection;
|
|
856
|
-
/**
|
|
857
|
-
* Toggle mark on current selection (Delta-based)
|
|
858
|
-
*/
|
|
859
|
-
private toggleMarkOnSelection;
|
|
860
|
-
/**
|
|
861
|
-
* Create plugin context
|
|
862
|
-
*/
|
|
863
|
-
private createPluginContext;
|
|
864
|
-
/**
|
|
865
|
-
* Apply a delta
|
|
866
|
-
*/
|
|
867
|
-
applyDelta(delta: Delta): void;
|
|
868
|
-
/**
|
|
869
|
-
* Register event listener
|
|
870
|
-
*/
|
|
871
|
-
on(event: EditorEvent, callback: EditorEventCallback): void;
|
|
872
|
-
/**
|
|
873
|
-
* Unregister event listener
|
|
874
|
-
*/
|
|
875
|
-
off(event: EditorEvent, callback: EditorEventCallback): void;
|
|
876
|
-
/**
|
|
877
|
-
* Emit event
|
|
878
|
-
*/
|
|
879
|
-
private emit;
|
|
880
|
-
/**
|
|
881
|
-
* Register command
|
|
882
|
-
*/
|
|
883
|
-
registerCommand(name: string, handler: CommandHandler): void;
|
|
884
|
-
/**
|
|
885
|
-
* Execute command
|
|
886
|
-
*/
|
|
887
|
-
executeCommand(name: string, ...args: unknown[]): unknown;
|
|
888
|
-
/**
|
|
889
|
-
* Undo last change
|
|
890
|
-
*/
|
|
891
|
-
undo(): void;
|
|
892
|
-
/**
|
|
893
|
-
* Redo last undone change
|
|
894
|
-
*/
|
|
895
|
-
redo(): void;
|
|
896
|
-
/**
|
|
897
|
-
* Configure editor options
|
|
898
|
-
* @param config - Configuration options to apply
|
|
899
|
-
*/
|
|
900
|
-
configure(config: EditorConfig): void;
|
|
901
|
-
/**
|
|
902
|
-
* Destroy the editor and clean up resources
|
|
903
|
-
*/
|
|
904
|
-
destroy(): void;
|
|
905
|
-
/**
|
|
906
|
-
* Get current content as string or JSON
|
|
907
|
-
* @returns Current document content
|
|
908
|
-
*/
|
|
909
|
-
getContent(): Document_2 | string;
|
|
910
|
-
/**
|
|
911
|
-
* Get current state
|
|
912
|
-
*/
|
|
913
|
-
getState(): EditorState;
|
|
914
|
-
/**
|
|
915
|
-
* Get document as JSON
|
|
916
|
-
*/
|
|
917
|
-
getJSON(): Document_2;
|
|
918
|
-
/**
|
|
919
|
-
* Set document from JSON
|
|
920
|
-
*/
|
|
921
|
-
setJSON(doc: Document_2): void;
|
|
922
|
-
/**
|
|
923
|
-
* Get HTML content (sanitized)
|
|
924
|
-
*/
|
|
925
|
-
getHTML(): string;
|
|
926
|
-
/**
|
|
927
|
-
* Set HTML content (with sanitization)
|
|
928
|
-
* @param html - HTML content to set
|
|
929
|
-
*/
|
|
930
|
-
setHTML(html: string): void;
|
|
931
|
-
/**
|
|
932
|
-
* Set content from string (with sanitization)
|
|
933
|
-
* @param content - Content to set
|
|
934
|
-
* @param allowHTML - Allow HTML tags
|
|
935
|
-
*/
|
|
936
|
-
setContent(content: string, allowHTML?: boolean): void;
|
|
937
|
-
/**
|
|
938
|
-
* Export HTML content (sanitized)
|
|
939
|
-
* @returns Sanitized HTML
|
|
940
|
-
*/
|
|
941
|
-
exportHTML(): string;
|
|
942
|
-
/**
|
|
943
|
-
* Focus the editor
|
|
944
|
-
*/
|
|
945
|
-
focus(): void;
|
|
946
|
-
/**
|
|
947
|
-
* Blur the editor
|
|
948
|
-
*/
|
|
949
|
-
blur(): void;
|
|
950
|
-
}
|
|
951
|
-
|
|
952
|
-
/**
|
|
953
|
-
* Structured error class for Notectl
|
|
954
|
-
*/
|
|
955
|
-
export declare class NotectlError extends Error {
|
|
956
|
-
code: ErrorCode;
|
|
957
|
-
details?: unknown | undefined;
|
|
958
|
-
constructor(code: ErrorCode, message: string, details?: unknown | undefined);
|
|
959
|
-
/**
|
|
960
|
-
* Convert to JSON-serializable format
|
|
961
|
-
*/
|
|
962
|
-
toJSON(): {
|
|
963
|
-
error: {
|
|
964
|
-
code: ErrorCode;
|
|
965
|
-
message: string;
|
|
966
|
-
details: unknown;
|
|
967
|
-
};
|
|
968
|
-
};
|
|
969
|
-
}
|
|
970
|
-
|
|
971
|
-
/**
|
|
972
|
-
* Union of all operation types
|
|
973
|
-
*/
|
|
974
|
-
export declare type Operation = InsertTextOp | DeleteRangeOp | ApplyMarkOp | InsertBlockBeforeOp | InsertBlockAfterOp | DeleteBlockOp | SetAttrsOp | WrapInOp | LiftOutOp | TableInsertRowOp | TableDeleteRowOp | TableInsertColOp | TableDeleteColOp | TableMergeCellsOp | TableSplitCellOp | UpdateSelectionOp;
|
|
975
|
-
|
|
976
|
-
/**
|
|
977
|
-
* Plugin interface
|
|
978
|
-
*/
|
|
979
|
-
declare interface Plugin_2 {
|
|
980
|
-
/**
|
|
981
|
-
* Unique plugin identifier
|
|
982
|
-
*/
|
|
983
|
-
id: string;
|
|
984
|
-
/**
|
|
985
|
-
* Plugin name
|
|
986
|
-
*/
|
|
987
|
-
name: string;
|
|
988
|
-
/**
|
|
989
|
-
* Plugin version
|
|
990
|
-
*/
|
|
991
|
-
version: string;
|
|
992
|
-
/**
|
|
993
|
-
* Plugin dependencies (optional)
|
|
994
|
-
*/
|
|
995
|
-
dependencies?: string[];
|
|
996
|
-
/**
|
|
997
|
-
* Initialize the plugin
|
|
998
|
-
*/
|
|
999
|
-
init(context: PluginContext): Promise<void> | void;
|
|
1000
|
-
/**
|
|
1001
|
-
* Cleanup the plugin
|
|
1002
|
-
*/
|
|
1003
|
-
destroy?(): Promise<void> | void;
|
|
1004
|
-
/**
|
|
1005
|
-
* Handle state updates (optional)
|
|
1006
|
-
*/
|
|
1007
|
-
onStateUpdate?(oldState: EditorState, newState: EditorState): void;
|
|
1008
|
-
/**
|
|
1009
|
-
* Handle delta application (optional)
|
|
1010
|
-
*/
|
|
1011
|
-
onDeltaApplied?(delta: Delta): void;
|
|
1012
|
-
}
|
|
1013
|
-
export { Plugin_2 as Plugin }
|
|
1014
|
-
|
|
1015
|
-
/**
|
|
1016
|
-
* Plugin context provided to plugins
|
|
1017
|
-
*/
|
|
1018
|
-
export declare interface PluginContext {
|
|
1019
|
-
/**
|
|
1020
|
-
* Get current editor state
|
|
1021
|
-
*/
|
|
1022
|
-
getState(): EditorState;
|
|
1023
|
-
/**
|
|
1024
|
-
* Apply a delta to the editor
|
|
1025
|
-
*/
|
|
1026
|
-
applyDelta(delta: Delta): void;
|
|
1027
|
-
/**
|
|
1028
|
-
* Get current selection
|
|
1029
|
-
*/
|
|
1030
|
-
getSelection(): Selection_2 | null;
|
|
1031
|
-
/**
|
|
1032
|
-
* Set selection
|
|
1033
|
-
*/
|
|
1034
|
-
setSelection(selection: Selection_2): void;
|
|
1035
|
-
/**
|
|
1036
|
-
* Get the block containing the current cursor/selection
|
|
1037
|
-
*/
|
|
1038
|
-
getSelectedBlock(): BlockNode | null;
|
|
1039
|
-
/**
|
|
1040
|
-
* Find all blocks of a specific type
|
|
1041
|
-
* @param type - Block type to search for (e.g., 'table', 'heading', 'paragraph')
|
|
1042
|
-
* @returns Array of matching blocks
|
|
1043
|
-
*/
|
|
1044
|
-
findBlocksByType(type: string): BlockNode[];
|
|
1045
|
-
/**
|
|
1046
|
-
* Find a block by its ID
|
|
1047
|
-
* @param blockId - Block identifier
|
|
1048
|
-
* @returns Block or undefined if not found
|
|
1049
|
-
*/
|
|
1050
|
-
findBlockById(blockId: BlockId): BlockNode | undefined;
|
|
1051
|
-
/**
|
|
1052
|
-
* Find parent block of a given block
|
|
1053
|
-
* @param block - Child block
|
|
1054
|
-
* @returns Parent block or null if block is at root level
|
|
1055
|
-
*/
|
|
1056
|
-
findParentBlock(block: BlockNode): BlockNode | null;
|
|
1057
|
-
/**
|
|
1058
|
-
* Get block at current cursor position
|
|
1059
|
-
*/
|
|
1060
|
-
getBlockAtCursor(): BlockNode | null;
|
|
1061
|
-
/**
|
|
1062
|
-
* Insert a block after another block
|
|
1063
|
-
* @param block - Block to insert
|
|
1064
|
-
* @param afterId - ID of block to insert after (if undefined, appends to end)
|
|
1065
|
-
*/
|
|
1066
|
-
insertBlockAfter(block: BlockNode, afterId?: BlockId): void;
|
|
1067
|
-
/**
|
|
1068
|
-
* Insert a block before another block
|
|
1069
|
-
* @param block - Block to insert
|
|
1070
|
-
* @param beforeId - ID of block to insert before (if undefined, prepends to start)
|
|
1071
|
-
*/
|
|
1072
|
-
insertBlockBefore(block: BlockNode, beforeId?: BlockId): void;
|
|
1073
|
-
/**
|
|
1074
|
-
* Update block attributes
|
|
1075
|
-
* @param blockId - Block to update
|
|
1076
|
-
* @param attrs - Attributes to merge
|
|
1077
|
-
*/
|
|
1078
|
-
updateBlockAttrs(blockId: BlockId, attrs: Record<string, unknown>): void;
|
|
1079
|
-
/**
|
|
1080
|
-
* Delete a block
|
|
1081
|
-
* @param blockId - Block to delete
|
|
1082
|
-
*/
|
|
1083
|
-
deleteBlock(blockId: BlockId): void;
|
|
1084
|
-
/**
|
|
1085
|
-
* Add mark to current selection
|
|
1086
|
-
* @param mark - Mark to add
|
|
1087
|
-
*/
|
|
1088
|
-
addMark(mark: Mark): void;
|
|
1089
|
-
/**
|
|
1090
|
-
* Remove mark from current selection
|
|
1091
|
-
* @param markType - Type of mark to remove
|
|
1092
|
-
*/
|
|
1093
|
-
removeMark(markType: string): void;
|
|
1094
|
-
/**
|
|
1095
|
-
* Toggle mark on current selection
|
|
1096
|
-
* @param markType - Type of mark to toggle
|
|
1097
|
-
*/
|
|
1098
|
-
toggleMark(markType: string): void;
|
|
1099
|
-
/**
|
|
1100
|
-
* Register event listener
|
|
1101
|
-
*/
|
|
1102
|
-
on(event: string, callback: (data: unknown) => void): void;
|
|
1103
|
-
/**
|
|
1104
|
-
* Unregister event listener
|
|
1105
|
-
*/
|
|
1106
|
-
off(event: string, callback: (data: unknown) => void): void;
|
|
1107
|
-
/**
|
|
1108
|
-
* Emit an event
|
|
1109
|
-
*/
|
|
1110
|
-
emit(event: string, data?: unknown): void;
|
|
1111
|
-
/**
|
|
1112
|
-
* Register a command
|
|
1113
|
-
*/
|
|
1114
|
-
registerCommand(name: string, handler: CommandHandler): void;
|
|
1115
|
-
/**
|
|
1116
|
-
* Execute a command
|
|
1117
|
-
*/
|
|
1118
|
-
executeCommand(name: string, ...args: unknown[]): unknown;
|
|
1119
|
-
/**
|
|
1120
|
-
* Access DOM container (editable area)
|
|
1121
|
-
* @deprecated Prefer using Delta operations instead of direct DOM manipulation
|
|
1122
|
-
*/
|
|
1123
|
-
getContainer(): HTMLElement;
|
|
1124
|
-
/**
|
|
1125
|
-
* Access plugin container for UI elements (toolbar, etc.)
|
|
1126
|
-
* @param position - 'top' or 'bottom'
|
|
1127
|
-
*/
|
|
1128
|
-
getPluginContainer(position: 'top' | 'bottom'): HTMLElement;
|
|
1129
|
-
}
|
|
1130
|
-
|
|
1131
|
-
/**
|
|
1132
|
-
* Plugin factory function type
|
|
1133
|
-
*/
|
|
1134
|
-
export declare type PluginFactory<TConfig = unknown> = (config?: TConfig) => Plugin_2;
|
|
1135
|
-
|
|
1136
|
-
/**
|
|
1137
|
-
* Plugin manager class
|
|
1138
|
-
*/
|
|
1139
|
-
export declare class PluginManager {
|
|
1140
|
-
private plugins;
|
|
1141
|
-
private initializationOrder;
|
|
1142
|
-
constructor();
|
|
1143
|
-
/**
|
|
1144
|
-
* Register a plugin
|
|
1145
|
-
*
|
|
1146
|
-
* @param plugin - The plugin to register
|
|
1147
|
-
* @param context - Plugin context with editor APIs
|
|
1148
|
-
* @throws {NotectlError} If plugin validation fails or initialization errors occur
|
|
1149
|
-
*
|
|
1150
|
-
* @example
|
|
1151
|
-
* ```typescript
|
|
1152
|
-
* const toolbarPlugin = new ToolbarPlugin();
|
|
1153
|
-
* await pluginManager.register(toolbarPlugin, context);
|
|
1154
|
-
* ```
|
|
1155
|
-
*/
|
|
1156
|
-
register(plugin: Plugin_2, context: PluginContext): Promise<void>;
|
|
1157
|
-
/**
|
|
1158
|
-
* Unregister a plugin
|
|
1159
|
-
*
|
|
1160
|
-
* @param pluginId - ID of the plugin to unregister
|
|
1161
|
-
* @param context - Plugin context for event emission
|
|
1162
|
-
* @throws {NotectlError} If plugin is not found or has dependents
|
|
1163
|
-
*
|
|
1164
|
-
* @example
|
|
1165
|
-
* ```typescript
|
|
1166
|
-
* await pluginManager.unregister('toolbar-plugin', context);
|
|
1167
|
-
* ```
|
|
1168
|
-
*/
|
|
1169
|
-
unregister(pluginId: string, context: PluginContext): Promise<void>;
|
|
1170
|
-
/**
|
|
1171
|
-
* Get a plugin by ID
|
|
1172
|
-
*/
|
|
1173
|
-
get(pluginId: string): Plugin_2 | undefined;
|
|
1174
|
-
/**
|
|
1175
|
-
* Check if a plugin is registered
|
|
1176
|
-
*/
|
|
1177
|
-
has(pluginId: string): boolean;
|
|
1178
|
-
/**
|
|
1179
|
-
* Get all registered plugins
|
|
1180
|
-
*/
|
|
1181
|
-
getAll(): Plugin_2[];
|
|
1182
|
-
/**
|
|
1183
|
-
* Notify plugins of state update
|
|
1184
|
-
*/
|
|
1185
|
-
notifyStateUpdate(oldState: EditorState, newState: EditorState): void;
|
|
1186
|
-
/**
|
|
1187
|
-
* Notify plugins of delta application
|
|
1188
|
-
*/
|
|
1189
|
-
notifyDeltaApplied(delta: Delta): void;
|
|
1190
|
-
/**
|
|
1191
|
-
* Destroy all plugins
|
|
1192
|
-
*/
|
|
1193
|
-
destroyAll(): Promise<void>;
|
|
1194
|
-
}
|
|
1195
|
-
|
|
1196
|
-
/**
|
|
1197
|
-
* Text position within a block (code point offset)
|
|
1198
|
-
*/
|
|
1199
|
-
export declare interface Position {
|
|
1200
|
-
blockId: BlockId;
|
|
1201
|
-
offset: number;
|
|
1202
|
-
}
|
|
1203
|
-
|
|
1204
|
-
/**
|
|
1205
|
-
* Range of text across blocks
|
|
1206
|
-
*/
|
|
1207
|
-
declare interface Range_2 {
|
|
1208
|
-
start: Position;
|
|
1209
|
-
end: Position;
|
|
1210
|
-
}
|
|
1211
|
-
export { Range_2 as Range }
|
|
1212
|
-
|
|
1213
|
-
/**
|
|
1214
|
-
* Document schema
|
|
1215
|
-
*/
|
|
1216
|
-
export declare class Schema {
|
|
1217
|
-
nodes: Map<NodeType, NodeSpec>;
|
|
1218
|
-
marks: Map<string, MarkSpec>;
|
|
1219
|
-
topNode: NodeType;
|
|
1220
|
-
constructor(config: {
|
|
1221
|
-
nodes: NodeSpec[];
|
|
1222
|
-
marks: MarkSpec[];
|
|
1223
|
-
topNode?: NodeType;
|
|
1224
|
-
});
|
|
1225
|
-
/**
|
|
1226
|
-
* Get node specification
|
|
1227
|
-
*/
|
|
1228
|
-
node(type: NodeType): NodeSpec | undefined;
|
|
1229
|
-
/**
|
|
1230
|
-
* Get mark specification
|
|
1231
|
-
*/
|
|
1232
|
-
mark(type: string): MarkSpec | undefined;
|
|
1233
|
-
/**
|
|
1234
|
-
* Validate if a node conforms to the schema
|
|
1235
|
-
*/
|
|
1236
|
-
validateNode(node: Node_2): {
|
|
1237
|
-
valid: boolean;
|
|
1238
|
-
errors: string[];
|
|
1239
|
-
};
|
|
1240
|
-
/**
|
|
1241
|
-
* Check if a mark is allowed on a node
|
|
1242
|
-
*/
|
|
1243
|
-
markAllowedOn(markType: string, nodeType: NodeType): boolean;
|
|
1244
|
-
/**
|
|
1245
|
-
* Check if two marks can coexist
|
|
1246
|
-
*/
|
|
1247
|
-
marksCompatible(markA: string, markB: string): boolean;
|
|
1248
|
-
}
|
|
1249
|
-
|
|
1250
|
-
/**
|
|
1251
|
-
* Selection state
|
|
1252
|
-
*/
|
|
1253
|
-
declare interface Selection_2 {
|
|
1254
|
-
anchor: Position;
|
|
1255
|
-
head: Position;
|
|
1256
|
-
}
|
|
1257
|
-
export { Selection_2 as Selection }
|
|
1258
|
-
|
|
1259
|
-
/**
|
|
1260
|
-
* Selection helper utilities
|
|
1261
|
-
*/
|
|
1262
|
-
export declare interface SelectionHelpers {
|
|
1263
|
-
/**
|
|
1264
|
-
* Check if selection is collapsed (cursor)
|
|
1265
|
-
*/
|
|
1266
|
-
isCollapsed(selection: Selection_2): boolean;
|
|
1267
|
-
/**
|
|
1268
|
-
* Check if selection spans multiple blocks
|
|
1269
|
-
*/
|
|
1270
|
-
isMultiBlock(selection: Selection_2): boolean;
|
|
1271
|
-
/**
|
|
1272
|
-
* Get the direction of selection (forward/backward)
|
|
1273
|
-
*/
|
|
1274
|
-
getDirection(selection: Selection_2): 'forward' | 'backward' | 'none';
|
|
1275
|
-
/**
|
|
1276
|
-
* Create a collapsed selection at a position
|
|
1277
|
-
*/
|
|
1278
|
-
createCollapsed(position: Position): Selection_2;
|
|
1279
|
-
/**
|
|
1280
|
-
* Create a selection range
|
|
1281
|
-
*/
|
|
1282
|
-
createRange(start: Position, end: Position): Selection_2;
|
|
1283
|
-
}
|
|
1284
|
-
|
|
1285
|
-
/**
|
|
1286
|
-
* Selection helper implementation
|
|
1287
|
-
*/
|
|
1288
|
-
export declare const selectionHelpers: SelectionHelpers;
|
|
1289
|
-
|
|
1290
|
-
/**
|
|
1291
|
-
* Set attributes on a block
|
|
1292
|
-
*/
|
|
1293
|
-
export declare interface SetAttrsOp extends BaseOperation {
|
|
1294
|
-
op: 'set_attrs';
|
|
1295
|
-
target: {
|
|
1296
|
-
blockId: BlockId;
|
|
1297
|
-
};
|
|
1298
|
-
attrs: BlockAttrs;
|
|
1299
|
-
}
|
|
1300
|
-
|
|
1301
|
-
/**
|
|
1302
|
-
* Table cell structure
|
|
1303
|
-
*/
|
|
1304
|
-
export declare interface TableCell {
|
|
1305
|
-
id?: string;
|
|
1306
|
-
content: string;
|
|
1307
|
-
rowSpan?: number;
|
|
1308
|
-
colSpan?: number;
|
|
1309
|
-
attrs?: {
|
|
1310
|
-
style?: Record<string, string | number>;
|
|
1311
|
-
[key: string]: unknown;
|
|
1312
|
-
};
|
|
1313
|
-
}
|
|
1314
|
-
|
|
1315
|
-
/**
|
|
1316
|
-
* Table structure for attributes
|
|
1317
|
-
*/
|
|
1318
|
-
export declare interface TableData {
|
|
1319
|
-
rows: TableRow[];
|
|
1320
|
-
}
|
|
1321
|
-
|
|
1322
|
-
/**
|
|
1323
|
-
* Table operation: delete column
|
|
1324
|
-
*/
|
|
1325
|
-
export declare interface TableDeleteColOp extends BaseOperation {
|
|
1326
|
-
op: 'table_delete_col';
|
|
1327
|
-
target: {
|
|
1328
|
-
tableId: BlockId;
|
|
1329
|
-
colIndex: number;
|
|
1330
|
-
};
|
|
1331
|
-
}
|
|
1332
|
-
|
|
1333
|
-
/**
|
|
1334
|
-
* Table operation: delete row
|
|
1335
|
-
*/
|
|
1336
|
-
export declare interface TableDeleteRowOp extends BaseOperation {
|
|
1337
|
-
op: 'table_delete_row';
|
|
1338
|
-
target: {
|
|
1339
|
-
tableId: BlockId;
|
|
1340
|
-
rowIndex: number;
|
|
1341
|
-
};
|
|
1342
|
-
}
|
|
1343
|
-
|
|
1344
|
-
/**
|
|
1345
|
-
* Table operation: insert column
|
|
1346
|
-
*/
|
|
1347
|
-
export declare interface TableInsertColOp extends BaseOperation {
|
|
1348
|
-
op: 'table_insert_col';
|
|
1349
|
-
target: {
|
|
1350
|
-
tableId: BlockId;
|
|
1351
|
-
colIndex: number;
|
|
1352
|
-
};
|
|
1353
|
-
}
|
|
1354
|
-
|
|
1355
|
-
/**
|
|
1356
|
-
* Table operation: insert row
|
|
1357
|
-
*/
|
|
1358
|
-
export declare interface TableInsertRowOp extends BaseOperation {
|
|
1359
|
-
op: 'table_insert_row';
|
|
1360
|
-
target: {
|
|
1361
|
-
tableId: BlockId;
|
|
1362
|
-
rowIndex: number;
|
|
1363
|
-
};
|
|
1364
|
-
row: BlockNode;
|
|
1365
|
-
}
|
|
1366
|
-
|
|
1367
|
-
/**
|
|
1368
|
-
* Table operation: merge cells
|
|
1369
|
-
*/
|
|
1370
|
-
export declare interface TableMergeCellsOp extends BaseOperation {
|
|
1371
|
-
op: 'table_merge_cells';
|
|
1372
|
-
target: {
|
|
1373
|
-
tableId: BlockId;
|
|
1374
|
-
cells: BlockId[];
|
|
1375
|
-
};
|
|
1376
|
-
}
|
|
1377
|
-
|
|
1378
|
-
/**
|
|
1379
|
-
* Table row structure
|
|
1380
|
-
*/
|
|
1381
|
-
export declare interface TableRow {
|
|
1382
|
-
id?: string;
|
|
1383
|
-
cells: TableCell[];
|
|
1384
|
-
attrs?: {
|
|
1385
|
-
style?: Record<string, string | number>;
|
|
1386
|
-
[key: string]: unknown;
|
|
1387
|
-
};
|
|
1388
|
-
}
|
|
1389
|
-
|
|
1390
|
-
/**
|
|
1391
|
-
* Table operation: split cell
|
|
1392
|
-
*/
|
|
1393
|
-
export declare interface TableSplitCellOp extends BaseOperation {
|
|
1394
|
-
op: 'table_split_cell';
|
|
1395
|
-
target: {
|
|
1396
|
-
tableId: BlockId;
|
|
1397
|
-
cellId: BlockId;
|
|
1398
|
-
};
|
|
1399
|
-
}
|
|
1400
|
-
|
|
1401
|
-
/**
|
|
1402
|
-
* Text node
|
|
1403
|
-
*/
|
|
1404
|
-
export declare interface TextNode {
|
|
1405
|
-
type: 'text';
|
|
1406
|
-
text: string;
|
|
1407
|
-
marks?: Mark[];
|
|
1408
|
-
}
|
|
1409
|
-
|
|
1410
|
-
/**
|
|
1411
|
-
* Transform a delta against another delta
|
|
1412
|
-
* Returns transformed version of deltaA that can be applied after deltaB
|
|
1413
|
-
*/
|
|
1414
|
-
export declare function transformDelta(deltaA: Delta, deltaB: Delta, side?: 'left' | 'right'): Delta;
|
|
1415
|
-
|
|
1416
|
-
/**
|
|
1417
|
-
* Transform operation A against operation B
|
|
1418
|
-
* Returns transformed version of A that can be applied after B
|
|
1419
|
-
*/
|
|
1420
|
-
export declare function transformOperation(opA: Operation, opB: Operation, side: 'left' | 'right'): Operation;
|
|
1421
|
-
|
|
1422
|
-
/**
|
|
1423
|
-
* Update selection/cursor
|
|
1424
|
-
*/
|
|
1425
|
-
export declare interface UpdateSelectionOp extends BaseOperation {
|
|
1426
|
-
op: 'update_selection';
|
|
1427
|
-
actorId: string;
|
|
1428
|
-
selection: {
|
|
1429
|
-
anchor: Position;
|
|
1430
|
-
head: Position;
|
|
1431
|
-
};
|
|
1432
|
-
}
|
|
1433
|
-
|
|
1434
|
-
/**
|
|
1435
|
-
* Validate a delta against constraints
|
|
1436
|
-
*/
|
|
1437
|
-
export declare function validateDelta(delta: Delta): {
|
|
1438
|
-
valid: boolean;
|
|
1439
|
-
errors: string[];
|
|
1440
|
-
};
|
|
1441
|
-
|
|
1442
|
-
/**
|
|
1443
|
-
* Validation constraint types
|
|
1444
|
-
*/
|
|
1445
|
-
export declare type ValidationConstraint = 'noDanglingRefs' | 'tableGridConsistent' | 'altOrDecorative' | 'rtlIntegrity' | string;
|
|
1446
|
-
|
|
1447
|
-
/**
|
|
1448
|
-
* Validation constraints for document structure
|
|
1449
|
-
*/
|
|
1450
|
-
export declare const ValidationConstraints: {
|
|
1451
|
-
readonly NO_DANGLING_REFS: "noDanglingRefs";
|
|
1452
|
-
readonly TABLE_GRID_CONSISTENT: "tableGridConsistent";
|
|
1453
|
-
readonly ALT_OR_DECORATIVE: "altOrDecorative";
|
|
1454
|
-
readonly RTL_INTEGRITY: "rtlIntegrity";
|
|
1455
|
-
};
|
|
1456
|
-
|
|
1457
|
-
export declare const VERSION = "0.0.1";
|
|
1458
|
-
|
|
1459
|
-
/**
|
|
1460
|
-
* Wrap blocks in a container
|
|
1461
|
-
*/
|
|
1462
|
-
export declare interface WrapInOp extends BaseOperation {
|
|
1463
|
-
op: 'wrap_in';
|
|
1464
|
-
blockIds: BlockId[];
|
|
1465
|
-
wrapperType: string;
|
|
1466
|
-
wrapperAttrs?: BlockAttrs;
|
|
1467
|
-
}
|
|
1468
|
-
|
|
1469
|
-
export { }
|