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
c6c97199
Commit
c6c97199
authored
4 years ago
by
chris
Browse files
Options
Downloads
Patches
Plain Diff
get data needed for comment posting
parent
32d72aab
No related branches found
No related tags found
1 merge request
!109
Track changes ids
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
wax-prosemirror-components/src/components/comments/CommentBox.js
+43
-10
43 additions, 10 deletions
...semirror-components/src/components/comments/CommentBox.js
wax-prosemirror-core/src/WaxView.js
+1
-0
1 addition, 0 deletions
wax-prosemirror-core/src/WaxView.js
with
44 additions
and
10 deletions
wax-prosemirror-components/src/components/comments/CommentBox.js
+
43
−
10
View file @
c6c97199
import
React
,
{
Fragment
,
useState
,
useEffect
,
useContext
}
from
"
react
"
;
import
React
,
{
Fragment
,
useState
,
useEffect
,
useContext
,
useRef
}
from
"
react
"
;
import
{
Transition
}
from
"
react-transition-group
"
;
import
styled
from
"
styled-components
"
;
import
{
WaxContext
}
from
"
wax-prosemirror-core
"
;
const
CommentBoxStyled
=
styled
.
div
`
height: 50px;
width: 50px;
display: flex;
flex-direction: column;
margin-top: 10px;
b
ackground:
#ffab20;
b
order: 1px solid
#ffab20;
position: absolute;
transition:
${({
state
})
=>
"
top 1s, opacity 1.5s, left 1s
"
}
;
top:
${
props
=>
(
props
.
top
?
`
${
props
.
top
}
px`
:
0
)}
;
...
...
@@ -29,18 +34,34 @@ const CommentBoxStyled = styled.div`
`
;
export
default
({
comment
,
view
,
top
,
dataBox
})
=>
{
const
[
animate
,
setAnimate
]
=
useState
(
false
);
const
{
view
:
{
main
},
app
,
activeView
}
=
useContext
(
WaxContext
);
const
{
attrs
:
{
id
}
}
=
comment
;
const
{
view
:
{
main
:
{
props
:
{
user
}
}
},
app
,
activeView
}
=
useContext
(
WaxContext
),
commentInput
=
useRef
(
null
),
[
animate
,
setAnimate
]
=
useState
(
false
),
[
commentAnnotation
,
setCommentAnnotation
]
=
useState
(
comment
),
[
currentUser
,
setCurrentuser
]
=
useState
(
user
),
{
attrs
:
{
id
}
}
=
comment
,
activeCommentPlugin
=
app
.
PmPlugins
.
get
(
"
activeComment
"
),
activeComment
=
activeCommentPlugin
.
getState
(
activeView
.
state
).
comment
;
const
activeCommentPlugin
=
app
.
PmPlugins
.
get
(
"
activeComment
"
);
const
activeComment
=
activeCommentPlugin
.
getState
(
activeView
.
state
).
comment
;
let
active
=
false
;
if
(
activeComment
&&
id
===
activeComment
.
attrs
.
id
)
active
=
true
;
useEffect
(()
=>
{
setAnimate
(
true
);
},
[]);
const
handleKeyDown
=
event
=>
{
if
(
event
.
key
===
"
Enter
"
||
event
.
which
===
13
)
{
saveComment
();
}
};
const
saveComment
=
()
=>
{
const
{
current
:
{
value
}
}
=
commentInput
;
console
.
log
(
commentAnnotation
,
currentUser
,
value
);
};
return
(
<
Fragment
>
<
Transition
in
=
{
animate
}
timeout
=
{
1000
}
>
...
...
@@ -50,7 +71,19 @@ export default ({ comment, view, top, dataBox }) => {
state
=
{
state
}
data
-
box
=
{
dataBox
}
active
=
{
active
}
/
>
>
<
div
>
<
input
type
=
"
text
"
ref
=
{
commentInput
}
placeholder
=
"
add a new comment
"
onKeyPress
=
{
handleKeyDown
}
autoFocus
/>
<
button
onClick
=
{
saveComment
}
>
Post
<
/button
>
<
button
>
Cancel
<
/button
>
<
/div
>
<
/CommentBoxStyled
>
)}
<
/Transition
>
<
/Fragment
>
...
...
This diff is collapsed.
Click to expand it.
wax-prosemirror-core/src/WaxView.js
+
1
−
0
View file @
c6c97199
...
...
@@ -32,6 +32,7 @@ export default props => {
editable
:
()
=>
!
readonly
,
state
:
EditorState
.
create
(
options
),
dispatchTransaction
,
user
,
handleDOMEvents
:
{
blur
:
onBlur
?
view
=>
{
...
...
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