mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-03 07:18:49 +01:00
This commit is contained in:
parent
df3ee3f24e
commit
67b81bfaad
15 changed files with 117 additions and 6 deletions
|
|
@ -1,5 +1,8 @@
|
|||
document.body.insertAdjacentHTML('afterBegin', `<svg style="position: absolute; width: 0; height: 0; overflow: hidden;" xmlns="http://www.w3.org/2000/svg">
|
||||
<defs>
|
||||
<symbol id="iconLayout" viewBox="0 0 32 32">
|
||||
<path d="M29.8 1h-27.6c-0.664 0-1.2 0.536-1.2 1.2v27.6c0 0.664 0.536 1.2 1.2 1.2h27.6c0.664 0 1.2-0.536 1.2-1.2v-27.6c0-0.664-0.536-1.2-1.2-1.2zM3.7 3.7h5.1v24.6h-5.1v-24.6zM28.3 28.3h-17.1v-17.1h17.1v17.1zM11.2 8.8v-5.1h17.1v5.1h-17.1z"></path>
|
||||
</symbol>
|
||||
<symbol id="iconFullscreen" viewBox="0 0 32 32">
|
||||
<path d="M6.541 4.258l1.87-1.87c0.061-0.062 0.099-0.147 0.099-0.241 0-0.174-0.13-0.317-0.298-0.339l-0.002-0-6.826-0.805c-0.217-0.026-0.405 0.158-0.379 0.379l0.805 6.826c0.034 0.281 0.379 0.401 0.579 0.2l1.862-1.862 5.697 5.692c0.132 0.132 0.349 0.132 0.481 0l1.807-1.802c0.132-0.132 0.132-0.349 0-0.481l-5.697-5.697zM21.569 12.238c0.132 0.132 0.349 0.132 0.481 0l5.697-5.692 1.862 1.862c0.062 0.061 0.147 0.099 0.241 0.099 0.174 0 0.317-0.13 0.339-0.298l0-0.002 0.805-6.821c0.026-0.217-0.158-0.405-0.379-0.379l-6.826 0.805c-0.281 0.034-0.401 0.379-0.2 0.579l1.87 1.87-5.697 5.688c-0.061 0.062-0.099 0.147-0.099 0.241s0.038 0.179 0.099 0.241l1.806 1.806zM30.188 23.793c-0.034-0.281-0.379-0.401-0.579-0.2l-1.862 1.862-5.697-5.692c-0.062-0.061-0.147-0.099-0.241-0.099s-0.179 0.038-0.241 0.099l0-0-1.807 1.802c-0.061 0.062-0.099 0.147-0.099 0.241s0.038 0.179 0.099 0.241l5.697 5.697-1.87 1.87c-0.061 0.062-0.099 0.147-0.099 0.241 0 0.174 0.13 0.317 0.298 0.339l0.002 0 6.826 0.805c0.217 0.026 0.405-0.158 0.379-0.379l-0.805-6.826zM10.431 19.762c-0.062-0.061-0.147-0.099-0.241-0.099s-0.179 0.038-0.241 0.099l-5.697 5.692-1.862-1.862c-0.062-0.061-0.147-0.099-0.241-0.099-0.174 0-0.317 0.13-0.339 0.298l-0 0.002-0.805 6.821c-0.026 0.217 0.158 0.405 0.379 0.379l6.826-0.805c0.281-0.034 0.401-0.379 0.2-0.579l-1.87-1.866 5.697-5.692c0.132-0.132 0.132-0.349 0-0.481l-1.807-1.807z"></path>
|
||||
</symbol>
|
||||
|
|
|
|||
|
|
@ -2,5 +2,5 @@
|
|||
"name": "ant",
|
||||
"author": "Vanessa",
|
||||
"url": "https://github.com/Vanessa219",
|
||||
"version": "1.15.1"
|
||||
"version": "1.16.1"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,6 +28,12 @@
|
|||
<body>
|
||||
<h2>SiYuan</h2>
|
||||
<div class="fn__clear">
|
||||
<div>
|
||||
<svg>
|
||||
<use xlink:href="#iconLayout"></use>
|
||||
</svg>
|
||||
iconLayout
|
||||
</div>
|
||||
<div>
|
||||
<svg>
|
||||
<use xlink:href="#iconFullscreenExit"></use>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
document.body.insertAdjacentHTML('afterbegin', `<svg style="position: absolute; width: 0; height: 0; overflow: hidden;" xmlns="http://www.w3.org/2000/svg">
|
||||
<defs>
|
||||
<symbol id="iconLayout" viewBox="0 0 32 32">
|
||||
<path d="M3.5 31q-1 0-1.75-0.75t-0.75-1.75v-25q0-1 0.75-1.75t1.75-0.75h25q1 0 1.75 0.75t0.75 1.75v25q0 1-0.75 1.75t-1.75 0.75zM3.5 28.5h11.25v-25h-11.25v25zM17.25 28.5h11.25v-12.542h-11.25zM17.25 13.458h11.25v-9.958h-11.25z"></path>
|
||||
</symbol>
|
||||
<symbol id="iconFullscreenExit" viewBox="0 0 32 32">
|
||||
<path d="M8.125 31v-7.125h-7.125v-3.214h10.339v10.339zM20.661 31v-10.339h10.339v3.214h-7.125v7.125zM1 11.339v-3.214h7.125v-7.125h3.214v10.339zM20.661 11.339v-10.339h3.214v7.125h7.125v3.214z"></path>
|
||||
</symbol>
|
||||
|
|
|
|||
|
|
@ -2,5 +2,5 @@
|
|||
"name": "material",
|
||||
"author": "Vanessa",
|
||||
"url": "https://github.com/Vanessa219",
|
||||
"version": "1.15.1"
|
||||
"version": "1.16.1"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
"saveLayout": "Save Layout",
|
||||
"ai": "Artificial Intelligence",
|
||||
"aiContinueWrite": "Continue writing",
|
||||
"aiTranslate": "Translate",
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
"saveLayout": "Guardar diseño",
|
||||
"ai": "Inteligencia Artificial",
|
||||
"aiContinueWrite": "Continuar escribiendo",
|
||||
"aiTranslate": "Traducir",
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
"saveLayout": "Enregistrer la mise en page",
|
||||
"ai": "Intelligence Artificielle",
|
||||
"aiContinueWrite": "Continuer à écrire",
|
||||
"aiTranslate": "Traduire",
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
"saveLayout": "保存佈局",
|
||||
"ai": "人工智能",
|
||||
"aiContinueWrite": "續寫",
|
||||
"aiTranslate": "翻譯",
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
"saveLayout": "保存布局",
|
||||
"ai": "人工智能",
|
||||
"aiContinueWrite": "续写",
|
||||
"aiTranslate": "翻译",
|
||||
|
|
|
|||
|
|
@ -78,6 +78,7 @@ export abstract class Constants {
|
|||
public static readonly LOCAL_EXPORTIMG = "local-exportimg";
|
||||
public static readonly LOCAL_BAZAAR = "local-bazaar";
|
||||
public static readonly LOCAL_PDFTHEME = "local-pdftheme";
|
||||
public static readonly LOCAL_LAYOUTS = "local-layouts";
|
||||
|
||||
// timeout
|
||||
public static readonly TIMEOUT_DBLCLICK = 190;
|
||||
|
|
|
|||
|
|
@ -145,7 +145,7 @@ export const resetLayout = () => {
|
|||
});
|
||||
};
|
||||
|
||||
export const exportLayout = (reload: boolean, cb?: () => void) => {
|
||||
export const exportLayout = (reload: boolean, cb?: () => void, onlyData = false) => {
|
||||
const useElement = document.querySelector("#barDock use");
|
||||
if (!useElement) {
|
||||
return;
|
||||
|
|
@ -158,7 +158,10 @@ export const exportLayout = (reload: boolean, cb?: () => void) => {
|
|||
right: dockToJSON(window.siyuan.layout.rightDock),
|
||||
};
|
||||
layoutToJSON(window.siyuan.layout.layout, layoutJSON.layout);
|
||||
fetchPost("/api/system/setUILayout", {layout: layoutJSON, exit: typeof cb !== "undefined"}, () => {
|
||||
if (onlyData) {
|
||||
return layoutJSON;
|
||||
}
|
||||
fetchPost("/api/system/setUILayout", {layout: layoutJSON}, () => {
|
||||
if (reload) {
|
||||
window.location.reload();
|
||||
} else if (cb) {
|
||||
|
|
|
|||
|
|
@ -12,13 +12,15 @@ import {setStorageVal, writeText} from "../protyle/util/compatibility";
|
|||
import {openCard} from "../card/openCard";
|
||||
import {openSetting} from "../config";
|
||||
import {getAllDocks} from "../layout/getAll";
|
||||
import {getDockByType} from "../layout/util";
|
||||
import {exportLayout, getDockByType} from "../layout/util";
|
||||
import {lockScreen} from "../dialog/processSystem";
|
||||
import {showMessage} from "../dialog/message";
|
||||
import {unicode2Emoji} from "../emoji";
|
||||
import {Dock} from "../layout/dock";
|
||||
import {escapeHtml} from "../util/escape";
|
||||
import {viewCards} from "../card/viewCards";
|
||||
import {Dialog} from "../dialog";
|
||||
import {hasClosestByClassName} from "../protyle/util/hasClosest";
|
||||
|
||||
const togglePinDock = (dock: Dock, icon: string) => {
|
||||
return {
|
||||
|
|
@ -101,6 +103,88 @@ export const workspaceMenu = (rect: DOMRect) => {
|
|||
}).element);
|
||||
}
|
||||
/// #endif
|
||||
const layoutSubMenu: IMenu[] = [{
|
||||
iconHTML: Constants.ZWSP,
|
||||
label: window.siyuan.languages.saveLayout,
|
||||
click() {
|
||||
const saveDialog = new Dialog({
|
||||
title: window.siyuan.languages.saveLayout,
|
||||
content: `<div class="b3-dialog__content">
|
||||
<input class="b3-text-field fn__block" placeholder="${window.siyuan.languages.memo}">
|
||||
</div>
|
||||
<div class="b3-dialog__action">
|
||||
<button class="b3-button b3-button--cancel">${window.siyuan.languages.cancel}</button><div class="fn__space"></div>
|
||||
<button class="b3-button b3-button--text">${window.siyuan.languages.confirm}</button>
|
||||
</div>`,
|
||||
width: "520px",
|
||||
});
|
||||
const btnsElement = saveDialog.element.querySelectorAll(".b3-button");
|
||||
saveDialog.bindInput(saveDialog.element.querySelector("input"), () => {
|
||||
btnsElement[1].dispatchEvent(new CustomEvent("click"));
|
||||
});
|
||||
btnsElement[0].addEventListener("click", () => {
|
||||
saveDialog.destroy();
|
||||
});
|
||||
btnsElement[1].addEventListener("click", () => {
|
||||
const value = saveDialog.element.querySelector("input").value;
|
||||
if (!value) {
|
||||
showMessage(window.siyuan.languages["_kernel"]["142"]);
|
||||
return;
|
||||
}
|
||||
const hadName = window.siyuan.storage[Constants.LOCAL_LAYOUTS].find((item: ISaveLayout) => {
|
||||
if (item.name === value) {
|
||||
showMessage(window.siyuan.languages.duplicate);
|
||||
return true;
|
||||
}
|
||||
})
|
||||
if (hadName) {
|
||||
return;
|
||||
}
|
||||
window.siyuan.storage[Constants.LOCAL_LAYOUTS].push({
|
||||
name: value,
|
||||
layout: exportLayout(false, undefined, true)
|
||||
})
|
||||
setStorageVal(Constants.LOCAL_LAYOUTS, window.siyuan.storage[Constants.LOCAL_LAYOUTS]);
|
||||
saveDialog.destroy();
|
||||
});
|
||||
}
|
||||
}];
|
||||
window.siyuan.storage[Constants.LOCAL_LAYOUTS].forEach((item: ISaveLayout) => {
|
||||
layoutSubMenu.push({
|
||||
iconHTML: Constants.ZWSP,
|
||||
label: `<div class="fn__flex">
|
||||
<span class="fn__flex-1">${item.name}</span>
|
||||
<span class="fn__space"></span>
|
||||
<svg class="b3-menu__icon fn__a" style="width: 8px"><use xlink:href="#iconClose"></use></svg>
|
||||
</div>`,
|
||||
bind(menuElement) {
|
||||
menuElement.addEventListener("click", (event) => {
|
||||
if (hasClosestByClassName(event.target as HTMLElement, "fn__a")) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
window.siyuan.storage[Constants.LOCAL_LAYOUTS].find((layoutItem: ISaveLayout, index: number) => {
|
||||
if (layoutItem.name === item.name) {
|
||||
menuElement.remove();
|
||||
window.siyuan.storage[Constants.LOCAL_LAYOUTS].splice(index, 1);
|
||||
setStorageVal(Constants.LOCAL_LAYOUTS, window.siyuan.storage[Constants.LOCAL_LAYOUTS]);
|
||||
return true;
|
||||
}
|
||||
})
|
||||
return;
|
||||
}
|
||||
fetchPost("/api/system/setUILayout", {layout: item.layout}, () => {
|
||||
window.location.reload();
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
label: window.siyuan.languages.layout,
|
||||
icon: "iconLayout",
|
||||
type: "submenu",
|
||||
submenu: layoutSubMenu
|
||||
}).element);
|
||||
window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);
|
||||
if (!window.siyuan.config.readonly) {
|
||||
if (getOpenNotebookCount() < 2) {
|
||||
|
|
|
|||
|
|
@ -155,6 +155,7 @@ export const getLocalStorage = (cb: () => void) => {
|
|||
layoutTab: 0
|
||||
};
|
||||
defaultStorage[Constants.LOCAL_PDFTHEME] = {light: "light", dark: "dark", annoColor: "var(--b3-pdf-background1)"};
|
||||
defaultStorage[Constants.LOCAL_LAYOUTS] = []; // {name: "", layout:{}}
|
||||
defaultStorage[Constants.LOCAL_BAZAAR] = {
|
||||
theme: "0",
|
||||
template: "0",
|
||||
|
|
@ -208,7 +209,7 @@ export const getLocalStorage = (cb: () => void) => {
|
|||
|
||||
[Constants.LOCAL_EXPORTIMG, Constants.LOCAL_SEARCHEKEYS, Constants.LOCAL_PDFTHEME, Constants.LOCAL_BAZAAR, Constants.LOCAL_EXPORTWORD,
|
||||
Constants.LOCAL_EXPORTPDF, Constants.LOCAL_DOCINFO, Constants.LOCAL_FONTSTYLES, Constants.LOCAL_SEARCHEDATA,
|
||||
Constants.LOCAL_ZOOM, Constants.LOCAL_SEARCHEKEY].forEach((key) => {
|
||||
Constants.LOCAL_ZOOM, Constants.LOCAL_SEARCHEKEY, Constants.LOCAL_LAYOUTS].forEach((key) => {
|
||||
if (typeof response.data[key] === "string") {
|
||||
try {
|
||||
window.siyuan.storage[key] = Object.assign(defaultStorage[key], JSON.parse(response.data[key]));
|
||||
|
|
|
|||
5
app/src/types/index.d.ts
vendored
5
app/src/types/index.d.ts
vendored
|
|
@ -56,6 +56,11 @@ interface Window {
|
|||
openFileByURL(URL: string): boolean
|
||||
}
|
||||
|
||||
interface ISaveLayout {
|
||||
name: string,
|
||||
layout: IObject
|
||||
}
|
||||
|
||||
interface IWorkspace {
|
||||
path: string
|
||||
closed: boolean
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue