mirror of
https://github.com/zadam/trilium.git
synced 2025-10-26 07:46:30 +01:00
chore(react/ribbon): unable to create notes in attribute editor
This commit is contained in:
@@ -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");
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
)
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user