Skip to content

Commit

Permalink
fix(widget-markdown): allow shortcodes as list items (#3278)
Browse files Browse the repository at this point in the history
  • Loading branch information
erezrokah committed Feb 17, 2020
1 parent 8cc5fcb commit cdd3747
Showing 1 changed file with 1 addition and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ const schema = ({ voidCodeBlock } = {}) => ({
{ type: 'numbered-list' },
{ type: 'thematic-break' },
{ type: 'table' },
{ type: 'shortcode' },
],
},
],
Expand All @@ -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;
}
}
},
*/
},

/**
Expand Down

0 comments on commit cdd3747

Please sign in to comment.