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 { minBy, maxBy } from 'lodash';
import { keymap } from 'prosemirror-keymap';
import { undo, redo } from 'prosemirror-history';
......@@ -10,6 +11,7 @@ import {
} from 'prosemirror-schema-list';
import {
toggleMark,
baseKeymap,
chainCommands,
exitCode,
......@@ -19,6 +21,8 @@ import {
deleteSelection,
} from 'prosemirror-commands';
import { Commands, DocumentHelpers } from 'wax-prosemirror-utilities';
const backSpace = chainCommands(
deleteSelection,
joinBackward,
......@@ -42,6 +46,7 @@ const redoShortCut = (state, dispatch, view) =>
class ShortCuts {
constructor(plugins, schema) {
this.insertBreak = this.insertBreak.bind(this);
this.pressEnter = this.pressEnter.bind(this);
this.insertRule = this.insertRule.bind(this);
this.PmPlugins = plugins;
this.schema = schema;
......@@ -54,6 +59,25 @@ class ShortCuts {
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) {
const hr = this.schema.nodes.horizontal_rule.create();
dispatch(state.tr.replaceSelectionWith(hr).scrollIntoView());
......@@ -94,7 +118,7 @@ class ShortCuts {
'Mod-_': this.insertRule,
'Mod-[': liftListItem(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-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