mirror of
https://github.com/zadam/trilium.git
synced 2025-10-29 18:49:00 +01:00
feat(promoted_attributes): add color type
This commit is contained in:
parent
7d7c3e7cdb
commit
b29781b614
@ -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";
|
type Multiplicity = "single" | "multi";
|
||||||
|
|
||||||
export interface DefinitionObject {
|
export interface DefinitionObject {
|
||||||
@ -17,7 +17,7 @@ function parse(value: string) {
|
|||||||
for (const token of tokens) {
|
for (const token of tokens) {
|
||||||
if (token === "promoted") {
|
if (token === "promoted") {
|
||||||
defObj.isPromoted = true;
|
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;
|
defObj.labelType = token as LabelType;
|
||||||
} else if (["single", "multi"].includes(token)) {
|
} else if (["single", "multi"].includes(token)) {
|
||||||
defObj.multiplicity = token as Multiplicity;
|
defObj.multiplicity = token as Multiplicity;
|
||||||
|
|||||||
@ -443,7 +443,8 @@
|
|||||||
"other_notes_with_name": "Other notes with {{attributeType}} name \"{{attributeName}}\"",
|
"other_notes_with_name": "Other notes with {{attributeType}} name \"{{attributeName}}\"",
|
||||||
"and_more": "... and {{count}} more.",
|
"and_more": "... and {{count}} more.",
|
||||||
"print_landscape": "When exporting to PDF, changes the orientation of the page to landscape instead of portrait.",
|
"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": {
|
"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>",
|
"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>",
|
||||||
|
|||||||
@ -142,6 +142,7 @@ const TPL = /*html*/`
|
|||||||
<option value="datetime">${t("attribute_detail.date_time")}</option>
|
<option value="datetime">${t("attribute_detail.date_time")}</option>
|
||||||
<option value="time">${t("attribute_detail.time")}</option>
|
<option value="time">${t("attribute_detail.time")}</option>
|
||||||
<option value="url">${t("attribute_detail.url")}</option>
|
<option value="url">${t("attribute_detail.url")}</option>
|
||||||
|
<option value="color">${t("attribute_detail.color_type")}</option>
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
@ -66,6 +66,12 @@ const TPL = /*html*/`
|
|||||||
appearance: auto;
|
appearance: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.promoted-attribute-cell input[type="color"] {
|
||||||
|
width: 50px;
|
||||||
|
padding: 0;
|
||||||
|
border: 0;
|
||||||
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<div class="promoted-attributes-container"></div>
|
<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"));
|
.on("click", () => window.open($input.val() as string, "_blank"));
|
||||||
|
|
||||||
$input.after($openButton);
|
$input.after($openButton);
|
||||||
|
} else if (definition.labelType === "color") {
|
||||||
|
$input.prop("type", "color");
|
||||||
} else {
|
} else {
|
||||||
ws.logError(t("promoted_attributes.unknown_label_type", { type: definition.labelType }));
|
ws.logError(t("promoted_attributes.unknown_label_type", { type: definition.labelType }));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -35,6 +35,15 @@ const labelTypeMappings: Record<ColumnType, Partial<ColumnDefinition>> = {
|
|||||||
formatter: "link",
|
formatter: "link",
|
||||||
editor: "input"
|
editor: "input"
|
||||||
},
|
},
|
||||||
|
color: {
|
||||||
|
editor: "input",
|
||||||
|
formatter: "color",
|
||||||
|
editorParams: {
|
||||||
|
elementAttributes: {
|
||||||
|
type: "color"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
relation: {
|
relation: {
|
||||||
editor: RelationEditor,
|
editor: RelationEditor,
|
||||||
formatter: NoteFormatter
|
formatter: NoteFormatter
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user