This commit is contained in:
parent
07e572f46c
commit
52cdc67f19
9 changed files with 64 additions and 33 deletions
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
"currentNotebook": "Current Notebook",
|
||||
"containerBlockTip1": "Enabling container blocks will result in duplicate search results",
|
||||
"containerBlockTip2": "Enabling document blocks currently only supports searching for document titles",
|
||||
"copyAsPNG": "Copy as PNG",
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
"currentNotebook": "Cuaderno actual",
|
||||
"containerBlockTip1": "Habilitar bloques de contenedores generará resultados de búsqueda duplicados",
|
||||
"containerBlockTip2": "Habilitar bloques de documentos actualmente solo admite la búsqueda de títulos de documentos",
|
||||
"copyAsPNG": "Copiar como PNG",
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
"currentNotebook": "Carnet actuel",
|
||||
"containerBlockTip1": "L'activation des blocs de conteneurs entraînera des résultats de recherche en double",
|
||||
"containerBlockTip2": "L'activation des blocs de documents ne prend actuellement en charge que la recherche de titres de documents",
|
||||
"copyAsPNG": "Copier en tant PNG",
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
"currentNotebook": "目前筆記本",
|
||||
"containerBlockTip1": "啟用容器區塊後會導致搜尋結果重複",
|
||||
"containerBlockTip2": "啟用文件區塊目前僅支援搜尋文件名稱",
|
||||
"copyAsPNG": "複製為 PNG",
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
"currentNotebook": "当前笔记本",
|
||||
"containerBlockTip1": "启用容器块后会导致搜索结果重复",
|
||||
"containerBlockTip2": "启用文档块目前仅支持搜索文档名",
|
||||
"copyAsPNG": "复制为 PNG",
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import {fetchPost} from "../util/fetch";
|
||||
import {genNotebookOption} from "../menus/onGetnotebookconf";
|
||||
|
||||
export const fileTree = {
|
||||
element: undefined as Element,
|
||||
|
@ -51,22 +52,6 @@ export const fileTree = {
|
|||
<span class="fn__space"></span>
|
||||
<input class="b3-switch fn__flex-center" id="useSingleLineSave" type="checkbox"${window.siyuan.config.fileTree.useSingleLineSave ? " checked" : ""}/>
|
||||
</label>
|
||||
<div class="fn__flex b3-label config__item">
|
||||
<div class="fn__flex-1">
|
||||
${window.siyuan.languages.fileTree12}
|
||||
<div class="b3-label__text">${window.siyuan.languages.fileTree13}</div>
|
||||
</div>
|
||||
<span class="fn__space"></span>
|
||||
<input class="b3-text-field fn__flex-center fn__size200" id="docCreateSavePath" value="">
|
||||
</div>
|
||||
<div class="b3-label fn__flex config__item">
|
||||
<div class="fn__flex-1">
|
||||
${window.siyuan.languages.fileTree5}
|
||||
<div class="b3-label__text">${window.siyuan.languages.fileTree6}</div>
|
||||
</div>
|
||||
<span class="fn__space"></span>
|
||||
<input class="b3-text-field fn__flex-center fn__size200" id="refCreateSavePath" value="${window.siyuan.config.fileTree.refCreateSavePath}">
|
||||
</div>
|
||||
<div class="fn__flex b3-label config__item">
|
||||
<div class="fn__flex-1">
|
||||
${window.siyuan.languages.fileTree16}
|
||||
|
@ -82,6 +67,26 @@ export const fileTree = {
|
|||
</div>
|
||||
<span class="fn__space"></span>
|
||||
<input class="b3-text-field fn__flex-center fn__size200" id="maxOpenTabCount" type="number" min="1" max="32" value="${window.siyuan.config.fileTree.maxOpenTabCount}">
|
||||
</div>
|
||||
<div class="b3-label config__item">
|
||||
${window.siyuan.languages.fileTree12}
|
||||
<div class="b3-label__text">${window.siyuan.languages.fileTree13}</div>
|
||||
<span class="fn__hr"></span>
|
||||
<div class="fn__flex">
|
||||
<select style="min-width: 200px" class="b3-select" id="docCreateSaveBox">${genNotebookOption(window.siyuan.config.fileTree.docCreateSaveBox)}</select>
|
||||
<div class="fn__space"></div>
|
||||
<input class="b3-text-field fn__flex-1" id="docCreateSavePath" value="">
|
||||
</div>
|
||||
</div>
|
||||
<div class="b3-label config__item">
|
||||
${window.siyuan.languages.fileTree5}
|
||||
<div class="b3-label__text">${window.siyuan.languages.fileTree6}</div>
|
||||
<span class="fn__hr"></span>
|
||||
<div class="fn__flex">
|
||||
<select style="min-width: 200px" class="b3-select" id="refCreateSaveBox">${genNotebookOption(window.siyuan.config.fileTree.refCreateSaveBox)}</select>
|
||||
<div class="fn__space"></div>
|
||||
<input class="b3-text-field fn__flex-1" id="refCreateSavePath" value="${window.siyuan.config.fileTree.refCreateSavePath}">
|
||||
</div>
|
||||
</div>`;
|
||||
},
|
||||
_send() {
|
||||
|
@ -100,7 +105,9 @@ export const fileTree = {
|
|||
sort: window.siyuan.config.fileTree.sort,
|
||||
alwaysSelectOpenedFile: (fileTree.element.querySelector("#alwaysSelectOpenedFile") as HTMLInputElement).checked,
|
||||
refCreateSavePath: (fileTree.element.querySelector("#refCreateSavePath") as HTMLInputElement).value,
|
||||
refCreateSaveBox: (fileTree.element.querySelector("#refCreateSaveBox") as HTMLInputElement).value,
|
||||
docCreateSavePath: (fileTree.element.querySelector("#docCreateSavePath") as HTMLInputElement).value,
|
||||
docCreateSaveBox: (fileTree.element.querySelector("#docCreateSaveBox") as HTMLInputElement).value,
|
||||
openFilesUseCurrentTab: (fileTree.element.querySelector("#openFilesUseCurrentTab") as HTMLInputElement).checked,
|
||||
closeTabsOnStart: (fileTree.element.querySelector("#closeTabsOnStart") as HTMLInputElement).checked,
|
||||
allowCreateDeeper: (fileTree.element.querySelector("#allowCreateDeeper") as HTMLInputElement).checked,
|
||||
|
@ -115,7 +122,7 @@ export const fileTree = {
|
|||
bindEvent: () => {
|
||||
(fileTree.element.querySelector("#docCreateSavePath") as HTMLInputElement).value = window.siyuan.config.fileTree.docCreateSavePath;
|
||||
(fileTree.element.querySelector("#refCreateSavePath") as HTMLInputElement).value = window.siyuan.config.fileTree.refCreateSavePath;
|
||||
fileTree.element.querySelectorAll("input").forEach((item) => {
|
||||
fileTree.element.querySelectorAll("input, select").forEach((item) => {
|
||||
item.addEventListener("change", () => {
|
||||
fileTree._send();
|
||||
});
|
||||
|
|
|
@ -14,32 +14,47 @@ declare interface INotebookConf {
|
|||
refCreateSavePath: string
|
||||
docCreateSavePath: string
|
||||
dailyNoteSavePath: string
|
||||
refCreateSaveBox: string;
|
||||
docCreateSaveBox: string;
|
||||
dailyNoteTemplatePath: string
|
||||
}
|
||||
}
|
||||
|
||||
export const genNotebookOption = (id: string) => {
|
||||
let html = `<option value="">${window.siyuan.languages.currentNotebook}</option>`;
|
||||
window.siyuan.notebooks.forEach((item) => {
|
||||
html += `<option value="${item.id}" ${id === item.id ? "selected" : ""}>${item.name}</option>`;
|
||||
});
|
||||
return html;
|
||||
}
|
||||
|
||||
export const onGetnotebookconf = (data: INotebookConf) => {
|
||||
const titleHTML = `<div class="fn__flex">${escapeHtml(data.name)}
|
||||
<div class="fn__space"></div>
|
||||
<button class="b3-button b3-button--small">${window.siyuan.languages.copy} ID</button></div>`;
|
||||
const contentHTML = `<div class="b3-dialog__content" style="background-color: var(--b3-theme-background);">
|
||||
<div class="b3-label">
|
||||
<div class="b3-label config__item">
|
||||
${window.siyuan.languages.fileTree12}
|
||||
<div class="fn__hr"></div>
|
||||
<div class="b3-label__text">${window.siyuan.languages.fileTree13}</div>
|
||||
<div class="fn__hr"></div>
|
||||
<input class="b3-text-field fn__flex-center fn__block" id="docCreateSavePath" value="">
|
||||
<span class="fn__hr"></span>
|
||||
<div class="fn__flex">
|
||||
<select style="min-width: 200px" class="b3-select" id="docCreateSaveBox">${genNotebookOption(data.conf.docCreateSaveBox)}</select>
|
||||
<div class="fn__space"></div>
|
||||
<input class="b3-text-field fn__flex-1" id="docCreateSavePath" value="">
|
||||
</div>
|
||||
</div>
|
||||
<div class="b3-label">
|
||||
<div class="b3-label config__item">
|
||||
${window.siyuan.languages.fileTree5}
|
||||
<div class="fn__hr"></div>
|
||||
<div class="b3-label__text">${window.siyuan.languages.fileTree6}</div>
|
||||
<div class="fn__hr"></div>
|
||||
<input class="b3-text-field fn__flex-center fn__block" id="refCreateSavePath" value="${window.siyuan.config.fileTree.refCreateSavePath}">
|
||||
<span class="fn__hr"></span>
|
||||
<div class="fn__flex">
|
||||
<select style="min-width: 200px" class="b3-select" id="refCreateSaveBox">${genNotebookOption(data.conf.refCreateSaveBox)}</select>
|
||||
<div class="fn__space"></div>
|
||||
<input class="b3-text-field fn__flex-1" id="refCreateSavePath" value="">
|
||||
</div>
|
||||
</div>
|
||||
<div class="b3-label">
|
||||
${window.siyuan.languages.fileTree11}
|
||||
<div class="fn__hr"></div>
|
||||
<div class="b3-label__text">${window.siyuan.languages.fileTree14}</div>
|
||||
<div class="fn__hr"></div>
|
||||
<input class="b3-text-field fn__flex-center fn__block" id="dailyNoteSavePath" value="">
|
||||
|
@ -81,12 +96,14 @@ const bindSettingEvent = (contentElement: Element, data: INotebookConf) => {
|
|||
refCreateSavePathElement.value = data.conf.refCreateSavePath;
|
||||
const dailyNoteTemplatePathElement = contentElement.querySelector("#dailyNoteTemplatePath") as HTMLInputElement;
|
||||
dailyNoteTemplatePathElement.value = data.conf.dailyNoteTemplatePath;
|
||||
contentElement.querySelectorAll("input").forEach((item) => {
|
||||
contentElement.querySelectorAll("input, select").forEach((item) => {
|
||||
item.addEventListener("change", () => {
|
||||
fetchPost("/api/notebook/setNotebookConf", {
|
||||
notebook: data.box,
|
||||
conf: {
|
||||
refCreateSavePath: refCreateSavePathElement.value,
|
||||
refCreateSaveBox: (contentElement.querySelector("#refCreateSaveBox") as HTMLInputElement).value,
|
||||
docCreateSaveBox: (contentElement.querySelector("#docCreateSaveBox") as HTMLInputElement).value,
|
||||
docCreateSavePath: docCreateSavePathElement.value,
|
||||
dailyNoteSavePath: dailyNoteSavePathElement.value,
|
||||
dailyNoteTemplatePath: dailyNoteTemplatePathElement.value,
|
||||
|
|
2
app/src/types/config.d.ts
vendored
2
app/src/types/config.d.ts
vendored
|
@ -536,6 +536,8 @@ declare namespace Config {
|
|||
* The storage path of the new document created using block references
|
||||
*/
|
||||
refCreateSavePath: string;
|
||||
refCreateSaveBox: string;
|
||||
docCreateSaveBox: string;
|
||||
/**
|
||||
* Close the secondary confirmation when deleting a document
|
||||
*/
|
||||
|
|
|
@ -95,7 +95,7 @@ export const newFile = (optios: {
|
|||
if ((data.data.path.indexOf("/") > -1 && optios.useSavePath) || optios.name) {
|
||||
if (data.data.path.startsWith("/") || optios.currentPath === "/") {
|
||||
fetchPost("/api/filetree/createDocWithMd", {
|
||||
notebook: optios.notebookId,
|
||||
notebook: data.data.box,
|
||||
path: pathPosix().join(data.data.path, optios.name || (data.data.path.endsWith("/") ? window.siyuan.languages.untitled : "")),
|
||||
// 根目录时无法确定 parentID
|
||||
markdown: ""
|
||||
|
@ -112,11 +112,11 @@ export const newFile = (optios: {
|
|||
});
|
||||
} else {
|
||||
fetchPost("/api/filetree/getHPathByPath", {
|
||||
notebook: optios.notebookId,
|
||||
notebook: data.data.box,
|
||||
path: optios.currentPath.endsWith(".sy") ? optios.currentPath : optios.currentPath + ".sy"
|
||||
}, (responseHPath) => {
|
||||
fetchPost("/api/filetree/createDocWithMd", {
|
||||
notebook: optios.notebookId,
|
||||
notebook: data.data.box,
|
||||
path: pathPosix().join(responseHPath.data, data.data.path, optios.name || (data.data.path.endsWith("/") ? window.siyuan.languages.untitled : "")),
|
||||
parentID: getDisplayName(optios.currentPath, true, true),
|
||||
markdown: ""
|
||||
|
@ -144,7 +144,7 @@ export const newFile = (optios: {
|
|||
optios.paths[optios.paths.indexOf(undefined)] = newPath;
|
||||
}
|
||||
fetchPost("/api/filetree/createDoc", {
|
||||
notebook: optios.notebookId,
|
||||
notebook: data.data.box,
|
||||
path: newPath,
|
||||
title,
|
||||
md: "",
|
||||
|
@ -169,7 +169,7 @@ export const getSavePath = (pathString: string, notebookId: string, cb: (p: stri
|
|||
cb(getDisplayName(data.data.path, false, true));
|
||||
} else {
|
||||
fetchPost("/api/filetree/getHPathByPath", {
|
||||
notebook: notebookId,
|
||||
notebook: data.data.box,
|
||||
path: pathString
|
||||
}, (response) => {
|
||||
cb(getDisplayName(pathPosix().join(response.data, data.data.path), false, true));
|
||||
|
@ -177,7 +177,7 @@ export const getSavePath = (pathString: string, notebookId: string, cb: (p: stri
|
|||
}
|
||||
} else {
|
||||
fetchPost("/api/filetree/getHPathByPath", {
|
||||
notebook: notebookId,
|
||||
notebook: data.data.box,
|
||||
path: pathString
|
||||
}, (response) => {
|
||||
cb(getDisplayName(response.data, false, true));
|
||||
|
|
Loading…
Add table
Reference in a new issue