From b6543b9b88fb0c87729e8c7b1f1bfbd131613669 Mon Sep 17 00:00:00 2001 From: chris <kokosias@yahoo.gr> Date: Tue, 23 Feb 2021 12:55:38 +0200 Subject: [PATCH] blockquote active --- editors/editoria/src/Editoria.js | 3 +-- .../BlockQuoteService/BlockQuote.js | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/editors/editoria/src/Editoria.js b/editors/editoria/src/Editoria.js index 00db23f7e..33d5439b3 100644 --- a/editors/editoria/src/Editoria.js +++ b/editors/editoria/src/Editoria.js @@ -62,8 +62,7 @@ const Editoria = () => { autoFocus placeholder="Type Something..." fileUpload={file => renderImage(file)} - value={`<p class="paragraph">hello</p><p class="custom-tag-label-3" data-type="block">Lorem this is <span class="custom-tag-label-1,custom-tag-label-2" data-type="inline" data-tags="["custom-tag-label-1","custom-tag-label-2"]">text </span>dolor si</p>`} - // value={demo} + value={demo} // readonly layout={layout} // onChange={source => console.log(source)} diff --git a/wax-prosemirror-services/src/TextBlockLevel/BlockQuoteService/BlockQuote.js b/wax-prosemirror-services/src/TextBlockLevel/BlockQuoteService/BlockQuote.js index f5e852195..f6da4040b 100644 --- a/wax-prosemirror-services/src/TextBlockLevel/BlockQuoteService/BlockQuote.js +++ b/wax-prosemirror-services/src/TextBlockLevel/BlockQuoteService/BlockQuote.js @@ -1,6 +1,7 @@ -import Tools from '../../lib/Tools'; import { injectable } from 'inversify'; import { wrapIn } from 'prosemirror-commands'; +import { NodeSelection } from 'prosemirror-state'; +import Tools from '../../lib/Tools'; @injectable() class BlockQuote extends Tools { @@ -19,6 +20,20 @@ class BlockQuote extends Tools { return true; }; + get active() { + return state => { + const { $from, to } = state.selection; + const same = $from.sharedDepth(to); + if (same === 0) return false; + const pos = $from.before(same); + const node = NodeSelection.create(state.doc, pos); + if (node.$from.parent.hasMarkup(state.config.schema.nodes.blockquote)) { + return true; + } + return false; + }; + } + get enable() { return state => { return wrapIn(state.config.schema.nodes.blockquote)(state); -- GitLab