mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-21 07:46:09 +01:00
🚨
This commit is contained in:
parent
bbb1abb7c6
commit
af35b8ba57
17 changed files with 37 additions and 43 deletions
|
|
@ -65,7 +65,7 @@ export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLEle
|
|||
|
||||
const gutterElement = hasClosestByClassName(event.target, "av__gutters");
|
||||
if (gutterElement) {
|
||||
const gutterRect = gutterElement.getBoundingClientRect()
|
||||
const gutterRect = gutterElement.getBoundingClientRect();
|
||||
avContextmenu(protyle, gutterElement.parentElement, {
|
||||
x: gutterRect.left,
|
||||
y: gutterRect.bottom,
|
||||
|
|
@ -262,7 +262,7 @@ export const avContextmenu = (protyle: IProtyle, rowElement: HTMLElement, positi
|
|||
icon: "iconTrashcan",
|
||||
label: window.siyuan.languages.delete,
|
||||
click() {
|
||||
const avID = blockElement.getAttribute("data-av-id")
|
||||
const avID = blockElement.getAttribute("data-av-id");
|
||||
const undoOperations: IOperation[] = [];
|
||||
rowElements.forEach(item => {
|
||||
undoOperations.push({
|
||||
|
|
@ -271,8 +271,8 @@ export const avContextmenu = (protyle: IProtyle, rowElement: HTMLElement, positi
|
|||
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,
|
||||
|
|
@ -349,7 +349,7 @@ export const updateAVName = (protyle: IProtyle, blockElement: Element) => {
|
|||
if (newData === nameElement.dataset.title.trim()) {
|
||||
return;
|
||||
}
|
||||
const newUpdated = dayjs().format("YYYYMMDDHHmmss")
|
||||
const newUpdated = dayjs().format("YYYYMMDDHHmmss");
|
||||
transaction(protyle, [{
|
||||
action: "setAttrViewName",
|
||||
id: avId,
|
||||
|
|
|
|||
|
|
@ -355,7 +355,7 @@ export const cellScrollIntoView = (blockElement: HTMLElement, cellRect: DOMRect,
|
|||
avScrollElement.scrollLeft = avScrollElement.scrollLeft + cellRect.right - avScrollRect.right;
|
||||
}
|
||||
}
|
||||
const avHeaderRect = blockElement.querySelector(".av__header").getBoundingClientRect()
|
||||
const avHeaderRect = blockElement.querySelector(".av__header").getBoundingClientRect();
|
||||
if (avHeaderRect.bottom > cellRect.top) {
|
||||
const contentElement = hasClosestByClassName(blockElement, "protyle-content", true);
|
||||
if (contentElement) {
|
||||
|
|
@ -370,7 +370,7 @@ export const cellScrollIntoView = (blockElement: HTMLElement, cellRect: DOMRect,
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export const popTextCell = (protyle: IProtyle, cellElements: HTMLElement[], type?: TAVCol) => {
|
||||
if (!type) {
|
||||
|
|
@ -385,7 +385,7 @@ export const popTextCell = (protyle: IProtyle, cellElements: HTMLElement[], type
|
|||
const blockElement = hasClosestBlock(cellElements[0]);
|
||||
let cellRect = cellElements[0].getBoundingClientRect();
|
||||
if (blockElement) {
|
||||
cellScrollIntoView(blockElement, cellRect)
|
||||
cellScrollIntoView(blockElement, cellRect);
|
||||
}
|
||||
cellRect = cellElements[0].getBoundingClientRect();
|
||||
let html = "";
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import {hasClosestBlock} from "../../util/hasClosest";
|
||||
import {Menu} from "../../../plugin/Menu";
|
||||
import {transaction} from "../../wysiwyg/transaction";
|
||||
import {fetchPost} from "../../../util/fetch";
|
||||
|
|
|
|||
|
|
@ -28,13 +28,13 @@ export const avKeydown = (event: KeyboardEvent, nodeElement: HTMLElement, protyl
|
|||
event.preventDefault();
|
||||
return true;
|
||||
}
|
||||
let newCellElement
|
||||
let newCellElement;
|
||||
if (event.key === "ArrowLeft") {
|
||||
const previousRowElement = selectCellElement.parentElement.previousElementSibling
|
||||
const previousRowElement = selectCellElement.parentElement.previousElementSibling;
|
||||
if (selectCellElement.previousElementSibling && selectCellElement.previousElementSibling.classList.contains("av__cell")) {
|
||||
newCellElement = selectCellElement.previousElementSibling
|
||||
newCellElement = selectCellElement.previousElementSibling;
|
||||
} else if (previousRowElement && !previousRowElement.classList.contains("av__row--header")) {
|
||||
newCellElement = previousRowElement.lastElementChild.previousElementSibling
|
||||
newCellElement = previousRowElement.lastElementChild.previousElementSibling;
|
||||
}
|
||||
if (newCellElement) {
|
||||
selectCellElement.classList.remove("av__cell--select");
|
||||
|
|
@ -45,11 +45,11 @@ export const avKeydown = (event: KeyboardEvent, nodeElement: HTMLElement, protyl
|
|||
return true;
|
||||
}
|
||||
if (event.key === "ArrowRight") {
|
||||
const nextRowElement = selectCellElement.parentElement.nextElementSibling
|
||||
const nextRowElement = selectCellElement.parentElement.nextElementSibling;
|
||||
if (selectCellElement.nextElementSibling && selectCellElement.nextElementSibling.classList.contains("av__cell")) {
|
||||
newCellElement = selectCellElement.nextElementSibling
|
||||
newCellElement = selectCellElement.nextElementSibling;
|
||||
} else if (nextRowElement && !nextRowElement.classList.contains("av__row--footer")) {
|
||||
newCellElement = nextRowElement.querySelector(".av__cell")
|
||||
newCellElement = nextRowElement.querySelector(".av__cell");
|
||||
}
|
||||
if (newCellElement) {
|
||||
selectCellElement.classList.remove("av__cell--select");
|
||||
|
|
@ -60,9 +60,9 @@ export const avKeydown = (event: KeyboardEvent, nodeElement: HTMLElement, protyl
|
|||
return true;
|
||||
}
|
||||
if (event.key === "ArrowUp") {
|
||||
const previousRowElement = selectCellElement.parentElement.previousElementSibling
|
||||
const previousRowElement = selectCellElement.parentElement.previousElementSibling;
|
||||
if (previousRowElement && !previousRowElement.classList.contains("av__row--header")) {
|
||||
newCellElement = previousRowElement.querySelector(`.av__cell[data-col-id="${selectCellElement.dataset.colId}"]`)
|
||||
newCellElement = previousRowElement.querySelector(`.av__cell[data-col-id="${selectCellElement.dataset.colId}"]`);
|
||||
}
|
||||
if (newCellElement) {
|
||||
selectCellElement.classList.remove("av__cell--select");
|
||||
|
|
@ -73,9 +73,9 @@ export const avKeydown = (event: KeyboardEvent, nodeElement: HTMLElement, protyl
|
|||
return true;
|
||||
}
|
||||
if (event.key === "ArrowDown") {
|
||||
const nextRowElement = selectCellElement.parentElement.nextElementSibling
|
||||
const nextRowElement = selectCellElement.parentElement.nextElementSibling;
|
||||
if (nextRowElement && !nextRowElement.classList.contains("av__row--footer")) {
|
||||
newCellElement = nextRowElement.querySelector(`.av__cell[data-col-id="${selectCellElement.dataset.colId}"]`)
|
||||
newCellElement = nextRowElement.querySelector(`.av__cell[data-col-id="${selectCellElement.dataset.colId}"]`);
|
||||
}
|
||||
if (newCellElement) {
|
||||
selectCellElement.classList.remove("av__cell--select");
|
||||
|
|
@ -111,30 +111,30 @@ export const avKeydown = (event: KeyboardEvent, nodeElement: HTMLElement, protyl
|
|||
}
|
||||
// TODO event.shiftKey
|
||||
if (event.key === "ArrowUp") {
|
||||
const previousRowElement = selectRowElements[0].previousElementSibling
|
||||
const previousRowElement = selectRowElements[0].previousElementSibling;
|
||||
selectRow(selectRowElements[0].querySelector(".av__firstcol"), "unselectAll");
|
||||
if (previousRowElement && !previousRowElement.classList.contains("av__row--header")) {
|
||||
selectRow(previousRowElement.querySelector(".av__firstcol"), "select");
|
||||
cellScrollIntoView(nodeElement, previousRowElement.getBoundingClientRect(), true);
|
||||
} else {
|
||||
nodeElement.classList.add("protyle-wysiwyg--select")
|
||||
nodeElement.classList.add("protyle-wysiwyg--select");
|
||||
}
|
||||
event.preventDefault();
|
||||
return true;
|
||||
}
|
||||
if (event.key === "ArrowDown") {
|
||||
const nextRowElement = selectRowElements[selectRowElements.length - 1].nextElementSibling
|
||||
const nextRowElement = selectRowElements[selectRowElements.length - 1].nextElementSibling;
|
||||
selectRow(selectRowElements[0].querySelector(".av__firstcol"), "unselectAll");
|
||||
if (nextRowElement && !nextRowElement.classList.contains("av__row--add")) {
|
||||
selectRow(nextRowElement.querySelector(".av__firstcol"), "select");
|
||||
cellScrollIntoView(nodeElement, nextRowElement.getBoundingClientRect(), true);
|
||||
} else {
|
||||
nodeElement.classList.add("protyle-wysiwyg--select")
|
||||
nodeElement.classList.add("protyle-wysiwyg--select");
|
||||
}
|
||||
event.preventDefault();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -219,7 +219,7 @@ ${cell.color ? `color:${cell.color};` : ""}">${text}</div>`;
|
|||
if (newCellElement) {
|
||||
newCellElement.classList.add("av__cell--select");
|
||||
}
|
||||
focusBlock(e)
|
||||
focusBlock(e);
|
||||
}
|
||||
if (cb) {
|
||||
cb();
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ export const selectRow = (checkElement: Element, type: "toggle" | "select" | "un
|
|||
}
|
||||
focusBlock(hasClosestBlock(rowElement) as HTMLElement);
|
||||
updateHeader(rowElement);
|
||||
}
|
||||
};
|
||||
|
||||
export const updateHeader = (rowElement: HTMLElement) => {
|
||||
const blockElement = hasClosestBlock(rowElement);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue