diff --git a/app/src/menus/index.ts b/app/src/menus/index.ts index 34cafe9b4..328160958 100644 --- a/app/src/menus/index.ts +++ b/app/src/menus/index.ts @@ -15,7 +15,6 @@ import {App} from "../index"; import {Constants} from "../constants"; import {textMenu} from "./text"; - export class Menus { public menu: Menu; diff --git a/app/src/menus/text.ts b/app/src/menus/text.ts index 1dc1f9897..07cbe0f47 100644 --- a/app/src/menus/text.ts +++ b/app/src/menus/text.ts @@ -9,6 +9,13 @@ export const textMenu = (target: Element) => { label: window.siyuan.languages.copy, icon: "iconCopy", click() { + if (getSelection().rangeCount === 0) { + return; + } + const range = getSelection().getRangeAt(0); + if (!range.toString()) { + getSelection().getRangeAt(0).selectNode(target); + } document.execCommand("copy"); } });