diff --git a/wax-prosemirror-services/src/TrackChangeService/track-changes/helpers/removeNode.js b/wax-prosemirror-services/src/TrackChangeService/track-changes/helpers/removeNode.js new file mode 100644 index 0000000000000000000000000000000000000000..1612e92a002f0d62afcbae14a6f44ce8ea226d83 --- /dev/null +++ b/wax-prosemirror-services/src/TrackChangeService/track-changes/helpers/removeNode.js @@ -0,0 +1,23 @@ +import { + ReplaceStep, + ReplaceAroundStep, + replaceStep, +} from 'prosemirror-transform'; +import { Slice } from 'prosemirror-model'; +import { Selection, TextSelection, EditorState } from 'prosemirror-state'; +import { liftListItem } from 'prosemirror-schema-list'; + +const removeNode = (tr, node, nodePos, map, accept) => { + const newNodePos = map.map(nodePos); + const selectionBefore = Selection.findFrom(tr.doc.resolve(newNodePos), -1); + const start = selectionBefore.$anchor.pos; + const end = newNodePos + 1; + + const delStep = ReplaceStep(tr.doc, start, end); + + tr.step(delStep); + const stepMap = delStep.getMap(); + map.appendMap(stepMap); +}; + +export default removeNode;