From d1a4348048c9c9b44e0a55f58c2833e11386b7b0 Mon Sep 17 00:00:00 2001 From: boojack Date: Fri, 9 Sep 2022 19:42:04 +0800 Subject: [PATCH] chore: support double-click to edit memo (#207) --- web/src/components/Memo.tsx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/web/src/components/Memo.tsx b/web/src/components/Memo.tsx index 44395db1..fbfa9f03 100644 --- a/web/src/components/Memo.tsx +++ b/web/src/components/Memo.tsx @@ -171,6 +171,20 @@ const Memo: React.FC = (props: Props) => { } }; + const handleMemoContentDoubleClick = (e: React.MouseEvent) => { + const targetEl = e.target as HTMLElement; + + if (targetEl.className === "memo-link-text") { + return; + } else if (targetEl.className === "tag-span") { + return; + } else if (targetEl.classList.contains("todo-block")) { + return; + } + + editorStateService.setEditMemoWithId(memo.id); + }; + const handleExpandBtnClick = () => { const expandButtonStatus = Boolean(!state.expandButtonStatus); if (!expandButtonStatus) { @@ -228,6 +242,7 @@ const Memo: React.FC = (props: Props) => { ref={memoContentContainerRef} className={`memo-content-text ${state.expandButtonStatus === 0 ? "expanded" : ""}`} onClick={handleMemoContentClick} + onDoubleClick={handleMemoContentDoubleClick} dangerouslySetInnerHTML={{ __html: formatMemoContent(memo.content) }} > {state.expandButtonStatus !== -1 && (