mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-09-22 00:20:47 +02:00
This commit is contained in:
parent
6803c6483e
commit
8b21b8fd03
1 changed files with 26 additions and 0 deletions
|
@ -29,6 +29,7 @@ import {openAttr, openFileAttr} from "../menus/commonMenuItem";
|
||||||
import {globalCommand} from "../boot/globalEvent/command/global";
|
import {globalCommand} from "../boot/globalEvent/command/global";
|
||||||
import {exportLayout} from "../layout/util";
|
import {exportLayout} from "../layout/util";
|
||||||
import {saveScroll} from "../protyle/scroll/saveScroll";
|
import {saveScroll} from "../protyle/scroll/saveScroll";
|
||||||
|
import {hasClosestByClassName} from "../protyle/util/hasClosest";
|
||||||
|
|
||||||
let openTab;
|
let openTab;
|
||||||
let openWindow;
|
let openWindow;
|
||||||
|
@ -212,6 +213,30 @@ const saveLayout = (cb: () => void) => {
|
||||||
/// #endif
|
/// #endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getActiveEditor = () => {
|
||||||
|
let editor;
|
||||||
|
/// #if !MOBILE
|
||||||
|
const range = getSelection().rangeCount > 0 ? getSelection().getRangeAt(0) : null;
|
||||||
|
if (range) {
|
||||||
|
editor = getAllEditor().find(item => {
|
||||||
|
if (item.protyle.element.contains(range.startContainer)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (!editor) {
|
||||||
|
editor = getAllEditor().find(item => {
|
||||||
|
if (hasClosestByClassName(item.protyle.element, "layout__wnd--active", true)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/// #else
|
||||||
|
editor = window.siyuan.mobile.popEditor || window.siyuan.mobile.editor;
|
||||||
|
/// #endif
|
||||||
|
return editor;
|
||||||
|
};
|
||||||
|
|
||||||
export const API = {
|
export const API = {
|
||||||
adaptHotkey: updateHotkeyTip,
|
adaptHotkey: updateHotkeyTip,
|
||||||
confirm: confirmDialog,
|
confirm: confirmDialog,
|
||||||
|
@ -239,6 +264,7 @@ export const API = {
|
||||||
getActiveTab,
|
getActiveTab,
|
||||||
getAllModels,
|
getAllModels,
|
||||||
/// #endif
|
/// #endif
|
||||||
|
getActiveEditor,
|
||||||
platformUtils,
|
platformUtils,
|
||||||
openSetting,
|
openSetting,
|
||||||
openAttributePanel,
|
openAttributePanel,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue