소스 검색

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

Vanessa 1 년 전
부모
커밋
955d6b4610

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

@@ -135,7 +135,6 @@
   "percentChecked": "Percent checked",
   "percentUnchecked": "Percent unchecked",
   "checkbox": "Checkbox",
-  "copyInline": "Copy inline element",
   "unsplit": "Unsplit",
   "unsplitAll": "Unsplit All",
   "resetCardTip": "Are you sure reset ${x} flashcards?",

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

@@ -135,7 +135,6 @@
   "percentChecked": "Porcentaje comprobado",
   "percentUnchecked": "Porcentaje no marcado",
   "checkbox": "Casilla de verificación",
-  "copyInline": "Copiar elemento en línea",
   "unsplit": "Desdividir",
   "unsplitAll": "Desdividir Todo",
   "resetCardTip": "¿Estás seguro de restablecer ${x} tarjetas?",

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

@@ -135,7 +135,6 @@
   "percentChecked": "Pourcentage vérifié",
   "percentUnchecked": "Pourcentage non coché",
   "checkbox": "case à cocher",
-  "copyInline": "Copier l'élément en ligne",
   "unsplit": "Unsplit",
   "unsplitAll": "Tout dédiviser",
   "resetCardTip": "Êtes-vous sûr de réinitialiser ${x} flashcards ?",

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

@@ -135,7 +135,6 @@
   "percentChecked": "チェック済みの割合",
   "percentUnchecked": "未チェックの割合",
   "checkbox": "チェックボックス",
-  "copyInline": "インライン要素をコピー",
   "unsplit": "分割解除",
   "unsplitAll": "すべての分割解除",
   "resetCardTip": "${x} 枚のフラッシュカードをリセットしてもよろしいですか?",

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

@@ -135,7 +135,6 @@
   "percentChecked": "已完成佔比",
   "percentUnchecked": "未完成佔比",
   "checkbox": "勾選方塊",
-  "copyInline": "複製行級元素",
   "unsplit": "取消分割畫面",
   "unsplitAll": "取消全部分螢幕",
   "resetCardTip": "確定重設 ${x} 張閃卡?",

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

@@ -135,7 +135,6 @@
   "percentChecked": "已完成占比",
   "percentUnchecked": "未完成占比",
   "checkbox": "勾选框",
-  "copyInline": "复制行级元素",
   "unsplit": "取消分屏",
   "unsplitAll": "取消全部分屏",
   "resetCardTip": "确定重置 ${x} 张闪卡?",

+ 41 - 3
app/src/menus/protyle.ts

@@ -653,6 +653,8 @@ export const contentMenu = (protyle: IProtyle, nodeElement: Element) => {
     /// #if MOBILE
     protyle.toolbar.showContent(protyle, range, nodeElement);
     /// #else
+    const oldHTML = nodeElement.outerHTML;
+    const id = nodeElement.getAttribute("data-node-id")
     if (range.toString() !== "" || (range.cloneContents().childNodes[0] as HTMLElement)?.classList?.contains("emoji")) {
         window.siyuan.menus.menu.append(new MenuItem({
             icon: "iconCopy",
@@ -691,11 +693,10 @@ export const contentMenu = (protyle: IProtyle, nodeElement: Element) => {
             click() {
                 const currentRange = getEditorRange(nodeElement);
                 currentRange.insertNode(document.createElement("wbr"));
-                const oldHTML = nodeElement.outerHTML;
                 currentRange.extractContents();
                 focusByWbr(nodeElement, currentRange);
                 focusByRange(currentRange);
-                updateTransaction(protyle, nodeElement.getAttribute("data-node-id"), nodeElement.outerHTML, oldHTML);
+                updateTransaction(protyle, id, nodeElement.outerHTML, oldHTML);
             }
         }).element);
     } else {
@@ -705,11 +706,48 @@ export const contentMenu = (protyle: IProtyle, nodeElement: Element) => {
             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,
+                    label: window.siyuan.languages.copy,
+                    icon:"iconCopy",
+                    click() {
+                        writeText(protyle.lute.BlockDOM2StdMd(inlineElement.outerHTML));
+                    }
+                }).element);
+                window.siyuan.menus.menu.append(new MenuItem({
+                    label: window.siyuan.languages.copyPlainText,
                     click() {
                         copyPlainText(inlineElement.textContent);
                     }
                 }).element);
+                if (!protyle.disabled) {
+                    const id = nodeElement.getAttribute("data-node-id");
+                    window.siyuan.menus.menu.append(new MenuItem({
+                        icon: "iconCut",
+                        label: window.siyuan.languages.cut,
+                        click() {
+                            writeText(protyle.lute.BlockDOM2StdMd(inlineElement.outerHTML));
+
+                            inlineElement.insertAdjacentHTML("afterend", "<wbr>");
+                            inlineElement.remove();
+                            nodeElement.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss"));
+                            updateTransaction(protyle, id, nodeElement.outerHTML, oldHTML);
+                            focusByWbr(nodeElement, protyle.toolbar.range);
+                        }
+                    }).element);
+                    window.siyuan.menus.menu.append(new MenuItem({
+                        icon: "iconTrashcan",
+                        label: window.siyuan.languages.remove,
+                        click() {
+                            inlineElement.insertAdjacentHTML("afterend", "<wbr>");
+                            inlineElement.remove();
+                            nodeElement.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss"));
+                            updateTransaction(protyle, id, nodeElement.outerHTML, oldHTML);
+                            focusByWbr(nodeElement, protyle.toolbar.range);
+                        }
+                    }).element);
+                }
+                window.siyuan.menus.menu.append(new MenuItem({
+                    type: "separator",
+                }).element);
             }
         }
     }