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
feat(promoted_attributes): add color type
Elian Doranb29781b614ae
diff --git a/apps/client/src/services/promoted_attribute_definition_parser.ts b/apps/client/src/services/promoted_attribute_definition_parser.tsindex 6cdb8edc60..fe3a9cf2ea 100644--- a/apps/client/src/services/promoted_attribute_definition_parser.ts+++ b/apps/client/src/services/promoted_attribute_definition_parser.ts@@ -1,4 +1,4 @@-export type LabelType = "text" | "number" | "boolean" | "date" | "datetime" | "time" | "url";+export type LabelType = "text" | "number" | "boolean" | "date" | "datetime" | "time" | "url" | "color";type Multiplicity = "single" | "multi";export interface DefinitionObject {@@ -17,7 +17,7 @@ function parse(value: string) {for (const token of tokens) {if (token === "promoted") {defObj.isPromoted = true;- } else if (["text", "number", "boolean", "date", "datetime", "time", "url"].includes(token)) {+ } else if (["text", "number", "boolean", "date", "datetime", "time", "url", "color"].includes(token)) {defObj.labelType = token as LabelType;} else if (["single", "multi"].includes(token)) {defObj.multiplicity = token as Multiplicity;diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.jsonindex a61220ddc0..13f9258e04 100644--- a/apps/client/src/translations/en/translation.json+++ b/apps/client/src/translations/en/translation.json@@ -443,7 +443,8 @@"other_notes_with_name": "Other notes with {{attributeType}} name \"{{attributeName}}\"","and_more": "... and {{count}} more.","print_landscape": "When exporting to PDF, changes the orientation of the page to landscape instead of portrait.",- "print_page_size": "When exporting to PDF, changes the size of the page. Supported values: <code>A0</code>, <code>A1</code>, <code>A2</code>, <code>A3</code>, <code>A4</code>, <code>A5</code>, <code>A6</code>, <code>Legal</code>, <code>Letter</code>, <code>Tabloid</code>, <code>Ledger</code>."+ "print_page_size": "When exporting to PDF, changes the size of the page. Supported values: <code>A0</code>, <code>A1</code>, <code>A2</code>, <code>A3</code>, <code>A4</code>, <code>A5</code>, <code>A6</code>, <code>Legal</code>, <code>Letter</code>, <code>Tabloid</code>, <code>Ledger</code>.",+ "color_type": "Color"},"attribute_editor": {"help_text_body1": "To add label, just type e.g. <code>#rock</code> or if you want to add also value then e.g. <code>#year = 2020</code>",diff --git a/apps/client/src/widgets/attribute_widgets/attribute_detail.ts b/apps/client/src/widgets/attribute_widgets/attribute_detail.tsindex f4134745d1..cdb7c7b438 100644--- a/apps/client/src/widgets/attribute_widgets/attribute_detail.ts+++ b/apps/client/src/widgets/attribute_widgets/attribute_detail.ts@@ -142,6 +142,7 @@ const TPL = /*html*/`<option value="datetime">${t("attribute_detail.date_time")}</option><option value="time">${t("attribute_detail.time")}</option><option value="url">${t("attribute_detail.url")}</option>+ <option value="color">${t("attribute_detail.color_type")}</option></select></td></tr>diff --git a/apps/client/src/widgets/ribbon_widgets/promoted_attributes.ts b/apps/client/src/widgets/ribbon_widgets/promoted_attributes.tsindex 8895d5e42c..5f21cb6e5f 100644--- a/apps/client/src/widgets/ribbon_widgets/promoted_attributes.ts+++ b/apps/client/src/widgets/ribbon_widgets/promoted_attributes.ts@@ -66,6 +66,12 @@ const TPL = /*html*/`appearance: auto;}+ .promoted-attribute-cell input[type="color"] {+ width: 50px;+ padding: 0;+ border: 0;+ }+</style><div class="promoted-attributes-container"></div>@@ -265,6 +271,8 @@ export default class PromotedAttributesWidget extends NoteContextAwareWidget {.on("click", () => window.open($input.val() as string, "_blank"));$input.after($openButton);+ } else if (definition.labelType === "color") {+ $input.prop("type", "color");} else {ws.logError(t("promoted_attributes.unknown_label_type", { type: definition.labelType }));}diff --git a/apps/client/src/widgets/view_widgets/table_view/columns.ts b/apps/client/src/widgets/view_widgets/table_view/columns.tsindex 65991fb5fd..39047fa70e 100644--- a/apps/client/src/widgets/view_widgets/table_view/columns.ts+++ b/apps/client/src/widgets/view_widgets/table_view/columns.ts@@ -35,6 +35,15 @@ const labelTypeMappings: Record<ColumnType, Partial<ColumnDefinition>> = {formatter: "link",editor: "input"},+ color: {+ editor: "input",+ formatter: "color",+ editorParams: {+ elementAttributes: {+ type: "color"+ }+ }+ },relation: {editor: RelationEditor,formatter: NoteFormatter