When inserting an image from the + or / menus and the post is empty then replace the current post with the image, if the post is not empty then insert the image in the following post.

This commit is contained in:
Ryan McCarvill 2017-04-05 19:00:01 +12:00 committed by Kevin Ansfield
parent fd857d2493
commit 4cd7e67e5c

View File

@ -198,9 +198,14 @@ export default function (editor, toolbar) {
order: 2,
cardMenu: true,
onClick: (editor) => {
editor.run((postEditor) => {
editor.run((postEditor, section) => {
let card = postEditor.builder.createCardSection('card-image', {pos: 'top'});
postEditor.insertSection(card);
console.log(editor.range.headSection.text.length);
if (section || editor.range.headSection.text.length) {
postEditor.insertSection(card);
} else {
postEditor.replaceSection(section || editor.range.headSection, card);
}
});
},