mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-20 22:14:06 +01:00
🎨 delete row by keydown
This commit is contained in:
parent
a104c94c5f
commit
ff0973029d
3 changed files with 40 additions and 32 deletions
|
|
@ -225,3 +225,32 @@ export const setPageSize = (options: {
|
|||
y: rect.bottom
|
||||
});
|
||||
};
|
||||
|
||||
export const deleteRow = (blockElement: HTMLElement, protyle: IProtyle) => {
|
||||
const avID = blockElement.getAttribute("data-av-id");
|
||||
const undoOperations: IOperation[] = [];
|
||||
const rowElements = blockElement.querySelectorAll(".av__row--select:not(.av__row--header)");
|
||||
const blockIds:string[] = [];
|
||||
rowElements.forEach(item => {
|
||||
blockIds.push(item.querySelector(".av__cell[data-block-id]").getAttribute("data-block-id"));
|
||||
});
|
||||
rowElements.forEach(item => {
|
||||
undoOperations.push({
|
||||
action: "insertAttrViewBlock",
|
||||
avID,
|
||||
previousID: item.previousElementSibling?.getAttribute("data-id") || "",
|
||||
srcIDs: [item.getAttribute("data-id")],
|
||||
isDetached: item.querySelector('.av__cell[data-detached="true"]') ? true : false,
|
||||
});
|
||||
});
|
||||
transaction(protyle, [{
|
||||
action: "removeAttrViewBlock",
|
||||
srcIDs: blockIds,
|
||||
avID,
|
||||
}], undoOperations);
|
||||
rowElements.forEach(item => {
|
||||
item.remove();
|
||||
});
|
||||
stickyRow(blockElement, protyle.contentElement.getBoundingClientRect(), "all");
|
||||
updateHeader(blockElement.querySelector(".av__row"));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue