diff --git a/app/appearance/langs/en_US.json b/app/appearance/langs/en_US.json index be02757ef..d62b803d1 100644 --- a/app/appearance/langs/en_US.json +++ b/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?", diff --git a/app/appearance/langs/es_ES.json b/app/appearance/langs/es_ES.json index 173163ad4..6cec67e18 100644 --- a/app/appearance/langs/es_ES.json +++ b/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?", diff --git a/app/appearance/langs/fr_FR.json b/app/appearance/langs/fr_FR.json index 9173d06ff..1f6407171 100644 --- a/app/appearance/langs/fr_FR.json +++ b/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 ?", diff --git a/app/appearance/langs/ja_JP.json b/app/appearance/langs/ja_JP.json index a0d60649e..6d2239d47 100644 --- a/app/appearance/langs/ja_JP.json +++ b/app/appearance/langs/ja_JP.json @@ -135,7 +135,6 @@ "percentChecked": "チェック済みの割合", "percentUnchecked": "未チェックの割合", "checkbox": "チェックボックス", - "copyInline": "インライン要素をコピー", "unsplit": "分割解除", "unsplitAll": "すべての分割解除", "resetCardTip": "${x} 枚のフラッシュカードをリセットしてもよろしいですか?", diff --git a/app/appearance/langs/zh_CHT.json b/app/appearance/langs/zh_CHT.json index 4b3f70eee..ad8747616 100644 --- a/app/appearance/langs/zh_CHT.json +++ b/app/appearance/langs/zh_CHT.json @@ -135,7 +135,6 @@ "percentChecked": "已完成佔比", "percentUnchecked": "未完成佔比", "checkbox": "勾選方塊", - "copyInline": "複製行級元素", "unsplit": "取消分割畫面", "unsplitAll": "取消全部分螢幕", "resetCardTip": "確定重設 ${x} 張閃卡?", diff --git a/app/appearance/langs/zh_CN.json b/app/appearance/langs/zh_CN.json index 7e1c07295..1004333d3 100644 --- a/app/appearance/langs/zh_CN.json +++ b/app/appearance/langs/zh_CN.json @@ -135,7 +135,6 @@ "percentChecked": "已完成占比", "percentUnchecked": "未完成占比", "checkbox": "勾选框", - "copyInline": "复制行级元素", "unsplit": "取消分屏", "unsplitAll": "取消全部分屏", "resetCardTip": "确定重置 ${x} 张闪卡?", diff --git a/app/src/menus/protyle.ts b/app/src/menus/protyle.ts index 10881da2a..77a176134 100644 --- a/app/src/menus/protyle.ts +++ b/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", ""); + 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", ""); + 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); } } }