Skip to content

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

:sparkles: Support image file names and inline renaming https://github.com/siyuan-note/siyuan/issues/19978

Daniel93c8bae0702b
diff --git a/app/appearance/langs/ar.json b/app/appearance/langs/ar.json
index b536a1ed2d..0ab256efe1 100644
--- a/app/appearance/langs/ar.json
+++ b/app/appearance/langs/ar.json
@@ -1,4 +1,5 @@
{
+ "displayImgName": "إظهار أسماء ملفات الصور",
"s3EndpointBucketWarning": "قد يحتوي Endpoint بالفعل على اسم الحاوية، مما قد يعطل عرض لقطات السحابة وتنظيفها. تحقق من الإعدادات؛ إذا كانت هناك بيانات متزامنة، فانسخها احتياطيًا وتحقق من مسار تخزينها قبل تغيير الإعدادات",
"embedHTMLFileBelow": "تضمين ملف HTML أدناه",
"horizontalSuperBlock": "كتلة خارقة أفقية",
diff --git a/app/appearance/langs/de.json b/app/appearance/langs/de.json
index 31bc778ee7..39585c39c1 100644
--- a/app/appearance/langs/de.json
+++ b/app/appearance/langs/de.json
@@ -1,4 +1,5 @@
{
+ "displayImgName": "Bilddateinamen anzeigen",
"s3EndpointBucketWarning": "Endpoint enthält möglicherweise bereits den Bucket-Namen, was das Auflisten und Bereinigen von Cloud-Snapshots beeinträchtigen kann. Prüfen Sie die Konfiguration; sichern Sie vorhandene synchronisierte Daten und prüfen Sie deren Speicherpfad, bevor Sie die Konfiguration ändern",
"embedHTMLFileBelow": "HTML-Datei darunter einbetten",
"horizontalSuperBlock": "Horizontaler Superblock",
diff --git a/app/appearance/langs/en.json b/app/appearance/langs/en.json
index b890f3b910..a4b97829ab 100644
--- a/app/appearance/langs/en.json
+++ b/app/appearance/langs/en.json
@@ -1,4 +1,5 @@
{
+ "displayImgName": "Show image file names",
"s3EndpointBucketWarning": "Endpoint may already contain the bucket name, which can disrupt cloud snapshot listing and cleanup. Check the configuration; if synced data already exists, back it up and verify its storage path before changing the configuration",
"embedHTMLFileBelow": "Embed HTML file below",
"horizontalSuperBlock": "Horizontal super block",
diff --git a/app/appearance/langs/es.json b/app/appearance/langs/es.json
index c6f8e4fa38..0898599bfa 100644
--- a/app/appearance/langs/es.json
+++ b/app/appearance/langs/es.json
@@ -1,4 +1,5 @@
{
+ "displayImgName": "Mostrar nombres de archivos de imagen",
"s3EndpointBucketWarning": "Endpoint puede contener ya el nombre del bucket, lo que puede afectar al listado y la limpieza de instantáneas en la nube. Revise la configuración; si ya hay datos sincronizados, haga una copia de seguridad y compruebe su ruta de almacenamiento antes de cambiarla",
"embedHTMLFileBelow": "Incrustar archivo HTML debajo",
"horizontalSuperBlock": "Superbloque horizontal",
diff --git a/app/appearance/langs/fr.json b/app/appearance/langs/fr.json
index 934af0e284..b7c457f01c 100644
--- a/app/appearance/langs/fr.json
+++ b/app/appearance/langs/fr.json
@@ -1,4 +1,5 @@
{
+ "displayImgName": "Afficher les noms des fichiers image",
"s3EndpointBucketWarning": "Endpoint contient peut-être déjà le nom du bucket, ce qui peut perturber la liste et le nettoyage des instantanés cloud. Vérifiez la configuration ; si des données sont déjà synchronisées, sauvegardez-les et vérifiez leur chemin de stockage avant de modifier la configuration",
"embedHTMLFileBelow": "Intégrer le fichier HTML en dessous",
"horizontalSuperBlock": "Superblock horizontal",
diff --git a/app/appearance/langs/he.json b/app/appearance/langs/he.json
index 999e4da879..56bd41b259 100644
--- a/app/appearance/langs/he.json
+++ b/app/appearance/langs/he.json
@@ -1,4 +1,5 @@
{
+ "displayImgName": "הצגת שמות קובצי תמונות",
"s3EndpointBucketWarning": "ייתכן ש-Endpoint כבר מכיל את שם דלי האחסון, דבר שעלול לשבש הצגה וניקוי של תמונות מצב בענן. יש לבדוק את ההגדרות; אם קיימים נתונים מסונכרנים, יש לגבות אותם ולוודא את נתיב האחסון לפני שינוי ההגדרות",
"embedHTMLFileBelow": "הטמעת קובץ HTML מתחת",
"horizontalSuperBlock": "בלוק עליון אופקי",
diff --git a/app/appearance/langs/hi.json b/app/appearance/langs/hi.json
index c4e6a0a878..02a4a019e4 100644
--- a/app/appearance/langs/hi.json
+++ b/app/appearance/langs/hi.json
@@ -1,4 +1,5 @@
{
+ "displayImgName": "चित्र फ़ाइलों के नाम दिखाएँ",
"s3EndpointBucketWarning": "Endpoint में बकेट का नाम पहले से शामिल हो सकता है, जिससे क्लाउड स्नैपशॉट की सूची और सफ़ाई में समस्या आ सकती है। कॉन्फ़िगरेशन जाँचें; यदि सिंक किया गया डेटा मौजूद है, तो कॉन्फ़िगरेशन बदलने से पहले उसका बैकअप लें और संग्रहण पथ की पुष्टि करें",
"embedHTMLFileBelow": "नीचे HTML फ़ाइल एम्बेड करें",
"horizontalSuperBlock": "क्षैतिज सुपर ब्लॉक",
diff --git a/app/appearance/langs/id.json b/app/appearance/langs/id.json
index b79a7dfa72..d416e0b91d 100644
--- a/app/appearance/langs/id.json
+++ b/app/appearance/langs/id.json
@@ -1,4 +1,5 @@
{
+ "displayImgName": "Tampilkan nama berkas gambar",
"s3EndpointBucketWarning": "Endpoint mungkin sudah memuat nama bucket, sehingga daftar dan pembersihan snapshot cloud dapat terganggu. Periksa konfigurasi; jika sudah ada data tersinkron, cadangkan dan pastikan jalur penyimpanannya sebelum mengubah konfigurasi",
"embedHTMLFileBelow": "Sematkan berkas HTML di bawah",
"horizontalSuperBlock": "Super blok horizontal",
diff --git a/app/appearance/langs/it.json b/app/appearance/langs/it.json
index e38b902aec..296ba92a45 100644
--- a/app/appearance/langs/it.json
+++ b/app/appearance/langs/it.json
@@ -1,4 +1,5 @@
{
+ "displayImgName": "Mostra i nomi dei file immagine",
"s3EndpointBucketWarning": "Endpoint potrebbe già contenere il nome del bucket, causando problemi nell'elenco e nella pulizia delle istantanee nel cloud. Controlla la configurazione; se esistono già dati sincronizzati, esegui un backup e verifica il percorso di archiviazione prima di modificarla",
"embedHTMLFileBelow": "Incorpora file HTML sotto",
"horizontalSuperBlock": "Super blocco orizzontale",
diff --git a/app/appearance/langs/ja.json b/app/appearance/langs/ja.json
index c5aff7c025..5fda9ecde8 100644
--- a/app/appearance/langs/ja.json
+++ b/app/appearance/langs/ja.json
@@ -1,4 +1,5 @@
{
+ "displayImgName": "画像のファイル名を表示",
"s3EndpointBucketWarning": "Endpoint にバケット名が既に含まれている可能性があり、クラウドスナップショットの一覧取得やクリーンアップに支障が出る場合があります。設定を確認し、同期済みデータがある場合は、変更前にバックアップして保存先のパスを確認してください",
"embedHTMLFileBelow": "下に HTML ファイルを埋め込む",
"horizontalSuperBlock": "横向きスーパーブロック",
diff --git a/app/appearance/langs/ko.json b/app/appearance/langs/ko.json
index 3d01d369e8..1ef5693360 100644
--- a/app/appearance/langs/ko.json
+++ b/app/appearance/langs/ko.json
@@ -1,4 +1,5 @@
{
+ "displayImgName": "이미지 파일 이름 표시",
"s3EndpointBucketWarning": "Endpoint에 버킷 이름이 이미 포함되어 있으면 클라우드 스냅샷 목록 조회와 정리에 문제가 생길 수 있습니다. 설정을 확인하고, 동기화된 데이터가 있다면 설정을 변경하기 전에 백업하고 저장 경로를 확인하세요",
"embedHTMLFileBelow": "아래에 HTML 파일 삽입",
"horizontalSuperBlock": "가로 슈퍼 블록",
diff --git a/app/appearance/langs/nl.json b/app/appearance/langs/nl.json
index 9dfc3d05e9..3afd3f6c70 100644
--- a/app/appearance/langs/nl.json
+++ b/app/appearance/langs/nl.json
@@ -1,4 +1,5 @@
{
+ "displayImgName": "Bestandsnamen van afbeeldingen tonen",
"s3EndpointBucketWarning": "Endpoint bevat mogelijk al de bucketnaam, wat het weergeven en opruimen van cloudsnapshots kan verstoren. Controleer de configuratie; maak een back-up van bestaande gesynchroniseerde gegevens en controleer hun opslagpad voordat u de configuratie wijzigt",
"embedHTMLFileBelow": "HTML-bestand hieronder insluiten",
"horizontalSuperBlock": "Horizontaal superblok",
diff --git a/app/appearance/langs/pl.json b/app/appearance/langs/pl.json
index fbad1bbf87..63588f5ada 100644
--- a/app/appearance/langs/pl.json
+++ b/app/appearance/langs/pl.json
@@ -1,4 +1,5 @@
{
+ "displayImgName": "Pokazuj nazwy plików obrazów",
"s3EndpointBucketWarning": "Endpoint może już zawierać nazwę zasobnika, co może zakłócać wyświetlanie i czyszczenie migawek w chmurze. Sprawdź konfigurację; jeśli istnieją już zsynchronizowane dane, wykonaj ich kopię zapasową i sprawdź ścieżkę przechowywania przed zmianą konfiguracji",
"embedHTMLFileBelow": "Osadź plik HTML poniżej",
"horizontalSuperBlock": "Poziomy super blok",
diff --git a/app/appearance/langs/pt-BR.json b/app/appearance/langs/pt-BR.json
index 22cda30c71..7813c205cc 100644
--- a/app/appearance/langs/pt-BR.json
+++ b/app/appearance/langs/pt-BR.json
@@ -1,4 +1,5 @@
{
+ "displayImgName": "Mostrar nomes dos arquivos de imagem",
"s3EndpointBucketWarning": "Endpoint pode já conter o nome do bucket, o que pode prejudicar a listagem e a limpeza de snapshots na nuvem. Verifique a configuração; se já houver dados sincronizados, faça um backup e confirme o caminho de armazenamento antes de alterá-la",
"embedHTMLFileBelow": "Incorporar arquivo HTML abaixo",
"horizontalSuperBlock": "Super bloco horizontal",
diff --git a/app/appearance/langs/ru.json b/app/appearance/langs/ru.json
index 2521fb9030..1cffe1e000 100644
--- a/app/appearance/langs/ru.json
+++ b/app/appearance/langs/ru.json
@@ -1,4 +1,5 @@
{
+ "displayImgName": "Показывать имена файлов изображений",
"s3EndpointBucketWarning": "Endpoint может уже содержать имя бакета, что может нарушить получение списка и очистку облачных снимков. Проверьте настройки; если данные уже синхронизированы, создайте резервную копию и проверьте путь хранения перед изменением настроек",
"embedHTMLFileBelow": "Встроить HTML-файл ниже",
"horizontalSuperBlock": "Горизонтальный супер блок",
diff --git a/app/appearance/langs/sk.json b/app/appearance/langs/sk.json
index 895cb4df27..cbb2456c2d 100644
--- a/app/appearance/langs/sk.json
+++ b/app/appearance/langs/sk.json
@@ -1,4 +1,5 @@
{
+ "displayImgName": "Zobraziť názvy súborov obrázkov",
"s3EndpointBucketWarning": "Endpoint už môže obsahovať názov bucketu, čo môže narušiť zobrazovanie a čistenie cloudových snímok. Skontrolujte nastavenia; ak už existujú synchronizované údaje, pred zmenou nastavení ich zálohujte a overte cestu uloženia",
"embedHTMLFileBelow": "Vložiť súbor HTML nižšie",
"horizontalSuperBlock": "Horizontálny super blok",
diff --git a/app/appearance/langs/sr.json b/app/appearance/langs/sr.json
index 44c2f3dee3..e6f8ff8cf6 100644
--- a/app/appearance/langs/sr.json
+++ b/app/appearance/langs/sr.json
@@ -1,4 +1,5 @@
{
+ "displayImgName": "Прикажи називе датотека слика",
"s3EndpointBucketWarning": "Endpoint можда већ садржи назив складишног контејнера, што може ометати приказ и чишћење снимака у облаку. Проверите подешавања; ако већ постоје синхронизовани подаци, направите резервну копију и проверите путању складиштења пре промене подешавања",
"embedHTMLFileBelow": "Угради HTML датотеку испод",
"horizontalSuperBlock": "Horizontalni superblok",
diff --git a/app/appearance/langs/th.json b/app/appearance/langs/th.json
index 536f2847e4..d1a3591e81 100644
--- a/app/appearance/langs/th.json
+++ b/app/appearance/langs/th.json
@@ -1,4 +1,5 @@
{
+ "displayImgName": "แสดงชื่อไฟล์รูปภาพ",
"s3EndpointBucketWarning": "Endpoint อาจมีชื่อบักเก็ตอยู่แล้ว ซึ่งอาจทำให้การแสดงรายการและล้างสแนปช็อตบนคลาวด์ผิดปกติ โปรดตรวจสอบการตั้งค่า หากมีข้อมูลที่ซิงค์แล้ว ให้สำรองข้อมูลและตรวจสอบเส้นทางจัดเก็บก่อนเปลี่ยนการตั้งค่า",
"embedHTMLFileBelow": "ฝังไฟล์ HTML ด้านล่าง",
"horizontalSuperBlock": "ซูเปอร์บล็อกแนวนอน",
diff --git a/app/appearance/langs/tr.json b/app/appearance/langs/tr.json
index d262d0c9d7..fdba6a789d 100644
--- a/app/appearance/langs/tr.json
+++ b/app/appearance/langs/tr.json
@@ -1,4 +1,5 @@
{
+ "displayImgName": "Görsel dosya adlarını göster",
"s3EndpointBucketWarning": "Endpoint zaten kova adını içeriyor olabilir; bu durum bulut anlık görüntülerinin listelenmesini ve temizlenmesini aksatabilir. Yapılandırmayı kontrol edin; eşitlenmiş veriler varsa yapılandırmayı değiştirmeden önce yedekleyin ve depolama yolunu doğrulayın",
"embedHTMLFileBelow": "HTML dosyasını aşağıya göm",
"horizontalSuperBlock": "Yatay süper blok",
diff --git a/app/appearance/langs/uk.json b/app/appearance/langs/uk.json
index 159fc8b66a..e742c91fdc 100644
--- a/app/appearance/langs/uk.json
+++ b/app/appearance/langs/uk.json
@@ -1,4 +1,5 @@
{
+ "displayImgName": "Показувати назви файлів зображень",
"s3EndpointBucketWarning": "Endpoint може вже містити назву бакета, що може порушити отримання списку та очищення хмарних знімків. Перевірте налаштування; якщо дані вже синхронізовано, створіть резервну копію та перевірте шлях зберігання перед зміною налаштувань",
"embedHTMLFileBelow": "Вбудувати HTML-файл нижче",
"horizontalSuperBlock": "Горизонтальний суперблок",
diff --git a/app/appearance/langs/zh-CN.json b/app/appearance/langs/zh-CN.json
index c337e95d0c..457d1859ef 100644
--- a/app/appearance/langs/zh-CN.json
+++ b/app/appearance/langs/zh-CN.json
@@ -1,4 +1,5 @@
{
+ "displayImgName": "显示图片文件名",
"s3EndpointBucketWarning": "Endpoint 可能重复包含桶名,导致云端快照列举和清理异常。请核对配置;已有同步数据时,请先备份并确认存储路径,再修改配置",
"embedHTMLFileBelow": "在下方嵌入 HTML 文件",
"horizontalSuperBlock": "横向超级块",
diff --git a/app/appearance/langs/zh-TW.json b/app/appearance/langs/zh-TW.json
index b1ace6aec1..8031571960 100644
--- a/app/appearance/langs/zh-TW.json
+++ b/app/appearance/langs/zh-TW.json
@@ -1,4 +1,5 @@
{
+ "displayImgName": "顯示圖片檔名",
"s3EndpointBucketWarning": "Endpoint 可能重複包含儲存桶名稱,導致雲端快照列舉與清理異常。請核對設定;若已有同步資料,請先備份並確認儲存路徑,再修改設定",
"embedHTMLFileBelow": "在下方嵌入 HTML 檔案",
"horizontalSuperBlock": "橫向超級區塊",
diff --git a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20200924100744-br924ar.sy b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20200924100744-br924ar.sy
index 17f121152d..fd2023a002 100644
--- a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20200924100744-br924ar.sy
+++ b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20200924100744-br924ar.sy
@@ -6,7 +6,7 @@
"id": "20200924100744-br924ar",
"title": "Assets",
"type": "doc",
- "updated": "20260930090802"
+ "updated": "20260930092043"
},
"Children": [
{
@@ -357,6 +357,47 @@
}
]
},
+ {
+ "ID": "20260930092043-7z9onxu",
+ "Type": "NodeParagraph",
+ "Properties": {
+ "id": "20260930092043-7z9onxu",
+ "updated": "20260930092043"
+ },
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "Enable "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "Settings"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " - "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "Editor"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " - "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "Show image file names"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " to show file names above local images, without the asset path or generated ID and with the extension preserved. Click a name to edit it, then press Enter to rename the asset and update all references; Escape or leaving the field cancels. Read-only views and encrypted notebooks do not allow inline renaming."
+ }
+ ]
+ },
{
"ID": "20210115224203-q8bj2gd",
"Type": "NodeHeading",
diff --git a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20200915214115-42b8zma.sy b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20200915214115-42b8zma.sy
index 429be664d7..6e06978d74 100644
--- a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20200915214115-42b8zma.sy
+++ b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20200915214115-42b8zma.sy
@@ -6,7 +6,7 @@
"id": "20200915214115-42b8zma",
"title": "资源文件",
"type": "doc",
- "updated": "20260930090802"
+ "updated": "20260930092043"
},
"Children": [
{
@@ -357,6 +357,47 @@
}
]
},
+ {
+ "ID": "20260930092043-qa1mz4p",
+ "Type": "NodeParagraph",
+ "Properties": {
+ "id": "20260930092043-qa1mz4p",
+ "updated": "20260930092043"
+ },
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "开启 "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "设置"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " - "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "编辑器"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " - "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "显示图片文件名"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " 后,本地图片上方会显示文件名,隐藏资源路径和随机码,保留扩展名。单击文件名可编辑,按回车改名并更新所有引用;按 Escape 或离开输入框取消。只读视图和加密笔记本不支持内联改名。"
+ }
+ ]
+ },
{
"ID": "20210115222011-bzsftun",
"Type": "NodeHeading",
diff --git a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20211226123038-4umgpxy.sy b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20211226123038-4umgpxy.sy
index ceaba382ac..2a5efe4e12 100644
--- a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20211226123038-4umgpxy.sy
+++ b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20211226123038-4umgpxy.sy
@@ -6,7 +6,7 @@
"id": "20211226123038-4umgpxy",
"title": "資料文件",
"type": "doc",
- "updated": "20260930090802"
+ "updated": "20260930092043"
},
"Children": [
{
@@ -353,6 +353,47 @@
}
]
},
+ {
+ "ID": "20260930092043-i4ib04g",
+ "Type": "NodeParagraph",
+ "Properties": {
+ "id": "20260930092043-i4ib04g",
+ "updated": "20260930092043"
+ },
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "開啟 "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "設定"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " - "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "編輯器"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " - "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "顯示圖片檔名"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " 後,本機圖片上方會顯示檔名,隱藏資源路徑和隨機碼,保留副檔名。按一下檔名可編輯,按 Enter 重新命名並更新所有引用;按 Escape 或離開輸入框取消。唯讀檢視和加密筆記本不支援行內重新命名。"
+ }
+ ]
+ },
{
"ID": "20211226123051-5250xg7",
"Type": "NodeHeading",
diff --git a/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-g3ugxml/20240530101000-1m5un7l.sy b/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-g3ugxml/20240530101000-1m5un7l.sy
index 3c92e10aaa..8e98b9312c 100644
--- a/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-g3ugxml/20240530101000-1m5un7l.sy
+++ b/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-g3ugxml/20240530101000-1m5un7l.sy
@@ -7,7 +7,7 @@
"id": "20240530101000-1m5un7l",
"title": "アセット",
"type": "doc",
- "updated": "20260930090802"
+ "updated": "20260930092043"
},
"Children": [
{
@@ -364,6 +364,43 @@
}
]
},
+ {
+ "ID": "20260930092043-zd8vt2u",
+ "Type": "NodeParagraph",
+ "Properties": {
+ "id": "20260930092043-zd8vt2u",
+ "updated": "20260930092043"
+ },
+ "Children": [
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "設定"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " - "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "エディター"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " - "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "画像のファイル名を表示"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " を有効にすると、ローカル画像の上にパスと生成 ID を除いたファイル名が拡張子付きで表示されます。名前をクリックして編集し、Enter で名前を変更するとすべての参照が更新されます。Escape または入力欄から離れるとキャンセルされます。読み取り専用表示と暗号化ノートブックではインラインで名前を変更できません。"
+ }
+ ]
+ },
{
"ID": "20240530101000-m2u22gy",
"Type": "NodeHeading",
diff --git a/app/src/assets/scss/protyle/_protyle.scss b/app/src/assets/scss/protyle/_protyle.scss
index 9f1a6c4084..851249d220 100644
--- a/app/src/assets/scss/protyle/_protyle.scss
+++ b/app/src/assets/scss/protyle/_protyle.scss
@@ -1429,3 +1429,22 @@ table + .protyle-action__table {
}
}
}
+
+.img__name {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ gap: 4px;
+ overflow-wrap: anywhere;
+ white-space: break-spaces;
+
+ > span:not(.img__extension) {
+ flex: 1;
+ width: 0;
+ }
+
+ input {
+ min-width: 0;
+ width: 100%;
+ }
+}
diff --git a/app/src/config/tabs/editorTab.ts b/app/src/config/tabs/editorTab.ts
index 783ad834bb..54f3c65c5b 100644
--- a/app/src/config/tabs/editorTab.ts
+++ b/app/src/config/tabs/editorTab.ts
@@ -189,6 +189,9 @@ const bindDatabaseAttrSettingsVisibility = (root: HTMLElement) => {
const registerEditorBlockFeaturesGroup = (tab: SettingTabBuilder) => {
const group = tab.group("blockFeatures", window.siyuan.languages.configGroupBlockFeatures);
+ group.switch("editor.displayImgName", {
+ title: window.siyuan.languages.displayImgName,
+ });
group.switch("editor.displayNetImgMark", {
title: window.siyuan.languages.md7,
desc: window.siyuan.languages.md8,
diff --git a/app/src/editor/rename.ts b/app/src/editor/rename.ts
index 68b4afdb81..7e6ddfbc29 100644
--- a/app/src/editor/rename.ts
+++ b/app/src/editor/rename.ts
@@ -4,7 +4,7 @@ import {focusByRange} from "../protyle/util/selection";
import {hasClosestBlock} from "../protyle/util/hasClosest";
import {removeEmbed} from "../protyle/wysiwyg/removeEmbed";
import {getAssetName, getDisplayName, pathPosix, setNotebookName} from "../util/pathName";
-import {fetchPost} from "../util/fetch";
+import {fetchPost, fetchSyncPost} from "../util/fetch";
import {Constants} from "../constants";
import {showTooltip} from "../dialog/tooltip";
/// #if !MOBILE
@@ -102,30 +102,36 @@ export const renameAsset = (assetPath: string) => {
const dialog = openInputDialog({
title: window.siyuan.languages.rename,
value: oldName,
- onConfirm: (value, dialog) => {
+ onConfirm: async (value, dialog) => {
if (value === oldName || !value) {
dialog.destroy();
return;
}
- fetchPost("/api/asset/renameAsset", {oldPath: assetPath, newName: value}, (response) => {
- /// #if !MOBILE
- getAllModels().asset.forEach(item => {
- if (item.path === assetPath) {
- item.update(response.data.newPath);
- }
- });
- /// #endif
- getAllEditor().forEach(item => {
- item.reload(false);
- });
+ if (await renameAssetFile(assetPath, value)) {
dialog.destroy();
- });
+ }
},
});
dialog.element.setAttribute("data-key", Constants.DIALOG_RENAMEASSETS);
};
+export const renameAssetFile = async (assetPath: string, newName: string): Promise<string | undefined> => {
+ const response = await fetchSyncPost("/api/asset/renameAsset", {oldPath: assetPath, newName});
+ if (response.code !== 0) {
+ return;
+ }
+ /// #if !MOBILE
+ getAllModels().asset.forEach(item => {
+ if (item.path === assetPath) {
+ item.update(response.data.newPath);
+ }
+ });
+ /// #endif
+ getAllEditor().forEach(item => item.reload(false));
+ return response.data.newPath;
+};
+
export const newFileContentBySelect = (protyle: IProtyle) => {
if (getSelection().rangeCount === 0) {
return;
diff --git a/app/src/menus/protyle.ts b/app/src/menus/protyle.ts
index 90cda527ca..5274f029be 100644
--- a/app/src/menus/protyle.ts
+++ b/app/src/menus/protyle.ts
@@ -48,6 +48,7 @@ import {getSearch, isMobile} from "../util/functions";
import * as dayjs from "dayjs";
import {blockRender} from "../protyle/render/blockRender";
import {renameAsset} from "../editor/rename";
+import {renderImageDisplay} from "../protyle/render/imageDisplay";
import {electronUndo} from "../protyle/undo";
import {pushBack} from "../mobile/util/MobileBackFoward";
import {copyPNGByLink, exportAsset, writeAssetToClipboard} from "./util";
@@ -1608,6 +1609,7 @@ export const imgMenu = (protyle: IProtyle, range: Range, assetElement: HTMLEleme
}
imgElement.setAttribute("alt", textElements[2].value.replace(/\n|\r\n|\r|\u2028|\u2029/g, ""));
+ renderImageDisplay(assetElement);
nodeElement.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss"));
updateTransaction(protyle, nodeElement, html);
};
diff --git a/app/src/protyle/render/imageDisplay.test.ts b/app/src/protyle/render/imageDisplay.test.ts
new file mode 100644
index 0000000000..fcb5522df8
--- /dev/null
+++ b/app/src/protyle/render/imageDisplay.test.ts
@@ -0,0 +1,102 @@
+import * as assert from "node:assert/strict";
+import {execFile} from "node:child_process";
+import {mkdtempSync, readFileSync, rmSync, writeFileSync} from "node:fs";
+import {tmpdir} from "node:os";
+import * as path from "node:path";
+import {test} from "node:test";
+import {promisify} from "node:util";
+import {ScriptTarget, transpileModule} from "typescript";
+
+const browserCases = async (source: string, luteSource: string) => {
+ const check: typeof assert = require("node:assert/strict");
+ new Function(luteSource)();
+ const lute = Lute.New();
+ const config = {editor: {displayImgName: true}, readonly: false};
+ Object.assign(window, {siyuan: {config, languages: {rename: "Rename"}}});
+ const renamed: {path: string, name: string}[] = [];
+ const getExtension = (value: string) => require("node:path").posix.extname(value.split("?")[0]);
+ const dependencies = {
+ getAssetExtension: getExtension,
+ getAssetName: (value: string) => require("node:path").posix.basename(value.split("?")[0], getExtension(value))
+ .replace(/-\d{14}-\w{7}$/, ""),
+ isEncryptedBox: (box: string) => box === "encrypted",
+ validateName: () => true,
+ renameAssetFile: async (assetPath: string, name: string) => {
+ renamed.push({path: assetPath, name});
+ return "assets/renamed.png";
+ },
+ };
+ const render = new Function(...Object.keys(dependencies), source + "\nreturn renderImageDisplay;")(...Object.values(dependencies));
+ const root = document.createElement("div");
+ root.className = "protyle-wysiwyg";
+ root.innerHTML = lute.Md2BlockDOM('![description](assets/example-20260930090000-abcdefg.png "caption")');
+ document.body.append(root);
+ const original = lute.BlockDOM2StdMd(root.innerHTML);
+ render(root);
+ render(root);
+ check.equal(root.querySelectorAll(".img__name").length, 1);
+ const name = root.querySelector<HTMLElement>(".img__name");
+ check.equal(name.textContent, "example.png");
+ check.equal(lute.BlockDOM2StdMd(root.innerHTML), original);
+ name.click();
+ let input = name.querySelector("input");
+ check.equal(input.value, "example");
+ check.equal(lute.BlockDOM2StdMd(root.innerHTML), original);
+ input.value = "renamed";
+ input.dispatchEvent(new KeyboardEvent("keydown", {key: "Enter", bubbles: true}));
+ await new Promise(resolve => setTimeout(resolve, 0));
+ check.deepEqual(renamed, [{path: "assets/example-20260930090000-abcdefg.png", name: "renamed"}]);
+ name.click();
+ input = name.querySelector("input");
+ input.value = "discarded";
+ input.dispatchEvent(new KeyboardEvent("keydown", {key: "Escape", bubbles: true}));
+ check.equal(name.querySelector("input"), null);
+ check.equal(renamed.length, 1);
+ root.setAttribute("data-readonly", "true");
+ name.click();
+ check.equal(name.querySelector("input"), null);
+ root.setAttribute("data-readonly", "false");
+ root.setAttribute("data-notebook-id", "encrypted");
+ name.click();
+ check.equal(name.querySelector("input"), null);
+ config.editor.displayImgName = false;
+ render(root);
+ check.equal(root.querySelector(".img__name"), null);
+ check.equal(lute.BlockDOM2StdMd(root.innerHTML), original);
+ return "Image display cases passed";
+};
+
+test("image names support inline renaming without changing document serialization", {
+ skip: process.platform === "linux" && !process.env.DISPLAY && !process.env.WAYLAND_DISPLAY,
+ timeout: 45000,
+}, async () => {
+ const source = transpileModule(readFileSync(path.resolve(__dirname, "imageDisplay.ts"), "utf8")
+ .replace(/^import [\s\S]*?;\r?\n/gm, "").replace(/^export /gm, ""),
+ {compilerOptions: {target: ScriptTarget.ES2021}}).outputText;
+ const luteSource = readFileSync("stage/protyle/js/lute/lute.min.js", "utf8");
+ const temporary = mkdtempSync(path.join(tmpdir(), "siyuan-image-display-test-"));
+ const script = path.join(temporary, "run.cjs");
+ const code = "const __name = value => value; (" + browserCases.toString() + ")(" +
+ JSON.stringify(source) + "," + JSON.stringify(luteSource) + ")";
+ writeFileSync(script, `const {app, BrowserWindow} = require("electron");
+app.setPath("userData", ${JSON.stringify(path.join(temporary, "profile"))});
+app.whenReady().then(async () => {
+ const win = new BrowserWindow({show: false, webPreferences: {nodeIntegration: true, contextIsolation: false}});
+ try {
+ await win.loadURL("data:text/html,<html><body></body></html>");
+ console.log(await win.webContents.executeJavaScript(${JSON.stringify(code)}));
+ app.exit(0);
+ } catch (error) { console.error(error); app.exit(1); }
+});`, "utf8");
+ const env = {...process.env};
+ delete env.ELECTRON_RUN_AS_NODE;
+ try {
+ const result = await promisify(execFile)(require("electron") as unknown as string, [script],
+ {env, windowsHide: true, timeout: 40000});
+ assert.match(result.stdout, /Image display cases passed/);
+ } finally {
+ if (path.dirname(path.resolve(temporary)) === path.resolve(tmpdir()) && path.basename(temporary).startsWith("siyuan-image-display-test-")) {
+ rmSync(temporary, {recursive: true, force: true});
+ }
+ }
+});
diff --git a/app/src/protyle/render/imageDisplay.ts b/app/src/protyle/render/imageDisplay.ts
new file mode 100644
index 0000000000..83dd58b7a0
--- /dev/null
+++ b/app/src/protyle/render/imageDisplay.ts
@@ -0,0 +1,98 @@
+import {getAssetExtension, getAssetName, isEncryptedBox} from "../../util/pathName";
+import {renameAssetFile, validateName} from "../../editor/rename";
+
+const setImageName = (element: HTMLElement, path: string) => {
+ const text = document.createElement("span");
+ text.textContent = getAssetName(path) + getAssetExtension(path);
+ element.replaceChildren(text);
+};
+
+export const renderImageDisplay = (root: Element) => {
+ root.querySelectorAll<HTMLImageElement>(".img img").forEach(image => {
+ const container = image.parentElement;
+ let name = container.querySelector<HTMLElement>(".img__name");
+ const path = image.getAttribute("data-src") || "";
+ if (!window.siyuan.config.editor.displayImgName || !path.startsWith("assets/")) {
+ name?.remove();
+ return;
+ }
+ if (!name) {
+ name = document.createElement("span");
+ name.className = "img__name";
+ name.contentEditable = "false";
+ name.tabIndex = 0;
+ name.setAttribute("role", "button");
+ name.setAttribute("aria-label", window.siyuan.languages.rename);
+ container.insertBefore(name, image);
+ name.addEventListener("mousedown", event => event.stopPropagation());
+ name.addEventListener("keydown", (event: KeyboardEvent) => {
+ if (event.target === name && (event.key === "Enter" || event.key === " ") && !event.isComposing) {
+ event.preventDefault();
+ event.stopPropagation();
+ name.click();
+ }
+ });
+ name.addEventListener("click", event => {
+ event.stopPropagation();
+ if (name.querySelector("input")) {
+ return;
+ }
+ event.preventDefault();
+ const wysiwyg = image.closest(".protyle-wysiwyg");
+ const source = image.getAttribute("data-src");
+ if (!wysiwyg || wysiwyg.getAttribute("data-readonly") === "true" || window.siyuan.config.readonly ||
+ window.siyuan.isPublish || source.includes("?box=") ||
+ isEncryptedBox(image.closest("[data-notebook-id]")?.getAttribute("data-notebook-id"))) {
+ return;
+ }
+ const input = document.createElement("input");
+ input.className = "b3-text-field";
+ input.value = getAssetName(source);
+ input.setAttribute("aria-label", window.siyuan.languages.rename);
+ const extension = document.createElement("span");
+ extension.className = "img__extension";
+ extension.textContent = getAssetExtension(source);
+ name.replaceChildren(input, extension);
+ const restore = () => setImageName(name, image.getAttribute("data-src"));
+ input.addEventListener("blur", () => {
+ if (!input.disabled) {
+ restore();
+ }
+ });
+ input.addEventListener("keydown", async (keyEvent: KeyboardEvent) => {
+ keyEvent.stopPropagation();
+ if (keyEvent.isComposing) {
+ return;
+ }
+ if (keyEvent.key === "Escape") {
+ keyEvent.preventDefault();
+ restore();
+ } else if (keyEvent.key === "Enter") {
+ keyEvent.preventDefault();
+ const value = input.value.trim();
+ if (!value || value === getAssetName(source)) {
+ restore();
+ return;
+ }
+ if (!validateName(value, input) || input.disabled) {
+ return;
+ }
+ input.disabled = true;
+ try {
+ if (await renameAssetFile(source, value)) {
+ restore();
+ }
+ } finally {
+ input.disabled = false;
+ }
+ }
+ });
+ input.focus();
+ input.select();
+ });
+ }
+ if (!name.querySelector("input")) {
+ setImageName(name, path);
+ }
+ });
+};
diff --git a/app/src/protyle/util/processCode.ts b/app/src/protyle/util/processCode.ts
index 7923842f3b..1970bfcc71 100644
--- a/app/src/protyle/util/processCode.ts
+++ b/app/src/protyle/util/processCode.ts
@@ -15,6 +15,7 @@ import {renderEmbedHeadings} from "../render/embedHeading";
import {normalizeInlineElementBoundaries} from "./inlineElementBoundary";
import {renderLongTextRuns} from "./longTextWrap";
import {renderImageActions} from "../render/imageActions";
+import {renderImageDisplay} from "../render/imageDisplay";
export const processPasteCode = (html: string, text: string, originalTextHTML: string, protyle: IProtyle) => {
const tempElement = document.createElement("div");
@@ -65,6 +66,7 @@ const RENDER_MAP: Record<string, (previewPanel: Element) => void> = {
export const processRender = (previewPanel: Element) => {
renderImageActions(previewPanel);
+ renderImageDisplay(previewPanel);
normalizeInlineElementBoundaries(previewPanel);
renderLongTextRuns(previewPanel);
renderEmbedHeadings(previewPanel);
diff --git a/app/src/types/api/index.d.ts b/app/src/types/api/index.d.ts
index ad8d2e26f3..97b803e61f 100644
--- a/app/src/types/api/index.d.ts
+++ b/app/src/types/api/index.d.ts
@@ -1774,7 +1774,7 @@ export type SetCriterionRequestInput = { "criterion": CriterionInput | null; };
export type SetDatabaseBlockViewRequestInput = { "avID": string; "id": string; "viewID": string; };
-export type SetEditorRequestInput = { "allowHTMLBLockScript"?: boolean | null; "allowSVGScript"?: boolean | null; "assetOpen"?: SettingAssetOpenInput | null; "autoDirection"?: boolean | null; "backlinkBlockSort"?: number | null; "backlinkContainChildren"?: boolean | null; "backlinkExpandCount"?: number | null; "backlinkGlobalSort"?: number | null; "backlinkHideReference"?: boolean | null; "backlinkMentionExclude"?: string | null; "backlinkShowBottom"?: boolean | null; "backlinkSort"?: number | null; "backmentionExpandCount"?: number | null; "backmentionSort"?: number | null; "blockRefDynamicAnchorTextMaxLen"?: number | null; "checkBlockRef"?: boolean | null; "codeFontFamilies"?: Array<SettingEditorFontInput | null> | null; "codeLigatures"?: boolean | null; "codeLineWrap"?: boolean | null; "codeSyntaxHighlightLineNum"?: boolean | null; "codeTabSpaces"?: number | null; "cursorSurroundingLines"?: number | null; "databaseAttrClickMode"?: number | null; "databaseAttrHideEmpty"?: boolean | null; "databaseAttrShow"?: boolean | null; "databaseAttrUseTabs"?: boolean | null; "databaseAttrViewMode"?: number | null; "displayBookmarkIcon"?: boolean | null; "displayNetImgMark"?: boolean | null; "dragHTMLFileToIframe"?: boolean | null; "dynamicLoadBlocks"?: number | null; "embedBlockBreadcrumb"?: boolean | null; "emoji"?: Array<string> | null; "floatWindowDelay"?: number | null; "floatWindowMode"?: number | null; "fontFamilies"?: Array<SettingEditorFontInput | null> | null; "fontFamily"?: string | null; "fontFamilyDisplay"?: string | null; "fontSize"?: number | null; "fontSizeScrollZoom"?: boolean | null; "fontWeight"?: number | null; "fullWidth"?: boolean | null; "generateHistoryInterval"?: number | null; "hashTagSearch"?: boolean | null; "headingEmbedMode"?: number | null; "headingNumber"?: boolean | null; "headingNumberFormat"?: string | null; "historyRetentionDays"?: number | null; "justify"?: boolean | null; "katexMacros"?: string | null; "keepLoadedContent"?: boolean | null; "listItemDotNumberClickFocus"?: boolean | null; "listLogicalOutdent"?: boolean | null; "markdown"?: SettingMarkdownInput | null; "onlySearchForDoc"?: boolean | null; "pasteURLAutoConvert"?: boolean | null; "plantUMLServePath"?: string | null; "readOnly"?: boolean | null; "rtl"?: boolean | null; "spellcheck"?: boolean | null; "spellcheckLanguages"?: Array<string> | null; "virtualBlockRef"?: boolean | null; "virtualBlockRefExclude"?: string | null; "virtualBlockRefInclude"?: string | null; };
+export type SetEditorRequestInput = { "allowHTMLBLockScript"?: boolean | null; "allowSVGScript"?: boolean | null; "assetOpen"?: SettingAssetOpenInput | null; "autoDirection"?: boolean | null; "backlinkBlockSort"?: number | null; "backlinkContainChildren"?: boolean | null; "backlinkExpandCount"?: number | null; "backlinkGlobalSort"?: number | null; "backlinkHideReference"?: boolean | null; "backlinkMentionExclude"?: string | null; "backlinkShowBottom"?: boolean | null; "backlinkSort"?: number | null; "backmentionExpandCount"?: number | null; "backmentionSort"?: number | null; "blockRefDynamicAnchorTextMaxLen"?: number | null; "checkBlockRef"?: boolean | null; "codeFontFamilies"?: Array<SettingEditorFontInput | null> | null; "codeLigatures"?: boolean | null; "codeLineWrap"?: boolean | null; "codeSyntaxHighlightLineNum"?: boolean | null; "codeTabSpaces"?: number | null; "cursorSurroundingLines"?: number | null; "databaseAttrClickMode"?: number | null; "databaseAttrHideEmpty"?: boolean | null; "databaseAttrShow"?: boolean | null; "databaseAttrUseTabs"?: boolean | null; "databaseAttrViewMode"?: number | null; "displayBookmarkIcon"?: boolean | null; "displayImgName"?: boolean | null; "displayNetImgMark"?: boolean | null; "dragHTMLFileToIframe"?: boolean | null; "dynamicLoadBlocks"?: number | null; "embedBlockBreadcrumb"?: boolean | null; "emoji"?: Array<string> | null; "floatWindowDelay"?: number | null; "floatWindowMode"?: number | null; "fontFamilies"?: Array<SettingEditorFontInput | null> | null; "fontFamily"?: string | null; "fontFamilyDisplay"?: string | null; "fontSize"?: number | null; "fontSizeScrollZoom"?: boolean | null; "fontWeight"?: number | null; "fullWidth"?: boolean | null; "generateHistoryInterval"?: number | null; "hashTagSearch"?: boolean | null; "headingEmbedMode"?: number | null; "headingNumber"?: boolean | null; "headingNumberFormat"?: string | null; "historyRetentionDays"?: number | null; "justify"?: boolean | null; "katexMacros"?: string | null; "keepLoadedContent"?: boolean | null; "listItemDotNumberClickFocus"?: boolean | null; "listLogicalOutdent"?: boolean | null; "markdown"?: SettingMarkdownInput | null; "onlySearchForDoc"?: boolean | null; "pasteURLAutoConvert"?: boolean | null; "plantUMLServePath"?: string | null; "readOnly"?: boolean | null; "rtl"?: boolean | null; "spellcheck"?: boolean | null; "spellcheckLanguages"?: Array<string> | null; "virtualBlockRef"?: boolean | null; "virtualBlockRefExclude"?: string | null; "virtualBlockRefInclude"?: string | null; };
export type SetEntryVisibilityRequestInput = { "active"?: string | null; "profiles"?: Array<SettingEntryVisibilityProfileInput | null> | null; "version"?: number | null; };
@@ -1900,7 +1900,7 @@ export type SettingEditing = { "maxCompletionTokens": number; "maxHistoryMessage
export type SettingEditingInput = { "maxCompletionTokens"?: number | null; "maxHistoryMessages"?: number | null; "modelId"?: string | null; "temperature"?: number | null; };
-export type SettingEditor = { "allowHTMLBLockScript": boolean; "allowSVGScript": boolean; "assetOpen": SettingAssetOpen | null; "autoDirection": boolean; "backlinkBlockSort": number; "backlinkContainChildren": boolean; "backlinkExpandCount": number; "backlinkGlobalSort": number; "backlinkHideReference": boolean; "backlinkMentionExclude": string; "backlinkShowBottom": boolean; "backlinkSort": number | null; "backmentionExpandCount": number; "backmentionSort": number | null; "blockRefDynamicAnchorTextMaxLen": number; "checkBlockRef": boolean | null; "codeFontFamilies": Array<SettingEditorFont | null> | null; "codeLigatures": boolean; "codeLineWrap": boolean; "codeSyntaxHighlightLineNum": boolean; "codeTabSpaces": number; "cursorSurroundingLines": number; "databaseAttrClickMode": number; "databaseAttrHideEmpty": boolean; "databaseAttrShow": boolean | null; "databaseAttrUseTabs": boolean | null; "databaseAttrViewMode": number; "displayBookmarkIcon": boolean; "displayNetImgMark": boolean; "dragHTMLFileToIframe": boolean; "dynamicLoadBlocks": number; "embedBlockBreadcrumb": boolean; "emoji": Array<string> | null; "floatWindowDelay": number | null; "floatWindowMode": number; "fontFamilies": Array<SettingEditorFont | null> | null; "fontFamily": string; "fontFamilyDisplay": string; "fontSize": number; "fontSizeScrollZoom": boolean; "fontWeight": number; "fullWidth": boolean; "generateHistoryInterval": number; "hashTagSearch": boolean | null; "headingEmbedMode": number; "headingNumber": boolean; "headingNumberFormat": string; "historyRetentionDays": number; "justify": boolean; "katexMacros": string; "keepLoadedContent": boolean; "listItemDotNumberClickFocus": boolean; "listLogicalOutdent": boolean; "markdown": SettingMarkdown | null; "onlySearchForDoc": boolean; "pasteURLAutoConvert": boolean; "plantUMLServePath": string; "readOnly": boolean; "rtl": boolean; "spellcheck": boolean; "spellcheckLanguages": Array<string> | null; "virtualBlockRef": boolean; "virtualBlockRefExclude": string; "virtualBlockRefInclude": string; };
+export type SettingEditor = { "allowHTMLBLockScript": boolean; "allowSVGScript": boolean; "assetOpen": SettingAssetOpen | null; "autoDirection": boolean; "backlinkBlockSort": number; "backlinkContainChildren": boolean; "backlinkExpandCount": number; "backlinkGlobalSort": number; "backlinkHideReference": boolean; "backlinkMentionExclude": string; "backlinkShowBottom": boolean; "backlinkSort": number | null; "backmentionExpandCount": number; "backmentionSort": number | null; "blockRefDynamicAnchorTextMaxLen": number; "checkBlockRef": boolean | null; "codeFontFamilies": Array<SettingEditorFont | null> | null; "codeLigatures": boolean; "codeLineWrap": boolean; "codeSyntaxHighlightLineNum": boolean; "codeTabSpaces": number; "cursorSurroundingLines": number; "databaseAttrClickMode": number; "databaseAttrHideEmpty": boolean; "databaseAttrShow": boolean | null; "databaseAttrUseTabs": boolean | null; "databaseAttrViewMode": number; "displayBookmarkIcon": boolean; "displayImgName": boolean; "displayNetImgMark": boolean; "dragHTMLFileToIframe": boolean; "dynamicLoadBlocks": number; "embedBlockBreadcrumb": boolean; "emoji": Array<string> | null; "floatWindowDelay": number | null; "floatWindowMode": number; "fontFamilies": Array<SettingEditorFont | null> | null; "fontFamily": string; "fontFamilyDisplay": string; "fontSize": number; "fontSizeScrollZoom": boolean; "fontWeight": number; "fullWidth": boolean; "generateHistoryInterval": number; "hashTagSearch": boolean | null; "headingEmbedMode": number; "headingNumber": boolean; "headingNumberFormat": string; "historyRetentionDays": number; "justify": boolean; "katexMacros": string; "keepLoadedContent": boolean; "listItemDotNumberClickFocus": boolean; "listLogicalOutdent": boolean; "markdown": SettingMarkdown | null; "onlySearchForDoc": boolean; "pasteURLAutoConvert": boolean; "plantUMLServePath": string; "readOnly": boolean; "rtl": boolean; "spellcheck": boolean; "spellcheckLanguages": Array<string> | null; "virtualBlockRef": boolean; "virtualBlockRefExclude": string; "virtualBlockRefInclude": string; };
export type SettingEditorFont = { "displayName": string; "family": string; "weight": number; };
diff --git a/app/src/types/config.d.ts b/app/src/types/config.d.ts
index 45eee6eb5d..3dd5fdbf8a 100644
--- a/app/src/types/config.d.ts
+++ b/app/src/types/config.d.ts
@@ -617,6 +617,8 @@ declare namespace Config {
* Whether to display the network image mark
*/
displayNetImgMark: boolean;
+ /** 全局显示图片文件名,默认关闭,不写入文档属性 */
+ displayImgName: boolean;
/**
* Whether to show database attributes at the top of the document
*/
diff --git a/kernel/api/contract_setting_test.go b/kernel/api/contract_setting_test.go
index eb2ecf6088..8e55c7b48b 100644
--- a/kernel/api/contract_setting_test.go
+++ b/kernel/api/contract_setting_test.go
@@ -93,6 +93,42 @@ func TestAPIContractSettingMindmapCompatibility(t *testing.T) {
})
}
+func TestAPIContractSettingImageDisplayCompatibility(t *testing.T) {
+ compareSettingConfig(t, apicontract.SetEditor, conf.NewEditor, []string{
+ `{}`, `{"displayImgName":true}`, `{"displayImgName":false}`,
+ `{"displayImgName":null}`, `{"DisplayImgName":true}`, `{"displayImgName":"bad"}`,
+ })
+}
+
+func TestAPIContractSettingImageDisplayUpdates(t *testing.T) {
+ previousConf, previousReadOnly, previousMarkdown := model.Conf, util.ReadOnly, util.MarkdownSettings
+ model.Conf = model.NewAppConf()
+ model.Conf.Editor = conf.NewEditor()
+ util.ReadOnly = true
+ t.Cleanup(func() {
+ model.Conf, util.ReadOnly, util.MarkdownSettings = previousConf, previousReadOnly, previousMarkdown
+ })
+ for _, entry := range []struct {
+ body string
+ want bool
+ }{
+ {`{"displayImgName":true}`, true},
+ {`{}`, true},
+ {`{"displayImgName":false}`, false},
+ {`{"DisplayImgName":true}`, true},
+ {`{"displayImgName":null}`, false},
+ } {
+ code, message, data := settingContractRequest(t, "setEditor", setEditor, entry.body)
+ var response apicontract.SettingEditor
+ if err := json.Unmarshal(data, &response); err != nil {
+ t.Fatal(err)
+ }
+ if code != 0 || model.Conf.Editor.DisplayImgName != entry.want || response.DisplayImgName != entry.want {
+ t.Fatalf("image display update %s: code=%d message=%s data=%s", entry.body, code, message, data)
+ }
+ }
+}
+
func TestAPIContractSettingParserCompatibility(t *testing.T) {
gin.SetMode(gin.TestMode)
for _, body := range []string{"", `{`, `[]`, `false`, `{"unknown":1e1000}`, `{"app":1e1000,"app":1}`, `{"fontSize":16}{"extra":true}`} {
diff --git a/kernel/api/setting.go b/kernel/api/setting.go
index db0dcf1ce5..4151524325 100644
--- a/kernel/api/setting.go
+++ b/kernel/api/setting.go
@@ -375,6 +375,9 @@ var setEditor = contractHandler(apicontract.SetEditor, func(c *gin.Context, requ
if !request.HasField("codeFontFamilies") {
editor.CodeFontFamilies = model.Conf.Editor.CodeFontFamilies
}
+ if !request.HasFieldFold("displayImgName") {
+ editor.DisplayImgName = model.Conf.Editor.DisplayImgName
+ }
editor.NormalizeFontFamilies()
if "" == editor.PlantUMLServePath {
diff --git a/kernel/api/setting_contract.go b/kernel/api/setting_contract.go
index 6d280306f5..06c0edf705 100644
--- a/kernel/api/setting_contract.go
+++ b/kernel/api/setting_contract.go
@@ -347,6 +347,7 @@ func settingEditorPayload(value *conf.Editor) *apicontract.SettingEditor {
result.CodeLigatures = value.CodeLigatures
result.DisplayBookmarkIcon = value.DisplayBookmarkIcon
result.DisplayNetImgMark = value.DisplayNetImgMark
+ result.DisplayImgName = value.DisplayImgName
result.DatabaseAttrShow = value.DatabaseAttrShow
result.DatabaseAttrClickMode = value.DatabaseAttrClickMode
result.DatabaseAttrViewMode = value.DatabaseAttrViewMode
diff --git a/kernel/apicontract/schema.json b/kernel/apicontract/schema.json
index c421de4ade..6ed0488e85 100644
--- a/kernel/apicontract/schema.json
+++ b/kernel/apicontract/schema.json
@@ -38546,6 +38546,16 @@
}
]
},
+ "displayImgName": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
"displayNetImgMark": {
"anyOf": [
{
@@ -42020,6 +42030,9 @@
"displayBookmarkIcon": {
"type": "boolean"
},
+ "displayImgName": {
+ "type": "boolean"
+ },
"displayNetImgMark": {
"type": "boolean"
},
@@ -42216,6 +42229,7 @@
"databaseAttrUseTabs",
"databaseAttrViewMode",
"displayBookmarkIcon",
+ "displayImgName",
"displayNetImgMark",
"dragHTMLFileToIframe",
"dynamicLoadBlocks",
diff --git a/kernel/apicontract/setting.go b/kernel/apicontract/setting.go
index 6a34a5f980..46c07a9dc4 100644
--- a/kernel/apicontract/setting.go
+++ b/kernel/apicontract/setting.go
@@ -174,6 +174,7 @@ type SettingFlashcard struct {
Weights string `json:"weights" api:"optional,nullable"`
}
+// SettingEditor 描述编辑器配置。displayImgName 默认关闭,更新设置时省略该字段保留当前值。
type SettingEditor struct {
AllowSVGScript bool `json:"allowSVGScript" api:"optional,nullable"`
AllowHTMLBLockScript bool `json:"allowHTMLBLockScript" api:"optional,nullable"`
@@ -191,6 +192,7 @@ type SettingEditor struct {
CodeLigatures bool `json:"codeLigatures" api:"optional,nullable"`
DisplayBookmarkIcon bool `json:"displayBookmarkIcon" api:"optional,nullable"`
DisplayNetImgMark bool `json:"displayNetImgMark" api:"optional,nullable"`
+ DisplayImgName bool `json:"displayImgName" api:"optional,nullable"`
DatabaseAttrShow *bool `json:"databaseAttrShow" api:"optional,nullable"`
DatabaseAttrClickMode int `json:"databaseAttrClickMode" api:"optional,nullable"`
DatabaseAttrViewMode int `json:"databaseAttrViewMode" api:"optional,nullable"`
diff --git a/kernel/apicontract/setting_config.go b/kernel/apicontract/setting_config.go
index 5e43da85fa..d5684feb14 100644
--- a/kernel/apicontract/setting_config.go
+++ b/kernel/apicontract/setting_config.go
@@ -20,6 +20,16 @@ func (r settingConfig) ConfigJSON() []byte { return append([]byte(nil), r
func (r settingConfig) ConfigError() error { return r.configError }
func (r settingConfig) HasField(name string) bool { _, ok := r.fields[name]; return ok }
+// HasFieldFold 按配置结构的大小写兼容规则检查字段是否提交。
+func (r settingConfig) HasFieldFold(name string) bool {
+ for field := range r.fields {
+ if strings.EqualFold(field, name) {
+ return true
+ }
+ }
+ return false
+}
+
func decodeSettingConfig(reader io.Reader, path string, removeApp bool) (r settingConfig, err error) {
var raw json.RawMessage
err = json.NewDecoder(reader).Decode(&raw)
diff --git a/kernel/conf/editor.go b/kernel/conf/editor.go
index 6ee4e7ff35..49397e31a1 100644
--- a/kernel/conf/editor.go
+++ b/kernel/conf/editor.go
@@ -60,6 +60,7 @@ type Editor struct {
CodeLigatures bool `json:"codeLigatures"` // 代码块是否连字
DisplayBookmarkIcon bool `json:"displayBookmarkIcon"` // 是否显示内容块角标
DisplayNetImgMark bool `json:"displayNetImgMark"` // 是否显示网络图片角标
+ DisplayImgName bool `json:"displayImgName"` // 是否显示图片文件名
DatabaseAttrShow *bool `json:"databaseAttrShow"` // 是否在文档顶部显示数据库属性
DatabaseAttrClickMode int `json:"databaseAttrClickMode"` // 数据库角标点击模式,0:聚焦块并展开数据库面板,1:打开块属性面板
DatabaseAttrViewMode int `json:"databaseAttrViewMode"` // 数据库属性默认展开状态,0:展开,1:折叠