Skip to content

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

:bug: Improve mind map theme readability and palette previews https://github.com/siyuan-note/siyuan/issues/20856

Danielff9edef4ffcb
diff --git a/app/src/assets/scss/component/_menu.scss b/app/src/assets/scss/component/_menu.scss
index 8a0186df0b..c7b5e42563 100644
--- a/app/src/assets/scss/component/_menu.scss
+++ b/app/src/assets/scss/component/_menu.scss
@@ -401,6 +401,7 @@
&__items {
overflow: auto;
padding: 0 8px;
+ max-height: var(--b3-menu-items-max-height, none);
}
&__item {
diff --git a/app/src/assets/scss/protyle/_mindmap-view.scss b/app/src/assets/scss/protyle/_mindmap-view.scss
index bd24a71f9d..ea43d8a754 100644
--- a/app/src/assets/scss/protyle/_mindmap-view.scss
+++ b/app/src/assets/scss/protyle/_mindmap-view.scss
@@ -27,6 +27,7 @@
.mindmap-view {
--mindmap-node-text-color: initial;
+ --b3-task-completed-color: initial;
position: relative;
display: flex;
flex-direction: column;
@@ -492,7 +493,18 @@
}
}
+ &__node--colored {
+ --b3-task-completed-color: var(--mindmap-node-text-color);
+ }
+
&__node--colored > .mindmap-view__content {
+ // 默认的列表正文和删除线沿用节点前景,手动行内颜色仍由正文自身决定。
+ .li,
+ s,
+ span[data-type~="s"] {
+ color: var(--mindmap-node-text-color);
+ }
+
.bq,
.callout {
color: var(--mindmap-node-text-color, var(--b3-theme-on-surface));
@@ -503,6 +515,11 @@
}
}
+ &__theme-preview {
+ width: 64px;
+ flex-basis: 64px;
+ }
+
&__node[data-task] {
display: grid;
// 空任务正文也保留输入宽度,确保光标能落入编辑器。
diff --git a/app/src/assets/scss/protyle/_task.scss b/app/src/assets/scss/protyle/_task.scss
index 14951e2a96..407a76b0fd 100644
--- a/app/src/assets/scss/protyle/_task.scss
+++ b/app/src/assets/scss/protyle/_task.scss
@@ -1,7 +1,7 @@
@use "sass:string";
@mixin completed-text {
- color: var(--b3-theme-on-surface-light);
+ color: var(--b3-task-completed-color, var(--b3-theme-on-surface-light));
text-decoration: line-through;
}
diff --git a/app/src/menus/Menu.ts b/app/src/menus/Menu.ts
index 05640af92c..288661f54d 100644
--- a/app/src/menus/Menu.ts
+++ b/app/src/menus/Menu.ts
@@ -529,7 +529,9 @@ export class Menu {
// 按实际边框和内边距扣除菜单外壳高度,兼容主题及字号调整。
const rect = menuElement.getBoundingClientRect();
const chromeHeight = rect.height - itemsMenuElement.getBoundingClientRect().height;
- itemsMenuElement.style.maxHeight = Math.max(window.innerHeight - rect.top - chromeHeight, 0) + "px";
+ const availableHeight = Math.max(window.innerHeight - rect.top - chromeHeight, 0) + "px";
+ const preferredHeight = getComputedStyle(itemsMenuElement).getPropertyValue("--b3-menu-items-max-height").trim();
+ itemsMenuElement.style.maxHeight = preferredHeight ? `min(${availableHeight}, ${preferredHeight})` : availableHeight;
// 滚动条可能改变菜单宽度,限高后再按最终尺寸校正窗口边界。
setPosition(menuElement, rect.left, rect.top);
}
diff --git a/app/src/menus/menuLayout.dom.test.ts b/app/src/menus/menuLayout.dom.test.ts
index e5f1fee8ac..8435d256db 100644
--- a/app/src/menus/menuLayout.dom.test.ts
+++ b/app/src/menus/menuLayout.dom.test.ts
@@ -290,6 +290,81 @@ const browserCases = async (sources: Record<string, string>, css: string) => {
fitsViewport(submenu);
dispose(submenus);
+ const appearance: typeof import("../protyle/render/listMindmap/appearance") = load("protyle/render/listMindmap/appearance");
+ const labels: Record<string, string> = {theme: "Theme", default: "Default", ...Object.fromEntries(appearance.LIST_MINDMAP_PALETTES
+ .map(preset => [preset.label, preset.id]))};
+ for (const touch of [false, true]) {
+ mobile = touch;
+ await require("electron").ipcRenderer.invoke("resize-menu-test", touch ? 360 : 640, 520);
+ await settle();
+ window.siyuan.mobile.size.portrait.height1 = innerHeight;
+ for (const fontSize of [16, 24]) {
+ document.documentElement.style.setProperty("--b3-font-size", `${fontSize}px`);
+ const instance = createMenu();
+ const metadata: import("../protyle/render/listMindmap/model").ListMindmapMetadata = {version: 1, nodes: {}, relations: []};
+ let changes = 0;
+ const menu = appearance.getListMindmapAppearanceMenu(metadata, update => { update(metadata); changes++; },
+ labels, {id: "connectorStyle"});
+ instance.addItem((menu.submenu as IMenu[]).find(item => item.id === "theme"));
+ if (touch) {
+ instance.fullscreen("bottom");
+ } else {
+ instance.popup({x: 280, y: 90});
+ }
+ const parent = instance.element.querySelector<HTMLElement>('[data-id="theme"]');
+ parent.dispatchEvent(new MouseEvent(touch ? "click" : "mouseover", {bubbles: true}));
+ await settle();
+ if (touch) {
+ for (let attempt = 0; attempt < 20 && instance.element.style.transform !== "translateY(0px)"; attempt++) {
+ await settle();
+ }
+ check.equal(instance.element.style.transform, "translateY(0px)");
+ instance.element.getAnimations({subtree: true}).forEach(animation => animation.finish());
+ await settle();
+ }
+ const panel = parent.querySelector<HTMLElement>(":scope > .b3-menu__submenu");
+ const items = panel.querySelector<HTMLElement>(":scope > .b3-menu__items");
+ check.equal(items.children.length, appearance.LIST_MINDMAP_PALETTES.length + 1);
+ check.ok(items.scrollHeight > items.clientHeight, "theme choices scroll inside a bounded menu");
+ if (!touch) {
+ fitsViewport(panel);
+ check.ok(items.clientHeight <= Math.min(480, innerHeight * .6) + 1,
+ "desktop themes keep the preferred height within viewport limits");
+ } else {
+ const bounds = panel.getBoundingClientRect();
+ check.ok(bounds.top >= 0 && bounds.bottom <= innerHeight + 1,
+ "mobile theme choices fit the visible sheet after its opening transition");
+ check.ok(bounds.left >= 0 && bounds.right <= innerWidth + 1, "mobile themes fit a narrow screen");
+ }
+ for (const [index, preset] of appearance.LIST_MINDMAP_PALETTES.entries()) {
+ const row = items.children[index + 1];
+ const preview = row.querySelector<HTMLElement>(".mindmap-view__theme-preview");
+ const label = row.querySelector<HTMLElement>(".b3-menu__label");
+ check.equal(preview.getAttribute("aria-hidden"), "true");
+ check.ok(getComputedStyle(preview).backgroundImage.startsWith("linear-gradient("));
+ check.ok(new Set(getComputedStyle(preview).backgroundImage.match(/rgb\([^)]+\)/g)).size >= 3,
+ "the preview shows multiple representative theme colors");
+ check.equal(preview.getBoundingClientRect().width, 64);
+ check.ok(label.getBoundingClientRect().left >= preview.getBoundingClientRect().right);
+ check.equal(label.textContent, labels[preset.label]);
+ }
+ const last = items.lastElementChild as HTMLElement;
+ items.scrollTop = items.scrollHeight;
+ const lastBounds = last.getBoundingClientRect();
+ check.ok(lastBounds.bottom <= items.getBoundingClientRect().bottom + 1,
+ "the final theme remains reachable without expanding the menu");
+ last.click();
+ check.equal(changes, 1);
+ check.deepEqual(metadata.appearance.palette, appearance.LIST_MINDMAP_PALETTES.at(-1).colors);
+ dispose(instance);
+ }
+ }
+ document.documentElement.style.setProperty("--b3-font-size", "16px");
+ mobile = false;
+ await require("electron").ipcRenderer.invoke("resize-menu-test", 1000, 800);
+ await settle();
+ window.siyuan.mobile.size.portrait.height1 = innerHeight;
+
const shared = createMenu();
const independent = new PluginMenu(undefined, undefined, true);
independent.addItem({label: "First"});
@@ -726,12 +801,13 @@ test("menus adapt to layout changes and optional whole-menu mouse scrolling", {
const sources = Object.fromEntries(["menus/Menu", "menus/menuPosition", "menus/menuMouseScroll", "menus/menuGroup", "menus/sheetOpen", "menus/sheetActions",
"util/setPosition", "protyle/util/hasClosest", "plugin/Menu", "protyle/render/av/openMenuPanel",
"asset/pdf/viewerTemplate", "asset/pdf/secondary_toolbar.js", "protyle/render/av/calendar/undated", "protyle/gutter/embedBreadcrumbMenu",
- "layout/dock/agent/AgentSessionPanel"].map(name => [name,
+ "layout/dock/agent/AgentSessionPanel", "protyle/render/listMindmap/appearance"].map(name => [name,
transpileModule(readFileSync(path.join(__dirname, "..", name.endsWith(".js") ? name : name + ".ts"), "utf8"), {
compilerOptions: {target: ScriptTarget.ES2021, module: ModuleKind.CommonJS},
}).outputText]));
const css = ["component/_menu.scss", "component/_list.scss", "component/_text-field.scss", "util/_function.scss",
- "business/_av.scss", "business/_av-calendar.scss", "business/_ai_agent.scss", "pdf/_pdf.scss"].map(name =>
+ "business/_av.scss", "business/_av-calendar.scss", "business/_ai_agent.scss", "pdf/_pdf.scss",
+ "protyle/_mindmap-view.scss"].map(name =>
compile(path.join(__dirname, "../assets/scss", name), {logger: Logger.silent}).css).join("\n");
const source = `const __name = value => value; (${browserCases.toString()})(${JSON.stringify(sources)}, ${JSON.stringify(css)})`;
const temporary = mkdtempSync(path.join(tmpdir(), "siyuan-menu-layout-test-"));
diff --git a/app/src/protyle/render/listMindmap/appearance.test.ts b/app/src/protyle/render/listMindmap/appearance.test.ts
index f92ef6011c..5e6633225b 100644
--- a/app/src/protyle/render/listMindmap/appearance.test.ts
+++ b/app/src/protyle/render/listMindmap/appearance.test.ts
@@ -41,7 +41,12 @@ test("appearance validates optional colors and rejects unsupported formats", ()
}
});
-test("all 47 reference palettes retain white filled nodes and adapt transparent node text to the canvas", () => {
+test("all 47 reference palettes adapt filled and transparent node text without rewriting saved colors", () => {
+ const luminance = (color: string) => color.match(/[a-f\d]{2}/gi).map(channel => parseInt(channel, 16) / 255)
+ .map(channel => channel <= .04045 ? channel / 12.92 : ((channel + .055) / 1.055) ** 2.4)
+ .reduce((sum, channel, index) => sum + channel * [.2126, .7152, .0722][index], 0);
+ const contrast = (a: string, b: string) => (Math.max(luminance(a), luminance(b)) + .05) /
+ (Math.min(luminance(a), luminance(b)) + .05);
assert.equal(LIST_MINDMAP_PALETTES.length, 47);
assert.equal(new Set(LIST_MINDMAP_PALETTES.map(preset => preset.id)).size, 47);
assert.equal(new Set(LIST_MINDMAP_PALETTES.map(preset => JSON.stringify(preset.colors))).size, 47);
@@ -68,7 +73,11 @@ test("all 47 reference palettes retain white filled nodes and adapt transparent
const before = JSON.stringify(model.metadata);
const styles = resolveListMindmapColors(model, canvas);
assert.deepEqual(["root", "a", "a1"].map(id => styles.get(id).textColor),
- ["#ffffff", "#ffffff", canvas === "#1e1e1e" ? "#ffffff" : "#000000"]);
+ [getMindmapTextColor(preset.rootColor), getMindmapTextColor(preset.colors[0]), getMindmapTextColor(canvas)]);
+ for (const [id, style] of styles) {
+ assert.ok(contrast(style.textColor, style.backgroundColor === "transparent" ? canvas : style.backgroundColor) >= 4.5,
+ `${preset.id} ${id} has readable automatic text on its actual background`);
+ }
assert.deepEqual(["root", "a", "a1"].map(id => styles.get(id).backgroundColor),
[preset.rootColor, preset.colors[0], "transparent"]);
assert.deepEqual(["root", "a", "a1"].map(id => styles.get(id).lineWidth), [1.5, 1.5, 1.5]);
@@ -322,7 +331,7 @@ test("appearance menu preserves manual colors and non-color metadata until expli
const contrastCases = async (source: string, css: string, legacyPresets: typeof legacyPalettes) => {
const check = require("node:assert/strict");
const api = new Function("Constants", "mathRender", "tabsRender", "destroyTabsRender", source +
- "; return {ListMindmapView, readListMindmap, retagMindmapBranch, getMindmapLineColor, resolveListMindmapColors, LIST_MINDMAP_PALETTES};")({
+ "; return {ListMindmapView, readListMindmap, retagMindmapBranch, getMindmapLineColor, getMindmapTextColor, resolveListMindmapColors, LIST_MINDMAP_PALETTES};")({
CUSTOM_SY_LIST_MINDMAP: "custom-sy-list-mindmap", CUSTOM_SY_LIST_MINDMAP_DATA: "custom-sy-list-mindmap-data",
}, async () => {}, () => {}, () => {});
const sheet = document.createElement("style");
@@ -456,8 +465,10 @@ const contrastCases = async (source: string, css: string, legacyPresets: typeof
view.update(model);
check.equal(getComputedStyle(view.nodeElements.get(model.root.id)).backgroundColor, computedColor(preset.rootColor));
for (const node of [model.root, emptyNode, quoteNode]) {
- check.equal(getComputedStyle(view.nodeElements.get(node.id)).color, "rgb(255, 255, 255)",
- "root and first-level foregrounds follow the fixed white reference style");
+ check.equal(getComputedStyle(view.nodeElements.get(node.id)).color,
+ computedColor(api.getMindmapTextColor(node === model.root ? preset.rootColor :
+ preset.colors[node === emptyNode ? 0 : 1])),
+ "filled node foregrounds contrast with their own root or branch fill");
}
const deep = view.nodeElements.get(deepNode.id);
check.equal(getComputedStyle(deep).backgroundColor, "rgba(0, 0, 0, 0)");
@@ -467,9 +478,10 @@ const contrastCases = async (source: string, css: string, legacyPresets: typeof
check.equal(getComputedStyle(deep.querySelector(".bq .p")).color, foreground);
check.equal(getComputedStyle(deep.querySelector(".bq span")).color, "rgb(194, 65, 12)",
"deep inline colors remain authoritative");
- check.equal(getComputedStyle(view.getContentHost(emptyNode.id), "::before").color, "rgb(255, 255, 255)");
+ check.equal(getComputedStyle(view.getContentHost(emptyNode.id), "::before").color,
+ computedColor(api.getMindmapTextColor(preset.colors[0])));
check.equal(getComputedStyle(view.nodeElements.get(quoteNode.id).querySelector(".bq .p")).color,
- "rgb(255, 255, 255)");
+ computedColor(api.getMindmapTextColor(preset.colors[1])));
check.equal(getComputedStyle(view.nodeElements.get(quoteNode.id).querySelector(".bq span")).color,
"rgb(194, 65, 12)", "explicit inline text colors remain authoritative");
widths.length = 0;
@@ -586,6 +598,70 @@ const contrastCases = async (source: string, css: string, legacyPresets: typeof
}
delete model.metadata.nodes[deepNode.id];
}
+ const rich = document.createElement("div");
+ rich.innerHTML = lute.Md2BlockDOM("Task ~~strike~~ **bold** `code`\n\n- [x] Nested task\n");
+ const richParagraph = rich.querySelector<HTMLElement>(":scope > .p");
+ const nestedTasks = rich.querySelector<HTMLElement>(":scope > .list");
+ nestedTasks.querySelector(".li").classList.add("protyle-task--done");
+ richParagraph.dataset.contrastFixture = "true";
+ const explicit = document.createElement("span");
+ explicit.dataset.type = "s";
+ explicit.style.color = "#c2410c";
+ explicit.textContent = "Manual strike";
+ richParagraph.querySelector("[contenteditable]").append(explicit);
+ quoteNode.contentBlocks.push(richParagraph, nestedTasks);
+ deepNode.contentBlocks.push(richParagraph.cloneNode(true), nestedTasks.cloneNode(true));
+ const originalTaskMarkers = [quoteNode.taskMarker, deepNode.taskMarker];
+ const originalSource = list.outerHTML;
+ for (const printLayout of [false, true]) {
+ view.options.printLayout = printLayout;
+ view.readOnly = printLayout;
+ for (const background of ["#ffffff", "#1e1e1e"]) {
+ for (const palette of [["#670069"], ["#fec245"], []]) {
+ model.metadata.appearance = {version: 1, palette, rootColor: palette[0], nodeStyle: "branch", backgroundColor: background};
+ for (const marker of ["x", "-", "/"]) {
+ quoteNode.taskMarker = deepNode.taskMarker = marker;
+ const before = JSON.stringify(model.metadata);
+ view.update(model);
+ const checkTaskContent = (node: ListMindmapNode) => {
+ const element = view.nodeElements.get(node.id);
+ const foreground = getComputedStyle(element).color;
+ const paragraph = element.querySelector('[data-contrast-fixture="true"]');
+ check.equal(getComputedStyle(paragraph).color, foreground, "task text uses its node foreground");
+ check.equal(getComputedStyle(paragraph).textDecorationLine, marker === "/" ? "none" : "line-through",
+ `${marker} ${printLayout}: ${element.className}, ${paragraph.parentElement.className}`);
+ check.equal(getComputedStyle(paragraph.querySelector('[data-type~="s"]')).color, foreground,
+ "default strikethrough text stays readable");
+ check.equal(getComputedStyle(paragraph.querySelector('[style*="color"]')).color, "rgb(194, 65, 12)",
+ "manual inline colors stay authoritative");
+ check.equal(getComputedStyle(element.querySelector(".mindmap-view__task")).color, foreground,
+ "node task icons use the same readable foreground");
+ check.equal(getComputedStyle(element.querySelector(".li > .p")).color, foreground,
+ "nested completed tasks stay readable");
+ };
+ checkTaskContent(quoteNode);
+ checkTaskContent(deepNode);
+ if (!printLayout) {
+ view.setEditing(quoteNode.id);
+ const editor = document.createElement("div");
+ editor.className = "protyle-wysiwyg";
+ editor.append(richParagraph.cloneNode(true), nestedTasks.cloneNode(true));
+ const contentHost = view.getContentHost(quoteNode.id);
+ const preview = Array.from(contentHost.childNodes);
+ contentHost.classList.add("mindmap-view__editor");
+ contentHost.replaceChildren(editor);
+ checkTaskContent(quoteNode);
+ view.setEditing(undefined);
+ contentHost.classList.remove("mindmap-view__editor");
+ contentHost.replaceChildren(...preview);
+ }
+ check.equal(JSON.stringify(model.metadata), before, "readability changes never enter saved appearance");
+ check.equal(list.outerHTML, originalSource, "preview and editor styles never rewrite source blocks");
+ }
+ }
+ }
+ }
+ [quoteNode.taskMarker, deepNode.taskMarker] = originalTaskMarkers;
model.metadata.appearance.palette = [];
view.update(model);
view.nodeElements.forEach((element: HTMLElement) => {
@@ -598,7 +674,7 @@ const contrastCases = async (source: string, css: string, legacyPresets: typeof
return "mindmap-contrast-ok";
};
-test("reference and legacy palettes preserve their foreground rules, hierarchy paths and manual overrides", {
+test("reference and legacy palettes keep readable foregrounds, hierarchy paths and manual overrides", {
timeout: 20000,
skip: process.platform === "linux" && !process.env.DISPLAY && !process.env.WAYLAND_DISPLAY,
}, async () => {
diff --git a/app/src/protyle/render/listMindmap/appearance.ts b/app/src/protyle/render/listMindmap/appearance.ts
index 13e459acf1..b54d07f7f9 100644
--- a/app/src/protyle/render/listMindmap/appearance.ts
+++ b/app/src/protyle/render/listMindmap/appearance.ts
@@ -212,7 +212,7 @@ export const resolveListMindmapColors = (model: ListMindmapModel, canvasColor?:
const {node, color, level} = pending.pop();
if (appearance.nodeStyle === "branch") {
result.set(node.id, {backgroundColor: level < 2 ? color : "transparent",
- textColor: level < 2 ? "#ffffff" : getMindmapTextColor(background), lineColor: color,
+ textColor: getMindmapTextColor(level < 2 ? color : background), lineColor: color,
fontSize: level === 0 ? 20 : level === 1 ? 16 : 14, bold: level < 2, lineWidth: 1.5});
} else if (appearance.nodeStyle === "layered") {
result.set(node.id, {backgroundColor: "transparent",
@@ -246,25 +246,34 @@ export const getListMindmapAppearanceMenu = (metadata: ListMindmapMetadata,
return {
id: "appearance", icon: "iconTheme", label: labels.appearance,
submenu: [
- {id: "theme", iconHTML: "", label: labels.theme, submenu: [
- {id: "default", iconHTML: "", label: labels.default, checked: !palette.length,
- click: () => change(data => {
- data.appearance = {...data.appearance, version: 1, palette: []};
- delete data.appearance.rootColor;
- delete data.appearance.nodeStyle;
- })},
- ...LIST_MINDMAP_PALETTES.map(preset => ({
- id: preset.id, iconHTML: `<span class="b3-menu__icon b3-menu__icon--color" style="background-color:${preset.colors[0]}"></span>`,
- label: labels[preset.label],
- checked: metadata.appearance?.nodeStyle === "branch" &&
- metadata.appearance.rootColor === preset.rootColor &&
- JSON.stringify(palette) === JSON.stringify(preset.colors),
- click: () => change(data => {
- data.appearance = {...data.appearance, version: 1, palette: [...preset.colors],
- rootColor: preset.rootColor, nodeStyle: "branch"};
+ {id: "theme", iconHTML: "", label: labels.theme,
+ bind: element => element.style.setProperty("--b3-menu-items-max-height", "min(480px, 60vh)"),
+ submenu: [
+ {id: "default", iconHTML: '<span class="b3-menu__icon mindmap-view__theme-preview" aria-hidden="true"></span>',
+ label: labels.default, checked: !palette.length,
+ click: () => change(data => {
+ data.appearance = {...data.appearance, version: 1, palette: []};
+ delete data.appearance.rootColor;
+ delete data.appearance.nodeStyle;
+ })},
+ ...LIST_MINDMAP_PALETTES.map(preset => {
+ const colors = [preset.rootColor, ...preset.colors.filter((_color, index) => index % 2 === 0)];
+ const gradient = colors.map((color, index) =>
+ `${color} ${index * 100 / colors.length}% ${(index + 1) * 100 / colors.length}%`).join(",");
+ return {
+ id: preset.id,
+ iconHTML: `<span class="b3-menu__icon b3-menu__icon--color mindmap-view__theme-preview" aria-hidden="true" style="background:linear-gradient(90deg,${gradient})"></span>`,
+ label: labels[preset.label],
+ checked: metadata.appearance?.nodeStyle === "branch" &&
+ metadata.appearance.rootColor === preset.rootColor &&
+ JSON.stringify(palette) === JSON.stringify(preset.colors),
+ click: () => change(data => {
+ data.appearance = {...data.appearance, version: 1, palette: [...preset.colors],
+ rootColor: preset.rootColor, nodeStyle: "branch"};
+ }),
+ };
}),
- })),
- ]},
+ ]},
{id: "canvasBackground", iconHTML: "", label: labels.listMindmapCanvasBackground, submenu: [
{id: "default", color: "", label: labels.default},
{id: "light", color: "#ffffff", label: labels.themeLight},
diff --git a/app/src/protyle/render/listMindmap/view.ts b/app/src/protyle/render/listMindmap/view.ts
index 09a0e18ec9..2dc3d54b27 100644
--- a/app/src/protyle/render/listMindmap/view.ts
+++ b/app/src/protyle/render/listMindmap/view.ts
@@ -1027,20 +1027,23 @@ export class ListMindmapView {
return;
}
this.viewport.style.backgroundColor = this.model.metadata.appearance?.backgroundColor || "";
+ const canvasForeground = this.model.metadata.appearance?.backgroundColor ?
+ getMindmapTextColor(this.model.metadata.appearance.backgroundColor) : undefined;
this.themeColors = resolveListMindmapColors(this.model, getComputedStyle(this.options.host).backgroundColor);
this.nodeElements.forEach((element, id) => {
const style = this.model.metadata.nodes[id];
const themed = this.themeColors.get(id);
const background = style?.backgroundColor || themed?.backgroundColor || "";
- element.classList.toggle("mindmap-view__node--colored", !!themed);
+ const adaptForeground = !!themed || !!canvasForeground;
+ element.classList.toggle("mindmap-view__node--colored", adaptForeground);
element.style.backgroundColor = background;
- element.style.color = style?.textColor || (themed && style?.backgroundColor && isMindmapColor(background) ?
- getMindmapTextColor(background) : themed?.textColor) || "";
+ element.style.color = style?.textColor || (adaptForeground && style?.backgroundColor && isMindmapColor(background) ?
+ getMindmapTextColor(background) : themed?.textColor || canvasForeground) || "";
element.style.fontSize = themed?.fontSize ? `${style?.fontSize ?? themed.fontSize}px` : "";
element.style.fontWeight = themed?.fontSize ? (style?.bold === undefined ? (themed.bold ? "600" : "400") :
style.bold ? "700" : "400") : "";
element.style.fontStyle = themed?.fontSize && style?.italic !== undefined ? (style.italic ? "italic" : "normal") : "";
- if (themed) {
+ if (adaptForeground) {
element.style.setProperty("--mindmap-node-text-color", element.style.color);
} else {
element.style.removeProperty("--mindmap-node-text-color");