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
chore(react/ribbon): unable to create notes in attribute editor
Elian Doran82914fc2aa28
diff --git a/apps/client/src/widgets/attribute_widgets/attribute_editor.ts b/apps/client/src/widgets/attribute_widgets/attribute_editor.tsindex 6c732b779f..87db417f5e 100644--- a/apps/client/src/widgets/attribute_widgets/attribute_editor.ts+++ b/apps/client/src/widgets/attribute_widgets/attribute_editor.ts@@ -18,29 +18,7 @@ export default class AttributeEditorWidget extends NoteContextAwareWidget implem}}- dataChanged() {- this.lastUpdatedNoteId = this.noteId;- }-- async createNoteForReferenceLink(title: string) {- let result;- if (this.notePath) {- result = await noteCreateService.createNoteWithTypePrompt(this.notePath, {- activate: false,- title: title- });- }-- return result?.note?.getBestNotePathString();- }-async updateAttributeList(attributes: FAttribute[]) {await this.renderOwnedAttributes(attributes, false);}-- focus() {- this.$editor.trigger("focus");--- }}diff --git a/apps/client/src/widgets/ribbon/OwnedAttributesTab.tsx b/apps/client/src/widgets/ribbon/OwnedAttributesTab.tsxindex 2c168841f5..daf9d14951 100644--- a/apps/client/src/widgets/ribbon/OwnedAttributesTab.tsx+++ b/apps/client/src/widgets/ribbon/OwnedAttributesTab.tsx@@ -1,10 +1,16 @@import AttributeEditor from "./components/AttributeEditor";import { TabContext } from "./ribbon-interface";-export default function OwnedAttributesTab({ note }: TabContext) {+export default function OwnedAttributesTab({ note, notePath, componentId }: TabContext) {return (<div className="attribute-list">- { note && <AttributeEditor note={note} /> }+ { note && (+ <AttributeEditor+ componentId={componentId}+ note={note}+ notePath={notePath}+ />+ )}</div>)}\ No newline at end of filediff --git a/apps/client/src/widgets/ribbon/components/AttributeEditor.tsx b/apps/client/src/widgets/ribbon/components/AttributeEditor.tsxindex 7a82962cce..2ef34d22e0 100644--- a/apps/client/src/widgets/ribbon/components/AttributeEditor.tsx+++ b/apps/client/src/widgets/ribbon/components/AttributeEditor.tsx@@ -20,6 +20,7 @@ import contextMenu from "../../../menus/context_menu";import type { CommandData, FilteredCommandNames } from "../../../components/app_context";import { AttributeType } from "@triliumnext/commons";import attributes from "../../../services/attributes";+import note_create from "../../../services/note_create";type AttributeCommandNames = FilteredCommandNames<CommandData>;@@ -75,9 +76,9 @@ const mentionSetup: MentionFeed[] = [];-export default function AttributeEditor({ note, componentId }: { note: FNote, componentId: string }) {+export default function AttributeEditor({ note, componentId, notePath }: { note: FNote, componentId: string, notePath?: string | null }) {const parentComponent = useContext(ParentComponent);- injectLoadReferenceLinkTitle(parentComponent);+ injectLoadReferenceLinkTitle(parentComponent, notePath);const [ state, setState ] = useState<"normal" | "showHelpTooltip" | "showAttributeDetail">();const [ error, setError ] = useState<unknown>();@@ -373,7 +374,7 @@ function getClickIndex(pos: ModelPosition) {return clickIndex;}-function injectLoadReferenceLinkTitle(component: Component | null) {+function injectLoadReferenceLinkTitle(component: Component | null, notePath?: string | null) {if (!component) return;(component as any).loadReferenceLinkTitle = async ($el: JQuery<HTMLElement>, href: string) => {const { noteId } = link.parseNavigationStateFromUrl(href);@@ -382,4 +383,15 @@ function injectLoadReferenceLinkTitle(component: Component | null) {$el.text(title);}+ (component as any).createNoteForReferenceLink = async (title: string) => {+ let result;+ if (notePath) {+ result = await note_create.createNoteWithTypePrompt(notePath, {+ activate: false,+ title: title+ });+ }++ return result?.note?.getBestNotePathString();+ }}\ No newline at end of file