Vanessa 2025-11-22 23:04:44 +08:00
parent 3fa9d458e5
commit 5704032318
12 changed files with 33 additions and 39 deletions

View file

@ -61,7 +61,7 @@ import {popSearch} from "../mobile/menu/search";
import {showMessage} from "../dialog/message";
import {img3115} from "../boot/compatibleVersion";
import {hideTooltip} from "../dialog/tooltip";
import {clearSelect} from "../protyle/util/clearSelect";
import {clearSelect} from "../protyle/util/clear";
import {scrollCenter} from "../util/highlightById";
const renderAssetList = (element: Element, k: string, position: IPosition, exts: string[] = []) => {

View file

@ -62,7 +62,7 @@ import {openFileById} from "../../editor/util";
import * as path from "path";
/// #endif
import {checkFold} from "../../util/noRelyPCFunction";
import {clearSelect} from "../util/clearSelect";
import {clearSelect} from "../util/clear";
export class Gutter {
public element: HTMLElement;

View file

@ -36,7 +36,7 @@ import {fetchPost, fetchSyncPost} from "../../../util/fetch";
import {scrollCenter} from "../../../util/highlightById";
import {escapeHtml} from "../../../util/escape";
import {editGalleryItem, openGalleryItemMenu} from "./gallery/util";
import {clearSelect} from "../../util/clearSelect";
import {clearSelect} from "../../util/clear";
import {removeCompressURL} from "../../../util/image";
let foldTimeout: number;

View file

@ -2,7 +2,7 @@ import {genCellValue, getTypeByCellElement, renderCell, renderCellAttr} from "..
import {fetchPost} from "../../../../util/fetch";
import {setPage} from "../row";
import {Constants} from "../../../../constants";
import {clearSelect} from "../../../util/clearSelect";
import {clearSelect} from "../../../util/clear";
export const insertGalleryItemAnimation = (options: {
blockElement: HTMLElement;

View file

@ -5,7 +5,7 @@ import {avContextmenu} from "./action";
import {hasClosestByClassName} from "../../util/hasClosest";
import {Constants} from "../../../constants";
import {upDownHint} from "../../../util/upDownHint";
import {clearSelect} from "../../util/clearSelect";
import {clearSelect} from "../../util/clear";
export const avKeydown = (event: KeyboardEvent, nodeElement: HTMLElement, protyle: IProtyle) => {
if (!nodeElement.classList.contains("av") || !window.siyuan.menus.menu.element.classList.contains("fn__none")) {

View file

@ -17,7 +17,7 @@ import {renderGallery} from "./gallery/render";
import {getFieldsByData, getViewIcon} from "./view";
import {openMenuPanel} from "./openMenuPanel";
import {getPageSize} from "./groups";
import {clearSelect} from "../../util/clearSelect";
import {clearSelect} from "../../util/clear";
import {showMessage} from "../../../dialog/message";
import {renderKanban} from "./kanban/render";

View file

@ -7,7 +7,7 @@ import {fetchPost} from "../../../util/fetch";
import * as dayjs from "dayjs";
import {Constants} from "../../../constants";
import {insertGalleryItemAnimation} from "./gallery/item";
import {clearSelect} from "../../util/clearSelect";
import {clearSelect} from "../../util/clear";
import {isCustomAttr} from "./blockAttr";
export const getFieldIdByCellElement = (cellElement: Element, viewType: TAVView): string => {

View file

@ -1,4 +1,21 @@
import {updateHeader} from "../render/av/row";
import {Constants} from "../../constants";
export const clearBlockElement = (element: Element) => {
element.classList.remove("protyle-wysiwyg--select", "protyle-wysiwyg--hl");
element.removeAttribute(Constants.CUSTOM_RIFF_DECKS);
element.removeAttribute("refcount");
element.querySelector(".protyle-attr--av")?.remove();
element.querySelector(".protyle-attr--refcount")?.remove();
element.removeAttribute("custom-avs");
element.removeAttribute("av-names");
debugger
element.getAttributeNames().forEach(attr => {
if (attr.startsWith("custom-sy-av-s-text-")) {
element.removeAttribute(attr);
}
})
};
export const clearSelect = (types: ("av" | "img" | "cell" | "row" | "galleryItem")[], element: Element) => {
if (types.includes("cell")) {

View file

@ -34,7 +34,7 @@ import {webUtils} from "electron";
import {addDragFill, getTypeByCellElement} from "../render/av/cell";
import {processClonePHElement} from "../render/util";
import {insertGalleryItemAnimation} from "../render/av/gallery/item";
import {clearSelect} from "./clearSelect";
import {clearSelect} from "./clear";
import {dragoverTab} from "../render/av/view";
// position: afterbegin 为拖拽成超级块; "afterend", "beforebegin" 一般拖拽

View file

@ -14,6 +14,7 @@ import {hideElements} from "../ui/hideElements";
import {avRender} from "../render/av/render";
import {cellScrollIntoView, getCellText} from "../render/av/cell";
import {getContenteditableElement} from "../wysiwyg/getBlock";
import {clearBlockElement} from "./clear";
export const getTextStar = (blockElement: HTMLElement) => {
const dataType = blockElement.dataset.type;
@ -407,13 +408,8 @@ export const paste = async (protyle: IProtyle, event: (ClipboardEvent | DragEven
tempElement.querySelectorAll("[data-node-id]").forEach((e) => {
const newId = Lute.NewNodeID();
e.setAttribute("data-node-id", newId);
e.removeAttribute(Constants.CUSTOM_RIFF_DECKS);
e.classList.remove("protyle-wysiwyg--select", "protyle-wysiwyg--hl");
e.setAttribute("updated", newId.split("-")[0]);
e.removeAttribute("refcount");
e.querySelector(".protyle-attr--av")?.remove();
e.removeAttribute("custom-avs");
e.removeAttribute("av-names");
clearBlockElement(e);
isBlock = true;
});
if (nodeElement.classList.contains("table")) {

View file

@ -15,6 +15,7 @@ import {processClonePHElement} from "../render/util";
import {copyTextByType} from "../toolbar/util";
import {hasClosestByTag, hasTopClosestByClassName} from "../util/hasClosest";
import {removeEmbed} from "./removeEmbed";
import {clearBlockElement} from "../util/clear";
export const commonHotkey = (protyle: IProtyle, event: KeyboardEvent, nodeElement?: HTMLElement) => {
if (matchHotKey(window.siyuan.config.keymap.editor.general.netImg2LocalAsset.custom, event)) {
@ -313,25 +314,13 @@ export const duplicateBlock = async (nodeElements: Element[], protyle: IProtyle)
focusElement = tempElement;
}
tempElement.setAttribute("data-node-id", newId);
tempElement.removeAttribute(Constants.CUSTOM_RIFF_DECKS);
tempElement.classList.remove("protyle-wysiwyg--hl");
tempElement.setAttribute("updated", newId.split("-")[0]);
tempElement.removeAttribute("refcount");
tempElement.lastElementChild.querySelector(".protyle-attr--refcount")?.remove();
tempElement.lastElementChild.querySelector(".protyle-attr--av")?.remove();
tempElement.removeAttribute("custom-avs");
tempElement.removeAttribute("av-names");
clearBlockElement(tempElement);
tempElement.querySelectorAll("[data-node-id]").forEach(childItem => {
const subNewId = Lute.NewNodeID();
childItem.setAttribute("data-node-id", subNewId);
childItem.removeAttribute(Constants.CUSTOM_RIFF_DECKS);
childItem.classList.remove("protyle-wysiwyg--hl");
childItem.setAttribute("updated", subNewId.split("-")[0]);
childItem.removeAttribute("refcount");
childItem.lastElementChild.querySelector(".protyle-attr--refcount")?.remove();
childItem.lastElementChild.querySelector(".protyle-attr--av")?.remove();
childItem.removeAttribute("custom-avs");
childItem.removeAttribute("av-names");
clearBlockElement(childItem);
});
if (typeof starIndex === "number") {
const orderIndex = starIndex + index + 1;
@ -360,19 +349,11 @@ export const duplicateBlock = async (nodeElements: Element[], protyle: IProtyle)
}
childItem.querySelectorAll("[data-node-id]").forEach(subItem => {
subItem.setAttribute("data-node-id", Lute.NewNodeID());
subItem.removeAttribute(Constants.CUSTOM_RIFF_DECKS);
subItem.removeAttribute("refcount");
subItem.lastElementChild.querySelector(".protyle-attr--av")?.remove();
subItem.removeAttribute("custom-avs");
subItem.removeAttribute("av-names");
clearBlockElement(subItem);
});
const newChildId = Lute.NewNodeID();
childItem.setAttribute("data-node-id", newChildId);
childItem.removeAttribute(Constants.CUSTOM_RIFF_DECKS);
childItem.removeAttribute("refcount");
childItem.lastElementChild.querySelector(".protyle-attr--av")?.remove();
childItem.removeAttribute("custom-avs");
childItem.removeAttribute("av-names");
clearBlockElement(childItem);
doOperations.push({
context: {
ignoreProcess: "true"

View file

@ -99,7 +99,7 @@ import {img3115} from "../../boot/compatibleVersion";
import {globalClickHideMenu} from "../../boot/globalEvent/click";
import {hideTooltip} from "../../dialog/tooltip";
import {openGalleryItemMenu} from "../render/av/gallery/util";
import {clearSelect} from "../util/clearSelect";
import {clearSelect} from "../util/clear";
import {chartRender} from "../render/chartRender";
export class WYSIWYG {