From f26003f3813d07b21a8e0a83910c9123f7db4e45 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Thu, 28 Sep 2023 00:08:16 +0800 Subject: [PATCH] :art: https://github.com/siyuan-note/siyuan/issues/9294 --- app/src/protyle/render/av/action.ts | 39 ++--------------------------- app/src/protyle/render/av/addCol.ts | 2 +- app/src/protyle/render/av/col.ts | 38 +++++++++++++++++++++++++++- 3 files changed, 40 insertions(+), 39 deletions(-) diff --git a/app/src/protyle/render/av/action.ts b/app/src/protyle/render/av/action.ts index bd363c880..11612b110 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 = `
-
- - ${options.name} -
-
-
`; - } else { - html = '
'; - } - 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 84d6bbd0b..371e0c9cc 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 8e56b93de..9763ea467 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 = `
+
+ + ${options.name} +
+
+
`; + } else { + html = '
'; + } + 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");