Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: asset search

Vanessabd59d77a7693
diff --git a/app/src/assets/scss/protyle/_wysiwyg.scss b/app/src/assets/scss/protyle/_wysiwyg.scss
index 00ef6ac3db..d5bbff5e08 100644
--- a/app/src/assets/scss/protyle/_wysiwyg.scss
+++ b/app/src/assets/scss/protyle/_wysiwyg.scss
@@ -216,7 +216,7 @@
}
.def--mark {
- background-color: var(--b3-protyle-inline-mark-background);
+ background-color: var(--b3-theme-secondary);
}
span[data-type~="block-ref"],
diff --git a/app/src/constants.ts b/app/src/constants.ts
index 1aa9378f6d..ac164f56d5 100644
--- a/app/src/constants.ts
+++ b/app/src/constants.ts
@@ -491,6 +491,9 @@ export abstract class Constants {
public static readonly SIYUAN_ASSETS_AUDIO: string[] = [".mp3", ".wav", ".ogg", ".m4a"];
public static readonly SIYUAN_ASSETS_VIDEO: string[] = [".mov", ".weba", ".mkv", ".mp4", ".webm"];
public static readonly SIYUAN_ASSETS_EXTS: string[] = [".pdf"].concat(Constants.SIYUAN_ASSETS_IMAGE).concat(Constants.SIYUAN_ASSETS_AUDIO).concat(Constants.SIYUAN_ASSETS_VIDEO);
+ public static readonly SIYUAN_ASSETS_SEARCH: string[] = [".txt", ".md", ".markdown", ".docx", ".xlsx", ".pptx", ".pdf", ".json", ".log", ".sql", ".html", ".xml", ".java", ".h", ".c",
+ ".cpp", ".go", ".rs", ".swift", ".kt", ".py", ".php", ".js", ".css", ".ts", ".sh", ".bat", ".cmd", ".ini", ".yaml",
+ ".rst", ".adoc", ".textile", ".opml", ".org", ".wiki"];
// protyle
public static readonly SIYUAN_CONFIG_APPEARANCE_DARK_CODE: string[] = ["a11y-dark", "agate", "an-old-hope", "androidstudio",
diff --git a/app/src/protyle/util/compatibility.ts b/app/src/protyle/util/compatibility.ts
index 2114532a55..38be59ba7c 100644
--- a/app/src/protyle/util/compatibility.ts
+++ b/app/src/protyle/util/compatibility.ts
@@ -154,16 +154,13 @@ export const getLocalStorage = (cb: () => void) => {
row: "",
layout: 0,
method: 0,
- types: {
- ".txt": true,
- ".md": true,
- ".docx": true,
- ".xlsx": true,
- ".pptx": true,
- },
+ types: {},
sort: 0,
k: "",
};
+ Constants.SIYUAN_ASSETS_SEARCH.forEach(type => {
+ defaultStorage[Constants.LOCAL_SEARCHASSET].types[type] = true
+ })
defaultStorage[Constants.LOCAL_SEARCHKEYS] = {
keys: [],
replaceKeys: [],
diff --git a/app/src/search/assets.ts b/app/src/search/assets.ts
index e07703463f..1892d8ee04 100644
--- a/app/src/search/assets.ts
+++ b/app/src/search/assets.ts
@@ -69,7 +69,7 @@ export const openSearchAsset = (element: Element, isStick: boolean) => {
<div class="search__drag"></div>
<div id="searchAssetPreview" class="fn__flex-1 search__preview" style="padding: 8px"></div>
</div>
-<div class="search__tip${isStick ? "" : " fn__none"}">
+<div class="search__tip${isStick ? " fn__none" : ""}">
<kbd>↑/↓</kbd> ${window.siyuan.languages.searchTip1}
${enterTip}
<kbd>Esc</kbd> ${window.siyuan.languages.searchTip5}
@@ -357,35 +357,27 @@ export const assetMethodMenu = (target: HTMLElement, cb: () => void) => {
window.siyuan.menus.menu.popup({x: rect.right, y: rect.bottom}, true);
};
-let filterTypes: string[] = [
- ".txt", ".md", ".markdown", ".docx", ".xlsx", ".pptx", ".pdf", ".json", ".log", ".sql", ".html", ".xml", ".java", ".h", ".c",
- ".cpp", ".go", ".rs", ".swift", ".kt", ".py", ".php", ".js", ".css", ".ts", ".sh", ".bat", ".cmd", ".ini", ".yaml",
- ".rst", ".adoc", ".textile", ".opml", ".org", ".wiki",
-]
-
-const filterTypesHTML = (types: string[]) => {
- filterTypes = filterTypes.sort((a: string, b: string) => {
- return a.localeCompare(b);
- });
-
+const filterTypesHTML = (types:IObject) => {
let html = "";
- types.forEach((type: string) => {
+ Constants.SIYUAN_ASSETS_SEARCH.sort((a: string, b: string) => {
+ return a.localeCompare(b);
+ }).forEach((type: string) => {
html += `<label class="fn__flex b3-label">
<div class="fn__flex-1 fn__flex-center">
${type}
</div>
<span class="fn__space"></span>
- <input class="b3-switch fn__flex-center" data-type="${type}" type="checkbox" checked>
+ <input class="b3-switch fn__flex-center" data-type="${type}" type="checkbox" ${types[type] ? " checked" : ""}>
</label>`;
});
return html;
-}
+};
export const assetFilterMenu = (assetsElement: Element) => {
const localData = window.siyuan.storage[Constants.LOCAL_SEARCHASSET].types;
const filterDialog = new Dialog({
title: window.siyuan.languages.type,
- content: `<div class="b3-dialog__content">` + filterTypesHTML(filterTypes) + `</div>
+ content: `<div class="b3-dialog__content">${filterTypesHTML(localData)}</div>
<div class="b3-dialog__action">
<button class="b3-button b3-button--cancel">${window.siyuan.languages.cancel}</button><div class="fn__space"></div>
<button class="b3-button b3-button--text">${window.siyuan.languages.confirm}</button>
diff --git a/app/src/search/util.ts b/app/src/search/util.ts
index c3103d2d04..6f47259186 100644
--- a/app/src/search/util.ts
+++ b/app/src/search/util.ts
@@ -508,7 +508,7 @@ export const genSearch = (app: App, config: ISearchOption, element: Element, clo
event.preventDefault();
break;
} else if (target.id === "searchAsset") {
- openSearchAsset(assetsElement, !!closeCB);
+ openSearchAsset(assetsElement, !closeCB);
event.stopPropagation();
event.preventDefault();
break;