useEditorContext
Return the editor from the nearest editor container.
Similar to TipTap's useCurrentEditor
hook.
Code example
import { useEditorContext } from "swash/editor";
function EditorJSONPreview() {
const { editor } = useEditorContext();
if (!editor) {
throw new Error("EditorJSONPreview must be wrapped in an EditorProvider");
}
return <pre>{JSON.stringify(editor.getJSON(), null, 2)}</pre>;
}