Skip to content

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

:bug: Correct mind map block menus and list conversions https://github.com/siyuan-note/siyuan/issues/18831

Vanessacf2a2bf6e4b8
diff --git a/app/appearance/langs/ar.json b/app/appearance/langs/ar.json
index 06a70ef333..25883fa22d 100644
--- a/app/appearance/langs/ar.json
+++ b/app/appearance/langs/ar.json
@@ -50,8 +50,6 @@
"openLeftSidebar": "فتح الشريط الجانبي الأيسر",
"openRightSidebar": "فتح الشريط الجانبي الأيمن",
"listMindmapPlaceholder": "أدخل نصًا",
- "listMindmapToMindmap": "التبديل إلى عرض الخريطة الذهنية",
- "listMindmapToList": "التبديل إلى عرض القائمة",
"listMindmapRoot": "القائمة الحالية",
"listMindmapChild": "إضافة عقدة فرعية",
"listMindmapFit": "ملاءمة لوحة الرسم",
diff --git a/app/appearance/langs/de.json b/app/appearance/langs/de.json
index 8d084f5be2..57df59515d 100644
--- a/app/appearance/langs/de.json
+++ b/app/appearance/langs/de.json
@@ -50,8 +50,6 @@
"openLeftSidebar": "Linke Seitenleiste öffnen",
"openRightSidebar": "Rechte Seitenleiste öffnen",
"listMindmapPlaceholder": "Text eingeben",
- "listMindmapToMindmap": "Zur Mindmap-Ansicht wechseln",
- "listMindmapToList": "Zur Listenansicht wechseln",
"listMindmapRoot": "Aktuelle Liste",
"listMindmapChild": "Untergeordneten Knoten hinzufügen",
"listMindmapFit": "An Zeichenfläche anpassen",
diff --git a/app/appearance/langs/en.json b/app/appearance/langs/en.json
index ab9e5b3f7f..5d9275dc67 100644
--- a/app/appearance/langs/en.json
+++ b/app/appearance/langs/en.json
@@ -50,8 +50,6 @@
"openLeftSidebar": "Open left sidebar",
"openRightSidebar": "Open right sidebar",
"listMindmapPlaceholder": "Enter text",
- "listMindmapToMindmap": "Switch to mind map view",
- "listMindmapToList": "Switch to list view",
"listMindmapRoot": "Current list",
"listMindmapChild": "Add child node",
"listMindmapFit": "Fit to canvas",
diff --git a/app/appearance/langs/es.json b/app/appearance/langs/es.json
index 6c4b13c79d..a230c51cfa 100644
--- a/app/appearance/langs/es.json
+++ b/app/appearance/langs/es.json
@@ -50,8 +50,6 @@
"openLeftSidebar": "Abrir panel lateral izquierdo",
"openRightSidebar": "Abrir panel lateral derecho",
"listMindmapPlaceholder": "Introducir texto",
- "listMindmapToMindmap": "Cambiar a vista de mapa mental",
- "listMindmapToList": "Cambiar a vista de lista",
"listMindmapRoot": "Lista actual",
"listMindmapChild": "Añadir nodo hijo",
"listMindmapFit": "Ajustar al lienzo",
diff --git a/app/appearance/langs/fr.json b/app/appearance/langs/fr.json
index 26fcd2e3b6..78d1247a4b 100644
--- a/app/appearance/langs/fr.json
+++ b/app/appearance/langs/fr.json
@@ -50,8 +50,6 @@
"openLeftSidebar": "Ouvrir le panneau latéral gauche",
"openRightSidebar": "Ouvrir le panneau latéral droit",
"listMindmapPlaceholder": "Saisir du texte",
- "listMindmapToMindmap": "Passer à la vue carte mentale",
- "listMindmapToList": "Passer à la vue liste",
"listMindmapRoot": "Liste actuelle",
"listMindmapChild": "Ajouter un nœud enfant",
"listMindmapFit": "Ajuster au canevas",
diff --git a/app/appearance/langs/he.json b/app/appearance/langs/he.json
index 6b3141936d..a8ed26f532 100644
--- a/app/appearance/langs/he.json
+++ b/app/appearance/langs/he.json
@@ -50,8 +50,6 @@
"openLeftSidebar": "פתיחת סרגל הצד השמאלי",
"openRightSidebar": "פתיחת סרגל הצד הימני",
"listMindmapPlaceholder": "הזן טקסט",
- "listMindmapToMindmap": "מעבר לתצוגת מפת חשיבה",
- "listMindmapToList": "מעבר לתצוגת רשימה",
"listMindmapRoot": "הרשימה הנוכחית",
"listMindmapChild": "הוספת צומת בן",
"listMindmapFit": "התאמה למשטח הציור",
diff --git a/app/appearance/langs/hi.json b/app/appearance/langs/hi.json
index abb737d93e..6481f7d95b 100644
--- a/app/appearance/langs/hi.json
+++ b/app/appearance/langs/hi.json
@@ -50,8 +50,6 @@
"openLeftSidebar": "बायाँ साइडबार खोलें",
"openRightSidebar": "दायाँ साइडबार खोलें",
"listMindmapPlaceholder": "पाठ दर्ज करें",
- "listMindmapToMindmap": "माइंड मैप दृश्य पर जाएँ",
- "listMindmapToList": "सूची दृश्य पर जाएँ",
"listMindmapRoot": "वर्तमान सूची",
"listMindmapChild": "उप-नोड जोड़ें",
"listMindmapFit": "कैनवास में समायोजित करें",
diff --git a/app/appearance/langs/id.json b/app/appearance/langs/id.json
index 4b3c2bd276..f8a23f3f6e 100644
--- a/app/appearance/langs/id.json
+++ b/app/appearance/langs/id.json
@@ -50,8 +50,6 @@
"openLeftSidebar": "Buka bilah samping kiri",
"openRightSidebar": "Buka bilah samping kanan",
"listMindmapPlaceholder": "Masukkan teks",
- "listMindmapToMindmap": "Beralih ke tampilan peta pikiran",
- "listMindmapToList": "Beralih ke tampilan daftar",
"listMindmapRoot": "Daftar saat ini",
"listMindmapChild": "Tambah simpul anak",
"listMindmapFit": "Sesuaikan dengan kanvas",
diff --git a/app/appearance/langs/it.json b/app/appearance/langs/it.json
index dbab29f541..acd8f349a5 100644
--- a/app/appearance/langs/it.json
+++ b/app/appearance/langs/it.json
@@ -50,8 +50,6 @@
"openLeftSidebar": "Apri la barra laterale sinistra",
"openRightSidebar": "Apri la barra laterale destra",
"listMindmapPlaceholder": "Inserisci testo",
- "listMindmapToMindmap": "Passa alla vista mappa mentale",
- "listMindmapToList": "Passa alla vista elenco",
"listMindmapRoot": "Elenco attuale",
"listMindmapChild": "Aggiungi nodo figlio",
"listMindmapFit": "Adatta all’area di disegno",
diff --git a/app/appearance/langs/ja.json b/app/appearance/langs/ja.json
index 4cb0436bb4..905b7821e9 100644
--- a/app/appearance/langs/ja.json
+++ b/app/appearance/langs/ja.json
@@ -50,8 +50,6 @@
"openLeftSidebar": "左サイドバーを開く",
"openRightSidebar": "右サイドバーを開く",
"listMindmapPlaceholder": "テキストを入力",
- "listMindmapToMindmap": "マインドマップ表示に切り替え",
- "listMindmapToList": "リスト表示に切り替え",
"listMindmapRoot": "現在のリスト",
"listMindmapChild": "子ノードを追加",
"listMindmapFit": "キャンバスに合わせる",
diff --git a/app/appearance/langs/ko.json b/app/appearance/langs/ko.json
index fd66b95eeb..787c05436e 100644
--- a/app/appearance/langs/ko.json
+++ b/app/appearance/langs/ko.json
@@ -50,8 +50,6 @@
"openLeftSidebar": "왼쪽 사이드바 열기",
"openRightSidebar": "오른쪽 사이드바 열기",
"listMindmapPlaceholder": "텍스트 입력",
- "listMindmapToMindmap": "마인드맵 보기로 전환",
- "listMindmapToList": "목록 보기로 전환",
"listMindmapRoot": "현재 목록",
"listMindmapChild": "하위 노드 추가",
"listMindmapFit": "캔버스에 맞추기",
diff --git a/app/appearance/langs/nl.json b/app/appearance/langs/nl.json
index 9ad2089a45..9d71bb5c46 100644
--- a/app/appearance/langs/nl.json
+++ b/app/appearance/langs/nl.json
@@ -50,8 +50,6 @@
"openLeftSidebar": "Linkerzijbalk openen",
"openRightSidebar": "Rechterzijbalk openen",
"listMindmapPlaceholder": "Voer tekst in",
- "listMindmapToMindmap": "Naar mindmapweergave schakelen",
- "listMindmapToList": "Naar lijstweergave schakelen",
"listMindmapRoot": "Huidige lijst",
"listMindmapChild": "Onderliggende knoop toevoegen",
"listMindmapFit": "Aan canvas aanpassen",
diff --git a/app/appearance/langs/pl.json b/app/appearance/langs/pl.json
index 86814a0fc9..572673f5c6 100644
--- a/app/appearance/langs/pl.json
+++ b/app/appearance/langs/pl.json
@@ -50,8 +50,6 @@
"openLeftSidebar": "Otwórz lewy panel boczny",
"openRightSidebar": "Otwórz prawy panel boczny",
"listMindmapPlaceholder": "Wpisz tekst",
- "listMindmapToMindmap": "Przełącz na widok mapy myśli",
- "listMindmapToList": "Przełącz na widok listy",
"listMindmapRoot": "Bieżąca lista",
"listMindmapChild": "Dodaj węzeł podrzędny",
"listMindmapFit": "Dopasuj do płótna",
diff --git a/app/appearance/langs/pt-BR.json b/app/appearance/langs/pt-BR.json
index be48a72ea3..2e7e466a9f 100644
--- a/app/appearance/langs/pt-BR.json
+++ b/app/appearance/langs/pt-BR.json
@@ -50,8 +50,6 @@
"openLeftSidebar": "Abrir barra lateral esquerda",
"openRightSidebar": "Abrir barra lateral direita",
"listMindmapPlaceholder": "Digite o texto",
- "listMindmapToMindmap": "Alternar para a visualização de mapa mental",
- "listMindmapToList": "Alternar para a visualização de lista",
"listMindmapRoot": "Lista atual",
"listMindmapChild": "Adicionar nó filho",
"listMindmapFit": "Ajustar à área de desenho",
diff --git a/app/appearance/langs/ru.json b/app/appearance/langs/ru.json
index d4b6830a28..77d63eb99a 100644
--- a/app/appearance/langs/ru.json
+++ b/app/appearance/langs/ru.json
@@ -50,8 +50,6 @@
"openLeftSidebar": "Открыть левую боковую панель",
"openRightSidebar": "Открыть правую боковую панель",
"listMindmapPlaceholder": "Введите текст",
- "listMindmapToMindmap": "Переключить на интеллект-карту",
- "listMindmapToList": "Переключить на список",
"listMindmapRoot": "Текущий список",
"listMindmapChild": "Добавить дочерний узел",
"listMindmapFit": "Вписать в холст",
diff --git a/app/appearance/langs/sk.json b/app/appearance/langs/sk.json
index 424e320938..d837322285 100644
--- a/app/appearance/langs/sk.json
+++ b/app/appearance/langs/sk.json
@@ -50,8 +50,6 @@
"openLeftSidebar": "Otvoriť ľavý bočný panel",
"openRightSidebar": "Otvoriť pravý bočný panel",
"listMindmapPlaceholder": "Zadajte text",
- "listMindmapToMindmap": "Prepnúť na zobrazenie myšlienkovej mapy",
- "listMindmapToList": "Prepnúť na zobrazenie zoznamu",
"listMindmapRoot": "Aktuálny zoznam",
"listMindmapChild": "Pridať podradený uzol",
"listMindmapFit": "Prispôsobiť plátnu",
diff --git a/app/appearance/langs/sr.json b/app/appearance/langs/sr.json
index cb03f741c6..e75450cfca 100644
--- a/app/appearance/langs/sr.json
+++ b/app/appearance/langs/sr.json
@@ -50,8 +50,6 @@
"openLeftSidebar": "Отвори леву бочну траку",
"openRightSidebar": "Отвори десну бочну траку",
"listMindmapPlaceholder": "Унесите текст",
- "listMindmapToMindmap": "Пређи на приказ мапе ума",
- "listMindmapToList": "Пређи на приказ листе",
"listMindmapRoot": "Тренутна листа",
"listMindmapChild": "Додај подређени чвор",
"listMindmapFit": "Уклопи у платно",
diff --git a/app/appearance/langs/th.json b/app/appearance/langs/th.json
index 88b6d1f912..4f06e32f67 100644
--- a/app/appearance/langs/th.json
+++ b/app/appearance/langs/th.json
@@ -50,8 +50,6 @@
"openLeftSidebar": "เปิดแถบด้านซ้าย",
"openRightSidebar": "เปิดแถบด้านขวา",
"listMindmapPlaceholder": "ป้อนข้อความ",
- "listMindmapToMindmap": "เปลี่ยนเป็นมุมมองแผนผังความคิด",
- "listMindmapToList": "เปลี่ยนเป็นมุมมองรายการ",
"listMindmapRoot": "รายการปัจจุบัน",
"listMindmapChild": "เพิ่มโหนดลูก",
"listMindmapFit": "ปรับให้พอดีกับพื้นที่วาด",
diff --git a/app/appearance/langs/tr.json b/app/appearance/langs/tr.json
index 26938dbf8f..f7a225cc99 100644
--- a/app/appearance/langs/tr.json
+++ b/app/appearance/langs/tr.json
@@ -50,8 +50,6 @@
"openLeftSidebar": "Sol kenar çubuğunu aç",
"openRightSidebar": "Sağ kenar çubuğunu aç",
"listMindmapPlaceholder": "Metin girin",
- "listMindmapToMindmap": "Zihin haritası görünümüne geç",
- "listMindmapToList": "Liste görünümüne geç",
"listMindmapRoot": "Geçerli liste",
"listMindmapChild": "Alt düğüm ekle",
"listMindmapFit": "Tuvale sığdır",
diff --git a/app/appearance/langs/uk.json b/app/appearance/langs/uk.json
index 53b21d33b8..df5582dfd0 100644
--- a/app/appearance/langs/uk.json
+++ b/app/appearance/langs/uk.json
@@ -50,8 +50,6 @@
"openLeftSidebar": "Відкрити ліву бічну панель",
"openRightSidebar": "Відкрити праву бічну панель",
"listMindmapPlaceholder": "Введіть текст",
- "listMindmapToMindmap": "Перемкнути на мапу думок",
- "listMindmapToList": "Перемкнути на список",
"listMindmapRoot": "Поточний список",
"listMindmapChild": "Додати дочірній вузол",
"listMindmapFit": "Вписати в полотно",
diff --git a/app/appearance/langs/zh-CN.json b/app/appearance/langs/zh-CN.json
index 421e0848f0..fdf83236e2 100644
--- a/app/appearance/langs/zh-CN.json
+++ b/app/appearance/langs/zh-CN.json
@@ -50,8 +50,6 @@
"openLeftSidebar": "打开左侧栏",
"openRightSidebar": "打开右侧栏",
"listMindmapPlaceholder": "输入文字",
- "listMindmapToMindmap": "切换为思维导图视图",
- "listMindmapToList": "切换为列表视图",
"listMindmapRoot": "当前列表",
"listMindmapChild": "添加子节点",
"listMindmapFit": "适应画布",
diff --git a/app/appearance/langs/zh-TW.json b/app/appearance/langs/zh-TW.json
index 35f9d5be39..7955037c7e 100644
--- a/app/appearance/langs/zh-TW.json
+++ b/app/appearance/langs/zh-TW.json
@@ -50,8 +50,6 @@
"openLeftSidebar": "開啟左側欄",
"openRightSidebar": "開啟右側欄",
"listMindmapPlaceholder": "輸入文字",
- "listMindmapToMindmap": "切換為心智圖檢視",
- "listMindmapToList": "切換為清單檢視",
"listMindmapRoot": "目前清單",
"listMindmapChild": "新增子節點",
"listMindmapFit": "符合畫布大小",
diff --git a/app/src/config/entryVisibility/catalog.test.ts b/app/src/config/entryVisibility/catalog.test.ts
index 812923f438..c74b8fe211 100644
--- a/app/src/config/entryVisibility/catalog.test.ts
+++ b/app/src/config/entryVisibility/catalog.test.ts
@@ -672,7 +672,7 @@ test("heading conversions follow list conversions across block menu scopes", ()
["gutter.single.turnInto", "gutter.multi.turnInto"].forEach((path) => {
const keys = getEntryCatalogChildren(path).map(item => item.key);
const headingIndex = keys.indexOf("heading1");
- assert.equal(headingIndex, keys.indexOf("check") + 1);
+ assert.equal(headingIndex, keys.indexOf(path === "gutter.single.turnInto" ? "listMindmap" : "check") + 1);
assert.deepEqual(keys.slice(headingIndex, headingIndex + headingKeys.length), headingKeys);
});
});
@@ -756,11 +756,11 @@ test("list block submenu follows the base block entries", () => {
"separator_numbering",
"prependListItem",
"appendListItem",
- "listMindmap",
]);
- assert.equal(getEntryCatalogNode("gutter.single.listBlock.listMindmap")?.simple, true);
- assert.equal(getEntryCatalogNode("gutter.single.listBlock.listMindmap")?.type, "entry");
- assert.equal(getEntryParentPath("gutter.single.listBlock.listMindmap"), "gutter.single.listBlock");
+ assert.equal(getEntryCatalogNode("gutter.single.listBlock.listMindmap"), undefined);
+ assert.equal(getEntryCatalogNode("gutter.single.turnInto.listMindmap")?.simple, true);
+ assert.equal(getEntryCatalogNode("gutter.single.turnInto.listMindmap")?.type, "entry");
+ assert.equal(getEntryParentPath("gutter.single.turnInto.listMindmap"), "gutter.single.turnInto");
assert.equal(getEntryCatalogNode("gutter.multi.listBlock.listMindmap"), undefined);
assert.equal(getEntryCatalogNode("gutter.single.listBlock.customTaskStatus")?.simple, true);
assert.equal(getEntryCatalogNode("gutter.single.listBlock.customTaskStatus")?.type, "entry");
@@ -768,7 +768,7 @@ test("list block submenu follows the base block entries", () => {
assert.equal(getEntryCatalogNode("gutter.single.listBlock.separator_taskStatus")?.type, "separator");
const source = readFileSync(resolve(process.cwd(), "src/protyle/gutter/index.ts"), "utf8");
const submenu = source.slice(source.indexOf("const genListBlockSubmenu"), source.indexOf("return submenu;", source.indexOf("const genListBlockSubmenu")));
- assert.match(submenu, /if \(type === "NodeList"\) \{\s+submenu\.push\(\{\s+id: "listMindmap"/);
+ assert.doesNotMatch(submenu, /id: "listMindmap"/);
const taskSource = readFileSync(resolve(process.cwd(), "src/protyle/wysiwyg/taskStatusDialog.ts"), "utf8");
assert.deepEqual([...Array.from(taskSource.matchAll(/id: "([^"]+)"/g), match => match[1]),
...Array.from(submenu.matchAll(/id: "([^"]+)"/g), match => match[1])],
diff --git a/app/src/config/entryVisibility/catalog.ts b/app/src/config/entryVisibility/catalog.ts
index ac2608daf7..894edb1d43 100644
--- a/app/src/config/entryVisibility/catalog.ts
+++ b/app/src/config/entryVisibility/catalog.ts
@@ -225,6 +225,7 @@ const gutterTurnInto = (multi: boolean) => node("turnInto", lang("turnInto"), tr
node("list", lang("list")),
node("orderedList", lang("ordered-list")),
node("check", lang("check")),
+ ...(!multi ? [node("listMindmap", lang("mindmap"))] : []),
node("heading1", lang("heading1")),
node("heading2", lang("heading2")),
node("heading3", lang("heading3")),
@@ -381,7 +382,6 @@ const gutterSingle = () => [
separator("separator_numbering"),
node("prependListItem", lang("prependListItem")),
node("appendListItem", lang("appendListItem")),
- node("listMindmap", lang("listMindmapToMindmap")),
]),
separator("separator_tabs"),
node("tabs", lang("tabs"), true, [
diff --git a/app/src/config/entryVisibility/order.test.ts b/app/src/config/entryVisibility/order.test.ts
index 99659922b8..18782ac367 100644
--- a/app/src/config/entryVisibility/order.test.ts
+++ b/app/src/config/entryVisibility/order.test.ts
@@ -70,8 +70,8 @@ test("custom task status merges into saved list menus without moving existing en
merged, new Set(["separator_numbering"])), ["appendListItem", "plugin:example:item", "customTaskStatus", "prependListItem"]);
});
-test("list mind map view merges into saved list menus and preserves plugin slots", () => {
- const entries = getEntryCatalogChildren("gutter.single.listBlock");
+test("list mind map view merges into conversion menus and preserves plugin slots", () => {
+ const entries = getEntryCatalogChildren("gutter.single.turnInto");
const defaults = entries.map(item => item.key);
const saved = defaults.filter(key => key !== "listMindmap");
saved.splice(1, 0, "plugin:example:item");
@@ -79,10 +79,10 @@ test("list mind map view merges into saved list menus and preserves plugin slots
const separators = new Set(entries.filter(item => item.type === "separator").map(item => item.key));
assert.deepEqual(merged.filter(key => key !== "listMindmap"), saved);
assert.equal(merged[1], "plugin:example:item");
- assert.equal(merged[merged.indexOf("appendListItem") + 1], "listMindmap");
+ assert.equal(merged[merged.indexOf("check") + 1], "listMindmap");
assert.deepEqual(resolveEntryOrder([...defaults, "plugin:example:item"], merged, separators), merged);
- assert.deepEqual(resolveEntryOrder(["prependListItem", "appendListItem", "listMindmap"], merged, separators),
- ["prependListItem", "appendListItem", "listMindmap"]);
+ assert.deepEqual(resolveEntryOrder(["list", "check", "listMindmap"], merged, separators),
+ ["list", "check", "listMindmap"]);
});
test("definition conversion submenus preserve custom order and plugin slots", () => {
diff --git a/app/src/config/entryVisibility/profile.test.ts b/app/src/config/entryVisibility/profile.test.ts
index 3f913d3b98..fba0b3b3dc 100644
--- a/app/src/config/entryVisibility/profile.test.ts
+++ b/app/src/config/entryVisibility/profile.test.ts
@@ -5,12 +5,29 @@ import {resolve} from "node:path";
import {getEntryCatalogCustomDefaultVisibility, getEntryCatalogDefaultVisibility, getEntryCatalogNode} from "./catalog";
import {TOOLBAR_ENTRY_ROOT_PATH} from "../../protyle/toolbar/defaults";
import {
+ migrateMindmapMenu,
getBuiltinProfileEntryVisibility,
getProfileEntryVisibility,
isEntryVisibilityImportVersionSupported,
normalizeEntryVisibilityImportProfile,
} from "./profile";
+test("mind map menu migration preserves visibility and plugin order", () => {
+ const profile = {
+ entries: {"gutter.single.listBlock.listMindmap": false},
+ orders: {"gutter.single.listBlock": ["prependListItem", "listMindmap", "plugin:test", "appendListItem"],
+ "gutter.single.turnInto": ["check", "plugin:convert", "list"]},
+ };
+ migrateMindmapMenu(profile);
+ const expected = {entries: {"gutter.single.turnInto.listMindmap": false}, orders: {
+ "gutter.single.listBlock": ["prependListItem", "plugin:test", "appendListItem"],
+ "gutter.single.turnInto": ["check", "plugin:convert", "list"],
+ }};
+ assert.deepEqual(profile, expected);
+ migrateMindmapMenu(profile);
+ assert.deepEqual(profile, expected);
+});
+
test("task state imports match kernel migrations and remain stable on reimport", () => {
const fixtures = JSON.parse(readFileSync(resolve(process.cwd(), "../kernel/conf/testdata/task_status_menu.json"), "utf8"));
for (const fixture of fixtures) {
@@ -111,11 +128,11 @@ test("custom entry visibility uses a caller-provided default only when the entry
assert.equal(getProfileEntryVisibility(profile, "hidden", true), false);
});
-test("entry visibility import supports versions 1 through 6", () => {
- for (const version of [1, 2, 3, 4, 5, 6]) {
- assert.equal(isEntryVisibilityImportVersionSupported(version, 6), true);
+test("entry visibility import supports versions 1 through 7", () => {
+ for (const version of [1, 2, 3, 4, 5, 6, 7]) {
+ assert.equal(isEntryVisibilityImportVersionSupported(version, 7), true);
}
- assert.equal(isEntryVisibilityImportVersionSupported(7, 6), false);
+ assert.equal(isEntryVisibilityImportVersionSupported(8, 7), false);
});
test("legacy entry visibility imports require base without persisting it", () => {
diff --git a/app/src/config/entryVisibility/profile.ts b/app/src/config/entryVisibility/profile.ts
index eb8c7178e8..59d84f3848 100644
--- a/app/src/config/entryVisibility/profile.ts
+++ b/app/src/config/entryVisibility/profile.ts
@@ -21,6 +21,26 @@ export type TEntryVisibilityImportProfile = {
export const isEntryVisibilityImportVersionSupported = (version: number, currentVersion: number) =>
Number.isInteger(version) && version >= 1 && version <= currentVersion;
+// 脑图入口迁移到转换菜单,保留显式可见性和其余菜单项顺序。
+export const migrateMindmapMenu = (profile: Pick<Config.IEntryVisibilityProfile, "entries" | "orders">) => {
+ const oldParent = "gutter.single.listBlock";
+ const newParent = "gutter.single.turnInto";
+ const key = "listMindmap";
+ const oldPath = `${oldParent}.${key}`;
+ const newPath = `${newParent}.${key}`;
+ if (oldPath in profile.entries) {
+ if (!(newPath in profile.entries)) {
+ profile.entries[newPath] = profile.entries[oldParent] !== false && profile.entries[oldPath];
+ }
+ delete profile.entries[oldPath];
+ } else if (profile.entries[oldParent] === false && !(newPath in profile.entries)) {
+ profile.entries[newPath] = false;
+ }
+ if (profile.orders[oldParent]) {
+ profile.orders[oldParent] = profile.orders[oldParent].filter(item => item !== key);
+ }
+};
+
// 展开任务状态子菜单,合并重复入口的可见性,并在原菜单位置保留子项顺序及插件位置。
export const migrateTaskStatusMenu = (profile: Pick<Config.IEntryVisibilityProfile, "entries" | "orders">) => {
const parent = "gutter.single.listBlock";
@@ -128,5 +148,8 @@ export const normalizeEntryVisibilityImportProfile = (
if (version < 6) {
migrateTaskStatusMenu({entries, orders});
}
+ if (version < 7) {
+ migrateMindmapMenu({entries, orders});
+ }
return {name: profile.name, entries, orders};
};
diff --git a/app/src/config/entryVisibility/runtime.ts b/app/src/config/entryVisibility/runtime.ts
index 449d25cd26..f2473ed7b6 100644
--- a/app/src/config/entryVisibility/runtime.ts
+++ b/app/src/config/entryVisibility/runtime.ts
@@ -37,7 +37,7 @@ import {
mergeDockEntryOrderSnapshot,
} from "./dockOrder";
-export const ENTRY_VISIBILITY_VERSION = 6;
+export const ENTRY_VISIBILITY_VERSION = 7;
export const ENTRY_PROFILE_SIMPLE = "simple";
export const ENTRY_PROFILE_FULL = "full";
export type TEntryVisibilityTemplate = typeof ENTRY_PROFILE_SIMPLE | typeof ENTRY_PROFILE_FULL;
diff --git a/app/src/protyle/export/listMindmapExport.test.ts b/app/src/protyle/export/listMindmapExport.test.ts
index 60ab3a9d8c..d5dc08041c 100644
--- a/app/src/protyle/export/listMindmapExport.test.ts
+++ b/app/src/protyle/export/listMindmapExport.test.ts
@@ -18,7 +18,6 @@ test("mind map export labels preserve localized text without closing the generat
listMindmapRoot: "Current\u2028list\u2029root",
connect: "Connect",
text: "Text",
- listMindmapToList: "List view",
fullscreen: "Fullscreen",
exitFullscreen: "Exit fullscreen",
task: "Task",
diff --git a/app/src/protyle/gutter/index.ts b/app/src/protyle/gutter/index.ts
index 5cd349efb4..8c3d967a21 100644
--- a/app/src/protyle/gutter/index.ts
+++ b/app/src/protyle/gutter/index.ts
@@ -1833,7 +1833,16 @@ export class Gutter {
type: "List2Tabs"
}));
const listSubtype = nodeElement.getAttribute("data-subtype");
- if (listSubtype === "o") {
+ const isMindmap = nodeElement.getAttribute(Constants.CUSTOM_SY_LIST_MINDMAP) === "1";
+ if (isMindmap) {
+ [
+ {menuId: "list", icon: "iconList", label: "list", type: "OL2UL"},
+ {menuId: "orderedList", icon: "iconOrderedList", label: "ordered-list", type: "UL2OL"},
+ {menuId: "check", icon: "iconCheck", label: "check", type: "UL2TL"},
+ ].forEach(target => turnIntoSubmenu.push(this.turnsOneInto({
+ ...target, id, protyle, nodeElement, label: window.siyuan.languages[target.label],
+ })));
+ } else if (listSubtype === "o") {
turnIntoSubmenu.push(this.turnsOneInto({
menuId: "list",
id,
@@ -1897,7 +1906,18 @@ export class Gutter {
type: "OL2TL"
}));
}
- if (this.hasSublist([nodeElement])) {
+ if (!isMindmap) {
+ turnIntoSubmenu.push({
+ id: "listMindmap",
+ icon: "iconMindmap",
+ label: window.siyuan.languages.mindmap,
+ click() {
+ hideElements(["select"], protyle);
+ void toggleListMindmap(protyle, nodeElement as HTMLElement);
+ },
+ });
+ }
+ if (!isMindmap && this.hasSublist([nodeElement])) {
turnIntoSubmenu.push(this.recursiveListMenu(protyle, [nodeElement]));
}
} else if (type === "NodeTabs" && allowStructuralMutation) {
@@ -2041,7 +2061,8 @@ export class Gutter {
}
}).element);
}
- if ((type === "NodeList" || type === "NodeListItem") && allowStructuralMutation) {
+ if ((type === "NodeList" || type === "NodeListItem") && allowStructuralMutation &&
+ nodeElement.getAttribute(Constants.CUSTOM_SY_LIST_MINDMAP) !== "1") {
const isOrderedList = type === "NodeList" && nodeElement.getAttribute("data-subtype") === "o";
const continueListStartPromise = isOrderedList ? fetchSyncPost("/api/block/getOrderedListContinueStart", {
id,
@@ -2105,18 +2126,6 @@ export class Gutter {
void appendListItem(protyle, nodeElement as HTMLElement, range);
}
});
- if (type === "NodeList") {
- submenu.push({
- id: "listMindmap",
- icon: nodeElement.getAttribute("custom-sy-list-mindmap") === "1" ? "iconList" : "iconMindmap",
- label: nodeElement.getAttribute("custom-sy-list-mindmap") === "1" ?
- window.siyuan.languages.listMindmapToList : window.siyuan.languages.listMindmapToMindmap,
- click() {
- hideElements(["select"], protyle);
- void toggleListMindmap(protyle, nodeElement as HTMLElement);
- },
- });
- }
return submenu;
};
window.siyuan.menus.menu.append(new MenuItem({id: "separator_listBlock", type: "separator"}).element);
diff --git a/app/src/protyle/render/listMindmap/model.test.ts b/app/src/protyle/render/listMindmap/model.test.ts
index e407463f72..20f17b6079 100644
--- a/app/src/protyle/render/listMindmap/model.test.ts
+++ b/app/src/protyle/render/listMindmap/model.test.ts
@@ -125,7 +125,7 @@ test("layout rejects cyclic or invalid trees and supports deep nesting without r
const browserCases = async (sourceCode: string, css: string, taskSource: string, taskCSS: string, dragSource: string) => {
const check = require("node:assert/strict");
const api = new Function("mathRender", "Constants", "highlightRender", sourceCode + "; return {readListMindmap, moveListMindmapNode, addListMindmapNode, " +
- "deleteListMindmapNode, replaceListMindmapContent, cleanListMindmapHTML, remapListMindmapIDs, writeListMindmapMetadata, " +
+ "deleteListMindmapNode, replaceListMindmapContent, cleanListMindmapHTML, convertListMindmapToList, remapListMindmapIDs, writeListMindmapMetadata, " +
"normalizeLegacyMindmapCodes, replaceLegacyMindmapHTML, spinListMindmapDOM, focusListMindmap, " +
"tabsRender, destroyTabsRender, getTabTask, getListMindmapTabItem, ListMindmapView};")(
async (element: Element) => {
@@ -459,9 +459,9 @@ const browserCases = async (sourceCode: string, css: string, taskSource: string,
const cleaned = api.cleanListMindmapHTML(list.outerHTML);
// 列表转换只接收源块,脑图工具栏、画布和节点预览不能传给 Lute。
for (const [markdown, conversions] of [
- ["* Alpha\n* Beta\n", [["UL2OL", "o"], ["UL2TL", "t"]]],
- ["1. Alpha\n2. Beta\n", [["OL2UL", "u"], ["OL2TL", "t"]]],
- ["* [ ] Alpha\n* [x] Beta\n", [["TL2UL", "u"], ["TL2OL", "o"]]],
+ ["* Alpha\n* Beta\n", [["OL2UL", "u"], ["UL2OL", "o"], ["UL2TL", "t"]]],
+ ["1. Alpha\n2. Beta\n", [["OL2UL", "u"], ["UL2OL", "o"], ["UL2TL", "t"]]],
+ ["* [ ] Alpha\n* [x] Beta\n", [["OL2UL", "u"], ["UL2OL", "o"], ["UL2TL", "t"]]],
] as [string, [string, string][]][]) {
const source = document.createElement("div");
source.innerHTML = lute.Md2BlockDOM(markdown);
@@ -473,11 +473,12 @@ const browserCases = async (sourceCode: string, css: string, taskSource: string,
sourceList.prepend(derived.cloneNode(true));
for (const [conversion, subtype] of conversions) {
const converted = document.createElement("div");
- converted.innerHTML = (lute as any)[conversion](api.cleanListMindmapHTML(sourceList.outerHTML));
+ converted.innerHTML = api.convertListMindmapToList(sourceList, conversion, lute);
const result = converted.firstElementChild;
check.equal(result.getAttribute("data-subtype"), subtype);
check.equal(result.getAttribute("data-node-id"), sourceList.getAttribute("data-node-id"));
- check.equal(result.getAttribute("custom-sy-list-mindmap"), "1");
+ check.equal(result.getAttribute("custom-sy-list-mindmap"), null);
+ check.equal(sourceList.getAttribute("custom-sy-list-mindmap"), "1", "undo source retains mind map view");
check.equal(result.getAttribute("custom-sy-list-mindmap-data"), metadata);
check.equal(result.querySelector(".list-mindmap"), null);
check.equal(result.hasAttribute("data-list-mindmap-rendered"), false);
diff --git a/app/src/protyle/render/listMindmap/model.ts b/app/src/protyle/render/listMindmap/model.ts
index 9cbaab9573..052e663793 100644
--- a/app/src/protyle/render/listMindmap/model.ts
+++ b/app/src/protyle/render/listMindmap/model.ts
@@ -260,6 +260,25 @@ export const cleanListMindmapHTML = (html: string): string => {
return template.innerHTML;
};
+// 转换列表类型时退出脑图显示,保留节点、连接元数据及原 DOM 供撤销使用。
+export const convertListMindmapToList = (element: Element, type: string, lute: Lute): string | undefined => {
+ if (element.getAttribute(Constants.CUSTOM_SY_LIST_MINDMAP) !== "1" ||
+ !["OL2UL", "UL2OL", "UL2TL", "OL2TL", "TL2UL", "TL2OL"].includes(type)) {
+ return;
+ }
+ const template = document.createElement("template");
+ template.innerHTML = cleanListMindmapHTML(element.outerHTML);
+ const source = template.content.firstElementChild;
+ source.removeAttribute(Constants.CUSTOM_SY_LIST_MINDMAP);
+ const from = {o: "OL", t: "TL", u: "UL"}[source.getAttribute("data-subtype")] || "UL";
+ const to = type.split("2")[1];
+ if (from === to) {
+ return source.outerHTML;
+ }
+ // @ts-expect-error Lute 的类型声明未包含列表转换方法。
+ return lute[`${from}2${to}`](source.outerHTML);
+};
+
// 按每层最大宽度对齐节点,并为每个分支保留完整的垂直空间,避免富文本节点相互遮挡。
export const layoutListMindmap = (root: ListMindmapLayoutNode, options: {
horizontalGap?: number;
diff --git a/app/src/protyle/wysiwyg/transaction.ts b/app/src/protyle/wysiwyg/transaction.ts
index f239497c33..1cb1a84efc 100644
--- a/app/src/protyle/wysiwyg/transaction.ts
+++ b/app/src/protyle/wysiwyg/transaction.ts
@@ -74,7 +74,7 @@ import {
} from "./blockSelection";
import {isEmptyParagraph} from "./emptyTextBlock";
import {cleanTableCellRichHTML, retainTableCellRichMetadata} from "../util/tableCellRich";
-import {cleanListMindmapHTML} from "../render/listMindmap/model";
+import {cleanListMindmapHTML, convertListMindmapToList} from "../render/listMindmap/model";
import {completeTabsListSource, convertTabsList, isTabsListConversion} from "./tabsList";
import {waitForPendingTransactions} from "../util/transactionQueue";
import {
@@ -2288,8 +2288,9 @@ export const turnsOneInto = async (options: {
}
newHTML = converted.outerHTML;
} else {
+ const listHTML = convertListMindmapToList(options.nodeElement, options.type, options.protyle.lute);
// @ts-ignore
- newHTML = options.protyle.lute[options.type](cleanListMindmapHTML(options.nodeElement.outerHTML), options.level);
+ newHTML = listHTML ?? options.protyle.lute[options.type](cleanListMindmapHTML(options.nodeElement.outerHTML), options.level);
}
disposeCustomBlocksInElement(options.nodeElement);
options.nodeElement.insertAdjacentHTML("afterend", newHTML);
diff --git a/kernel/conf/appearance.go b/kernel/conf/appearance.go
index 6c79d4d127..4f67b50a6f 100644
--- a/kernel/conf/appearance.go
+++ b/kernel/conf/appearance.go
@@ -80,7 +80,7 @@ func (appearance *Appearance) NormalizeGlobalFontFamilies() {
}
const (
- EntryVisibilityVersion = 6
+ EntryVisibilityVersion = 7
EntryVisibilityProfileSimple = "simple"
EntryVisibilityProfileFull = "full"
)
@@ -168,6 +168,9 @@ func NormalizeEntryVisibility(entryVisibility *EntryVisibility, fallback string)
if version < 6 {
migrateTaskStatusMenu(profile)
}
+ if version < 7 {
+ migrateMindmapMenu(profile)
+ }
profileIDs[profile.ID] = true
profiles = append(profiles, profile)
}
diff --git a/kernel/conf/mindmap_menu.go b/kernel/conf/mindmap_menu.go
new file mode 100644
index 0000000000..1c1e9aa712
--- /dev/null
+++ b/kernel/conf/mindmap_menu.go
@@ -0,0 +1,28 @@
+package conf
+
+// 将脑图入口迁移到转换菜单,保留显式可见性和其余菜单项顺序。
+func migrateMindmapMenu(profile *EntryVisibilityProfile) {
+ const oldParent = "gutter.single.listBlock"
+ const oldPath = oldParent + ".listMindmap"
+ const newPath = "gutter.single.turnInto.listMindmap"
+ if visible, exists := profile.Entries[oldPath]; exists {
+ if _, configured := profile.Entries[newPath]; !configured {
+ parentVisible, parentConfigured := profile.Entries[oldParent]
+ profile.Entries[newPath] = visible && (!parentConfigured || parentVisible)
+ }
+ delete(profile.Entries, oldPath)
+ } else if visible, exists := profile.Entries[oldParent]; exists && !visible {
+ if _, configured := profile.Entries[newPath]; !configured {
+ profile.Entries[newPath] = false
+ }
+ }
+ if order, exists := profile.Orders[oldParent]; exists {
+ filtered := make([]string, 0, len(order))
+ for _, key := range order {
+ if key != "listMindmap" {
+ filtered = append(filtered, key)
+ }
+ }
+ profile.Orders[oldParent] = filtered
+ }
+}
diff --git a/kernel/conf/mindmap_menu_test.go b/kernel/conf/mindmap_menu_test.go
new file mode 100644
index 0000000000..e04f2983cc
--- /dev/null
+++ b/kernel/conf/mindmap_menu_test.go
@@ -0,0 +1,24 @@
+package conf
+
+import (
+ "reflect"
+ "testing"
+)
+
+func TestMindmapMenuMigration(t *testing.T) {
+ profile := &EntryVisibilityProfile{ID: "custom", Name: "Custom",
+ Entries: map[string]bool{"gutter.single.listBlock.listMindmap": false},
+ Orders: map[string][]string{
+ "gutter.single.listBlock": {"prependListItem", "listMindmap", "plugin:test", "appendListItem"},
+ "gutter.single.turnInto": {"check", "plugin:convert", "list"},
+ }}
+ config := &EntryVisibility{Version: 6, Active: "custom", Profiles: []*EntryVisibilityProfile{profile}}
+ for i := 0; i < 2; i++ {
+ NormalizeEntryVisibility(config, EntryVisibilityProfileFull)
+ if !reflect.DeepEqual(profile.Entries, map[string]bool{"gutter.single.turnInto.listMindmap": false}) ||
+ !reflect.DeepEqual(profile.Orders["gutter.single.listBlock"], []string{"prependListItem", "plugin:test", "appendListItem"}) ||
+ !reflect.DeepEqual(profile.Orders["gutter.single.turnInto"], []string{"check", "plugin:convert", "list"}) {
+ t.Fatalf("unexpected migration: %+v", profile)
+ }
+ }
+}
diff --git a/kernel/conf/task_status_menu_test.go b/kernel/conf/task_status_menu_test.go
index 45ec219954..1d34d6019f 100644
--- a/kernel/conf/task_status_menu_test.go
+++ b/kernel/conf/task_status_menu_test.go
@@ -25,7 +25,7 @@ func TestTaskStatusMenuMigration(t *testing.T) {
config := &EntryVisibility{Version: 5, Active: "custom", Profiles: []*EntryVisibilityProfile{&fixture.Input}}
for i := 0; i < 2; i++ {
NormalizeEntryVisibility(config, EntryVisibilityProfileFull)
- if config.Version != 6 || !reflect.DeepEqual(fixture.Input.Entries, fixture.Expected.Entries) ||
+ if config.Version != EntryVisibilityVersion || !reflect.DeepEqual(fixture.Input.Entries, fixture.Expected.Entries) ||
!reflect.DeepEqual(fixture.Input.Orders, fixture.Expected.Orders) {
t.Fatalf("unexpected migration: %+v", fixture.Input)
}