Skip to content

Commit

Permalink
🎨 #13793
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanessa219 committed Jan 15, 2025
1 parent c70bf35 commit 2b22ff9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 8 additions & 3 deletions app/src/boot/globalEvent/click.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,21 @@ import {writeText} from "../../protyle/util/compatibility";
import {showMessage} from "../../dialog/message";
import {cancelDrag} from "./dragover";

export const globalClick = (event: MouseEvent & { target: HTMLElement }) => {
cancelDrag();
if (!window.siyuan.menus.menu.element.contains(event.target) && !hasClosestByAttribute(event.target, "data-menu", "true")) {
export const globalClickHideMenu = (element: HTMLElement) => {
if (!window.siyuan.menus.menu.element.contains(element) && !hasClosestByAttribute(element, "data-menu", "true")) {
if (getSelection().rangeCount > 0 && window.siyuan.menus.menu.element.contains(getSelection().getRangeAt(0).startContainer) &&
window.siyuan.menus.menu.element.contains(document.activeElement)) {
// https://ld246.com/article/1654567749834/comment/1654589171218#comments
} else {
window.siyuan.menus.menu.remove();
}
}
}

export const globalClick = (event: MouseEvent & { target: HTMLElement }) => {
cancelDrag();

globalClickHideMenu(event.target);

if (!hasClosestByClassName(event.target, "pdf__outer")) {
hideAllElements(["pdfutil"]);
Expand Down
2 changes: 2 additions & 0 deletions app/src/protyle/wysiwyg/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ import {openLink} from "../../editor/openLink";
import {mathRender} from "../render/mathRender";
import {editAssetItem} from "../render/av/asset";
import {img3115} from "../../boot/compatibleVersion";
import {globalClickHideMenu} from "../../boot/globalEvent/click";

export class WYSIWYG {
public lastHTMLs: { [key: string]: string } = {};
Expand Down Expand Up @@ -2590,6 +2591,7 @@ export class WYSIWYG {
hasClosestByClassName(event.target, "iframe");
if (!event.shiftKey && !ctrlIsPressed && selectElement) {
selectElement.classList.add("protyle-wysiwyg--select");
globalClickHideMenu(event.target);
event.stopPropagation();
return;
}
Expand Down

0 comments on commit 2b22ff9

Please sign in to comment.