From f461f2328c0922d877fa2e3170f21dce7cdf41ad Mon Sep 17 00:00:00 2001 From: chris <kokosias@yahoo.gr> Date: Sun, 25 Oct 2020 18:32:05 +0200 Subject: [PATCH] add new schema --- editors/editoria/src/config/config.js | 146 +++++++----------- editors/editoria/src/config/defaultSchema.js | 28 ++++ wax-prosemirror-core/src/Application.js | 1 - wax-prosemirror-core/src/Wax.js | 3 - .../src/SchemaService/DefaultSchema.js | 24 ++- 5 files changed, 96 insertions(+), 106 deletions(-) create mode 100644 editors/editoria/src/config/defaultSchema.js diff --git a/editors/editoria/src/config/config.js b/editors/editoria/src/config/config.js index 783887b8d..dabe19bde 100644 --- a/editors/editoria/src/config/config.js +++ b/editors/editoria/src/config/config.js @@ -39,103 +39,71 @@ import invisibles, { } from '@guardian/prosemirror-invisibles'; export default { - // MenuService: [ - // { - // templateArea: 'topBar', - // toolGroups: [ - // 'Base', - // { - // name: 'Annotations', - // more: ['Superscript', 'Subscript', 'SmallCaps'], - // }, - // 'Notes', - // 'Lists', - // 'Images', - // 'CodeBlock', - // 'Tables', - // 'TrackingAndEditing', - // ], - // }, - // { - // templateArea: 'leftSideBar', - // toolGroups: ['DisplayText'], - // }, - // ], - - SchemaService: { - nodes: { - doc: { - content: 'inline*', - }, - text: { - group: 'inline', - }, - paragraph: null, - hard_break: null, - title: { - group: 'inline', - content: 'inline*', - inline: true, - parseDOM: [ - { - tag: 'title', - }, - ], - toDOM(node) { - return ['title', node.attrs, 0]; + MenuService: [ + { + templateArea: 'topBar', + toolGroups: [ + 'Base', + { + name: 'Annotations', + more: ['Superscript', 'Subscript', 'SmallCaps'], }, - }, + 'Notes', + 'Lists', + 'Images', + 'CodeBlock', + 'Tables', + 'TrackingAndEditing', + ], }, - marks: { - em: { - parseDOM: [{ tag: 'i' }, { tag: 'em' }, { style: 'font-style=italic' }], - toDOM(mark) { - return [('em', 0)]; - }, - }, + { + templateArea: 'leftSideBar', + toolGroups: ['DisplayText'], }, - }, + ], - // RulesService: [emDash, ellipsis], - // ShortCutsService: {}, - // EnableTrackChangeService: { enabled: false }, + SchemaService: {}, - // PmPlugins: [ - // columnResizing(), - // tableEditing(), - // invisibles([hardBreak()]), - // WaxSelectionPlugin, - // ], + RulesService: [emDash, ellipsis], + ShortCutsService: {}, + EnableTrackChangeService: { enabled: false }, + + PmPlugins: [ + columnResizing(), + tableEditing(), + invisibles([hardBreak()]), + WaxSelectionPlugin, + ], // Always load first CommentsService and LinkService, //as it matters on how PM treats nodes and marks services: [ - // new DisplayBlockLevelService(), - // new DisplayToolGroupService(), - // new TextBlockLevelService(), - // new TextToolGroupService(), - // new ListsService(), - // new LinkService(), - // new InlineAnnotationsService(), - // new TrackChangeService(), - // new CommentsService(), - // new PlaceholderService(), - // new ImageService(), - // new TablesService(), - // new BaseService(), - // new BaseToolGroupService(), - // new NoteService(), - // new TableToolGroupService(), - // new ImageToolGroupService(), - // new AnnotationToolGroupService(), - // new NoteToolGroupService(), - // new ListToolGroupService(), - // new CodeBlockService(), - // new CodeBlockToolGroupService(), - // new TrackChangeToolGroupService(), - // new DisplayTextToolGroupService(), - // new MathService(), - // new FindAndReplaceService(), - // new TrackingAndEditingToolGroupService(), + new DisplayBlockLevelService(), + new DisplayToolGroupService(), + new TextBlockLevelService(), + new TextToolGroupService(), + new ListsService(), + new LinkService(), + new InlineAnnotationsService(), + new TrackChangeService(), + new CommentsService(), + new PlaceholderService(), + new ImageService(), + new TablesService(), + new BaseService(), + new BaseToolGroupService(), + new NoteService(), + new TableToolGroupService(), + new ImageToolGroupService(), + new AnnotationToolGroupService(), + new NoteToolGroupService(), + new ListToolGroupService(), + new CodeBlockService(), + new CodeBlockToolGroupService(), + new TrackChangeToolGroupService(), + new DisplayTextToolGroupService(), + new MathService(), + new FindAndReplaceService(), + new TrackingAndEditingToolGroupService(), ], }; diff --git a/editors/editoria/src/config/defaultSchema.js b/editors/editoria/src/config/defaultSchema.js new file mode 100644 index 000000000..8cbf09314 --- /dev/null +++ b/editors/editoria/src/config/defaultSchema.js @@ -0,0 +1,28 @@ +const defaultSchema = { + nodes: { + doc: { + content: 'inline*', + }, + text: { + group: 'inline', + }, + paragraph: null, + hard_break: null, + title: { + group: 'inline', + content: 'inline*', + inline: true, + parseDOM: [ + { + tag: 'title', + }, + ], + toDOM(node) { + return ['title', node.attrs, 0]; + }, + }, + }, + marks: {}, +}; + +export default defaultSchema; diff --git a/wax-prosemirror-core/src/Application.js b/wax-prosemirror-core/src/Application.js index 8fb3e16f7..40916f3a4 100644 --- a/wax-prosemirror-core/src/Application.js +++ b/wax-prosemirror-core/src/Application.js @@ -54,7 +54,6 @@ export default class Application { getSchema() { this.schema = this.container.get('Schema'); - console.log(this.schema.getSchema()); return this.schema.getSchema(); } diff --git a/wax-prosemirror-core/src/Wax.js b/wax-prosemirror-core/src/Wax.js index abed11e92..ccff04147 100644 --- a/wax-prosemirror-core/src/Wax.js +++ b/wax-prosemirror-core/src/Wax.js @@ -15,12 +15,9 @@ const parser = schema => { const WaxParser = DOMParser.fromSchema(schema); return content => { - console.log(content); const container = document.createElement('article'); container.innerHTML = content; - console.log(container.innerHTML); - console.log(WaxParser.parse(container)); return WaxParser.parse(container); }; }; diff --git a/wax-prosemirror-services/src/SchemaService/DefaultSchema.js b/wax-prosemirror-services/src/SchemaService/DefaultSchema.js index 8e636c9eb..26295da14 100644 --- a/wax-prosemirror-services/src/SchemaService/DefaultSchema.js +++ b/wax-prosemirror-services/src/SchemaService/DefaultSchema.js @@ -3,16 +3,23 @@ import { SchemaHelpers } from 'wax-prosemirror-utilities'; export default { nodes: { doc: { - content: 'inline+', + content: 'block+', }, text: { group: 'inline', }, - - paragraph: { + hard_break: { + inline: true, group: 'inline', + selectable: false, + parseDOM: [{ tag: 'br' }], + toDOM() { + return ['br']; + }, + }, + paragraph: { + group: 'block', content: 'inline*', - inline: true, attrs: { id: { default: '' }, class: { default: 'paragraph' }, @@ -37,15 +44,6 @@ export default { return ['p', attrs, 0]; }, }, - hard_break: { - inline: true, - group: 'inline', - selectable: false, - parseDOM: [{ tag: 'br' }], - toDOM() { - return ['br']; - }, - }, }, marks: {}, }; -- GitLab