From b0db7f29d365112bccc337b314f325100d860ac1 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Wed, 7 Feb 2018 22:29:33 -0800 Subject: [PATCH] Fixes: Possible to create blocks inside document title --- app/components/Editor/plugins/MarkdownShortcuts.js | 4 ++++ app/components/Editor/schema.js | 12 ++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/app/components/Editor/plugins/MarkdownShortcuts.js b/app/components/Editor/plugins/MarkdownShortcuts.js index 0cd0a5b7..912a8a65 100644 --- a/app/components/Editor/plugins/MarkdownShortcuts.js +++ b/app/components/Editor/plugins/MarkdownShortcuts.js @@ -40,6 +40,10 @@ export default function MarkdownShortcuts() { const { value } = change; if (value.isExpanded) return; const { startBlock, startOffset } = value; + + // no markdown shortcuts work in headings + if (startBlock.type.match(/heading/)) return; + const chars = startBlock.text.slice(0, startOffset).trim(); const type = this.getType(chars); diff --git a/app/components/Editor/schema.js b/app/components/Editor/schema.js index d3b757a4..870d7c6f 100644 --- a/app/components/Editor/schema.js +++ b/app/components/Editor/schema.js @@ -3,12 +3,12 @@ import { Block, Change, Node, Mark } from 'slate'; const schema = { blocks: { - heading1: { marks: [''] }, - heading2: { marks: [''] }, - heading3: { marks: [''] }, - heading4: { marks: [''] }, - heading5: { marks: [''] }, - heading6: { marks: [''] }, + heading1: { nodes: [{ kinds: ['text'] }], marks: [''] }, + heading2: { nodes: [{ kinds: ['text'] }], marks: [''] }, + heading3: { nodes: [{ kinds: ['text'] }], marks: [''] }, + heading4: { nodes: [{ kinds: ['text'] }], marks: [''] }, + heading5: { nodes: [{ kinds: ['text'] }], marks: [''] }, + heading6: { nodes: [{ kinds: ['text'] }], marks: [''] }, 'block-quote': { marks: [''] }, table: { nodes: [{ types: ['table-row', 'table-head', 'table-cell'] }],