This commit is contained in:
Vanessa 2025-10-13 17:49:45 +08:00
parent f4fe18a680
commit d758a0d218
2 changed files with 21 additions and 2 deletions

View file

@ -2,7 +2,7 @@ import {
hasClosestBlock,
hasClosestByAttribute,
hasClosestByClassName, hasClosestByTag,
hasTopClosestByClassName
hasTopClosestByClassName, isInEmbedBlock
} from "../protyle/util/hasClosest";
import {MenuItem} from "./Menu";
import {focusBlock, focusByRange, focusByWbr, getEditorRange, selectAll,} from "../protyle/util/selection";
@ -2433,6 +2433,22 @@ export const tableMenu = (protyle: IProtyle, nodeElement: Element, cellElement:
return {menus, removeMenus, insertMenus, otherMenus, other2Menus};
};
export const setFoldById = (data: {
id: string,
currentNodeID: string,
}, protyle: IProtyle) => {
Array.from(protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${data.id}"]`)).find((item: Element) => {
if (!isInEmbedBlock(item)) {
const operations = setFold(protyle, item, true, false, true, true);
operations.doOperations[0].context = {
focusId: data.currentNodeID,
};
transaction(protyle, operations.doOperations, operations.undoOperations);
return true;
}
});
};
export const setFold = (protyle: IProtyle, nodeElement: Element, isOpen?: boolean,
isRemove?: boolean, addLoading = true, getOperations = false) => {
if (nodeElement.getAttribute("data-type") === "NodeListItem" && nodeElement.childElementCount < 4) {

View file

@ -47,7 +47,7 @@ import {getAllModels} from "../layout/getAll";
/// #endif
import {isSupportCSSHL} from "./render/searchMarkRender";
import {renderAVAttribute} from "./render/av/blockAttr";
import {zoomOut} from "../menus/protyle";
import {setFoldById, zoomOut} from "../menus/protyle";
export class Protyle {
@ -157,6 +157,9 @@ export class Protyle {
addLoading(this.protyle, data.msg);
}
break;
case "unfoldHeading":
setFoldById(data.data, this.protyle);
break;
case "transactions":
this.onTransaction(data);
break;