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
4b958fcb
Commit
4b958fcb
authored
4 years ago
by
chris
Browse files
Options
Downloads
Patches
Plain Diff
mark position
parent
799e5984
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!127
Remove if empty comment
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
wax-prosemirror-components/src/components/comments/Comment.js
+7
-5
7 additions, 5 deletions
...prosemirror-components/src/components/comments/Comment.js
wax-prosemirror-utilities/src/document/DocumentHelpers.js
+19
-4
19 additions, 4 deletions
wax-prosemirror-utilities/src/document/DocumentHelpers.js
with
26 additions
and
9 deletions
wax-prosemirror-components/src/components/comments/Comment.js
+
7
−
5
View file @
4b958fcb
...
@@ -64,18 +64,20 @@ export default ({ comment, activeView, user }) => {
...
@@ -64,18 +64,20 @@ export default ({ comment, activeView, user }) => {
current
:
{
value
},
current
:
{
value
},
}
=
commentInput
;
}
=
commentInput
;
if
(
value
!==
''
)
{
if
(
value
!==
''
)
{
saveComment
();
//
saveComment();
}
}
// TODO
Find actual from to of comment
// TODO
Also find fragmented marks
if
(
conversation
.
length
===
0
&&
value
===
''
)
{
if
(
conversation
.
length
===
0
&&
value
===
''
)
{
dispatch
(
state
.
tr
.
removeMark
(
1
,
5
,
commentMark
));
const
commentPosition
=
DocumentHelpers
.
findMarkPosition
(
activeView
,
comment
.
pos
,
'
comment
'
);
dispatch
(
state
.
tr
.
removeMark
(
commentPosition
.
from
,
commentPosition
.
to
,
commentMark
));
}
}
};
};
const
resolveComment
=
()
=>
{
const
resolveComment
=
()
=>
{
// TODO Find actual from to of comment
// TODO Also find fragmented marks
dispatch
(
state
.
tr
.
removeMark
(
1
,
5
,
commentMark
));
const
commentPosition
=
DocumentHelpers
.
findMarkPoistion
(
activeView
,
comment
.
pos
,
'
comment
'
);
dispatch
(
state
.
tr
.
removeMark
(
commentPosition
.
from
,
commentPosition
.
to
,
commentMark
));
};
};
const
commentInputReply
=
()
=>
{
const
commentInputReply
=
()
=>
{
...
...
This diff is collapsed.
Click to expand it.
wax-prosemirror-utilities/src/document/DocumentHelpers.js
+
19
−
4
View file @
4b958fcb
...
@@ -88,10 +88,7 @@ const findAllCommentsWithSameId = state => {
...
@@ -88,10 +88,7 @@ const findAllCommentsWithSameId = state => {
const
allCommentsWithSameId
=
[];
const
allCommentsWithSameId
=
[];
commentNodes
.
map
(
node
=>
{
commentNodes
.
map
(
node
=>
{
node
.
node
.
marks
.
filter
(
mark
=>
{
node
.
node
.
marks
.
filter
(
mark
=>
{
if
(
if
(
mark
.
type
.
name
===
'
comment
'
&&
commentOnSelection
.
attrs
.
id
===
mark
.
attrs
.
id
)
{
mark
.
type
.
name
===
'
comment
'
&&
commentOnSelection
.
attrs
.
id
===
mark
.
attrs
.
id
)
{
allCommentsWithSameId
.
push
(
node
);
allCommentsWithSameId
.
push
(
node
);
}
}
});
});
...
@@ -99,6 +96,23 @@ const findAllCommentsWithSameId = state => {
...
@@ -99,6 +96,23 @@ const findAllCommentsWithSameId = state => {
return
allCommentsWithSameId
;
return
allCommentsWithSameId
;
};
};
const
findMarkPosition
=
(
activeView
,
initialPos
,
markType
)
=>
{
let
$pos
=
activeView
.
state
.
tr
.
doc
.
resolve
(
initialPos
);
let
parent
=
$pos
.
parent
;
let
start
=
parent
.
childAfter
(
$pos
.
parentOffset
);
if
(
!
start
.
node
)
return
null
;
const
actualMark
=
start
.
node
.
marks
.
find
(
mark
=>
mark
.
type
.
name
===
markType
);
let
startIndex
=
$pos
.
index
();
let
startPos
=
$pos
.
start
()
+
start
.
offset
;
while
(
startIndex
>
0
&&
actualMark
.
isInSet
(
parent
.
child
(
startIndex
-
1
).
marks
))
startPos
-=
parent
.
child
(
--
startIndex
).
nodeSize
;
let
endIndex
=
$pos
.
indexAfter
();
let
endPos
=
startPos
+
start
.
node
.
nodeSize
;
while
(
endPos
<
parent
.
childCount
&&
actualMark
.
isInSet
(
parent
.
child
(
endIndex
).
marks
))
endPos
+=
parent
.
child
(
endIndex
++
).
nodeSize
;
return
{
from
:
startPos
,
to
:
endPos
};
};
export
const
flatten
=
(
node
,
descend
=
true
)
=>
{
export
const
flatten
=
(
node
,
descend
=
true
)
=>
{
if
(
!
node
)
{
if
(
!
node
)
{
throw
new
Error
(
'
Invalid "node" parameter
'
);
throw
new
Error
(
'
Invalid "node" parameter
'
);
...
@@ -152,4 +166,5 @@ export default {
...
@@ -152,4 +166,5 @@ export default {
getSelectionMark
,
getSelectionMark
,
findFragmentedMark
,
findFragmentedMark
,
findAllCommentsWithSameId
,
findAllCommentsWithSameId
,
findMarkPosition
,
};
};
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