mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-22 23:14:07 +01:00
This commit is contained in:
parent
a01ac85bdb
commit
d0700b7527
9 changed files with 80 additions and 27 deletions
|
|
@ -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
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue