mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-29 19:56:10 +01:00
This commit is contained in:
parent
7a6cd95656
commit
3bd7c92710
1 changed files with 11 additions and 3 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue