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

lists

parent 9eafcc4e
No related branches found
No related tags found
No related merge requests found
...@@ -35,7 +35,7 @@ import { ...@@ -35,7 +35,7 @@ import {
import { DefaultSchema } from 'wax-prosemirror-utilities'; import { DefaultSchema } from 'wax-prosemirror-utilities';
import invisibles, { hardBreak } from '@guardian/prosemirror-invisibles'; import invisibles, { hardBreak } from '@guardian/prosemirror-invisibles';
const getContent = source => { const getContentOnEnter = source => {
console.log('editor content', source); console.log('editor content', source);
}; };
...@@ -68,7 +68,7 @@ export default { ...@@ -68,7 +68,7 @@ export default {
}, },
], ],
// ChatService: { getContent }, ChatService: { getContentOnEnter },
SchemaService: DefaultSchema, SchemaService: DefaultSchema,
RulesService: [emDash, ellipsis], RulesService: [emDash, ellipsis],
......
...@@ -33,26 +33,38 @@ export default props => { ...@@ -33,26 +33,38 @@ export default props => {
}, },
props: { props: {
handleKeyDown(view, event) { handleKeyDown(view, event) {
let isList = false;
if (event.key === 'Enter' && !event.shiftKey) { if (event.key === 'Enter' && !event.shiftKey) {
if (view.state.doc.content.size <= 2) { if (view.state.doc.content.size <= 2) {
return true; return true;
} }
const WaxOptions = { const {
doc: {}, selection: { from, to },
schema: view.props.options.schema, } = view.state;
plugins: view.props.options.plugins,
}; view.state.doc.nodesBetween(from, to, node => {
const parse = parser(view.props.options.schema); if (node.type.name === 'list_item') isList = true;
WaxOptions.doc = parse(''); });
const serialize = serializer(view.props.options.schema); if (!isList) {
props.getContent(serialize(view.state.doc.content)); const serialize = serializer(view.props.options.schema);
props.getContentOnEnter(serialize(view.state.doc.content));
view.updateState(EditorState.create(WaxOptions));
if (view.dispatch) { const WaxOptions = {
view.state.tr.setMeta('addToHistory', false); doc: {},
schema: view.props.options.schema,
plugins: view.props.options.plugins,
};
const parse = parser(view.props.options.schema);
WaxOptions.doc = parse('');
view.updateState(EditorState.create(WaxOptions));
if (view.dispatch) {
view.state.tr.setMeta('addToHistory', false);
}
return true;
} }
return true;
} }
return false; return false;
}, },
......
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