Vanessa 2025-07-23 13:08:38 +08:00
parent c88f99646c
commit 508eb93183
33 changed files with 111 additions and 108 deletions

View file

@ -298,11 +298,11 @@ class="fn__flex-1 fn__flex${["url", "text", "number", "email", "phone", "block"]
if (!targetElement) {
targetElement = hasClosestByClassName(document.elementFromPoint(event.clientX, event.clientY - 1), "av__row");
}
if (!targetElement || (targetElement === window.siyuan.dragElement) || !dragBlockElement) {
if (!targetElement || targetElement === window.siyuan.dragElement || !dragBlockElement) {
return;
}
const targetBlockElement = hasClosestBlock(targetElement);
if (!targetBlockElement || (targetBlockElement !== dragBlockElement)) {
if (!targetBlockElement || targetBlockElement !== dragBlockElement) {
return;
}
event.preventDefault();
@ -455,7 +455,7 @@ const openEdit = (protyle: IProtyle, element: HTMLElement, event: MouseEvent) =>
if (!blockElement) {
return;
}
while (target && (element !== target)) {
while (target && element !== target) {
const type = target.getAttribute("data-type");
if (target.classList.contains("av__celltext--url") || target.classList.contains("av__cellassetimg")) {
if (event.type === "contextmenu" || (!target.dataset.url && target.tagName !== "IMG")) {

View file

@ -743,9 +743,9 @@ export const updateCellsValue = (protyle: IProtyle, nodeElement: HTMLElement, va
const cellId = item.dataset.id; // 刚创建时无 id更新需和 oldValue 保持一致
const colId = getColId(item, viewType);
text += getCellText(item) + ((cellElements[elementIndex + 1] && item.nextElementSibling && (item.nextElementSibling === cellElements[elementIndex + 1])) ? "\t" : "\n\n");
text += getCellText(item) + ((cellElements[elementIndex + 1] && item.nextElementSibling && item.nextElementSibling === cellElements[elementIndex + 1]) ? "\t" : "\n\n");
const oldValue = genCellValueByElement(type, item);
if (elementIndex === 0 || (cellElements[elementIndex - 1] !== item.previousElementSibling)) {
if (elementIndex === 0 || cellElements[elementIndex - 1] !== item.previousElementSibling) {
json.push([]);
}
json[json.length - 1].push(oldValue);

View file

@ -1015,7 +1015,7 @@ export const showColMenu = (protyle: IProtyle, blockElement: Element, cellElemen
dialog.element.addEventListener("click", (event) => {
let target = event.target as HTMLElement;
const isDispatch = typeof event.detail === "string";
while (target && (target !== dialog.element) || isDispatch) {
while (target && target !== dialog.element || isDispatch) {
const action = target.getAttribute("data-action");
if (action === "delete" || (isDispatch && event.detail === "Enter")) {
removeColByMenu({

View file

@ -45,7 +45,7 @@ export const renderGallery = (options: {
const created = options.protyle.options.history?.created;
const snapshot = options.protyle.options.history?.snapshot;
let searchInputElement = options.blockElement.querySelector('[data-type="av-search"]') as HTMLInputElement;
const isSearching = searchInputElement && (document.activeElement === searchInputElement);
const isSearching = searchInputElement && document.activeElement === searchInputElement;
const query = searchInputElement?.value || "";
fetchPost(created ? "/api/av/renderHistoryAttributeView" : (snapshot ? "/api/av/renderSnapshotAttributeView" : "/api/av/renderAttributeView"), {
id: options.blockElement.getAttribute("data-av-id"),
@ -213,7 +213,7 @@ ${view.hideAttrViewName ? " av__gallery--top" : ""}">
const range = getSelection().getRangeAt(0);
if (!hasClosestByClassName(range.startContainer, "av__title")) {
const blockElement = hasClosestBlock(range.startContainer);
if (blockElement && (options.blockElement === blockElement) && !isSearching) {
if (blockElement && options.blockElement === blockElement && !isSearching) {
focusBlock(options.blockElement);
}
}
@ -245,7 +245,7 @@ ${view.hideAttrViewName ? " av__gallery--top" : ""}">
if (event.isComposing) {
return;
}
if (searchInputElement.value || (document.activeElement === searchInputElement)) {
if (searchInputElement.value || document.activeElement === searchInputElement) {
viewsElement.classList.add("av__views--show");
} else {
viewsElement.classList.remove("av__views--show");

View file

@ -475,11 +475,11 @@ export const openMenuPanel = (options: {
if (!targetElement) {
targetElement = hasClosestByAttribute(document.elementFromPoint(event.clientX, event.clientY - 1), "draggable", "true");
}
if (!targetElement || (targetElement === window.siyuan.dragElement)) {
if (!targetElement || targetElement === window.siyuan.dragElement) {
return;
}
event.preventDefault();
if (dragoverElement && (targetElement === dragoverElement)) {
if (dragoverElement && targetElement === dragoverElement) {
const nodeRect = targetElement.getBoundingClientRect();
avPanelElement.querySelectorAll(".dragover__bottom, .dragover__top").forEach((item: HTMLElement) => {
item.classList.remove("dragover__bottom", "dragover__top");
@ -526,7 +526,7 @@ export const openMenuPanel = (options: {
type = (event.detail as { type: string }).type;
target = (event.detail as { target: HTMLElement }).target;
}
while (target && (target !== avPanelElement) || type) {
while (target && target !== avPanelElement || type) {
type = target?.dataset.type || type;
if (type === "close") {
if (!options.protyle.toolbar.subElement.classList.contains("fn__none")) {
@ -1181,7 +1181,7 @@ export const openMenuPanel = (options: {
dialog.element.addEventListener("click", (dialogEvent) => {
let target = dialogEvent.target as HTMLElement;
const isDispatch = typeof dialogEvent.detail === "string";
while (target && (target !== dialog.element) || isDispatch) {
while (target && target !== dialog.element || isDispatch) {
const action = target.getAttribute("data-action");
if (action === "delete" || (isDispatch && dialogEvent.detail === "Enter")) {
removeCol({

View file

@ -85,7 +85,7 @@ export const avRender = (element: Element, protyle: IProtyle, cb?: (data: IAV) =
const created = protyle.options.history?.created;
const snapshot = protyle.options.history?.snapshot;
let searchInputElement = e.querySelector('[data-type="av-search"]') as HTMLInputElement;
const isSearching = searchInputElement && (document.activeElement === searchInputElement);
const isSearching = searchInputElement && document.activeElement === searchInputElement;
const query = searchInputElement?.value || "";
fetchPost(created ? "/api/av/renderHistoryAttributeView" : (snapshot ? "/api/av/renderSnapshotAttributeView" : "/api/av/renderAttributeView"), {
id: e.getAttribute("data-av-id"),
@ -336,7 +336,7 @@ ${cell.color ? `color:${cell.color};` : ""}">${renderCell(cell.value, rowIndex,
} else if (!avPanelElement && !isSearching && getSelection().rangeCount > 0) {
const range = getSelection().getRangeAt(0);
const blockElement = hasClosestBlock(range.startContainer);
if (blockElement && (e === blockElement)) {
if (blockElement && e === blockElement) {
focusBlock(e);
}
} else if (avPanelElement && !newCellElement) {
@ -366,7 +366,7 @@ ${cell.color ? `color:${cell.color};` : ""}">${renderCell(cell.value, rowIndex,
const range = getSelection().getRangeAt(0);
if (!hasClosestByClassName(range.startContainer, "av__title")) {
const blockElement = hasClosestBlock(range.startContainer);
if (blockElement && (e === blockElement) && !isSearching) {
if (blockElement && e === blockElement && !isSearching) {
focusBlock(e);
}
}
@ -398,7 +398,7 @@ ${cell.color ? `color:${cell.color};` : ""}">${renderCell(cell.value, rowIndex,
if (event.isComposing) {
return;
}
if (searchInputElement.value || (document.activeElement === searchInputElement)) {
if (searchInputElement.value || document.activeElement === searchInputElement) {
viewsElement.classList.add("av__views--show");
} else {
viewsElement.classList.remove("av__views--show");

View file

@ -408,17 +408,17 @@ export const dragoverTab = (event: DragEvent) => {
if (!target) {
return;
}
if ((viewTabElement !== window.siyuan.dragElement.parentElement) || (target === window.siyuan.dragElement)) {
if (viewTabElement !== window.siyuan.dragElement.parentElement || (target === window.siyuan.dragElement)) {
return;
}
const targetRect = target.getBoundingClientRect();
if (targetRect.left + targetRect.width / 2 < event.clientX) {
if (target.nextElementSibling && (target.nextElementSibling === window.siyuan.dragElement)) {
if (target.nextElementSibling && target.nextElementSibling === window.siyuan.dragElement) {
return;
}
target.after(window.siyuan.dragElement);
} else {
if (target.previousElementSibling && (target.previousElementSibling === window.siyuan.dragElement)) {
if (target.previousElementSibling && target.previousElementSibling === window.siyuan.dragElement) {
return;
}
target.before(window.siyuan.dragElement);