Vanessa 2025-03-18 11:56:26 +08:00
parent a01ac85bdb
commit d0700b7527
9 changed files with 80 additions and 27 deletions

View file

@ -1,4 +1,6 @@
/// #if !MOBILE
import {getAllModels} from "../../layout/getAll";
/// #endif
import {hasClosestByAttribute, hasClosestByClassName, hasTopClosestByClassName} from "../../protyle/util/hasClosest";
import {hideAllElements} from "../../protyle/ui/hideElements";
import {isWindow} from "../../util/functions";
@ -22,9 +24,25 @@ export const globalClick = (event: MouseEvent & { target: HTMLElement }) => {
globalClickHideMenu(event.target);
if (!hasClosestByClassName(event.target, "pdf__outer")) {
hideAllElements(["pdfutil"]);
const protyleElement = hasClosestByClassName(event.target, "protyle", true);
if (protyleElement) {
const wysiwygElement = protyleElement.querySelector(".protyle-wysiwyg");
if (wysiwygElement.getAttribute("data-readonly") === "true" || !wysiwygElement.contains(event.target)) {
wysiwygElement.dispatchEvent(new Event("focusin"));
}
}
const copyElement = hasTopClosestByClassName(event.target, "protyle-action__copy");
if (copyElement) {
let text = copyElement.parentElement.nextElementSibling.textContent.replace(/\n$/, "");
text = text.replace(/\u00A0/g, " "); // Replace non-breaking spaces with normal spaces when copying https://github.com/siyuan-note/siyuan/issues/9382
writeText(text);
showMessage(window.siyuan.languages.copied, 2000);
event.preventDefault();
return;
}
/// #if !MOBILE
// dock float 时,点击空白处,隐藏 dock。场景文档树上重命名后
if (!isWindow() && window.siyuan.layout.leftDock &&
!hasClosestByClassName(event.target, "b3-dialog--open", true) &&
@ -38,21 +56,8 @@ export const globalClick = (event: MouseEvent & { target: HTMLElement }) => {
window.siyuan.layout.rightDock.hideDock();
}
const protyleElement = hasClosestByClassName(event.target, "protyle", true);
if (protyleElement) {
const wysiwygElement = protyleElement.querySelector(".protyle-wysiwyg");
if (wysiwygElement.getAttribute("data-readonly") === "true" || !wysiwygElement.contains(event.target)) {
wysiwygElement.dispatchEvent(new Event("focusin"));
}
}
const copyElement = hasTopClosestByClassName(event.target, "protyle-action__copy");
if (copyElement) {
let text = copyElement.parentElement.nextElementSibling.textContent.replace(/\n$/, "");
text = text.replace(/\u00A0/g, " "); // Replace non-breaking spaces with normal spaces when copying https://github.com/siyuan-note/siyuan/issues/9382
writeText(text);
showMessage(window.siyuan.languages.copied, 2000);
event.preventDefault();
return;
if (!hasClosestByClassName(event.target, "pdf__outer")) {
hideAllElements(["pdfutil"]);
}
// 点击空白pdf 搜索、更多消失
@ -81,4 +86,5 @@ export const globalClick = (event: MouseEvent & { target: HTMLElement }) => {
) {
currentPDFViewerObject.findBar.close();
}
/// #endif
};