UNPKG

@curvenote/schema

Version:

Schema and markdown parser for @curvenote/editor

13 lines 602 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.fromJSON = void 0; const prosemirror_state_1 = require("prosemirror-state"); const schemas_1 = require("../../schemas"); function fromJSON(content, useSchema) { const schema = (0, schemas_1.getSchema)(useSchema); const data = typeof content === 'string' ? JSON.parse(content) : content; const state = prosemirror_state_1.EditorState.fromJSON({ schema }, { doc: data, selection: { type: 'text', anchor: 0, head: 0 } }); return state.doc; } exports.fromJSON = fromJSON; //# sourceMappingURL=index.js.map