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
4c4a9ce2
Commit
4c4a9ce2
authored
4 years ago
by
chris
Browse files
Options
Downloads
Patches
Plain Diff
create comment on footnote
parent
f19b8e24
No related branches found
No related tags found
1 merge request
!181
Fix comment on notes
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
wax-prosemirror-components/src/components/comments/ConnectedComment.js
+0
-1
0 additions, 1 deletion
...or-components/src/components/comments/ConnectedComment.js
wax-prosemirror-utilities/src/commands/Commands.js
+45
-24
45 additions, 24 deletions
wax-prosemirror-utilities/src/commands/Commands.js
with
45 additions
and
25 deletions
wax-prosemirror-components/src/components/comments/ConnectedComment.js
+
0
−
1
View file @
4c4a9ce2
...
...
@@ -112,7 +112,6 @@ export default ({ comment, top, commentId, recalculateTops }) => {
let
minPos
=
comment
.
pos
;
allCommentsWithSameId
.
forEach
(
singleComment
=>
{
console
.
log
(
singleComment
.
pos
);
const
markPosition
=
DocumentHelpers
.
findMarkPosition
(
state
,
singleComment
.
pos
,
...
...
This diff is collapsed.
Click to expand it.
wax-prosemirror-utilities/src/commands/Commands.js
+
45
−
24
View file @
4c4a9ce2
import
{
v4
as
uuidv4
}
from
'
uuid
'
;
import
{
toggleMark
}
from
'
prosemirror-commands
'
;
import
{
AddMarkStep
}
from
'
prosemirror-transform
'
;
const
setBlockType
=
(
nodeType
,
attrs
=
{})
=>
{
return
(
state
,
dispatch
)
=>
{
...
...
@@ -127,10 +128,10 @@ const createComment = (state, dispatch, group, viewid) => {
state
.
doc
.
nodesBetween
(
$from
.
pos
,
$to
.
pos
,
(
node
,
from
)
=>
{
if
(
node
.
type
.
name
===
'
footnote
'
)
{
footnote
=
true
;
createCommentOnFootnote
(
state
,
dispatch
,
group
,
viewid
);
}
});
createCommentOnFootnote
(
state
,
dispatch
,
group
,
viewid
);
if
(
footnote
)
return
;
toggleMark
(
state
.
config
.
schema
.
marks
.
comment
,
{
...
...
@@ -144,47 +145,67 @@ const createComment = (state, dispatch, group, viewid) => {
const
createCommentOnFootnote
=
(
state
,
dispatch
,
group
,
viewid
)
=>
{
const
{
selection
:
{
$from
},
selection
,
tr
,
}
=
state
;
const
{
content
}
=
$from
.
parent
;
// const $pos = state.doc.resolve($from.pos);
// const commentStart = $from.pos - $pos.textOffset;
// const commentEnd = commentStart + $pos.parent.child($pos.index()).nodeSize;
const
$pos
=
state
.
doc
.
resolve
(
$from
.
pos
);
const
commentStart
=
$from
.
pos
-
$pos
.
textOffset
;
const
commentEnd
=
commentStart
+
$pos
.
parent
.
child
(
$pos
.
index
()).
nodeSize
;
let
start
=
$from
.
pos
;
let
end
=
1
;
let
end
=
commentEnd
;
const
ranges
=
[];
content
.
content
.
forEach
((
contentNode
,
index
)
=>
{
start
=
end
;
end
+=
contentNode
.
nodeSize
;
ranges
.
push
({
start
,
end
,
footnote
:
contentNode
.
type
.
name
===
'
footnote
'
});
const
allFragments
=
[];
selection
.
content
().
content
.
content
.
forEach
(
node
=>
{
node
.
content
.
content
.
forEach
(
fragment
=>
{
allFragments
.
push
(
fragment
);
});
});
allFragments
.
forEach
((
contentNode
,
index
)
=>
{
start
=
index
===
0
?
start
:
end
;
end
=
index
===
0
?
end
:
end
+
contentNode
.
nodeSize
;
ranges
.
push
({
start
,
end
,
footnote
:
contentNode
.
type
.
name
===
'
footnote
'
,
});
});
const
mergedRanges
=
[];
ranges
.
forEach
((
item
,
i
)
=>
{
if
(
item
.
footnote
)
{
mergedRanges
[
mergedRanges
.
length
-
1
].
end
=
mergedRanges
[
mergedRanges
.
length
-
1
].
end
+
2
;
mergedRanges
[
mergedRanges
.
length
-
1
].
end
+
1
;
}
else
{
mergedRanges
.
push
(
item
);
}
});
console
.
log
(
mergedRanges
);
// dispatch(
// state.tr.addMark(
// $from.pos,
// $to.pos,
// state.config.schema.marks.comment.create({
// id: uuidv4(),
// group,
// conversation: [],
// viewid,
// }),
// ),
// );
const
id
=
uuidv4
();
mergedRanges
.
forEach
(
range
=>
{
tr
.
step
(
new
AddMarkStep
(
range
.
start
,
range
.
end
,
state
.
config
.
schema
.
marks
.
comment
.
create
({
id
,
group
,
conversation
:
[],
viewid
,
}),
),
);
});
dispatch
(
tr
);
};
export
default
{
setBlockType
,
blockActive
,
...
...
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