Dont show caption placeholder in reading mode.
Make it easier to escape image selected state
This commit is contained in:
@ -30,6 +30,7 @@ class Image extends Component {
|
|||||||
const caption = node.data.get('alt');
|
const caption = node.data.get('alt');
|
||||||
const src = node.data.get('src');
|
const src = node.data.get('src');
|
||||||
const active = state.isFocused && state.selection.hasEdgeIn(node);
|
const active = state.isFocused && state.selection.hasEdgeIn(node);
|
||||||
|
const showCaption = !readOnly || caption;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<CenteredImage>
|
<CenteredImage>
|
||||||
@ -40,15 +41,17 @@ class Image extends Component {
|
|||||||
active={active}
|
active={active}
|
||||||
loading={loading}
|
loading={loading}
|
||||||
/>
|
/>
|
||||||
<Caption
|
{showCaption &&
|
||||||
type="text"
|
<Caption
|
||||||
placeholder="Write a caption"
|
type="text"
|
||||||
onChange={this.handleChange}
|
placeholder="Write a caption"
|
||||||
onClick={this.handleClick}
|
onChange={this.handleChange}
|
||||||
defaultValue={caption}
|
onClick={this.handleClick}
|
||||||
contentEditable={false}
|
defaultValue={caption}
|
||||||
disabled={readOnly}
|
contentEditable={false}
|
||||||
/>
|
disabled={readOnly}
|
||||||
|
tabIndex={-1}
|
||||||
|
/>}
|
||||||
</CenteredImage>
|
</CenteredImage>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -215,6 +215,19 @@ export default function MarkdownShortcuts() {
|
|||||||
return this.onBackspace(ev, state);
|
return this.onBackspace(ev, state);
|
||||||
if (endOffset !== startBlock.length) return;
|
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 (
|
if (
|
||||||
startBlock.type !== 'heading1' &&
|
startBlock.type !== 'heading1' &&
|
||||||
startBlock.type !== 'heading2' &&
|
startBlock.type !== 'heading2' &&
|
||||||
@ -228,7 +241,6 @@ export default function MarkdownShortcuts() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
|
|
||||||
return state.transform().splitBlock().setBlock('paragraph').apply();
|
return state.transform().splitBlock().setBlock('paragraph').apply();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user