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

pass user to track-changes

parent 333a49c6
No related branches found
No related tags found
1 merge request!52Develop
......@@ -48,6 +48,7 @@ const Editoria = () => (
autoFocus
placeholder="Type Something..."
fileUpload={file => renderImage(file)}
TrackChange
value={
'<p class="paragraph">this is some text <a href="www.sss.ff" >some</a> more</p>'
}
......
......@@ -15,7 +15,7 @@ import trackedTransaction from "./track-changes/trackedTransaction";
import { WaxContext } from "./ioc-react";
export default props => {
const { readonly, onBlur, options, debug, autoFocus } = props;
const { readonly, onBlur, options, debug, autoFocus, user } = props;
const editorRef = useRef();
const context = useContext(WaxContext);
......@@ -29,7 +29,7 @@ export default props => {
dispatchTransaction: transaction => {
const { TrackChange } = props;
const tr = TrackChange
? trackedTransaction(transaction, view.state, this)
? trackedTransaction(transaction, view.state, user)
: transaction;
const state = view.state.apply(tr);
......
......@@ -13,7 +13,7 @@ import markDeletion from "./markDeletion";
import markInsertion from "./markInsertion";
import markWrapping from "./markWrapping";
const trackedTransaction = (tr, state, editor) => {
const trackedTransaction = (tr, state, currentUser) => {
if (
!tr.steps.length ||
(tr.meta &&
......@@ -25,7 +25,7 @@ const trackedTransaction = (tr, state, editor) => {
) {
return tr;
}
const user = editor.props.user.userId,
const user = currentUser.userId,
approved = false,
// !editor.view.state.doc.firstChild.attrs.tracked &&
// editor.docInfo.access_rights !== "write-tracked",
......@@ -34,7 +34,7 @@ const trackedTransaction = (tr, state, editor) => {
exactDate = Date.now(),
date10 = Math.floor(exactDate / 600000) * 10, // 10 minute interval
date1 = Math.floor(exactDate / 60000), // 1 minute interval
username = editor.props.user.username,
username = currentUser.username,
// We only insert content if this is not directly a tr for cell deletion. This is because tables delete rows by deleting the
// contents of each cell and replacing it with an empty paragraph.
cellDeleteTr =
......@@ -48,6 +48,7 @@ const trackedTransaction = (tr, state, editor) => {
if (!step) {
return;
}
if (step instanceof ReplaceStep) {
const newStep = approved
? step
......@@ -66,6 +67,7 @@ const trackedTransaction = (tr, state, editor) => {
if (trTemp.maybeStep(newStep).failed) {
return;
}
const mappedNewStepTo = newStep.getMap().map(newStep.to);
markInsertion(
trTemp,
......
import { toggleMark } from "prosemirror-commands";
import { markActive, promptForURL } from "../lib/Utils";
import { markActive } from "../lib/Utils";
import Tools from "../lib/Tools";
import { injectable } from "inversify";
import { icons } from "wax-prosemirror-components";
......
import React, { useState } from "react";
import { injectable } from "inversify";
import { isFunction } from "lodash";
@injectable()
export default class ToolGroup {
_config = {};
......
......@@ -53,16 +53,6 @@ const getMarkPosition = ($start, mark) => {
return { from: startPos, to: endPos };
};
const promptForURL = () => {
let url = window && window.prompt("Enter the URL", "https://");
if (url && !/^https?:\/\//i.test(url)) {
url = "http://" + url;
}
return url;
};
const createTable = (state, dispatch) => {
let rowCount = window && window.prompt("How many rows?", 2);
let colCount = window && window.prompt("How many columns?", 2);
......@@ -81,11 +71,4 @@ const createTable = (state, dispatch) => {
dispatch(state.tr.replaceSelectionWith(table));
};
export {
markActive,
blockActive,
canInsert,
promptForURL,
createTable,
getMarkPosition
};
export { markActive, blockActive, canInsert, createTable, getMarkPosition };
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