prosemirror-state
Advanced tools
Comparing version 1.1.1 to 1.2.0
@@ -0,1 +1,9 @@ | ||
## 1.2.0 (2018-04-05) | ||
### New features | ||
[`EditorState.create`](https://prosemirror.net/docs/ref/#state.EditorState^create) now accepts a `storedMark` option to set the state's stored marks. | ||
[`EditorState.toJSON`](https://prosemirror.net/docs/ref/#state.EditorState.toJSON) and [`fromJSON`](https://prosemirror.net/docs/ref/#state.EditorState^fromJSON) persist the set of stored marks, when available. | ||
## 1.1.1 (2018-03-15) | ||
@@ -2,0 +10,0 @@ |
@@ -732,3 +732,3 @@ 'use strict'; | ||
new FieldDesc("storedMarks", { | ||
init: function init() { return null }, | ||
init: function init(config) { return config.storedMarks || null }, | ||
apply: function apply(tr, _marks, _old, state) { return state.selection.$cursor ? tr.storedMarks : null } | ||
@@ -889,2 +889,5 @@ }), | ||
// | ||
// storedMarks:: ?[Mark] | ||
// The initial set of [stored marks](#state.EditorState.storedMarks). | ||
// | ||
// plugins:: ?[Plugin] | ||
@@ -937,2 +940,3 @@ // The plugins that should be active in this state. | ||
var result = {doc: this.doc.toJSON(), selection: this.selection.toJSON()}; | ||
if (this.storedMarks) { result.storedMarks = this.storedMarks.map(function (m) { return m.toJSON(); }); } | ||
if (pluginFields && typeof pluginFields == 'object') { for (var prop in pluginFields) { | ||
@@ -971,2 +975,4 @@ if (prop == "doc" || prop == "selection") | ||
instance.selection = Selection.fromJSON(instance.doc, json.selection); | ||
} else if (field.name == "storedMarks") { | ||
if (json.storedMarks) { instance.storedMarks = json.storedMarks.map(config.schema.markFromJSON); } | ||
} else { | ||
@@ -973,0 +979,0 @@ if (pluginFields) { for (var prop in pluginFields) { |
{ | ||
"name": "prosemirror-state", | ||
"version": "1.1.1", | ||
"version": "1.2.0", | ||
"description": "ProseMirror editor state", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -30,3 +30,3 @@ import {Node} from "prosemirror-model" | ||
new FieldDesc("storedMarks", { | ||
init() { return null }, | ||
init(config) { return config.storedMarks || null }, | ||
apply(tr, _marks, _old, state) { return state.selection.$cursor ? tr.storedMarks : null } | ||
@@ -179,2 +179,5 @@ }), | ||
// | ||
// storedMarks:: ?[Mark] | ||
// The initial set of [stored marks](#state.EditorState.storedMarks). | ||
// | ||
// plugins:: ?[Plugin] | ||
@@ -223,2 +226,3 @@ // The plugins that should be active in this state. | ||
let result = {doc: this.doc.toJSON(), selection: this.selection.toJSON()} | ||
if (this.storedMarks) result.storedMarks = this.storedMarks.map(m => m.toJSON()) | ||
if (pluginFields && typeof pluginFields == 'object') for (let prop in pluginFields) { | ||
@@ -257,2 +261,4 @@ if (prop == "doc" || prop == "selection") | ||
instance.selection = Selection.fromJSON(instance.doc, json.selection) | ||
} else if (field.name == "storedMarks") { | ||
if (json.storedMarks) instance.storedMarks = json.storedMarks.map(config.schema.markFromJSON) | ||
} else { | ||
@@ -259,0 +265,0 @@ if (pluginFields) for (let prop in pluginFields) { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
171851
1970