Browse Source

:art: fix https://github.com/siyuan-note/siyuan/issues/11275#issuecomment-2119783575

Vanessa 1 year ago
parent
commit
d0f3ac29b6
2 changed files with 7 additions and 1 deletions
  1. 0 1
      app/src/menus/index.ts
  2. 7 0
      app/src/menus/text.ts

+ 0 - 1
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;
 

+ 7 - 0
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");
         }
     });