From 5ab1ba9b60e06c36670ca79b02e5f472a03385ad Mon Sep 17 00:00:00 2001 From: chris <kokosias@yahoo.gr> Date: Sun, 7 Mar 2021 11:00:11 +0200 Subject: [PATCH] fix track block undo --- .../src/nodes/bulletListNode.js | 24 +++++++++---------- wax-prosemirror-schema/src/nodes/imageNode.js | 2 +- .../src/nodes/listItemNode.js | 2 +- .../src/nodes/orderedListNode.js | 2 +- .../trackChangesNodes/authorTrackNode.js | 2 +- .../trackChangesNodes/customBlockTrackNode.js | 2 +- .../epigraphPoetryTrackNode.js | 2 +- .../epigraphProseTrackNode.js | 2 +- .../extractPoetryTrackNode.js | 2 +- .../extractProseTrackNode.js | 2 +- .../trackChangesNodes/headingTrackNode.js | 2 +- .../trackChangesNodes/orderedListTrackNode.js | 2 +- .../paragraphContTrackNode.js | 2 +- .../trackChangesNodes/sourceNoteTrackNode.js | 2 +- .../trackChangesNodes/subTitleTrackNode.js | 2 +- .../nodes/trackChangesNodes/titleTrackNode.js | 2 +- 16 files changed, 27 insertions(+), 27 deletions(-) diff --git a/wax-prosemirror-schema/src/nodes/bulletListNode.js b/wax-prosemirror-schema/src/nodes/bulletListNode.js index ed09e842d..314efd305 100644 --- a/wax-prosemirror-schema/src/nodes/bulletListNode.js +++ b/wax-prosemirror-schema/src/nodes/bulletListNode.js @@ -1,30 +1,30 @@ -import { SchemaHelpers } from "wax-prosemirror-utilities"; +import { SchemaHelpers } from 'wax-prosemirror-utilities'; const bulletlist = { - group: "block", - content: "list_item+", + group: 'block', + content: 'list_item+', attrs: { - track: { default: [] } + track: { default: [] }, }, parseDOM: [ { - tag: "ul", + tag: 'ul', getAttrs(hook, next) { Object.assign(hook, { - track: SchemaHelpers.parseTracks(hook.dom.dataset.track) + track: SchemaHelpers.parseTracks(hook.dom.dataset.track), }); next(); - } - } + }, + }, ], toDOM(hook, next) { const attrs = {}; - if (hook.node.attrs.track.length) { - attrs["data-track"] = JSON.stringify(hook.node.attrs.track); + if (hook.node.attrs.track && hook.node.attrs.track.length) { + attrs['data-track'] = JSON.stringify(hook.node.attrs.track); } - hook.value = ["ul", attrs, 0]; + hook.value = ['ul', attrs, 0]; next(); - } + }, }; export default bulletlist; diff --git a/wax-prosemirror-schema/src/nodes/imageNode.js b/wax-prosemirror-schema/src/nodes/imageNode.js index d74314f43..40e38f316 100644 --- a/wax-prosemirror-schema/src/nodes/imageNode.js +++ b/wax-prosemirror-schema/src/nodes/imageNode.js @@ -27,7 +27,7 @@ const image = { toDOM(hook, next) { const attrs = {}; let temp = ''; - if (hook.node.attrs.track.length) { + if (hook.node.attrs.track && hook.node.attrs.track.length) { attrs['data-track'] = JSON.stringify(hook.node.attrs.track); attrs['data-id'] = hook.node.attrs.id; } diff --git a/wax-prosemirror-schema/src/nodes/listItemNode.js b/wax-prosemirror-schema/src/nodes/listItemNode.js index ffc88e827..5c16de775 100644 --- a/wax-prosemirror-schema/src/nodes/listItemNode.js +++ b/wax-prosemirror-schema/src/nodes/listItemNode.js @@ -19,7 +19,7 @@ const list_item = { ], toDOM(hook, next) { const attrs = {}; - if (hook.node.attrs.track.length) { + if (hook.node.attrs.track && hook.node.attrs.track.length) { attrs['data-track'] = JSON.stringify(hook.node.attrs.track); } hook.value = ['li', attrs, 0]; diff --git a/wax-prosemirror-schema/src/nodes/orderedListNode.js b/wax-prosemirror-schema/src/nodes/orderedListNode.js index eb9761519..014d6e02d 100644 --- a/wax-prosemirror-schema/src/nodes/orderedListNode.js +++ b/wax-prosemirror-schema/src/nodes/orderedListNode.js @@ -26,7 +26,7 @@ const orderedlist = { if (hook.node.attrs.order !== 1) { attrs.start = hook.node.attrs.order; } - if (hook.node.attrs.track.length) { + if (hook.node.attrs.track && hook.node.attrs.track.length) { attrs['data-track'] = JSON.stringify(hook.node.attrs.track); } hook.value = ['ol', attrs, 0]; diff --git a/wax-prosemirror-schema/src/nodes/trackChangesNodes/authorTrackNode.js b/wax-prosemirror-schema/src/nodes/trackChangesNodes/authorTrackNode.js index cf812debc..984015c99 100644 --- a/wax-prosemirror-schema/src/nodes/trackChangesNodes/authorTrackNode.js +++ b/wax-prosemirror-schema/src/nodes/trackChangesNodes/authorTrackNode.js @@ -26,7 +26,7 @@ const author = { }, ], toDOM(hook, next) { - if (hook.node.attrs.track.length) { + if (hook.node.attrs.track && hook.node.attrs.track.length) { Object.assign(hook.value[1], { 'data-id': hook.node.attrs.id, 'data-track': JSON.stringify(hook.node.attrs.track), diff --git a/wax-prosemirror-schema/src/nodes/trackChangesNodes/customBlockTrackNode.js b/wax-prosemirror-schema/src/nodes/trackChangesNodes/customBlockTrackNode.js index c9413a700..2e764c4a1 100644 --- a/wax-prosemirror-schema/src/nodes/trackChangesNodes/customBlockTrackNode.js +++ b/wax-prosemirror-schema/src/nodes/trackChangesNodes/customBlockTrackNode.js @@ -26,7 +26,7 @@ const customBlockNode = { }, ], toDOM(hook, next) { - if (hook.node.attrs.track.length) { + if (hook.node.attrs.track && hook.node.attrs.track.length) { Object.assign(hook.value[1], { 'data-id': hook.node.attrs.id, 'data-track': JSON.stringify(hook.node.attrs.track), diff --git a/wax-prosemirror-schema/src/nodes/trackChangesNodes/epigraphPoetryTrackNode.js b/wax-prosemirror-schema/src/nodes/trackChangesNodes/epigraphPoetryTrackNode.js index c55f7a32d..d079f0379 100644 --- a/wax-prosemirror-schema/src/nodes/trackChangesNodes/epigraphPoetryTrackNode.js +++ b/wax-prosemirror-schema/src/nodes/trackChangesNodes/epigraphPoetryTrackNode.js @@ -26,7 +26,7 @@ const epigraphPoetry = { }, ], toDOM(hook, next) { - if (hook.node.attrs.track.length) { + if (hook.node.attrs.track && hook.node.attrs.track.length) { Object.assign(hook.value[1], { 'data-id': hook.node.attrs.id, 'data-track': JSON.stringify(hook.node.attrs.track), diff --git a/wax-prosemirror-schema/src/nodes/trackChangesNodes/epigraphProseTrackNode.js b/wax-prosemirror-schema/src/nodes/trackChangesNodes/epigraphProseTrackNode.js index d77610beb..f082da4ef 100644 --- a/wax-prosemirror-schema/src/nodes/trackChangesNodes/epigraphProseTrackNode.js +++ b/wax-prosemirror-schema/src/nodes/trackChangesNodes/epigraphProseTrackNode.js @@ -26,7 +26,7 @@ const epigraphProse = { }, ], toDOM(hook, next) { - if (hook.node.attrs.track.length) { + if (hook.node.attrs.track && hook.node.attrs.track.length) { Object.assign(hook.value[1], { 'data-id': hook.node.attrs.id, 'data-track': JSON.stringify(hook.node.attrs.track), diff --git a/wax-prosemirror-schema/src/nodes/trackChangesNodes/extractPoetryTrackNode.js b/wax-prosemirror-schema/src/nodes/trackChangesNodes/extractPoetryTrackNode.js index 9cff2b413..42ec054a9 100644 --- a/wax-prosemirror-schema/src/nodes/trackChangesNodes/extractPoetryTrackNode.js +++ b/wax-prosemirror-schema/src/nodes/trackChangesNodes/extractPoetryTrackNode.js @@ -26,7 +26,7 @@ const extractPoetry = { }, ], toDOM(hook, next) { - if (hook.node.attrs.track.length) { + if (hook.node.attrs.track && hook.node.attrs.track.length) { Object.assign(hook.value[1], { 'data-id': hook.node.attrs.id, 'data-track': JSON.stringify(hook.node.attrs.track), diff --git a/wax-prosemirror-schema/src/nodes/trackChangesNodes/extractProseTrackNode.js b/wax-prosemirror-schema/src/nodes/trackChangesNodes/extractProseTrackNode.js index c6e9363fd..2e6f4ec81 100644 --- a/wax-prosemirror-schema/src/nodes/trackChangesNodes/extractProseTrackNode.js +++ b/wax-prosemirror-schema/src/nodes/trackChangesNodes/extractProseTrackNode.js @@ -26,7 +26,7 @@ const extractProse = { }, ], toDOM(hook, next) { - if (hook.node.attrs.track.length) { + if (hook.node.attrs.track && hook.node.attrs.track.length) { Object.assign(hook.value[1], { 'data-id': hook.node.attrs.id, 'data-track': JSON.stringify(hook.node.attrs.track), diff --git a/wax-prosemirror-schema/src/nodes/trackChangesNodes/headingTrackNode.js b/wax-prosemirror-schema/src/nodes/trackChangesNodes/headingTrackNode.js index a0af93970..db059daa9 100644 --- a/wax-prosemirror-schema/src/nodes/trackChangesNodes/headingTrackNode.js +++ b/wax-prosemirror-schema/src/nodes/trackChangesNodes/headingTrackNode.js @@ -49,7 +49,7 @@ const heading = { }, ], toDOM(hook, next) { - if (hook.node.attrs.track.length) { + if (hook.node.attrs.track && hook.node.attrs.track.length) { Object.assign(hook.value[1], { 'data-id': hook.node.attrs.id, 'data-track': JSON.stringify(hook.node.attrs.track), diff --git a/wax-prosemirror-schema/src/nodes/trackChangesNodes/orderedListTrackNode.js b/wax-prosemirror-schema/src/nodes/trackChangesNodes/orderedListTrackNode.js index c3727ca77..56ac769bc 100644 --- a/wax-prosemirror-schema/src/nodes/trackChangesNodes/orderedListTrackNode.js +++ b/wax-prosemirror-schema/src/nodes/trackChangesNodes/orderedListTrackNode.js @@ -24,7 +24,7 @@ const orderedlist = { }, ], toDOM(hook, next) { - if (hook.node.attrs.track.length) { + if (hook.node.attrs.track && hook.node.attrs.track.length) { Object.assign(hook.value[1], { 'data-id': hook.node.attrs.id, 'data-track': JSON.stringify(hook.node.attrs.track), diff --git a/wax-prosemirror-schema/src/nodes/trackChangesNodes/paragraphContTrackNode.js b/wax-prosemirror-schema/src/nodes/trackChangesNodes/paragraphContTrackNode.js index 35a760346..5752f8e2a 100644 --- a/wax-prosemirror-schema/src/nodes/trackChangesNodes/paragraphContTrackNode.js +++ b/wax-prosemirror-schema/src/nodes/trackChangesNodes/paragraphContTrackNode.js @@ -26,7 +26,7 @@ const paragraphCont = { }, ], toDOM(hook, next) { - if (hook.node.attrs.track.length) { + if (hook.node.attrs.track && hook.node.attrs.track.length) { Object.assign(hook.value[1], { 'data-id': hook.node.attrs.id, 'data-track': JSON.stringify(hook.node.attrs.track), diff --git a/wax-prosemirror-schema/src/nodes/trackChangesNodes/sourceNoteTrackNode.js b/wax-prosemirror-schema/src/nodes/trackChangesNodes/sourceNoteTrackNode.js index 89c7debea..d87b2d7fb 100644 --- a/wax-prosemirror-schema/src/nodes/trackChangesNodes/sourceNoteTrackNode.js +++ b/wax-prosemirror-schema/src/nodes/trackChangesNodes/sourceNoteTrackNode.js @@ -26,7 +26,7 @@ const sourceNote = { }, ], toDOM(hook, next) { - if (hook.node.attrs.track.length) { + if (hook.node.attrs.track && hook.node.attrs.track.length) { Object.assign(hook.value[1], { 'data-id': hook.node.attrs.id, 'data-track': JSON.stringify(hook.node.attrs.track), diff --git a/wax-prosemirror-schema/src/nodes/trackChangesNodes/subTitleTrackNode.js b/wax-prosemirror-schema/src/nodes/trackChangesNodes/subTitleTrackNode.js index 16f566567..a9183b6de 100644 --- a/wax-prosemirror-schema/src/nodes/trackChangesNodes/subTitleTrackNode.js +++ b/wax-prosemirror-schema/src/nodes/trackChangesNodes/subTitleTrackNode.js @@ -26,7 +26,7 @@ const subtitle = { }, ], toDOM(hook, next) { - if (hook.node.attrs.track.length) { + if (hook.node.attrs.track && hook.node.attrs.track.length) { Object.assign(hook.value[1], { 'data-id': hook.node.attrs.id, 'data-track': JSON.stringify(hook.node.attrs.track), diff --git a/wax-prosemirror-schema/src/nodes/trackChangesNodes/titleTrackNode.js b/wax-prosemirror-schema/src/nodes/trackChangesNodes/titleTrackNode.js index 8276e0cf8..e9128da51 100644 --- a/wax-prosemirror-schema/src/nodes/trackChangesNodes/titleTrackNode.js +++ b/wax-prosemirror-schema/src/nodes/trackChangesNodes/titleTrackNode.js @@ -26,7 +26,7 @@ const title = { }, ], toDOM(hook, next) { - if (hook.node.attrs.track.length) { + if (hook.node.attrs.track && hook.node.attrs.track.length) { Object.assign(hook.value[1], { 'data-id': hook.node.attrs.id, 'data-track': JSON.stringify(hook.node.attrs.track), -- GitLab