mirror of
https://github.com/zadam/trilium.git
synced 2025-11-02 19:36:12 +01:00
chore(react/ribbon): unable to create notes in attribute editor
This commit is contained in:
@@ -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