Skip to content
Snippets Groups Projects
Commit fdadc15b authored by chris's avatar chris
Browse files

expand comment on enter

parent 3f142f56
No related branches found
No related tags found
1 merge request!160add track change plugin through service
import { injectable } from 'inversify'; import { injectable } from 'inversify';
import { minBy, maxBy } from 'lodash';
import { keymap } from 'prosemirror-keymap'; import { keymap } from 'prosemirror-keymap';
import { undo, redo } from 'prosemirror-history'; import { undo, redo } from 'prosemirror-history';
...@@ -10,6 +11,7 @@ import { ...@@ -10,6 +11,7 @@ import {
} from 'prosemirror-schema-list'; } from 'prosemirror-schema-list';
import { import {
toggleMark,
baseKeymap, baseKeymap,
chainCommands, chainCommands,
exitCode, exitCode,
...@@ -19,6 +21,8 @@ import { ...@@ -19,6 +21,8 @@ import {
deleteSelection, deleteSelection,
} from 'prosemirror-commands'; } from 'prosemirror-commands';
import { Commands, DocumentHelpers } from 'wax-prosemirror-utilities';
const backSpace = chainCommands( const backSpace = chainCommands(
deleteSelection, deleteSelection,
joinBackward, joinBackward,
...@@ -42,6 +46,7 @@ const redoShortCut = (state, dispatch, view) => ...@@ -42,6 +46,7 @@ const redoShortCut = (state, dispatch, view) =>
class ShortCuts { class ShortCuts {
constructor(plugins, schema) { constructor(plugins, schema) {
this.insertBreak = this.insertBreak.bind(this); this.insertBreak = this.insertBreak.bind(this);
this.pressEnter = this.pressEnter.bind(this);
this.insertRule = this.insertRule.bind(this); this.insertRule = this.insertRule.bind(this);
this.PmPlugins = plugins; this.PmPlugins = plugins;
this.schema = schema; this.schema = schema;
...@@ -54,6 +59,25 @@ class ShortCuts { ...@@ -54,6 +59,25 @@ class ShortCuts {
return true; return true;
} }
pressEnter(state, dispatch) {
const commentMark = state.schema.marks.comment;
const commentOnSelection = DocumentHelpers.findFragmentedMark(
state,
commentMark,
);
if (commentOnSelection) {
state.schema.marks.comment.spec.inclusive = true;
}
// LISTS
if (splitListItem(this.schema.nodes.list_item)(state)) {
splitListItem(this.schema.nodes.list_item)(state, dispatch);
return true;
}
return false;
}
insertRule(state, dispatch) { insertRule(state, dispatch) {
const hr = this.schema.nodes.horizontal_rule.create(); const hr = this.schema.nodes.horizontal_rule.create();
dispatch(state.tr.replaceSelectionWith(hr).scrollIntoView()); dispatch(state.tr.replaceSelectionWith(hr).scrollIntoView());
...@@ -94,7 +118,7 @@ class ShortCuts { ...@@ -94,7 +118,7 @@ class ShortCuts {
'Mod-_': this.insertRule, 'Mod-_': this.insertRule,
'Mod-[': liftListItem(this.schema.nodes.list_item), 'Mod-[': liftListItem(this.schema.nodes.list_item),
'Mod-]': sinkListItem(this.schema.nodes.list_item), 'Mod-]': sinkListItem(this.schema.nodes.list_item),
Enter: splitListItem(this.schema.nodes.list_item), Enter: this.pressEnter,
'Shift-Ctrl-8': wrapInList(this.schema.nodes.bulletlist), 'Shift-Ctrl-8': wrapInList(this.schema.nodes.bulletlist),
'Shift-Ctrl-9': wrapInList(this.schema.nodes.orderedlist), 'Shift-Ctrl-9': wrapInList(this.schema.nodes.orderedlist),
}; };
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment