From e3450cf558d9f8c779bf57793c853b04652ff2bf Mon Sep 17 00:00:00 2001 From: chris <kokosias@yahoo.gr> Date: Tue, 12 May 2020 16:05:29 +0300 Subject: [PATCH] fix if not track attrs for undo --- editors/editoria/src/Editoria.js | 1 - .../src/commands/Commands.js | 2 +- .../src/schema/SchemaHelpers.js | 19 ++++++++++--------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/editors/editoria/src/Editoria.js b/editors/editoria/src/Editoria.js index 9bbc674bc..375f028f5 100644 --- a/editors/editoria/src/Editoria.js +++ b/editors/editoria/src/Editoria.js @@ -52,7 +52,6 @@ const Editoria = () => ( TrackChange // onChange={source => console.log(source)} user={user} - debug /> </Fragment> ); diff --git a/wax-prosemirror-utilities/src/commands/Commands.js b/wax-prosemirror-utilities/src/commands/Commands.js index 555e9f2fd..9e6c94a18 100644 --- a/wax-prosemirror-utilities/src/commands/Commands.js +++ b/wax-prosemirror-utilities/src/commands/Commands.js @@ -2,8 +2,8 @@ import { v4 as uuidv4 } from "uuid"; const setBlockType = (nodeType, attrs = {}) => { return (state, dispatch) => { + const { tr } = state; const { from, to } = state.selection; - const tr = state.tr; state.doc.nodesBetween(from, to, (node, pos) => { if (!node.isTextblock || node.hasMarkup(nodeType, attrs)) return; let applicable = false; diff --git a/wax-prosemirror-utilities/src/schema/SchemaHelpers.js b/wax-prosemirror-utilities/src/schema/SchemaHelpers.js index 40cac9e01..79134bb58 100644 --- a/wax-prosemirror-utilities/src/schema/SchemaHelpers.js +++ b/wax-prosemirror-utilities/src/schema/SchemaHelpers.js @@ -11,7 +11,7 @@ const parseFormatList = str => { if (!Array.isArray(formatList)) { return []; } - return formatList.filter(format => typeof format === "string"); // ensure there are only strings in list + return formatList.filter(format => typeof format === "string"); }; const parseTracks = str => { @@ -38,14 +38,15 @@ const parseTracks = str => { }; const blockLevelToDOM = node => { - const attrs = node.attrs.track.length - ? { - "data-id": node.attrs.id, - class: node.attrs.class, - "data-track": JSON.stringify(node.attrs.track), - "data-group": node.attrs.group - } - : { class: node.attrs.class }; + const attrs = + node.attrs.track && node.attrs.track.length + ? { + "data-id": node.attrs.id, + class: node.attrs.class, + "data-track": JSON.stringify(node.attrs.track), + "data-group": node.attrs.group + } + : { class: node.attrs.class }; return attrs; }; -- GitLab