From efb80649dc524d152b424c8c539e4fee33450403 Mon Sep 17 00:00:00 2001 From: bobzel Date: Thu, 22 Aug 2024 15:54:00 -0400 Subject: added '@' prefix syntax to show metadata field value in keywords box --- src/client/views/KeywordBox.tsx | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/client/views/KeywordBox.tsx b/src/client/views/KeywordBox.tsx index fc9c38a11..20cb63d66 100644 --- a/src/client/views/KeywordBox.tsx +++ b/src/client/views/KeywordBox.tsx @@ -13,6 +13,7 @@ import { DragManager } from '../util/DragManager'; import { SnappingManager } from '../util/SnappingManager'; import { DocumentView } from './nodes/DocumentView'; import { ObservableReactComponent } from './ObservableReactComponent'; +import { undoable } from '../util/UndoManager'; interface KeywordItemProps { doc: Doc; @@ -123,9 +124,18 @@ export class KeywordItem extends ObservableReactComponent { }; render() { + const keyword = this._props.keyword.replace(/^@/, ''); + const metadata = this._props.keyword.startsWith('@'); return (
- {this._props.keyword} + {metadata ? ( + + {keyword}  + {this._props.doc[keyword] as string}{' '} + + ) : ( + keyword + )} {this.props.isEditing && }
); @@ -218,7 +228,7 @@ export class KeywordBox extends ObservableReactComponent { * Adds the keyword to the document. * @param keyword */ - submitLabel = (keyword: string) => { + submitLabel = undoable((keyword: string) => { // If the active Dashboard does not have a keyword collection, create it. if (Doc.ActiveDashboard && !Doc.ActiveDashboard.myKeywordCollections) { Doc.ActiveDashboard.myKeywordCollections = new List(); @@ -261,7 +271,7 @@ export class KeywordBox extends ObservableReactComponent { this._props.doc![DocData][`${submittedLabel}`] = true; this._currentInput = ''; // Clear the input box } - }; + }, 'added doc label'); @action onInputChange = (e: React.ChangeEvent) => { -- cgit v1.2.3-70-g09d2