2022-05-26 15:18:53 +08:00
|
|
|
import {Dialog} from "../dialog";
|
|
|
|
|
import {fetchPost} from "../util/fetch";
|
|
|
|
|
import {isMobile} from "../util/functions";
|
|
|
|
|
import {escapeHtml} from "../util/escape";
|
|
|
|
|
import {writeText} from "../protyle/util/compatibility";
|
|
|
|
|
import {showMessage} from "../dialog/message";
|
|
|
|
|
|
|
|
|
|
export const onGetnotebookconf = (data: {
|
|
|
|
|
name: string,
|
|
|
|
|
box: string,
|
|
|
|
|
conf: {
|
|
|
|
|
refCreateSavePath: string
|
2023-02-03 20:47:43 +08:00
|
|
|
docCreateSavePath: string
|
2022-05-26 15:18:53 +08:00
|
|
|
dailyNoteSavePath: string
|
|
|
|
|
dailyNoteTemplatePath: string
|
|
|
|
|
}
|
|
|
|
|
}) => {
|
|
|
|
|
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 style="max-height: 80vh;overflow: auto;">
|
|
|
|
|
<div class="b3-label">
|
|
|
|
|
${window.siyuan.languages.fileTree12}
|
|
|
|
|
<div class="fn__hr"></div>
|
2022-08-12 12:08:16 +08:00
|
|
|
<div class="b3-label__text">${window.siyuan.languages.fileTree13}</div>
|
2022-05-26 15:18:53 +08:00
|
|
|
<div class="fn__hr"></div>
|
2023-02-03 20:47:43 +08:00
|
|
|
<input class="b3-text-field fn__flex-center fn__block" id="docCreateSavePath" value="">
|
2022-05-26 15:18:53 +08:00
|
|
|
</div>
|
|
|
|
|
<div class="b3-label">
|
|
|
|
|
${window.siyuan.languages.fileTree5}
|
|
|
|
|
<div class="fn__hr"></div>
|
2022-08-12 12:08:16 +08:00
|
|
|
<div class="b3-label__text">${window.siyuan.languages.fileTree6}</div>
|
2022-05-26 15:18:53 +08:00
|
|
|
<div class="fn__hr"></div>
|
|
|
|
|
<input class="b3-text-field fn__flex-center fn__block" id="refCreateSavePath" value="${window.siyuan.config.fileTree.refCreateSavePath}">
|
|
|
|
|
</div>
|
|
|
|
|
<div class="b3-label">
|
|
|
|
|
${window.siyuan.languages.fileTree11}
|
|
|
|
|
<div class="fn__hr"></div>
|
2022-08-12 12:08:16 +08:00
|
|
|
<div class="b3-label__text">${window.siyuan.languages.fileTree14}</div>
|
2022-05-26 15:18:53 +08:00
|
|
|
<div class="fn__hr"></div>
|
|
|
|
|
<input class="b3-text-field fn__flex-center fn__block" id="dailyNoteSavePath" value="">
|
|
|
|
|
<div class="fn__hr"></div>
|
2022-08-12 12:08:16 +08:00
|
|
|
<div class="b3-label__text">${window.siyuan.languages.fileTree15}</div>
|
2022-05-26 15:18:53 +08:00
|
|
|
<div class="fn__hr"></div>
|
|
|
|
|
<input class="b3-text-field fn__flex-center fn__block" id="dailyNoteTemplatePath" value="${data.conf.dailyNoteTemplatePath}">
|
|
|
|
|
</div></div>`;
|
|
|
|
|
let contentElement;
|
|
|
|
|
if (isMobile()) {
|
|
|
|
|
contentElement = document.getElementById("model");
|
|
|
|
|
contentElement.style.top = "0";
|
|
|
|
|
contentElement.querySelector(".toolbar__icon").innerHTML = '<use xlink:href="#iconSettings"></use>';
|
|
|
|
|
contentElement.querySelector(".toolbar__text").innerHTML = titleHTML;
|
|
|
|
|
contentElement.querySelector("#modelMain").innerHTML = contentHTML;
|
|
|
|
|
} else {
|
|
|
|
|
const dialog = new Dialog({
|
|
|
|
|
width: "80vw",
|
|
|
|
|
title: titleHTML,
|
|
|
|
|
content: contentHTML
|
|
|
|
|
});
|
|
|
|
|
contentElement = dialog.element;
|
|
|
|
|
}
|
|
|
|
|
contentElement.querySelector(".b3-button--small").addEventListener("click", () => {
|
|
|
|
|
writeText(data.box);
|
|
|
|
|
showMessage(window.siyuan.languages.copied);
|
|
|
|
|
});
|
|
|
|
|
const dailyNoteSavePathElement = contentElement.querySelector("#dailyNoteSavePath") as HTMLInputElement;
|
|
|
|
|
dailyNoteSavePathElement.value = data.conf.dailyNoteSavePath;
|
2023-02-03 20:47:43 +08:00
|
|
|
const docCreateSavePathElement = contentElement.querySelector("#docCreateSavePath") as HTMLInputElement;
|
|
|
|
|
docCreateSavePathElement.value = data.conf.docCreateSavePath;
|
2022-05-26 15:18:53 +08:00
|
|
|
const refCreateSavePathElement = contentElement.querySelector("#refCreateSavePath") as HTMLInputElement;
|
|
|
|
|
refCreateSavePathElement.value = data.conf.refCreateSavePath;
|
|
|
|
|
const dailyNoteTemplatePathElement = contentElement.querySelector("#dailyNoteTemplatePath") as HTMLInputElement;
|
|
|
|
|
dailyNoteTemplatePathElement.value = data.conf.dailyNoteTemplatePath;
|
|
|
|
|
contentElement.querySelectorAll("input").forEach((item) => {
|
|
|
|
|
item.addEventListener("change", () => {
|
|
|
|
|
fetchPost("/api/notebook/setNotebookConf", {
|
|
|
|
|
notebook: data.box,
|
|
|
|
|
conf: {
|
|
|
|
|
refCreateSavePath: refCreateSavePathElement.value,
|
2023-02-03 20:47:43 +08:00
|
|
|
docCreateSavePath: docCreateSavePathElement.value,
|
2022-05-26 15:18:53 +08:00
|
|
|
dailyNoteSavePath: dailyNoteSavePathElement.value,
|
|
|
|
|
dailyNoteTemplatePath: dailyNoteTemplatePathElement.value,
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
};
|