fix: Pasting rich text into image caption inherits styling
This commit is contained in:
@@ -215,6 +215,14 @@ export default class Image extends SimpleImage {
|
|||||||
void downloadImageNode(node);
|
void downloadImageNode(node);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Ensure only plain text can be pasted into input when pasting from another
|
||||||
|
// rich text source.
|
||||||
|
handlePaste = (event: React.ClipboardEvent<HTMLSpanElement>) => {
|
||||||
|
event.preventDefault();
|
||||||
|
const text = event.clipboardData.getData("text/plain");
|
||||||
|
window.document.execCommand("insertText", false, text);
|
||||||
|
};
|
||||||
|
|
||||||
component = (props: ComponentProps) => (
|
component = (props: ComponentProps) => (
|
||||||
<ImageComponent
|
<ImageComponent
|
||||||
{...props}
|
{...props}
|
||||||
@@ -223,6 +231,7 @@ export default class Image extends SimpleImage {
|
|||||||
onChangeSize={this.handleChangeSize(props)}
|
onChangeSize={this.handleChangeSize(props)}
|
||||||
>
|
>
|
||||||
<Caption
|
<Caption
|
||||||
|
onPaste={this.handlePaste}
|
||||||
onKeyDown={this.handleKeyDown(props)}
|
onKeyDown={this.handleKeyDown(props)}
|
||||||
onBlur={this.handleBlur(props)}
|
onBlur={this.handleBlur(props)}
|
||||||
onMouseDown={this.handleMouseDown}
|
onMouseDown={this.handleMouseDown}
|
||||||
|
|||||||
Reference in New Issue
Block a user