mirror of
https://github.com/zadam/trilium.git
synced 2025-11-13 08:45:50 +01:00
Compare commits
2 Commits
main
...
react/prom
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
54c8322960 | ||
|
|
3d0d1fa36e |
@@ -38,7 +38,7 @@
|
||||
"@playwright/test": "1.56.1",
|
||||
"@stylistic/eslint-plugin": "5.5.0",
|
||||
"@types/express": "5.0.5",
|
||||
"@types/node": "24.10.1",
|
||||
"@types/node": "24.10.0",
|
||||
"@types/yargs": "17.0.34",
|
||||
"@vitest/coverage-v8": "3.2.4",
|
||||
"eslint": "9.39.1",
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
"keywords": [],
|
||||
"author": "Elian Doran <contact@eliandoran.me>",
|
||||
"license": "AGPL-3.0-only",
|
||||
"packageManager": "pnpm@10.22.0",
|
||||
"packageManager": "pnpm@10.21.0",
|
||||
"devDependencies": {
|
||||
"@redocly/cli": "2.11.1",
|
||||
"archiver": "7.0.1",
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
"normalize.css": "8.0.1",
|
||||
"panzoom": "9.4.3",
|
||||
"preact": "10.27.2",
|
||||
"react-i18next": "16.3.1",
|
||||
"react-i18next": "16.2.4",
|
||||
"reveal.js": "5.2.1",
|
||||
"svg-pan-zoom": "3.6.2",
|
||||
"tabulator-tables": "6.3.1",
|
||||
|
||||
@@ -3,7 +3,7 @@ import { DESKTOP_FLOATING_BUTTONS } from "../widgets/FloatingButtonsDefinitions.
|
||||
import ApiLog from "../widgets/api_log.jsx";
|
||||
import ClosePaneButton from "../widgets/buttons/close_pane_button.js";
|
||||
import CloseZenModeButton from "../widgets/close_zen_button.jsx";
|
||||
import ContentHeader from "../widgets/containers/content_header.js";
|
||||
import ContentHeader from "../widgets/containers/content-header.js";
|
||||
import CreatePaneButton from "../widgets/buttons/create_pane_button.js";
|
||||
import FindWidget from "../widgets/find.js";
|
||||
import FlexContainer from "../widgets/containers/flex_container.js";
|
||||
@@ -21,7 +21,6 @@ import NoteTreeWidget from "../widgets/note_tree.js";
|
||||
import NoteWrapperWidget from "../widgets/note_wrapper.js";
|
||||
import options from "../services/options.js";
|
||||
import PasswordNoteSetDialog from "../widgets/dialogs/password_not_set.js";
|
||||
import PromotedAttributesWidget from "../widgets/promoted_attributes.js";
|
||||
import QuickSearchWidget from "../widgets/quick_search.js";
|
||||
import ReadOnlyNoteInfoBar from "../widgets/ReadOnlyNoteInfoBar.jsx";
|
||||
import Ribbon from "../widgets/ribbon/Ribbon.jsx";
|
||||
@@ -44,6 +43,7 @@ import UploadAttachmentsDialog from "../widgets/dialogs/upload_attachments.js";
|
||||
import utils from "../services/utils.js";
|
||||
import WatchedFileUpdateStatusWidget from "../widgets/watched_file_update_status.js";
|
||||
import NoteDetail from "../widgets/NoteDetail.jsx";
|
||||
import PromotedAttributes from "../widgets/PromotedAttributes.jsx";
|
||||
|
||||
export default class DesktopLayout {
|
||||
|
||||
@@ -140,7 +140,7 @@ export default class DesktopLayout {
|
||||
.child(<ReadOnlyNoteInfoBar />)
|
||||
.child(<SharedInfo />)
|
||||
)
|
||||
.child(new PromotedAttributesWidget())
|
||||
.child(<PromotedAttributes />)
|
||||
.child(<SqlTableSchemas />)
|
||||
.child(<NoteDetail />)
|
||||
.child(<NoteList media="screen" />)
|
||||
|
||||
@@ -10,7 +10,7 @@ import LauncherContainer from "../widgets/containers/launcher_container.js";
|
||||
import MobileDetailMenu from "../widgets/mobile_widgets/mobile_detail_menu.js";
|
||||
import NoteList from "../widgets/collections/NoteList.jsx";
|
||||
import NoteTitleWidget from "../widgets/note_title.js";
|
||||
import ContentHeader from "../widgets/containers/content_header.js";
|
||||
import ContentHeader from "../widgets/containers/content-header.js";
|
||||
import NoteTreeWidget from "../widgets/note_tree.js";
|
||||
import NoteWrapperWidget from "../widgets/note_wrapper.js";
|
||||
import PromotedAttributesWidget from "../widgets/promoted_attributes.js";
|
||||
|
||||
91
apps/client/src/widgets/PromotedAttributes.css
Normal file
91
apps/client/src/widgets/PromotedAttributes.css
Normal file
@@ -0,0 +1,91 @@
|
||||
body.mobile .promoted-attributes-widget {
|
||||
/* https://github.com/zadam/trilium/issues/4468 */
|
||||
flex-shrink: 0.4;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.component.promoted-attributes-widget {
|
||||
contain: none;
|
||||
}
|
||||
|
||||
.promoted-attributes-container {
|
||||
margin: 0 1.5em;
|
||||
overflow: auto;
|
||||
max-height: 400px;
|
||||
flex-wrap: wrap;
|
||||
display: table;
|
||||
}
|
||||
.promoted-attribute-cell {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin: 10px;
|
||||
display: table-row;
|
||||
}
|
||||
.promoted-attribute-cell > label {
|
||||
user-select: none;
|
||||
font-weight: bold;
|
||||
vertical-align: middle;
|
||||
}
|
||||
.promoted-attribute-cell > * {
|
||||
display: table-cell;
|
||||
padding: 1px 0;
|
||||
}
|
||||
|
||||
.promoted-attribute-cell div.input-group {
|
||||
margin-inline-start: 10px;
|
||||
display: flex;
|
||||
min-height: 40px;
|
||||
}
|
||||
.promoted-attribute-cell strong {
|
||||
word-break:keep-all;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.promoted-attribute-cell input[type="checkbox"] {
|
||||
width: 22px !important;
|
||||
flex-grow: 0;
|
||||
width: unset;
|
||||
}
|
||||
|
||||
/* Restore default apperance */
|
||||
.promoted-attribute-cell input[type="number"],
|
||||
.promoted-attribute-cell input[type="checkbox"] {
|
||||
appearance: auto;
|
||||
}
|
||||
|
||||
.promoted-attribute-cell input[type="color"] {
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
margin-top: 2px;
|
||||
appearance: none;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
outline: none;
|
||||
border-radius: 25% !important;
|
||||
}
|
||||
|
||||
.promoted-attribute-cell input[type="color"]::-webkit-color-swatch-wrapper {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.promoted-attribute-cell input[type="color"]::-webkit-color-swatch {
|
||||
border: none;
|
||||
border-radius: 25%;
|
||||
}
|
||||
|
||||
.promoted-attribute-label-color input[type="hidden"][value=""] + input[type="color"] {
|
||||
position: relative;
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.promoted-attribute-label-color input[type="hidden"][value=""] + input[type="color"]:after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: 10px;
|
||||
inset-inline-start: 0px;
|
||||
inset-inline-end: 0;
|
||||
height: 2px;
|
||||
background: rgba(0, 0, 0, 0.5);
|
||||
transform: rotate(45deg);
|
||||
pointer-events: none;
|
||||
}
|
||||
120
apps/client/src/widgets/PromotedAttributes.tsx
Normal file
120
apps/client/src/widgets/PromotedAttributes.tsx
Normal file
@@ -0,0 +1,120 @@
|
||||
import { useEffect, useState } from "preact/hooks";
|
||||
import "./PromotedAttributes.css";
|
||||
import { useNoteContext, useNoteLabel } from "./react/hooks";
|
||||
import { Attribute } from "../services/attribute_parser";
|
||||
import { ComponentChild } from "preact";
|
||||
import FAttribute from "../entities/fattribute";
|
||||
import { t } from "../services/i18n";
|
||||
import ActionButton from "./react/ActionButton";
|
||||
|
||||
export default function PromotedAttributes() {
|
||||
const { note } = useNoteContext();
|
||||
const [ promotedAttributes, setPromotedAttributes ] = useState<ComponentChild[]>();
|
||||
const [ viewType ] = useNoteLabel(note, "viewType");
|
||||
|
||||
useEffect(() => {
|
||||
if (!note) {
|
||||
setPromotedAttributes([]);
|
||||
return;
|
||||
}
|
||||
|
||||
const promotedDefAttrs = note.getPromotedDefinitionAttributes();
|
||||
const ownedAttributes = note.getOwnedAttributes();
|
||||
// attrs are not resorted if position changes after the initial load
|
||||
// promoted attrs are sorted primarily by order of definitions, but with multi-valued promoted attrs
|
||||
// the order of attributes is important as well
|
||||
ownedAttributes.sort((a, b) => a.position - b.position);
|
||||
|
||||
let promotedAttributes: ComponentChild[] = [];
|
||||
for (const definitionAttr of promotedDefAttrs) {
|
||||
const valueType = definitionAttr.name.startsWith("label:") ? "label" : "relation";
|
||||
const valueName = definitionAttr.name.substr(valueType.length + 1);
|
||||
|
||||
let valueAttrs = ownedAttributes.filter((el) => el.name === valueName && el.type === valueType) as Attribute[];
|
||||
|
||||
if (valueAttrs.length === 0) {
|
||||
valueAttrs.push({
|
||||
attributeId: "",
|
||||
type: valueType,
|
||||
name: valueName,
|
||||
value: ""
|
||||
});
|
||||
}
|
||||
|
||||
if (definitionAttr.getDefinition().multiplicity === "single") {
|
||||
valueAttrs = valueAttrs.slice(0, 1);
|
||||
}
|
||||
|
||||
for (const valueAttr of valueAttrs) {
|
||||
promotedAttributes.push(<PromotedAttributeCell
|
||||
noteId={note.noteId}
|
||||
definitionAttr={definitionAttr}
|
||||
valueAttr={valueAttr} valueName={valueName} />)
|
||||
}
|
||||
}
|
||||
setPromotedAttributes(promotedAttributes);
|
||||
console.log("Got ", promotedAttributes);
|
||||
}, [ note ]);
|
||||
|
||||
return (
|
||||
<div className="promoted-attributes-widget">
|
||||
{viewType !== "table" && (
|
||||
<div className="promoted-attributes-container">
|
||||
{promotedAttributes}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function PromotedAttributeCell({ noteId, definitionAttr, valueAttr, valueName }: {
|
||||
noteId: string;
|
||||
definitionAttr: FAttribute;
|
||||
valueAttr: Attribute;
|
||||
valueName: string;
|
||||
}) {
|
||||
const definition = definitionAttr.getDefinition();
|
||||
const id = `value-${valueAttr.attributeId}`;
|
||||
|
||||
return (
|
||||
<div className="promoted-attribute-cell">
|
||||
<label
|
||||
for={id}
|
||||
>{definition.promotedAlias ?? valueName}</label>
|
||||
|
||||
<div className="input-group">
|
||||
<input
|
||||
className="form-control promoted-attribute-input"
|
||||
tabindex={200 + definitionAttr.position}
|
||||
id={id}
|
||||
// if not owned, we'll force creation of a new attribute instead of updating the inherited one
|
||||
data-attribute-id={valueAttr.noteId === noteId ? valueAttr.attributeId ?? "" : ""}
|
||||
data-attribute-type={valueAttr.type}
|
||||
data-attribute-name={valueAttr.name}
|
||||
value={valueAttr.value}
|
||||
placeholder={t("promoted_attributes.unset-field-placeholder")}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div />
|
||||
|
||||
{definition.multiplicity === "multi" && (
|
||||
<td className="multiplicity">
|
||||
<ActionButton
|
||||
icon="bx bx-plus"
|
||||
className="pointer tn-tool-button"
|
||||
text={t("promoted_attributes.add_new_attribute")}
|
||||
noIconActionClass
|
||||
/>
|
||||
|
||||
<ActionButton
|
||||
icon="bx bx-trash"
|
||||
className="pointer tn-tool-button"
|
||||
text={t("promoted_attributes.remove_this_attribute")}
|
||||
noIconActionClass
|
||||
/>
|
||||
</td>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
.promoted-attributes {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
align-items: center;
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
.promoted-attributes .promoted-attribute {
|
||||
padding: 2px 10px;
|
||||
border-radius: 9999px;
|
||||
white-space: nowrap;
|
||||
background-color: var(--chip-bg, rgba(0, 0, 0, 0.08));
|
||||
color: var(--chip-fg, inherit);
|
||||
border: 1px solid var(--chip-border, rgba(0, 0, 0, 0.15));
|
||||
font-size: 12px;
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
.promoted-attributes .promoted-attribute:hover {
|
||||
background-color: var(--chip-bg-hover, rgba(0, 0, 0, 0.12));
|
||||
border-color: var(--chip-border-hover, rgba(0, 0, 0, 0.22));
|
||||
}
|
||||
|
||||
.promoted-attributes .promoted-attribute .name {
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.promoted-attributes .promoted-attribute .value {
|
||||
opacity: 0.9;
|
||||
}
|
||||
@@ -1,119 +0,0 @@
|
||||
import { useState } from "preact/hooks";
|
||||
import FNote from "../../entities/fnote";
|
||||
import "./PromotedAttributesDisplay.css";
|
||||
import { useTriliumEvent } from "../react/hooks";
|
||||
import attributes from "../../services/attributes";
|
||||
import { DefinitionObject } from "../../services/promoted_attribute_definition_parser";
|
||||
import { formatDateTime } from "../../utils/formatters";
|
||||
import { ComponentChildren } from "preact";
|
||||
import Icon from "../react/Icon";
|
||||
import NoteLink from "../react/NoteLink";
|
||||
|
||||
interface PromotedAttributesDisplayProps {
|
||||
note: FNote;
|
||||
ignoredAttributes?: string[];
|
||||
}
|
||||
|
||||
interface AttributeWithDefinitions {
|
||||
friendlyName: string;
|
||||
name: string;
|
||||
type: string;
|
||||
value: string;
|
||||
def: DefinitionObject;
|
||||
}
|
||||
|
||||
export default function PromotedAttributesDisplay({ note, ignoredAttributes }: PromotedAttributesDisplayProps) {
|
||||
const promotedDefinitionAttributes = useNoteAttributesWithDefinitions(note, ignoredAttributes);
|
||||
return promotedDefinitionAttributes?.length > 0 && (
|
||||
<div className="promoted-attributes">
|
||||
{promotedDefinitionAttributes?.map((attr) => {
|
||||
const className = `${attr.type === "label" ? "label" + " " + attr.def.labelType : "relation"}`;
|
||||
return (
|
||||
<span key={attr.friendlyName} className={`promoted-attribute type-${className}`}>
|
||||
{attr.type === "relation" ? formatRelation(attr) : formatLabelValue(attr)}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
function useNoteAttributesWithDefinitions(note: FNote, attributesToIgnore: string[] = []): AttributeWithDefinitions[] {
|
||||
const [ promotedDefinitionAttributes, setPromotedDefinitionAttributes ] = useState<AttributeWithDefinitions[]>(getAttributesWithDefinitions(note, attributesToIgnore));
|
||||
|
||||
useTriliumEvent("entitiesReloaded", ({ loadResults }) => {
|
||||
if (loadResults.getAttributeRows().some(attr => attributes.isAffecting(attr, note))) {
|
||||
setPromotedDefinitionAttributes(getAttributesWithDefinitions(note, attributesToIgnore));
|
||||
}
|
||||
});
|
||||
|
||||
return promotedDefinitionAttributes;
|
||||
}
|
||||
|
||||
function formatLabelValue(attr: AttributeWithDefinitions): ComponentChildren {
|
||||
let value = attr.value;
|
||||
switch (attr.def.labelType) {
|
||||
case "number":
|
||||
let formattedValue = value;
|
||||
const numberValue = Number(value);
|
||||
if (attr.def.numberPrecision) {
|
||||
formattedValue = numberValue.toFixed(attr.def.numberPrecision);
|
||||
}
|
||||
return <><strong>{attr.friendlyName}:</strong> {formattedValue}</>;
|
||||
case "date":
|
||||
case "datetime": {
|
||||
const date = new Date(value);
|
||||
const timeFormat = attr.def.labelType !== "date" ? "short" : "none";
|
||||
return <><strong>{attr.friendlyName}:</strong> {formatDateTime(date, "short", timeFormat)}</>;
|
||||
}
|
||||
case "time": {
|
||||
const date = new Date(`1970-01-01T${value}Z`);
|
||||
return <><strong>{attr.friendlyName}:</strong> {formatDateTime(date, "none", "short")}</>;
|
||||
}
|
||||
case "boolean":
|
||||
return <><Icon icon={value === "true" ? "bx bx-check-square" : "bx bx-square"} /> <strong>{attr.friendlyName}</strong></>;
|
||||
case "url":
|
||||
return <><a href={value} target="_blank" rel="noopener noreferrer">{attr.friendlyName}</a></>;
|
||||
case "color":
|
||||
return <><span style={{ color: value }}>{attr.friendlyName}</span></>;
|
||||
case "text":
|
||||
default:
|
||||
return <><strong>{attr.friendlyName}:</strong> {value}</>;
|
||||
}
|
||||
}
|
||||
|
||||
function formatRelation(attr: AttributeWithDefinitions): ComponentChildren {
|
||||
return (
|
||||
<><strong>{attr.friendlyName}:</strong> <NoteLink notePath={attr.value} showNoteIcon /></>
|
||||
)
|
||||
}
|
||||
|
||||
function getAttributesWithDefinitions(note: FNote, attributesToIgnore: string[] = []): AttributeWithDefinitions[] {
|
||||
const promotedDefinitionAttributes = note.getPromotedDefinitionAttributes();
|
||||
const result: AttributeWithDefinitions[] = [];
|
||||
for (const attr of promotedDefinitionAttributes) {
|
||||
const def = attr.getDefinition();
|
||||
const [ type, name ] = attr.name.split(":", 2);
|
||||
const friendlyName = def?.promotedAlias || name;
|
||||
const props: Omit<AttributeWithDefinitions, "value"> = { def, name, type, friendlyName };
|
||||
|
||||
if (type === "label") {
|
||||
const labels = note.getLabels(name);
|
||||
for (const label of labels) {
|
||||
if (!label.value) continue;
|
||||
result.push({ ...props, value: label.value } );
|
||||
}
|
||||
} else if (type === "relation") {
|
||||
const relations = note.getRelations(name);
|
||||
for (const relation of relations) {
|
||||
if (!relation.value) continue;
|
||||
result.push({ ...props, value: relation.value } );
|
||||
}
|
||||
}
|
||||
|
||||
if (attributesToIgnore.includes(name)) continue;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -16,7 +16,7 @@ export default class BoardApi {
|
||||
private byColumn: ColumnMap | undefined,
|
||||
public columns: string[],
|
||||
private parentNote: FNote,
|
||||
readonly statusAttribute: string,
|
||||
private statusAttribute: string,
|
||||
private viewConfig: BoardViewData,
|
||||
private saveConfig: (newConfig: BoardViewData) => void,
|
||||
private setBranchIdToEdit: (branchId: string | undefined) => void
|
||||
|
||||
@@ -6,7 +6,6 @@ import { BoardViewContext, TitleEditor } from ".";
|
||||
import { ContextMenuEvent } from "../../../menus/context_menu";
|
||||
import { openNoteContextMenu } from "./context_menu";
|
||||
import { t } from "../../../services/i18n";
|
||||
import PromotedAttributesDisplay from "../../attribute_widgets/PromotedAttributesDisplay";
|
||||
|
||||
export const CARD_CLIPBOARD_TYPE = "trilium/board-card";
|
||||
|
||||
@@ -109,7 +108,6 @@ export default function Card({
|
||||
title={t("board_view.edit-note-title")}
|
||||
onClick={handleEdit}
|
||||
/>
|
||||
<PromotedAttributesDisplay note={note} ignoredAttributes={[api.statusAttribute]} />
|
||||
</>
|
||||
) : (
|
||||
<TitleEditor
|
||||
|
||||
@@ -104,8 +104,6 @@ export default function Column({
|
||||
{!isEditing ? (
|
||||
<>
|
||||
<span className="title">{column}</span>
|
||||
<span className="counter-badge">{columnItems?.length ?? 0}</span>
|
||||
<div className="spacer" />
|
||||
<span
|
||||
className="edit-icon icon bx bx-edit-alt"
|
||||
title={t("board_view.edit-column-title")}
|
||||
|
||||
@@ -53,16 +53,7 @@
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.board-view-container .board-column h3 .counter-badge {
|
||||
background-color: var(--muted-text-color);
|
||||
color: var(--main-background-color);
|
||||
border-radius: 12px;
|
||||
padding: 0.1em 0.6em;
|
||||
font-size: 0.75em;
|
||||
margin-inline-start: 0.5em;
|
||||
}
|
||||
|
||||
.board-view-container .board-column h3 > .spacer {
|
||||
.board-view-container .board-column h3 > .title {
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,6 @@ export default class ContentHeader extends Container<BasicWidget> {
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.class("content-header-widget");
|
||||
this.css("contain", "unset");
|
||||
this.resizeObserver = new ResizeObserver(this.onResize.bind(this));
|
||||
}
|
||||
@@ -12,102 +12,6 @@ import type { Attribute } from "../services/attribute_parser.js";
|
||||
import type FAttribute from "../entities/fattribute.js";
|
||||
import type { EventData } from "../components/app_context.js";
|
||||
|
||||
const TPL = /*html*/`
|
||||
<div class="promoted-attributes-widget">
|
||||
<style>
|
||||
body.mobile .promoted-attributes-widget {
|
||||
/* https://github.com/zadam/trilium/issues/4468 */
|
||||
flex-shrink: 0.4;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.promoted-attributes-container {
|
||||
margin: 0 1.5em;
|
||||
overflow: auto;
|
||||
max-height: 400px;
|
||||
flex-wrap: wrap;
|
||||
display: table;
|
||||
}
|
||||
.promoted-attribute-cell {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin: 10px;
|
||||
display: table-row;
|
||||
}
|
||||
.promoted-attribute-cell > label {
|
||||
user-select: none;
|
||||
font-weight: bold;
|
||||
vertical-align: middle;
|
||||
}
|
||||
.promoted-attribute-cell > * {
|
||||
display: table-cell;
|
||||
padding: 1px 0;
|
||||
}
|
||||
|
||||
.promoted-attribute-cell div.input-group {
|
||||
margin-inline-start: 10px;
|
||||
display: flex;
|
||||
min-height: 40px;
|
||||
}
|
||||
.promoted-attribute-cell strong {
|
||||
word-break:keep-all;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.promoted-attribute-cell input[type="checkbox"] {
|
||||
width: 22px !important;
|
||||
flex-grow: 0;
|
||||
width: unset;
|
||||
}
|
||||
|
||||
/* Restore default apperance */
|
||||
.promoted-attribute-cell input[type="number"],
|
||||
.promoted-attribute-cell input[type="checkbox"] {
|
||||
appearance: auto;
|
||||
}
|
||||
|
||||
.promoted-attribute-cell input[type="color"] {
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
margin-top: 2px;
|
||||
appearance: none;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
outline: none;
|
||||
border-radius: 25% !important;
|
||||
}
|
||||
|
||||
.promoted-attribute-cell input[type="color"]::-webkit-color-swatch-wrapper {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.promoted-attribute-cell input[type="color"]::-webkit-color-swatch {
|
||||
border: none;
|
||||
border-radius: 25%;
|
||||
}
|
||||
|
||||
.promoted-attribute-label-color input[type="hidden"][value=""] + input[type="color"] {
|
||||
position: relative;
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.promoted-attribute-label-color input[type="hidden"][value=""] + input[type="color"]:after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: 10px;
|
||||
inset-inline-start: 0px;
|
||||
inset-inline-end: 0;
|
||||
height: 2px;
|
||||
background: rgba(0, 0, 0, 0.5);
|
||||
transform: rotate(45deg);
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<div class="promoted-attributes-container"></div>
|
||||
</div>`;
|
||||
|
||||
// TODO: Deduplicate
|
||||
interface AttributeResult {
|
||||
attributeId: string;
|
||||
@@ -117,115 +21,17 @@ export default class PromotedAttributesWidget extends NoteContextAwareWidget {
|
||||
|
||||
private $container!: JQuery<HTMLElement>;
|
||||
|
||||
get name() {
|
||||
return "promotedAttributes";
|
||||
}
|
||||
|
||||
get toggleCommand() {
|
||||
return "toggleRibbonTabPromotedAttributes";
|
||||
}
|
||||
|
||||
doRender() {
|
||||
this.$widget = $(TPL);
|
||||
this.$widget = $("");
|
||||
this.contentSized();
|
||||
this.$container = this.$widget.find(".promoted-attributes-container");
|
||||
}
|
||||
|
||||
getTitle(note: FNote) {
|
||||
const promotedDefAttrs = note.getPromotedDefinitionAttributes();
|
||||
|
||||
if (promotedDefAttrs.length === 0) {
|
||||
return { show: false };
|
||||
}
|
||||
|
||||
return {
|
||||
show: true,
|
||||
activate: options.is("promotedAttributesOpenInRibbon"),
|
||||
title: t("promoted_attributes.promoted_attributes"),
|
||||
icon: "bx bx-table"
|
||||
};
|
||||
}
|
||||
|
||||
async refreshWithNote(note: FNote) {
|
||||
this.$container.empty();
|
||||
|
||||
const promotedDefAttrs = note.getPromotedDefinitionAttributes();
|
||||
const ownedAttributes = note.getOwnedAttributes();
|
||||
// attrs are not resorted if position changes after the initial load
|
||||
// promoted attrs are sorted primarily by order of definitions, but with multi-valued promoted attrs
|
||||
// the order of attributes is important as well
|
||||
ownedAttributes.sort((a, b) => a.position - b.position);
|
||||
|
||||
if (promotedDefAttrs.length === 0 || note.getLabelValue("viewType") === "table") {
|
||||
this.toggleInt(false);
|
||||
return;
|
||||
}
|
||||
|
||||
const $cells: JQuery<HTMLElement>[] = [];
|
||||
|
||||
for (const definitionAttr of promotedDefAttrs) {
|
||||
const valueType = definitionAttr.name.startsWith("label:") ? "label" : "relation";
|
||||
const valueName = definitionAttr.name.substr(valueType.length + 1);
|
||||
|
||||
let valueAttrs = ownedAttributes.filter((el) => el.name === valueName && el.type === valueType) as Attribute[];
|
||||
|
||||
if (valueAttrs.length === 0) {
|
||||
valueAttrs.push({
|
||||
attributeId: "",
|
||||
type: valueType,
|
||||
name: valueName,
|
||||
value: ""
|
||||
});
|
||||
}
|
||||
|
||||
if (definitionAttr.getDefinition().multiplicity === "single") {
|
||||
valueAttrs = valueAttrs.slice(0, 1);
|
||||
}
|
||||
|
||||
for (const valueAttr of valueAttrs) {
|
||||
const $cell = await this.createPromotedAttributeCell(definitionAttr, valueAttr, valueName);
|
||||
|
||||
if ($cell) {
|
||||
$cells.push($cell);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// we replace the whole content in one step, so there can't be any race conditions
|
||||
// (previously we saw promoted attributes doubling)
|
||||
this.$container.empty().append(...$cells);
|
||||
this.toggleInt(true);
|
||||
}
|
||||
|
||||
async createPromotedAttributeCell(definitionAttr: FAttribute, valueAttr: Attribute, valueName: string) {
|
||||
const definition = definitionAttr.getDefinition();
|
||||
const id = `value-${valueAttr.attributeId}`;
|
||||
// .on("change", (event) => this.promotedAttributeChanged(event));
|
||||
|
||||
const $input = $("<input>")
|
||||
.prop("tabindex", 200 + definitionAttr.position)
|
||||
.prop("id", id)
|
||||
.attr("data-attribute-id", valueAttr.noteId === this.noteId ? valueAttr.attributeId ?? "" : "") // if not owned, we'll force creation of a new attribute instead of updating the inherited one
|
||||
.attr("data-attribute-type", valueAttr.type)
|
||||
.attr("data-attribute-name", valueAttr.name)
|
||||
.prop("value", valueAttr.value)
|
||||
.prop("placeholder", t("promoted_attributes.unset-field-placeholder"))
|
||||
.addClass("form-control")
|
||||
.addClass("promoted-attribute-input")
|
||||
.on("change", (event) => this.promotedAttributeChanged(event));
|
||||
|
||||
const $actionCell = $("<div>");
|
||||
const $multiplicityCell = $("<td>").addClass("multiplicity").attr("nowrap", "true");
|
||||
|
||||
const $wrapper = $('<div class="promoted-attribute-cell">')
|
||||
.append(
|
||||
$("<label>")
|
||||
.prop("for", id)
|
||||
.text(definition.promotedAlias ?? valueName)
|
||||
)
|
||||
.append($("<div>").addClass("input-group").append($input))
|
||||
.append($actionCell)
|
||||
.append($multiplicityCell);
|
||||
|
||||
if (valueAttr.type === "label") {
|
||||
$wrapper.addClass(`promoted-attribute-label-${definition.labelType}`);
|
||||
if (definition.labelType === "text") {
|
||||
@@ -359,8 +165,6 @@ export default class PromotedAttributesWidget extends NoteContextAwareWidget {
|
||||
|
||||
if (definition.multiplicity === "multi") {
|
||||
const $addButton = $("<span>")
|
||||
.addClass("bx bx-plus pointer tn-tool-button")
|
||||
.prop("title", t("promoted_attributes.add_new_attribute"))
|
||||
.on("click", async () => {
|
||||
const $new = await this.createPromotedAttributeCell(
|
||||
definitionAttr,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM node:24.11.1-bullseye-slim AS builder
|
||||
FROM node:24.11.0-bullseye-slim AS builder
|
||||
RUN corepack enable
|
||||
|
||||
# Install native dependencies since we might be building cross-platform.
|
||||
@@ -7,7 +7,7 @@ COPY ./docker/package.json ./docker/pnpm-workspace.yaml /usr/src/app/
|
||||
# We have to use --no-frozen-lockfile due to CKEditor patches
|
||||
RUN pnpm install --no-frozen-lockfile --prod && pnpm rebuild
|
||||
|
||||
FROM node:24.11.1-bullseye-slim
|
||||
FROM node:24.11.0-bullseye-slim
|
||||
# Install only runtime dependencies
|
||||
RUN apt-get update && \
|
||||
apt-get install -y --no-install-recommends \
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM node:24.11.1-alpine AS builder
|
||||
FROM node:24.11.0-alpine AS builder
|
||||
RUN corepack enable
|
||||
|
||||
# Install native dependencies since we might be building cross-platform.
|
||||
@@ -7,7 +7,7 @@ COPY ./docker/package.json ./docker/pnpm-workspace.yaml /usr/src/app/
|
||||
# We have to use --no-frozen-lockfile due to CKEditor patches
|
||||
RUN pnpm install --no-frozen-lockfile --prod && pnpm rebuild
|
||||
|
||||
FROM node:24.11.1-alpine
|
||||
FROM node:24.11.0-alpine
|
||||
# Install runtime dependencies
|
||||
RUN apk add --no-cache su-exec shadow
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM node:24.11.1-alpine AS builder
|
||||
FROM node:24.11.0-alpine AS builder
|
||||
RUN corepack enable
|
||||
|
||||
# Install native dependencies since we might be building cross-platform.
|
||||
@@ -7,7 +7,7 @@ COPY ./docker/package.json ./docker/pnpm-workspace.yaml /usr/src/app/
|
||||
# We have to use --no-frozen-lockfile due to CKEditor patches
|
||||
RUN pnpm install --no-frozen-lockfile --prod && pnpm rebuild
|
||||
|
||||
FROM node:24.11.1-alpine
|
||||
FROM node:24.11.0-alpine
|
||||
# Create a non-root user with configurable UID/GID
|
||||
ARG USER=trilium
|
||||
ARG UID=1001
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM node:24.11.1-bullseye-slim AS builder
|
||||
FROM node:24.11.0-bullseye-slim AS builder
|
||||
RUN corepack enable
|
||||
|
||||
# Install native dependencies since we might be building cross-platform.
|
||||
@@ -7,7 +7,7 @@ COPY ./docker/package.json ./docker/pnpm-workspace.yaml /usr/src/app/
|
||||
# We have to use --no-frozen-lockfile due to CKEditor patches
|
||||
RUN pnpm install --no-frozen-lockfile --prod && pnpm rebuild
|
||||
|
||||
FROM node:24.11.1-bullseye-slim
|
||||
FROM node:24.11.0-bullseye-slim
|
||||
# Create a non-root user with configurable UID/GID
|
||||
ARG USER=trilium
|
||||
ARG UID=1001
|
||||
|
||||
@@ -104,7 +104,7 @@
|
||||
"is-animated": "2.0.2",
|
||||
"is-svg": "6.1.0",
|
||||
"jimp": "1.6.0",
|
||||
"js-yaml": "4.1.1",
|
||||
"js-yaml": "4.1.0",
|
||||
"marked": "16.4.2",
|
||||
"mime-types": "3.0.1",
|
||||
"multer": "2.0.2",
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
"preact": "10.27.2",
|
||||
"preact-iso": "2.11.0",
|
||||
"preact-render-to-string": "6.6.3",
|
||||
"react-i18next": "16.3.1"
|
||||
"react-i18next": "16.2.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@preact/preset-vite": "2.10.2",
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
"@playwright/test": "1.56.1",
|
||||
"@triliumnext/server": "workspace:*",
|
||||
"@types/express": "5.0.5",
|
||||
"@types/node": "24.10.1",
|
||||
"@types/node": "24.10.0",
|
||||
"@vitest/coverage-v8": "3.2.4",
|
||||
"@vitest/ui": "3.2.4",
|
||||
"chalk": "5.6.2",
|
||||
@@ -83,7 +83,7 @@
|
||||
"url": "https://github.com/TriliumNext/Trilium/issues"
|
||||
},
|
||||
"homepage": "https://triliumnotes.org",
|
||||
"packageManager": "pnpm@10.22.0",
|
||||
"packageManager": "pnpm@10.21.0",
|
||||
"pnpm": {
|
||||
"patchedDependencies": {
|
||||
"@ckeditor/ckeditor5-mention": "patches/@ckeditor__ckeditor5-mention.patch",
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
"ckeditor5-premium-features": "47.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@smithy/middleware-retry": "4.4.10",
|
||||
"@smithy/middleware-retry": "4.4.7",
|
||||
"@types/jquery": "3.5.33"
|
||||
}
|
||||
}
|
||||
|
||||
773
pnpm-lock.yaml
generated
773
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user