diff --git a/wax-prosemirror-services/src/TrackChangeService/AcceptTrackChangeService/AcceptTrackChange.js b/wax-prosemirror-services/src/TrackChangeService/AcceptTrackChangeService/AcceptTrackChange.js index b32d56a15ee3419b223db380686c2ed1132465a2..7afad204f700ffa84acbfa99792d0bca26c28403 100644 --- a/wax-prosemirror-services/src/TrackChangeService/AcceptTrackChangeService/AcceptTrackChange.js +++ b/wax-prosemirror-services/src/TrackChangeService/AcceptTrackChangeService/AcceptTrackChange.js @@ -8,7 +8,29 @@ class AcceptTrackChange extends Tools { content = 'Accept'; get run() { - return (state, dispatch) => {}; + return (state, dispatch) => { + const { + selection: { from, to }, + } = state; + + state.doc.nodesBetween(from, to, (node, pos) => { + if ( + node.marks && + node.marks.find(mark => mark.type.name === 'insertion') + ) { + const insertionMark = node.marks.find( + mark => mark.type.name === 'insertion', + ); + dispatch( + state.tr.removeMark( + insertionMark.pos, + insertionMark.pos + node.nodeSize, + state.schema.marks.insertion, + ), + ); + } + }); + }; } get active() {