From cdd3747850cca77f61b663cbfeda9765a72eb8d0 Mon Sep 17 00:00:00 2001 From: Erez Rokah Date: Mon, 17 Feb 2020 17:35:29 +0200 Subject: [PATCH] fix(widget-markdown): allow shortcodes as list items (#3278) --- .../src/MarkdownControl/schema.js | 40 +------------------ 1 file changed, 1 insertion(+), 39 deletions(-) diff --git a/packages/netlify-cms-widget-markdown/src/MarkdownControl/schema.js b/packages/netlify-cms-widget-markdown/src/MarkdownControl/schema.js index 16f3cc7d..2af9870b 100644 --- a/packages/netlify-cms-widget-markdown/src/MarkdownControl/schema.js +++ b/packages/netlify-cms-widget-markdown/src/MarkdownControl/schema.js @@ -90,6 +90,7 @@ const schema = ({ voidCodeBlock } = {}) => ({ { type: 'numbered-list' }, { type: 'thematic-break' }, { type: 'table' }, + { type: 'shortcode' }, ], }, ], @@ -101,45 +102,6 @@ const schema = ({ voidCodeBlock } = {}) => ({ { match: [{ object: 'block', type: 'list-item' }], parent: [{ type: 'bulleted-list' }, { type: 'numbered-list' }], - /* - normalize: (editor, error) => { - switch (error.code) { - // If a list item is wrapped in something other than a list, wrap it - // in a list. This is only known to happen when toggling blockquote - // with multiple list items selected. - case 'parent_type_invalid': { - const parent = editor.value.document.getParent(error.node.key) - const grandparent = editor.value.document.getParent(parent.key) - console.log(editor.value.blocks) - - if ( - !editor.everyBlock('list-item') || - !editor.areSiblings(editor.value.blocks) || - !['bulleted-list', 'numbered-list'].includes(grandparent.type) - ) { - return; - } - - editor.withoutNormalizing(() => { - const entireListSelected = editor.value.blocks.length === parent.nodes.length; - editor.setNodeByKey(parent.key, grandparent.type); - - console.log(entireListSelected) - console.log(JSON.stringify(editor.value.document.toJS(), null, 2)) - // Wrap the entire list if all list items are selected - if (entireListSelected) { - editor.setNodeByKey(grandparent.key, parent.type) - } else { - editor - .wrapBlockByKey(parent.key, parent.type) - .wrapBlockByKey(grandparent.key, 'list-item'); - } - }) - return; - } - } - }, - */ }, /**