Explorar el Código

:art: fix https://github.com/siyuan-note/siyuan/issues/9630

Vanessa hace 1 año
padre
commit
ec4da7cde7

+ 1 - 0
app/appearance/langs/en_US.json

@@ -1,4 +1,5 @@
 {
+  "copyInline": "Copy inline element",
   "unsplit": "Unsplit",
   "unsplitAll": "Unsplit All",
   "resetCardTip": "Are you sure reset ${x} flashcards?",

+ 1 - 0
app/appearance/langs/es_ES.json

@@ -1,4 +1,5 @@
 {
+  "copyInline": "Copiar elemento en línea",
   "unsplit": "Desdividir",
   "unsplitAll": "Desdividir Todo",
   "resetCardTip": "¿Estás seguro de restablecer ${x} tarjetas?",

+ 1 - 0
app/appearance/langs/fr_FR.json

@@ -1,4 +1,5 @@
 {
+  "copyInline": "Copier l'élément en ligne",
   "unsplit": "Unsplit",
   "unsplitAll": "Tout dédiviser",
   "resetCardTip": "Êtes-vous sûr de réinitialiser ${x} flashcards ?",

+ 1 - 0
app/appearance/langs/zh_CHT.json

@@ -1,4 +1,5 @@
 {
+  "copyInline": "複製行級元素",
   "unsplit": "取消分割畫面",
   "unsplitAll": "取消全部分螢幕",
   "resetCardTip": "確定重設 ${x} 張閃卡?",

+ 1 - 0
app/appearance/langs/zh_CN.json

@@ -1,4 +1,5 @@
 {
+  "copyInline": "复制行级元素",
   "unsplit": "取消分屏",
   "unsplitAll": "取消全部分屏",
   "resetCardTip": "确定重置 ${x} 张闪卡?",

+ 14 - 0
app/src/menus/protyle.ts

@@ -655,6 +655,20 @@ export const contentMenu = (protyle: IProtyle, nodeElement: Element) => {
                 updateTransaction(protyle, nodeElement.getAttribute("data-node-id"), nodeElement.outerHTML, oldHTML);
             }
         }).element);
+    } else {
+        // https://github.com/siyuan-note/siyuan/issues/9630
+        const inlineElement = hasClosestByMatchTag(range.startContainer, "SPAN")
+        if (inlineElement) {
+            const inlineTypes = protyle.toolbar.getCurrentType(range);
+            if (inlineTypes.includes("code") || inlineTypes.includes("kbd")) {
+                window.siyuan.menus.menu.append(new MenuItem({
+                    label: window.siyuan.languages.copyInline,
+                    click() {
+                        copyPlainText(inlineElement.textContent);
+                    }
+                }).element);
+            }
+        }
     }
     if (!protyle.disabled) {
         window.siyuan.menus.menu.append(new MenuItem({