mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-23 10:00:13 +01:00
This commit is contained in:
parent
b378829fe9
commit
f5ff8f74c2
9 changed files with 27 additions and 13 deletions
|
|
@ -1164,6 +1164,7 @@ export const windowKeyDown = (app: App, event: KeyboardEvent) => {
|
|||
}
|
||||
hideElements(["dialog"]);
|
||||
switchDialog = new Dialog({
|
||||
positionId: Constants.DIALOG_SWITCHTAB,
|
||||
title: window.siyuan.languages.switchTab,
|
||||
content: `<div class="fn__flex-column switch-doc">
|
||||
<input style="opacity: 0;height: 0.1px;box-sizing: border-box;margin: 0;padding: 0;border: 0;">
|
||||
|
|
|
|||
|
|
@ -83,6 +83,7 @@ export const openRecentDocs = () => {
|
|||
range = getSelection().getRangeAt(0);
|
||||
}
|
||||
const dialog = new Dialog({
|
||||
positionId: Constants.DIALOG_RECENTDOCS,
|
||||
title: `<div class="fn__flex">
|
||||
<div class="fn__flex-center">${window.siyuan.languages.recentDocs}</div>
|
||||
<div class="fn__flex-1"></div>
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ export const makeCard = (app: App, ids: string[]) => {
|
|||
html += genCardItem(item);
|
||||
});
|
||||
const dialog = new Dialog({
|
||||
positionId: Constants.DIALOG_MAKECARD,
|
||||
width: isMobile() ? "92vw" : "50vw",
|
||||
height: "70vh",
|
||||
title: window.siyuan.languages.riffCard,
|
||||
|
|
|
|||
|
|
@ -464,13 +464,11 @@ export const openCardByData = (app: App, cardsData: {
|
|||
if (exit) {
|
||||
return;
|
||||
}
|
||||
const dialogPosition = window.siyuan.storage[Constants.LOCAL_DIALOGPOSITION][Constants.DIALOG_OPENCARD];
|
||||
const dialog = new Dialog({
|
||||
positionId: Constants.DIALOG_OPENCARD,
|
||||
content: genCardHTML({id, cardType, cardsData, isTab: false}),
|
||||
width: dialogPosition ? dialogPosition.width + "px" : (isMobile() ? "100vw" : "80vw"),
|
||||
height: dialogPosition ? dialogPosition.height + "px" : (isMobile() ? "100vh" : "70vh"),
|
||||
left: dialogPosition?.left,
|
||||
top: dialogPosition?.top,
|
||||
width: isMobile() ? "100vw" : "80vw",
|
||||
height: isMobile() ? "100vh" : "70vh",
|
||||
destroyCallback() {
|
||||
if (editor) {
|
||||
editor.destroy();
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ export const viewCards = (app: App, deckID: string, title: string, deckType: "Tr
|
|||
page: pageIndex
|
||||
}, (response) => {
|
||||
const dialog = new Dialog({
|
||||
positionId: Constants.DIALOG_VIEWCARDS,
|
||||
content: `<div class="fn__flex-column" style="height: 100%">
|
||||
<div class="block__icons">
|
||||
<span class="fn__flex-1 fn__flex-center resize__move">${escapeHtml(title)}</span>
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import {moveResize} from "./moveResize";
|
|||
import {isMobile} from "../util/functions";
|
||||
import {isNotCtrl} from "../protyle/util/compatibility";
|
||||
import {Protyle} from "../protyle";
|
||||
import {Constants} from "../constants";
|
||||
|
||||
export class Dialog {
|
||||
private destroyCallback: (options?: IObject) => void;
|
||||
|
|
@ -15,11 +16,10 @@ export class Dialog {
|
|||
public data: any;
|
||||
|
||||
constructor(options: {
|
||||
positionId?: string,
|
||||
title?: string,
|
||||
transparent?: boolean,
|
||||
content: string,
|
||||
left?: number,
|
||||
top?: number,
|
||||
width?: string,
|
||||
height?: string,
|
||||
destroyCallback?: (options?: IObject) => void,
|
||||
|
|
@ -33,10 +33,20 @@ export class Dialog {
|
|||
window.siyuan.dialogs.push(this);
|
||||
this.destroyCallback = options.destroyCallback;
|
||||
this.element = document.createElement("div") as HTMLElement;
|
||||
|
||||
this.element.innerHTML = `<div class="b3-dialog" style="z-index: ${++window.siyuan.zIndex};${typeof options.left === "number" ? "display:block" : ""}">
|
||||
let left
|
||||
let top
|
||||
if (!isMobile() && options.positionId) {
|
||||
const dialogPosition = window.siyuan.storage[Constants.LOCAL_DIALOGPOSITION][options.positionId];
|
||||
if (dialogPosition) {
|
||||
left = dialogPosition.left + "px";
|
||||
top = dialogPosition.top + "px";
|
||||
options.width = dialogPosition.width + "px";
|
||||
options.height = dialogPosition.height + "px";
|
||||
}
|
||||
}
|
||||
this.element.innerHTML = `<div class="b3-dialog" style="z-index: ${++window.siyuan.zIndex};${typeof left === "string" ? "display:block" : ""}">
|
||||
<div class="b3-dialog__scrim"${options.transparent ? 'style="background-color:transparent"' : ""}></div>
|
||||
<div class="b3-dialog__container" style="width:${options.width || "auto"};height:${options.height || "auto"};left:${options.left}px;top:${options.top}px">
|
||||
<div class="b3-dialog__container" style="width:${options.width || "auto"};height:${options.height || "auto"};left:${left};top:${top}">
|
||||
<svg ${(isMobile() && options.title) ? 'style="top:0;right:0;"' : ""} class="b3-dialog__close${(this.disableClose || options.hideCloseIcon) ? " fn__none" : ""}"><use xlink:href="#iconCloseRound"></use></svg>
|
||||
<div class="resize__move b3-dialog__header${options.title ? "" : " fn__none"}" onselectstart="return false;">${options.title || ""}</div>
|
||||
<div class="b3-dialog__body">${options.content}</div>
|
||||
|
|
|
|||
|
|
@ -137,10 +137,10 @@ export const moveResize = (element: HTMLElement, afterCB?: (type: string) => voi
|
|||
const dialogElement = hasClosestByClassName(element, "b3-dialog--open")
|
||||
if (dialogElement) {
|
||||
const dialogId = dialogElement.dataset.key;
|
||||
if (dialogId) {
|
||||
if (dialogId && element.offsetWidth) {
|
||||
window.siyuan.storage[Constants.LOCAL_DIALOGPOSITION][dialogId] = {
|
||||
width: parseInt(element.style.width),
|
||||
height: parseInt(element.style.height),
|
||||
width: element.offsetWidth,
|
||||
height: element.offsetHeight,
|
||||
left: parseInt(element.style.left),
|
||||
top: parseInt(element.style.top),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -80,6 +80,7 @@ export const openSearch = async (options: {
|
|||
range = getSelection().getRangeAt(0);
|
||||
}
|
||||
const dialog = new Dialog({
|
||||
positionId: options.hotkey,
|
||||
content: "",
|
||||
width: "80vw",
|
||||
height: "90vh",
|
||||
|
|
|
|||
|
|
@ -64,6 +64,7 @@ export const newDailyNote = (app: App) => {
|
|||
}
|
||||
});
|
||||
const dialog = new Dialog({
|
||||
positionId: Constants.DIALOG_DIALYNOTE,
|
||||
title: window.siyuan.languages.plsChoose,
|
||||
content: `<div class="b3-dialog__content">
|
||||
<select class="b3-select fn__block">${optionsHTML}</select>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue