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
4de1519f
Commit
4de1519f
authored
1 year ago
by
chris
Browse files
Options
Downloads
Patches
Plain Diff
fix feedback rerender
parent
95b1a5ca
No related branches found
No related tags found
1 merge request
!519
Move tool groups
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
wax-questions-service/src/MultipleChoiceQuestionService/components/FeedbackComponent.js
+34
-23
34 additions, 23 deletions
...ipleChoiceQuestionService/components/FeedbackComponent.js
with
34 additions
and
23 deletions
wax-questions-service/src/MultipleChoiceQuestionService/components/FeedbackComponent.js
+
34
−
23
View file @
4de1519f
import
React
,
{
useContext
,
useRef
,
useState
}
from
'
react
'
;
import
React
,
{
useContext
,
useRef
,
useState
,
useMemo
,
useEffect
}
from
'
react
'
;
import
styled
from
'
styled-components
'
;
import
styled
from
'
styled-components
'
;
import
{
TextSelection
}
from
'
prosemirror-state
'
;
import
{
TextSelection
}
from
'
prosemirror-state
'
;
import
{
WaxContext
,
DocumentHelpers
}
from
'
wax-prosemirror-core
'
;
import
{
WaxContext
,
DocumentHelpers
}
from
'
wax-prosemirror-core
'
;
...
@@ -50,17 +50,10 @@ export default ({ node, getPos, readOnly }) => {
...
@@ -50,17 +50,10 @@ export default ({ node, getPos, readOnly }) => {
pmViews
:
{
main
},
pmViews
:
{
main
},
}
=
context
;
}
=
context
;
const
[
isFirstRun
,
setFirstRun
]
=
useState
(
true
);
const
[
feedBack
,
setFeedBack
]
=
useState
(
node
.
attrs
.
feedback
);
const
[
feedBack
,
setFeedBack
]
=
useState
(
node
.
attrs
.
feedback
);
const
feedBackRef
=
useRef
(
null
);
const
feedBackRef
=
useRef
(
null
);
const
setHeight
=
()
=>
{
const
textarea
=
feedBackRef
.
current
;
if
(
!
textarea
)
return
;
const
heightLimit
=
200
;
textarea
.
style
.
height
=
''
;
textarea
.
style
.
height
=
`
${
Math
.
min
(
textarea
.
scrollHeight
,
heightLimit
)}
px`
;
};
const
feedBackInput
=
()
=>
{
const
feedBackInput
=
()
=>
{
setFeedBack
(
feedBackRef
.
current
.
value
);
setFeedBack
(
feedBackRef
.
current
.
value
);
const
allNodes
=
getNodes
(
main
);
const
allNodes
=
getNodes
(
main
);
...
@@ -79,6 +72,14 @@ export default ({ node, getPos, readOnly }) => {
...
@@ -79,6 +72,14 @@ export default ({ node, getPos, readOnly }) => {
return
false
;
return
false
;
};
};
const
setHeight
=
()
=>
{
const
textarea
=
feedBackRef
.
current
;
if
(
!
textarea
)
return
;
const
heightLimit
=
200
;
textarea
.
style
.
height
=
''
;
textarea
.
style
.
height
=
`
${
Math
.
min
(
textarea
.
scrollHeight
,
heightLimit
)}
px`
;
};
const
setNullSelection
=
()
=>
{
const
setNullSelection
=
()
=>
{
main
.
dispatch
(
main
.
dispatch
(
main
.
state
.
tr
.
setSelection
(
TextSelection
.
create
(
main
.
state
.
tr
.
doc
,
null
)),
main
.
state
.
tr
.
setSelection
(
TextSelection
.
create
(
main
.
state
.
tr
.
doc
,
null
)),
...
@@ -91,20 +92,30 @@ export default ({ node, getPos, readOnly }) => {
...
@@ -91,20 +92,30 @@ export default ({ node, getPos, readOnly }) => {
},
50
);
},
50
);
};
};
return
(
useEffect
(()
=>
{
<
FeedBack
>
setTimeout
(()
=>
{
<
FeedBackLabel
>
Feedback
<
/FeedBackLabel
>
setFirstRun
(
false
);
<
FeedBackInput
});
onChange
=
{
feedBackInput
}
},
[]);
onFocus
=
{
onFocus
}
placeholder
=
"
Insert feedback
"
return
useMemo
(
readOnly
=
{
readOnly
}
()
=>
(
ref
=
{
feedBackRef
}
<
FeedBack
>
rows
=
"
1
"
<
FeedBackLabel
>
Feedback
<
/FeedBackLabel
>
type
=
"
text
"
<
FeedBackInput
value
=
{
feedBack
}
onChange
=
{
feedBackInput
}
/
>
onFocus
=
{
onFocus
}
<
/FeedBack
>
placeholder
=
"
Insert feedback
"
readOnly
=
{
readOnly
}
ref
=
{
feedBackRef
}
rows
=
"
1
"
style
=
{{
height
:
setHeight
()
}}
type
=
"
text
"
value
=
{
feedBack
}
/
>
<
/FeedBack
>
),
[
feedBack
,
isFirstRun
],
);
);
};
};
...
...
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