Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: https://github.com/siyuan-note/siyuan/issues/13092

Vanessa1eaa79c99953
diff --git a/app/src/menus/protyle.ts b/app/src/menus/protyle.ts
index 7e314070ed..934b6ce3fc 100644
--- a/app/src/menus/protyle.ts
+++ b/app/src/menus/protyle.ts
@@ -1716,21 +1716,20 @@ export const tagMenu = (protyle: IProtyle, tagElement: HTMLElement) => {
label: window.siyuan.languages.copy,
icon: "iconCopy",
click() {
- writeText(protyle.lute.BlockDOM2StdMd(tagElement.outerHTML));
+ const range = document.createRange()
+ range.selectNode(tagElement);
+ focusByRange(range)
+ document.execCommand("copy");
}
}).element);
window.siyuan.menus.menu.append(new MenuItem({
label: window.siyuan.languages.cut,
icon: "iconCut",
click() {
- writeText(protyle.lute.BlockDOM2StdMd(tagElement.outerHTML));
-
- const oldHTML = nodeElement.outerHTML;
- tagElement.insertAdjacentHTML("afterend", "<wbr>");
- tagElement.remove();
- nodeElement.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss"));
- updateTransaction(protyle, id, nodeElement.outerHTML, oldHTML);
- focusByWbr(nodeElement, protyle.toolbar.range);
+ const range = document.createRange()
+ range.selectNode(tagElement);
+ focusByRange(range)
+ document.execCommand("cut");
}
}).element);
window.siyuan.menus.menu.append(new MenuItem({
@@ -1781,7 +1780,10 @@ export const inlineMathMenu = (protyle: IProtyle, element: Element) => {
label: window.siyuan.languages.copy,
icon: "iconCopy",
click() {
- writeText(protyle.lute.BlockDOM2StdMd(element.outerHTML));
+ const range = document.createRange()
+ range.selectNode(element);
+ focusByRange(range)
+ document.execCommand("copy");
}
}).element);
if (!protyle.disabled) {
@@ -1789,13 +1791,10 @@ export const inlineMathMenu = (protyle: IProtyle, element: Element) => {
icon: "iconCut",
label: window.siyuan.languages.cut,
click() {
- writeText(protyle.lute.BlockDOM2StdMd(element.outerHTML));
-
- element.insertAdjacentHTML("afterend", "<wbr>");
- element.remove();
- nodeElement.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss"));
- updateTransaction(protyle, id, nodeElement.outerHTML, html);
- focusByWbr(nodeElement, protyle.toolbar.range);
+ const range = document.createRange()
+ range.selectNode(element);
+ focusByRange(range)
+ document.execCommand("cut");
}
}).element);
window.siyuan.menus.menu.append(new MenuItem({
diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.ts
index 7ee1d5312a..630ecfb71d 100644
--- a/app/src/protyle/wysiwyg/index.ts
+++ b/app/src/protyle/wysiwyg/index.ts
@@ -1775,7 +1775,7 @@ export class WYSIWYG {
protyle.toolbar.range = getEditorRange(protyle.element);
if (target.tagName === "SPAN" && !isNotEditBlock(nodeElement)) { // https://ld246.com/article/1665141518103
- let types = target.getAttribute("data-type")?.split(" ");
+ let types = target.getAttribute("data-type")?.split(" ") || [];
if (types.length === 0) {
// https://github.com/siyuan-note/siyuan/issues/8960
types = (target.dataset.type || "").split(" ");