An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: Improve mind map node toolbar controls https://github.com/siyuan-note/siyuan/issues/20803
Daniel98d36d2bb554
diff --git a/app/appearance/langs/ar.json b/app/appearance/langs/ar.jsonindex bf3e6098b2..ea9844adf8 100644--- a/app/appearance/langs/ar.json+++ b/app/appearance/langs/ar.json@@ -1,4 +1,5 @@{+ "listMindmapRestoreWidth": "استعادة العرض الأصلي","lockScreenReveal": "انقر أو اضغط على مفتاح لتسجيل الدخول","loadAllAndSelectAll": "تحميل المستند بالكامل وتحديد الكل","autoFitRowHeight": "ملاءمة ارتفاع الصف تلقائيًا",diff --git a/app/appearance/langs/de.json b/app/appearance/langs/de.jsonindex 2452b9b064..43af3f2901 100644--- a/app/appearance/langs/de.json+++ b/app/appearance/langs/de.json@@ -1,4 +1,5 @@{+ "listMindmapRestoreWidth": "Ursprüngliche Breiten wiederherstellen","lockScreenReveal": "Zum Anmelden klicken oder eine Taste drücken","loadAllAndSelectAll": "Gesamtes Dokument laden und alles auswählen","autoFitRowHeight": "Zeilenhöhe automatisch anpassen",diff --git a/app/appearance/langs/en.json b/app/appearance/langs/en.jsonindex b8b9b67bf1..739130fdf7 100644--- a/app/appearance/langs/en.json+++ b/app/appearance/langs/en.json@@ -1,4 +1,5 @@{+ "listMindmapRestoreWidth": "Restore original widths","lockScreenReveal": "Click or press a key to sign in","loadAllAndSelectAll": "Load full document and select all","autoFitRowHeight": "Auto-fit row height",diff --git a/app/appearance/langs/es.json b/app/appearance/langs/es.jsonindex 44946842eb..2fbf3aab83 100644--- a/app/appearance/langs/es.json+++ b/app/appearance/langs/es.json@@ -1,4 +1,5 @@{+ "listMindmapRestoreWidth": "Restaurar los anchos originales","lockScreenReveal": "Haz clic o pulsa una tecla para iniciar sesión","loadAllAndSelectAll": "Cargar el documento completo y seleccionar todo","autoFitRowHeight": "Ajustar automáticamente la altura de fila",diff --git a/app/appearance/langs/fr.json b/app/appearance/langs/fr.jsonindex 05e22e6c48..14674de1f1 100644--- a/app/appearance/langs/fr.json+++ b/app/appearance/langs/fr.json@@ -1,4 +1,5 @@{+ "listMindmapRestoreWidth": "Restaurer les largeurs initiales","lockScreenReveal": "Cliquez ou appuyez sur une touche pour vous connecter","loadAllAndSelectAll": "Charger le document entier et tout sélectionner","autoFitRowHeight": "Ajuster automatiquement la hauteur de ligne",diff --git a/app/appearance/langs/he.json b/app/appearance/langs/he.jsonindex 8ccdcc120b..47ebfa66fb 100644--- a/app/appearance/langs/he.json+++ b/app/appearance/langs/he.json@@ -1,4 +1,5 @@{+ "listMindmapRestoreWidth": "שחזור הרוחב המקורי","lockScreenReveal": "יש ללחוץ על המסך או על מקש כדי להיכנס","loadAllAndSelectAll": "טעינת המסמך המלא ובחירת הכול","autoFitRowHeight": "התאמה אוטומטית של גובה השורה",diff --git a/app/appearance/langs/hi.json b/app/appearance/langs/hi.jsonindex 43538d2a8f..03b8a4737e 100644--- a/app/appearance/langs/hi.json+++ b/app/appearance/langs/hi.json@@ -1,4 +1,5 @@{+ "listMindmapRestoreWidth": "मूल चौड़ाई बहाल करें","lockScreenReveal": "लॉगिन करने के लिए क्लिक करें या कोई कुंजी दबाएँ","loadAllAndSelectAll": "पूरा दस्तावेज़ लोड करें और सभी चुनें","autoFitRowHeight": "पंक्ति की ऊँचाई अपने आप समायोजित करें",diff --git a/app/appearance/langs/id.json b/app/appearance/langs/id.jsonindex 55dd1579b3..002f0413f0 100644--- a/app/appearance/langs/id.json+++ b/app/appearance/langs/id.json@@ -1,4 +1,5 @@{+ "listMindmapRestoreWidth": "Pulihkan lebar semula","lockScreenReveal": "Klik atau tekan tombol untuk masuk","loadAllAndSelectAll": "Muat seluruh dokumen dan pilih semua","autoFitRowHeight": "Sesuaikan tinggi baris secara otomatis",diff --git a/app/appearance/langs/it.json b/app/appearance/langs/it.jsonindex 36d6496250..472a1b4269 100644--- a/app/appearance/langs/it.json+++ b/app/appearance/langs/it.json@@ -1,4 +1,5 @@{+ "listMindmapRestoreWidth": "Ripristina le larghezze originali","lockScreenReveal": "Fai clic o premi un tasto per accedere","loadAllAndSelectAll": "Carica l'intero documento e seleziona tutto","autoFitRowHeight": "Adatta automaticamente l’altezza della riga",diff --git a/app/appearance/langs/ja.json b/app/appearance/langs/ja.jsonindex ce82f58dd6..33fb0bea13 100644--- a/app/appearance/langs/ja.json+++ b/app/appearance/langs/ja.json@@ -1,4 +1,5 @@{+ "listMindmapRestoreWidth": "元の幅に戻す","lockScreenReveal": "クリックまたはキーを押してログイン","loadAllAndSelectAll": "全文を読み込んですべて選択","autoFitRowHeight": "行の高さを自動調整",diff --git a/app/appearance/langs/ko.json b/app/appearance/langs/ko.jsonindex 1008ff9bf2..8d4d0f4e17 100644--- a/app/appearance/langs/ko.json+++ b/app/appearance/langs/ko.json@@ -1,4 +1,5 @@{+ "listMindmapRestoreWidth": "원래 너비 복원","lockScreenReveal": "화면을 클릭하거나 키를 눌러 로그인","loadAllAndSelectAll": "전체 문서를 불러오고 모두 선택","autoFitRowHeight": "행 높이 자동 맞춤",diff --git a/app/appearance/langs/nl.json b/app/appearance/langs/nl.jsonindex 38dc78dfb4..f5238c0ef4 100644--- a/app/appearance/langs/nl.json+++ b/app/appearance/langs/nl.json@@ -1,4 +1,5 @@{+ "listMindmapRestoreWidth": "Oorspronkelijke breedtes herstellen","lockScreenReveal": "Klik of druk op een toets om aan te melden","loadAllAndSelectAll": "Volledig document laden en alles selecteren","autoFitRowHeight": "Rijhoogte automatisch aanpassen",diff --git a/app/appearance/langs/pl.json b/app/appearance/langs/pl.jsonindex 9ace76d1f1..39b59fa116 100644--- a/app/appearance/langs/pl.json+++ b/app/appearance/langs/pl.json@@ -1,4 +1,5 @@{+ "listMindmapRestoreWidth": "Przywróć pierwotne szerokości","lockScreenReveal": "Kliknij lub naciśnij klawisz, aby się zalogować","loadAllAndSelectAll": "Wczytaj cały dokument i zaznacz wszystko","autoFitRowHeight": "Automatycznie dopasuj wysokość wiersza",diff --git a/app/appearance/langs/pt-BR.json b/app/appearance/langs/pt-BR.jsonindex d3b4970a98..734f979ae5 100644--- a/app/appearance/langs/pt-BR.json+++ b/app/appearance/langs/pt-BR.json@@ -1,4 +1,5 @@{+ "listMindmapRestoreWidth": "Restaurar larguras originais","lockScreenReveal": "Clique ou pressione uma tecla para entrar","loadAllAndSelectAll": "Carregar o documento completo e selecionar tudo","autoFitRowHeight": "Ajustar automaticamente a altura da linha",diff --git a/app/appearance/langs/ru.json b/app/appearance/langs/ru.jsonindex 4344d74808..b009977dd1 100644--- a/app/appearance/langs/ru.json+++ b/app/appearance/langs/ru.json@@ -1,4 +1,5 @@{+ "listMindmapRestoreWidth": "Восстановить исходную ширину","lockScreenReveal": "Нажмите на экран или клавишу для входа","loadAllAndSelectAll": "Загрузить весь документ и выделить всё","autoFitRowHeight": "Автоподбор высоты строки",diff --git a/app/appearance/langs/sk.json b/app/appearance/langs/sk.jsonindex e6d1049a9e..e0738dcd81 100644--- a/app/appearance/langs/sk.json+++ b/app/appearance/langs/sk.json@@ -1,4 +1,5 @@{+ "listMindmapRestoreWidth": "Obnoviť pôvodné šírky","lockScreenReveal": "Prihláste sa kliknutím alebo stlačením klávesu","loadAllAndSelectAll": "Načítať celý dokument a vybrať všetko","autoFitRowHeight": "Automaticky prispôsobiť výšku riadka",diff --git a/app/appearance/langs/sr.json b/app/appearance/langs/sr.jsonindex 2becb9b217..9d93f46963 100644--- a/app/appearance/langs/sr.json+++ b/app/appearance/langs/sr.json@@ -1,4 +1,5 @@{+ "listMindmapRestoreWidth": "Врати првобитне ширине","lockScreenReveal": "Кликните или притисните тастер за пријављивање","loadAllAndSelectAll": "Учитај цео документ и изабери све","autoFitRowHeight": "Аутоматски прилагоди висину реда",diff --git a/app/appearance/langs/th.json b/app/appearance/langs/th.jsonindex 09803a70bd..4f97384e3f 100644--- a/app/appearance/langs/th.json+++ b/app/appearance/langs/th.json@@ -1,4 +1,5 @@{+ "listMindmapRestoreWidth": "คืนค่าความกว้างเดิม","lockScreenReveal": "คลิกหรือกดปุ่มเพื่อเข้าสู่ระบบ","loadAllAndSelectAll": "โหลดเอกสารทั้งหมดและเลือกทั้งหมด","autoFitRowHeight": "ปรับความสูงของแถวโดยอัตโนมัติ",diff --git a/app/appearance/langs/tr.json b/app/appearance/langs/tr.jsonindex 82c128b677..bcb5938b44 100644--- a/app/appearance/langs/tr.json+++ b/app/appearance/langs/tr.json@@ -1,4 +1,5 @@{+ "listMindmapRestoreWidth": "Özgün genişlikleri geri yükle","lockScreenReveal": "Giriş yapmak için tıklayın veya bir tuşa basın","loadAllAndSelectAll": "Belgenin tamamını yükle ve tümünü seç","autoFitRowHeight": "Satır yüksekliğini otomatik sığdır",diff --git a/app/appearance/langs/uk.json b/app/appearance/langs/uk.jsonindex 850049d963..2da783c8e4 100644--- a/app/appearance/langs/uk.json+++ b/app/appearance/langs/uk.json@@ -1,4 +1,5 @@{+ "listMindmapRestoreWidth": "Відновити початкову ширину","lockScreenReveal": "Натисніть на екран або клавішу для входу","loadAllAndSelectAll": "Завантажити весь документ і виділити все","autoFitRowHeight": "Автоматично підібрати висоту рядка",diff --git a/app/appearance/langs/zh-CN.json b/app/appearance/langs/zh-CN.jsonindex 1da9b7d66e..d9a6347762 100644--- a/app/appearance/langs/zh-CN.json+++ b/app/appearance/langs/zh-CN.json@@ -1,4 +1,5 @@{+ "listMindmapRestoreWidth": "恢复原宽度","lockScreenReveal": "点击屏幕或按键以登录","loadAllAndSelectAll": "加载全文并全选","autoFitRowHeight": "自适应行高",diff --git a/app/appearance/langs/zh-TW.json b/app/appearance/langs/zh-TW.jsonindex 86f95d2d9e..2236bfe968 100644--- a/app/appearance/langs/zh-TW.json+++ b/app/appearance/langs/zh-TW.json@@ -1,4 +1,5 @@{+ "listMindmapRestoreWidth": "還原原始寬度","lockScreenReveal": "點擊畫面或按鍵以登入","loadAllAndSelectAll": "載入全文並全選","autoFitRowHeight": "自動調整列高",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.syindex adee21ef22..6438fcb89a 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": "20261022235541"+ "updated": "20261023003049"},"Children": [{@@ -1961,7 +1961,7 @@"HeadingLevel": 2,"Properties": {"id": "20210104091509-v1x69oc",- "updated": "20261022235541"+ "updated": "20261023003049"},"Children": [{@@ -1995,17 +1995,121 @@}]},+ {+ "ID": "20261023003049-1oqzzuq",+ "Type": "NodeParagraph",+ "Properties": {+ "id": "20261023003049-1oqzzuq",+ "updated": "20261023003049"+ },+ "Children": [+ {+ "Type": "NodeText",+ "Data": "The bottom node menu provides "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "Delete"+ },+ {+ "Type": "NodeText",+ "Data": ", "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "Copy"+ },+ {+ "Type": "NodeText",+ "Data": ", "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "Cut"+ },+ {+ "Type": "NodeText",+ "Data": ", and "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "Paste"+ },+ {+ "Type": "NodeText",+ "Data": " directly. "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "Paste"+ },+ {+ "Type": "NodeText",+ "Data": " adds child nodes; "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "More"+ },+ {+ "Type": "NodeText",+ "Data": " retains the sibling paste option. Hover over or tap "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "Color"+ },+ {+ "Type": "NodeText",+ "Data": " to open the styles and style management panel above the bar. Unsupported actions are disabled."+ }+ ]+ },{"ID": "20261022181804-c0rm54w","Type": "NodeParagraph","Properties": {"id": "20261022181804-c0rm54w",- "updated": "20261022181804"+ "updated": "20261023003049"},"Children": [{"Type": "NodeText",- "Data": "Select one or more nodes and set Width in the floating style bar to adjust their width in pixels. Clear the value to restore automatic sizing. Widen a node to show a long inline formula on one line. The width is saved with the document and supports undo and redo."+ "Data": "Select one or more nodes and hover over or tap "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "Width"+ },+ {+ "Type": "NodeText",+ "Data": " in the bottom node menu. The panel opens above the bar. The slider starts centered on the current width; move left to narrow or right to widen the selected nodes. Dragging previews the result, and releasing saves one undoable change. You can also enter a pixel width. "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "Restore original widths"+ },+ {+ "Type": "NodeText",+ "Data": " returns each selected node to its width when this panel was opened, including automatic widths. "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "Default"+ },+ {+ "Type": "NodeText",+ "Data": ", or clearing the number field, fits the width to the content. Widening a node can keep a long inline formula on one line. Widths are saved with the document and support undo and redo."}]},diff --git a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20200924100950-9op5xi1.sy b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20200924100950-9op5xi1.syindex 6f57b51354..6b4960f5a6 100644--- a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20200924100950-9op5xi1.sy+++ b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20200924100950-9op5xi1.sy@@ -7,7 +7,7 @@"id": "20200924100950-9op5xi1","title": "Shortcuts","type": "doc",- "updated": "20261022235541"+ "updated": "20261023003049"},"Children": [{@@ -13115,7 +13115,7 @@"Type": "NodeHeading","Properties": {"id": "20260921105011-4zeuyl4",- "updated": "20261022235541"+ "updated": "20261023003049"},"HeadingLevel": 3,"Children": [@@ -13960,7 +13960,7 @@"Type": "NodeParagraph","Properties": {"id": "20260926152753-8trdt10",- "updated": "20261022235541"+ "updated": "20261023003049"},"Children": [{@@ -13975,6 +13975,10 @@{"Type": "NodeText","Data": " in the bottom node menu to create all valid groups in one undoable operation and edit the first new summary. Esc on the canvas leaves multi-select mode. While editing summary text, Enter saves and Esc cancels the text edit. Delete or Backspace removes the selected summary."+ },+ {+ "Type": "NodeText",+ "Data": " When a color or width panel is open, Escape closes it and cancels any unsaved width preview."}]},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.syindex 3525a2de1b..9e723956cc 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": "20261022235541"+ "updated": "20261023003125"},"Children": [{@@ -1964,7 +1964,7 @@"HeadingLevel": 2,"Properties": {"id": "20210104091228-wdpx6ev",- "updated": "20261022235541"+ "updated": "20261023003125"},"Children": [{@@ -1998,17 +1998,88 @@}]},+ {+ "ID": "20261023003125-br0hgmh",+ "Type": "NodeParagraph",+ "Properties": {+ "id": "20261023003125-br0hgmh",+ "updated": "20261023003125"+ },+ "Children": [+ {+ "Type": "NodeText",+ "Data": "底部节点菜单直接提供删除、复制、剪切和粘贴。粘贴会添加子节点,"+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "更多"+ },+ {+ "Type": "NodeText",+ "Data": " "+ },+ {+ "Type": "NodeText",+ "Data": "保留粘贴为同级节点的选项。悬停或点击 "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "颜色"+ },+ {+ "Type": "NodeText",+ "Data": ",可在底栏上方打开节点样式及样式管理面板。不适用的操作会置灰。"+ }+ ]+ },{"ID": "20261022181804-udgwd1x","Type": "NodeParagraph","Properties": {"id": "20261022181804-udgwd1x",- "updated": "20261022181804"+ "updated": "20261023003125"},"Children": [{"Type": "NodeText",- "Data": "选中一个或多个节点后,在浮动样式栏的“宽度”中输入像素值即可调整节点宽度;清空数值可恢复自动宽度。加宽节点可让较长的行级公式在一行内显示。宽度随文档保存,支持撤销和重做。"+ "Data": "选中一个或多个节点后,悬停或点击底部节点菜单的 "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "宽度"+ },+ {+ "Type": "NodeText",+ "Data": ",在底栏上方打开面板。滑块以打开面板时的当前宽度为中心,向左缩窄,向右加宽所选节点。拖动时预览,松手后保存为一次可撤销的修改,也可输入精确的像素宽度。"+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "恢复原宽度"+ },+ {+ "Type": "NodeText",+ "Data": " "+ },+ {+ "Type": "NodeText",+ "Data": "会还原各节点打开面板时的宽度,包括原先的自动宽度;"+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "默认"+ },+ {+ "Type": "NodeText",+ "Data": " "+ },+ {+ "Type": "NodeText",+ "Data": "或清空数值输入框会按内容自适应。加宽节点可让较长的行内公式在一行中显示。宽度随文档保存,支持撤销和重做。"}]},diff --git a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20200813004551-gm0pbn1.sy b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20200813004551-gm0pbn1.syindex 72d7588666..2a9df2caec 100644--- a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20200813004551-gm0pbn1.sy+++ b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20200813004551-gm0pbn1.sy@@ -7,7 +7,7 @@"id": "20200813004551-gm0pbn1","title": "快捷键","type": "doc",- "updated": "20261022235541"+ "updated": "20261023003125"},"Children": [{@@ -13097,7 +13097,7 @@"Type": "NodeHeading","Properties": {"id": "20260921105011-hmrchvc",- "updated": "20261022235541"+ "updated": "20261023003125"},"HeadingLevel": 3,"Children": [@@ -14030,7 +14030,7 @@"Type": "NodeParagraph","Properties": {"id": "20260926152753-tamny2o",- "updated": "20261022235541"+ "updated": "20261023003125"},"Children": [{@@ -14045,6 +14045,10 @@{"Type": "NodeText","Data": " 可一次创建所有有效分组,并可一次撤销,随后编辑第一个新概要。在画布上按 Esc 退出多选模式。编辑概要文字时,Enter 保存,Esc 取消文字编辑。选中概要后,Delete 或 Backspace 删除概要。"+ },+ {+ "Type": "NodeText",+ "Data": "颜色或宽度面板打开时,按 Esc 关闭面板,并取消尚未保存的宽度预览。"}]},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.syindex a15b1e9e9c..a0b1e0455e 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": "20261022235541"+ "updated": "20261023003125"},"Children": [{@@ -1962,7 +1962,7 @@"HeadingLevel": 2,"Properties": {"id": "20211226122008-731sqd6",- "updated": "20261022235541"+ "updated": "20261023003125"},"Children": [{@@ -1996,17 +1996,88 @@}]},+ {+ "ID": "20261023003125-gh1vclp",+ "Type": "NodeParagraph",+ "Properties": {+ "id": "20261023003125-gh1vclp",+ "updated": "20261023003125"+ },+ "Children": [+ {+ "Type": "NodeText",+ "Data": "底部節點選單直接提供刪除、複製、剪下和貼上。貼上會新增子節點,"+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "更多"+ },+ {+ "Type": "NodeText",+ "Data": " "+ },+ {+ "Type": "NodeText",+ "Data": "保留貼上為同層節點的選項。懸停或點擊 "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "顏色"+ },+ {+ "Type": "NodeText",+ "Data": ",可在底欄上方開啟節點樣式及樣式管理面板。不適用的操作會停用。"+ }+ ]+ },{"ID": "20261022181804-9n8owq8","Type": "NodeParagraph","Properties": {"id": "20261022181804-9n8owq8",- "updated": "20261022181804"+ "updated": "20261023003125"},"Children": [{"Type": "NodeText",- "Data": "選取一個或多個節點後,在浮動樣式列的「寬度」中輸入像素值即可調整節點寬度;清空數值可恢復自動寬度。加寬節點可讓較長的行內公式在同一行顯示。寬度隨文件儲存,支援復原與重做。"+ "Data": "選取一個或多個節點後,懸停或點擊底部節點選單的 "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "寬度"+ },+ {+ "Type": "NodeText",+ "Data": ",在底欄上方開啟面板。滑桿以開啟面板時的目前寬度為中心,向左縮窄,向右加寬所選節點。拖動時預覽,放開後儲存為一次可復原的修改,也可輸入精確的像素寬度。"+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "還原原始寬度"+ },+ {+ "Type": "NodeText",+ "Data": " "+ },+ {+ "Type": "NodeText",+ "Data": "會還原各節點開啟面板時的寬度,包括原先的自動寬度;"+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "預設"+ },+ {+ "Type": "NodeText",+ "Data": " "+ },+ {+ "Type": "NodeText",+ "Data": "或清空數值輸入框會依內容自動調整。加寬節點可讓較長的行內公式在一行中顯示。寬度隨文件儲存,支援復原和重做。"}]},diff --git a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20211226122549-jktxego.sy b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20211226122549-jktxego.syindex 6684af6814..95cb0010bb 100644--- a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20211226122549-jktxego.sy+++ b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20211226122549-jktxego.sy@@ -7,7 +7,7 @@"id": "20211226122549-jktxego","title": "快捷鍵","type": "doc",- "updated": "20261022235541"+ "updated": "20261023003125"},"Children": [{@@ -13103,7 +13103,7 @@"Type": "NodeHeading","Properties": {"id": "20260921105011-z0oyw36",- "updated": "20261022235541"+ "updated": "20261023003125"},"HeadingLevel": 3,"Children": [@@ -13948,7 +13948,7 @@"Type": "NodeParagraph","Properties": {"id": "20260926152753-0k1m0f6",- "updated": "20261022235541"+ "updated": "20261023003125"},"Children": [{@@ -13963,6 +13963,10 @@{"Type": "NodeText","Data": " 可一次建立所有有效分組,並可一次復原,隨後編輯第一個新概要。在畫布上按 Esc 結束多選模式。編輯概要文字時,Enter 儲存,Esc 取消文字編輯。選取概要後,Delete 或 Backspace 刪除概要。"+ },+ {+ "Type": "NodeText",+ "Data": "顏色或寬度面板開啟時,按 Esc 關閉面板,並取消尚未儲存的寬度預覽。"}]},diff --git a/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-g3ugxml/20240530101000-xsbxokr.sy b/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-g3ugxml/20240530101000-xsbxokr.syindex 0868eca299..f575b92c31 100644--- a/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-g3ugxml/20240530101000-xsbxokr.sy+++ b/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-g3ugxml/20240530101000-xsbxokr.sy@@ -9,7 +9,7 @@"id": "20240530101000-xsbxokr","title": "ショートカット","type": "doc",- "updated": "20261022235541"+ "updated": "20261023003241"},"Children": [{@@ -13053,7 +13053,7 @@"Type": "NodeHeading","Properties": {"id": "20260921105011-icqlkb6",- "updated": "20261022235541"+ "updated": "20261023003241"},"HeadingLevel": 3,"Children": [@@ -13880,7 +13880,7 @@"Type": "NodeParagraph","Properties": {"id": "20260926152753-5vwcnw1",- "updated": "20261022235541"+ "updated": "20261023003241"},"Children": [{@@ -13895,6 +13895,10 @@{"Type": "NodeText","Data": " を実行すると、有効な全グループを一度に作成し、最初の新しい要約を編集できます。作成は一度の取り消しで元に戻せます。キャンバス上で Esc を押すと複数選択モードを終了します。要約テキストの編集中は Enter で保存、Esc でテキストの編集をキャンセルします。選択中の要約は Delete または Backspace で削除できます。"+ },+ {+ "Type": "NodeText",+ "Data": "色または幅のパネルが開いているときは、Esc でパネルを閉じ、未保存の幅のプレビューを取り消します。"}]},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.syindex f86f654030..54a0776098 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": "20261022235541"+ "updated": "20261023003125"},"Children": [{@@ -2090,7 +2090,7 @@"Properties": {"ID": "20240530101000-ch5e4vh","id": "20240530101000-1ev7xub",- "updated": "20261022235541"+ "updated": "20261023003125"},"Children": [{@@ -2124,17 +2124,83 @@}]},+ {+ "ID": "20261023003125-j5vqqpm",+ "Type": "NodeParagraph",+ "Properties": {+ "id": "20261023003125-j5vqqpm",+ "updated": "20261023003125"+ },+ "Children": [+ {+ "Type": "NodeText",+ "Data": "下部のノードメニューには削除、コピー、切り取り、貼り付けを直接表示します。貼り付けは子ノードを追加し、「その他」では同じ階層への貼り付けも選べます。"+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "色"+ },+ {+ "Type": "NodeText",+ "Data": " "+ },+ {+ "Type": "NodeText",+ "Data": "にマウスを合わせるかタップすると、バーの上にノードのスタイルとスタイル管理のパネルが開きます。利用できない操作は無効になります。"+ }+ ]+ },{"ID": "20261022181804-s1vt5mf","Type": "NodeParagraph","Properties": {"id": "20261022181804-s1vt5mf",- "updated": "20261022181804"+ "updated": "20261023003125"},"Children": [{"Type": "NodeText",- "Data": "1 つ以上のノードを選択し、フローティングスタイルバーの「幅」にピクセル値を入力すると、ノードの幅を調整できます。値を空にすると自動調整に戻ります。ノードを広げると、長いインライン数式を 1 行で表示できます。幅は文書とともに保存され、取り消しとやり直しに対応します。"+ "Data": "1 つ以上のノードを選択し、下部のノードメニューの "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "幅"+ },+ {+ "Type": "NodeText",+ "Data": " "+ },+ {+ "Type": "NodeText",+ "Data": "にマウスを合わせるかタップすると、バーの上にパネルが開きます。スライダーの中央はパネルを開いたときの現在の幅です。左に動かすと狭く、右に動かすと広くなります。ドラッグ中はプレビューし、指を離すと取り消し可能な 1 回の変更として保存します。ピクセル値を直接入力することもできます。"+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "元の幅に戻す"+ },+ {+ "Type": "NodeText",+ "Data": " "+ },+ {+ "Type": "NodeText",+ "Data": "は各ノードをパネルを開いたときの幅に戻し、自動幅も復元します。"+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "デフォルト"+ },+ {+ "Type": "NodeText",+ "Data": " "+ },+ {+ "Type": "NodeText",+ "Data": "または数値欄を空にすると内容に合わせて自動調整します。幅を広げると長いインライン数式を 1 行で表示できます。幅は文書とともに保存され、取り消しとやり直しに対応します。"}]},diff --git a/app/src/assets/scss/protyle/_mindmap-view.scss b/app/src/assets/scss/protyle/_mindmap-view.scssindex fcce7cebf9..8859dc320c 100644--- a/app/src/assets/scss/protyle/_mindmap-view.scss+++ b/app/src/assets/scss/protyle/_mindmap-view.scss@@ -935,6 +935,40 @@.b3-text-field {width: 80px;}++ .b3-slider {+ width: 100px;+ min-width: 48px;+ flex: 1;+ }++ .color__square {+ flex-shrink: 0;+ }+ }++ &__inspector-popover {+ @include protyle-toolbar-surface;+ position: absolute;+ z-index: 7;+ display: flex;+ flex-direction: column;+ max-width: calc(100% - 16px);+ padding: 8px;+ box-sizing: border-box;+ overflow: auto;++ .mindmap-view__palette {+ flex-wrap: wrap;+ overflow: visible;+ max-width: 320px;+ }++ .mindmap-view__node-width {+ min-width: 0;+ flex-shrink: 1;+ flex-wrap: wrap;+ }}}@@ -961,6 +995,7 @@&__route-handle,&__route-status,&__selection-box,+ &__inspector-popover,&__add-bridge,&__fold,&__add-child {diff --git a/app/src/protyle/render/listMindmap/clipboard.test.ts b/app/src/protyle/render/listMindmap/clipboard.test.tsindex 6c3fc207d1..26f6b80fb2 100644--- a/app/src/protyle/render/listMindmap/clipboard.test.ts+++ b/app/src/protyle/render/listMindmap/clipboard.test.ts@@ -196,9 +196,28 @@ const browserCases = async (source: string, css: string) => {};pointer(a.id);await checkNodeMenu();+ const action = (key: string) => host.querySelector<HTMLButtonElement>(`.mindmap-view__inspector > [aria-label="${key}"]`);+ for (const key of ["copy", "cut", "paste"]) {+ check.ok(action(key), `${key} is directly available on the bottom bar`);+ check.equal(action(key).disabled, false);+ action(key).dispatchEvent(new PointerEvent("pointerdown", {bubbles: true, pointerType: "touch", pointerId: 12}));+ check.deepEqual(view.getSelectedIds(), [a.id], "touching a clipboard button keeps the node selection");+ action(key).click();+ }+ check.deepEqual(copied.map(item => item.cut), [false, true]);+ check.deepEqual(pasted, [{id: a.id, kind: "child"}]);+ copied.length = 0;+ pasted.length = 0;pointer(b.id, {ctrlKey: true});await checkNodeMenu();+ check.equal(action("paste").disabled, true, "multiple targets cannot receive a paste");+ view.focusNode(model.root.id);+ check.equal(action("cut").disabled, true, "the map root cannot be cut away");+ check.equal(action("delete").disabled, true, "the map root cannot be deleted");+ pointer(a.id);+ pointer(b.id, {ctrlKey: true});check.deepEqual(new Set(view.getSelectedIds()), new Set([a.id, b.id]));+ host.querySelector<HTMLButtonElement>('.mindmap-view__inspector [aria-label="color"]').click();host.querySelector<HTMLButtonElement>('[aria-label="Batch orange"]').click();check.equal(styleChanges.length, 1, "batch colors use one callback for the complete selection");check.deepEqual(new Set(styleChanges[0].ids), new Set([a.id, b.id]));@@ -374,7 +393,9 @@ test("mind map selection and clipboard preserve branches, metadata, identities a"../../util/blockDOMClipboard.ts", "../../util/clipboardData.ts"].map(compile).join("\n") +ts.transpileModule(`class ClipboardController {${methods.map(method => method.getText(sourceFile)).join("\n")}}`,{compilerOptions: {target: ts.ScriptTarget.ES2021}}).outputText;- const css = require("sass").compile(path.resolve(__dirname, "../../../assets/scss/protyle/_mindmap-view.scss")).css;+ const css = ["business/_block.scss", "business/_color.scss", "component/_svg.scss", "component/_slider.scss",+ "component/_text-field.scss", "protyle/_mindmap-view.scss"].map(file =>+ require("sass").compile(path.resolve(__dirname, "../../../assets/scss", file)).css).join("\n");const dir = mkdtempSync(path.join(tmpdir(), "siyuan-mindmap-clipboard-"));const script = path.join(dir, "run.cjs");const browser = ts.transpileModule(`(${browserCases.toString()})`, {compilerOptions: {target: ts.ScriptTarget.ES2021}})diff --git a/app/src/protyle/render/listMindmap/index.ts b/app/src/protyle/render/listMindmap/index.tsindex f3f224ec43..5b8d7d8711 100644--- a/app/src/protyle/render/listMindmap/index.ts+++ b/app/src/protyle/render/listMindmap/index.ts@@ -487,6 +487,16 @@ class ListMindmapController {metadata.nodes[id] = {...metadata.nodes[id], ...patch};});}),+ onNodeWidths: (widths, expected) => this.metadata(metadata => {+ const nodes = readListMindmap(list).nodes;+ const current = widths.map(({id}) => ({id, width: metadata.nodes[id]?.width || 0}));+ if (JSON.stringify(current) !== expected || widths.some(({id, width}) =>+ !nodes.has(id) || !Number.isFinite(width) || width < 0)) {+ showMessage(window.siyuan.languages.listMindmapStale);+ return false;+ }+ widths.forEach(({id, width}) => metadata.nodes[id] = {...metadata.nodes[id], width});+ }),onRelationAdd: (from, to) => this.metadata(metadata => {if (from !== to && !metadata.relations.some(relation => relation.from === from && relation.to === to)) {metadata.relations.push({id: Lute.NewNodeID(), from, to, label: ""});diff --git a/app/src/protyle/render/listMindmap/model.test.ts b/app/src/protyle/render/listMindmap/model.test.tsindex 375f4f04e9..9c5594806e 100644--- a/app/src/protyle/render/listMindmap/model.test.ts+++ b/app/src/protyle/render/listMindmap/model.test.ts@@ -1230,6 +1230,15 @@ const browserCases = async (sourceCode: string, css: string, taskSource: string,panMenu = pan;},onNodeStyle: (...args: unknown[]) => nodeStyles.push(args),+ onNodeWidths: async (widths: {id: string, width: number}[], expected: string) => {+ check.equal(expected, JSON.stringify(widths.map(({id}) => ({id, width: model.metadata.nodes[id]?.width || 0}))));+ widths.forEach(({id, width}) => {+ nodeStyles.push([id, {width}]);+ model.metadata.nodes[id] = {...model.metadata.nodes[id], width};+ });+ view.update(model);+ return true;+ },onRelationAdd: (...args: unknown[]) => relationAdditions.push(args),onRelationChange: (...args: unknown[]) => relationChanges.push(args),onRelationDelete: (id: string) => relationDeletions.push(id),@@ -2174,9 +2183,13 @@ const browserCases = async (sourceCode: string, css: string, taskSource: string,host.style.width = `${width}px`;view.renderInspector();await settle();- const palette = inspector.querySelector<HTMLElement>(".mindmap-view__palette");- check.ok(palette.scrollWidth > palette.clientWidth, "long palettes scroll independently");- palette.scrollLeft = palette.scrollWidth;+ inspector.querySelector<HTMLButtonElement>('[aria-label="color"]').click();+ const popup = host.querySelector<HTMLElement>(".mindmap-view__inspector-popover");+ const palette = popup.querySelector<HTMLElement>(".mindmap-view__palette");+ check.equal(palette.children.length, 31);+ const popupBounds = popup.getBoundingClientRect();+ check.ok(popupBounds.width <= host.offsetWidth - 16, "long palettes wrap within the canvas");+ check.ok(popupBounds.bottom <= inspector.getBoundingClientRect().top, "node settings open above the bottom bar");const bounds = inspector.getBoundingClientRect();for (const key of ["connect", "listMindmapSummary", "delete"]) {const action = inspector.querySelector<HTMLElement>(`[aria-label="${key}"]`).getBoundingClientRect();@@ -2193,22 +2206,85 @@ const browserCases = async (sourceCode: string, css: string, taskSource: string,getComputedStyle(host).borderTopColor + " 0px 0px 0px 1px");}host.style.removeProperty("--b3-border-color");- check.equal(inspector.querySelectorAll('input[type="number"]').length, 1, "node width is editable");- const widthInput = inspector.querySelector<HTMLInputElement>('input[type="number"]');- widthInput.value = "640";- widthInput.dispatchEvent(new Event("change", {bubbles: true}));+ check.equal(inspector.querySelectorAll('input[type="number"]').length, 0, "the width field is kept out of the main bar");+ inspector.querySelector<HTMLButtonElement>('[aria-label="width"]').click();+ const nodePopup = host.querySelector<HTMLElement>(".mindmap-view__inspector-popover");+ const widthInput = () => nodePopup.querySelector<HTMLInputElement>('input[type="number"]');+ widthInput().value = "640";+ widthInput().dispatchEvent(new Event("change", {bubbles: true}));+ await settle();check.deepEqual(nodeStyles.at(-1), [beta, {width: 640}]);const styleCount = nodeStyles.length;- widthInput.value = "12";- widthInput.dispatchEvent(new Event("change", {bubbles: true}));+ widthInput().value = "12";+ widthInput().dispatchEvent(new Event("change", {bubbles: true}));+ await settle();check.equal(nodeStyles.length, styleCount, "invalid widths do not change metadata");- widthInput.value = "";- widthInput.dispatchEvent(new Event("change", {bubbles: true}));+ widthInput().value = "";+ widthInput().dispatchEvent(new Event("change", {bubbles: true}));+ await settle();check.deepEqual(nodeStyles.at(-1), [beta, {width: 0}], "clearing restores automatic width");- check.equal(inspector.querySelectorAll('input[type="checkbox"]').length, 0);- check.equal(inspector.querySelector('input[type="color"]'), null);- check.equal(inspector.querySelectorAll('[role="group"]').length, 1);- const nodePalette = inspector.querySelector<HTMLElement>('[role="group"][aria-label="color"]');+ const oldAlphaWidth = model.metadata.nodes[alpha]?.width || 0;+ model.metadata.nodes[alpha] = {...model.metadata.nodes[alpha], width: 0};+ model.metadata.nodes[beta] = {...model.metadata.nodes[beta], width: 480};+ view.update(model);+ await settle();+ view.focusNode(alpha);+ view.selectNode(beta, true);+ const mixedWidthSelection = view.getSelectedIds();+ const widthButton = inspector.querySelector<HTMLButtonElement>('[aria-label="width"]');+ await moveMouse(widthButton);+ check.equal(nodePopup.hidden, false, "mouse hover opens node settings");+ const slider = () => nodePopup.querySelector<HTMLInputElement>('input[type="range"]');+ check.equal(slider().value, "0", "the slider starts centered on the current width");+ const beforeWidthDrag = nodeStyles.length;+ slider().value = "50";+ slider().dispatchEvent(new Event("input", {bubbles: true}));+ await settle();+ check.equal(nodeStyles.length, beforeWidthDrag, "drag previews do not write intermediate transactions");+ check.equal(nodeElement(beta).style.width, "960px");+ slider().dispatchEvent(new Event("change", {bubbles: true}));+ await settle();+ check.equal(nodeStyles.length, beforeWidthDrag + 2, "release saves one callback for all selected nodes");+ check.equal(model.metadata.nodes[alpha].width, 960);+ check.equal(model.metadata.nodes[beta].width, 960);+ widthInput().focus();+ widthInput().value = "1000";+ widthInput().dispatchEvent(new Event("input", {bubbles: true}));+ const beforeRestoreWidth = nodeStyles.length;+ await clickMouse(nodePopup.querySelector('[aria-label="listMindmapRestoreWidth"]'));+ check.equal(nodeStyles.length, beforeRestoreWidth + 2, "Restore replaces an unsaved numeric preview without an extra save");+ check.equal(model.metadata.nodes[alpha].width, 0, "restore retains an originally automatic width");+ check.equal(model.metadata.nodes[beta].width, 480, "restore retains each node's individual width");+ await clickMouse(nodePopup.querySelector('[aria-label="default"]'));+ check.equal(model.metadata.nodes[beta].width, 0, "default makes every selected width automatic");+ const beforeCancelWidth = nodeStyles.length;+ slider().value = "50";+ slider().dispatchEvent(new Event("input", {bubbles: true}));+ slider().dispatchEvent(new KeyboardEvent("keydown", {key: "Escape", bubbles: true, cancelable: true}));+ await settle();+ check.equal(nodePopup.hidden, true, "Escape closes the popup");+ check.equal(nodeStyles.length, beforeCancelWidth, "canceling a preview does not save a width");+ check.equal(nodeElement(beta).style.width, "", "canceled previews restore persisted geometry");+ check.deepEqual(view.getSelectedIds(), mixedWidthSelection, "popup keyboard handling preserves node selection");+ const touchWidthButton = inspector.querySelector<HTMLButtonElement>('[aria-label="width"]');+ const touchWidthPoint = centerPoint(touchWidthButton);+ await require("electron").ipcRenderer.invoke("mindmap-view-native-touch", [+ {type: "touchStart", touchPoints: [{id: 1, ...touchWidthPoint}]},+ {type: "touchEnd", touchPoints: []},+ ]);+ await settle();+ check.equal(nodePopup.hidden, false, "a native touch tap opens the width panel");+ check.deepEqual(view.getSelectedIds(), mixedWidthSelection, "touch popup activation preserves the selection");+ host.focus();+ host.dispatchEvent(new KeyboardEvent("keydown", {key: "Escape", bubbles: true, cancelable: true}));+ check.equal(nodePopup.hidden, true, "Escape also closes a hovered panel while canvas focus is retained");+ check.deepEqual(view.getSelectedIds(), mixedWidthSelection);+ model.metadata.nodes[alpha].width = oldAlphaWidth;+ view.update(model);+ view.focusNode(beta);+ inspector.querySelector<HTMLButtonElement>('[aria-label="color"]').click();+ check.equal(inspector.querySelectorAll('[role="group"]').length, 0, "palettes are kept out of the main bar");+ const nodePalette = nodePopup.querySelector<HTMLElement>('[role="group"][aria-label="color"]');const nodeColorButton = nodePalette.querySelector<HTMLButtonElement>('[aria-label="Appearance combined"]');check.equal(nodeColorButton.textContent, "A");check.equal(nodeColorButton.classList.contains("color__square"), true);@@ -2222,11 +2298,11 @@ const browserCases = async (sourceCode: string, css: string, taskSource: string,view.update(model);check.equal(getComputedStyle(nodeElement(beta)).backgroundColor, "rgb(171, 205, 239)");check.equal(getComputedStyle(nodeElement(beta)).color, "rgb(18, 52, 86)");- check.equal(inspector.querySelector('[aria-label="Appearance combined"]').getAttribute("aria-pressed"), "true");+ check.equal(nodePopup.querySelector('[aria-label="Appearance combined"]').getAttribute("aria-pressed"), "true");host.style.setProperty("--b3-font-background1", "#334455");check.equal(getComputedStyle(nodeElement(beta)).backgroundColor, "rgb(51, 68, 85)","node colors follow changes to the appearance palette");- inspector.querySelector<HTMLButtonElement>('[aria-label="color"] [aria-label="default"]').click();+ nodePopup.querySelector<HTMLButtonElement>('[aria-label="color"] [aria-label="default"]').click();check.deepEqual(nodeStyles[nodeStyles.length - 1], [beta, {textColor: "", backgroundColor: ""}]);model.metadata.nodes[beta].backgroundColor = "";model.metadata.nodes[beta].textColor = "";@@ -5217,11 +5293,13 @@ test("list mindmap mutations preserve block data in the real DOM and Lute", {compile(path.join(__dirname, "appearance.ts")) + compile(path.join(__dirname, "model.ts")) +compile(path.join(__dirname, "preferences.ts")) + compile(path.join(__dirname, "fold.ts")) +compile(path.join(__dirname, "routing.ts")) + compile(path.join(__dirname, "pan.ts")) +- compile(path.join(__dirname, "view.ts")) ++ compile(path.join(__dirname, "clipboard.ts")) + compile(path.join(__dirname, "view.ts")) +compile(path.join(__dirname, "legacy.ts")) + compile(path.join(__dirname, "migrate.ts")) +compile(path.join(__dirname, "create.ts")) + compile(path.join(__dirname, "render.ts"));const css = require("sass").compile(path.resolve(__dirname, "../../../assets/scss/business/_block.scss")).css +require("sass").compile(path.resolve(__dirname, "../../../assets/scss/component/_svg.scss")).css ++ require("sass").compile(path.resolve(__dirname, "../../../assets/scss/component/_slider.scss")).css ++ require("sass").compile(path.resolve(__dirname, "../../../assets/scss/component/_text-field.scss")).css +require("sass").compile(path.resolve(__dirname, "../../../assets/scss/component/_button.scss")).css +require("sass").compile(path.resolve(__dirname, "../../../assets/scss/component/_select.scss")).css +require("sass").compile(path.resolve(__dirname, "../../../assets/scss/business/_color.scss")).css +@@ -5351,7 +5429,7 @@ app.whenReady().then(async () => {delete env.ELECTRON_RUN_AS_NODE;try {const executable = require("electron") as unknown as string;- const result = await promisify(execFile)(executable, [script], {env, timeout: 40000, windowsHide: true});+ const result = await promisify(execFile)(executable, [script], {env, timeout: 80000, windowsHide: true});assert.match(result.stdout, /List mindmap DOM cases passed/);} finally {rmSync(temporary, {recursive: true, force: true});diff --git a/app/src/protyle/render/listMindmap/nodeWidths.test.ts b/app/src/protyle/render/listMindmap/nodeWidths.test.tsnew file mode 100644index 0000000000..7260b51801--- /dev/null+++ b/app/src/protyle/render/listMindmap/nodeWidths.test.ts@@ -0,0 +1,66 @@+import * as assert from "node:assert/strict";+import {readFileSync} from "node:fs";+import test from "node:test";+import {runInNewContext} from "node:vm";+import {createSourceFile, isClassDeclaration, isPropertyAssignment, ScriptTarget, transpileModule} from "typescript";++const source = createSourceFile("index.ts", readFileSync("src/protyle/render/listMindmap/index.ts", "utf8"),+ ScriptTarget.ES2021, true);+const controller = source.statements.find(item => isClassDeclaration(item) && item.name?.text === "ListMindmapController");+assert.ok(controller && isClassDeclaration(controller));+let callback = "";+const visit = (node: import("typescript").Node) => {+ if (isPropertyAssignment(node) && node.name.getText(source) === "onNodeWidths") {+ callback = node.initializer.getText(source);+ }+ node.forEachChild(visit);+};+visit(controller);+assert.ok(callback);+const methods = controller.members.filter(item => item.name && ["metadata", "change"].includes(item.name.getText(source)));+const compiled = transpileModule(`class Controller {+ ${methods.map(item => item.getText(source)).join("\n")}+ onNodeWidths = ${callback};+} globalThis.Controller = Controller;`, {compilerOptions: {target: ScriptTarget.ES2021}}).outputText;++test("node width changes and mixed-width restoration save one undoable snapshot without replacing other styles", async () => {+ for (const version of [1, 2]) {+ let metadata: {version: number, nodes: Record<string, {width: number, textColor?: string}>,+ relations: unknown[], extension: string} = {+ version, nodes: {a: {width: 0, textColor: "red"}, b: {width: 480}}, relations: [], extension: "keep",+ };+ const list = {isConnected: true, dataset: {nodeId: "map"}, closest: (): null => null,+ get outerHTML() { return JSON.stringify(metadata); }};+ let editable = true;+ let messages = 0;+ const history: {before: string, after: string}[] = [];+ const context: any = {list, owner: {}, canEdit: () => editable,+ readListMindmap: () => ({root: {id: "root"}, metadata: structuredClone(metadata),+ nodes: new Map([["a", {children: []}], ["b", {children: []}]])}),+ getListMindmapSiblingIDs: () => new Map(),+ normalizeListMindmapSummaryMetadata: () => {}, cleanListMindmapHTML: (value: string) => value,+ writeListMindmapMetadata: (_list: unknown, value: typeof metadata) => metadata = value,+ updateTransaction: (_owner: unknown, _list: unknown, before: string) => history.push({before, after: list.outerHTML}),+ showMessage: () => messages++, window: {siyuan: {languages: {listMindmapStale: "stale"}}}};+ runInNewContext(compiled, context);+ const target = Object.assign(new context.Controller(), {list, owner: {}, view: {getSelectedId: () => "a"}, refresh: () => {}});+ const original = [{id: "a", width: 0}, {id: "b", width: 480}];+ const changed = [{id: "a", width: 320}, {id: "b", width: 320}];+ assert.equal(await target.onNodeWidths(changed, JSON.stringify(original)), true);+ assert.equal(history.length, 1);+ assert.equal(metadata.nodes.a.textColor, "red");+ assert.equal(metadata.extension, "keep");+ assert.equal(await target.onNodeWidths(original, JSON.stringify(changed)), true);+ assert.equal(history.length, 2, "restoring different original widths is one change");+ assert.equal(history[1].after, history[0].before, "restoration retains automatic width and all unrelated metadata");+ assert.equal(await target.onNodeWidths(changed, JSON.stringify(changed)), false, "a stale snapshot cannot overwrite newer widths");+ for (const widths of [[{id: "missing", width: 200}], [{id: "a", width: -1}], [{id: "a", width: NaN}]]) {+ const expected = JSON.stringify(widths.map(({id}) => ({id, width: metadata.nodes[id]?.width || 0})));+ assert.equal(await target.onNodeWidths(widths, expected), false);+ }+ assert.equal(messages, 4);+ editable = false;+ assert.equal(await target.onNodeWidths(changed, JSON.stringify(original)), false);+ assert.equal(history.length, 2);+ }+});diff --git a/app/src/protyle/render/listMindmap/view.ts b/app/src/protyle/render/listMindmap/view.tsindex 046f3a7ea2..c1157d8ab6 100644--- a/app/src/protyle/render/listMindmap/view.ts+++ b/app/src/protyle/render/listMindmap/view.ts@@ -23,6 +23,7 @@ import {getListMindmapSummarySelection, getListMindmapSummarySnapshot,import type {ListMindmapSummary, ListMindmapSummaryPosition, ListMindmapSummaryRange} from "./summary";import {buildListMindmapConnectors, buildListMindmapSummaryConnector} from "./connectors";import {getMindmapLineColor, getMindmapTextColor, isMindmapColor, resolveListMindmapColors} from "./appearance";+import {canCutMindmapBranches} from "./clipboard";export interface ListMindmapViewOptions {host: HTMLElement;@@ -71,6 +72,7 @@ export interface ListMindmapViewOptions {onRedo?: () => void;onNodeStyle?: (id: string, patch: Partial<ListMindmapNodeStyle>) => void;onNodesStyle?: (ids: string[], patch: Partial<ListMindmapNodeStyle>) => void;+ onNodeWidths?: (widths: {id: string, width: number}[], expected: string) => Promise<boolean>;onRelationAdd?: (from: string, to: string) => void;onRelationChange?: (id: string, patch: Partial<ListMindmapRelation>, expected?: string) => void;onRelationDelete?: (id: string) => void;@@ -129,6 +131,12 @@ export class ListMindmapView {private readonly canvas: HTMLCanvasElement;private readonly toolbar: HTMLDivElement;private readonly inspector: HTMLDivElement;+ private readonly inspectorPopover = createElement("div", "mindmap-view__inspector-popover");+ private inspectorPanel?: {+ kind: "color" | "width", ids: string[], anchor: HTMLButtonElement,+ widths: {id: string, width: number}[], baseWidth: number, slider: number, preview: boolean,+ };+ private widthPending = false;private readonly zoomLabel: HTMLSpanElement;private readonly zoomSlider = createElement("input", "b3-slider");private readonly nodeElements = new Map<string, HTMLDivElement>();@@ -219,6 +227,9 @@ export class ListMindmapView {this.inspector = createElement("div", "mindmap-view__inspector");this.inspector.setAttribute("data-prevent-swipe", "true");this.inspector.hidden = true;+ this.inspectorPopover.hidden = true;+ this.inspectorPopover.setAttribute("role", "group");+ this.inspectorPopover.setAttribute("data-prevent-swipe", "true");this.zoomLabel = createElement("span", "mindmap-view__zoom");this.viewport.append(this.canvas, this.world);this.tooltip.hidden = true;@@ -226,7 +237,24 @@ export class ListMindmapView {this.colorProbe.setAttribute("aria-hidden", "true");this.routeStatus.hidden = true;this.routeStatus.setAttribute("role", "status");- options.host.append(this.toolbar, this.viewport, this.inspector, this.tooltip, this.colorProbe, this.routeStatus);+ options.host.append(this.toolbar, this.viewport, this.inspector, this.inspectorPopover,+ this.tooltip, this.colorProbe, this.routeStatus);+ this.listen(this.inspector, "scroll", () => this.closeInspectorPanel());+ this.listen(this.inspectorPopover, "mousedown", (event: MouseEvent) => {+ // 面板按钮保留输入焦点,恢复和默认操作直接替换未提交的宽度预览。+ if ((event.target as Element).closest("button")) {+ event.preventDefault();+ }+ });+ this.listen(this.inspectorPopover, "keydown", (event: KeyboardEvent) => {+ if (event.key === "Escape") {+ const anchor = this.inspectorPanel?.anchor;+ this.closeInspectorPanel();+ anchor?.focus({preventScroll: true});+ event.preventDefault();+ event.stopPropagation();+ }+ });this.selectionBox.hidden = true;this.viewport.append(this.selectionBox);this.createToolbar();@@ -330,6 +358,7 @@ export class ListMindmapView {this.resizeObserver = new ResizeObserver(() => {this.updateToolbarLayout();this.refreshLayout();+ this.positionInspectorPanel();});this.resizeObserver.observe(this.viewport);this.update(this.model);@@ -362,7 +391,7 @@ export class ListMindmapView {private showButtonTooltip = (event: Event) => {const button = (event.target as Element).closest<HTMLButtonElement>("button[aria-label]");if (!button || button.closest(".mindmap-view") !== this.options.host ||- !(this.toolbar.contains(button) || this.inspector.contains(button) ||+ !(this.toolbar.contains(button) || this.inspector.contains(button) || this.inspectorPopover.contains(button) ||button.classList.contains("mindmap-view__add-child") || button.classList.contains("mindmap-view__fold"))) {this.tooltip.hidden = true;return;@@ -407,6 +436,9 @@ export class ListMindmapView {private dismissControls = (event: PointerEvent) => {const target = event.target as Node;this.tooltip.hidden = true;+ if (!this.inspectorPopover.contains(target) && !this.inspectorPanel?.anchor.contains(target)) {+ this.closeInspectorPanel();+ }if (!this.options.host.contains(target)) {this.setInteractionActive(false);}@@ -419,7 +451,7 @@ export class ListMindmapView {if (target instanceof Element && target.closest(".mindmap-view__relation-editor, .mindmap-view__route-handle, .mindmap-view__summary-editor")) {return;}- if (this.inspector.contains(target) || this.buttons.get("style")?.contains(target) ||+ if (this.inspector.contains(target) || this.inspectorPopover.contains(target) || this.buttons.get("style")?.contains(target) ||this.buttons.get("relation")?.contains(target) || this.buttons.get("expandLevel")?.contains(target) ||this.buttons.get("summary")?.contains(target) || this.buttons.get("multiSelect")?.contains(target) ||this.levelSelect?.contains(target)) {@@ -476,6 +508,7 @@ export class ListMindmapView {this.interactionActive = value;this.options.host.classList.toggle("mindmap-view--active", value);if (!value) {+ this.closeInspectorPanel();const selecting = !!this.relationFrom || this.multiSelect;const inspectorVisible = !this.inspector.hidden;this.multiSelect = false;@@ -2036,6 +2069,10 @@ export class ListMindmapView {}private updateSelection() {+ if (this.inspector.hidden || this.readOnly || this.selectedRelation || this.selectedEdge || this.selectedSummary ||+ this.inspectorPanel && JSON.stringify(this.inspectorPanel.ids) !== JSON.stringify(this.getSelectedIds())) {+ this.closeInspectorPanel();+ }if (!this.selectedId) {this.selectedIds.clear();}@@ -3137,6 +3174,14 @@ export class ListMindmapView {};private keyDown = (event: KeyboardEvent) => {+ if (event.key === "Escape" && this.inspectorPanel) {+ const anchor = this.inspectorPanel.anchor;+ this.closeInspectorPanel();+ anchor.focus({preventScroll: true});+ event.preventDefault();+ event.stopPropagation();+ return;+ }if (this.locked) {if (event.key === "Escape" && this.fullscreenMarker) {event.preventDefault();@@ -3334,6 +3379,217 @@ export class ListMindmapView {event.stopPropagation();};+ private closeInspectorPanel() {+ const panel = this.inspectorPanel;+ this.inspectorPanel = undefined;+ this.inspectorPopover.hidden = true;+ panel?.anchor.setAttribute("aria-expanded", "false");+ if (panel?.preview && !this.destroyed) {+ this.previewNodeWidths(this.nodeWidths(panel.ids));+ }+ }++ private nodeWidths(ids: string[]) {+ return ids.map(id => ({id, width: this.model.metadata.nodes[id]?.width || 0}));+ }++ private openInspectorPanel(kind: "color" | "width", anchor: HTMLButtonElement) {+ if (this.readOnly || this.inspector.hidden || anchor.disabled) {+ return;+ }+ if (this.inspectorPanel?.kind !== kind) {+ this.closeInspectorPanel();+ const ids = this.getSelectedIds();+ this.inspectorPanel = {kind, ids, anchor, widths: this.nodeWidths(ids), slider: 0, preview: false,+ baseWidth: Math.max(32, this.positions.get(this.selectedId)?.width || 32)};+ }+ anchor.setAttribute("aria-expanded", "true");+ this.renderInspectorPanel();+ }++ private positionInspectorPanel() {+ if (this.inspectorPopover.hidden || !this.inspectorPanel) {+ return;+ }+ const host = this.options.host.getBoundingClientRect();+ const anchor = this.inspectorPanel.anchor.getBoundingClientRect();+ const scaleX = host.width / this.options.host.offsetWidth || 1;+ const scaleY = host.height / this.options.host.offsetHeight || 1;+ const bottom = (host.bottom - this.inspector.getBoundingClientRect().top) / scaleY + 4;+ const left = (anchor.left + anchor.width / 2 - host.left) / scaleX - this.inspectorPopover.offsetWidth / 2;+ this.inspectorPopover.style.left = `${Math.max(8,+ Math.min(left, this.options.host.offsetWidth - this.inspectorPopover.offsetWidth - 8))}px`;+ this.inspectorPopover.style.bottom = `${bottom}px`;+ this.inspectorPopover.style.maxHeight = `${Math.max(48, this.options.host.offsetHeight - bottom - 8)}px`;+ }++ private previewNodeWidths(widths: {id: string, width: number}[]) {+ widths.forEach(({id, width}) => {+ const element = this.nodeElements.get(id);+ if (element) {+ element.style.width = width ? `${Math.max(32, width)}px` : "";+ element.style.maxWidth = width ? "none" : "";+ }+ });+ this.refreshLayout();+ }++ private async commitInspectorWidths(widths: {id: string, width: number}[]) {+ const panel = this.inspectorPanel;+ if (!panel || this.widthPending || this.readOnly || !this.options.onNodeWidths) {+ return;+ }+ const expected = JSON.stringify(this.nodeWidths(panel.ids));+ const focus = this.inspectorPopover.contains(document.activeElement) ?+ document.activeElement.getAttribute("data-width-control") : undefined;+ this.widthPending = true;+ try {+ await this.options.onNodeWidths(widths, expected);+ } catch (error) {+ console.error(error);+ } finally {+ this.widthPending = false;+ if (!this.destroyed) {+ panel.preview = false;+ this.previewNodeWidths(this.nodeWidths(panel.ids));+ if (this.inspectorPanel === panel) {+ this.renderInspector();+ if (focus) {+ this.inspectorPopover.querySelector<HTMLInputElement>(`[data-width-control="${focus}"]`)?.focus({preventScroll: true});+ }+ }+ }+ }+ }++ private renderInspectorPanel() {+ const panel = this.inspectorPanel;+ if (!panel) {+ return;+ }+ const focus = this.inspectorPopover.contains(document.activeElement) ?+ document.activeElement.getAttribute("data-width-control") : undefined;+ this.inspectorPopover.replaceChildren();+ this.inspectorPopover.hidden = false;+ this.inspectorPopover.setAttribute("aria-label", this.label(panel.kind));+ const current = () => this.inspectorPanel === panel && !this.readOnly && !this.inspector.hidden &&+ JSON.stringify(panel.ids) === JSON.stringify(this.getSelectedIds());+ const button = (key: string, icon: string, action: () => void) => {+ const control = this.makeButton(key, icon, () => { if (current()) { action(); } });+ control.className = "color__square";+ control.querySelector("svg")?.classList.add("svg--mid");+ return control;+ };+ if (panel.kind === "color") {+ const change = (patch: Partial<ListMindmapNodeStyle>) => {+ if (current()) {+ if (panel.ids.length > 1) {+ this.options.onNodesStyle?.(panel.ids, patch);+ } else {+ this.options.onNodeStyle?.(panel.ids[0], patch);+ }+ }+ };+ const palette = createElement("div", "mindmap-view__palette");+ palette.setAttribute("role", "group");+ palette.setAttribute("aria-label", this.label("color"));+ [{label: this.label("default"), color: "", backgroundColor: "", preview: undefined},+ ...(this.options.nodeColors?.() || [])].forEach(item => {+ const selected = panel.ids.every(id => {+ const style = this.model.metadata.nodes[id] || {};+ return (style.textColor || "") === item.color && (style.backgroundColor || "") === item.backgroundColor;+ });+ const control = button("color", "", () => change({textColor: item.color, backgroundColor: item.backgroundColor}));+ control.textContent = "A";+ control.setAttribute("aria-label", item.label);+ control.setAttribute("aria-pressed", String(selected));+ control.classList.toggle("color__square--current", selected);+ control.style.color = item.preview?.color ?? item.color;+ control.style.backgroundColor = item.preview?.backgroundColor ?? item.backgroundColor;+ palette.append(control);+ });+ if (this.options.onManageNodeColors) {+ palette.append(button("manageColors", "iconSettings", this.options.onManageNodeColors));+ }+ this.inspectorPopover.append(palette);+ if (panel.ids.length > 1) {+ const lines = createElement("div", "mindmap-view__palette");+ lines.setAttribute("role", "group");+ lines.setAttribute("aria-label", this.label("listMindmapLineColor"));+ [{label: this.label("default"), value: ""}, ...(this.options.colors?.() || [])].forEach(item => {+ const control = button("color", "", () => change({lineColor: item.value}));+ control.setAttribute("aria-label", item.label);+ control.style.backgroundColor = item.value || "var(--b3-theme-background)";+ lines.append(control);+ });+ if (this.options.onManageLineColors) {+ lines.append(button("manageColors", "iconSettings", this.options.onManageLineColors));+ }+ this.inspectorPopover.append(lines);+ }+ } else {+ const row = createElement("div", "mindmap-view__node-width");+ const slider = createElement("input", "b3-slider");+ slider.type = "range";+ slider.min = "-100";+ slider.max = "100";+ slider.step = "1";+ slider.value = String(panel.slider);+ slider.setAttribute("aria-label", this.label("width"));+ slider.dataset.widthControl = "slider";+ const width = createElement("input", "b3-text-field");+ width.type = "number";+ width.min = "32";+ width.step = "1";+ width.placeholder = this.label("default");+ width.setAttribute("aria-label", this.label("width"));+ width.dataset.widthControl = "number";+ const widths = this.nodeWidths(panel.ids);+ width.value = widths[0].width && widths.every(item => item.width === widths[0].width) ? String(widths[0].width) : "";+ const preview = () => {+ if (current() && !this.widthPending && width.validity.valid) {+ panel.preview = true;+ this.previewNodeWidths(panel.ids.map(id => ({id, width: width.valueAsNumber || 0})));+ }+ };+ slider.addEventListener("input", () => {+ panel.slider = slider.valueAsNumber;+ width.value = String(Math.max(32, Math.round(panel.baseWidth * Math.pow(2, panel.slider / 50))));+ preview();+ });+ width.addEventListener("input", () => {+ if (width.valueAsNumber >= 32) {+ panel.slider = Math.max(-100, Math.min(100, 50 * Math.log2(width.valueAsNumber / panel.baseWidth)));+ slider.value = String(panel.slider);+ }+ preview();+ });+ const save = () => {+ if (current() && width.validity.valid) {+ this.finishThen(() => void this.commitInspectorWidths(panel.ids.map(id => ({id, width: width.valueAsNumber || 0}))));+ }+ };+ slider.addEventListener("change", save);+ width.addEventListener("change", save);+ const restore = button("listMindmapRestoreWidth", "iconRefresh", () => {+ panel.slider = 0;+ void this.commitInspectorWidths(panel.widths);+ });+ const automatic = button("default", "iconFocus", () => {+ panel.slider = 0;+ void this.commitInspectorWidths(panel.ids.map(id => ({id, width: 0})));+ });+ [slider, width, restore, automatic].forEach(control => control.disabled = this.widthPending);+ row.append(slider, width, restore, automatic);+ this.inspectorPopover.append(row);+ if (focus) {+ this.inspectorPopover.querySelector<HTMLInputElement>(`[data-width-control="${focus}"]`)?.focus({preventScroll: true});+ }+ }+ this.positionInspectorPanel();+ requestAnimationFrame(() => this.positionInspectorPanel());+ }+private renderInspector() {if (this.inspector.hidden || this.readOnly) {return;@@ -3421,6 +3677,7 @@ export class ListMindmapView {const id = this.selectedId;const ids = this.getSelectedIds();const multiple = ids.length > 1;+ const sameSelection = () => !this.readOnly && JSON.stringify(ids) === JSON.stringify(this.getSelectedIds());const appendMore = () => {if (this.options.onClipboardMenu) {const more = squareButton("more", "iconMore", () => this.options.onClipboardMenu(more, ids));@@ -3432,61 +3689,48 @@ export class ListMindmapView {const remove = squareButton("delete", "iconTrashcan", () => this.deleteSelection());remove.disabled = ids.includes(this.model.root.id) ||this.model.root.virtual && this.model.root.children.every(node => ids.includes(node.id));- this.inspector.append(this.buttons.get("relation"), this.buttons.get("summary"), remove);- const change = (patch: Partial<ListMindmapNodeStyle>) => multiple ? this.options.onNodesStyle?.(ids, patch) :- this.options.onNodeStyle?.(id, patch);- const nodePalette = createElement("div", "mindmap-view__palette");- nodePalette.setAttribute("role", "group");- nodePalette.setAttribute("aria-label", this.label("color"));- const nodeColors: ReturnType<NonNullable<ListMindmapViewOptions["nodeColors"]>> = [- {label: this.label("default"), color: "", backgroundColor: ""}, ...(this.options.nodeColors?.() || []),- ];- nodeColors.forEach(item => {- const button = this.makeButton("color", "iconFont", () => change({- textColor: item.color, backgroundColor: item.backgroundColor,- }));- const selected = ids.every(nodeID => {- const nodeStyle = this.model.metadata.nodes[nodeID] || {};- return (nodeStyle.textColor || "") === item.color && (nodeStyle.backgroundColor || "") === item.backgroundColor;+ this.inspector.append(remove);+ if (this.options.onCopy) {+ const copy = squareButton("copy", "iconCopy", () => {+ if (sameSelection()) {+ this.options.onCopy(ids, false);+ }});- button.className = "color__square" + (selected ? " color__square--current" : "");- button.textContent = "A";- button.setAttribute("aria-label", item.label);- button.setAttribute("aria-pressed", String(selected));- button.style.color = item.preview?.color ?? item.color;- button.style.backgroundColor = item.preview?.backgroundColor ?? item.backgroundColor;- nodePalette.append(button);- });- if (this.options.onManageNodeColors) {- const manage = squareButton("manageColors", "iconSettings", this.options.onManageNodeColors);- nodePalette.append(manage);- }- this.inspector.append(nodePalette);- const widthLabel = createElement("label", "mindmap-view__node-width");- widthLabel.append(this.label("width"));- const width = createElement("input", "b3-text-field");- width.type = "number";- width.min = "32";- width.step = "1";- width.placeholder = this.label("default");- width.setAttribute("aria-label", this.label("width"));- const selectedWidth = this.model.metadata.nodes[id]?.width || 0;- width.value = ids.every(nodeID => (this.model.metadata.nodes[nodeID]?.width || 0) === selectedWidth) &&- selectedWidth ? String(selectedWidth) : "";- width.addEventListener("change", () => {- if (!width.validity.valid) {- return;- }- if (width.value === "") {- change({width: 0});- } else if (Number.isFinite(width.valueAsNumber)) {- change({width: width.valueAsNumber});+ const cut = squareButton("cut", "iconCut", () => {+ if (sameSelection() && canCutMindmapBranches(this.model, ids)) {+ this.options.onCopy(ids, true);+ }+ });+ cut.disabled = !canCutMindmapBranches(this.model, ids);+ this.inspector.append(copy, cut);+ }+ if (this.options.onPaste) {+ const paste = squareButton("paste", "iconPaste", () => {+ if (sameSelection() && ids.length === 1) {+ this.options.onPaste(id, "child");+ }+ });+ paste.disabled = multiple;+ paste.dataset.tooltip = this.label("mindmapPasteChild");+ this.inspector.append(paste);+ }+ this.inspector.append(this.buttons.get("relation"), this.buttons.get("summary"));+ for (const [kind, key, icon] of [["color", "color", "iconFont"], ["width", "width", "iconWidth"]] as const) {+ const button = squareButton(key, icon, () => this.openInspectorPanel(kind, button));+ button.setAttribute("aria-expanded", String(this.inspectorPanel?.kind === kind));+ button.disabled = kind === "width" && (!this.options.onNodeWidths || this.widthPending);+ button.addEventListener("pointerenter", event => {+ if (event.pointerType === "mouse" && !button.disabled) {+ this.openInspectorPanel(kind, button);+ }+ });+ this.inspector.append(button);+ if (this.inspectorPanel?.kind === kind) {+ this.inspectorPanel.anchor = button;+ this.renderInspectorPanel();}- });- widthLabel.append(width);- this.inspector.append(widthLabel);+ }if (multiple) {- color(undefined, value => change({lineColor: value}), "listMindmapLineColor");appendMore();return;}diff --git a/app/src/protyle/render/listMindmap/viewportFocus.test.ts b/app/src/protyle/render/listMindmap/viewportFocus.test.tsindex 2915c9e6ee..34857b9563 100644--- a/app/src/protyle/render/listMindmap/viewportFocus.test.ts+++ b/app/src/protyle/render/listMindmap/viewportFocus.test.ts@@ -8,7 +8,7 @@ const source = createSourceFile("view.ts", readFileSync("src/protyle/render/listScriptTarget.ES2021, true);const view = source.statements.find(item => isClassDeclaration(item) && item.name?.text === "ListMindmapView");assert.ok(view && isClassDeclaration(view));-const names = ["focusNode", "getToolbarBounds", "revealNode", "isTemporaryPan", "activatePointer", "isPanTarget", "dismissControls", "pointerDown", "preparePointer", "beginPointer", "pointerUp"];+const names = ["focusNode", "getToolbarBounds", "revealNode", "isTemporaryPan", "activatePointer", "isPanTarget", "dismissControls", "closeInspectorPanel", "pointerDown", "preparePointer", "beginPointer", "pointerUp"];const methods = view.members.filter(item => item.name && names.includes(item.name.getText(source)));assert.equal(methods.length, names.length);const compiled = transpileModule(`class View { ${methods.map(item => item.getText(source)).join("\n")} }@@ -26,6 +26,7 @@ const setup = () => {const target = Object.assign(new context.View(), {options: {host}, editingId: "new", model: {nodes: new Map([["new", {}]])},selectedId: "new", tooltip: {}, inspector: {hidden: true},+ inspectorPopover: {hidden: true, contains: () => false},toolbar: {hidden: false, querySelectorAll: (): unknown[] => []},world: {querySelectorAll: (): HTMLElement[] => []},nodeElements: new Map(), summaryElements: new Map(), offsetX: 0, offsetY: 0,