Vanessa 2023-10-13 11:55:51 +08:00
parent af810b279d
commit 3554333da9
5 changed files with 32 additions and 7 deletions

View file

@ -1666,9 +1666,12 @@ export const setFold = (protyle: IProtyle, nodeElement: Element, isOpen?: boolea
}
nodeElement.querySelectorAll(".img--select, .av__cell--select, .av__row--select").forEach((item:HTMLElement) => {
if (item.classList.contains("av__row--select")) {
item.classList.remove("av__row--select");
item.querySelector(".av__firstcol use").setAttribute("xlink:href", "#iconUncheck");
updateHeader(item);
} else {
item.classList.remove("img--select", "av__cell--select");
}
item.classList.remove("img--select", "av__cell--select", "av__row--select");
});
}
const id = nodeElement.getAttribute("data-node-id");

View file

@ -159,7 +159,11 @@ export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLEle
if (type === "updated" || type === "created" || (type === "block" && !cellElement.getAttribute("data-detached"))) {
selectRow(cellElement.parentElement.querySelector(".av__firstcol"), "toggle");
} else {
selectRow(cellElement.parentElement.querySelector(".av__firstcol"), "unselect");
cellElement.parentElement.parentElement.querySelectorAll(".av__row--select").forEach(item => {
item.querySelector(".av__firstcol use").setAttribute("xlink:href", "#iconUncheck");
item.classList.remove("av__row--select");
});
updateHeader(cellElement.parentElement);
popTextCell(protyle, [cellElement]);
}
event.preventDefault();

View file

@ -6,6 +6,7 @@ import {updateAttrViewCellAnimation} from "./action";
import {isCtrl} from "../../util/compatibility";
import {objEquals} from "../../../util/functions";
import {fetchPost} from "../../../util/fetch";
import {focusBlock} from "../../util/selection";
export const getCalcValue = (column: IAVColumn) => {
if (!column.calc || !column.calc.result) {
@ -523,6 +524,9 @@ const updateCellValue = (protyle: IProtyle, type: TAVCol, cellElements: HTMLElem
transaction(protyle, doOperations, undoOperations);
}
cellElements[0].classList.add("av__cell--select");
if (blockElement) {
focusBlock(blockElement);
}
setTimeout(() => {
avMaskElement.remove();
});

View file

@ -188,11 +188,12 @@ export class WYSIWYG {
// 图片移除选择状态应放在前面,否则 https://github.com/siyuan-note/siyuan/issues/4173
protyle.wysiwyg.element.querySelectorAll(".img--select, .av__cell--select, .av__row--select").forEach((item: HTMLElement) => {
if (item.classList.contains("av__row--select") && !hasClosestByClassName(element, "av")) {
updateHeader(item);
item.classList.remove("av__row--select");
item.querySelector(".av__firstcol use").setAttribute("xlink:href", "#iconUncheck");
updateHeader(item);
} else {
item.classList.remove("img--select", "av__cell--select");
}
item.classList.remove("img--select", "av__cell--select");
});
let nodeElement = element;

View file

@ -69,6 +69,7 @@ import {escapeHtml} from "../../util/escape";
import {insertHTML} from "../util/insertHTML";
import {removeSearchMark} from "../toolbar/util";
import {copyPNG} from "../../menus/util";
import {selectRow, updateHeader} from "../render/av/row";
const getContentByInlineHTML = (range: Range, cb: (content: string) => void) => {
@ -122,7 +123,9 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
if (matchHotKey("⌘B", event) || matchHotKey("⌘I", event) || matchHotKey("⌘U", event)) {
event.preventDefault();
}
return;
if (event.key !== "Escape") {
return;
}
}
if (nodeElement.classList.contains("protyle-wysiwyg--select") && !isCtrl(event) && !event.shiftKey && !event.altKey) {
if (event.key.toLowerCase() === "a") {
@ -1214,7 +1217,11 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
// esc
if (event.key === "Escape") {
if (!protyle.toolbar.element.classList.contains("fn__none") ||
const cellSelectElement = nodeElement.querySelector(".av__cell--select")
if (cellSelectElement) {
cellSelectElement.classList.remove("av__cell--select");
selectRow(cellSelectElement.parentElement.querySelector(".av__firstcol"), "select");
} else if (!protyle.toolbar.element.classList.contains("fn__none") ||
!protyle.hint.element.classList.contains("fn__none") ||
!protyle.toolbar.subElement.classList.contains("fn__none")) {
hideElements(["toolbar", "hint", "util"], protyle);
@ -1230,6 +1237,12 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
range.collapse(false);
nodeElement.classList.add("protyle-wysiwyg--select");
countBlockWord([nodeElement.getAttribute("data-node-id")], protyle.block.rootID);
const selectRowElement = nodeElement.querySelector(".av__row--select:not(.av__row--header)") as HTMLElement;
if (selectRowElement) {
selectRowElement.querySelector(".av__firstcol use").setAttribute("xlink:href", "#iconUncheck");
selectRowElement.classList.remove("av__row--select");
updateHeader(selectRowElement);
}
}
event.preventDefault();
return;