This is an automated email from the ASF dual-hosted git repository. linkinstar pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/incubator-answer-plugins.git
commit f1c51a856e9e30be2111e39ecedebed42fdcc38e Author: robin <[email protected]> AuthorDate: Thu May 30 16:29:27 2024 +0800 feat(embed-basic): add keyboard shortcut for showing embed modal --- embed-basic/Component.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/embed-basic/Component.tsx b/embed-basic/Component.tsx index 95d8b28..b4ce9e1 100644 --- a/embed-basic/Component.tsx +++ b/embed-basic/Component.tsx @@ -17,7 +17,7 @@ * under the License. */ -import { useState } from 'react' +import { useState, useEffect } from 'react' import { Button } from 'react-bootstrap' import EmbedModal from './modal' @@ -28,6 +28,13 @@ const Component = ({ editor, previewElement }) => { useRenderEmbed(previewElement) + useEffect(() => { + if (!editor) return + editor.addKeyMap({ + 'Ctrl-m': handleShow, + }) + }, [editor]) + const handleShow = () => { setShowState(true) } @@ -48,6 +55,7 @@ const Component = ({ editor, previewElement }) => { variant="link" className="p-0 b-0 btn-no-border toolbar text-body" onClick={handleShow} + title="Embed (Ctrl+m)" > <i className="bi bi-window" /> </Button>
