mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-18 23:50:13 +01:00
This commit is contained in:
parent
96a03115f1
commit
fb9d45e7c2
3 changed files with 28 additions and 34 deletions
|
|
@ -998,7 +998,7 @@ class="b3-list-item b3-list-item--hide-action" data-path="${item.path}">
|
||||||
}
|
}
|
||||||
}).element);
|
}).element);
|
||||||
if (!window.siyuan.config.readonly) {
|
if (!window.siyuan.config.readonly) {
|
||||||
sortMenu("notebooks", window.siyuan.config.fileTree.sort, (sort: number) => {
|
const subMenu = sortMenu("notebooks", window.siyuan.config.fileTree.sort, (sort: number) => {
|
||||||
window.siyuan.config.fileTree.sort = sort;
|
window.siyuan.config.fileTree.sort = sort;
|
||||||
fetchPost("/api/setting/setFiletree", {
|
fetchPost("/api/setting/setFiletree", {
|
||||||
sort: window.siyuan.config.fileTree.sort,
|
sort: window.siyuan.config.fileTree.sort,
|
||||||
|
|
@ -1013,6 +1013,12 @@ class="b3-list-item b3-list-item--hide-action" data-path="${item.path}">
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
window.siyuan.menus.menu.append(new MenuItem({
|
||||||
|
icon: "iconSort",
|
||||||
|
label: window.siyuan.languages.sort,
|
||||||
|
type: "submenu",
|
||||||
|
submenu:subMenu,
|
||||||
|
}).element);
|
||||||
}
|
}
|
||||||
return window.siyuan.menus.menu;
|
return window.siyuan.menus.menu;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ export const initNavigationMenu = (liElement: HTMLElement) => {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}).element);
|
}).element);
|
||||||
sortMenu("notebook", parseInt(liElement.parentElement.getAttribute("data-sortmode")), (sort) => {
|
const subMenu = sortMenu("notebook", parseInt(liElement.parentElement.getAttribute("data-sortmode")), (sort) => {
|
||||||
fetchPost("/api/notebook/setNotebookConf", {
|
fetchPost("/api/notebook/setNotebookConf", {
|
||||||
notebook: notebookId,
|
notebook: notebookId,
|
||||||
conf: {
|
conf: {
|
||||||
|
|
@ -117,6 +117,12 @@ export const initNavigationMenu = (liElement: HTMLElement) => {
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
window.siyuan.menus.menu.append(new MenuItem({
|
||||||
|
icon: "iconSort",
|
||||||
|
label: window.siyuan.languages.sort,
|
||||||
|
type: "submenu",
|
||||||
|
submenu: subMenu,
|
||||||
|
}).element);
|
||||||
}
|
}
|
||||||
window.siyuan.menus.menu.append(new MenuItem({
|
window.siyuan.menus.menu.append(new MenuItem({
|
||||||
label: window.siyuan.languages.riffCard,
|
label: window.siyuan.languages.riffCard,
|
||||||
|
|
@ -514,7 +520,7 @@ const genImportMenu = (notebookId: string, pathString: string) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const sortMenu = (type: "notebooks" | "notebook", sortMode: number, clickEvent: (sort: number) => void) => {
|
export const sortMenu = (type: "notebooks" | "notebook", sortMode: number, clickEvent: (sort: number) => void) => {
|
||||||
const submenu: IMenu[] = [{
|
const sortMenu: IMenu[] = [{
|
||||||
icon: sortMode === 0 ? "iconSelect" : undefined,
|
icon: sortMode === 0 ? "iconSelect" : undefined,
|
||||||
label: window.siyuan.languages.fileNameASC,
|
label: window.siyuan.languages.fileNameASC,
|
||||||
click: () => {
|
click: () => {
|
||||||
|
|
@ -606,7 +612,7 @@ export const sortMenu = (type: "notebooks" | "notebook", sortMode: number, click
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
if (type === "notebook") {
|
if (type === "notebook") {
|
||||||
submenu.push({
|
sortMenu.push({
|
||||||
icon: sortMode === 15 ? "iconSelect" : undefined,
|
icon: sortMode === 15 ? "iconSelect" : undefined,
|
||||||
label: window.siyuan.languages.sortByFiletree,
|
label: window.siyuan.languages.sortByFiletree,
|
||||||
click: () => {
|
click: () => {
|
||||||
|
|
@ -614,10 +620,5 @@ export const sortMenu = (type: "notebooks" | "notebook", sortMode: number, click
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
window.siyuan.menus.menu.append(new MenuItem({
|
return sortMenu;
|
||||||
icon: "iconSort",
|
|
||||||
label: window.siyuan.languages.sort,
|
|
||||||
type: "submenu",
|
|
||||||
submenu,
|
|
||||||
}).element);
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ import {unicode2Emoji} from "../../emoji";
|
||||||
import {mountHelp, newNotebook} from "../../util/mount";
|
import {mountHelp, newNotebook} from "../../util/mount";
|
||||||
import {confirmDialog} from "../../dialog/confirmDialog";
|
import {confirmDialog} from "../../dialog/confirmDialog";
|
||||||
import {newFile} from "../../util/newFile";
|
import {newFile} from "../../util/newFile";
|
||||||
import {isMobile} from "../../util/functions";
|
import {MenuItem} from "../../menus/Menu";
|
||||||
|
|
||||||
export class MobileFiles extends Model {
|
export class MobileFiles extends Model {
|
||||||
public element: HTMLElement;
|
public element: HTMLElement;
|
||||||
|
|
@ -118,7 +118,7 @@ export class MobileFiles extends Model {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
break;
|
break;
|
||||||
} else if (type === "sort") {
|
} else if (type === "sort") {
|
||||||
this.genSort(event);
|
this.genSort();
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
break;
|
break;
|
||||||
|
|
@ -167,8 +167,6 @@ export class MobileFiles extends Model {
|
||||||
} else if (target.classList.contains("b3-list-item__action")) {
|
} else if (target.classList.contains("b3-list-item__action")) {
|
||||||
const type = target.getAttribute("data-type");
|
const type = target.getAttribute("data-type");
|
||||||
const pathString = target.parentElement.getAttribute("data-path");
|
const pathString = target.parentElement.getAttribute("data-path");
|
||||||
const x = (event instanceof TouchEvent) ? event.touches[0].clientX : event.clientX;
|
|
||||||
const y = (event instanceof TouchEvent) ? event.touches[0].clientY : event.clientY;
|
|
||||||
const ulElement = hasTopClosestByTag(target, "UL");
|
const ulElement = hasTopClosestByTag(target, "UL");
|
||||||
if (ulElement) {
|
if (ulElement) {
|
||||||
const notebookId = ulElement.getAttribute("data-url");
|
const notebookId = ulElement.getAttribute("data-url");
|
||||||
|
|
@ -176,28 +174,14 @@ export class MobileFiles extends Model {
|
||||||
if (type === "new") {
|
if (type === "new") {
|
||||||
newFile(notebookId, pathString);
|
newFile(notebookId, pathString);
|
||||||
} else if (type === "more-root") {
|
} else if (type === "more-root") {
|
||||||
initNavigationMenu(target.parentElement)
|
initNavigationMenu(target.parentElement);
|
||||||
if (isMobile()) {
|
window.siyuan.menus.menu.fullscreen("bottom");
|
||||||
window.siyuan.menus.menu.fullscreen("bottom");
|
|
||||||
} else {
|
|
||||||
window.siyuan.menus.menu.popup({
|
|
||||||
x,
|
|
||||||
y
|
|
||||||
});
|
|
||||||
}
|
|
||||||
window.siyuan.menus.menu.element.style.zIndex = "310";
|
window.siyuan.menus.menu.element.style.zIndex = "310";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (type === "more-file") {
|
if (type === "more-file") {
|
||||||
initFileMenu(notebookId, pathString, target.parentElement);
|
initFileMenu(notebookId, pathString, target.parentElement);
|
||||||
if (isMobile()) {
|
window.siyuan.menus.menu.fullscreen("bottom");
|
||||||
window.siyuan.menus.menu.fullscreen("bottom");
|
|
||||||
} else {
|
|
||||||
window.siyuan.menus.menu.popup({
|
|
||||||
x,
|
|
||||||
y
|
|
||||||
});
|
|
||||||
}
|
|
||||||
window.siyuan.menus.menu.element.style.zIndex = "310";
|
window.siyuan.menus.menu.element.style.zIndex = "310";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -227,9 +211,9 @@ export class MobileFiles extends Model {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private genSort(event: MouseEvent) {
|
private genSort() {
|
||||||
window.siyuan.menus.menu.remove();
|
window.siyuan.menus.menu.remove();
|
||||||
sortMenu("notebooks", window.siyuan.config.fileTree.sort, (sort: number) => {
|
const subMenu = sortMenu("notebooks", window.siyuan.config.fileTree.sort, (sort: number) => {
|
||||||
window.siyuan.config.fileTree.sort = sort;
|
window.siyuan.config.fileTree.sort = sort;
|
||||||
fetchPost("/api/setting/setFiletree", {
|
fetchPost("/api/setting/setFiletree", {
|
||||||
sort: window.siyuan.config.fileTree.sort,
|
sort: window.siyuan.config.fileTree.sort,
|
||||||
|
|
@ -244,8 +228,11 @@ export class MobileFiles extends Model {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
subMenu.forEach((item) => {
|
||||||
|
window.siyuan.menus.menu.append(new MenuItem(item).element);
|
||||||
|
});
|
||||||
|
window.siyuan.menus.menu.fullscreen("bottom");
|
||||||
window.siyuan.menus.menu.element.style.zIndex = "310";
|
window.siyuan.menus.menu.element.style.zIndex = "310";
|
||||||
window.siyuan.menus.menu.popup({x: event.clientX, y: event.clientY});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private genNotebook(item: INotebook) {
|
private genNotebook(item: INotebook) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue