atproto blogging
at main 92 lines 3.0 kB view raw
1/** 2 * Weaver Editor - Embeddable markdown editor. 3 * 4 * Usage: 5 * ```typescript 6 * import { createEditor } from '@weaver.sh/editor-core'; 7 * 8 * const editor = await createEditor({ 9 * container: document.getElementById('editor')!, 10 * initialMarkdown: '# Hello World', 11 * onChange: () => console.log('changed'), 12 * }); 13 * 14 * // Get content 15 * const md = editor.getMarkdown(); 16 * const entry = editor.toEntry(); 17 * 18 * // Cleanup 19 * editor.destroy(); 20 * ``` 21 */ 22import type { Editor, EditorConfig, EventResult } from "./types"; 23export * from "./types"; 24interface JsResolvedContent { 25 addEmbed(atUri: string, html: string): void; 26} 27interface JsEditor { 28 mount(container: HTMLElement, onChange?: () => void): void; 29 unmount(): void; 30 isMounted(): boolean; 31 focus(): void; 32 blur(): void; 33 getMarkdown(): string; 34 getSnapshot(): unknown; 35 toEntry(): unknown; 36 setResolvedContent(content: JsResolvedContent): void; 37 getTitle(): string; 38 setTitle(title: string): void; 39 getPath(): string; 40 setPath(path: string): void; 41 getTags(): string[]; 42 setTags(tags: string[]): void; 43 executeAction(action: unknown): void; 44 addPendingImage(image: unknown, dataUrl: string): void; 45 finalizeImage(localId: string, finalized: unknown, blobRkey: string, ident: string): void; 46 removeImage(localId: string): void; 47 getPendingImages(): unknown; 48 getStagingUris(): string[]; 49 addEntryToIndex(title: string, path: string, canonicalUrl: string): void; 50 clearEntryIndex(): void; 51 getCursorOffset(): number; 52 setCursorOffset(offset: number): void; 53 getLength(): number; 54 canUndo(): boolean; 55 canRedo(): boolean; 56 getParagraphs(): unknown; 57 renderAndUpdateDom(): void; 58 handleBeforeInput(inputType: string, data: string | null, targetStart: number | null, targetEnd: number | null, isComposing: boolean): EventResult; 59 handleKeydown(key: string, ctrl: boolean, alt: boolean, shift: boolean, meta: boolean): EventResult; 60 handleKeyup(key: string): void; 61 handlePaste(text: string): void; 62 handleCut(): string | null; 63 handleCopy(): string | null; 64 handleBlur(): void; 65 handleCompositionStart(data: string | null): void; 66 handleCompositionUpdate(data: string | null): void; 67 handleCompositionEnd(data: string | null): void; 68 handleAndroidEnter(): void; 69 syncCursor(): void; 70} 71interface JsEditorConstructor { 72 new (): JsEditor; 73 fromMarkdown(content: string): JsEditor; 74 fromSnapshot(snapshot: unknown): JsEditor; 75} 76interface WasmModule { 77 JsEditor: JsEditorConstructor; 78 create_resolved_content: () => JsResolvedContent; 79} 80/** 81 * Initialize the WASM module. 82 * 83 * Called automatically by createEditor, but can be called early 84 * to preload the module. 85 */ 86export declare function initWasm(): Promise<WasmModule>; 87/** 88 * Create a new editor instance. 89 */ 90export declare function createEditor(config: EditorConfig): Promise<Editor>; 91export { createCollabEditor, initCollabWasm } from "./collab"; 92//# sourceMappingURL=index.d.ts.map