diff --git a/app/src/boot/globalEvent/keydown.ts b/app/src/boot/globalEvent/keydown.ts index f05e177a3..08af0f653 100644 --- a/app/src/boot/globalEvent/keydown.ts +++ b/app/src/boot/globalEvent/keydown.ts @@ -1137,12 +1137,12 @@ export const windowKeyDown = (app: App, event: KeyboardEvent) => { const initData = item.headElement.getAttribute("data-initdata"); if (item.model instanceof Editor) { rootId = ` data-node-id="${item.model.editor.protyle.block.rootID}"`; - icon = unicode2Emoji(item.docIcon || Constants.SIYUAN_IMAGE_FILE, "b3-list-item__graphic", true); + icon = unicode2Emoji(item.docIcon || window.siyuan.storage[Constants.LOCAL_IMAGES].file, "b3-list-item__graphic", true); } else if (initData) { const initDataObj = JSON.parse(initData); if (initDataObj.instance === "Editor") { rootId = ` data-node-id="${initDataObj.rootId}"`; - icon = unicode2Emoji(item.docIcon || Constants.SIYUAN_IMAGE_FILE, "b3-list-item__graphic", true); + icon = unicode2Emoji(item.docIcon || window.siyuan.storage[Constants.LOCAL_IMAGES].file, "b3-list-item__graphic", true); } } tabHtml += `
  • ${icon}${escapeHtml(item.title)}
  • `; diff --git a/app/src/business/openRecentDocs.ts b/app/src/business/openRecentDocs.ts index a3809e2d7..3a7df3ab7 100644 --- a/app/src/business/openRecentDocs.ts +++ b/app/src/business/openRecentDocs.ts @@ -16,7 +16,7 @@ const getHTML = async (data: { rootID: string, icon: string, title: string }[], data.forEach((item) => { if (!key || item.title.toLowerCase().includes(key.toLowerCase())) { tabHtml += `
  • -${unicode2Emoji(item.icon || Constants.SIYUAN_IMAGE_FILE, "b3-list-item__graphic", true)} +${unicode2Emoji(item.icon || window.siyuan.storage[Constants.LOCAL_IMAGES].file, "b3-list-item__graphic", true)} ${escapeHtml(item.title)}
  • `; index++; diff --git a/app/src/constants.ts b/app/src/constants.ts index 7b334e4a6..0959536bf 100644 --- a/app/src/constants.ts +++ b/app/src/constants.ts @@ -122,6 +122,7 @@ export abstract class Constants { public static readonly LOCAL_SESSION_FIRSTLOAD = "local-session-firstload"; public static readonly LOCAL_OUTLINE = "local-outline"; public static readonly LOCAL_PLUGIN_DOCKS = "local-plugin-docks"; + public static readonly LOCAL_IMAGES = "local-images"; // dialog public static readonly DIALOG_OPENCARD = "dialog-opencard"; @@ -642,9 +643,6 @@ export abstract class Constants { `; - public static readonly SIYUAN_IMAGE_FILE: string = "1f4c4"; - public static readonly SIYUAN_IMAGE_NOTE: string = "1f5c3"; - public static readonly SIYUAN_IMAGE_FOLDER: string = "1f4d1"; // assets public static readonly SIYUAN_ASSETS_IMAGE: string[] = [".apng", ".ico", ".cur", ".jpg", ".jpe", ".jpeg", ".jfif", ".pjp", ".pjpeg", ".png", ".gif", ".webp", ".bmp", ".svg", ".avif"]; diff --git a/app/src/emoji/index.ts b/app/src/emoji/index.ts index 973a3eee7..0c92fe43b 100644 --- a/app/src/emoji/index.ts +++ b/app/src/emoji/index.ts @@ -482,7 +482,7 @@ export const updateOutlineEmoji = (unicode: string, id: string) => { /// #if !MOBILE getAllModels().outline.forEach(model => { if (model.blockId === id) { - model.headerElement.nextElementSibling.firstElementChild.outerHTML = unicode2Emoji(unicode || Constants.SIYUAN_IMAGE_FILE, "b3-list-item__graphic", true); + model.headerElement.nextElementSibling.firstElementChild.outerHTML = unicode2Emoji(unicode || window.siyuan.storage[Constants.LOCAL_IMAGES].file, "b3-list-item__graphic", true); } }); /// #endif @@ -504,7 +504,7 @@ export const updateFileTreeEmoji = (unicode: string, id: string, icon = "iconFil } /// #endif if (emojiElement) { - emojiElement.innerHTML = unicode2Emoji(unicode || (icon === "iconFile" ? (emojiElement.previousElementSibling.classList.contains("fn__hidden") ? Constants.SIYUAN_IMAGE_FILE : Constants.SIYUAN_IMAGE_FOLDER) : Constants.SIYUAN_IMAGE_NOTE)); + emojiElement.innerHTML = unicode2Emoji(unicode || (icon === "iconFile" ? (emojiElement.previousElementSibling.classList.contains("fn__hidden") ? window.siyuan.storage[Constants.LOCAL_IMAGES].file : window.siyuan.storage[Constants.LOCAL_IMAGES].folder) : window.siyuan.storage[Constants.LOCAL_IMAGES].note)); } if (icon !== "iconFile") { setNoteBook(); diff --git a/app/src/layout/Wnd.ts b/app/src/layout/Wnd.ts index d0e79a559..7521e89ad 100644 --- a/app/src/layout/Wnd.ts +++ b/app/src/layout/Wnd.ts @@ -611,7 +611,7 @@ export class Wnd { } } else if (!graphicElement) { // 没有图标的文档 - iconHTML = unicode2Emoji(Constants.SIYUAN_IMAGE_FILE, "b3-menu__icon", true); + iconHTML = unicode2Emoji(window.siyuan.storage[Constants.LOCAL_IMAGES].file, "b3-menu__icon", true); } window.siyuan.menus.menu.append(new MenuItem({ label: escapeHtml(item.querySelector(".item__text").textContent), diff --git a/app/src/layout/dock/Files.ts b/app/src/layout/dock/Files.ts index 207745488..1402d450d 100644 --- a/app/src/layout/dock/Files.ts +++ b/app/src/layout/dock/Files.ts @@ -710,7 +710,7 @@ export class Files extends Model { } private genNotebook(item: INotebook) { - const emojiHTML = `${unicode2Emoji(item.icon || Constants.SIYUAN_IMAGE_NOTE)}`; + const emojiHTML = `${unicode2Emoji(item.icon || window.siyuan.storage[Constants.LOCAL_IMAGES].note)}`; if (item.closed) { return `
  • @@ -829,8 +829,8 @@ export class Files extends Model { iconElement.parentElement.classList.add("fn__hidden"); } const emojiElement = iconElement.parentElement.nextElementSibling; - if (emojiElement.innerHTML === unicode2Emoji(Constants.SIYUAN_IMAGE_FOLDER)) { - emojiElement.innerHTML = unicode2Emoji(Constants.SIYUAN_IMAGE_FILE); + if (emojiElement.innerHTML === unicode2Emoji(window.siyuan.storage[Constants.LOCAL_IMAGES].folder)) { + emojiElement.innerHTML = unicode2Emoji(window.siyuan.storage[Constants.LOCAL_IMAGES].file); } } targetElement.parentElement.remove(); @@ -902,8 +902,8 @@ export class Files extends Model { sourceElement.parentElement.previousElementSibling.querySelector(".b3-list-item__toggle").classList.add("fn__hidden"); sourceElement.parentElement.previousElementSibling.querySelector(".b3-list-item__arrow").classList.remove("b3-list-item__arrow--open"); const emojiElement = sourceElement.parentElement.previousElementSibling.querySelector(".b3-list-item__icon"); - if (emojiElement.innerHTML === unicode2Emoji(Constants.SIYUAN_IMAGE_FOLDER)) { - emojiElement.innerHTML = unicode2Emoji(Constants.SIYUAN_IMAGE_FILE); + if (emojiElement.innerHTML === unicode2Emoji(window.siyuan.storage[Constants.LOCAL_IMAGES].folder)) { + emojiElement.innerHTML = unicode2Emoji(window.siyuan.storage[Constants.LOCAL_IMAGES].file); } } sourceElement.parentElement.remove(); @@ -916,8 +916,8 @@ export class Files extends Model { if (newElement) { newElement.querySelector(".b3-list-item__toggle").classList.remove("fn__hidden"); const emojiElement = newElement.querySelector(".b3-list-item__icon"); - if (emojiElement.innerHTML === unicode2Emoji(Constants.SIYUAN_IMAGE_FILE)) { - emojiElement.innerHTML = unicode2Emoji(Constants.SIYUAN_IMAGE_FOLDER); + if (emojiElement.innerHTML === unicode2Emoji(window.siyuan.storage[Constants.LOCAL_IMAGES].file)) { + emojiElement.innerHTML = unicode2Emoji(window.siyuan.storage[Constants.LOCAL_IMAGES].folder); } const arrowElement = newElement.querySelector(".b3-list-item__arrow"); if (arrowElement.classList.contains("b3-list-item__arrow--open")) { @@ -993,8 +993,8 @@ export class Files extends Model { arrowElement.classList.add("b3-list-item__arrow--open"); arrowElement.parentElement.classList.remove("fn__hidden"); const emojiElement = liElement.querySelector(".b3-list-item__icon"); - if (emojiElement.textContent === unicode2Emoji(Constants.SIYUAN_IMAGE_FILE)) { - emojiElement.textContent = unicode2Emoji(Constants.SIYUAN_IMAGE_FOLDER); + if (emojiElement.textContent === unicode2Emoji(window.siyuan.storage[Constants.LOCAL_IMAGES].file)) { + emojiElement.textContent = unicode2Emoji(window.siyuan.storage[Constants.LOCAL_IMAGES].folder); } liElement.insertAdjacentHTML("afterend", ``); if (setStorage) { @@ -1139,7 +1139,7 @@ class="b3-list-item b3-list-item--hide-action" data-path="${item.path}"> - ${unicode2Emoji(item.icon || (item.subFileCount === 0 ? Constants.SIYUAN_IMAGE_FILE : Constants.SIYUAN_IMAGE_FOLDER))} + ${unicode2Emoji(item.icon || (item.subFileCount === 0 ? window.siyuan.storage[Constants.LOCAL_IMAGES].file : window.siyuan.storage[Constants.LOCAL_IMAGES].folder))} ${getDisplayName(item.name, true, true)} diff --git a/app/src/layout/dock/Outline.ts b/app/src/layout/dock/Outline.ts index fa3978d3b..d5332add1 100644 --- a/app/src/layout/dock/Outline.ts +++ b/app/src/layout/dock/Outline.ts @@ -342,7 +342,7 @@ export class Outline extends Model { const docTitleElement = this.headerElement.nextElementSibling as HTMLElement; if (this.type === "pin") { if (ial) { - let iconHTML = `${unicode2Emoji(ial.icon || Constants.SIYUAN_IMAGE_FILE, "b3-list-item__graphic", true)}`; + let iconHTML = `${unicode2Emoji(ial.icon || window.siyuan.storage[Constants.LOCAL_IMAGES].file, "b3-list-item__graphic", true)}`; if (ial.icon === Constants.ZWSP && docTitleElement.firstElementChild) { iconHTML = docTitleElement.firstElementChild.outerHTML; } diff --git a/app/src/menus/workspace.ts b/app/src/menus/workspace.ts index 9ab78816e..82e426791 100644 --- a/app/src/menus/workspace.ts +++ b/app/src/menus/workspace.ts @@ -395,7 +395,7 @@ export const workspaceMenu = (app: App, rect: DOMRect) => { if (!item.closed) { submenu.push({ label: escapeHtml(item.name), - iconHTML: unicode2Emoji(item.icon || Constants.SIYUAN_IMAGE_NOTE, "b3-menu__icon", true), + iconHTML: unicode2Emoji(item.icon || window.siyuan.storage[Constants.LOCAL_IMAGES].note, "b3-menu__icon", true), accelerator: window.siyuan.storage[Constants.LOCAL_DAILYNOTEID] === item.id ? window.siyuan.config.keymap.general.dailyNote.custom : "", click: () => { fetchNewDailyNote(app, item.id); diff --git a/app/src/mobile/dock/MobileFiles.ts b/app/src/mobile/dock/MobileFiles.ts index 3408020cd..ad0e032a9 100644 --- a/app/src/mobile/dock/MobileFiles.ts +++ b/app/src/mobile/dock/MobileFiles.ts @@ -262,7 +262,7 @@ export class MobileFiles extends Model { } private genNotebook(item: INotebook) { - const emojiHTML = `${unicode2Emoji(item.icon || Constants.SIYUAN_IMAGE_NOTE)}`; + const emojiHTML = `${unicode2Emoji(item.icon || window.siyuan.storage[Constants.LOCAL_IMAGES].note)}`; if (item.closed) { return `
  • @@ -346,8 +346,8 @@ export class MobileFiles extends Model { sourceElement.parentElement.previousElementSibling.querySelector(".b3-list-item__toggle").classList.add("fn__hidden"); sourceElement.parentElement.previousElementSibling.querySelector(".b3-list-item__arrow").classList.remove("b3-list-item__arrow--open"); const emojiElement = sourceElement.parentElement.previousElementSibling.querySelector(".b3-list-item__icon"); - if (emojiElement.innerHTML === unicode2Emoji(Constants.SIYUAN_IMAGE_FOLDER)) { - emojiElement.innerHTML = unicode2Emoji(Constants.SIYUAN_IMAGE_FILE); + if (emojiElement.innerHTML === unicode2Emoji(window.siyuan.storage[Constants.LOCAL_IMAGES].folder)) { + emojiElement.innerHTML = unicode2Emoji(window.siyuan.storage[Constants.LOCAL_IMAGES].file); } } sourceElement.parentElement.remove(); @@ -359,8 +359,8 @@ export class MobileFiles extends Model { // 重新展开移动到的新文件夹 if (newElement) { const emojiElement = newElement.querySelector(".b3-list-item__icon"); - if (emojiElement.innerHTML === unicode2Emoji(Constants.SIYUAN_IMAGE_FILE)) { - emojiElement.innerHTML = unicode2Emoji(Constants.SIYUAN_IMAGE_FOLDER); + if (emojiElement.innerHTML === unicode2Emoji(window.siyuan.storage[Constants.LOCAL_IMAGES].file)) { + emojiElement.innerHTML = unicode2Emoji(window.siyuan.storage[Constants.LOCAL_IMAGES].folder); } newElement.querySelector(".b3-list-item__toggle").classList.remove("fn__hidden"); newElement.querySelector(".b3-list-item__arrow").classList.remove("b3-list-item__arrow--open"); @@ -399,8 +399,8 @@ export class MobileFiles extends Model { targetElement.querySelector(".b3-list-item__arrow").classList.remove("b3-list-item__arrow--open"); targetElement.querySelector(".b3-list-item__toggle").classList.remove("fn__hidden"); const emojiElement = targetElement.querySelector(".b3-list-item__icon"); - if (emojiElement.innerHTML === unicode2Emoji(Constants.SIYUAN_IMAGE_FILE)) { - emojiElement.innerHTML = unicode2Emoji(Constants.SIYUAN_IMAGE_FOLDER); + if (emojiElement.innerHTML === unicode2Emoji(window.siyuan.storage[Constants.LOCAL_IMAGES].file)) { + emojiElement.innerHTML = unicode2Emoji(window.siyuan.storage[Constants.LOCAL_IMAGES].folder); } if (targetElement.nextElementSibling && targetElement.nextElementSibling.tagName === "UL") { targetElement.nextElementSibling.remove(); @@ -460,8 +460,8 @@ export class MobileFiles extends Model { iconElement.parentElement.classList.add("fn__hidden"); } const emojiElement = iconElement.parentElement.nextElementSibling; - if (emojiElement.innerHTML === unicode2Emoji(Constants.SIYUAN_IMAGE_FOLDER)) { - emojiElement.innerHTML = unicode2Emoji(Constants.SIYUAN_IMAGE_FILE); + if (emojiElement.innerHTML === unicode2Emoji(window.siyuan.storage[Constants.LOCAL_IMAGES].folder)) { + emojiElement.innerHTML = unicode2Emoji(window.siyuan.storage[Constants.LOCAL_IMAGES].file); } } targetElement.parentElement.remove(); @@ -709,7 +709,7 @@ class="b3-list-item" data-path="${item.path}"> - ${unicode2Emoji(item.icon || (item.subFileCount === 0 ? Constants.SIYUAN_IMAGE_FILE : Constants.SIYUAN_IMAGE_FOLDER))} + ${unicode2Emoji(item.icon || (item.subFileCount === 0 ? window.siyuan.storage[Constants.LOCAL_IMAGES].file : window.siyuan.storage[Constants.LOCAL_IMAGES].folder))} ${getDisplayName(item.name, true, true)} diff --git a/app/src/mobile/menu/getRecentDocs.ts b/app/src/mobile/menu/getRecentDocs.ts index 43227044a..d3308c8d3 100644 --- a/app/src/mobile/menu/getRecentDocs.ts +++ b/app/src/mobile/menu/getRecentDocs.ts @@ -12,7 +12,7 @@ export const getRecentDocs = (app: App) => { let html = ""; response.data.forEach((item: any, index: number) => { html += `
  • -${unicode2Emoji(item.icon || Constants.SIYUAN_IMAGE_FILE, "b3-list-item__graphic", true)} +${unicode2Emoji(item.icon || window.siyuan.storage[Constants.LOCAL_IMAGES].file, "b3-list-item__graphic", true)} ${escapeHtml(item.title)}
  • `; }); diff --git a/app/src/mobile/menu/search.ts b/app/src/mobile/menu/search.ts index 97513139d..2eede267e 100644 --- a/app/src/mobile/menu/search.ts +++ b/app/src/mobile/menu/search.ts @@ -172,7 +172,7 @@ const onRecentBlocks = (data: IBlock[], config: Config.IUILayoutTabSearchConfig, -${unicode2Emoji(getNotebookIcon(item.box) || Constants.SIYUAN_IMAGE_NOTE, "b3-list-item__graphic", true)} +${unicode2Emoji(getNotebookIcon(item.box) || window.siyuan.storage[Constants.LOCAL_IMAGES].note, "b3-list-item__graphic", true)} ${escapeGreat(title)}
    `; item.children.forEach((childItem, childIndex) => { diff --git a/app/src/protyle/util/compatibility.ts b/app/src/protyle/util/compatibility.ts index 345412167..6d63a0583 100644 --- a/app/src/protyle/util/compatibility.ts +++ b/app/src/protyle/util/compatibility.ts @@ -206,7 +206,12 @@ export const getLocalStorage = (cb: () => void) => { defaultStorage[Constants.LOCAL_FILEPOSITION] = {}; // {id: IScrollAttr} defaultStorage[Constants.LOCAL_DIALOGPOSITION] = {}; // {id: IPosition} defaultStorage[Constants.LOCAL_HISTORY] = { - notebookId: "%", type: 0, operation: "all", sideWidth: "256px", sideDocWidth: "256px", sideDiffWidth: "256px", + notebookId: "%", + type: 0, + operation: "all", + sideWidth: "256px", + sideDocWidth: "256px", + sideDiffWidth: "256px", }; defaultStorage[Constants.LOCAL_FLASHCARD] = { fullscreen: false @@ -235,6 +240,11 @@ export const getLocalStorage = (cb: () => void) => { defaultStorage[Constants.LOCAL_DOCINFO] = { id: "", }; + defaultStorage[Constants.LOCAL_IMAGES] = { + file: "1f4c4", + note: "1f5c3", + folder: "1f4d1" + }; defaultStorage[Constants.LOCAL_FONTSTYLES] = []; defaultStorage[Constants.LOCAL_FILESPATHS] = []; // filesPath[] defaultStorage[Constants.LOCAL_SEARCHDATA] = { @@ -271,7 +281,7 @@ export const getLocalStorage = (cb: () => void) => { Constants.LOCAL_SEARCHDATA, Constants.LOCAL_ZOOM, Constants.LOCAL_LAYOUTS, Constants.LOCAL_AI, Constants.LOCAL_PLUGINTOPUNPIN, Constants.LOCAL_SEARCHASSET, Constants.LOCAL_FLASHCARD, Constants.LOCAL_DIALOGPOSITION, Constants.LOCAL_SEARCHUNREF, Constants.LOCAL_HISTORY, - Constants.LOCAL_OUTLINE, Constants.LOCAL_FILEPOSITION, Constants.LOCAL_FILESPATHS, + Constants.LOCAL_OUTLINE, Constants.LOCAL_FILEPOSITION, Constants.LOCAL_FILESPATHS, Constants.LOCAL_IMAGES, Constants.LOCAL_PLUGIN_DOCKS].forEach((key) => { if (typeof response.data[key] === "string") { try { diff --git a/app/src/search/util.ts b/app/src/search/util.ts index 0dde8a218..15672fdaa 100644 --- a/app/src/search/util.ts +++ b/app/src/search/util.ts @@ -1400,7 +1400,7 @@ const onSearch = (data: IBlock[], edit: Protyle, element: Element, config: Confi -${unicode2Emoji(getNotebookIcon(item.box) || Constants.SIYUAN_IMAGE_NOTE, "b3-list-item__graphic", true)} +${unicode2Emoji(getNotebookIcon(item.box) || window.siyuan.storage[Constants.LOCAL_IMAGES].note, "b3-list-item__graphic", true)} ${escapeGreat(title)}
    `; item.children.forEach((childItem, childIndex) => { diff --git a/app/src/util/Tree.ts b/app/src/util/Tree.ts index f1b7c87bf..a469b07c5 100644 --- a/app/src/util/Tree.ts +++ b/app/src/util/Tree.ts @@ -129,7 +129,7 @@ ${item.label ? "data-label='" + item.label + "'" : ""}> iconHTML = ``; } else { if (item.type === "NodeDocument") { - iconHTML = `${unicode2Emoji(item.ial.icon || Constants.SIYUAN_IMAGE_FILE)}`; + iconHTML = `${unicode2Emoji(item.ial.icon || window.siyuan.storage[Constants.LOCAL_IMAGES].file)}`; } else { iconHTML = ``; } diff --git a/app/src/util/pathName.ts b/app/src/util/pathName.ts index fb67d163f..dad5f4272 100644 --- a/app/src/util/pathName.ts +++ b/app/src/util/pathName.ts @@ -195,7 +195,7 @@ export const movePathTo = (cb: (toPath: string[], toNotebook: string[]) => void, - ${unicode2Emoji(item.icon || Constants.SIYUAN_IMAGE_NOTE, "b3-list-item__graphic", true)} + ${unicode2Emoji(item.icon || window.siyuan.storage[Constants.LOCAL_IMAGES].note, "b3-list-item__graphic", true)} ${escapeHtml(item.name)} ${countHTML} `; @@ -242,7 +242,7 @@ export const movePathTo = (cb: (toPath: string[], toNotebook: string[]) => void, ${item.flashcardCount}`; } fileHTML += `
  • - ${unicode2Emoji(item.boxIcon || Constants.SIYUAN_IMAGE_NOTE, "b3-list-item__graphic", true)} + ${unicode2Emoji(item.boxIcon || window.siyuan.storage[Constants.LOCAL_IMAGES].note, "b3-list-item__graphic", true)} ${escapeHtml(item.hPath)} ${countHTML}
  • `; @@ -516,7 +516,7 @@ const getLeaf = (liElement: HTMLElement, flashcard: boolean) => { - ${unicode2Emoji(item.icon || (item.subFileCount === 0 ? Constants.SIYUAN_IMAGE_FILE : Constants.SIYUAN_IMAGE_FOLDER), "b3-list-item__graphic", true)} + ${unicode2Emoji(item.icon || (item.subFileCount === 0 ? window.siyuan.storage[Constants.LOCAL_IMAGES].file : window.siyuan.storage[Constants.LOCAL_IMAGES].folder), "b3-list-item__graphic", true)} " + window.siyuan.languages.bookmark + " " + item.bookmark : ""}${item.name1 ? "
    " + window.siyuan.languages.name + " " + item.name1 : ""}${item.alias ? "
    " + window.siyuan.languages.alias + " " + item.alias : ""}${item.memo ? "
    " + window.siyuan.languages.memo + " " + item.memo : ""}${item.subFileCount !== 0 ? window.siyuan.languages.includeSubFile.replace("x", item.subFileCount) : ""}
    ${window.siyuan.languages.modifiedAt} ${item.hMtime}
    ${window.siyuan.languages.createdAt} ${item.hCtime}">${getDisplayName(item.name, true, true)}
    ${countHTML} `;