Skip to content
Snippets Groups Projects
Commit 7a7f2bea authored by chris's avatar chris
Browse files

pass group to markWrapping

parent 2c0c3089
No related branches found
No related tags found
1 merge request!109Track changes ids
......@@ -56,8 +56,9 @@ export default props => {
const dispatchTransaction = transaction => {
const { TrackChange } = props;
const group = "main";
const tr = TrackChange
? trackedTransaction(transaction, view.state, user)
? trackedTransaction(transaction, view.state, user, group)
: transaction;
const state = view.state.apply(tr);
......
......@@ -20,7 +20,6 @@ const author = {
toDOM(hook, next) {
const attrs = { class: hook.node.attrs.class };
hook.value = ["p", attrs, 0];
console.log(hook);
next();
}
};
......
......@@ -25,7 +25,6 @@ const author = {
],
toDOM(hook, next) {
if (hook.node.attrs.track.length) {
console.log(hook);
Object.assign(hook.value[1], {
"data-id": hook.node.attrs.id,
"data-track": JSON.stringify(hook.node.attrs.track),
......
import { v4 as uuidv4 } from "uuid";
const markWrapping = (tr, pos, oldNode, newNode, user, date) => {
const markWrapping = (tr, pos, oldNode, newNode, user, date, group) => {
let track = oldNode.attrs.track.slice(),
blockTrack = track.find(track => track.type === "block_change");
......@@ -35,7 +35,11 @@ const markWrapping = (tr, pos, oldNode, newNode, user, date) => {
}
track.push(blockTrack);
}
tr.setNodeMarkup(pos, null, Object.assign({}, newNode.attrs, { track }));
tr.setNodeMarkup(
pos,
null,
Object.assign({}, newNode.attrs, { track, group })
);
};
export default markWrapping;
......@@ -2,17 +2,29 @@ import markDeletion from "./markDeletion";
import markInsertion from "./markInsertion";
import markWrapping from "./markWrapping";
const replaceAroundStep = (state, tr, step, newTr, map, doc, user, date) => {
const replaceAroundStep = (
state,
tr,
step,
newTr,
map,
doc,
user,
date,
group
) => {
if (step.from === step.gapFrom && step.to === step.gapTo) {
// wrapped in something
newTr.step(step);
const from = step.getMap().map(step.from, -1);
const to = step.getMap().map(step.gapFrom);
markInsertion(newTr, from, to, user, date);
markInsertion(newTr, from, to, user, date, group);
} else if (!step.slice.size) {
// unwrapped from something
map.appendMap(step.invert(doc).getMap());
map.appendMap(markDeletion(newTr, step.from, step.gapFrom, user, date));
map.appendMap(
markDeletion(newTr, step.from, step.gapFrom, user, date, group)
);
} else if (
step.slice.size === 2 &&
step.gapFrom - step.from === 1 &&
......@@ -28,7 +40,8 @@ const replaceAroundStep = (state, tr, step, newTr, map, doc, user, date) => {
oldNode,
step.slice.content.firstChild,
user,
date
date,
group
);
}
} else {
......
......@@ -20,7 +20,7 @@ import replaceAroundStep from "./helpers/replaceAroundStep";
import addMarkStep from "./helpers/addMarkStep";
import removeMarkStep from "./helpers/removeMarkStep";
const trackedTransaction = (tr, state, user) => {
const trackedTransaction = (tr, state, user, group) => {
if (
!tr.steps.length ||
(tr.meta &&
......@@ -45,16 +45,16 @@ const trackedTransaction = (tr, state, user) => {
switch (step.constructor) {
case ReplaceStep:
replaceStep(state, tr, step, newTr, map, doc, user, date);
replaceStep(state, tr, step, newTr, map, doc, user, date, group);
break;
case ReplaceAroundStep:
replaceAroundStep(state, tr, step, newTr, map, doc, user, date);
replaceAroundStep(state, tr, step, newTr, map, doc, user, date, group);
break;
case AddMarkStep:
addMarkStep(state, tr, step, newTr, map, doc, user, date);
addMarkStep(state, tr, step, newTr, map, doc, user, date, group);
break;
case RemoveMarkStep:
removeMarkStep(state, tr, step, newTr, map, doc, user, date);
removeMarkStep(state, tr, step, newTr, map, doc, user, date, group);
break;
}
});
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment