@prosekit/core 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_tsup-dts-rollup.d.ts +18 -0
- package/dist/prosekit-core.d.ts +2 -0
- package/dist/prosekit-core.js +11 -2
- package/package.json +1 -1
@@ -731,6 +731,15 @@ declare function nodeFromHTML(html: string, schema: Schema): ProseMirrorNode;
|
|
731
731
|
export { nodeFromHTML }
|
732
732
|
export { nodeFromHTML as nodeFromHTML_alias_1 }
|
733
733
|
|
734
|
+
/**
|
735
|
+
* Parse a JSON object to a ProseMirror node.
|
736
|
+
*
|
737
|
+
* @public
|
738
|
+
*/
|
739
|
+
declare function nodeFromJSON(json: NodeJSON, schema: Schema): ProseMirrorNode;
|
740
|
+
export { nodeFromJSON }
|
741
|
+
export { nodeFromJSON as nodeFromJSON_alias_1 }
|
742
|
+
|
734
743
|
/**
|
735
744
|
* A JSON representation of the prosemirror node.
|
736
745
|
*
|
@@ -896,6 +905,15 @@ export { SimplifyUnion as SimplifyUnion_alias_1 }
|
|
896
905
|
|
897
906
|
export declare const stateFacet: Facet<StatePayload, StatePayload>;
|
898
907
|
|
908
|
+
/**
|
909
|
+
* Parse a JSON object to a ProseMirror state.
|
910
|
+
*
|
911
|
+
* @public
|
912
|
+
*/
|
913
|
+
declare function stateFromJSON(json: StateJSON, schema: Schema): EditorState;
|
914
|
+
export { stateFromJSON }
|
915
|
+
export { stateFromJSON as stateFromJSON_alias_1 }
|
916
|
+
|
899
917
|
/**
|
900
918
|
* A JSON representation of the prosemirror state.
|
901
919
|
*
|
package/dist/prosekit-core.d.ts
CHANGED
@@ -57,6 +57,8 @@ export { jsonFromNode } from './_tsup-dts-rollup';
|
|
57
57
|
export { jsonFromState } from './_tsup-dts-rollup';
|
58
58
|
export { nodeFromElement } from './_tsup-dts-rollup';
|
59
59
|
export { nodeFromHTML } from './_tsup-dts-rollup';
|
60
|
+
export { nodeFromJSON } from './_tsup-dts-rollup';
|
61
|
+
export { stateFromJSON } from './_tsup-dts-rollup';
|
60
62
|
export { isAllSelection } from './_tsup-dts-rollup';
|
61
63
|
export { isMark } from './_tsup-dts-rollup';
|
62
64
|
export { isNodeSelection } from './_tsup-dts-rollup';
|
package/dist/prosekit-core.js
CHANGED
@@ -217,7 +217,7 @@ function toggleNode({
|
|
217
217
|
|
218
218
|
// src/editor/editor.ts
|
219
219
|
import { Schema as Schema6 } from "@prosekit/pm/model";
|
220
|
-
import { EditorState } from "@prosekit/pm/state";
|
220
|
+
import { EditorState as EditorState2 } from "@prosekit/pm/state";
|
221
221
|
import { EditorView } from "@prosekit/pm/view";
|
222
222
|
|
223
223
|
// src/extensions/default-state.ts
|
@@ -340,6 +340,7 @@ var stateFacet = Facet.defineRootFacet({
|
|
340
340
|
|
341
341
|
// src/utils/parse.ts
|
342
342
|
import { DOMParser } from "@prosekit/pm/model";
|
343
|
+
import { EditorState } from "@prosekit/pm/state";
|
343
344
|
|
344
345
|
// src/utils/get-dom-api.ts
|
345
346
|
function getGlobalBrowserDocument() {
|
@@ -396,6 +397,12 @@ function jsonFromState(state) {
|
|
396
397
|
function jsonFromNode(node) {
|
397
398
|
return node.toJSON();
|
398
399
|
}
|
400
|
+
function nodeFromJSON(json, schema) {
|
401
|
+
return schema.nodeFromJSON(json);
|
402
|
+
}
|
403
|
+
function stateFromJSON(json, schema) {
|
404
|
+
return EditorState.fromJSON({ schema }, json);
|
405
|
+
}
|
399
406
|
|
400
407
|
// src/extensions/default-state.ts
|
401
408
|
function defineDefaultState({
|
@@ -837,7 +844,7 @@ var EditorInstance = class {
|
|
837
844
|
}
|
838
845
|
const schema = new Schema6(schemaInput);
|
839
846
|
const stateConfig = stateInput ? stateInput({ schema }) : { schema };
|
840
|
-
const state =
|
847
|
+
const state = EditorState2.create(stateConfig);
|
841
848
|
if (commandInput) {
|
842
849
|
for (const [name, commandCreator] of Object.entries(commandInput)) {
|
843
850
|
this.defineCommand(name, commandCreator);
|
@@ -1447,9 +1454,11 @@ export {
|
|
1447
1454
|
jsonFromState,
|
1448
1455
|
nodeFromElement,
|
1449
1456
|
nodeFromHTML,
|
1457
|
+
nodeFromJSON,
|
1450
1458
|
pluginFacet,
|
1451
1459
|
removeMark,
|
1452
1460
|
setBlockType,
|
1461
|
+
stateFromJSON,
|
1453
1462
|
toggleMark,
|
1454
1463
|
toggleNode,
|
1455
1464
|
union,
|