aboutsummaryrefslogtreecommitdiff
path: root/src/client/util/ProsemirrorExampleTransfer.ts
diff options
context:
space:
mode:
authorbob <bcz@cs.brown.edu>2019-09-03 16:19:20 -0400
committerbob <bcz@cs.brown.edu>2019-09-03 16:19:20 -0400
commita4d36f835b5c43351d1761034b61513b000445ba (patch)
treef58c29b3289b36e09f90ecbcda9934002785cc0f /src/client/util/ProsemirrorExampleTransfer.ts
parent4a1d94325d5d1b5641cd280e89c442c114074e8d (diff)
added inline footnote.
Diffstat (limited to 'src/client/util/ProsemirrorExampleTransfer.ts')
-rw-r--r--src/client/util/ProsemirrorExampleTransfer.ts13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/client/util/ProsemirrorExampleTransfer.ts b/src/client/util/ProsemirrorExampleTransfer.ts
index bcb8b404b..419311df8 100644
--- a/src/client/util/ProsemirrorExampleTransfer.ts
+++ b/src/client/util/ProsemirrorExampleTransfer.ts
@@ -51,6 +51,19 @@ export default function buildKeymap<S extends Schema<any>>(schema: S, mapKeys?:
bind("Ctrl->", wrapIn(schema.nodes.blockquote));
+ bind("^", (state: EditorState<S>, dispatch: (tx: Transaction<S>) => void) => {
+ let newNode = schema.nodes.footnote.create({});
+ if (dispatch && state.selection.from === state.selection.to) {
+ let tr = state.tr;
+ tr.replaceSelectionWith(newNode); // replace insertion with a footnote.
+ dispatch(tr.setSelection(new NodeSelection( // select the footnote node to open its display
+ tr.doc.resolve( // get the location of the footnote node by subtracting the nodesize of the footnote from the current insertion point anchor (which will be immediately after the footnote node)
+ tr.selection.anchor - tr.selection.$anchor.nodeBefore!.nodeSize))));
+ return true;
+ }
+ return false;
+ })
+
let cmd = chainCommands(exitCode, (state, dispatch) => {
if (dispatch) {