mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-16 03:58:07 +01:00
This commit is contained in:
parent
c4d052b934
commit
a0d51e8cfc
6 changed files with 72 additions and 16 deletions
|
|
@ -56,6 +56,9 @@ import {commandPanel} from "../../plugin/commandPanel";
|
|||
import {toggleDockBar} from "../../layout/dock/util";
|
||||
import {workspaceMenu} from "../../menus/workspace";
|
||||
import {resize} from "../../protyle/util/resize";
|
||||
import {Search} from "../../search";
|
||||
import {Custom} from "../../layout/dock/Custom";
|
||||
import {Protyle} from "../../protyle";
|
||||
|
||||
const switchDialogEvent = (app: App, event: MouseEvent) => {
|
||||
event.preventDefault();
|
||||
|
|
@ -152,22 +155,73 @@ const dialogArrow = (app: App, element: HTMLElement, event: KeyboardEvent) => {
|
|||
const editKeydown = (app: App, event: KeyboardEvent) => {
|
||||
const activeTabElement = document.querySelector(".layout__wnd--active .item--focus");
|
||||
let protyle: IProtyle;
|
||||
if (activeTabElement) {
|
||||
const tab = getInstanceById(activeTabElement.getAttribute("data-id")) as Tab;
|
||||
if (!(tab.model instanceof Editor)) {
|
||||
return false;
|
||||
}
|
||||
protyle = tab.model.editor.protyle;
|
||||
} else {
|
||||
const editor = getAllModels().editor.find(item => {
|
||||
if (item.parent.headElement.classList.contains("item--focus")) {
|
||||
let range: Range;
|
||||
if (getSelection().rangeCount > 0) {
|
||||
range = getSelection().getRangeAt(0);
|
||||
}
|
||||
if (range) {
|
||||
window.siyuan.dialogs.find(item => {
|
||||
if (item.editor && item.editor.protyle.element.contains(range.startContainer)) {
|
||||
protyle = item.editor.protyle;
|
||||
return true;
|
||||
}
|
||||
});
|
||||
if (!editor) {
|
||||
})
|
||||
}
|
||||
if (!protyle && activeTabElement) {
|
||||
const tab = getInstanceById(activeTabElement.getAttribute("data-id")) as Tab;
|
||||
if (tab.model instanceof Editor) {
|
||||
protyle = tab.model.editor.protyle;
|
||||
} else if (tab.model instanceof Search) {
|
||||
protyle = tab.model.edit.protyle;
|
||||
} else if (tab.model instanceof Custom && tab.model.data?.editor instanceof Protyle) {
|
||||
protyle = tab.model.data.editor.protyle;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else if (!protyle) {
|
||||
const models = getAllModels();
|
||||
if (!protyle && range) {
|
||||
window.siyuan.blockPanels.find(item => {
|
||||
item.editors.find(editorItem => {
|
||||
if (editorItem.protyle.element.contains(range.startContainer)) {
|
||||
protyle = editorItem.protyle;
|
||||
return true;
|
||||
}
|
||||
})
|
||||
if (protyle) {
|
||||
return true
|
||||
}
|
||||
})
|
||||
}
|
||||
if (!protyle) {
|
||||
models.backlink.find(item => {
|
||||
if (item.element.classList.contains("layout__tab--active")) {
|
||||
if (range) {
|
||||
item.editors.find(editor => {
|
||||
if (editor.protyle.element.contains(range.startContainer)) {
|
||||
protyle = editor.protyle;
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
if (!protyle) {
|
||||
protyle = item.editors[0].protyle;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
})
|
||||
}
|
||||
if (!protyle) {
|
||||
models.editor.find(item => {
|
||||
if (item.parent.headElement.classList.contains("item--focus")) {
|
||||
protyle = item.editor.protyle;
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
if (!protyle) {
|
||||
return false;
|
||||
}
|
||||
protyle = editor.editor.protyle;
|
||||
}
|
||||
const activePanelElement = document.querySelector(".layout__tab--active");
|
||||
let isFileFocus = false;
|
||||
|
|
@ -181,10 +235,6 @@ const editKeydown = (app: App, event: KeyboardEvent) => {
|
|||
searchKey = window.siyuan.config.keymap.general.search.custom;
|
||||
}
|
||||
if (!isFileFocus && searchKey) {
|
||||
let range: Range;
|
||||
if (getSelection().rangeCount > 0) {
|
||||
range = getSelection().getRangeAt(0);
|
||||
}
|
||||
if (range && protyle.element.contains(range.startContainer)) {
|
||||
openSearch({
|
||||
app,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue