From c68573a7d115b3d4042aa68c29ff2fed0272e52c Mon Sep 17 00:00:00 2001 From: chris <kokosias@yahoo.gr> Date: Fri, 26 Jul 2019 18:14:18 +0300 Subject: [PATCH] schema --- editors/editoria/src/Editoria.js | 4 ++-- wax-prosemirror-schema/src/EditoriaSchema.js | 21 ++++++++++++++------ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/editors/editoria/src/Editoria.js b/editors/editoria/src/Editoria.js index 970df2218..5ed1bbbde 100644 --- a/editors/editoria/src/Editoria.js +++ b/editors/editoria/src/Editoria.js @@ -112,9 +112,9 @@ const renderImage = file => { }); }; -const text = `<h1> this is a title</h1><p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. +const text = `<h1> this is a title</h1><p class="author">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. -</p><p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. +</p><p class="paragraph">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. </p>`; diff --git a/wax-prosemirror-schema/src/EditoriaSchema.js b/wax-prosemirror-schema/src/EditoriaSchema.js index 4aae65897..7dab05c26 100644 --- a/wax-prosemirror-schema/src/EditoriaSchema.js +++ b/wax-prosemirror-schema/src/EditoriaSchema.js @@ -48,7 +48,9 @@ const parseTracks = str => { const blockLevelToDOM = node => { const attrs = node.attrs.track.length - ? { "data-track": JSON.stringify(node.attrs.track) } + ? { + "data-track": JSON.stringify(node.attrs.track) + } : {}; return attrs; }; @@ -102,15 +104,17 @@ const EditoriaSchema = { group: "block", content: "inline*", attrs: { + class: { default: "paragraph" }, track: { default: [] } }, parseDOM: [ { - tag: "p", + tag: "p.paragraph", getAttrs(dom) { return { + class: dom.getAttribute("class"), track: parseTracks(dom.dataset.track) }; } @@ -127,20 +131,25 @@ const EditoriaSchema = { priority: 0, defining: true, attrs: { - class: { default: "author" } + class: { default: "author" }, + track: { + default: [] + } }, parseDOM: [ { - tag: "p", + tag: "p.author", getAttrs(dom) { return { - class: dom.getAttribute("class") + class: dom.getAttribute("class"), + track: parseTracks(dom.dataset.track) }; } } ], toDOM(node) { - return ["p", node.attrs, 0]; + const attrs = blockLevelToDOM(node); + return ["p", attrs, 0]; } }, epigraphProse: { -- GitLab