mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-19 16:10:12 +01:00
This commit is contained in:
parent
48c64f98f4
commit
6d7637850a
7 changed files with 74 additions and 30 deletions
|
|
@ -279,6 +279,7 @@ export class Gutter {
|
|||
content: ""
|
||||
}],
|
||||
blockID: id,
|
||||
groupID: rowElement.parentElement.getAttribute("data-group-id"),
|
||||
}, {
|
||||
action: "doUpdateUpdated",
|
||||
id,
|
||||
|
|
|
|||
|
|
@ -157,7 +157,7 @@ export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLEle
|
|||
event.stopPropagation();
|
||||
return true;
|
||||
} else if (type === "av-add-more") {
|
||||
insertRows(blockElement, protyle, 1, undefined);
|
||||
insertRows({blockElement, protyle, count: 1, previousID: ""});
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
return true;
|
||||
|
|
@ -210,10 +210,14 @@ export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLEle
|
|||
event.stopPropagation();
|
||||
return true;
|
||||
} else if (type === "av-add-bottom") {
|
||||
insertRows(blockElement, protyle, 1,
|
||||
blockElement.querySelector(".av__row--util")?.previousElementSibling?.getAttribute("data-id") ||
|
||||
target.previousElementSibling?.getAttribute("data-id") || undefined
|
||||
);
|
||||
const bodyElement = hasClosestByClassName(target, "av__body");
|
||||
insertRows({
|
||||
blockElement, protyle,
|
||||
count: 1,
|
||||
previousID: blockElement.querySelector(".av__row--util")?.previousElementSibling?.getAttribute("data-id") ||
|
||||
target.previousElementSibling?.getAttribute("data-id") || undefined,
|
||||
groupID: bodyElement ? bodyElement.getAttribute("data-group-id") : ""
|
||||
});
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
return true;
|
||||
|
|
@ -582,7 +586,8 @@ export const avContextmenu = (protyle: IProtyle, rowElement: HTMLElement, positi
|
|||
avID,
|
||||
ignoreFillFilter: true,
|
||||
srcs,
|
||||
blockID: listItemElement.dataset.blockId
|
||||
blockID: listItemElement.dataset.blockId,
|
||||
groupID: rowElement.parentElement.getAttribute("data-group-id")
|
||||
}, {
|
||||
action: "doUpdateUpdated",
|
||||
id: listItemElement.dataset.blockId,
|
||||
|
|
@ -611,12 +616,24 @@ ${window.siyuan.languages[avType === "table" ? "insertRowBefore" : "insertItemBe
|
|||
if (document.activeElement === inputElement) {
|
||||
return;
|
||||
}
|
||||
insertRows(blockElement, protyle, parseInt(inputElement.value), rowElements[0].previousElementSibling.getAttribute("data-id"));
|
||||
insertRows({
|
||||
blockElement,
|
||||
protyle,
|
||||
count: parseInt(inputElement.value),
|
||||
previousID: rowElements[0].previousElementSibling.getAttribute("data-id"),
|
||||
groupID: rowElements[0].parentElement.getAttribute("data-group-id")
|
||||
});
|
||||
menu.close();
|
||||
});
|
||||
inputElement.addEventListener("keydown", (event: KeyboardEvent) => {
|
||||
if (!event.isComposing && event.key === "Enter") {
|
||||
insertRows(blockElement, protyle, parseInt(inputElement.value), rowElements[0].previousElementSibling.getAttribute("data-id"));
|
||||
insertRows({
|
||||
blockElement,
|
||||
protyle,
|
||||
count: parseInt(inputElement.value),
|
||||
previousID: rowElements[0].previousElementSibling.getAttribute("data-id"),
|
||||
groupID: rowElements[0].parentElement.getAttribute("data-group-id")
|
||||
});
|
||||
menu.close();
|
||||
}
|
||||
});
|
||||
|
|
@ -634,12 +651,24 @@ ${window.siyuan.languages[avType === "table" ? "insertRowAfter" : "insertItemAft
|
|||
if (document.activeElement === inputElement) {
|
||||
return;
|
||||
}
|
||||
insertRows(blockElement, protyle, parseInt(inputElement.value), rowElements[0].getAttribute("data-id"));
|
||||
insertRows({
|
||||
blockElement,
|
||||
protyle,
|
||||
count: parseInt(inputElement.value),
|
||||
previousID: rowElements[0].getAttribute("data-id"),
|
||||
groupID: rowElements[0].parentElement.getAttribute("data-group-id")
|
||||
});
|
||||
menu.close();
|
||||
});
|
||||
inputElement.addEventListener("keydown", (event: KeyboardEvent) => {
|
||||
if (!event.isComposing && event.key === "Enter") {
|
||||
insertRows(blockElement, protyle, parseInt(inputElement.value), rowElements[0].getAttribute("data-id"));
|
||||
insertRows({
|
||||
blockElement,
|
||||
protyle,
|
||||
count: parseInt(inputElement.value),
|
||||
previousID: rowElements[0].getAttribute("data-id"),
|
||||
groupID: rowElements[0].parentElement.getAttribute("data-group-id")
|
||||
});
|
||||
menu.close();
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -420,6 +420,7 @@ draggable="true">${genSelectItemHTML("selected", targetId, !target.querySelector
|
|||
const blockID = target.querySelector(".popover__block").getAttribute("data-id");
|
||||
const content = target.querySelector("b").textContent;
|
||||
const rowId = Lute.NewNodeID();
|
||||
const bodyElement = hasClosestByClassName(cellElements[0], "av__body");
|
||||
transaction(protyle, [{
|
||||
action: "insertAttrViewBlock",
|
||||
ignoreFillFilter: true,
|
||||
|
|
@ -430,6 +431,7 @@ draggable="true">${genSelectItemHTML("selected", targetId, !target.querySelector
|
|||
content
|
||||
}],
|
||||
blockID,
|
||||
groupID: bodyElement ? bodyElement.getAttribute("data-group-id") : "",
|
||||
}, {
|
||||
action: "doUpdateUpdated",
|
||||
id: blockID,
|
||||
|
|
|
|||
|
|
@ -239,7 +239,7 @@ const renderGroupTable = (options: ITableOptions) => {
|
|||
<svg class="${group.groupFolded ? "" : "av__group-arrow--open"}"><use xlink:href="#iconRight"></use></svg>
|
||||
</div><span class="fn__space"></span>${group.name}<span class="${group.rows.length === 0 ? "fn__none" : "counter"}">${group.rows.length}</span>
|
||||
</div>
|
||||
<div class="av__body${group.groupFolded ? " fn__none" : ""}">${getTableHTMLs(group, options.blockElement).contentHTML}</div>`;
|
||||
<div data-group-id="${group.id}" class="av__body${group.groupFolded ? " fn__none" : ""}">${getTableHTMLs(group, options.blockElement).contentHTML}</div>`;
|
||||
}
|
||||
});
|
||||
if (options.renderAll) {
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ export const updateHeader = (rowElement: HTMLElement) => {
|
|||
}
|
||||
|
||||
const counterElement = blockElement.querySelector(".av__counter");
|
||||
const allCount = blockElement.querySelectorAll(".av__row--select:not(.av__row--header)").length
|
||||
const allCount = blockElement.querySelectorAll(".av__row--select:not(.av__row--header)").length;
|
||||
if (allCount === 0) {
|
||||
counterElement.classList.add("fn__none");
|
||||
return;
|
||||
|
|
@ -432,7 +432,8 @@ export const deleteRow = (blockElement: HTMLElement, protyle: IProtyle) => {
|
|||
isDetached: blockValue.isDetached,
|
||||
content: blockValue.block.content
|
||||
}],
|
||||
blockID: blockElement.dataset.nodeId
|
||||
blockID: blockElement.dataset.nodeId,
|
||||
groupID: item.parentElement.getAttribute("data-group-id")
|
||||
});
|
||||
});
|
||||
const newUpdated = dayjs().format("YYYYMMDDHHmmss");
|
||||
|
|
@ -458,11 +459,17 @@ export const deleteRow = (blockElement: HTMLElement, protyle: IProtyle) => {
|
|||
blockElement.setAttribute("updated", newUpdated);
|
||||
};
|
||||
|
||||
export const insertRows = (blockElement: HTMLElement, protyle: IProtyle, count: number, previousID: string) => {
|
||||
const avID = blockElement.getAttribute("data-av-id");
|
||||
export const insertRows = (options: {
|
||||
blockElement: HTMLElement,
|
||||
protyle: IProtyle,
|
||||
count: number,
|
||||
previousID: string,
|
||||
groupID?: string
|
||||
}) => {
|
||||
const avID = options.blockElement.getAttribute("data-av-id");
|
||||
const srcIDs: string[] = [];
|
||||
const srcs: IOperationSrcs[] = [];
|
||||
new Array(count).fill(0).forEach(() => {
|
||||
new Array(options.count).fill(0).forEach(() => {
|
||||
const newNodeID = Lute.NewNodeID();
|
||||
srcIDs.push(newNodeID);
|
||||
srcs.push({
|
||||
|
|
@ -472,15 +479,16 @@ export const insertRows = (blockElement: HTMLElement, protyle: IProtyle, count:
|
|||
});
|
||||
});
|
||||
const newUpdated = dayjs().format("YYYYMMDDHHmmss");
|
||||
transaction(protyle, [{
|
||||
transaction(options.protyle, [{
|
||||
action: "insertAttrViewBlock",
|
||||
avID,
|
||||
previousID,
|
||||
previousID: options.previousID,
|
||||
srcs,
|
||||
blockID: blockElement.dataset.nodeId,
|
||||
blockID: options.blockElement.dataset.nodeId,
|
||||
groupID: options.groupID
|
||||
}, {
|
||||
action: "doUpdateUpdated",
|
||||
id: blockElement.dataset.nodeId,
|
||||
id: options.blockElement.dataset.nodeId,
|
||||
data: newUpdated,
|
||||
}], [{
|
||||
action: "removeAttrViewBlock",
|
||||
|
|
@ -488,18 +496,18 @@ export const insertRows = (blockElement: HTMLElement, protyle: IProtyle, count:
|
|||
avID,
|
||||
}, {
|
||||
action: "doUpdateUpdated",
|
||||
id: blockElement.dataset.nodeId,
|
||||
data: blockElement.getAttribute("updated")
|
||||
id: options.blockElement.dataset.nodeId,
|
||||
data: options.blockElement.getAttribute("updated")
|
||||
}]);
|
||||
if (blockElement.getAttribute("data-av-type") === "gallery") {
|
||||
if (options.blockElement.getAttribute("data-av-type") === "gallery") {
|
||||
insertGalleryItemAnimation({
|
||||
blockElement,
|
||||
protyle,
|
||||
blockElement: options.blockElement,
|
||||
protyle: options.protyle,
|
||||
srcIDs,
|
||||
previousId: previousID
|
||||
previousId: options.previousID
|
||||
});
|
||||
} else {
|
||||
insertAttrViewBlockAnimation(protyle, blockElement, srcIDs, previousID, avID);
|
||||
insertAttrViewBlockAnimation(options.protyle, options.blockElement, srcIDs, options.previousID, avID);
|
||||
}
|
||||
blockElement.setAttribute("updated", newUpdated);
|
||||
options.blockElement.setAttribute("updated", newUpdated);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1109,7 +1109,8 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
|
|||
avID,
|
||||
previousID,
|
||||
srcs,
|
||||
blockID: blockElement.dataset.nodeId
|
||||
blockID: blockElement.dataset.nodeId,
|
||||
groupID: targetElement.parentElement.getAttribute("data-group-id")
|
||||
}, {
|
||||
action: "doUpdateUpdated",
|
||||
id: blockElement.dataset.nodeId,
|
||||
|
|
@ -1169,7 +1170,8 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
|
|||
avID,
|
||||
previousID,
|
||||
srcs,
|
||||
blockID: blockElement.dataset.nodeId
|
||||
blockID: blockElement.dataset.nodeId,
|
||||
groupID: targetElement.parentElement.getAttribute("data-group-id")
|
||||
}, {
|
||||
action: "doUpdateUpdated",
|
||||
id: blockElement.dataset.nodeId,
|
||||
|
|
@ -1290,6 +1292,7 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
|
|||
previousID,
|
||||
srcs,
|
||||
blockID: blockElement.dataset.nodeId,
|
||||
groupID: targetElement.parentElement.getAttribute("data-group-id")
|
||||
}, {
|
||||
action: "doUpdateUpdated",
|
||||
id: blockElement.dataset.nodeId,
|
||||
|
|
|
|||
1
app/src/types/index.d.ts
vendored
1
app/src/types/index.d.ts
vendored
|
|
@ -552,6 +552,7 @@ interface IOperation {
|
|||
blockIDs?: string[] // add/removeFlashcards 专享
|
||||
removeDest?: boolean // removeAttrViewCol 专享
|
||||
layout?: string // addAttrViewView 专享
|
||||
groupID?: string // insertAttrViewBlock 专享
|
||||
}
|
||||
|
||||
interface IOperationSrcs {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue