feat(web): markdown support copy
This commit is contained in:
@@ -150,9 +150,19 @@ const RbMarkdown: FC<RbMarkdownProps> = ({
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 处理键盘快捷键
|
||||||
|
const handleKeyDown = (e: React.KeyboardEvent) => {
|
||||||
|
if ((e.ctrlKey || e.metaKey) && e.key === 'c') {
|
||||||
|
const selection = window.getSelection()
|
||||||
|
if (selection && selection.toString()) {
|
||||||
|
navigator.clipboard.writeText(selection.toString())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 预览模式
|
// 预览模式
|
||||||
return (
|
return (
|
||||||
<div className="rb:relative">
|
<div className="rb:relative" onKeyDown={handleKeyDown} tabIndex={0}>
|
||||||
<style>{`
|
<style>{`
|
||||||
.html-comment {
|
.html-comment {
|
||||||
color: #999;
|
color: #999;
|
||||||
|
|||||||
Reference in New Issue
Block a user