From bfde29ff6ae3af0c187a74ee6f3a207af7006519 Mon Sep 17 00:00:00 2001
From: chris <kokosias@yahoo.gr>
Date: Thu, 22 Aug 2019 01:17:00 +0300
Subject: [PATCH] pass user to props

---
 editors/editoria/src/Editoria.js               | 6 ++++++
 wax-prosemirror-core/src/Wax.js                | 4 +++-
 wax-prosemirror-core/src/trackedTransaction.js | 4 ++--
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/editors/editoria/src/Editoria.js b/editors/editoria/src/Editoria.js
index e0cf49070..0c93c27ee 100644
--- a/editors/editoria/src/Editoria.js
+++ b/editors/editoria/src/Editoria.js
@@ -94,6 +94,11 @@ const renderImage = file => {
   });
 };
 
+const user = {
+  userId: "1234",
+  username: "demo"
+};
+
 const text = `<ul><li>sl jlkf jlfkjdf</li><li>sl jlkf jlfkjdf</li></ul><h1>this is a title</h1><p class="paragraph" data-track="[{&quot;type&quot;:&quot;block_change&quot;,&quot;user&quot;:&quot;editor.user.id&quot;,&quot;username&quot;:&quot;editor.user.username&quot;,&quot;date&quot;:26069447,&quot;before&quot;:{&quot;type&quot;:&quot;author&quot;,&quot;attrs&quot;:{&quot;class&quot;:&quot;author&quot;}}}]">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p><p class="author">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>`;
 
 class Editoria extends Component {
@@ -111,6 +116,7 @@ class Editoria extends Component {
           debug
           TrackChange
           value={text}
+          user={user}
         >
           {({ editor, view, ...props }) => (
             <React.Fragment>
diff --git a/wax-prosemirror-core/src/Wax.js b/wax-prosemirror-core/src/Wax.js
index 2e11b0fce..c9846ead4 100644
--- a/wax-prosemirror-core/src/Wax.js
+++ b/wax-prosemirror-core/src/Wax.js
@@ -83,7 +83,8 @@ class Wax extends Component {
       layout,
       theme,
       debug,
-      TrackChange
+      TrackChange,
+      user
     } = this.props;
 
     const defaultRender = ({ editor, state, dispatch, fileUpload }) => (
@@ -107,6 +108,7 @@ class Wax extends Component {
           onChange={this.onChange || (value => true)}
           debug={debug}
           TrackChange={TrackChange}
+          user={user}
         >
           {WaxRender}
         </WaxView>
diff --git a/wax-prosemirror-core/src/trackedTransaction.js b/wax-prosemirror-core/src/trackedTransaction.js
index deb19eac8..81e7876d8 100644
--- a/wax-prosemirror-core/src/trackedTransaction.js
+++ b/wax-prosemirror-core/src/trackedTransaction.js
@@ -205,7 +205,7 @@ const trackedTransaction = (tr, state, editor) => {
   ) {
     return tr;
   }
-  const user = "editor.user.id",
+  const user = editor.props.user.userId,
     approved = false,
     // !editor.view.state.doc.firstChild.attrs.tracked &&
     // editor.docInfo.access_rights !== "write-tracked",
@@ -214,7 +214,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.user.username",
+    username = editor.props.user.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 =
-- 
GitLab