An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: https://github.com/siyuan-note/siyuan/issues/10264
Vanessa76ac9912dc03
diff --git a/app/src/protyle/render/av/cell.ts b/app/src/protyle/render/av/cell.tsindex 21d74da031..b7d9d81552 100644--- a/app/src/protyle/render/av/cell.ts+++ b/app/src/protyle/render/av/cell.ts@@ -76,6 +76,9 @@ export const genCellValueByElement = (colType: TAVCol, cellElement: HTMLElement)} else if (colType === "mAsset") {const mAsset: IAVCellAssetValue[] = [];Array.from(cellElement.children).forEach((item) => {+ if (item.classList.contains("av__drag-fill")) {+ return;+ }const isImg = item.classList.contains("av__cellassetimg");mAsset.push({type: isImg ? "image" : "file",@@ -420,11 +423,12 @@ export const updateCellsValue = (protyle: IProtyle, nodeElement: HTMLElement, vaconst avID = nodeElement.dataset.avId;const id = nodeElement.dataset.nodeId;let text = "";+ const json: IAVCellValue[] = [];let cellElements: Element[];if (cElements?.length > 0) {cellElements = cElements;} else {- cellElements = Array.from(nodeElement.querySelectorAll(".av__cell--select"));+ cellElements = Array.from(nodeElement.querySelectorAll(".av__cell--active, .av__cell--select"));if (cellElements.length === 0) {nodeElement.querySelectorAll(".av__row--select:not(.av__row--header)").forEach(rowElement => {rowElement.querySelectorAll(".av__cell").forEach(cellElement => {@@ -451,8 +455,9 @@ export const updateCellsValue = (protyle: IProtyle, nodeElement: HTMLElement, vaconst cellId = item.getAttribute("data-id");const colId = item.getAttribute("data-col-id");- text += getCellText(item);+ text += getCellText(item) + " ";const oldValue = genCellValueByElement(type, item);+ json.push(oldValue);// relation 为全部更新,以下类型为添加if (type === "mAsset") {if (Array.isArray(value)) {@@ -514,7 +519,7 @@ export const updateCellsValue = (protyle: IProtyle, nodeElement: HTMLElement, va});transaction(protyle, doOperations, undoOperations);}- return text;+ return {text: text.substring(0, text.length - 1), json};};export const renderCellAttr = (cellElement: Element, value: IAVCellValue) => {diff --git a/app/src/protyle/render/av/keydown.ts b/app/src/protyle/render/av/keydown.tsindex a9dee131ff..9bebe79dab 100644--- a/app/src/protyle/render/av/keydown.ts+++ b/app/src/protyle/render/av/keydown.ts@@ -23,10 +23,13 @@ export const avKeydown = (event: KeyboardEvent, nodeElement: HTMLElement, protylif (!rowElement) {return false;}- nodeElement.querySelectorAll(".av__cell--active").forEach(item => {- item.classList.remove("av__cell--active");- item.querySelector(".av__drag-fill")?.remove();- });+ // 复制、粘贴+ if (!event.ctrlKey && !event.metaKey) {+ nodeElement.querySelectorAll(".av__cell--active").forEach(item => {+ item.classList.remove("av__cell--active");+ item.querySelector(".av__drag-fill")?.remove();+ });+ }if (event.key === "Escape") {selectCellElement.classList.remove("av__cell--select");selectRow(rowElement.querySelector(".av__firstcol"), "select");diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.tsindex 7a40cdf469..5195b1980c 100644--- a/app/src/protyle/wysiwyg/index.ts+++ b/app/src/protyle/wysiwyg/index.ts@@ -294,7 +294,7 @@ export class WYSIWYG {});}} else if (selectAVElement) {- const cellElements: Element[] = Array.from(nodeElement.querySelectorAll(".av__cell--select")) || [];+ const cellElements: Element[] = Array.from(nodeElement.querySelectorAll(".av__cell--active, .av__cell--select")) || [];if (cellElements.length === 0) {nodeElement.querySelectorAll(".av__row--select:not(.av__row--header)").forEach(rowElement => {rowElement.querySelectorAll(".av__cell").forEach(cellElement => {@@ -302,11 +302,16 @@ export class WYSIWYG {});});}- cellElements.forEach((item: HTMLElement) => {- const cellText = getCellText(item);- html += cellText;- textPlain += cellText;- });+ if (cellElements.length > 0) {+ html = "[";+ cellElements.forEach((item: HTMLElement) => {+ const cellText = getCellText(item);+ html += JSON.stringify(genCellValueByElement(getTypeByCellElement(item), item)) + ",";+ textPlain += cellText + " ";+ });+ textPlain = textPlain.substring(0, textPlain.length - 1);+ html = html.substring(0, html.length - 1) + "]";+ }} else {const tempElement = document.createElement("div");// https://github.com/siyuan-note/siyuan/issues/5540@@ -369,7 +374,7 @@ export class WYSIWYG {textPlain = textPlain || protyle.lute.BlockDOM2StdMd(html).trimEnd();textPlain = textPlain.replace(/\u00A0/g, " "); // Replace non-breaking spaces with normal spaces when copying https://github.com/siyuan-note/siyuan/issues/9382event.clipboardData.setData("text/plain", textPlain);- event.clipboardData.setData("text/html", protyle.lute.BlockDOM2HTML(html));+ event.clipboardData.setData("text/html", selectAVElement ? html : protyle.lute.BlockDOM2HTML(html));event.clipboardData.setData("text/siyuan", html);});@@ -1269,6 +1274,7 @@ export class WYSIWYG {selectElements = [nodeElement];}let html = "";+ let textPlain = "";if (selectElements.length > 0) {if (selectElements[0].getAttribute("data-type") === "NodeListItem" &&selectElements[0].parentElement.classList.contains("list") && // 反链复制列表项 https://github.com/siyuan-note/siyuan/issues/6555@@ -1294,7 +1300,9 @@ export class WYSIWYG {focusBlock(nextElement);}} else if (selectAVElement) {- html = updateCellsValue(protyle, nodeElement);+ const cellsValue = updateCellsValue(protyle, nodeElement);+ html = JSON.stringify(cellsValue.json)+ textPlain = cellsValue.text;} else {const id = nodeElement.getAttribute("data-node-id");const oldHTML = nodeElement.outerHTML;@@ -1439,10 +1447,12 @@ export class WYSIWYG {}}protyle.hint.render(protyle);- let textPlain = protyle.lute.BlockDOM2StdMd(html).trimEnd(); // 需要 trimEnd,否则 \n 会导致 https://github.com/siyuan-note/siyuan/issues/6218+ if (!selectAVElement) {+ textPlain = protyle.lute.BlockDOM2StdMd(html).trimEnd(); // 需要 trimEnd,否则 \n 会导致 https://github.com/siyuan-note/siyuan/issues/6218+ }textPlain = textPlain.replace(/\u00A0/g, " "); // Replace non-breaking spaces with normal spaces when copying https://github.com/siyuan-note/siyuan/issues/9382event.clipboardData.setData("text/plain", textPlain);- event.clipboardData.setData("text/html", protyle.lute.BlockDOM2HTML(html));+ event.clipboardData.setData("text/html", selectAVElement ? html : protyle.lute.BlockDOM2HTML(html));event.clipboardData.setData("text/siyuan", html);});