Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wax-prosemirror
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wax
wax-prosemirror
Commits
3d4906f5
Commit
3d4906f5
authored
May 13, 2019
by
chris
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixes
parent
d4865270
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
30 additions
and
47 deletions
+30
-47
wax-prosemirror-core/index.js
wax-prosemirror-core/index.js
+0
-1
wax-prosemirror-core/src/WaxView.js
wax-prosemirror-core/src/WaxView.js
+2
-2
wax-prosemirror-core/src/trackedTransaction.js
wax-prosemirror-core/src/trackedTransaction.js
+24
-11
wax-prosemirror-plugins/src/trackChanges/TrackChangePlugin.js
...prosemirror-plugins/src/trackChanges/TrackChangePlugin.js
+2
-7
wax-prosemirror-themes/themes/editoria-theme.css
wax-prosemirror-themes/themes/editoria-theme.css
+2
-26
No files found.
wax-prosemirror-core/index.js
View file @
3d4906f5
...
...
@@ -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
"
;
wax-prosemirror-core/src/WaxView.js
View file @
3d4906f5
...
...
@@ -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
);
...
...
wax-prosemirror-core/src/
amend_t
ransaction.js
→
wax-prosemirror-core/src/
trackedT
ransaction.js
View file @
3d4906f5
...
...
@@ -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
;
wax-prosemirror-plugins/src/trackChanges/TrackChangePlugin.js
View file @
3d4906f5
...
...
@@ -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
));
}
}
}
...
...
wax-prosemirror-themes/themes/editoria-theme.css
View file @
3d4906f5
...
...
@@ -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
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment