yjs-editorjs-binding
Version:
Editor.js binding for yjs
41 lines (40 loc) • 1.15 kB
TypeScript
import EditorJS, { API } from "@editorjs/editorjs";
import { Array as YArray } from "yjs";
export declare class YJSEditorJSBinding {
editor?: EditorJS;
private yArray;
private internalStore;
private mutex;
private isReady;
constructor(yArray: YArray<any>);
/**
* Initialize our binding with Editor JS and Y doc array.
* @param editor
*/
bindEditor(editor: EditorJS): Promise<void>;
/**
* Listen to Editor JS `onChange(...)` block events and update our Y Doc array.
* @param api
* @param event
* @returns
*/
onBlockEventEditorJS(api: API, event: CustomEvent): Promise<void>;
/**
* Computed array version of our internalStore map
*/
private get internalStoreAsArray();
/**
* Initial pass at rendering Y doc to Editor JS. Only happens once, at the start.
*/
private initialRenderYdocToEditorJS;
/**
* Listen to changes in our yArray
*/
private deeplyObserveyArray;
/**
* Render into Editor JS and track within our internalStore
* @param editorBlock
* @param index
*/
private renderBlock;
}