Skip to content

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

:bug: Honor embedded breadcrumb preferences and inherited defaults https://github.com/siyuan-note/siyuan/issues/20698

Daniel5c50b8e622c6
diff --git a/app/appearance/langs/ar.json b/app/appearance/langs/ar.json
index 08f9c54c99..f9220691ee 100644
--- a/app/appearance/langs/ar.json
+++ b/app/appearance/langs/ar.json
@@ -1,4 +1,5 @@
{
+ "embedBlockBreadcrumbParentPathTip": "إظهار المسار فوق المستند في مسارات تنقل الكتل المضمنة؛ الإعداد الافتراضي لكل كتلة يتبع هذا الخيار",
"documentCreationRecovery": "قد تكون بعض المستندات قد أُنشئت بالفعل. تحقق من الروابط قبل المتابعة. ستحتفظ المتابعة بالمستندات الموجودة وتتخطى خطوات إنشائها المتبقية. الإلغاء ينهي هذه المحاولة.",
"documentCreationLimit": "أكمل عملية إنشاء مستندات معلقة أو ألغها قبل بدء عملية جديدة",
"listMindmapRestoreWidth": "استعادة العرض الأصلي",
diff --git a/app/appearance/langs/de.json b/app/appearance/langs/de.json
index f4bb76eea8..8fd746d4a2 100644
--- a/app/appearance/langs/de.json
+++ b/app/appearance/langs/de.json
@@ -1,4 +1,5 @@
{
+ "embedBlockBreadcrumbParentPathTip": "Den Pfad oberhalb des Dokuments in Breadcrumbs eingebetteter Blöcke anzeigen; die Blockoption Standard übernimmt diese Einstellung",
"documentCreationRecovery": "Einige Dokumente wurden möglicherweise bereits erstellt. Prüfen Sie die Links, bevor Sie fortfahren. Beim Fortfahren bleiben vorhandene Dokumente erhalten und ihre restlichen Erstellungsschritte werden übersprungen. Abbrechen beendet diesen Vorgang.",
"documentCreationLimit": "Schließen Sie eine ausstehende Dokumenterstellung ab oder brechen Sie sie ab, bevor Sie eine neue beginnen",
"listMindmapRestoreWidth": "Ursprüngliche Breiten wiederherstellen",
diff --git a/app/appearance/langs/en.json b/app/appearance/langs/en.json
index bd28f17a1b..a76793ae06 100644
--- a/app/appearance/langs/en.json
+++ b/app/appearance/langs/en.json
@@ -1,4 +1,5 @@
{
+ "embedBlockBreadcrumbParentPathTip": "Show the path above the document in embedded block breadcrumbs; each block follows this setting when set to Default",
"documentCreationRecovery": "Some documents may already exist. Check the links before continuing. Continuing keeps existing documents and skips their remaining creation steps. Cancel ends this creation attempt.",
"documentCreationLimit": "Finish or cancel a pending document creation before starting another",
"listMindmapRestoreWidth": "Restore original widths",
diff --git a/app/appearance/langs/es.json b/app/appearance/langs/es.json
index 2445f4051d..898b4ee676 100644
--- a/app/appearance/langs/es.json
+++ b/app/appearance/langs/es.json
@@ -1,4 +1,5 @@
{
+ "embedBlockBreadcrumbParentPathTip": "Mostrar la ruta superior al documento en las rutas de navegación de bloques incrustados; cada bloque hereda este ajuste al elegir Predeterminado",
"documentCreationRecovery": "Es posible que algunos documentos ya se hayan creado. Revise los enlaces antes de continuar. Al continuar se conservan los documentos existentes y se omiten los pasos de creación pendientes. Cancelar finaliza este intento.",
"documentCreationLimit": "Complete o cancele una creación de documentos pendiente antes de iniciar otra",
"listMindmapRestoreWidth": "Restaurar los anchos originales",
diff --git a/app/appearance/langs/fr.json b/app/appearance/langs/fr.json
index 7525c7e927..6f59b70ba8 100644
--- a/app/appearance/langs/fr.json
+++ b/app/appearance/langs/fr.json
@@ -1,4 +1,5 @@
{
+ "embedBlockBreadcrumbParentPathTip": "Afficher le chemin au-dessus du document dans le fil d’Ariane des blocs intégrés ; chaque bloc hérite de ce réglage avec l’option Par défaut",
"documentCreationRecovery": "Certains documents existent peut-être déjà. Vérifiez les liens avant de continuer. Continuer conserve les documents existants et ignore leurs étapes de création restantes. Annuler met fin à cette création.",
"documentCreationLimit": "Terminez ou annulez une création de document en attente avant d’en commencer une autre",
"listMindmapRestoreWidth": "Restaurer les largeurs initiales",
diff --git a/app/appearance/langs/he.json b/app/appearance/langs/he.json
index b88bbf9ef0..a49a1fe731 100644
--- a/app/appearance/langs/he.json
+++ b/app/appearance/langs/he.json
@@ -1,4 +1,5 @@
{
+ "embedBlockBreadcrumbParentPathTip": "הצגת הנתיב שמעל למסמך בפירורי הלחם של בלוקים מוטמעים; כל בלוק יורש הגדרה זו כאשר נבחרת ברירת המחדל",
"documentCreationRecovery": "ייתכן שחלק מהמסמכים כבר נוצרו. בדקו את הקישורים לפני ההמשך. המשך ישמור על המסמכים הקיימים וידלג על שלבי היצירה שנותרו. ביטול יסיים ניסיון זה.",
"documentCreationLimit": "יש להשלים או לבטל יצירת מסמכים ממתינה לפני שמתחילים יצירה חדשה",
"listMindmapRestoreWidth": "שחזור הרוחב המקורי",
diff --git a/app/appearance/langs/hi.json b/app/appearance/langs/hi.json
index 078309f838..ba22bfabc7 100644
--- a/app/appearance/langs/hi.json
+++ b/app/appearance/langs/hi.json
@@ -1,4 +1,5 @@
{
+ "embedBlockBreadcrumbParentPathTip": "एम्बेड किए गए ब्लॉक के ब्रेडक्रंब में दस्तावेज़ के ऊपर का पथ दिखाएँ; डिफ़ॉल्ट चुने जाने पर हर ब्लॉक इस सेटिंग का पालन करता है",
"documentCreationRecovery": "कुछ दस्तावेज़ पहले ही बन चुके हो सकते हैं। जारी रखने से पहले लिंक जाँचें। जारी रखने पर मौजूदा दस्तावेज़ सुरक्षित रहेंगे और उनके बचे हुए निर्माण चरण छोड़ दिए जाएँगे। रद्द करने पर यह प्रयास समाप्त होगा।",
"documentCreationLimit": "नया निर्माण शुरू करने से पहले लंबित दस्तावेज़ निर्माण पूरा करें या रद्द करें",
"listMindmapRestoreWidth": "मूल चौड़ाई बहाल करें",
diff --git a/app/appearance/langs/id.json b/app/appearance/langs/id.json
index fdad0d3f4a..057a3c160a 100644
--- a/app/appearance/langs/id.json
+++ b/app/appearance/langs/id.json
@@ -1,4 +1,5 @@
{
+ "embedBlockBreadcrumbParentPathTip": "Tampilkan jalur di atas dokumen pada breadcrumb blok tersemat; setiap blok mengikuti pengaturan ini saat memilih Bawaan",
"documentCreationRecovery": "Beberapa dokumen mungkin sudah dibuat. Periksa tautan sebelum melanjutkan. Melanjutkan akan mempertahankan dokumen yang ada dan melewati tahap pembuatan yang tersisa. Membatalkan mengakhiri percobaan ini.",
"documentCreationLimit": "Selesaikan atau batalkan pembuatan dokumen yang tertunda sebelum memulai yang baru",
"listMindmapRestoreWidth": "Pulihkan lebar semula",
diff --git a/app/appearance/langs/it.json b/app/appearance/langs/it.json
index 13a6954ad6..dc9ac3ca08 100644
--- a/app/appearance/langs/it.json
+++ b/app/appearance/langs/it.json
@@ -1,4 +1,5 @@
{
+ "embedBlockBreadcrumbParentPathTip": "Mostra il percorso sopra il documento nei breadcrumb dei blocchi incorporati; ogni blocco eredita questa impostazione scegliendo Predefinito",
"documentCreationRecovery": "Alcuni documenti potrebbero essere già stati creati. Controlla i collegamenti prima di continuare. Continuando, i documenti esistenti vengono conservati e i passaggi di creazione rimanenti vengono saltati. Annulla termina questo tentativo.",
"documentCreationLimit": "Completa o annulla una creazione di documenti in sospeso prima di avviarne un’altra",
"listMindmapRestoreWidth": "Ripristina le larghezze originali",
diff --git a/app/appearance/langs/ja.json b/app/appearance/langs/ja.json
index a57abdc08e..f6a4240f8b 100644
--- a/app/appearance/langs/ja.json
+++ b/app/appearance/langs/ja.json
@@ -1,4 +1,5 @@
{
+ "embedBlockBreadcrumbParentPathTip": "埋め込みブロックのパンくずに文書より上のパスを表示します。各ブロックで「デフォルト」を選ぶと、この設定に従います",
"documentCreationRecovery": "一部のドキュメントは作成済みの可能性があります。続行する前にリンクから確認してください。続行すると既存のドキュメントを保持し、残りの作成処理をスキップします。キャンセルすると今回の作成を終了します。",
"documentCreationLimit": "新たに作成する前に、保留中のドキュメント作成を完了するかキャンセルしてください",
"listMindmapRestoreWidth": "元の幅に戻す",
diff --git a/app/appearance/langs/ko.json b/app/appearance/langs/ko.json
index a05e1a328c..a05e5950c1 100644
--- a/app/appearance/langs/ko.json
+++ b/app/appearance/langs/ko.json
@@ -1,4 +1,5 @@
{
+ "embedBlockBreadcrumbParentPathTip": "임베드 블록의 탐색 경로에 문서 상위 경로를 표시하며, 각 블록에서 기본값을 선택하면 이 설정을 따릅니다",
"documentCreationRecovery": "일부 문서가 이미 생성되었을 수 있습니다. 계속하기 전에 링크를 확인하세요. 계속하면 기존 문서를 유지하고 남은 생성 단계를 건너뜁니다. 취소하면 이번 생성을 종료합니다.",
"documentCreationLimit": "새로 시작하기 전에 대기 중인 문서 생성을 완료하거나 취소하세요",
"listMindmapRestoreWidth": "원래 너비 복원",
diff --git a/app/appearance/langs/nl.json b/app/appearance/langs/nl.json
index b6dce94574..d5c521079e 100644
--- a/app/appearance/langs/nl.json
+++ b/app/appearance/langs/nl.json
@@ -1,4 +1,5 @@
{
+ "embedBlockBreadcrumbParentPathTip": "Toon het pad boven het document in broodkruimels van ingesloten blokken; elk blok volgt deze instelling bij Standaard",
"documentCreationRecovery": "Sommige documenten zijn mogelijk al aangemaakt. Controleer de links voordat u doorgaat. Doorgaan behoudt bestaande documenten en slaat hun resterende aanmaakstappen over. Annuleren beëindigt deze poging.",
"documentCreationLimit": "Voltooi of annuleer een lopende documentaanmaak voordat u een nieuwe start",
"listMindmapRestoreWidth": "Oorspronkelijke breedtes herstellen",
diff --git a/app/appearance/langs/pl.json b/app/appearance/langs/pl.json
index f971415b9d..3225838b28 100644
--- a/app/appearance/langs/pl.json
+++ b/app/appearance/langs/pl.json
@@ -1,4 +1,5 @@
{
+ "embedBlockBreadcrumbParentPathTip": "Pokazuj ścieżkę nadrzędną dokumentu w nawigacji osadzonych bloków; wybranie opcji Domyślne powoduje dziedziczenie tego ustawienia",
"documentCreationRecovery": "Niektóre dokumenty mogły już zostać utworzone. Przed kontynuowaniem sprawdź łącza. Kontynuacja zachowa istniejące dokumenty i pominie pozostałe etapy ich tworzenia. Anulowanie zakończy tę próbę.",
"documentCreationLimit": "Zakończ lub anuluj oczekujące tworzenie dokumentów przed rozpoczęciem kolejnego",
"listMindmapRestoreWidth": "Przywróć pierwotne szerokości",
diff --git a/app/appearance/langs/pt-BR.json b/app/appearance/langs/pt-BR.json
index e5427d4cbc..371bcbe62e 100644
--- a/app/appearance/langs/pt-BR.json
+++ b/app/appearance/langs/pt-BR.json
@@ -1,4 +1,5 @@
{
+ "embedBlockBreadcrumbParentPathTip": "Mostrar o caminho acima do documento na navegação de blocos incorporados; cada bloco herda esta configuração ao escolher Padrão",
"documentCreationRecovery": "Alguns documentos podem já ter sido criados. Verifique os links antes de continuar. Continuar mantém os documentos existentes e ignora as etapas de criação restantes. Cancelar encerra esta tentativa.",
"documentCreationLimit": "Conclua ou cancele uma criação de documentos pendente antes de iniciar outra",
"listMindmapRestoreWidth": "Restaurar larguras originais",
diff --git a/app/appearance/langs/ru.json b/app/appearance/langs/ru.json
index 67182c9f18..8eefd4f520 100644
--- a/app/appearance/langs/ru.json
+++ b/app/appearance/langs/ru.json
@@ -1,4 +1,5 @@
{
+ "embedBlockBreadcrumbParentPathTip": "Показывать путь выше документа в навигационной цепочке встроенных блоков; при выборе значения «По умолчанию» блок наследует эту настройку",
"documentCreationRecovery": "Некоторые документы, возможно, уже созданы. Перед продолжением проверьте ссылки. Продолжение сохранит существующие документы и пропустит оставшиеся этапы их создания. Отмена завершит эту попытку.",
"documentCreationLimit": "Завершите или отмените ожидающее создание документов, прежде чем начать новое",
"listMindmapRestoreWidth": "Восстановить исходную ширину",
diff --git a/app/appearance/langs/sk.json b/app/appearance/langs/sk.json
index f796d8d31c..81e24e928b 100644
--- a/app/appearance/langs/sk.json
+++ b/app/appearance/langs/sk.json
@@ -1,4 +1,5 @@
{
+ "embedBlockBreadcrumbParentPathTip": "Zobraziť cestu nad dokumentom v navigácii vložených blokov; pri voľbe Predvolené blok zdedí toto nastavenie",
"documentCreationRecovery": "Niektoré dokumenty už možno boli vytvorené. Pred pokračovaním skontrolujte odkazy. Pokračovanie zachová existujúce dokumenty a preskočí zostávajúce kroky ich vytvárania. Zrušenie ukončí tento pokus.",
"documentCreationLimit": "Pred začatím ďalšieho vytvárania dokumentov dokončite alebo zrušte čakajúce vytváranie",
"listMindmapRestoreWidth": "Obnoviť pôvodné šírky",
diff --git a/app/appearance/langs/sr.json b/app/appearance/langs/sr.json
index 1150de604a..6643c31e3c 100644
--- a/app/appearance/langs/sr.json
+++ b/app/appearance/langs/sr.json
@@ -1,4 +1,5 @@
{
+ "embedBlockBreadcrumbParentPathTip": "Прикажи путању изнад документа у навигацији уграђених блокова; сваки блок наслеђује ово подешавање када изабере подразумевану вредност",
"documentCreationRecovery": "Неки документи су можда већ направљени. Проверите везе пре него што наставите. Наставак задржава постојеће документе и прескаче преостале кораке њиховог прављења. Отказивање завршава овај покушај.",
"documentCreationLimit": "Завршите или откажите прављење докумената на чекању пре него што започнете ново",
"listMindmapRestoreWidth": "Врати првобитне ширине",
diff --git a/app/appearance/langs/th.json b/app/appearance/langs/th.json
index d8514f4512..e40b1e9661 100644
--- a/app/appearance/langs/th.json
+++ b/app/appearance/langs/th.json
@@ -1,4 +1,5 @@
{
+ "embedBlockBreadcrumbParentPathTip": "แสดงเส้นทางเหนือเอกสารในแถบนำทางของบล็อกฝัง แต่ละบล็อกจะใช้การตั้งค่านี้เมื่อเลือกค่าเริ่มต้น",
"documentCreationRecovery": "เอกสารบางส่วนอาจถูกสร้างแล้ว โปรดตรวจสอบลิงก์ก่อนดำเนินการต่อ การดำเนินการต่อจะเก็บเอกสารที่มีอยู่และข้ามขั้นตอนการสร้างที่เหลือ การยกเลิกจะสิ้นสุดการสร้างครั้งนี้",
"documentCreationLimit": "โปรดดำเนินการสร้างเอกสารที่ค้างอยู่ให้เสร็จหรือยกเลิกก่อนเริ่มสร้างใหม่",
"listMindmapRestoreWidth": "คืนค่าความกว้างเดิม",
diff --git a/app/appearance/langs/tr.json b/app/appearance/langs/tr.json
index 44e1ae0d77..067e0b7117 100644
--- a/app/appearance/langs/tr.json
+++ b/app/appearance/langs/tr.json
@@ -1,4 +1,5 @@
{
+ "embedBlockBreadcrumbParentPathTip": "Gömülü blokların içerik haritasında belgenin üst yolunu göster; Varsayılan seçildiğinde her blok bu ayarı devralır",
"documentCreationRecovery": "Bazı belgeler zaten oluşturulmuş olabilir. Devam etmeden önce bağlantıları kontrol edin. Devam etmek mevcut belgeleri korur ve kalan oluşturma adımlarını atlar. İptal, bu denemeyi sonlandırır.",
"documentCreationLimit": "Yeni bir belge oluşturma işlemine başlamadan önce bekleyen işlemi tamamlayın veya iptal edin",
"listMindmapRestoreWidth": "Özgün genişlikleri geri yükle",
diff --git a/app/appearance/langs/uk.json b/app/appearance/langs/uk.json
index 73281ca9de..dc4eed66e4 100644
--- a/app/appearance/langs/uk.json
+++ b/app/appearance/langs/uk.json
@@ -1,4 +1,5 @@
{
+ "embedBlockBreadcrumbParentPathTip": "Показувати шлях над документом у навігаційному ланцюжку вбудованих блоків; за вибору «Типово» блок успадковує це налаштування",
"documentCreationRecovery": "Деякі документи, можливо, вже створено. Перед продовженням перевірте посилання. Продовження збереже наявні документи та пропустить решту етапів їх створення. Скасування завершить цю спробу.",
"documentCreationLimit": "Завершіть або скасуйте незавершене створення документів, перш ніж починати нове",
"listMindmapRestoreWidth": "Відновити початкову ширину",
diff --git a/app/appearance/langs/zh-CN.json b/app/appearance/langs/zh-CN.json
index e7630c3563..b402f34ae7 100644
--- a/app/appearance/langs/zh-CN.json
+++ b/app/appearance/langs/zh-CN.json
@@ -1,4 +1,5 @@
{
+ "embedBlockBreadcrumbParentPathTip": "显示嵌入块所在文档的上层路径;块级选项选择“默认”时继承此设置",
"documentCreationRecovery": "部分文档可能已创建,请先通过链接检查。继续将保留已有文档,并跳过其尚未完成的创建处理。取消会结束本次创建。",
"documentCreationLimit": "请先完成或取消待处理的文档创建,再开始新的创建",
"listMindmapRestoreWidth": "恢复原宽度",
diff --git a/app/appearance/langs/zh-TW.json b/app/appearance/langs/zh-TW.json
index 2707c21f9b..aac104cac7 100644
--- a/app/appearance/langs/zh-TW.json
+++ b/app/appearance/langs/zh-TW.json
@@ -1,4 +1,5 @@
{
+ "embedBlockBreadcrumbParentPathTip": "顯示嵌入區塊所在文件的上層路徑;區塊選項選擇「預設」時繼承此設定",
"documentCreationRecovery": "部分文件可能已建立,請先透過連結檢查。繼續將保留既有文件,並略過其尚未完成的建立處理。取消會結束本次建立。",
"documentCreationLimit": "請先完成或取消待處理的文件建立,再開始新的建立",
"listMindmapRestoreWidth": "還原原始寬度",
diff --git a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-h361q1i/20200924093441-ft2rhps.sy b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-h361q1i/20200924093441-ft2rhps.sy
index 65f4dae072..2968bd5627 100644
--- a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-h361q1i/20200924093441-ft2rhps.sy
+++ b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-h361q1i/20200924093441-ft2rhps.sy
@@ -8,7 +8,7 @@
"title": "Formatting elements",
"title-img": "background-color:#269;background-image: linear-gradient(white 2px, transparent 2px),linear-gradient(90deg, white 2px, transparent 2px),linear-gradient(rgba(255,255,255,.3) 1px, transparent 1px),linear-gradient(90deg, rgba(255,255,255,.3) 1px, transparent 1px);background-size: 100px 100px, 100px 100px, 20px 20px, 20px 20px;background-position:-2px -2px, -2px -2px, -1px -1px, -1px -1px;",
"type": "doc",
- "updated": "20261024164212"
+ "updated": "20261024171608"
},
"Children": [
{
@@ -1025,7 +1025,7 @@
"HeadingLevel": 2,
"Properties": {
"id": "20210604225457-7lq09oe",
- "updated": "20220312123239"
+ "updated": "20261024171608"
},
"Children": [
{
@@ -1060,6 +1060,97 @@
}
]
},
+ {
+ "ID": "20261024171608-ctwgnun",
+ "Type": "NodeParagraph",
+ "Properties": {
+ "id": "20261024171608-ctwgnun",
+ "updated": "20261024171608"
+ },
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "In "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "Settings"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " - "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "Editor"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " - "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "Embed block"
+ },
+ {
+ "Type": "NodeText",
+ "Data": ", choose whether embedded blocks show breadcrumbs and include the path above the document. Hiding the parent path keeps the document title and its internal structure."
+ }
+ ]
+ },
+ {
+ "ID": "20261024171608-9eg0kvq",
+ "Type": "NodeParagraph",
+ "Properties": {
+ "id": "20261024171608-9eg0kvq",
+ "updated": "20261024171608"
+ },
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "The block menu entries "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "Embed block"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " - "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "Embed Block Breadcrumb"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " and "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "Embed block"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " - "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "Show parent path in breadcrumbs"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " each offer Enable, Disable and Default. Default removes the block override and follows the global setting."
+ }
+ ]
+ },
{
"ID": "20210604225720-p4ywemu",
"Type": "NodeHeading",
diff --git a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180320-abz7w6k/20200825162036-4dx365o.sy b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180320-abz7w6k/20200825162036-4dx365o.sy
index f32f60b29e..dc66e5559f 100644
--- a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180320-abz7w6k/20200825162036-4dx365o.sy
+++ b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180320-abz7w6k/20200825162036-4dx365o.sy
@@ -8,7 +8,7 @@
"title": "排版元素",
"title-img": "background-color: hsl(2, 57%, 40%);background-image: repeating-linear-gradient(transparent, transparent 50px, rgba(0,0,0,.4) 50px, rgba(0,0,0,.4) 53px, transparent 53px, transparent 63px, rgba(0,0,0,.4) 63px, rgba(0,0,0,.4) 66px, transparent 66px, transparent 116px, rgba(0,0,0,.5) 116px, rgba(0,0,0,.5) 166px, rgba(255,255,255,.2) 166px, rgba(255,255,255,.2) 169px, rgba(0,0,0,.5) 169px, rgba(0,0,0,.5) 179px, rgba(255,255,255,.2) 179px, rgba(255,255,255,.2) 182px, rgba(0,0,0,.5) 182px, rgba(0,0,0,.5) 232px, transparent 232px),repeating-linear-gradient(270deg, transparent, transparent 50px, rgba(0,0,0,.4) 50px, rgba(0,0,0,.4) 53px, transparent 53px, transparent 63px, rgba(0,0,0,.4) 63px, rgba(0,0,0,.4) 66px, transparent 66px, transparent 116px, rgba(0,0,0,.5) 116px, rgba(0,0,0,.5) 166px, rgba(255,255,255,.2) 166px, rgba(255,255,255,.2) 169px, rgba(0,0,0,.5) 169px, rgba(0,0,0,.5) 179px, rgba(255,255,255,.2) 179px, rgba(255,255,255,.2) 182px, rgba(0,0,0,.5) 182px, rgba(0,0,0,.5) 232px, transparent 232px),repeating-linear-gradient(125deg, transparent, transparent 2px, rgba(0,0,0,.2) 2px, rgba(0,0,0,.2) 3px, transparent 3px, transparent 5px, rgba(0,0,0,.2) 5px);",
"type": "doc",
- "updated": "20261024164212"
+ "updated": "20261024171629"
},
"Children": [
{
@@ -1036,7 +1036,7 @@
"HeadingLevel": 2,
"Properties": {
"id": "20210604182944-w4gwxvw",
- "updated": "20210604183242"
+ "updated": "20261024171629"
},
"Children": [
{
@@ -1071,6 +1071,97 @@
}
]
},
+ {
+ "ID": "20261024171629-13627i6",
+ "Type": "NodeParagraph",
+ "Properties": {
+ "id": "20261024171629-13627i6",
+ "updated": "20261024171629"
+ },
+ "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": " 中,可设置嵌入块是否显示面包屑,以及是否包含文档上层路径。隐藏上层路径后,保留文档名和文档内部结构。"
+ }
+ ]
+ },
+ {
+ "ID": "20261024171629-0mqjg6y",
+ "Type": "NodeParagraph",
+ "Properties": {
+ "id": "20261024171629-0mqjg6y",
+ "updated": "20261024171629"
+ },
+ "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": " - "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "面包屑显示文档上层路径"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " 均提供“启用”“禁用”“默认”选项。选择“默认”会移除块级属性,继承全局设置。"
+ }
+ ]
+ },
{
"ID": "20210604222535-cb4cjo9",
"Type": "NodeHeading",
diff --git a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226120854-dr1jfx2/20211226121319-emrk2yy.sy b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226120854-dr1jfx2/20211226121319-emrk2yy.sy
index 662f9ccda8..f23459f4fd 100644
--- a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226120854-dr1jfx2/20211226121319-emrk2yy.sy
+++ b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226120854-dr1jfx2/20211226121319-emrk2yy.sy
@@ -8,7 +8,7 @@
"title": "排版元素",
"title-img": "background-color: hsl(2, 57%, 40%);background-image: repeating-linear-gradient(transparent, transparent 50px, rgba(0,0,0,.4) 50px, rgba(0,0,0,.4) 53px, transparent 53px, transparent 63px, rgba(0,0,0,.4) 63px, rgba(0,0,0,.4) 66px, transparent 66px, transparent 116px, rgba(0,0,0,.5) 116px, rgba(0,0,0,.5) 166px, rgba(255,255,255,.2) 166px, rgba(255,255,255,.2) 169px, rgba(0,0,0,.5) 169px, rgba(0,0,0,.5) 179px, rgba(255,255,255,.2) 179px, rgba(255,255,255,.2) 182px, rgba(0,0,0,.5) 182px, rgba(0,0,0,.5) 232px, transparent 232px),repeating-linear-gradient(270deg, transparent, transparent 50px, rgba(0,0,0,.4) 50px, rgba(0,0,0,.4) 53px, transparent 53px, transparent 63px, rgba(0,0,0,.4) 63px, rgba(0,0,0,.4) 66px, transparent 66px, transparent 116px, rgba(0,0,0,.5) 116px, rgba(0,0,0,.5) 166px, rgba(255,255,255,.2) 166px, rgba(255,255,255,.2) 169px, rgba(0,0,0,.5) 169px, rgba(0,0,0,.5) 179px, rgba(255,255,255,.2) 179px, rgba(255,255,255,.2) 182px, rgba(0,0,0,.5) 182px, rgba(0,0,0,.5) 232px, transparent 232px),repeating-linear-gradient(125deg, transparent, transparent 2px, rgba(0,0,0,.2) 2px, rgba(0,0,0,.2) 3px, transparent 3px, transparent 5px, rgba(0,0,0,.2) 5px);",
"type": "doc",
- "updated": "20261024164212"
+ "updated": "20261024171629"
},
"Children": [
{
@@ -1032,7 +1032,7 @@
"HeadingLevel": 2,
"Properties": {
"id": "20211226122008-ju18gnz",
- "updated": "20260730184353"
+ "updated": "20261024171629"
},
"Children": [
{
@@ -1068,6 +1068,97 @@
}
]
},
+ {
+ "ID": "20261024171629-c82rywv",
+ "Type": "NodeParagraph",
+ "Properties": {
+ "id": "20261024171629-c82rywv",
+ "updated": "20261024171629"
+ },
+ "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": " 中,可設定嵌入區塊是否顯示麵包屑,以及是否包含文件上層路徑。隱藏上層路徑後,保留文件名稱和文件內部結構。"
+ }
+ ]
+ },
+ {
+ "ID": "20261024171629-v4rxlyd",
+ "Type": "NodeParagraph",
+ "Properties": {
+ "id": "20261024171629-v4rxlyd",
+ "updated": "20261024171629"
+ },
+ "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": " - "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "麵包屑顯示文件上層路徑"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " 均提供「啟用」「禁用」「預設」選項。選擇「預設」會移除區塊屬性,繼承全域設定。"
+ }
+ ]
+ },
{
"ID": "20211226122008-hsi1yp3",
"Type": "NodeHeading",
diff --git a/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-hnu6o79/20240530101000-3qhz7br.sy b/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-hnu6o79/20240530101000-3qhz7br.sy
index 125c7769cc..98b684f634 100644
--- a/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-hnu6o79/20240530101000-3qhz7br.sy
+++ b/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-hnu6o79/20240530101000-3qhz7br.sy
@@ -9,7 +9,7 @@
"title": "書式要素",
"title-img": "background-color:#269;background-image: linear-gradient(white 2px, transparent 2px),linear-gradient(90deg, white 2px, transparent 2px),linear-gradient(rgba(255,255,255,.3) 1px, transparent 1px),linear-gradient(90deg, rgba(255,255,255,.3) 1px, transparent 1px);background-size: 100px 100px, 100px 100px, 20px 20px, 20px 20px;background-position:-2px -2px, -2px -2px, -1px -1px, -1px -1px;",
"type": "doc",
- "updated": "20261024164212"
+ "updated": "20261024171629"
},
"Children": [
{
@@ -1109,7 +1109,7 @@
"Properties": {
"ID": "20240530101000-9o5xpb4",
"id": "20240530101000-69e5xnn",
- "updated": "20240530101000"
+ "updated": "20261024171629"
},
"Children": [
{
@@ -1145,6 +1145,93 @@
}
]
},
+ {
+ "ID": "20261024171629-7jfvtsh",
+ "Type": "NodeParagraph",
+ "Properties": {
+ "id": "20261024171629-7jfvtsh",
+ "updated": "20261024171629"
+ },
+ "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": "20261024171629-mnsfr9m",
+ "Type": "NodeParagraph",
+ "Properties": {
+ "id": "20261024171629-mnsfr9m",
+ "updated": "20261024171629"
+ },
+ "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": " - "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "パンくずリストに文書の上位パスを表示"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " では、有効、無効、デフォルトを選べます。デフォルトに戻すとブロックの属性が削除され、全体設定に従います。"
+ }
+ ]
+ },
{
"ID": "20240530101000-qip5gt3",
"Type": "NodeHeading",
diff --git a/app/src/config/entryVisibility/catalog.test.ts b/app/src/config/entryVisibility/catalog.test.ts
index 816ab8a065..b5473df696 100644
--- a/app/src/config/entryVisibility/catalog.test.ts
+++ b/app/src/config/entryVisibility/catalog.test.ts
@@ -109,6 +109,14 @@ test("embedded heading levels follow display modes and expose all levels in Simp
const levelPath = `${path}.embedHeadingLevel`;
assert.equal(getEntryCatalogNode(`${path}.embedBlockBreadcrumbParentPath`)?.simple, true);
assert.equal(getEntryParentPath(`${path}.embedBlockBreadcrumbParentPath`), path);
+ for (const key of ["embedBlockBreadcrumb", "embedBlockBreadcrumbParentPath"]) {
+ const parent = `${path}.${key}`;
+ assert.deepEqual(getEntryCatalogChildren(parent).map(item => item.key), ["enable", "disable", "default"]);
+ getEntryCatalogChildren(parent).forEach(item => {
+ assert.equal(item.simple, true);
+ assert.equal(getEntryParentPath(`${parent}.${item.key}`), parent);
+ });
+ }
assert.equal(getEntryCatalogNode(levelPath)?.simple, true);
assert.deepEqual(getEntryCatalogChildren(levelPath).map(entry => entry.key), [
"auto", "heading1", "heading2", "heading3", "heading4", "heading5", "heading6",
diff --git a/app/src/config/entryVisibility/catalog.ts b/app/src/config/entryVisibility/catalog.ts
index 51e946ecda..2b7da4e2ee 100644
--- a/app/src/config/entryVisibility/catalog.ts
+++ b/app/src/config/entryVisibility/catalog.ts
@@ -451,8 +451,11 @@ const gutterSingle = () => [
node("refresh", lang("refresh")),
node("update", lang("update")),
separator("separator_breadcrumb"),
- node("embedBlockBreadcrumb", lang("embedBlockBreadcrumb")),
- node("embedBlockBreadcrumbParentPath", lang("embedBlockBreadcrumbParentPath")),
+ ...["embedBlockBreadcrumb", "embedBlockBreadcrumbParentPath"].map(key => node(key, lang(key), true, [
+ node("enable", lang("enable")),
+ node("disable", lang("disable")),
+ node("default", lang("default")),
+ ])),
node("headingEmbedMode", lang("headingEmbedMode"), true, [
node("showHeadingWithBlocks", lang("showHeadingWithBlocks")),
node("showHeadingOnlyTitle", lang("showHeadingOnlyTitle")),
diff --git a/app/src/config/entryVisibility/order.test.ts b/app/src/config/entryVisibility/order.test.ts
index cf0862d40e..3ffe857acc 100644
--- a/app/src/config/entryVisibility/order.test.ts
+++ b/app/src/config/entryVisibility/order.test.ts
@@ -183,6 +183,8 @@ test("missing table and image actions merge into saved orders while preserving p
{path: "inline.image", added: ["openBy"]},
{path: "gutter.single.copy", added: ["copyMirror"]},
{path: "gutter.single.blockEmbed", added: ["embedHeadingLevel", "embedBlockBreadcrumbParentPath"]},
+ {path: "gutter.single.blockEmbed.embedBlockBreadcrumb", added: ["enable", "disable", "default"]},
+ {path: "gutter.single.blockEmbed.embedBlockBreadcrumbParentPath", added: ["enable", "disable", "default"]},
].forEach(({path, added}) => {
const entries = getEntryCatalogChildren(path);
const defaults = entries.map(item => item.key);
diff --git a/app/src/config/tabs/editorEmbedBreadcrumb.test.ts b/app/src/config/tabs/editorEmbedBreadcrumb.test.ts
new file mode 100644
index 0000000000..49109eab31
--- /dev/null
+++ b/app/src/config/tabs/editorEmbedBreadcrumb.test.ts
@@ -0,0 +1,35 @@
+import * as assert from "node:assert/strict";
+import {readFileSync} from "node:fs";
+import {test} from "node:test";
+import {runInNewContext} from "node:vm";
+import {createSourceFile, ScriptTarget, transpileModule} from "typescript";
+
+for (const mobile of [false, true]) {
+ test(`embed breadcrumb settings use standard switches in the shared embeds group (mobile=${mobile})`, () => {
+ const text = require("ifdef-loader/preprocessor").parse(readFileSync("src/config/tabs/editorTab.ts", "utf8"),
+ {MOBILE: mobile, BROWSER: true}, false, true);
+ const source = createSourceFile("editorTab.ts", text, ScriptTarget.ES2021, true);
+ const declaration = source.statements.find(node => node.getText(source).startsWith("const registerEditorEmbedsGroup ="));
+ assert.ok(declaration);
+ const rows: Array<{kind: string; id: string; options: {title: string; desc: string; save?: unknown}}> = [];
+ const exports = {} as {register: (tab: object) => void};
+ runInNewContext(transpileModule(declaration.getText(source), {compilerOptions: {target: ScriptTarget.ES2021}}).outputText +
+ "\nexports.register = registerEditorEmbedsGroup;", {
+ exports, window: {siyuan: {languages: new Proxy({}, {get: (_, key) => String(key)})}},
+ });
+ exports.register({group: (id: string) => {
+ assert.equal(id, "embeds");
+ return new Proxy({}, {get: (_, kind: string) => (id: string, options: typeof rows[number]["options"]) => {
+ rows.push({kind, id, options});
+ }});
+ }});
+ for (const [index, key] of ["embedBlockBreadcrumb", "embedBlockBreadcrumbParentPath"].entries()) {
+ const row = rows[index + 1];
+ assert.equal(row.id, `editor.${key}`);
+ assert.equal(row.kind, "switch");
+ assert.equal(row.options.title, key);
+ assert.equal(row.options.desc, key + "Tip");
+ assert.equal(row.options.save, undefined, "standard editor configuration persistence is shared across platforms");
+ }
+ });
+}
diff --git a/app/src/config/tabs/editorTab.ts b/app/src/config/tabs/editorTab.ts
index 07fd99cef3..913692d165 100644
--- a/app/src/config/tabs/editorTab.ts
+++ b/app/src/config/tabs/editorTab.ts
@@ -239,6 +239,10 @@ const registerEditorEmbedsGroup = (tab: SettingTabBuilder) => {
title: window.siyuan.languages.embedBlockBreadcrumb,
desc: window.siyuan.languages.embedBlockBreadcrumbTip,
});
+ group.switch("editor.embedBlockBreadcrumbParentPath", {
+ title: window.siyuan.languages.embedBlockBreadcrumbParentPath,
+ desc: window.siyuan.languages.embedBlockBreadcrumbParentPathTip,
+ });
};
const registerEditorImagesGroup = (tab: SettingTabBuilder) => {
diff --git a/app/src/constants.ts b/app/src/constants.ts
index 8d0ef11018..da574b23f6 100644
--- a/app/src/constants.ts
+++ b/app/src/constants.ts
@@ -82,6 +82,7 @@ export abstract class Constants {
public static readonly CUSTOM_REMINDER_WECHAT: string = "custom-reminder-wechat";
public static readonly CUSTOM_RIFF_DECKS: string = "custom-riff-decks";
public static readonly CUSTOM_SY_READONLY: string = "custom-sy-readonly";
+ public static readonly CUSTOM_SY_EMBED_BREADCRUMB_PARENT_PATH: string = "custom-sy-embed-breadcrumb-parent-path";
public static readonly CUSTOM_SY_SUBDOC_SORT_MODE: string = "custom-sy-subdoc-sort-mode";
public static readonly CUSTOM_SY_FULLWIDTH: string = "custom-sy-fullwidth";
public static readonly CUSTOM_SY_HEADING_NUMBER: string = "custom-sy-heading-number";
diff --git a/app/src/menus/menuLayout.dom.test.ts b/app/src/menus/menuLayout.dom.test.ts
index 98fedae1ff..e5f1fee8ac 100644
--- a/app/src/menus/menuLayout.dom.test.ts
+++ b/app/src/menus/menuLayout.dom.test.ts
@@ -25,7 +25,9 @@ const browserCases = async (sources: Record<string, string>, css: string) => {
"util/functions": {isMobile: () => mobile},
"util/zIndex": {isScrollAboveMenu: () => false},
"layout/getTopBarHeight": {getTopBarHeight: () => 32},
- constants: {Constants: {TIMEOUT_DBLCLICK: 10, ATTRIBUTE_MENU_KEYMAP: "data-keymap"}},
+ constants: {Constants: {TIMEOUT_DBLCLICK: 10, ATTRIBUTE_MENU_KEYMAP: "data-keymap",
+ CUSTOM_SY_EMBED_BREADCRUMB_PARENT_PATH: "custom-sy-embed-breadcrumb-parent-path"}},
+ "protyle/render/blockRender": {blockRender() {}},
"protyle/undo": {electronUndo() {}},
"util/escape": {escapeAttr: (value: string) => value || "", escapeHtml: (value: string) => value || ""},
"menus/menuKeyboard": {setMenuInputCurrent() {}},
@@ -46,7 +48,8 @@ const browserCases = async (sources: Record<string, string>, css: string) => {
"protyle/render/av/panels/inputs": {bindAVPanelInputs() {}},
"protyle/render/av/viewType": {},
"protyle/wysiwyg/transaction": {},
- "util/fetch": {fetchSyncPost: async (url: string) => {
+ "util/fetch": {fetchPost: (_url: string, _data: unknown, callback: () => void) => callback(),
+ fetchSyncPost: async (url: string) => {
check.equal(url, "/api/av/getAttributeViewCalendarUndated");
return {code: 0, data: {rows: calendarRows, total: calendarRows.length}};
}},
@@ -155,6 +158,36 @@ const browserCases = async (sources: Record<string, string>, css: string) => {
menu.element.remove();
};
+ const {embedBreadcrumbMenu}: typeof import("../protyle/gutter/embedBreadcrumbMenu") = load("protyle/gutter/embedBreadcrumbMenu");
+ Object.assign(window.siyuan.languages, {embedBlockBreadcrumb: "Breadcrumb", embedBlockBreadcrumbParentPath: "Parent path",
+ enable: "Enable", disable: "Disable", default: "Default"});
+ for (const touch of [false, true]) {
+ mobile = touch;
+ const embed = document.createElement("div");
+ embed.dataset.nodeId = "embed";
+ for (const [index, attribute] of ["breadcrumb", "custom-sy-embed-breadcrumb-parent-path"].entries()) {
+ for (const [choice, value] of [[0, "true"], [1, "false"], [2, null]] as const) {
+ const instance = createMenu();
+ instance.addItem(embedBreadcrumbMenu({} as IProtyle, embed)[index]);
+ instance.popup({x: 40, y: 40});
+ const parent = instance.element.querySelector<HTMLElement>(".b3-menu__item");
+ check.equal(parent.querySelector(":scope > svg:not(.b3-menu__icon--small)"), null,
+ "breadcrumb menus have no empty leading icon");
+ check.equal(parent.querySelector(":scope > .b3-menu__icon--small use")?.getAttribute("xlink:href"), "#iconRight",
+ "breadcrumb submenu retains the standard arrow");
+ parent.dispatchEvent(new MouseEvent(touch ? "click" : "mouseover", {bubbles: true}));
+ await settle();
+ check.ok(parent.classList.contains("b3-menu__item--show"), "desktop hover and mobile tap open the submenu");
+ const options = parent.querySelectorAll<HTMLElement>(".b3-menu__submenu .b3-menu__item");
+ check.equal(options.length, 3);
+ options[choice].click();
+ check.equal(embed.getAttribute(attribute), value);
+ dispose(instance);
+ }
+ }
+ }
+ mobile = false;
+
const menu = createMenu();
addItems(menu, 2);
menu.popup({x: 760, y: 600});
@@ -692,7 +725,7 @@ test("menus adapt to layout changes and optional whole-menu mouse scrolling", {
}, async () => {
const sources = Object.fromEntries(["menus/Menu", "menus/menuPosition", "menus/menuMouseScroll", "menus/menuGroup", "menus/sheetOpen", "menus/sheetActions",
"util/setPosition", "protyle/util/hasClosest", "plugin/Menu", "protyle/render/av/openMenuPanel",
- "asset/pdf/viewerTemplate", "asset/pdf/secondary_toolbar.js", "protyle/render/av/calendar/undated",
+ "asset/pdf/viewerTemplate", "asset/pdf/secondary_toolbar.js", "protyle/render/av/calendar/undated", "protyle/gutter/embedBreadcrumbMenu",
"layout/dock/agent/AgentSessionPanel"].map(name => [name,
transpileModule(readFileSync(path.join(__dirname, "..", name.endsWith(".js") ? name : name + ".ts"), "utf8"), {
compilerOptions: {target: ScriptTarget.ES2021, module: ModuleKind.CommonJS},
diff --git a/app/src/protyle/gutter/embedBreadcrumbMenu.test.ts b/app/src/protyle/gutter/embedBreadcrumbMenu.test.ts
new file mode 100644
index 0000000000..f7bea15873
--- /dev/null
+++ b/app/src/protyle/gutter/embedBreadcrumbMenu.test.ts
@@ -0,0 +1,56 @@
+import * as assert from "node:assert/strict";
+import {readFileSync} from "node:fs";
+import {test} from "node:test";
+import {runInNewContext} from "node:vm";
+import {ModuleKind, transpileModule} from "typescript";
+
+test("breadcrumb submenus persist overrides and delete attributes when returning to defaults", () => {
+ const constants = {} as typeof import("../../constants");
+ runInNewContext(transpileModule(readFileSync("src/constants.ts", "utf8"), {
+ compilerOptions: {module: ModuleKind.CommonJS},
+ }).outputText, {exports: constants, SIYUAN_VERSION: "test", NODE_ENV: "test"});
+ const attributes = new Map<string, string>([["data-node-id", "embed"]]);
+ const nodeElement = {
+ getAttribute: (name: string) => attributes.get(name) ?? null,
+ setAttribute: (name: string, value: string) => attributes.set(name, value),
+ removeAttribute: (name: string) => attributes.delete(name),
+ };
+ const requests: unknown[] = [];
+ let saved: () => void;
+ let renders = 0;
+ const api: {embedBreadcrumbMenu?: (protyle: object, node: object) => IMenu[]} = {};
+ const dependencies = {...constants,
+ fetchPost: (url: string, data: unknown, callback: () => void) => {
+ requests.push([url, JSON.parse(JSON.stringify(data))]); saved = callback;
+ },
+ blockRender: (_protyle: object, node: object) => {
+ assert.equal(node, nodeElement);
+ assert.equal(attributes.has("data-render"), false);
+ renders++;
+ },
+ };
+ runInNewContext(transpileModule(readFileSync("src/protyle/gutter/embedBreadcrumbMenu.ts", "utf8"), {
+ compilerOptions: {module: ModuleKind.CommonJS},
+ }).outputText, {exports: api, require: () => dependencies,
+ window: {siyuan: {languages: new Proxy({}, {get: (_, key) => key})}}});
+ const open = () => api.embedBreadcrumbMenu({}, nodeElement);
+ for (const [index, attribute] of ["breadcrumb", constants.Constants.CUSTOM_SY_EMBED_BREADCRUMB_PARENT_PATH].entries()) {
+ assert.deepEqual(Array.from(open()[index].submenu, item => item.id), ["enable", "disable", "default"]);
+ for (const [id, value] of [["disable", "false"], ["enable", "true"], ["default", null]]) {
+ const parent = open()[index];
+ assert.equal(parent.type, "submenu");
+ assert.equal(parent.iconHTML, "", "no placeholder icon is rendered");
+ const option = parent.submenu.find(item => item.id === id);
+ assert.equal(option.iconHTML, "");
+ attributes.set("data-render", "true");
+ const previous = attributes.get(attribute);
+ option.click(undefined, undefined);
+ assert.equal(attributes.get(attribute), previous, "failed or pending saves preserve the current preference");
+ saved();
+ assert.equal(attributes.get(attribute) ?? null, value);
+ assert.deepEqual(requests.at(-1), ["/api/attr/setBlockAttrs", {id: "embed", attrs: {[attribute]: value}}]);
+ assert.deepEqual(Array.from(open()[index].submenu.filter(item => item.checked), item => item.id), [id]);
+ }
+ }
+ assert.equal(renders, 6);
+});
diff --git a/app/src/protyle/gutter/embedBreadcrumbMenu.ts b/app/src/protyle/gutter/embedBreadcrumbMenu.ts
new file mode 100644
index 0000000000..ebda9e8e70
--- /dev/null
+++ b/app/src/protyle/gutter/embedBreadcrumbMenu.ts
@@ -0,0 +1,37 @@
+import {Constants} from "../../constants";
+import {fetchPost} from "../../util/fetch";
+import {blockRender} from "../render/blockRender";
+
+export const embedBreadcrumbMenu = (protyle: IProtyle, nodeElement: Element): IMenu[] =>
+ [
+ {id: "embedBlockBreadcrumb", attribute: "breadcrumb"},
+ {id: "embedBlockBreadcrumbParentPath", attribute: Constants.CUSTOM_SY_EMBED_BREADCRUMB_PARENT_PATH},
+ ].map(({id, attribute}): IMenu => {
+ const current = nodeElement.getAttribute(attribute);
+ return {
+ id,
+ label: window.siyuan.languages[id],
+ iconHTML: "",
+ type: "submenu",
+ submenu: [
+ {id: "enable", value: "true"},
+ {id: "disable", value: "false"},
+ {id: "default", value: null},
+ ].map(({id: option, value}) => ({
+ id: option,
+ label: window.siyuan.languages[option],
+ iconHTML: "",
+ checked: value === null ? current !== "true" && current !== "false" : current === value,
+ click() {
+ fetchPost("/api/attr/setBlockAttrs", {
+ id: nodeElement.getAttribute("data-node-id"), attrs: {[attribute]: value},
+ }, () => {
+ if (value === null) nodeElement.removeAttribute(attribute);
+ else nodeElement.setAttribute(attribute, value);
+ nodeElement.removeAttribute("data-render");
+ blockRender(protyle, nodeElement);
+ });
+ },
+ })),
+ };
+ });
diff --git a/app/src/protyle/gutter/index.ts b/app/src/protyle/gutter/index.ts
index 226e17b87b..6afaf7cdb7 100644
--- a/app/src/protyle/gutter/index.ts
+++ b/app/src/protyle/gutter/index.ts
@@ -46,7 +46,7 @@ import {hideElements} from "../ui/hideElements";
import {isGutterTouchDragging, markGutterForFoldRestore} from "../ui/gutterVisibility";
import {highlightRender} from "../render/highlightRender";
import {blockRender} from "../render/blockRender";
-import {EMBED_BREADCRUMB_PARENT_PATH} from "../render/embedBreadcrumb";
+import {embedBreadcrumbMenu} from "./embedBreadcrumbMenu";
import {toggleListMindmap} from "../render/listMindmap";
import {getBlockHeightTarget, setBlockHeight} from "./height";
import {orderGutterTurnIntoItems} from "./turnIntoMenu";
@@ -2501,7 +2501,6 @@ export class Gutter {
}).element);
} else if (type === "NodeBlockQueryEmbed" && !protyle.disabled) {
window.siyuan.menus.menu.append(new MenuItem({id: "separator_blockEmbed", type: "separator"}).element);
- const breadcrumb = nodeElement.getAttribute("breadcrumb");
window.siyuan.menus.menu.append(new MenuItem({
id: "blockEmbed",
type: "submenu",
@@ -2525,41 +2524,7 @@ export class Gutter {
}, {
id: "separator_breadcrumb",
type: "separator"
- }, {
- id: "embedBlockBreadcrumb",
- label: `<div class="fn__flex" style="margin-bottom: 4px"><span>${window.siyuan.languages.embedBlockBreadcrumb}</span><span class="fn__space fn__flex-1"></span>
-<input type="checkbox" class="b3-switch fn__flex-center"${breadcrumb === "true" ? " checked" : ((window.siyuan.config.editor.embedBlockBreadcrumb && breadcrumb !== "false") ? " checked" : "")}></div>`,
- bind(element) {
- element.addEventListener("click", (event: MouseEvent & { target: HTMLElement }) => {
- const inputElement = element.querySelector("input");
- if (event.target.tagName !== "INPUT") {
- inputElement.checked = !inputElement.checked;
- }
- nodeElement.setAttribute("breadcrumb", inputElement.checked.toString());
- fetchPost("/api/attr/setBlockAttrs", {
- id,
- attrs: {breadcrumb: inputElement.checked.toString()}
- });
- nodeElement.removeAttribute("data-render");
- blockRender(protyle, nodeElement);
- window.siyuan.menus.menu.remove();
- });
- }
- }, {
- id: "embedBlockBreadcrumbParentPath",
- label: window.siyuan.languages.embedBlockBreadcrumbParentPath,
- iconHTML: "",
- checked: nodeElement.getAttribute(EMBED_BREADCRUMB_PARENT_PATH) !== "false",
- click() {
- const value = (nodeElement.getAttribute(EMBED_BREADCRUMB_PARENT_PATH) === "false").toString();
- nodeElement.setAttribute(EMBED_BREADCRUMB_PARENT_PATH, value);
- fetchPost("/api/attr/setBlockAttrs", {
- id, attrs: {[EMBED_BREADCRUMB_PARENT_PATH]: value}
- });
- nodeElement.removeAttribute("data-render");
- blockRender(protyle, nodeElement);
- }
- }, {
+ }, ...embedBreadcrumbMenu(protyle, nodeElement), {
id: "headingEmbedMode",
label: window.siyuan.languages.headingEmbedMode,
type: "submenu",
diff --git a/app/src/protyle/render/blockRender.ts b/app/src/protyle/render/blockRender.ts
index 3561804304..32bb594a93 100644
--- a/app/src/protyle/render/blockRender.ts
+++ b/app/src/protyle/render/blockRender.ts
@@ -12,7 +12,8 @@ import {finishCustomEmbedRender, finishEmptyEmbedRender, IEmbedRenderLoadingStat
import {getHostCapabilities} from "../../util/hostCapabilities";
import {isDirectHeadingEmbed} from "./embedHeading";
import {isFoldedRenderContent} from "./foldedContent";
-import {EMBED_BREADCRUMB_PARENT_PATH, getEmbedBreadcrumbPaths} from "./embedBreadcrumb";
+import {getEmbedBreadcrumbPaths, resolveEmbedBreadcrumbPreference} from "./embedBreadcrumb";
+import {Constants} from "../../constants";
/**
* 渲染嵌入块
@@ -54,8 +55,7 @@ export const blockRender = (protyle: IProtyle, element: Element, top?: number, o
}
}
}
- const breadcrumbAttribute = item.getAttribute("breadcrumb");
- const breadcrumb = breadcrumbAttribute ? breadcrumbAttribute === "true" : window.siyuan.config.editor.embedBlockBreadcrumb;
+ const breadcrumb = resolveEmbedBreadcrumbPreference(item.getAttribute("breadcrumb"), window.siyuan.config.editor.embedBlockBreadcrumb);
if (content.startsWith("//!js")) {
// 安全模式下禁用 JS 查询嵌入块,与代码片段(CSS/JS snippet)的处理保持一致
@@ -123,7 +123,8 @@ const renderEmbed = (blocks: {
let breadcrumbHTML = "";
if (blocksItem.blockPaths.length !== 0) {
breadcrumbHTML = genBreadcrumb(getEmbedBreadcrumbPaths(blocksItem.blockPaths, blocksItem.block.rootID,
- item.getAttribute(EMBED_BREADCRUMB_PARENT_PATH)), true);
+ resolveEmbedBreadcrumbPreference(item.getAttribute(Constants.CUSTOM_SY_EMBED_BREADCRUMB_PARENT_PATH),
+ window.siyuan.config.editor.embedBlockBreadcrumbParentPath ?? true)), true);
}
let popover = "";
if (index !== 0) {
diff --git a/app/src/protyle/render/embedBreadcrumb.test.ts b/app/src/protyle/render/embedBreadcrumb.test.ts
index 7855cf35e3..41407a600d 100644
--- a/app/src/protyle/render/embedBreadcrumb.test.ts
+++ b/app/src/protyle/render/embedBreadcrumb.test.ts
@@ -2,114 +2,110 @@ import * as assert from "node:assert/strict";
import {readFileSync} from "node:fs";
import {test} from "node:test";
import {runInNewContext} from "node:vm";
-import {createSourceFile, isObjectLiteralExpression, isPropertyAssignment, ModuleKind, ScriptTarget, transpileModule} from "typescript";
-import {EMBED_BREADCRUMB_PARENT_PATH, getEmbedBreadcrumbPaths} from "./embedBreadcrumb";
+import {ModuleKind, transpileModule} from "typescript";
+import {getEmbedBreadcrumbPaths, resolveEmbedBreadcrumbPreference} from "./embedBreadcrumb";
-const paths: IBreadcrumb[] = ["notebook", "parent", "document", "heading", "block"].map((id, index): IBreadcrumb => ({
- id, name: id, type: index < 3 ? "NodeDocument" : index === 3 ? "NodeHeading" : "NodeParagraph",
- subType: "", children: [],
-}));
+const constants = {} as typeof import("../../constants");
+runInNewContext(transpileModule(readFileSync("src/constants.ts", "utf8"), {
+ compilerOptions: {module: ModuleKind.CommonJS},
+}).outputText, {exports: constants, SIYUAN_VERSION: "test", NODE_ENV: "test"});
+const attribute = constants.Constants.CUSTOM_SY_EMBED_BREADCRUMB_PARENT_PATH;
+const paths: IBreadcrumb[] = [
+ {id: "document", name: "Notebook/Parent/Title / Section &lt;A&gt;", documentTitle: "Title / Section &lt;A&gt;",
+ type: "NodeDocument", subType: "", children: []},
+ ...["heading", "block"].map((id): IBreadcrumb => ({id, name: "", type: "NodeHeading", subType: "", children: []})),
+];
-test("document-only breadcrumbs preserve the document and all internal ancestors without mutating responses", () => {
- for (const value of [null, "", "true", "unknown"]) {
- assert.equal(getEmbedBreadcrumbPaths(paths, "document", value), paths);
+test("embedded preferences inherit global values only without an explicit block override", () => {
+ for (const fallback of [false, true]) {
+ for (const value of [null, "", "unknown"]) assert.equal(resolveEmbedBreadcrumbPreference(value, fallback), fallback);
+ assert.equal(resolveEmbedBreadcrumbPreference("true", fallback), true);
+ assert.equal(resolveEmbedBreadcrumbPreference("false", fallback), false);
}
- assert.deepEqual(getEmbedBreadcrumbPaths(paths, "document", "false").map(item => item.id),
- ["document", "heading", "block"]);
- assert.equal(paths.length, 5);
- assert.deepEqual(getEmbedBreadcrumbPaths(paths.slice(0, 3), "document", "false").map(item => item.id), ["document"]);
- assert.equal(getEmbedBreadcrumbPaths(paths, "", "false"), paths);
- assert.equal(getEmbedBreadcrumbPaths(paths, "missing", "false"), paths);
- assert.deepEqual(getEmbedBreadcrumbPaths([], "document", "false"), []);
});
-test("embed rendering uses each result's document boundary and preserves full paths by default", () => {
- const compiled = transpileModule(readFileSync("src/protyle/render/blockRender.ts", "utf8") +
- "\nexport {renderEmbed};", {compilerOptions: {module: ModuleKind.CommonJS}}).outputText;
+test("document-only breadcrumbs replace the combined path with the exact title without mutating responses", () => {
+ assert.equal(getEmbedBreadcrumbPaths(paths, "document", true), paths);
+ const result = getEmbedBreadcrumbPaths(paths, "document", false);
+ assert.equal(result[0].name, "Title / Section &lt;A&gt;");
+ assert.equal(result[0].id, "document");
+ assert.equal(result[1], paths[1]);
+ assert.equal(paths[0].name, "Notebook/Parent/Title / Section &lt;A&gt;");
+ const expanded = [{...paths[0], id: "parent", name: "Parent"}, ...paths];
+ assert.deepEqual(getEmbedBreadcrumbPaths(expanded, "document", false).map(item => item.id), ["document", "heading", "block"]);
+ assert.equal(getEmbedBreadcrumbPaths(paths.slice(0, 1), "document", false)[0].name, paths[0].documentTitle);
+ assert.equal(getEmbedBreadcrumbPaths(paths, "missing", false), paths);
+ assert.equal(getEmbedBreadcrumbPaths(paths, "", false), paths);
+ const legacy = [{...paths[0], documentTitle: undefined}, ...paths.slice(1)];
+ assert.equal(getEmbedBreadcrumbPaths(legacy, "document", false)[0].name, legacy[0].name);
+ assert.deepEqual(getEmbedBreadcrumbPaths([], "document", false), []);
+});
+
+test("SQL and JS embed rendering use global preferences and per-result document titles", async () => {
+ const compiled = transpileModule(readFileSync("src/protyle/render/blockRender.ts", "utf8"),
+ {compilerOptions: {module: ModuleKind.CommonJS}}).outputText;
const breadcrumbs: string[][] = [];
- const api = {} as {renderEmbed: (...args: unknown[]) => void};
+ const requests: Array<{breadcrumb: boolean}> = [];
+ const api = {} as {blockRender: (...args: unknown[]) => void};
const noop = () => {};
const dependencies = {
- EMBED_BREADCRUMB_PARENT_PATH, getEmbedBreadcrumbPaths,
- genBreadcrumb: (items: IBreadcrumb[]) => { breadcrumbs.push(items.map(item => item.id)); return "breadcrumbs"; },
+ ...constants, getEmbedBreadcrumbPaths, resolveEmbedBreadcrumbPreference,
+ genBreadcrumb: (items: IBreadcrumb[]) => { breadcrumbs.push(items.map(item => item.name)); return "breadcrumbs"; },
normalizeHTMLAssetIFrameBlockDOM: (html: string) => html,
improveBreadcrumbAppearance: noop, processRender: noop, highlightRender: noop, avRender: noop,
- hasClosestByAttribute: () => false, isDirectHeadingEmbed: () => false,
+ hasClosestByAttribute: () => false, isDirectHeadingEmbed: () => false, isFoldedRenderContent: () => false,
+ isEncryptedBox: () => false, genRenderFrame: noop, getHostCapabilities: () => ({}),
+ fetchPost: (_url: string, data: typeof requests[number], callback: (data: unknown) => void) => {
+ requests.push(data);
+ callback({data: {blocks: [{block: {rootID: "document", id: "block", content: "one"},
+ blockPaths: data.breadcrumb ? paths : []},
+ {block: {rootID: "other", id: "child", content: "two"}, blockPaths: data.breadcrumb ?
+ [{...paths[0], id: "other", name: "Notebook/Other", documentTitle: "Other"}, paths[2]] : []}]}});
+ },
};
+ const editor = {embedBlockBreadcrumb: true, embedBlockBreadcrumbParentPath: true};
runInNewContext(compiled, {exports: api, require: () => dependencies,
- window: {siyuan: {languages: {}}}, Lute: {UnEscapeHTMLStr: (text: string) => text}});
- for (const value of [null, "false", "true"]) {
- breadcrumbs.length = 0;
- const item = {
- querySelector: (): null => null, querySelectorAll: (): Element[] => [],
- getAttribute: (name: string) => name === EMBED_BREADCRUMB_PARENT_PATH ? value : "",
- firstElementChild: {insertAdjacentHTML: noop}, style: {},
- };
- api.renderEmbed([
- {block: {rootID: "document", id: "block", content: "one"}, blockPaths: paths},
- {block: {rootID: "other", id: "child", content: "two"},
- blockPaths: [...paths.slice(0, 2), {...paths[2], id: "other"}, {...paths[4], id: "child"}]},
- ], {}, item);
- assert.deepEqual(breadcrumbs, value === "false" ?
- [["document", "heading", "block"], ["other", "child"]] :
- [["notebook", "parent", "document", "heading", "block"], ["notebook", "parent", "other", "child"]]);
- }
-});
-
-test("the shared desktop and mobile embed menu toggles only the selected embed and refreshes it", () => {
- const source = createSourceFile("gutter.ts", readFileSync("src/protyle/gutter/index.ts", "utf8"), ScriptTarget.Latest, true);
- let expression: string;
- const visit = (node: import("typescript").Node) => {
- if (isObjectLiteralExpression(node) && node.properties.some(property => isPropertyAssignment(property) &&
- property.name.getText(source) === "id" && property.initializer.getText(source) === '"embedBlockBreadcrumbParentPath"')) {
- expression = node.getText(source);
+ window: {siyuan: {languages: {}, config: {editor, system: {safeMode: false}}}}, Lute: {UnEscapeHTMLStr: (text: string) => text}});
+ for (const global of [true, false]) {
+ editor.embedBlockBreadcrumbParentPath = global;
+ for (const [value, content] of [null, "false", "true"].flatMap(value =>
+ ["select 1", "//!js\nreturn ['block'];"].map(content => [value, content] as const))) {
+ const attributes = new Map<string, string>([["data-type", "NodeBlockQueryEmbed"], ["data-content", content]]);
+ if (value) attributes.set(attribute, value);
+ const item = {
+ getAttribute: (name: string) => attributes.get(name) ?? null,
+ setAttribute: (name: string, value: string) => attributes.set(name, value),
+ closest: (): null => null, querySelector: (): null => null, querySelectorAll: (): Element[] => [],
+ firstElementChild: {insertAdjacentHTML: noop}, style: {},
+ };
+ breadcrumbs.length = 0;
+ api.blockRender({block: {rootID: "host"}}, item);
+ await new Promise(setImmediate);
+ assert.equal(requests.at(-1).breadcrumb, true);
+ assert.equal(breadcrumbs[0][0], resolveEmbedBreadcrumbPreference(value, global) ? paths[0].name : paths[0].documentTitle);
+ assert.equal(breadcrumbs[1][0], resolveEmbedBreadcrumbPreference(value, global) ? "Notebook/Other" : "Other");
+ attributes.delete("data-render");
+ attributes.set("breadcrumb", "false");
+ api.blockRender({block: {rootID: "host"}}, item);
+ await new Promise(setImmediate);
+ assert.equal(requests.at(-1).breadcrumb, false);
}
- node.forEachChild(visit);
- };
- visit(source);
- assert.ok(expression);
- const attributes = new Map<string, string>();
- const requests: unknown[] = [];
- let renders = 0;
- const nodeElement = {
- getAttribute: (name: string) => attributes.get(name) ?? null,
- setAttribute: (name: string, value: string) => attributes.set(name, value),
- removeAttribute: (name: string) => attributes.delete(name),
- };
- const context = {
- EMBED_BREADCRUMB_PARENT_PATH, nodeElement, id: "embed", protyle: {},
- window: {siyuan: {languages: {embedBlockBreadcrumbParentPath: "Parent path"}}},
- fetchPost: (url: string, data: unknown) => requests.push([url, JSON.parse(JSON.stringify(data))]),
- blockRender: (_protyle: object, item: object) => {
- assert.equal(item, nodeElement);
- assert.equal(attributes.has("data-render"), false);
- renders++;
- },
- };
- const open = () => runInNewContext(transpileModule(`(${expression})`,
- {compilerOptions: {target: ScriptTarget.ES2021}}).outputText, context);
- assert.equal(open().checked, true);
- for (const value of ["false", "true"]) {
- attributes.set("data-render", "true");
- open().click();
- assert.equal(attributes.get(EMBED_BREADCRUMB_PARENT_PATH), value);
- assert.equal(open().checked, value === "true");
}
- assert.equal(renders, 2);
- assert.deepEqual(requests, ["false", "true"].map(value =>
- ["/api/attr/setBlockAttrs", {id: "embed", attrs: {[EMBED_BREADCRUMB_PARENT_PATH]: value}}]));
});
-test("the bundled engine preserves the preference through native block serialization", () => {
- if (typeof Lute === "undefined") {
- require("../../../stage/protyle/js/lute/lute.min.js");
- }
+test("the bundled engine preserves explicit preferences and removes default attributes on serialization", () => {
+ if (typeof Lute === "undefined") require("../../../stage/protyle/js/lute/lute.min.js");
const lute = Lute.New();
lute.SetProtyleWYSIWYG(true);
lute.SetKramdownIAL(true);
- const html = "<div data-type=\"NodeBlockQueryEmbed\" data-node-id=\"20261020000000-abcdefg\" " +
- `data-content="select * from blocks" ${EMBED_BREADCRUMB_PARENT_PATH}="false"><div class="protyle-attr"></div></div>`;
- const markdown = lute.BlockDOM2Md(html);
- assert.ok(markdown.includes(`${EMBED_BREADCRUMB_PARENT_PATH}="false"`));
- assert.ok(lute.Md2BlockDOM(markdown).includes(`${EMBED_BREADCRUMB_PARENT_PATH}="false"`));
+ for (const value of ["true", "false"]) {
+ const html = '<div data-type="NodeBlockQueryEmbed" data-node-id="20261020000000-abcdefg" ' +
+ `data-content="select * from blocks" breadcrumb="${value}" ${attribute}="${value}"><div class="protyle-attr"></div></div>`;
+ const markdown = lute.BlockDOM2Md(html);
+ assert.ok(lute.Md2BlockDOM(markdown).includes(`${attribute}="${value}"`));
+ assert.ok(lute.Md2BlockDOM(markdown).includes(`breadcrumb="${value}"`));
+ const defaults = lute.BlockDOM2Md(html.replace(` breadcrumb="${value}"`, "").replace(` ${attribute}="${value}"`, ""));
+ assert.equal(defaults.includes(attribute), false);
+ assert.equal(defaults.includes('breadcrumb="'), false);
+ }
});
diff --git a/app/src/protyle/render/embedBreadcrumb.ts b/app/src/protyle/render/embedBreadcrumb.ts
index 4a5ca2fb64..e424abd88c 100644
--- a/app/src/protyle/render/embedBreadcrumb.ts
+++ b/app/src/protyle/render/embedBreadcrumb.ts
@@ -1,10 +1,16 @@
-export const EMBED_BREADCRUMB_PARENT_PATH = "custom-sy-embed-breadcrumb-parent-path";
+export const resolveEmbedBreadcrumbPreference = (value: string | null, fallback: boolean) =>
+ value === "true" ? true : value === "false" ? false : fallback;
-export const getEmbedBreadcrumbPaths = (paths: IBreadcrumb[], rootID: string, parentPath: string | null) => {
- if (parentPath !== "false" || !rootID) {
+export const getEmbedBreadcrumbPaths = (paths: IBreadcrumb[], rootID: string, parentPath: boolean) => {
+ if (parentPath || !rootID) {
return paths;
}
const documentIndex = paths.findIndex(item => item.id === rootID);
- // Preserve legacy or incomplete responses instead of dropping their available context.
- return documentIndex < 0 ? paths : paths.slice(documentIndex);
+ // 不完整的历史响应保留已有上下文,文档标题使用独立字段以保留标题中的斜杠。
+ if (documentIndex < 0) return paths;
+ const result = paths.slice(documentIndex);
+ if (typeof result[0].documentTitle === "string") {
+ result[0] = {...result[0], name: result[0].documentTitle};
+ }
+ return result;
};
diff --git a/app/src/protyle/render/listMindmap/preview.test.ts b/app/src/protyle/render/listMindmap/preview.test.ts
index 26432e7571..d7a2a532c2 100644
--- a/app/src/protyle/render/listMindmap/preview.test.ts
+++ b/app/src/protyle/render/listMindmap/preview.test.ts
@@ -298,7 +298,8 @@ test("special block previews cannot acquire document writes or lose unsupported
logger: require("sass").Logger.silent,
}).css;
const source = compile(readFileSync(path.join(__dirname, "../../../plugin/customBlockRender.ts"), "utf8")) +
- extract("../htmlRender.ts", ["htmlRender"]) + extract("../blockRender.ts", ["blockRender"]) +
+ extract("../htmlRender.ts", ["htmlRender"]) + compile(readFileSync(path.join(__dirname, "../embedBreadcrumb.ts"), "utf8")) +
+ extract("../blockRender.ts", ["blockRender"]) +
extract("../chartRender.ts", ["refreshChartTheme"]) +
extract("../av/render.ts", ["avRender", "getAVElements"]) +
extract("../../util/tableVirtualizationDOM.ts", ["TABLE_VIRTUAL_ID", "TABLE_VIRTUAL_ROWS"]) +
diff --git a/app/src/types/api/index.d.ts b/app/src/types/api/index.d.ts
index 65b056ddfc..8791ca7435 100644
--- a/app/src/types/api/index.d.ts
+++ b/app/src/types/api/index.d.ts
@@ -784,7 +784,7 @@ export type BlockKramdownRequestInput = { "id": string; "ids"?: Array<string> |
export type BlockOperation = { "action": "update"; "avID": string; "backRelationKeyID": string; "blockID": string; "blockIDs": Array<string> | null; "context": Record<string, string> | null; "data": string | null; "deckID": string; "format": string; "groupID": string; "id": string; "ignoreDefaultFill": boolean; "isDetached": boolean; "isTwoWay": boolean; "keyID": string; "layout": string; "name": string; "nextID": string; "parentID": string; "previousID": string; "removeDest": boolean; "retData": null | string | Array<string>; "rootID": string; "rowID": string; "srcIDs": Array<string> | null; "srcs": null; "targetGroupID": string; "type": ""; "viewID": string; "viewIDs"?: Array<string>; } | { "action": "insert"; "avID": string; "backRelationKeyID": string; "blockID": string; "blockIDs": Array<string> | null; "context": Record<string, string> | null; "data": string | null; "deckID": string; "format": string; "groupID": string; "id": string; "ignoreDefaultFill": boolean; "isDetached": boolean; "isTwoWay": boolean; "keyID": string; "layout": string; "name": string; "nextID": string; "parentID": string; "previousID": string; "removeDest": boolean; "retData": null | string | Array<string>; "rootID": string; "rowID": string; "srcIDs": Array<string> | null; "srcs": null; "targetGroupID": string; "type": ""; "viewID": string; "viewIDs"?: Array<string>; } | { "action": "delete"; "avID": string; "backRelationKeyID": string; "blockID": string; "blockIDs": Array<string> | null; "context": Record<string, string> | null; "data": BlockDeleteDataInput | null; "deckID": string; "format": string; "groupID": string; "id": string; "ignoreDefaultFill": boolean; "isDetached": boolean; "isTwoWay": boolean; "keyID": string; "layout": string; "name": string; "nextID": string; "parentID": string; "previousID": string; "removeDest": boolean; "retData": null | string | Array<string>; "rootID": string; "rowID": string; "srcIDs": Array<string> | null; "srcs": null; "targetGroupID": string; "type": ""; "viewID": string; "viewIDs"?: Array<string>; } | { "action": "moveOutlineHeading"; "avID": string; "backRelationKeyID": string; "blockID": string; "blockIDs": Array<string> | null; "context": Record<string, string> | null; "data": null; "deckID": string; "format": string; "groupID": string; "id": string; "ignoreDefaultFill": boolean; "isDetached": boolean; "isTwoWay": boolean; "keyID": string; "layout": string; "name": string; "nextID": string; "parentID": string; "previousID": string; "removeDest": boolean; "retData": null | string | Array<string>; "rootID": string; "rowID": string; "srcIDs": Array<string> | null; "srcs": null; "targetGroupID": string; "type": ""; "viewID": string; "viewIDs"?: Array<string>; } | { "action": "appendInsert"; "avID": string; "backRelationKeyID": string; "blockID": string; "blockIDs": Array<string> | null; "context": Record<string, string> | null; "data": string | null; "deckID": string; "format": string; "groupID": string; "id": string; "ignoreDefaultFill": boolean; "isDetached": boolean; "isTwoWay": boolean; "keyID": string; "layout": string; "name": string; "nextID": string; "parentID": string; "previousID": string; "removeDest": boolean; "retData": null | string | Array<string>; "rootID": string; "rowID": string; "srcIDs": Array<string> | null; "srcs": null; "targetGroupID": string; "type": ""; "viewID": string; "viewIDs"?: Array<string>; } | { "action": "prependInsert"; "avID": string; "backRelationKeyID": string; "blockID": string; "blockIDs": Array<string> | null; "context": Record<string, string> | null; "data": string | null; "deckID": string; "format": string; "groupID": string; "id": string; "ignoreDefaultFill": boolean; "isDetached": boolean; "isTwoWay": boolean; "keyID": string; "layout": string; "name": string; "nextID": string; "parentID": string; "previousID": string; "removeDest": boolean; "retData": null | string | Array<string>; "rootID": string; "rowID": string; "srcIDs": Array<string> | null; "srcs": null; "targetGroupID": string; "type": ""; "viewID": string; "viewIDs"?: Array<string>; } | { "action": "foldHeading"; "avID": string; "backRelationKeyID": string; "blockID": string; "blockIDs": Array<string> | null; "context": Record<string, string> | null; "data": null; "deckID": string; "format": string; "groupID": string; "id": string; "ignoreDefaultFill": boolean; "isDetached": boolean; "isTwoWay": boolean; "keyID": string; "layout": string; "name": string; "nextID": string; "parentID": string; "previousID": string; "removeDest": boolean; "retData": null | string | Array<string>; "rootID": string; "rowID": string; "srcIDs": Array<string> | null; "srcs": null; "targetGroupID": string; "type": ""; "viewID": string; "viewIDs"?: Array<string>; } | { "action": "unfoldHeading"; "avID": string; "backRelationKeyID": string; "blockID": string; "blockIDs": Array<string> | null; "context": Record<string, string> | null; "data": string | null; "deckID": string; "format": string; "groupID": string; "id": string; "ignoreDefaultFill": boolean; "isDetached": boolean; "isTwoWay": boolean; "keyID": string; "layout": string; "name": string; "nextID": string; "parentID": string; "previousID": string; "removeDest": boolean; "retData": null | string | Array<string>; "rootID": string; "rowID": string; "srcIDs": Array<string> | null; "srcs": null; "targetGroupID": string; "type": ""; "viewID": string; "viewIDs"?: Array<string>; } | { "action": "setAttrs"; "avID": string; "backRelationKeyID": string; "blockID": string; "blockIDs": Array<string> | null; "context": Record<string, string> | null; "data": string | null; "deckID": string; "format": string; "groupID": string; "id": string; "ignoreDefaultFill": boolean; "isDetached": boolean; "isTwoWay": boolean; "keyID": string; "layout": string; "name": string; "nextID": string; "parentID": string; "previousID": string; "removeDest": boolean; "retData": null | string | Array<string>; "rootID": string; "rowID": string; "srcIDs": Array<string> | null; "srcs": null; "targetGroupID": string; "type": ""; "viewID": string; "viewIDs"?: Array<string>; };
-export type BlockPath = { "children": Array<BlockPath | null> | null; "hasChildren"?: boolean; "id": string; "name": string; "subType": string; "type": string; };
+export type BlockPath = { "children": Array<BlockPath | null> | null; "documentTitle"?: string; "hasChildren"?: boolean; "id": string; "name": string; "subType": string; "type": string; };
export type BlockQueryRequestInput = { "id": string; "ids"?: Array<string> | null; "notebook"?: string | null; };
@@ -2004,7 +2004,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; "autoCloseRefBrackets"?: boolean | 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; "blockGutterMode"?: boolean | 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; "displayImgAlt"?: 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; "pageScrollButtons"?: 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; "autoCloseRefBrackets"?: boolean | 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; "blockGutterMode"?: boolean | 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; "displayImgAlt"?: boolean | null; "displayImgName"?: boolean | null; "displayNetImgMark"?: boolean | null; "dragHTMLFileToIframe"?: boolean | null; "dynamicLoadBlocks"?: number | null; "embedBlockBreadcrumb"?: boolean | null; "embedBlockBreadcrumbParentPath"?: 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; "pageScrollButtons"?: 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; };
@@ -2144,13 +2144,13 @@ 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; "autoCloseRefBrackets": boolean; "autoDirection": boolean; "backlinkBlockSort": number; "backlinkContainChildren": boolean; "backlinkExpandCount": number; "backlinkGlobalSort": number; "backlinkHideReference": boolean; "backlinkMentionExclude": string; "backlinkShowBottom": boolean; "backlinkSort": number | null; "backmentionExpandCount": number; "backmentionSort": number | null; "blockGutterMode": boolean; "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; "displayImgAlt": 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; "pageScrollButtons": 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; "autoCloseRefBrackets": boolean; "autoDirection": boolean; "backlinkBlockSort": number; "backlinkContainChildren": boolean; "backlinkExpandCount": number; "backlinkGlobalSort": number; "backlinkHideReference": boolean; "backlinkMentionExclude": string; "backlinkShowBottom": boolean; "backlinkSort": number | null; "backmentionExpandCount": number; "backmentionSort": number | null; "blockGutterMode": boolean; "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; "displayImgAlt": boolean; "displayImgName": boolean; "displayNetImgMark": boolean; "dragHTMLFileToIframe": boolean; "dynamicLoadBlocks": number; "embedBlockBreadcrumb": boolean; "embedBlockBreadcrumbParentPath": boolean | null; "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; "pageScrollButtons": 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; };
export type SettingEditorFontInput = { "displayName"?: string | null; "family"?: string | null; "weight"?: number | null; };
-export type SettingEditorInput = { "allowHTMLBLockScript"?: boolean | null; "allowSVGScript"?: boolean | null; "assetOpen"?: SettingAssetOpenInput | null; "autoCloseRefBrackets"?: boolean | 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; "blockGutterMode"?: boolean | 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; "displayImgAlt"?: 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; "pageScrollButtons"?: 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 SettingEditorInput = { "allowHTMLBLockScript"?: boolean | null; "allowSVGScript"?: boolean | null; "assetOpen"?: SettingAssetOpenInput | null; "autoCloseRefBrackets"?: boolean | 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; "blockGutterMode"?: boolean | 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; "displayImgAlt"?: boolean | null; "displayImgName"?: boolean | null; "displayNetImgMark"?: boolean | null; "dragHTMLFileToIframe"?: boolean | null; "dynamicLoadBlocks"?: number | null; "embedBlockBreadcrumb"?: boolean | null; "embedBlockBreadcrumbParentPath"?: 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; "pageScrollButtons"?: 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 SettingEmbedding = { "apiKey": string; "baseURL": string; "batchSize": number; "concurrency": number; "dimensions": number; "enabled": boolean; "id": string; "name": string; "timeout": number; };
@@ -7047,6 +7047,9 @@ export interface APIPOSTRoutes {
/** 服务器路由要求;资源权限与笔记本租约仍由内核校验 */
authorization?: readonly ["authenticated"];
};
+ /**
+ * 返回的文档面包屑项可附带 documentTitle,name 保留完整路径;标题不受路径分隔符影响。
+ */
"/api/search/getEmbedBlock": {
request: GetEmbedBlockRequestInput;
response: { "code": 0; "data": EmbedBlocksData; "msg": string; } | { "code": -1; "data": { "closeTimeout": number; } | null; "msg": string; };
@@ -7075,6 +7078,9 @@ export interface APIPOSTRoutes {
/** 服务器路由要求;资源权限与笔记本租约仍由内核校验 */
authorization?: readonly ["authenticated","admin","writable"];
};
+ /**
+ * 返回的文档面包屑项可附带 documentTitle,供客户端按偏好显示独立标题或完整 name 路径。
+ */
"/api/search/searchEmbedBlock": {
request: SearchEmbedBlockRequestInput;
response: { "code": 0; "data": EmbedBlocksData; "msg": string; } | { "code": -1; "data": { "closeTimeout": number; } | null; "msg": string; };
diff --git a/app/src/types/config.d.ts b/app/src/types/config.d.ts
index a5b57d31be..c48ee619ee 100644
--- a/app/src/types/config.d.ts
+++ b/app/src/types/config.d.ts
@@ -719,6 +719,7 @@ declare namespace Config {
* Whether the embedded block displays breadcrumbs
*/
embedBlockBreadcrumb: boolean;
+ embedBlockBreadcrumbParentPath: boolean;
/**
* Whether to display automatic heading numbers
*/
diff --git a/app/src/types/protyle.d.ts b/app/src/types/protyle.d.ts
index a41f97ae54..fb7e3f1abe 100644
--- a/app/src/types/protyle.d.ts
+++ b/app/src/types/protyle.d.ts
@@ -121,6 +121,7 @@ interface ILuteRender {
interface IBreadcrumb {
id: string,
name: string,
+ documentTitle?: string,
type: string,
subType: string,
children: IBreadcrumb[],
diff --git a/kernel/api/block.go b/kernel/api/block.go
index 5d4bc6e476..0ea2f27e10 100644
--- a/kernel/api/block.go
+++ b/kernel/api/block.go
@@ -1197,7 +1197,7 @@ func blockPathContracts(values []*model.BlockPath) []*apicontract.BlockPath {
result := make([]*apicontract.BlockPath, len(values))
for i, value := range values {
if value != nil {
- result[i] = &apicontract.BlockPath{ID: value.ID, Name: value.Name, Type: value.Type, SubType: value.SubType, Children: blockPathContracts(value.Children), HasChildren: value.HasChildren}
+ result[i] = &apicontract.BlockPath{ID: value.ID, Name: value.Name, DocumentTitle: value.DocumentTitle, Type: value.Type, SubType: value.SubType, Children: blockPathContracts(value.Children), HasChildren: value.HasChildren}
}
}
return result
diff --git a/kernel/api/contract_search_test.go b/kernel/api/contract_search_test.go
index 56f4787f4e..7b49a154f9 100644
--- a/kernel/api/contract_search_test.go
+++ b/kernel/api/contract_search_test.go
@@ -172,6 +172,12 @@ func TestAPIContractSearchEmbedConversion(t *testing.T) {
t.Fatalf("embed serialization changed: %s != %s, %v", actual, expected, err)
}
}
+ value := []*model.EmbedBlock{{Block: &model.Block{ID: "child", RootID: "document"},
+ BlockPaths: []*model.BlockPath{{ID: "document", Name: "Notebook/Parent/Title / Section", DocumentTitle: "Title / Section"}}}}
+ converted := embedBlockContracts(value)
+ if converted[0].BlockPaths[0].DocumentTitle != "Title / Section" || converted[0].BlockPaths[0].Name != value[0].BlockPaths[0].Name {
+ t.Fatalf("embed document title conversion lost data: %+v", converted[0].BlockPaths[0])
+ }
}
func TestAPIContractSearchPathAndSubtypeCompatibility(t *testing.T) {
diff --git a/kernel/api/contract_setting_embed_breadcrumb_test.go b/kernel/api/contract_setting_embed_breadcrumb_test.go
new file mode 100644
index 0000000000..00f40425c2
--- /dev/null
+++ b/kernel/api/contract_setting_embed_breadcrumb_test.go
@@ -0,0 +1,44 @@
+package api
+
+import (
+ "encoding/json"
+ "testing"
+
+ "github.com/siyuan-note/siyuan/kernel/apicontract"
+ "github.com/siyuan-note/siyuan/kernel/conf"
+ "github.com/siyuan-note/siyuan/kernel/model"
+ "github.com/siyuan-note/siyuan/kernel/util"
+)
+
+func TestAPIContractSettingEmbedBreadcrumbParentPath(t *testing.T) {
+ compareSettingConfig(t, apicontract.SetEditor, conf.NewEditor, []string{
+ `{}`, `{"embedBlockBreadcrumbParentPath":true}`, `{"embedBlockBreadcrumbParentPath":false}`,
+ `{"embedBlockBreadcrumbParentPath":null}`, `{"EmbedBlockBreadcrumbParentPath":false}`, `{"embedBlockBreadcrumbParentPath":"bad"}`,
+ })
+ previousConf, previousReadOnly, previousMarkdown := model.Conf, util.ReadOnly, util.MarkdownSettings.Load()
+ model.Conf = model.NewAppConf()
+ model.Conf.Editor.Store(conf.NewEditor())
+ util.ReadOnly = true
+ t.Cleanup(func() {
+ model.Conf, util.ReadOnly = previousConf, previousReadOnly
+ util.MarkdownSettings.Store(previousMarkdown)
+ })
+ for _, entry := range []struct {
+ body string
+ want bool
+ }{
+ {`{}`, true}, {`{"embedBlockBreadcrumbParentPath":false}`, false}, {`{}`, false},
+ {`{"embedBlockBreadcrumbParentPath":null}`, true}, {`{"embedBlockBreadcrumbParentPath":true}`, true},
+ {`{"EmbedBlockBreadcrumbParentPath":false}`, 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)
+ }
+ actual := model.Conf.Editor.Load().EmbedBlockBreadcrumbParentPath
+ if code != 0 || actual == nil || *actual != entry.want || response.EmbedBlockBreadcrumbParentPath == nil || *response.EmbedBlockBreadcrumbParentPath != entry.want {
+ t.Fatalf("breadcrumb setting %s: code=%d message=%s data=%s", entry.body, code, message, data)
+ }
+ }
+}
diff --git a/kernel/api/setting_contract.go b/kernel/api/setting_contract.go
index e0138a051f..1802f2ad70 100644
--- a/kernel/api/setting_contract.go
+++ b/kernel/api/setting_contract.go
@@ -393,6 +393,7 @@ func settingEditorPayload(value *conf.Editor) *apicontract.SettingEditor {
result.KaTexMacros = value.KaTexMacros
result.ReadOnly = value.ReadOnly
result.EmbedBlockBreadcrumb = value.EmbedBlockBreadcrumb
+ result.EmbedBlockBreadcrumbParentPath = value.EmbedBlockBreadcrumbParentPath
result.ListLogicalOutdent = value.ListLogicalOutdent
result.ListItemDotNumberClickFocus = value.ListItemDotNumberClickFocus
result.FloatWindowMode = value.FloatWindowMode
diff --git a/kernel/apicontract/block_tree.go b/kernel/apicontract/block_tree.go
index 168021efd9..176f2a12cb 100644
--- a/kernel/apicontract/block_tree.go
+++ b/kernel/apicontract/block_tree.go
@@ -15,12 +15,14 @@ type BlockTreeInfo struct {
}
type BlockPath struct {
- ID string `json:"id"`
- Name string `json:"name"`
- Type string `json:"type"`
- SubType string `json:"subType"`
- Children []*BlockPath `json:"children"`
- HasChildren bool `json:"hasChildren,omitempty"`
+ ID string `json:"id"`
+ Name string `json:"name"`
+ // 嵌入块的文档项提供独立标题,name 仍保留完整路径;旧响应可省略此字段。
+ DocumentTitle string `json:"documentTitle,omitempty"`
+ Type string `json:"type"`
+ SubType string `json:"subType"`
+ Children []*BlockPath `json:"children"`
+ HasChildren bool `json:"hasChildren,omitempty"`
}
type BlockBreadcrumbChildren struct {
diff --git a/kernel/apicontract/contracts.go b/kernel/apicontract/contracts.go
index bcac00d2aa..1349071b20 100644
--- a/kernel/apicontract/contracts.go
+++ b/kernel/apicontract/contracts.go
@@ -819,8 +819,10 @@ var UpdateEmbedBlock = define[UpdateEmbedBlockRequest, Null]("updateEmbedBlock",
var FullTextSearchAssetContent = define[SearchAssetContentRequest, SearchAssetContentData]("fullTextSearchAssetContent", "/api/search/fullTextSearchAssetContent", AuthenticatedAccess, JSONBody, ResponseOptions{}, "POST")
+// GetEmbedBlock 返回的文档面包屑项可附带 documentTitle,name 保留完整路径;标题不受路径分隔符影响。
var GetEmbedBlock = define[GetEmbedBlockRequest, EmbedBlocksData]("getEmbedBlock", "/api/search/getEmbedBlock", AuthenticatedAccess, JSONBody, ResponseOptions{}, "POST")
+// SearchEmbedBlock 返回的文档面包屑项可附带 documentTitle,供客户端按偏好显示独立标题或完整 name 路径。
var SearchEmbedBlock = define[SearchEmbedBlockRequest, EmbedBlocksData]("searchEmbedBlock", "/api/search/searchEmbedBlock", AuthenticatedAccess, JSONBody, ResponseOptions{}, "POST")
// method 缺省或为 null 时使用文本替换,支持文本(0)、查询语法(1)和正则表达式(3)。
diff --git a/kernel/apicontract/schema.json b/kernel/apicontract/schema.json
index 590a1a1a65..ad27a95cb6 100644
--- a/kernel/apicontract/schema.json
+++ b/kernel/apicontract/schema.json
@@ -20123,6 +20123,9 @@
}
]
},
+ "documentTitle": {
+ "type": "string"
+ },
"hasChildren": {
"type": "boolean"
},
@@ -42523,6 +42526,16 @@
}
]
},
+ "embedBlockBreadcrumbParentPath": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
"emoji": {
"anyOf": [
{
@@ -46732,6 +46745,16 @@
"embedBlockBreadcrumb": {
"type": "boolean"
},
+ "embedBlockBreadcrumbParentPath": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
"emoji": {
"anyOf": [
{
@@ -46927,6 +46950,7 @@
"dragHTMLFileToIframe",
"dynamicLoadBlocks",
"embedBlockBreadcrumb",
+ "embedBlockBreadcrumbParentPath",
"emoji",
"floatWindowDelay",
"floatWindowMode",
@@ -47392,6 +47416,16 @@
}
]
},
+ "embedBlockBreadcrumbParentPath": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
"emoji": {
"anyOf": [
{
diff --git a/kernel/apicontract/setting.go b/kernel/apicontract/setting.go
index 3fd4ebf717..2f62b75a11 100644
--- a/kernel/apicontract/setting.go
+++ b/kernel/apicontract/setting.go
@@ -249,11 +249,13 @@ type SettingEditor struct {
KaTexMacros string `json:"katexMacros" api:"optional,nullable"`
ReadOnly bool `json:"readOnly" api:"optional,nullable"`
EmbedBlockBreadcrumb bool `json:"embedBlockBreadcrumb" api:"optional,nullable"`
- ListLogicalOutdent bool `json:"listLogicalOutdent" api:"optional,nullable"`
- ListItemDotNumberClickFocus bool `json:"listItemDotNumberClickFocus" api:"optional,nullable"`
- FloatWindowMode int `json:"floatWindowMode" api:"optional,nullable"`
- FloatWindowDelay *int `json:"floatWindowDelay" api:"optional,nullable"`
- KeepLoadedContent bool `json:"keepLoadedContent" api:"optional,nullable"`
+ // 默认显示文档上层路径;省略保留当前值,null 恢复默认,块级显式设置优先。
+ EmbedBlockBreadcrumbParentPath *bool `json:"embedBlockBreadcrumbParentPath" api:"optional,nullable"`
+ ListLogicalOutdent bool `json:"listLogicalOutdent" api:"optional,nullable"`
+ ListItemDotNumberClickFocus bool `json:"listItemDotNumberClickFocus" api:"optional,nullable"`
+ FloatWindowMode int `json:"floatWindowMode" api:"optional,nullable"`
+ FloatWindowDelay *int `json:"floatWindowDelay" api:"optional,nullable"`
+ KeepLoadedContent bool `json:"keepLoadedContent" api:"optional,nullable"`
// PageScrollButtons 控制翻屏按钮,默认关闭,不迁移旧的本地偏好。
PageScrollButtons bool `json:"pageScrollButtons" api:"optional,nullable"`
DynamicLoadBlocks int `json:"dynamicLoadBlocks" api:"optional,nullable"`
diff --git a/kernel/conf/editor.go b/kernel/conf/editor.go
index 9845f68597..b70283354e 100644
--- a/kernel/conf/editor.go
+++ b/kernel/conf/editor.go
@@ -82,6 +82,7 @@ type Editor struct {
KaTexMacros string `json:"katexMacros"` // KeTex 宏定义
ReadOnly bool `json:"readOnly"` // 只读模式
EmbedBlockBreadcrumb bool `json:"embedBlockBreadcrumb"` // 嵌入块是否显示面包屑
+ EmbedBlockBreadcrumbParentPath *bool `json:"embedBlockBreadcrumbParentPath"` // 嵌入块面包屑是否显示文档上层路径
ListLogicalOutdent bool `json:"listLogicalOutdent"` // 列表逻辑反向缩进
ListItemDotNumberClickFocus bool `json:"listItemDotNumberClickFocus"` // 单击列表项标记聚焦
FloatWindowMode int `json:"floatWindowMode"` // 浮窗触发模式,0:光标悬停,1:按住 Ctrl 悬停,2:不触发浮窗
@@ -228,6 +229,7 @@ func NewEditor() *Editor {
KaTexMacros: "{}",
ReadOnly: false,
EmbedBlockBreadcrumb: false,
+ EmbedBlockBreadcrumbParentPath: new(true),
ListLogicalOutdent: false,
ListItemDotNumberClickFocus: true,
FloatWindowMode: 0,
diff --git a/kernel/conf/editor_test.go b/kernel/conf/editor_test.go
index 68ce39657d..56a2b6d50f 100644
--- a/kernel/conf/editor_test.go
+++ b/kernel/conf/editor_test.go
@@ -16,7 +16,27 @@
package conf
-import "testing"
+import (
+ "encoding/json"
+ "testing"
+)
+
+func TestEditorEmbedBreadcrumbParentPathDefaults(t *testing.T) {
+ for _, input := range []string{`{}`, `{"embedBlockBreadcrumbParentPath":null}`, `{"embedBlockBreadcrumbParentPath":true}`, `{"embedBlockBreadcrumbParentPath":false}`} {
+ var editor Editor
+ if err := json.Unmarshal([]byte(input), &editor); err != nil {
+ t.Fatal(err)
+ }
+ NormalizeEditor(&editor)
+ want := input != `{"embedBlockBreadcrumbParentPath":false}`
+ if editor.EmbedBlockBreadcrumbParentPath == nil || *editor.EmbedBlockBreadcrumbParentPath != want {
+ t.Fatalf("unexpected parent path default for %s: %+v", input, editor.EmbedBlockBreadcrumbParentPath)
+ }
+ }
+ if value := NewEditor().EmbedBlockBreadcrumbParentPath; value == nil || !*value {
+ t.Fatal("new editors must retain full paths")
+ }
+}
func TestNewEditorEnablesBlockRefCheck(t *testing.T) {
editor := NewEditor()
diff --git a/kernel/conf/settings_normalize.go b/kernel/conf/settings_normalize.go
index a38296e41f..233df648af 100644
--- a/kernel/conf/settings_normalize.go
+++ b/kernel/conf/settings_normalize.go
@@ -84,6 +84,9 @@ func NormalizeEditor(editor *Editor) *Editor {
if editor.CheckBlockRef == nil {
editor.CheckBlockRef = defaults.CheckBlockRef
}
+ if editor.EmbedBlockBreadcrumbParentPath == nil {
+ editor.EmbedBlockBreadcrumbParentPath = defaults.EmbedBlockBreadcrumbParentPath
+ }
if editor.HashTagSearch == nil {
editor.HashTagSearch = defaults.HashTagSearch
}
diff --git a/kernel/model/blockinfo.go b/kernel/model/blockinfo.go
index ec17ecbd73..ec1faab6ee 100644
--- a/kernel/model/blockinfo.go
+++ b/kernel/model/blockinfo.go
@@ -611,12 +611,13 @@ func getDocBlocksOrdersInTree(tree *parse.Tree) (ret []string) {
}
type BlockPath struct {
- ID string `json:"id"`
- Name string `json:"name"`
- Type string `json:"type"`
- SubType string `json:"subType"`
- Children []*BlockPath `json:"children"`
- HasChildren bool `json:"hasChildren,omitempty"`
+ ID string `json:"id"`
+ Name string `json:"name"`
+ DocumentTitle string `json:"documentTitle,omitempty"`
+ Type string `json:"type"`
+ SubType string `json:"subType"`
+ Children []*BlockPath `json:"children"`
+ HasChildren bool `json:"hasChildren,omitempty"`
}
type BlockBreadcrumbChildren struct {
@@ -881,11 +882,16 @@ func buildBlockBreadcrumb(node *ast.Node, excludeTypes []string, isEmbedBlock bo
}
if add {
+ documentTitle := ""
+ if isEmbedBlock && ast.NodeDocument == parent.Type {
+ documentTitle = util.EscapeHTML(strings.ReplaceAll(treenode.ReadDocumentTitle(parent).Text, editor.Caret, ""))
+ }
ret = append([]*BlockPath{{
- ID: id,
- Name: name,
- Type: parent.Type.String(),
- SubType: treenode.SubTypeAbbr(parent),
+ ID: id,
+ Name: name,
+ DocumentTitle: documentTitle,
+ Type: parent.Type.String(),
+ SubType: treenode.SubTypeAbbr(parent),
}}, ret...)
}
diff --git a/kernel/model/blockinfo_test.go b/kernel/model/blockinfo_test.go
index c3edbc2b07..171665259d 100644
--- a/kernel/model/blockinfo_test.go
+++ b/kernel/model/blockinfo_test.go
@@ -47,6 +47,28 @@ func TestWalkBlockBreadcrumbChildren(t *testing.T) {
assertBlockBreadcrumbChildIDs(t, paragraph1, []string{})
}
+func TestEmbedBreadcrumbDocumentTitle(t *testing.T) {
+ fixture := setupFileOperationTest(t)
+ tree, err := LoadTreeByBlockID(fixture.sourceID)
+ if err != nil {
+ t.Fatal(err)
+ }
+ tree.Root.SetIALAttr("title", "Title / Section <A> & B")
+ for _, embedded := range []bool{true, false} {
+ paths := buildBlockBreadcrumb(treenode.GetNodeInTree(tree, fixture.childID), nil, embedded)
+ if len(paths) == 0 || paths[0].ID != tree.Root.ID {
+ t.Fatalf("missing document breadcrumb: %+v", paths)
+ }
+ if embedded {
+ if paths[0].DocumentTitle != "Title / Section &lt;A&gt; &amp; B" || paths[0].Name == paths[0].DocumentTitle {
+ t.Fatalf("document title must be separate from the unchanged full path: %+v", paths[0])
+ }
+ } else if paths[0].DocumentTitle != "" {
+ t.Fatalf("ordinary breadcrumbs changed: %+v", paths[0])
+ }
+ }
+}
+
func TestWalkBlockBreadcrumbContainerChildren(t *testing.T) {
list := &ast.Node{Type: ast.NodeList, ID: "list"}
item1 := &ast.Node{Type: ast.NodeListItem, ID: "item1"}