mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-02 21:51:49 +01:00
🎨 Title localization when creating a document https://github.com/siyuan-note/siyuan/issues/10719
This commit is contained in:
parent
f5043a8c46
commit
2a8809bc7e
25 changed files with 72 additions and 61 deletions
|
|
@ -1,14 +1,15 @@
|
|||
import {
|
||||
focusBlock, focusByOffset,
|
||||
focusByRange, focusByWbr,
|
||||
getEditorRange, getSelectionOffset,
|
||||
focusBlock,
|
||||
focusByOffset,
|
||||
focusByRange,
|
||||
focusByWbr,
|
||||
getEditorRange,
|
||||
getSelectionOffset,
|
||||
} from "../util/selection";
|
||||
import {fetchPost} from "../../util/fetch";
|
||||
import {replaceFileName, validateName} from "../../editor/rename";
|
||||
import {MenuItem} from "../../menus/Menu";
|
||||
import {
|
||||
openFileAttr,
|
||||
} from "../../menus/commonMenuItem";
|
||||
import {openFileAttr,} from "../../menus/commonMenuItem";
|
||||
import {Constants} from "../../constants";
|
||||
import {matchHotKey} from "../util/hotKey";
|
||||
import {isMac, readText, writeText} from "../util/compatibility";
|
||||
|
|
@ -264,7 +265,7 @@ export class Title {
|
|||
|
||||
public setTitle(title: string) {
|
||||
if (code160to32(title) !== code160to32(this.editElement.textContent)) {
|
||||
this.editElement.textContent = title === "Untitled" ? "" : title;
|
||||
this.editElement.textContent = title === window.siyuan.languages.untitled ? "" : title;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,6 @@
|
|||
import {fetchPost, fetchSyncPost} from "../../util/fetch";
|
||||
import {MenuItem} from "../../menus/Menu";
|
||||
import {
|
||||
copySubMenu,
|
||||
exportMd,
|
||||
movePathToMenu,
|
||||
openFileAttr,
|
||||
openFileWechatNotify,
|
||||
} from "../../menus/commonMenuItem";
|
||||
import {copySubMenu, exportMd, movePathToMenu, openFileAttr, openFileWechatNotify,} from "../../menus/commonMenuItem";
|
||||
import {deleteFile} from "../../editor/deleteFile";
|
||||
import {updateHotkeyTip} from "../util/compatibility";
|
||||
/// #if !MOBILE
|
||||
|
|
@ -105,7 +99,7 @@ export const openTitleMenu = (protyle: IProtyle, position: IPosition) => {
|
|||
blockId: protyle.block.id,
|
||||
rootId: protyle.block.rootID,
|
||||
useBlockId: protyle.block.showAll,
|
||||
title: protyle.title ? (protyle.title.editElement.textContent || "Untitled") : null
|
||||
title: protyle.title ? (protyle.title.editElement.textContent || window.siyuan.languages.untitled) : null
|
||||
});
|
||||
}
|
||||
}).element);
|
||||
|
|
@ -119,7 +113,7 @@ export const openTitleMenu = (protyle: IProtyle, position: IPosition) => {
|
|||
blockId: protyle.block.id,
|
||||
rootId: protyle.block.rootID,
|
||||
useBlockId: protyle.block.showAll,
|
||||
title: protyle.title ? (protyle.title.editElement.textContent || "Untitled") : null
|
||||
title: protyle.title ? (protyle.title.editElement.textContent || window.siyuan.languages.untitled) : null
|
||||
});
|
||||
}
|
||||
}).element);
|
||||
|
|
|
|||
|
|
@ -619,7 +619,7 @@ ${genHintItemHTML(item)}
|
|||
fetchPost("/api/filetree/createDoc", {
|
||||
notebook: protyle.notebookId,
|
||||
path: pathPosix().join(getDisplayName(protyle.path, false, true), newSubDocId + ".sy"),
|
||||
title: "Untitled",
|
||||
title: window.siyuan.languages.untitled,
|
||||
md: ""
|
||||
}, () => {
|
||||
insertHTML(`<span data-type="block-ref" data-id="${newSubDocId}" data-subtype="d">Untitled</span>`, protyle);
|
||||
|
|
|
|||
|
|
@ -13,9 +13,9 @@ const genAVRollupHTML = (value: IAVCellValue) => {
|
|||
switch (value.type) {
|
||||
case "block":
|
||||
if (value?.isDetached) {
|
||||
html = `<span data-id="${value.block?.id}">${value.block?.content || "Untitled"}</span>`;
|
||||
html = `<span data-id="${value.block?.id}">${value.block?.content || window.siyuan.languages.untitled}</span>`;
|
||||
} else {
|
||||
html = `<span data-type="block-ref" data-id="${value.block?.id}" data-subtype="s" class="av__celltext--ref">${value.block?.content || "Untitled"}</span>`;
|
||||
html = `<span data-type="block-ref" data-id="${value.block?.id}" data-subtype="s" class="av__celltext--ref">${value.block?.content || window.siyuan.languages.untitled}</span>`;
|
||||
}
|
||||
break;
|
||||
case "text":
|
||||
|
|
|
|||
|
|
@ -613,7 +613,7 @@ export const renderCell = (cellValue: IAVCellValue) => {
|
|||
text = `<span class="av__celltext">${cellValue.block.content || ""}</span>
|
||||
<span class="b3-chip b3-chip--info b3-chip--small" data-type="block-more">${window.siyuan.languages.more}</span>`;
|
||||
} else {
|
||||
text = `<span data-type="block-ref" data-id="${cellValue.block.id}" data-subtype="s" class="av__celltext av__celltext--ref">${cellValue.block.content || "Untitled"}</span>
|
||||
text = `<span data-type="block-ref" data-id="${cellValue.block.id}" data-subtype="s" class="av__celltext av__celltext--ref">${cellValue.block.content || window.siyuan.languages.untitled}</span>
|
||||
<span class="b3-chip b3-chip--info b3-chip--small" data-type="block-more">${window.siyuan.languages.update}</span>`;
|
||||
}
|
||||
} else if (cellValue.type === "number") {
|
||||
|
|
@ -691,9 +691,9 @@ const renderRollup = (cellValue: IAVCellValue) => {
|
|||
}
|
||||
} else if (cellValue.type === "block") {
|
||||
if (cellValue?.isDetached) {
|
||||
text = `<span class="av__celltext" data-id="${cellValue.block?.id}">${cellValue.block?.content || "Untitled"}</span>`;
|
||||
text = `<span class="av__celltext" data-id="${cellValue.block?.id}">${cellValue.block?.content || window.siyuan.languages.untitled}</span>`;
|
||||
} else {
|
||||
text = `<span data-type="block-ref" data-id="${cellValue.block?.id}" data-subtype="s" class="av__celltext av__celltext--ref">${cellValue.block?.content || "Untitled"}</span>`;
|
||||
text = `<span data-type="block-ref" data-id="${cellValue.block?.id}" data-subtype="s" class="av__celltext av__celltext--ref">${cellValue.block?.content || window.siyuan.languages.untitled}</span>`;
|
||||
}
|
||||
} else if (cellValue.type === "number") {
|
||||
text = cellValue?.number.formattedContent || cellValue?.number.content.toString() || "";
|
||||
|
|
|
|||
|
|
@ -240,11 +240,11 @@ const filterItem = (menuElement: Element, cellElement: HTMLElement, keyword: str
|
|||
const hasIds: string[] = [];
|
||||
cellElement.querySelectorAll("span").forEach((item) => {
|
||||
hasIds.push(item.dataset.id);
|
||||
selectHTML += `<button data-id="${item.dataset.id}" data-type="setRelationCell" class="b3-menu__item${item.textContent.indexOf(keyword) > -1 ? "" : " fn__none"}" draggable="true">${genSelectItemHTML("selected", item.dataset.id, !item.classList.contains("av__celltext--ref"), item.textContent || "Untitled")}</button>`;
|
||||
selectHTML += `<button data-id="${item.dataset.id}" data-type="setRelationCell" class="b3-menu__item${item.textContent.indexOf(keyword) > -1 ? "" : " fn__none"}" draggable="true">${genSelectItemHTML("selected", item.dataset.id, !item.classList.contains("av__celltext--ref"), item.textContent || window.siyuan.languages.untitled)}</button>`;
|
||||
});
|
||||
cells.forEach((item) => {
|
||||
if (!hasIds.includes(item.block.id)) {
|
||||
html += genSelectItemHTML("unselect", item.block.id, item.isDetached, item.block.content || "Untitled");
|
||||
html += genSelectItemHTML("unselect", item.block.id, item.isDetached, item.block.content || window.siyuan.languages.untitled);
|
||||
}
|
||||
});
|
||||
menuElement.querySelector(".b3-menu__items").innerHTML = `${selectHTML || genSelectItemHTML("empty")}
|
||||
|
|
@ -270,11 +270,11 @@ export const bindRelationEvent = (options: {
|
|||
const hasIds: string[] = [];
|
||||
options.cellElements[0].querySelectorAll("span").forEach((item) => {
|
||||
hasIds.push(item.dataset.id);
|
||||
selectHTML += `<button data-id="${item.dataset.id}" data-type="setRelationCell" class="b3-menu__item" draggable="true">${genSelectItemHTML("selected", item.dataset.id, !item.classList.contains("av__celltext--ref"), item.textContent || "Untitled")}</button>`;
|
||||
selectHTML += `<button data-id="${item.dataset.id}" data-type="setRelationCell" class="b3-menu__item" draggable="true">${genSelectItemHTML("selected", item.dataset.id, !item.classList.contains("av__celltext--ref"), item.textContent || window.siyuan.languages.untitled)}</button>`;
|
||||
});
|
||||
cells.forEach((item) => {
|
||||
if (!hasIds.includes(item.block.id)) {
|
||||
html += genSelectItemHTML("unselect", item.block.id, item.isDetached, item.block.content || "Untitled");
|
||||
html += genSelectItemHTML("unselect", item.block.id, item.isDetached, item.block.content || window.siyuan.languages.untitled);
|
||||
}
|
||||
});
|
||||
options.menuElement.querySelector(".b3-menu__label").innerHTML = response.data.name;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue