Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
wax-prosemirror
Manage
Activity
Members
Labels
Plan
Issues
34
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
2
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
wax
wax-prosemirror
Commits
115890ff
Commit
115890ff
authored
4 years ago
by
chris
Browse files
Options
Downloads
Patches
Plain Diff
plugin state
parent
3b57a9aa
No related branches found
No related tags found
1 merge request
!231
Connect funcionality
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
editors/editoria/src/layout/EditorElements.js
+8
-0
8 additions, 0 deletions
editors/editoria/src/layout/EditorElements.js
wax-prosemirror-plugins/src/trackChanges/HideShowPlugin.js
+62
-3
62 additions, 3 deletions
wax-prosemirror-plugins/src/trackChanges/HideShowPlugin.js
with
70 additions
and
3 deletions
editors/editoria/src/layout/EditorElements.js
+
8
−
0
View file @
115890ff
...
...
@@ -248,6 +248,14 @@ export default css`
height: 100%;
}
.insertion .show-insertion {
color: black;
}
.deletion .hide-deletion {
display: none;
}
li[data-track]::before,
li [data-track]::before {
left: -5px;
...
...
This diff is collapsed.
Click to expand it.
wax-prosemirror-plugins/src/trackChanges/HideShowPlugin.js
+
62
−
3
View file @
115890ff
...
...
@@ -6,19 +6,78 @@ import { DocumentHelpers } from 'wax-prosemirror-utilities';
const
hideShowPlugin
=
new
PluginKey
(
'
hideShowPlugin
'
);
const
getTrackChanges
=
state
=>
{
const
finalTracks
=
[];
const
allInlineNodes
=
DocumentHelpers
.
findInlineNodes
(
state
.
doc
);
allInlineNodes
.
map
(
node
=>
{
if
(
node
.
node
.
marks
.
length
>
0
)
{
node
.
node
.
marks
.
filter
(
mark
=>
{
if
(
mark
.
type
.
name
===
'
insertion
'
||
mark
.
type
.
name
===
'
deletion
'
||
mark
.
type
.
name
===
'
format_change
'
)
{
mark
.
pos
=
node
.
pos
;
finalTracks
.
push
(
mark
);
}
});
}
});
return
finalTracks
;
};
export
default
props
=>
{
return
new
Plugin
({
key
:
hideShowPlugin
,
state
:
{
init
:
(
_
,
state
)
=>
{},
init
:
(
_
,
state
)
=>
{
return
DecorationSet
.
empty
;
},
apply
(
tr
,
prev
,
_
,
newState
)
{
console
.
log
(
'
in apply
'
);
let
decorations
;
let
createdDecorations
=
DecorationSet
.
empty
;
const
allMatches
=
getTrackChanges
(
newState
);
console
.
log
(
'
in apply
'
,
allMatches
);
if
(
allMatches
.
length
>
0
)
{
decorations
=
allMatches
.
map
((
result
,
index
)
=>
{
if
(
result
.
type
.
name
===
'
insertion
'
)
{
const
position
=
DocumentHelpers
.
findMarkPosition
(
newState
,
result
.
pos
,
'
insertion
'
,
);
return
Decoration
.
inline
(
position
.
from
,
position
.
to
,
{
class
:
'
show-insertion
'
,
});
}
if
(
result
.
type
.
name
===
'
deletion
'
)
{
const
position
=
DocumentHelpers
.
findMarkPosition
(
newState
,
result
.
pos
,
'
deletion
'
,
);
return
Decoration
.
inline
(
position
.
from
,
position
.
to
,
{
class
:
'
hide-deletion
'
,
});
}
});
createdDecorations
=
DecorationSet
.
create
(
newState
.
doc
,
decorations
);
}
return
{
createdDecorations
,
allMatches
,
};
},
},
props
:
{
decorations
:
state
=>
{
const
hideShowPluginState
=
state
&&
hideShowPlugin
.
getState
(
state
);
// return hideShowPluginState.createDecoration;
return
hideShowPluginState
.
createdDecorations
;
},
hideShow
:
show
=>
{
console
.
log
(
show
);
},
},
});
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment