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"]);
|
hideElements(["dialog"]);
|
||||||
switchDialog = new Dialog({
|
switchDialog = new Dialog({
|
||||||
|
positionId: Constants.DIALOG_SWITCHTAB,
|
||||||
title: window.siyuan.languages.switchTab,
|
title: window.siyuan.languages.switchTab,
|
||||||
content: `<div class="fn__flex-column switch-doc">
|
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;">
|
<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);
|
range = getSelection().getRangeAt(0);
|
||||||
}
|
}
|
||||||
const dialog = new Dialog({
|
const dialog = new Dialog({
|
||||||
|
positionId: Constants.DIALOG_RECENTDOCS,
|
||||||
title: `<div class="fn__flex">
|
title: `<div class="fn__flex">
|
||||||
<div class="fn__flex-center">${window.siyuan.languages.recentDocs}</div>
|
<div class="fn__flex-center">${window.siyuan.languages.recentDocs}</div>
|
||||||
<div class="fn__flex-1"></div>
|
<div class="fn__flex-1"></div>
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,7 @@ export const makeCard = (app: App, ids: string[]) => {
|
||||||
html += genCardItem(item);
|
html += genCardItem(item);
|
||||||
});
|
});
|
||||||
const dialog = new Dialog({
|
const dialog = new Dialog({
|
||||||
|
positionId: Constants.DIALOG_MAKECARD,
|
||||||
width: isMobile() ? "92vw" : "50vw",
|
width: isMobile() ? "92vw" : "50vw",
|
||||||
height: "70vh",
|
height: "70vh",
|
||||||
title: window.siyuan.languages.riffCard,
|
title: window.siyuan.languages.riffCard,
|
||||||
|
|
|
||||||
|
|
@ -464,13 +464,11 @@ export const openCardByData = (app: App, cardsData: {
|
||||||
if (exit) {
|
if (exit) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const dialogPosition = window.siyuan.storage[Constants.LOCAL_DIALOGPOSITION][Constants.DIALOG_OPENCARD];
|
|
||||||
const dialog = new Dialog({
|
const dialog = new Dialog({
|
||||||
|
positionId: Constants.DIALOG_OPENCARD,
|
||||||
content: genCardHTML({id, cardType, cardsData, isTab: false}),
|
content: genCardHTML({id, cardType, cardsData, isTab: false}),
|
||||||
width: dialogPosition ? dialogPosition.width + "px" : (isMobile() ? "100vw" : "80vw"),
|
width: isMobile() ? "100vw" : "80vw",
|
||||||
height: dialogPosition ? dialogPosition.height + "px" : (isMobile() ? "100vh" : "70vh"),
|
height: isMobile() ? "100vh" : "70vh",
|
||||||
left: dialogPosition?.left,
|
|
||||||
top: dialogPosition?.top,
|
|
||||||
destroyCallback() {
|
destroyCallback() {
|
||||||
if (editor) {
|
if (editor) {
|
||||||
editor.destroy();
|
editor.destroy();
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ export const viewCards = (app: App, deckID: string, title: string, deckType: "Tr
|
||||||
page: pageIndex
|
page: pageIndex
|
||||||
}, (response) => {
|
}, (response) => {
|
||||||
const dialog = new Dialog({
|
const dialog = new Dialog({
|
||||||
|
positionId: Constants.DIALOG_VIEWCARDS,
|
||||||
content: `<div class="fn__flex-column" style="height: 100%">
|
content: `<div class="fn__flex-column" style="height: 100%">
|
||||||
<div class="block__icons">
|
<div class="block__icons">
|
||||||
<span class="fn__flex-1 fn__flex-center resize__move">${escapeHtml(title)}</span>
|
<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 {isMobile} from "../util/functions";
|
||||||
import {isNotCtrl} from "../protyle/util/compatibility";
|
import {isNotCtrl} from "../protyle/util/compatibility";
|
||||||
import {Protyle} from "../protyle";
|
import {Protyle} from "../protyle";
|
||||||
|
import {Constants} from "../constants";
|
||||||
|
|
||||||
export class Dialog {
|
export class Dialog {
|
||||||
private destroyCallback: (options?: IObject) => void;
|
private destroyCallback: (options?: IObject) => void;
|
||||||
|
|
@ -15,11 +16,10 @@ export class Dialog {
|
||||||
public data: any;
|
public data: any;
|
||||||
|
|
||||||
constructor(options: {
|
constructor(options: {
|
||||||
|
positionId?: string,
|
||||||
title?: string,
|
title?: string,
|
||||||
transparent?: boolean,
|
transparent?: boolean,
|
||||||
content: string,
|
content: string,
|
||||||
left?: number,
|
|
||||||
top?: number,
|
|
||||||
width?: string,
|
width?: string,
|
||||||
height?: string,
|
height?: string,
|
||||||
destroyCallback?: (options?: IObject) => void,
|
destroyCallback?: (options?: IObject) => void,
|
||||||
|
|
@ -33,10 +33,20 @@ export class Dialog {
|
||||||
window.siyuan.dialogs.push(this);
|
window.siyuan.dialogs.push(this);
|
||||||
this.destroyCallback = options.destroyCallback;
|
this.destroyCallback = options.destroyCallback;
|
||||||
this.element = document.createElement("div") as HTMLElement;
|
this.element = document.createElement("div") as HTMLElement;
|
||||||
|
let left
|
||||||
this.element.innerHTML = `<div class="b3-dialog" style="z-index: ${++window.siyuan.zIndex};${typeof options.left === "number" ? "display:block" : ""}">
|
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__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>
|
<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="resize__move b3-dialog__header${options.title ? "" : " fn__none"}" onselectstart="return false;">${options.title || ""}</div>
|
||||||
<div class="b3-dialog__body">${options.content}</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")
|
const dialogElement = hasClosestByClassName(element, "b3-dialog--open")
|
||||||
if (dialogElement) {
|
if (dialogElement) {
|
||||||
const dialogId = dialogElement.dataset.key;
|
const dialogId = dialogElement.dataset.key;
|
||||||
if (dialogId) {
|
if (dialogId && element.offsetWidth) {
|
||||||
window.siyuan.storage[Constants.LOCAL_DIALOGPOSITION][dialogId] = {
|
window.siyuan.storage[Constants.LOCAL_DIALOGPOSITION][dialogId] = {
|
||||||
width: parseInt(element.style.width),
|
width: element.offsetWidth,
|
||||||
height: parseInt(element.style.height),
|
height: element.offsetHeight,
|
||||||
left: parseInt(element.style.left),
|
left: parseInt(element.style.left),
|
||||||
top: parseInt(element.style.top),
|
top: parseInt(element.style.top),
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -80,6 +80,7 @@ export const openSearch = async (options: {
|
||||||
range = getSelection().getRangeAt(0);
|
range = getSelection().getRangeAt(0);
|
||||||
}
|
}
|
||||||
const dialog = new Dialog({
|
const dialog = new Dialog({
|
||||||
|
positionId: options.hotkey,
|
||||||
content: "",
|
content: "",
|
||||||
width: "80vw",
|
width: "80vw",
|
||||||
height: "90vh",
|
height: "90vh",
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,7 @@ export const newDailyNote = (app: App) => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const dialog = new Dialog({
|
const dialog = new Dialog({
|
||||||
|
positionId: Constants.DIALOG_DIALYNOTE,
|
||||||
title: window.siyuan.languages.plsChoose,
|
title: window.siyuan.languages.plsChoose,
|
||||||
content: `<div class="b3-dialog__content">
|
content: `<div class="b3-dialog__content">
|
||||||
<select class="b3-select fn__block">${optionsHTML}</select>
|
<select class="b3-select fn__block">${optionsHTML}</select>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue