@curvenote/cli
Version:
CLI Client library for Curvenote
13 lines (12 loc) • 539 B
JavaScript
import { JSDOM } from 'jsdom';
import { server, fromHTML } from '@curvenote/schema';
export function getEditorState(content, schema = 'full') {
const { document, DOMParser } = new JSDOM('').window;
const state = server.getEditorState(schema, content, 0, document, DOMParser);
return state;
}
export function getEditorStateFromHTML(content, schema = 'full') {
const { document, DOMParser } = new JSDOM('').window;
const doc = fromHTML(content, schema, document, DOMParser);
return server.docToEditorState(doc, 0);
}