Skip to content

Build your personal knowledge base with Trilium Notes

fix(board): keep CJK upright in collapsed column titles (closes #11749)

Elian Doran3e2ed0387877
diff --git a/apps/client/src/widgets/collections/board/index.css b/apps/client/src/widgets/collections/board/index.css
index 503775692f..087682b41c 100644
--- a/apps/client/src/widgets/collections/board/index.css
+++ b/apps/client/src/widgets/collections/board/index.css
@@ -1498,6 +1498,17 @@ body.mobile .column-drop-placeholder {
transform: rotate(-90deg);
}
+/* Top-down, the only direction in which CJK characters stay upright. Applied to the whole board so
+ its collapsed columns all read the same way. */
+.board-view-container.cjk-titles .board-column.collapsed h3 > .title,
+.board-view-container.cjk-titles .board-column.collapsed h3 > .counter-badge {
+ transform: none;
+}
+
+.board-view-container.cjk-titles .board-column.collapsed h3 > .column-sort {
+ transform: rotate(90deg);
+}
+
/* Swapped: `padding` is physical, so it does not turn with the count. */
.board-view-container .board-column.collapsed h3 > .counter-badge {
padding: 0.6em 0.1em;
diff --git a/apps/client/src/widgets/collections/board/index.spec.tsx b/apps/client/src/widgets/collections/board/index.spec.tsx
index 48fe4abab0..44f3599cf2 100644
--- a/apps/client/src/widgets/collections/board/index.spec.tsx
+++ b/apps/client/src/widgets/collections/board/index.spec.tsx
@@ -1109,6 +1109,18 @@ describe("Board column creation", () => {
expect(saved.at(-1)?.columns?.map(c => c.value)).toEqual([ "To Do", "Done", "In Progress" ]);
expect(columnTitles(container)).toEqual([ "To Do", "Done", "In Progress" ]);
});
+
+ it("sets every collapsed title upright once a column is named in CJK", async () => {
+ const { container } = await setup();
+ const board = container.querySelector<HTMLElement>(".board-view-container");
+ if (!board) throw new Error("expected the board container");
+ expect(board.classList.contains("cjk-titles")).toBe(false);
+
+ await addColumn(container, "English 中文 あい");
+
+ expect(columnTitles(container)).toContain("English 中文 あい");
+ expect(board.classList.contains("cjk-titles")).toBe(true);
+ });
});
describe("Board column rename", () => {
diff --git a/apps/client/src/widgets/collections/board/index.tsx b/apps/client/src/widgets/collections/board/index.tsx
index 21146e55b5..47461519a1 100644
--- a/apps/client/src/widgets/collections/board/index.tsx
+++ b/apps/client/src/widgets/collections/board/index.tsx
@@ -288,6 +288,9 @@ const NO_COLUMNS: ReadonlySet<string> = new Set();
/** Shared empty map for a filter under which no column has been opened or closed by hand. */
const NO_FILTER_COLLAPSE: ReadonlyMap<string, boolean> = new Map();
+/** Scripts set upright in vertical text, which a collapsed column's title has to read top-down for. */
+const UPRIGHT_SCRIPT = /[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}]/u;
+
const NAVIGATION_HINTS: ShortcutHint[] = [
{ keys: [ "Up", "Down" ], labelKey: "board_view.hints.navigate_items" },
{ keys: [ "Left", "Right" ], labelKey: "board_view.hints.navigate_columns" },
@@ -806,6 +809,7 @@ function Board({
}
}), [ api, shownColumns, byColumn, storedColumns, isInRelationMode ]);
useSetContextData(noteContext, "boardColumns", outline);
+ const hasCjkTitles = outline.columns.some(({ title }) => UPRIGHT_SCRIPT.test(title));
// Reveals the column or card a `?column=` or `?card=` link names. Takes `shownColumns` rather
// than every column, so that a column hidden because it is archived is reported instead of
@@ -1466,7 +1470,8 @@ function Board({
className={clsx("board-view-container", {
pannable: isPannable,
panning: isPanning,
- selecting: isSelecting
+ selecting: isSelecting,
+ "cjk-titles": hasCjkTitles
})}
onKeyDown={handleKeyDown}
onClick={clearSelectionOutsideCards}
diff --git a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Collections/Kanban Board.html b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Collections/Kanban Board.html
index 082b48f3a8..a1fd5f9c0d 100644
--- a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Collections/Kanban Board.html
+++ b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Collections/Kanban Board.html
@@ -76,6 +76,10 @@
moving the selected cards up or down, or to another column.</li>
</ul>
<p>Collapsed columns can still be reordered, and their menus remain available.</p>
+<p>A collapsed column shows its title vertically, read from the bottom up.
+ If any column title on the board contains Chinese, Japanese or Korean characters,
+ the titles of all collapsed columns read from the top down instead, so
+ that those characters stay upright.</p>
<h4>Expanding</h4>
<p>You can restore a collapsed column so that its content is visible again
in the following ways:</p>
diff --git a/docs/User Guide/User Guide/Collections/Kanban Board.md b/docs/User Guide/User Guide/Collections/Kanban Board.md
index 24544c8ad5..b72a6fe606 100644
--- a/docs/User Guide/User Guide/Collections/Kanban Board.md
+++ b/docs/User Guide/User Guide/Collections/Kanban Board.md
@@ -59,6 +59,8 @@ Once a column is collapsed, its cards are no longer visible, but the column can
Collapsed columns can still be reordered, and their menus remain available.
+A collapsed column shows its title vertically, read from the bottom up. If any column title on the board contains Chinese, Japanese or Korean characters, the titles of all collapsed columns read from the top down instead, so that those characters stay upright.
+
#### Expanding
You can restore a collapsed column so that its content is visible again in the following ways: