mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-20 16:40:13 +01:00
This commit is contained in:
parent
f4fe18a680
commit
d758a0d218
2 changed files with 21 additions and 2 deletions
|
|
@ -2,7 +2,7 @@ import {
|
||||||
hasClosestBlock,
|
hasClosestBlock,
|
||||||
hasClosestByAttribute,
|
hasClosestByAttribute,
|
||||||
hasClosestByClassName, hasClosestByTag,
|
hasClosestByClassName, hasClosestByTag,
|
||||||
hasTopClosestByClassName
|
hasTopClosestByClassName, isInEmbedBlock
|
||||||
} from "../protyle/util/hasClosest";
|
} from "../protyle/util/hasClosest";
|
||||||
import {MenuItem} from "./Menu";
|
import {MenuItem} from "./Menu";
|
||||||
import {focusBlock, focusByRange, focusByWbr, getEditorRange, selectAll,} from "../protyle/util/selection";
|
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};
|
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,
|
export const setFold = (protyle: IProtyle, nodeElement: Element, isOpen?: boolean,
|
||||||
isRemove?: boolean, addLoading = true, getOperations = false) => {
|
isRemove?: boolean, addLoading = true, getOperations = false) => {
|
||||||
if (nodeElement.getAttribute("data-type") === "NodeListItem" && nodeElement.childElementCount < 4) {
|
if (nodeElement.getAttribute("data-type") === "NodeListItem" && nodeElement.childElementCount < 4) {
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ import {getAllModels} from "../layout/getAll";
|
||||||
/// #endif
|
/// #endif
|
||||||
import {isSupportCSSHL} from "./render/searchMarkRender";
|
import {isSupportCSSHL} from "./render/searchMarkRender";
|
||||||
import {renderAVAttribute} from "./render/av/blockAttr";
|
import {renderAVAttribute} from "./render/av/blockAttr";
|
||||||
import {zoomOut} from "../menus/protyle";
|
import {setFoldById, zoomOut} from "../menus/protyle";
|
||||||
|
|
||||||
export class Protyle {
|
export class Protyle {
|
||||||
|
|
||||||
|
|
@ -157,6 +157,9 @@ export class Protyle {
|
||||||
addLoading(this.protyle, data.msg);
|
addLoading(this.protyle, data.msg);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case "unfoldHeading":
|
||||||
|
setFoldById(data.data, this.protyle);
|
||||||
|
break;
|
||||||
case "transactions":
|
case "transactions":
|
||||||
this.onTransaction(data);
|
this.onTransaction(data);
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue