Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
custom task states: use "isHidden" promoted attribute instead of archiving the task state definition to hide it from being listed
Adorian Doran60c6cc8497a4
diff --git a/apps/client/src/services/task_states.ts b/apps/client/src/services/task_states.tsindex f4306ce5f8..3c156f791e 100644--- a/apps/client/src/services/task_states.ts+++ b/apps/client/src/services/task_states.ts@@ -38,24 +38,30 @@ export async function getTaskStateDefinitions(): Promise<TaskStateDef[]> {return DEFAULT_TASK_STATES;}- const states = (await container.getChildNotes()).map((note): TaskStateDef => {- if (note.noteId === NONE_STATE_ID) {- return NONE_TASK_STATE;- }- if (note.noteId === DONE_STATE_ID) {- return DONE_TASK_STATE;- }- return {- id: note.noteId,- name: note.getLabelValue("stateName") ?? "",- title: note.title,- markdownSymbol: note.getLabelValue("markdownSymbol") ?? "",- isCompleted: note.getLabelValue("isCompleted") === "true",- color: note.getLabelValue("color") ?? "",- icon: note.getLabelValue("iconClass") ?? "",- archived: note.isArchived- };- });+ const states = (await container.getChildNotes())+ .map((note): TaskStateDef | null => {+ if (note.noteId === NONE_STATE_ID) {+ return NONE_TASK_STATE;+ }+ if (note.noteId === DONE_STATE_ID) {+ return DONE_TASK_STATE;+ }+ // Archived definition notes are completely ignored — never enumerated.+ if (note.isArchived) {+ return null;+ }+ return {+ id: note.noteId,+ name: note.getLabelValue("stateName") ?? "",+ title: note.title,+ markdownSymbol: note.getLabelValue("markdownSymbol") ?? "",+ isCompleted: note.getLabelValue("isCompleted") === "true",+ color: note.getLabelValue("color") ?? "",+ icon: note.getLabelValue("iconClass") ?? "",+ isHidden: note.getLabelValue("isHidden") === "true"+ };+ })+ .filter((state): state is TaskStateDef => state !== null);const {valid, errors} = validateTaskStates(states);reportValidationErrors(errors);diff --git a/packages/ckeditor5/src/plugins/todo_list_multistate/todo_list_multistate_editing.ts b/packages/ckeditor5/src/plugins/todo_list_multistate/todo_list_multistate_editing.tsindex c5228492cb..8000dbe36b 100644--- a/packages/ckeditor5/src/plugins/todo_list_multistate/todo_list_multistate_editing.ts+++ b/packages/ckeditor5/src/plugins/todo_list_multistate/todo_list_multistate_editing.ts@@ -16,10 +16,10 @@ export function getConfiguredTaskStates(editor: Editor): TaskStateDef[] {/*** The states surfaced in the toolbar and keyboard cycle — configured states- * minus archived ones. Archived states still round-trip and keep their CSS.+ * minus hidden ones. Hidden states still round-trip and keep their CSS.*/export function getActiveTaskStates(editor: Editor): TaskStateDef[] {- return getConfiguredTaskStates(editor).filter((state) => !state.archived);+ return getConfiguredTaskStates(editor).filter((state) => !state.isHidden);}export default class TodoListMultistateEditing extends Plugin {diff --git a/packages/commons/src/lib/task_states.ts b/packages/commons/src/lib/task_states.tsindex ece0c569b6..cda4d6b5b9 100644--- a/packages/commons/src/lib/task_states.ts+++ b/packages/commons/src/lib/task_states.ts@@ -21,8 +21,8 @@ export interface TaskStateDef {color: string;/** Icon class, e.g. `bx bx-loader`. */icon: string;- /** Whether the state note is archived — kept for CSS/round-trip, hidden from the toolbar and cycle. */- archived?: boolean;+ /** The `isHidden` label — kept for CSS/round-trip, but hidden from the toolbar and keyboard cycle. */+ isHidden?: boolean;}/** Reserved name of the built-in unchecked anchor state. */diff --git a/packages/trilium-core/src/services/hidden_subtree.ts b/packages/trilium-core/src/services/hidden_subtree.tsindex 5423c28c69..f2bdd828d4 100644--- a/packages/trilium-core/src/services/hidden_subtree.ts+++ b/packages/trilium-core/src/services/hidden_subtree.ts@@ -95,7 +95,8 @@ function buildHiddenSubtreeDefinition(helpSubtree: HiddenSubtreeItem[]): HiddenS{ type: "label", name: "child:label:stateName", value: "promoted,single,text" },{ type: "label", name: "child:label:markdownSymbol", value: "promoted,single,text" },{ type: "label", name: "child:label:isCompleted", value: "promoted,single,bool" },- { type: "label", name: "child:label:color", value: "promoted,single,text" }+ { type: "label", name: "child:label:color", value: "promoted,single,text" },+ { type: "label", name: "child:label:isHidden", value: "promoted,single,bool" }],// Non-customizable anchor states — recreated if missing; they only// determine where `none`/`done` sit in the toolbar/cycling order.diff --git a/packages/trilium-core/src/services/task_states.ts b/packages/trilium-core/src/services/task_states.tsindex 19064a55e8..13c3b60ce4 100644--- a/packages/trilium-core/src/services/task_states.ts+++ b/packages/trilium-core/src/services/task_states.ts@@ -20,24 +20,30 @@ export function getTaskStates(): TaskStateDef[] {return DEFAULT_TASK_STATES;}- const states = container.getChildNotes().map((note): TaskStateDef => {- if (note.noteId === NONE_STATE_ID) {- return NONE_TASK_STATE;- }- if (note.noteId === DONE_STATE_ID) {- return DONE_TASK_STATE;- }- return {- id: note.noteId,- name: note.getLabelValue("stateName") ?? "",- title: note.title,- markdownSymbol: note.getLabelValue("markdownSymbol") ?? "",- isCompleted: note.getLabelValue("isCompleted") === "true",- color: note.getLabelValue("color") ?? "",- icon: note.getLabelValue("iconClass") ?? "",- archived: note.isArchived- };- });+ const states = container.getChildNotes()+ .map((note): TaskStateDef | null => {+ if (note.noteId === NONE_STATE_ID) {+ return NONE_TASK_STATE;+ }+ if (note.noteId === DONE_STATE_ID) {+ return DONE_TASK_STATE;+ }+ // Archived definition notes are completely ignored — never enumerated.+ if (note.isArchived) {+ return null;+ }+ return {+ id: note.noteId,+ name: note.getLabelValue("stateName") ?? "",+ title: note.title,+ markdownSymbol: note.getLabelValue("markdownSymbol") ?? "",+ isCompleted: note.getLabelValue("isCompleted") === "true",+ color: note.getLabelValue("color") ?? "",+ icon: note.getLabelValue("iconClass") ?? "",+ isHidden: note.getLabelValue("isHidden") === "true"+ };+ })+ .filter((state): state is TaskStateDef => state !== null);const {valid} = validateTaskStates(states);return valid.length ? valid : DEFAULT_TASK_STATES;