Vanessa 2025-08-21 20:25:10 +08:00
parent 7a6cd95656
commit 3bd7c92710

View file

@ -213,24 +213,32 @@ const saveLayout = (cb: () => void) => {
/// #endif
};
const getActiveEditor = () => {
const getActiveEditor = (wndActive = true) => {
let editor;
/// #if !MOBILE
const range = getSelection().rangeCount > 0 ? getSelection().getRangeAt(0) : null;
const allEditor = getAllEditor();
if (range) {
editor = getAllEditor().find(item => {
editor = allEditor.find(item => {
if (item.protyle.element.contains(range.startContainer)) {
return true;
}
});
}
if (!editor) {
editor = getAllEditor().find(item => {
editor = allEditor.find(item => {
if (hasClosestByClassName(item.protyle.element, "layout__wnd--active", true)) {
return true;
}
});
}
if (!editor && !wndActive) {
editor = allEditor.find(item => {
if (item.protyle?.model.parent.headElement?.classList.contains("item--focus")) {
return true;
}
});
}
/// #else
editor = window.siyuan.mobile.popEditor || window.siyuan.mobile.editor;
/// #endif