@technik-sde/prosemirror-recreate-transform
Advanced tools
Comparing version 1.0.1 to 1.1.0
{ | ||
"name": "@technik-sde/prosemirror-recreate-transform", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "Create a set of steps transforming one prosemirror json document to another", | ||
@@ -5,0 +5,0 @@ "main": "dist/recreateTransform.js", |
@@ -151,3 +151,14 @@ import { Transform } from "prosemirror-transform"; | ||
const nodeType = fromNode.type === toNode.type ? null : toNode.type; | ||
this.tr.setNodeMarkup(start, nodeType, toNode.attrs, toNode.marks); | ||
try { | ||
this.tr.setNodeMarkup(start, nodeType, toNode.attrs, toNode.marks); | ||
} catch (e) { | ||
// if nodetypes differ, the updated node-type and contents might not be compatible | ||
// with schema and requires a replace | ||
if (nodeType && e.message.includes("Invalid content")) { | ||
// @todo add test-case for this scenario | ||
this.tr.replaceWith(start, start + fromNode.nodeSize, toNode); | ||
} else { | ||
throw e; | ||
} | ||
} | ||
this.currentJSON = removeMarks(this.tr.doc).toJSON(); | ||
@@ -154,0 +165,0 @@ // setting the node markup may have invalidated the following ops, so we calculate them again. |
Sorry, the diff of this file is too big to display
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
599323
1623