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/13062

Vanessabda97eaef5b1
diff --git a/app/src/protyle/render/av/action.ts b/app/src/protyle/render/av/action.ts
index ac70a2d761..737c99c642 100644
--- a/app/src/protyle/render/av/action.ts
+++ b/app/src/protyle/render/av/action.ts
@@ -33,6 +33,7 @@ import {Constants} from "../../../constants";
import {hideElements} from "../../ui/hideElements";
import {fetchPost, fetchSyncPost} from "../../../util/fetch";
import {scrollCenter} from "../../../util/highlightById";
+import {escapeHtml} from "../../../util/escape";
export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLElement }) => {
if (isOnlyMeta(event)) {
@@ -288,17 +289,31 @@ export const avContextmenu = (protyle: IProtyle, rowElement: HTMLElement, positi
});
/// #endif
}
- let copyMenu: IMenu[] = [];
- if (rowElements.length === 1 && keyCellElement.getAttribute("data-detached") === "true") {
- copyMenu.push({
- iconHTML: "",
- label: window.siyuan.languages["_attrView"].key,
- click() {
- writeText(rowElements[0].querySelector('.av__cell[data-dtype="block"] .av__celltext').textContent);
- }
- });
- } else {
- copyMenu = [{
+ let hasBlock = false
+ rowElements.forEach((item, i) => {
+ if (item.querySelector('.av__cell[data-dtype="block"]').getAttribute("data-detached") !== "true") {
+ hasBlock = true
+ }
+ })
+ const copyMenu: IMenu[] = [{
+ iconHTML: "",
+ label: window.siyuan.languages.keyContent,
+ click() {
+ let text = ""
+ rowElements.forEach((item, i) => {
+ if (rowElements.length > 1) {
+ text += "* ";
+ }
+ text += item.querySelector('.av__cell[data-dtype="block"] .av__celltext').textContent.trim();
+ if (ids.length > 1 && i !== ids.length - 1) {
+ text += "\n";
+ }
+ })
+ writeText(text);
+ }
+ }];
+ if (hasBlock) {
+ copyMenu.splice(1, 0, {
id: "copyBlockRef",
iconHTML: "",
label: window.siyuan.languages.copyBlockRef,
@@ -443,7 +458,7 @@ export const avContextmenu = (protyle: IProtyle, rowElement: HTMLElement, positi
});
writeText(text);
}
- }];
+ });
}
menu.addItem({
@@ -572,7 +587,7 @@ ${window.siyuan.languages.insertRowAfter.replace("${x}", '<span class="fn__space
const icon = cellElement.dataset.icon;
editAttrSubmenu.push({
iconHTML: icon ? unicode2Emoji(icon, "b3-menu__icon", true) : `<svg class="b3-menu__icon"><use xlink:href="#${getColIconByType(type)}"></use></svg>`,
- label: cellElement.querySelector(".av__celltext").textContent.trim(),
+ label: escapeHtml(cellElement.querySelector(".av__celltext").textContent.trim()),
click() {
popTextCell(protyle, selectElements);
}
diff --git a/app/src/protyle/render/av/openMenuPanel.ts b/app/src/protyle/render/av/openMenuPanel.ts
index 5fd5385d5b..96f5f396b8 100644
--- a/app/src/protyle/render/av/openMenuPanel.ts
+++ b/app/src/protyle/render/av/openMenuPanel.ts
@@ -28,7 +28,7 @@ import {bindRelationEvent, getRelationHTML, openSearchAV, setRelationCell, updat
import {bindRollupData, getRollupHTML, goSearchRollupCol} from "./rollup";
import {updateCellsValue} from "./cell";
import {openCalcMenu} from "./calc";
-import {escapeAttr} from "../../../util/escape";
+import {escapeAttr, escapeHtml} from "../../../util/escape";
import {Dialog} from "../../../dialog";
export const openMenuPanel = (options: {
@@ -1336,7 +1336,7 @@ export const getPropertiesHTML = (data: IAVTable) => {
<svg class="b3-menu__icon fn__grab"><use xlink:href="#iconDrag"></use></svg>
<div class="b3-menu__label fn__flex">
${item.icon ? unicode2Emoji(item.icon, "b3-menu__icon", true) : `<svg class="b3-menu__icon"><use xlink:href="#${getColIconByType(item.type)}"></use></svg>`}
- ${item.name || "&nbsp;"}
+ ${escapeHtml(item.name) || "&nbsp;"}
</div>
<svg class="b3-menu__action" data-type="showCol"><use xlink:href="#iconEye"></use></svg>
<svg class="b3-menu__icon b3-menu__icon--small"><use xlink:href="#iconRight"></use></svg>
@@ -1346,7 +1346,7 @@ export const getPropertiesHTML = (data: IAVTable) => {
<svg class="b3-menu__icon fn__grab"><use xlink:href="#iconDrag"></use></svg>
<div class="b3-menu__label fn__flex">
${item.icon ? unicode2Emoji(item.icon, "b3-menu__icon", true) : `<svg class="b3-menu__icon"><use xlink:href="#${getColIconByType(item.type)}"></use></svg>`}
- ${item.name || "&nbsp;"}
+ ${escapeHtml(item.name) || "&nbsp;"}
</div>
<svg class="b3-menu__action${item.type === "block" ? " fn__none" : ""}" data-type="hideCol"><use xlink:href="#iconEyeoff"></use></svg>
<svg class="b3-menu__icon b3-menu__icon--small"><use xlink:href="#iconRight"></use></svg>