Commit 3d4906f5 authored by chris's avatar chris

fixes

parent d4865270
......@@ -3,4 +3,3 @@ export { default as CreateSchema } from "./src/config/classes/CreateSchema";
export {
default as CreateShortCuts
} from "./src/config/classes/CreateShortCuts";
export { amendTransaction } from "./src/amend_transaction";
......@@ -8,6 +8,7 @@ import placeholderPlugin from "./config/plugins/placeholderPlugin";
import "prosemirror-view/style/prosemirror.css";
import "prosemirror-gapcursor/style/gapcursor.css";
import { amendTransaction } from "./amend_transaction";
import trackedTransaction from "./trackedTransaction";
class WaxView extends Component {
constructor(props) {
......@@ -94,8 +95,7 @@ class WaxView extends Component {
};
dispatchTransaction = transaction => {
console.log(amendTransaction(transaction, this.view.state, this));
const trackedTr = amendTransaction(transaction, this.view.state, this);
const trackedTr = trackedTransaction(transaction, this.view.state, this);
const state = this.view.state.apply(trackedTr);
this.view.updateState(state);
this.props.onChange(state.doc.content);
......
......@@ -9,7 +9,16 @@ import {
} from "prosemirror-transform";
import { CellSelection } from "prosemirror-tables";
function markInsertion(tr, from, to, user, username, date1, date10, approved) {
const markInsertion = (
tr,
from,
to,
user,
username,
date1,
date10,
approved
) => {
tr.removeMark(from, to, tr.doc.type.schema.marks.deletion);
tr.removeMark(from, to, tr.doc.type.schema.marks.insertion);
const insertionMark = tr.doc.type.schema.marks.insertion.create({
......@@ -49,9 +58,9 @@ function markInsertion(tr, from, to, user, username, date1, date10, approved) {
return false;
}
});
}
};
function markDeletion(tr, from, to, user, username, date1, date10) {
const markDeletion = (tr, from, to, user, username, date1, date10) => {
const deletionMark = tr.doc.type.schema.marks.deletion.create({
user,
username,
......@@ -142,9 +151,9 @@ function markDeletion(tr, from, to, user, username, date1, date10) {
});
return deletionMap;
}
};
function markWrapping(tr, pos, oldNode, newNode, user, username, date1) {
const markWrapping = (tr, pos, oldNode, newNode, user, username, date1) => {
let track = oldNode.attrs.track.slice(),
blockTrack = track.find(track => track.type === "block_change");
......@@ -180,9 +189,9 @@ function markWrapping(tr, pos, oldNode, newNode, user, username, date1) {
track.push(blockTrack);
}
tr.setNodeMarkup(pos, null, Object.assign({}, newNode.attrs, { track }));
}
};
export function amendTransaction(tr, state, editor) {
const trackedTransaction = (tr, state, editor) => {
if (
!tr.steps.length ||
(tr.meta &&
......@@ -193,11 +202,13 @@ export function amendTransaction(tr, state, editor) {
// don't replace history TRs
["historyUndo", "historyRedo"].includes(tr.getMeta("inputType"))
) {
// None of the transactions change the doc, or all are remote, come from footnotes, are footnote creations, history or fixing IDs. Give up.
console.log(tr);
return tr;
}
const user = "editor.user.id", // current user
const user = "editor.user.id",
approved = false,
// !editor.view.state.doc.firstChild.attrs.tracked &&
// editor.docInfo.access_rights !== "write-tracked",
newTr = state.tr,
map = new Mapping(),
exactDate = Date.now(),
......@@ -456,10 +467,10 @@ export function amendTransaction(tr, state, editor) {
}
});
// We copy the input type meta data from the original transaction.
if (tr.getMeta("inputType")) {
newTr.setMeta(tr.getMeta("inputType"));
}
if (tr.getMeta("uiEvent")) {
newTr.setMeta(tr.getMeta("uiEvent"));
}
......@@ -484,4 +495,6 @@ export function amendTransaction(tr, state, editor) {
}
return newTr;
}
};
export default trackedTransaction;
......@@ -18,14 +18,12 @@ export default options => {
const userIds = ["33"];
state.doc.descendants(node => {
if (node.attrs.track) {
console.log("11111111");
node.attrs.track.forEach(track => {
if (!userIds.includes(track.user) && track.user !== 0) {
userIds.push(track.user);
}
});
} else {
console.log(node.marks);
node.marks.forEach(mark => {
if (
["deletion", "insertion", "format_change"].includes(
......@@ -63,7 +61,6 @@ export default options => {
? Decoration.node
: Decoration.inline;
if (insertion) {
console.log("insertion");
decos = decos.add(tr.doc, [
decoType(
insertion.from,
......@@ -76,7 +73,6 @@ export default options => {
]);
}
if (deletion) {
console.log("deletion");
decos = decos.add(tr.doc, [
decoType(
deletion.from,
......@@ -89,13 +85,12 @@ export default options => {
]);
}
if (formatChange) {
console.log("change format");
decos = decos.add(tr.doc, [
decoType(
formatChange.from,
formatChange.to,
{
class: "selected-format_change"
class: "selected-format-change"
},
selectedChangeFormatSpec
)
......@@ -116,7 +111,7 @@ export default options => {
},
handleDOMEvents: {
focus: (view, _event) => {
// view.dispatch(deactivateAllSelectedChanges(view.state.tr));
view.dispatch(deactivateAllSelectedChanges(view.state.tr));
}
}
}
......
......@@ -182,35 +182,11 @@ span.insertion {
.selected-insertion,
.selected-deletion,
.selected-format_change,
.selected-block_change {
.selected-format-change,
.selected-block-change {
background-color: #fffacf;
}
.tag.selected-insertion,
.contributor.selected-insertion,
.tag.selected-deletion,
.contributor.selected-deletion {
background-color: #fffacf;
color: #000;
}
.margin-box.track > div {
padding: 10px;
}
.margin-box .track-title {
font-weight: 700;
}
.margin-box .format-change-info {
margin-bottom: 9px;
}
.margin-box .format-change-info b {
font-weight: 700;
}
[data-track] {
position: relative;
}
......
Markdown is supported
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