Skip to content

Build your personal knowledge base with Trilium Notes

feat(import/notion): import status columns as single-valued labels

Elian Doranc5053339fdd3
diff --git a/packages/trilium-core/src/services/import/notion/importer.integration.spec.ts b/packages/trilium-core/src/services/import/notion/importer.integration.spec.ts
index e41a70df4e..95d0e2edca 100644
--- a/packages/trilium-core/src/services/import/notion/importer.integration.spec.ts
+++ b/packages/trilium-core/src/services/import/notion/importer.integration.spec.ts
@@ -429,6 +429,24 @@ describe("Notion importer — integration", () => {
expect(row?.getOwnedLabelValue("Select_column")).toBe("First");
});
+ it("imports a status column as a single-valued text label", async () => {
+ const dbId = "388c5eca1b8b8078a20fd18330d81306";
+ const rowId = "388c5eca1b8b80929a78da7c68154bd7";
+ // A status value sits in a <span class="status-value"> after an empty <div class="status-dot">.
+ const props = `<table class="properties"><tbody><tr class="property-row property-row-status"><th><span class="icon property-icon"><img src="x.svg"/></span>Status column</th><td><span class="status-value select-value-color-blue"><div class="status-dot status-dot-color-blue"></div>Another in progress</span></td></tr></tbody></table>`;
+ const importRoot = await importNotion({
+ "DB 388c5eca1b8b8078a20fd18330d81306.html":
+ `<html><head><title>DB</title></head><body><div id="${dbId}"><div class="page-body"></div></div></body></html>`,
+ "DB/Row 388c5eca1b8b80929a78da7c68154bd7.html":
+ `<html><head><title>Row</title></head><body><div id="${rowId}">${props}<div class="page-body"><p>x</p></div></div></body></html>`
+ });
+
+ const db = importRoot.getChildNotes().find((n) => n.title === "DB");
+ expect(db?.getOwnedLabel("label:Status_column")?.value).toBe("promoted,single,text,alias=Status column");
+ const row = db?.getChildNotes().find((n) => n.title === "Row");
+ expect(row?.getOwnedLabelValue("Status_column")).toBe("Another in progress");
+ });
+
it("neutralizes commas in a column name so the alias can't corrupt the definition", async () => {
const dbId = "388c5eca1b8b8078a20fd18330d81306";
const rowId = "388c5eca1b8b80929a78da7c68154bd7";
diff --git a/packages/trilium-core/src/services/import/notion/importer.ts b/packages/trilium-core/src/services/import/notion/importer.ts
index 9606fd0a15..0199e15255 100644
--- a/packages/trilium-core/src/services/import/notion/importer.ts
+++ b/packages/trilium-core/src/services/import/notion/importer.ts
@@ -482,7 +482,7 @@ export function firstChildNotionId(body: HTMLElement | null): string | undefined
* Reads a page's database properties from its Notion properties table. Each column is a
* `<tr class="property-row property-row-<type>">` whose `<th>` holds the column name (after an icon span,
* which carries no text) and `<td>` the value. Handled so far:
- * - `text` / `select`: the cell's text → one single-valued property;
+ * - `text` / `select` / `status`: the cell's text → one single-valued property;
* - `multi_select`: each `<span class="selected-value">` option → one entry of a multi-valued property.
* The importer turns each `{ name, value }` into a Trilium label; blank names/values are skipped (Notion
* sometimes emits an empty cell, e.g. an unset multi-select, which should contribute no label). Other types
@@ -498,9 +498,9 @@ function extractProperties(root: HTMLElement): NotionProperty[] {
}
const type = row.getAttribute("class")?.match(/property-row-(\w+)/)?.[1];
- if (type === "text" || type === "select") {
- // `select` is a single chosen option (one `<span class="selected-value">`); its cell text is the
- // whole value, so it takes the same single-valued path as a free-text column.
+ if (type === "text" || type === "select" || type === "status") {
+ // `select`/`status` are a single chosen option; their cell text is the whole value (a status'
+ // leading `<div class="status-dot">` carries no text), so they take the free-text single path.
const value = cell.textContent?.trim();
if (value) {
properties.push({ name, value, labelType: "text", multiplicity: "single" });