This commit is contained in:
parent
84819beaf7
commit
fbc86d6a90
6 changed files with 39 additions and 6 deletions
|
@ -52,8 +52,6 @@ Mobile #menu & .side-panel: 7
|
|||
|
||||
#windowControls: 999998
|
||||
|
||||
.b3-snackbar: 999999
|
||||
|
||||
.b3-tooltips: 1000000
|
||||
*/
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
position: fixed;
|
||||
right: 12px;
|
||||
top: 22px;
|
||||
z-index: 999999;
|
||||
// 不能设置死,否则右键菜单会被遮盖 z-index: 999999;
|
||||
max-height: calc(100vh - 32px);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
|
|
@ -46,7 +46,7 @@ export const showMessage = (message: string, timeout = 6000, type = "info", mess
|
|||
const messageVersion = message + (type === "error" ? " v" + Constants.SIYUAN_VERSION : "");
|
||||
if (existElement) {
|
||||
window.clearTimeout(parseInt(existElement.getAttribute("data-timeoutid")));
|
||||
existElement.innerHTML = `<div class="b3-snackbar__content${timeout === 0 ? " b3-snackbar__content--close" : ""}">${messageVersion}</div>${timeout === 0 ? '<svg class="b3-snackbar__close"><use xlink:href="#iconCloseRound"></use></svg>' : ""}`;
|
||||
existElement.innerHTML = `<div data-type="textMenu" class="b3-snackbar__content${timeout === 0 ? " b3-snackbar__content--close" : ""}">${messageVersion}</div>${timeout === 0 ? '<svg class="b3-snackbar__close"><use xlink:href="#iconCloseRound"></use></svg>' : ""}`;
|
||||
if (type === "error") {
|
||||
existElement.classList.add("b3-snackbar--error");
|
||||
} else {
|
||||
|
@ -60,7 +60,7 @@ export const showMessage = (message: string, timeout = 6000, type = "info", mess
|
|||
}
|
||||
return;
|
||||
}
|
||||
let messageHTML = `<div data-id="${id}" class="b3-snackbar--hide b3-snackbar${type === "error" ? " b3-snackbar--error" : ""}"><div class="b3-snackbar__content${timeout === 0 ? " b3-snackbar__content--close" : ""}">${messageVersion}</div>`;
|
||||
let messageHTML = `<div data-id="${id}" class="b3-snackbar--hide b3-snackbar${type === "error" ? " b3-snackbar--error" : ""}"><div data-type="textMenu" class="b3-snackbar__content${timeout === 0 ? " b3-snackbar__content--close" : ""}">${messageVersion}</div>`;
|
||||
if (timeout === 0) {
|
||||
messageHTML += '<svg class="b3-snackbar__close"><use xlink:href="#iconCloseRound"></use></svg>';
|
||||
} else if (timeout !== -1) { // -1 时需等待请求完成后手动关闭
|
||||
|
@ -70,6 +70,7 @@ export const showMessage = (message: string, timeout = 6000, type = "info", mess
|
|||
messageHTML = messageHTML.replace("<div data-id", `<div data-timeoutid="${timeoutId}" data-id`);
|
||||
}
|
||||
messagesElement.parentElement.classList.add("b3-snackbars--show");
|
||||
messagesElement.parentElement.style.zIndex = (++window.siyuan.zIndex).toString();
|
||||
messagesElement.insertAdjacentHTML("afterbegin", messageHTML + "</div>");
|
||||
setTimeout(() => {
|
||||
messagesElement.querySelectorAll(".b3-snackbar--hide").forEach(item => {
|
||||
|
|
|
@ -13,6 +13,7 @@ import {Menu} from "./Menu";
|
|||
import {hasClosestByClassName, hasTopClosestByTag} from "../protyle/util/hasClosest";
|
||||
import {App} from "../index";
|
||||
import {Constants} from "../constants";
|
||||
import {textMenu} from "./text";
|
||||
|
||||
|
||||
export class Menus {
|
||||
|
@ -89,7 +90,15 @@ export class Menus {
|
|||
initDockMenu(target).popup({x: event.clientX, y: event.clientY});
|
||||
event.stopPropagation();
|
||||
break;
|
||||
} else if (dataType === "textMenu") {
|
||||
/// #if !BROWSER
|
||||
textMenu(target).open({x: event.clientX, y: event.clientY});
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
break;
|
||||
/// #endif
|
||||
}
|
||||
|
||||
target = target.parentElement;
|
||||
}
|
||||
}, false);
|
||||
|
|
26
app/src/menus/text.ts
Normal file
26
app/src/menus/text.ts
Normal file
|
@ -0,0 +1,26 @@
|
|||
import {Menu} from "../plugin/Menu";
|
||||
|
||||
export const textMenu = (target: Element) => {
|
||||
const menu = new Menu();
|
||||
if (menu.isOpen) {
|
||||
return;
|
||||
}
|
||||
menu.addItem({
|
||||
label: window.siyuan.languages.copy,
|
||||
icon: "iconCopy",
|
||||
click() {
|
||||
document.execCommand("copy");
|
||||
}
|
||||
})
|
||||
menu.addItem({
|
||||
label: window.siyuan.languages.selectAll,
|
||||
icon: "iconSelect",
|
||||
click() {
|
||||
if (getSelection().rangeCount === 0) {
|
||||
return;
|
||||
}
|
||||
getSelection().getRangeAt(0).selectNode(target)
|
||||
}
|
||||
})
|
||||
return menu
|
||||
}
|
|
@ -31,7 +31,6 @@ export const exportAsset = (src: string) => {
|
|||
/// #endif
|
||||
};
|
||||
|
||||
|
||||
export const openEditorTab = (app: App, ids: string[], notebookId?: string, pathString?: string) => {
|
||||
/// #if !MOBILE
|
||||
const openSubmenus: IMenu[] = [{
|
||||
|
|
Loading…
Add table
Reference in a new issue