mirror of
https://github.com/zadam/trilium.git
synced 2025-11-02 11:26:15 +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[]) {
|
async updateAttributeList(attributes: FAttribute[]) {
|
||||||
await this.renderOwnedAttributes(attributes, false);
|
await this.renderOwnedAttributes(attributes, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
focus() {
|
|
||||||
this.$editor.trigger("focus");
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,16 @@
|
|||||||
import AttributeEditor from "./components/AttributeEditor";
|
import AttributeEditor from "./components/AttributeEditor";
|
||||||
import { TabContext } from "./ribbon-interface";
|
import { TabContext } from "./ribbon-interface";
|
||||||
|
|
||||||
export default function OwnedAttributesTab({ note }: TabContext) {
|
export default function OwnedAttributesTab({ note, notePath, componentId }: TabContext) {
|
||||||
return (
|
return (
|
||||||
<div className="attribute-list">
|
<div className="attribute-list">
|
||||||
{ note && <AttributeEditor note={note} /> }
|
{ note && (
|
||||||
|
<AttributeEditor
|
||||||
|
componentId={componentId}
|
||||||
|
note={note}
|
||||||
|
notePath={notePath}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -20,6 +20,7 @@ import contextMenu from "../../../menus/context_menu";
|
|||||||
import type { CommandData, FilteredCommandNames } from "../../../components/app_context";
|
import type { CommandData, FilteredCommandNames } from "../../../components/app_context";
|
||||||
import { AttributeType } from "@triliumnext/commons";
|
import { AttributeType } from "@triliumnext/commons";
|
||||||
import attributes from "../../../services/attributes";
|
import attributes from "../../../services/attributes";
|
||||||
|
import note_create from "../../../services/note_create";
|
||||||
|
|
||||||
type AttributeCommandNames = FilteredCommandNames<CommandData>;
|
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);
|
const parentComponent = useContext(ParentComponent);
|
||||||
injectLoadReferenceLinkTitle(parentComponent);
|
injectLoadReferenceLinkTitle(parentComponent, notePath);
|
||||||
|
|
||||||
const [ state, setState ] = useState<"normal" | "showHelpTooltip" | "showAttributeDetail">();
|
const [ state, setState ] = useState<"normal" | "showHelpTooltip" | "showAttributeDetail">();
|
||||||
const [ error, setError ] = useState<unknown>();
|
const [ error, setError ] = useState<unknown>();
|
||||||
@@ -373,7 +374,7 @@ function getClickIndex(pos: ModelPosition) {
|
|||||||
return clickIndex;
|
return clickIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
function injectLoadReferenceLinkTitle(component: Component | null) {
|
function injectLoadReferenceLinkTitle(component: Component | null, notePath?: string | null) {
|
||||||
if (!component) return;
|
if (!component) return;
|
||||||
(component as any).loadReferenceLinkTitle = async ($el: JQuery<HTMLElement>, href: string) => {
|
(component as any).loadReferenceLinkTitle = async ($el: JQuery<HTMLElement>, href: string) => {
|
||||||
const { noteId } = link.parseNavigationStateFromUrl(href);
|
const { noteId } = link.parseNavigationStateFromUrl(href);
|
||||||
@@ -382,4 +383,15 @@ function injectLoadReferenceLinkTitle(component: Component | null) {
|
|||||||
|
|
||||||
$el.text(title);
|
$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