diff --git a/app/src/menus/workspace.ts b/app/src/menus/workspace.ts
index a00d8d09d..a727b7e21 100644
--- a/app/src/menus/workspace.ts
+++ b/app/src/menus/workspace.ts
@@ -34,9 +34,10 @@ const editLayout = (layoutName?: string) => {
-
+
-
+
+
`,
width: "520px",
});
@@ -46,12 +47,37 @@ const editLayout = (layoutName?: string) => {
inputElement.select();
inputElement.focus();
dialog.bindInput(inputElement, () => {
- btnsElement[2].dispatchEvent(new CustomEvent("click"));
+ btnsElement[3].dispatchEvent(new CustomEvent("click"));
+ });
+ btnsElement[0].addEventListener("click", () => {
+ window.siyuan.storage[Constants.LOCAL_LAYOUTS].find((layoutItem: ISaveLayout, index: number) => {
+ if (layoutItem.name === layoutName) {
+ window.siyuan.storage[Constants.LOCAL_LAYOUTS].splice(index, 1);
+ setStorageVal(Constants.LOCAL_LAYOUTS, window.siyuan.storage[Constants.LOCAL_LAYOUTS]);
+ return true;
+ }
+ });
+ dialog.destroy();
});
btnsElement[1].addEventListener("click", () => {
dialog.destroy();
});
btnsElement[2].addEventListener("click", () => {
+ const value = inputElement.value;
+ if (!value) {
+ showMessage(window.siyuan.languages["_kernel"]["142"]);
+ return;
+ }
+ dialog.destroy();
+ window.siyuan.storage[Constants.LOCAL_LAYOUTS].find((layoutItem: ISaveLayout) => {
+ if (layoutItem.name === layoutName) {
+ layoutItem.name = value;
+ setStorageVal(Constants.LOCAL_LAYOUTS, window.siyuan.storage[Constants.LOCAL_LAYOUTS]);
+ return true;
+ }
+ });
+ });
+ btnsElement[3].addEventListener("click", () => {
const value = inputElement.value;
if (!value) {
showMessage(window.siyuan.languages["_kernel"]["142"]);
@@ -88,16 +114,6 @@ const editLayout = (layoutName?: string) => {
});
setStorageVal(Constants.LOCAL_LAYOUTS, window.siyuan.storage[Constants.LOCAL_LAYOUTS]);
});
- btnsElement[0].addEventListener("click", () => {
- window.siyuan.storage[Constants.LOCAL_LAYOUTS].find((layoutItem: ISaveLayout, index: number) => {
- if (layoutItem.name === layoutName) {
- window.siyuan.storage[Constants.LOCAL_LAYOUTS].splice(index, 1);
- setStorageVal(Constants.LOCAL_LAYOUTS, window.siyuan.storage[Constants.LOCAL_LAYOUTS]);
- return true;
- }
- });
- dialog.destroy();
- });
};
const togglePinDock = (dock: Dock, icon: string) => {