@guardian/prosemirror-noting
Advanced tools
Comparing version 3.1.4 to 3.1.5
@@ -10,3 +10,3 @@ 'use strict'; | ||
var uuid = _interopDefault(require('uuid/v1')); | ||
var v4 = _interopDefault(require('uuid/v4')); | ||
var uuid$1 = _interopDefault(require('uuid/v4')); | ||
var prosemirrorView = require('prosemirror-view'); | ||
@@ -103,3 +103,3 @@ | ||
if (n === "Object" && o.constructor) n = o.constructor.name; | ||
if (n === "Map" || n === "Set") return Array.from(n); | ||
if (n === "Map" || n === "Set") return Array.from(o); | ||
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); | ||
@@ -130,3 +130,3 @@ } | ||
} else if (val instanceof Object) { | ||
return Object.keys(val).reduce(function (out, key) { | ||
return [].concat(_toConsumableArray(Object.getOwnPropertySymbols(val)), _toConsumableArray(Object.keys(val))).reduce(function (out, key) { | ||
return Object.assign({}, out, _defineProperty({}, key, cloneDeep(val[key]))); | ||
@@ -259,3 +259,3 @@ }, {}); | ||
var sanitizeFragmentInner = function sanitizeFragmentInner(frag, markType) { | ||
var createId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : v4; | ||
var createId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : uuid$1; | ||
var idMap = {}; // the current id of the node according to the input document | ||
@@ -1057,2 +1057,4 @@ | ||
var MetaIdKey = Symbol("meta-id-key"); | ||
var createNoteWrapper = function createNoteWrapper(meta, cursorPos, inside) { | ||
@@ -1071,6 +1073,8 @@ var pluginPriority = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1; | ||
var sideAdjustedForPluginPriority = sideToRender + pluginPriority / Number.MAX_SAFE_INTEGER * Math.sign(side); // A unique key for the widget. It must change to force a render | ||
var sideAdjustedForPluginPriority = sideToRender + pluginPriority / Number.MAX_SAFE_INTEGER * Math.sign(side); // If the meta has changed, a unique key will be set to force a rerender. | ||
var maybeMetaKey = meta[MetaIdKey] ? "-".concat(meta[MetaIdKey]) : ""; // A unique key for the widget. It must change to force a render | ||
// every time we'd like the cursor behaviour to change. | ||
var key = "".concat(id, "-").concat(sideAdjustedForPluginPriority); | ||
var key = "".concat(id, "-").concat(sideAdjustedForPluginPriority).concat(maybeMetaKey); | ||
@@ -1389,3 +1393,3 @@ var toDom = function toDom() { | ||
id: id, | ||
meta: meta | ||
meta: Object.assign({}, meta, _defineProperty({}, MetaIdKey, uuid$1())) | ||
}]); | ||
@@ -1392,0 +1396,0 @@ }; |
{ | ||
"name": "@guardian/prosemirror-noting", | ||
"version": "3.1.4", | ||
"version": "3.1.5", | ||
"description": "A plugin to allow noting in prosemirror", | ||
@@ -5,0 +5,0 @@ "main": "dist/noting.js", |
@@ -5,3 +5,3 @@ import { Plugin, PluginKey } from "prosemirror-state"; | ||
import NoteTransaction from "./NoteTransaction"; | ||
import { createDecorateNotes } from "./utils/DecorationUtils"; | ||
import { createDecorateNotes, MetaIdKey } from "./utils/DecorationUtils"; | ||
import clickHandler from "./clickHandler"; | ||
@@ -15,2 +15,3 @@ import { | ||
import SharedNoteStateTracker from "./SharedNoteStateTracker"; | ||
import uuid from "uuid/v4"; | ||
@@ -38,3 +39,6 @@ const toggleNote = key => (type, cursorToEnd = false) => (state, dispatch) => | ||
const setNoteMeta = key => (id, meta) => setNotesMeta(key)([{ id, meta }]); | ||
const setNoteMeta = key => (id, meta) => | ||
setNotesMeta(key)([ | ||
{ id, meta: Object.assign({}, meta, { [MetaIdKey]: uuid() }) } | ||
]); | ||
@@ -41,0 +45,0 @@ const collapseAllNotes = key => () => (state, dispatch) => { |
import { DecorationSet, Decoration } from "prosemirror-view"; | ||
export const MetaIdKey = Symbol("meta-id-key"); | ||
const createNoteWrapper = ( | ||
@@ -25,5 +27,8 @@ meta, | ||
// If the meta has changed, a unique key will be set to force a rerender. | ||
const maybeMetaKey = meta[MetaIdKey] ? `-${meta[MetaIdKey]}` : ""; | ||
// A unique key for the widget. It must change to force a render | ||
// every time we'd like the cursor behaviour to change. | ||
const key = `${id}-${sideAdjustedForPluginPriority}`; | ||
const key = `${id}-${sideAdjustedForPluginPriority}${maybeMetaKey}`; | ||
@@ -30,0 +35,0 @@ const toDom = () => { |
@@ -7,3 +7,3 @@ // This might need improving, pretty thing implementation but for now it will | ||
} else if (val instanceof Object) { | ||
return Object.keys(val).reduce( | ||
return [...Object.getOwnPropertySymbols(val), ...Object.keys(val)].reduce( | ||
(out, key) => | ||
@@ -10,0 +10,0 @@ Object.assign({}, out, { |
import { AllSelection } from "prosemirror-state"; | ||
import { Fragment } from "prosemirror-model"; | ||
import v4 from "uuid/v4"; | ||
import uuid from "uuid/v4"; | ||
@@ -40,3 +40,3 @@ // Runs through a Fragment's nodes and runs `updater` on them, | ||
// e.g. <note id="1">test</note> some <note id="2">stuff</note> | ||
const sanitizeFragmentInner = (frag, markType, createId = v4) => { | ||
const sanitizeFragmentInner = (frag, markType, createId = uuid) => { | ||
let idMap = {}; | ||
@@ -43,0 +43,0 @@ // the current id of the node according to the input document |
272730
2504