mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-12 10:14:21 +01:00
This commit is contained in:
parent
afc792b476
commit
3727db323c
2 changed files with 23 additions and 3 deletions
|
|
@ -183,9 +183,6 @@ export const initFramework = () => {
|
|||
const initEditorName = () => {
|
||||
const inputElement = document.getElementById("toolbarName") as HTMLInputElement;
|
||||
inputElement.setAttribute("placeholder", window.siyuan.languages._kernel[16]);
|
||||
inputElement.addEventListener("focus", () => {
|
||||
hideKeyboardToolbar();
|
||||
});
|
||||
inputElement.addEventListener("blur", () => {
|
||||
if (window.siyuan.config.readonly || window.siyuan.config.editor.readOnly || window.siyuan.mobile.editor.protyle.disabled) {
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -87,7 +87,30 @@ export const hideKeyboard = () => {
|
|||
(document.activeElement as HTMLElement).blur();
|
||||
};
|
||||
|
||||
const disabledKeyboardToolbar = () => {
|
||||
document.querySelectorAll("#keyboardToolbar button").forEach(item => {
|
||||
if (item.getAttribute("data-type") !== "all") {
|
||||
item.setAttribute("disabled", "disabled");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
const enKeyboardToolbar = () => {
|
||||
document.querySelectorAll("#keyboardToolbar button").forEach(item => {
|
||||
item.removeAttribute("disabled");
|
||||
});
|
||||
}
|
||||
|
||||
export const initKeyboardToolbar = () => {
|
||||
window.addEventListener('focus', (event) => {
|
||||
const target = event.target as HTMLElement
|
||||
if (["INPUT", "TEXTAREA"].includes(target.tagName)) {
|
||||
disabledKeyboardToolbar()
|
||||
} else if (target.classList.contains("protyle-wysiwyg")) {
|
||||
enKeyboardToolbar()
|
||||
}
|
||||
}, true);
|
||||
|
||||
const toolbarElement = document.getElementById("keyboardToolbar");
|
||||
toolbarElement.addEventListener("click", (event) => {
|
||||
const target = event.target as HTMLElement;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue