This commit is contained in:
Liang Ding 2023-04-28 11:28:22 +08:00
parent 1c47a63cca
commit eddab390d6
No known key found for this signature in database
GPG Key ID: 136F30F901A2231D

View File

@ -526,7 +526,12 @@ export const exportMd = (id: string) => {
dialog.bindInput(inputElement, () => { dialog.bindInput(inputElement, () => {
(btnsElement[1] as HTMLButtonElement).click(); (btnsElement[1] as HTMLButtonElement).click();
}); });
inputElement.value = replaceFileName(result.data); let name = replaceFileName(result.data);
const maxNameLen = 32;
if (name.length > maxNameLen) {
name = name.substring(0, maxNameLen);
}
inputElement.value = name;
inputElement.focus(); inputElement.focus();
inputElement.select(); inputElement.select();
btnsElement[0].addEventListener("click", () => { btnsElement[0].addEventListener("click", () => {
@ -539,9 +544,13 @@ export const exportMd = (id: string) => {
inputElement.value = replaceFileName(inputElement.value); inputElement.value = replaceFileName(inputElement.value);
} }
if (name.length > maxNameLen) {
name = name.substring(0, maxNameLen);
}
fetchPost("/api/template/docSaveAsTemplate", { fetchPost("/api/template/docSaveAsTemplate", {
id, id,
name: inputElement.value, name,
overwrite: false overwrite: false
}, response => { }, response => {
if (response.code === 1) { if (response.code === 1) {
@ -549,7 +558,7 @@ export const exportMd = (id: string) => {
confirmDialog(window.siyuan.languages.export, window.siyuan.languages.exportTplTip, () => { confirmDialog(window.siyuan.languages.export, window.siyuan.languages.exportTplTip, () => {
fetchPost("/api/template/docSaveAsTemplate", { fetchPost("/api/template/docSaveAsTemplate", {
id, id,
name: inputElement.value, name,
overwrite: true overwrite: true
}, resp => { }, resp => {
if (resp.code === 0) { if (resp.code === 0) {