Vanessa 2023-09-28 00:08:16 +08:00
parent 9c416cbcea
commit f26003f381
3 changed files with 40 additions and 39 deletions

View file

@ -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)";

View file

@ -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");

View file

@ -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");