Dont show caption placeholder in reading mode.
Make it easier to escape image selected state
This commit is contained in:
parent
abff5aa331
commit
cfc9e6fb6b
@ -30,6 +30,7 @@ class Image extends Component {
|
||||
const caption = node.data.get('alt');
|
||||
const src = node.data.get('src');
|
||||
const active = state.isFocused && state.selection.hasEdgeIn(node);
|
||||
const showCaption = !readOnly || caption;
|
||||
|
||||
return (
|
||||
<CenteredImage>
|
||||
@ -40,6 +41,7 @@ class Image extends Component {
|
||||
active={active}
|
||||
loading={loading}
|
||||
/>
|
||||
{showCaption &&
|
||||
<Caption
|
||||
type="text"
|
||||
placeholder="Write a caption"
|
||||
@ -48,7 +50,8 @@ class Image extends Component {
|
||||
defaultValue={caption}
|
||||
contentEditable={false}
|
||||
disabled={readOnly}
|
||||
/>
|
||||
tabIndex={-1}
|
||||
/>}
|
||||
</CenteredImage>
|
||||
);
|
||||
}
|
||||
|
@ -215,6 +215,19 @@ export default function MarkdownShortcuts() {
|
||||
return this.onBackspace(ev, state);
|
||||
if (endOffset !== startBlock.length) return;
|
||||
|
||||
// Hitting enter while an image is selected should jump caret below and
|
||||
// insert a new paragraph
|
||||
if (startBlock.type === 'image') {
|
||||
ev.preventDefault();
|
||||
return state
|
||||
.transform()
|
||||
.collapseToEnd()
|
||||
.insertBlock('paragraph')
|
||||
.apply();
|
||||
}
|
||||
|
||||
// Hitting enter in a heading or blockquote will split the node at that
|
||||
// point and make the new node a paragraph
|
||||
if (
|
||||
startBlock.type !== 'heading1' &&
|
||||
startBlock.type !== 'heading2' &&
|
||||
@ -228,7 +241,6 @@ export default function MarkdownShortcuts() {
|
||||
}
|
||||
|
||||
ev.preventDefault();
|
||||
|
||||
return state.transform().splitBlock().setBlock('paragraph').apply();
|
||||
},
|
||||
|
||||
|
Reference in New Issue
Block a user