Fixes: Allow BlockInsert on final block (previously didnt work in Prod)
This commit is contained in:
@ -22,6 +22,8 @@ function findClosestRootNode(value, ev) {
|
||||
if (bounds.top > ev.clientY) return previous;
|
||||
previous = { node, element, bounds };
|
||||
}
|
||||
|
||||
return previous;
|
||||
}
|
||||
|
||||
@observer
|
||||
@ -100,10 +102,21 @@ export default class BlockInsert extends Component {
|
||||
}
|
||||
});
|
||||
|
||||
change
|
||||
.collapseToStartOf(this.closestRootNode)
|
||||
.collapseToEndOfPreviousBlock()
|
||||
.insertBlock({ type: 'block-toolbar', isVoid: true });
|
||||
change.collapseToStartOf(this.closestRootNode);
|
||||
|
||||
// if we're on an empty paragraph then just replace it with the block
|
||||
// toolbar. Otherwise insert the toolbar as an extra Node.
|
||||
if (
|
||||
!this.closestRootNode.text &&
|
||||
this.closestRootNode.type === 'paragraph'
|
||||
) {
|
||||
change.setNodeByKey(this.closestRootNode.key, {
|
||||
type: 'block-toolbar',
|
||||
isVoid: true,
|
||||
});
|
||||
} else {
|
||||
change.insertBlock({ type: 'block-toolbar', isVoid: true });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -1,3 +0,0 @@
|
||||
// @flow
|
||||
import ClickablePadding from './ClickablePadding';
|
||||
export default ClickablePadding;
|
@ -72,7 +72,7 @@ class BlockToolbar extends Component {
|
||||
|
||||
editor.value.document.nodes.forEach(node => {
|
||||
if (node.type === 'block-toolbar') {
|
||||
change.removeNodeByKey(node.key);
|
||||
change.removeNodeByKey(node.key, undefined, { normalize: false });
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
// @flow
|
||||
import React from 'react';
|
||||
import InlineCode from './components/InlineCode';
|
||||
import Code from './components/InlineCode';
|
||||
import { Mark } from 'slate';
|
||||
|
||||
type Props = {
|
||||
@ -13,7 +13,7 @@ export default function renderMark(props: Props) {
|
||||
case 'bold':
|
||||
return <strong>{props.children}</strong>;
|
||||
case 'code':
|
||||
return <InlineCode>{props.children}</InlineCode>;
|
||||
return <Code>{props.children}</Code>;
|
||||
case 'italic':
|
||||
return <em>{props.children}</em>;
|
||||
case 'underlined':
|
||||
|
@ -24,7 +24,7 @@ const createPlugins = ({ onImageUploadStart, onImageUploadStop }: Options) => {
|
||||
collapseTo: 'end',
|
||||
}),
|
||||
InsertImages({
|
||||
extensions: ['png', 'jpg', 'gif'],
|
||||
extensions: ['png', 'jpg', 'gif', 'webp'],
|
||||
insertImage: (change, file) => {
|
||||
return change.call(
|
||||
insertImageFile,
|
||||
|
@ -131,12 +131,15 @@ export default function MarkdownShortcuts() {
|
||||
return change
|
||||
.extendToStartOf(startBlock)
|
||||
.delete()
|
||||
.setBlock({
|
||||
.setBlock(
|
||||
{
|
||||
type: 'horizontal-rule',
|
||||
isVoid: true,
|
||||
})
|
||||
.collapseToStartOfNextBlock()
|
||||
.insertBlock('paragraph');
|
||||
},
|
||||
{ normalize: false }
|
||||
)
|
||||
.insertBlock('paragraph')
|
||||
.collapseToStart();
|
||||
}
|
||||
},
|
||||
|
||||
|
Reference in New Issue
Block a user