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

Vanessaf26003f3813d
diff --git a/app/src/protyle/render/av/action.ts b/app/src/protyle/render/av/action.ts
index bd363c8809..11612b110c 100644
--- a/app/src/protyle/render/av/action.ts
+++ b/app/src/protyle/render/av/action.ts
@@ -161,7 +161,8 @@ export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLEle
notebook: protyle.notebookId,
path: pathPosix().join(response.data, createDocElement.previousElementSibling.textContent.trim() || "Untitled"),
parentID: protyle.block.rootID,
- markdown: ""
+ markdown: "",
+ id: createDocElement.parentElement.dataset.id,
}, response => {
transaction(protyle, [{
action: "updateAttrViewCell",
@@ -347,42 +348,6 @@ export const updateAVName = (protyle: IProtyle, blockElement: Element) => {
nameElement.dataset.title = nameElement.textContent.trim();
};
-export const addAttrViewColAnimation = (options: {
- blockElement: Element,
- protyle: IProtyle,
- type: TAVCol,
- name: string,
- previousId?: string,
- id: string
-}) => {
- if (!options.blockElement) {
- return;
- }
- options.blockElement.querySelectorAll(".av__row").forEach((item, index) => {
- let previousElement;
- if (options.previousId) {
- previousElement = item.querySelector(`[data-col-id="${options.previousId}"]`);
- } else {
- previousElement = item.lastElementChild.previousElementSibling;
- }
- let html = "";
- if (index === 0) {
- html = `<div class="av__cell" data-col-id="${options.id}" data-dtype="${options.type}" style="width: 200px;white-space: nowrap;">
- <div draggable="true" class="av__cellheader">
- <svg><use xlink:href="#${getColIconByType(options.type)}"></use></svg>
- <span class="av__celltext">${options.name}</span>
- </div>
- <div class="av__widthdrag"></div>
-</div>`;
- } else {
- html = '<div class="av__cell" style="width: 200px"></div>';
- }
- previousElement.insertAdjacentHTML("afterend", html);
- });
- window.siyuan.menus.menu.remove();
- showColMenu(options.protyle, options.blockElement, options.blockElement.querySelector(`.av__row--header .av__cell[data-col-id="${options.id}"]`));
-};
-
export const updateAttrViewCellAnimation = (cellElement: HTMLElement) => {
cellElement.style.opacity = "0.38";
cellElement.style.backgroundColor = "var(--b3-theme-surface-light)";
diff --git a/app/src/protyle/render/av/addCol.ts b/app/src/protyle/render/av/addCol.ts
index 84d6bbd0bc..371e0c9ccc 100644
--- a/app/src/protyle/render/av/addCol.ts
+++ b/app/src/protyle/render/av/addCol.ts
@@ -1,6 +1,6 @@
import {Menu} from "../../../plugin/Menu";
import {transaction} from "../../wysiwyg/transaction";
-import {addAttrViewColAnimation} from "./action";
+import {addAttrViewColAnimation} from "./col";
export const addCol = (protyle: IProtyle, blockElement: Element) => {
const menu = new Menu("av-header-add");
diff --git a/app/src/protyle/render/av/col.ts b/app/src/protyle/render/av/col.ts
index 8e56b93de6..9763ea4679 100644
--- a/app/src/protyle/render/av/col.ts
+++ b/app/src/protyle/render/av/col.ts
@@ -6,7 +6,7 @@ import {getDefaultOperatorByType, setFilter} from "./filter";
import {genCellValue} from "./cell";
import {openMenuPanel} from "./openMenuPanel";
import {getLabelByNumberFormat} from "./number";
-import {addAttrViewColAnimation, removeAttrViewColAnimation} from "./action";
+import {removeAttrViewColAnimation} from "./action";
export const duplicateCol = (options: {
protyle: IProtyle,
@@ -284,6 +284,42 @@ export const updateHeader = (rowElement: HTMLElement) => {
avHeadElement.style.position = "sticky";
};
+export const addAttrViewColAnimation = (options: {
+ blockElement: Element,
+ protyle: IProtyle,
+ type: TAVCol,
+ name: string,
+ previousId?: string,
+ id: string
+}) => {
+ if (!options.blockElement) {
+ return;
+ }
+ options.blockElement.querySelectorAll(".av__row").forEach((item, index) => {
+ let previousElement;
+ if (options.previousId) {
+ previousElement = item.querySelector(`[data-col-id="${options.previousId}"]`);
+ } else {
+ previousElement = item.lastElementChild.previousElementSibling;
+ }
+ let html = "";
+ if (index === 0) {
+ html = `<div class="av__cell" data-col-id="${options.id}" data-dtype="${options.type}" style="width: 200px;white-space: nowrap;">
+ <div draggable="true" class="av__cellheader">
+ <svg><use xlink:href="#${getColIconByType(options.type)}"></use></svg>
+ <span class="av__celltext">${options.name}</span>
+ </div>
+ <div class="av__widthdrag"></div>
+</div>`;
+ } else {
+ html = '<div class="av__cell" style="width: 200px"></div>';
+ }
+ previousElement.insertAdjacentHTML("afterend", html);
+ });
+ window.siyuan.menus.menu.remove();
+ showColMenu(options.protyle, options.blockElement, options.blockElement.querySelector(`.av__row--header .av__cell[data-col-id="${options.id}"]`));
+};
+
export const showColMenu = (protyle: IProtyle, blockElement: Element, cellElement: HTMLElement) => {
const type = cellElement.getAttribute("data-dtype") as TAVCol;
const colId = cellElement.getAttribute("data-col-id");