Skip to content

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

:bug: fix https://github.com/siyuan-note/siyuan/issues/8706

Vanessa6c09dd4db210
diff --git a/app/src/protyle/wysiwyg/keydown.ts b/app/src/protyle/wysiwyg/keydown.ts
index 3ca8295dd8..45efba95f8 100644
--- a/app/src/protyle/wysiwyg/keydown.ts
+++ b/app/src/protyle/wysiwyg/keydown.ts
@@ -141,6 +141,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
// 有可能输入 shift+. ,因此需要使用 event.key 来进行判断
if (event.key !== "PageUp" && event.key !== "PageDown" && event.key !== "Home" && event.key !== "End" && event.key.indexOf("Arrow") === -1 &&
event.key !== "Escape" && event.key !== "Shift" && event.key !== "Meta" && event.key !== "Alt" && event.key !== "Control" && event.key !== "CapsLock" &&
+ !isNotEditBlock(nodeElement) &&
!/^F\d{1,2}$/.test(event.key) && typeof protyle.wysiwyg.lastHTMLs[nodeElement.getAttribute("data-node-id")] === "undefined") {
const cloneRange = range.cloneRange();
range.insertNode(document.createElement("wbr"));
@@ -1438,14 +1439,16 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
return;
}
- if (isNotEditBlock(nodeElement) &&
- nodeElement.getAttribute("data-type") !== "NodeHTMLBlock" // HTML 块选中部分内容无法复制 https://github.com/siyuan-note/siyuan/issues/5521
- && matchHotKey("⌘C", event)) {
+ if (isNotEditBlock(nodeElement) && matchHotKey("⌘C", event)) {
let html = "";
protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--select").forEach(item => {
html += removeEmbed(item);
});
- writeText(protyle.lute.BlockDOM2StdMd(html).trimEnd());
+ if (html !== "") {
+ // HTML 块选中部分内容时不写入剪切板 https://github.com/siyuan-note/siyuan/issues/5521
+ // 从下往上选中 HTML 块需可以复制 https://github.com/siyuan-note/siyuan/issues/8706
+ writeText(protyle.lute.BlockDOM2StdMd(html).trimEnd());
+ }
}
if (isNotEditBlock(nodeElement) && matchHotKey("⌘X", event)) {