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
Merge requests
!289
Pm node views portals
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Pm node views portals
pm-node-views-portals
into
master
Overview
0
Commits
55
Pipelines
0
Changes
78
Merged
Christos
requested to merge
pm-node-views-portals
into
master
3 years ago
Overview
0
Commits
55
Pipelines
0
Changes
3
Expand
0
0
Merge request reports
Viewing commit
0372c1db
Prev
Next
Show latest version
3 files
+
25
−
6
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
3
Search (e.g. *.vue) (Ctrl+P)
0372c1db
add keyboard shortcuts
· 0372c1db
chris
authored
3 years ago
editors/demo/src/HHMI/MultipleChoiceQuestionService/components/
T
estComponent.js
→
editors/demo/src/HHMI/MultipleChoiceQuestionService/components/
Qu
est
ion
Component.js
+
21
−
3
Options
/* eslint-disable react-hooks/exhaustive-deps */
import
React
,
{
useContext
,
useRef
,
useState
,
useEffect
}
from
'
react
'
;
import
styled
from
'
styled-components
'
;
import
{
EditorView
}
from
'
prosemirror-view
'
;
import
{
EditorState
,
TextSelection
}
from
'
prosemirror-state
'
;
import
{
EditorState
}
from
'
prosemirror-state
'
;
import
{
StepMap
}
from
'
prosemirror-transform
'
;
import
{
keymap
}
from
'
prosemirror-keymap
'
;
import
{
baseKeymap
}
from
'
prosemirror-commands
'
;
import
{
undo
,
redo
}
from
'
prosemirror-history
'
;
import
{
WaxContext
}
from
'
wax-prosemirror-core
'
;
import
styled
from
'
styled-components
'
;
const
QuestionWrapper
=
styled
.
div
`
border: 1px solid black;
display: flex;
@@ -46,6 +48,7 @@ export default ({ node, view, getPos }) => {
{
state
:
EditorState
.
create
({
doc
:
node
,
plugins
:
[
keymap
(
createKeyBindings
()),
...
context
.
app
.
getPlugins
()],
}),
// This is the magic part
dispatchTransaction
,
@@ -100,6 +103,21 @@ export default ({ node, view, getPos }) => {
// view.dispatch(view.state.tr);
};
const
createKeyBindings
=
()
=>
{
const
keys
=
getKeys
();
Object
.
keys
(
baseKeymap
).
forEach
(
key
=>
{
keys
[
key
]
=
baseKeymap
[
key
];
});
return
keys
;
};
const
getKeys
=
()
=>
{
return
{
'
Mod-z
'
:
()
=>
undo
(
view
.
state
,
view
.
dispatch
),
'
Mod-y
'
:
()
=>
redo
(
view
.
state
,
view
.
dispatch
),
};
};
return
(
<
QuestionWrapper
>
<
Question
>