This is an automated email from the ASF dual-hosted git repository.
robin0716 pushed a commit to branch feat/embed
in repository https://gitbox.apache.org/repos/asf/incubator-answer-plugins.git
The following commit(s) were added to refs/heads/feat/embed by this push:
new 2db4713 feat(embed-basic): add keyboard shortcut for showing embed
modal
2db4713 is described below
commit 2db47138467fd0bab40e2ec4f3b412d3c8cb573d
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>