@guardian/prosemirror-noting
Advanced tools
Comparing version 3.0.1 to 3.1.0
@@ -256,4 +256,4 @@ 'use strict'; | ||
var sanitizeFragment = function sanitizeFragment(frag, markType) { | ||
var getId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : v4; | ||
var sanitizeFragmentInner = function sanitizeFragmentInner(frag, markType) { | ||
var createId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : v4; | ||
var idMap = {}; // the current id of the node according to the input document | ||
@@ -264,3 +264,3 @@ | ||
var setNewId = function setNewId(prevId) { | ||
var newId = !idMap[prevId] ? prevId : getId(); | ||
var newId = !idMap[prevId] ? prevId : createId(); | ||
idMap[prevId] = newId; | ||
@@ -304,6 +304,17 @@ currentNoteId = prevId; | ||
})(frag); | ||
}; | ||
var wrap = function wrap(value) { | ||
return Array.isArray(value) ? value : [value]; | ||
}; // markTypes can either be a MarkType or MarkType[] | ||
var sanitizeFragment = function sanitizeFragment(frag, markTypes, createId) { | ||
return wrap(markTypes).reduce(function (nextFrag, markType) { | ||
return sanitizeFragmentInner(nextFrag, markType, createId); | ||
}, frag); | ||
}; // Similar to sanitizeFragment but allows a node to be passed instead | ||
var sanitizeNode = function sanitizeNode(node, markType, getId) { | ||
return node.copy(sanitizeFragment(node.content, markType, getId)); | ||
var sanitizeNode = function sanitizeNode(node, markTypes, createId) { | ||
return node.copy(sanitizeFragment(node.content, markTypes, createId)); | ||
}; // Return an array of all of the new ranges in a document [[start, end], ...] | ||
@@ -310,0 +321,0 @@ |
{ | ||
"name": "@guardian/prosemirror-noting", | ||
"version": "3.0.1", | ||
"version": "3.1.0", | ||
"description": "A plugin to allow noting in prosemirror", | ||
@@ -5,0 +5,0 @@ "main": "dist/noting.js", |
@@ -40,3 +40,3 @@ import { AllSelection } from "prosemirror-state"; | ||
// e.g. <note id="1">test</note> some <note id="2">stuff</note> | ||
export const sanitizeFragment = (frag, markType, getId = v4) => { | ||
const sanitizeFragmentInner = (frag, markType, createId = v4) => { | ||
let idMap = {}; | ||
@@ -47,3 +47,3 @@ // the current id of the node according to the input document | ||
const setNewId = prevId => { | ||
const newId = !idMap[prevId] ? prevId : getId(); | ||
const newId = !idMap[prevId] ? prevId : createId(); | ||
idMap[prevId] = newId; | ||
@@ -87,5 +87,14 @@ currentNoteId = prevId; | ||
const wrap = value => (Array.isArray(value) ? value : [value]); | ||
// markTypes can either be a MarkType or MarkType[] | ||
export const sanitizeFragment = (frag, markTypes, createId) => | ||
wrap(markTypes).reduce( | ||
(nextFrag, markType) => sanitizeFragmentInner(nextFrag, markType, createId), | ||
frag | ||
); | ||
// Similar to sanitizeFragment but allows a node to be passed instead | ||
export const sanitizeNode = (node, markType, getId) => | ||
node.copy(sanitizeFragment(node.content, markType, getId)); | ||
export const sanitizeNode = (node, markTypes, createId) => | ||
node.copy(sanitizeFragment(node.content, markTypes, createId)); | ||
@@ -92,0 +101,0 @@ // Return an array of all of the new ranges in a document [[start, end], ...] |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
2019401
2440
1