mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-16 00:50:56 +08:00
This commit is contained in:
parent
737839f6bb
commit
ecf7e4a561
@ -231,7 +231,7 @@ export class Gutter {
|
|||||||
srcIDs,
|
srcIDs,
|
||||||
avID,
|
avID,
|
||||||
}]);
|
}]);
|
||||||
insertAttrViewBlockAnimation(blockElement, srcIDs, previousID, avID);
|
insertAttrViewBlockAnimation(protyle, blockElement, srcIDs, previousID, avID);
|
||||||
} else {
|
} else {
|
||||||
avContextmenu(protyle, rowElement as HTMLElement, {
|
avContextmenu(protyle, rowElement as HTMLElement, {
|
||||||
x: gutterRect.left,
|
x: gutterRect.left,
|
||||||
|
@ -85,7 +85,7 @@ export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLEle
|
|||||||
srcIDs,
|
srcIDs,
|
||||||
avID,
|
avID,
|
||||||
}]);
|
}]);
|
||||||
insertAttrViewBlockAnimation(blockElement, srcIDs, undefined, avID);
|
insertAttrViewBlockAnimation(protyle, blockElement, srcIDs, undefined, avID);
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
return true;
|
return true;
|
||||||
@ -155,7 +155,7 @@ export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLEle
|
|||||||
srcIDs,
|
srcIDs,
|
||||||
avID,
|
avID,
|
||||||
}]);
|
}]);
|
||||||
insertAttrViewBlockAnimation(blockElement, srcIDs, previousID, avID);
|
insertAttrViewBlockAnimation(protyle, blockElement, srcIDs, previousID, avID);
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
return true;
|
return true;
|
||||||
|
@ -291,17 +291,12 @@ export const refreshAV = (protyle: IProtyle, operation: IOperation, isUndo: bool
|
|||||||
} else {
|
} else {
|
||||||
Array.from(protyle.wysiwyg.element.querySelectorAll(`[data-av-id="${operation.avID}"]`)).forEach((item: HTMLElement) => {
|
Array.from(protyle.wysiwyg.element.querySelectorAll(`[data-av-id="${operation.avID}"]`)).forEach((item: HTMLElement) => {
|
||||||
item.removeAttribute("data-render");
|
item.removeAttribute("data-render");
|
||||||
const isCurrent = item.querySelector(".av__pulse"); // ctrl+D 后点击添加行
|
|
||||||
avRender(item, protyle, () => {
|
avRender(item, protyle, () => {
|
||||||
if (operation.action === "insertAttrViewBlock") {
|
if (operation.action === "insertAttrViewBlock") {
|
||||||
item.querySelectorAll(".av__cell--select").forEach((cellElement: HTMLElement) => {
|
item.querySelectorAll(".av__cell--select").forEach((cellElement: HTMLElement) => {
|
||||||
cellElement.classList.remove("av__cell--select");
|
cellElement.classList.remove("av__cell--select");
|
||||||
});
|
});
|
||||||
// https://github.com/siyuan-note/siyuan/issues/9599
|
} else if (operation.action === "addAttrViewCol" && item.querySelector(".av__pulse")) {
|
||||||
if (!isUndo && operation.isDetached && isCurrent) {
|
|
||||||
popTextCell(protyle, [item.querySelector(`.av__row[data-id="${operation.srcIDs[0]}"] .av__cell[data-detached="true"]`)], "block");
|
|
||||||
}
|
|
||||||
} else if (operation.action === "addAttrViewCol" && isCurrent) {
|
|
||||||
openMenuPanel({protyle, blockElement: item, type: "edit", colId: operation.id});
|
openMenuPanel({protyle, blockElement: item, type: "edit", colId: operation.id});
|
||||||
}
|
}
|
||||||
}, ["addAttrViewView", "duplicateAttrViewView"].includes(operation.action) ? operation.id :
|
}, ["addAttrViewView", "duplicateAttrViewView"].includes(operation.action) ? operation.id :
|
||||||
|
@ -2,6 +2,7 @@ import {hasClosestBlock, hasClosestByClassName} from "../../util/hasClosest";
|
|||||||
import {focusBlock} from "../../util/selection";
|
import {focusBlock} from "../../util/selection";
|
||||||
import {Menu} from "../../../plugin/Menu";
|
import {Menu} from "../../../plugin/Menu";
|
||||||
import {transaction} from "../../wysiwyg/transaction";
|
import {transaction} from "../../wysiwyg/transaction";
|
||||||
|
import {popTextCell} from "./cell";
|
||||||
|
|
||||||
export const selectRow = (checkElement: Element, type: "toggle" | "select" | "unselect" | "unselectAll") => {
|
export const selectRow = (checkElement: Element, type: "toggle" | "select" | "unselect" | "unselectAll") => {
|
||||||
const rowElement = hasClosestByClassName(checkElement, "av__row");
|
const rowElement = hasClosestByClassName(checkElement, "av__row");
|
||||||
@ -69,15 +70,15 @@ export const updateHeader = (rowElement: HTMLElement) => {
|
|||||||
avHeadElement.style.position = "sticky";
|
avHeadElement.style.position = "sticky";
|
||||||
};
|
};
|
||||||
|
|
||||||
export const insertAttrViewBlockAnimation = (blockElement: Element, srcIDs: string[], previousId: string, avId?: string,) => {
|
export const insertAttrViewBlockAnimation = (protyle: IProtyle, blockElement: Element, srcIDs: string[], previousId: string, avId?: string,) => {
|
||||||
const previousElement = blockElement.querySelector(`.av__row[data-id="${previousId}"]`) || blockElement.querySelector(".av__row--header");
|
const previousElement = blockElement.querySelector(`.av__row[data-id="${previousId}"]`) || blockElement.querySelector(".av__row--header");
|
||||||
let colHTML = '<div style="width: 24px"></div>';
|
let colHTML = '<div class="av__firstcol av__colsticky"><svg><use xlink:href="#iconUncheck"></use></svg></div>';
|
||||||
const pinIndex = previousElement.querySelectorAll(".av__colsticky .av__cell").length - 1;
|
const pinIndex = previousElement.querySelectorAll(".av__colsticky .av__cell").length - 1;
|
||||||
if (pinIndex > -1) {
|
if (pinIndex > -1) {
|
||||||
colHTML = '<div class="av__colsticky"><div style="width: 24px"></div>';
|
colHTML = '<div class="av__colsticky"><div class="av__firstcol av__colsticky"><svg><use xlink:href="#iconUncheck"></use></svg></div>';
|
||||||
}
|
}
|
||||||
previousElement.querySelectorAll(".av__cell").forEach((item: HTMLElement, index) => {
|
previousElement.querySelectorAll(".av__cell").forEach((item: HTMLElement, index) => {
|
||||||
colHTML += `<div class="av__cell" style="width: ${item.style.width}" ${(item.getAttribute("data-block-id") || item.dataset.dtype === "block") ? ' data-detached="true"' : ""}><span class="av__pulse"></span></div>`;
|
colHTML += `<div class="av__cell" data-col-id="${item.dataset.colId}" style="width: ${item.style.width}" ${(item.getAttribute("data-block-id") || item.dataset.dtype === "block") ? ' data-detached="true"' : ""}><span class="${avId ? "av__celltext" : "av__pulse"}"></span></div>`;
|
||||||
if (pinIndex === index) {
|
if (pinIndex === index) {
|
||||||
colHTML += "</div>";
|
colHTML += "</div>";
|
||||||
}
|
}
|
||||||
@ -90,6 +91,9 @@ export const insertAttrViewBlockAnimation = (blockElement: Element, srcIDs: stri
|
|||||||
</div>`;
|
</div>`;
|
||||||
});
|
});
|
||||||
previousElement.insertAdjacentHTML("afterend", html);
|
previousElement.insertAdjacentHTML("afterend", html);
|
||||||
|
if (avId) {
|
||||||
|
popTextCell(protyle, [previousElement.nextElementSibling.querySelector('.av__cell[data-detached="true"]')], "block");
|
||||||
|
}
|
||||||
const pageSize = parseInt(blockElement.getAttribute("data-page-size"));
|
const pageSize = parseInt(blockElement.getAttribute("data-page-size"));
|
||||||
if (pageSize) {
|
if (pageSize) {
|
||||||
const currentCount = blockElement.querySelectorAll(".av__row:not(.av__row--header)").length;
|
const currentCount = blockElement.querySelectorAll(".av__row:not(.av__row--header)").length;
|
||||||
@ -230,7 +234,7 @@ export const deleteRow = (blockElement: HTMLElement, protyle: IProtyle) => {
|
|||||||
const avID = blockElement.getAttribute("data-av-id");
|
const avID = blockElement.getAttribute("data-av-id");
|
||||||
const undoOperations: IOperation[] = [];
|
const undoOperations: IOperation[] = [];
|
||||||
const rowElements = blockElement.querySelectorAll(".av__row--select:not(.av__row--header)");
|
const rowElements = blockElement.querySelectorAll(".av__row--select:not(.av__row--header)");
|
||||||
const blockIds:string[] = [];
|
const blockIds: string[] = [];
|
||||||
rowElements.forEach(item => {
|
rowElements.forEach(item => {
|
||||||
blockIds.push(item.querySelector(".av__cell[data-block-id]").getAttribute("data-block-id"));
|
blockIds.push(item.querySelector(".av__cell[data-block-id]").getAttribute("data-block-id"));
|
||||||
});
|
});
|
||||||
|
@ -897,7 +897,7 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
|
|||||||
srcIDs: sourceIds,
|
srcIDs: sourceIds,
|
||||||
avID,
|
avID,
|
||||||
}]);
|
}]);
|
||||||
insertAttrViewBlockAnimation(blockElement, sourceIds, previousID);
|
insertAttrViewBlockAnimation(protyle, blockElement, sourceIds, previousID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (sourceElements.length > 0) {
|
} else if (sourceElements.length > 0) {
|
||||||
@ -957,7 +957,7 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
|
|||||||
srcIDs: ids,
|
srcIDs: ids,
|
||||||
avID,
|
avID,
|
||||||
}]);
|
}]);
|
||||||
insertAttrViewBlockAnimation(blockElement, ids, previousID);
|
insertAttrViewBlockAnimation(protyle, blockElement, ids, previousID);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (let i = 0; i < ids.length; i++) {
|
for (let i = 0; i < ids.length; i++) {
|
||||||
|
Loading…
Reference in New Issue
Block a user