chore(quick_edit): inject note context

This commit is contained in:
Elian Doran
2025-11-22 19:11:20 +02:00
parent 31180afbd1
commit 29f049c411
2 changed files with 21 additions and 9 deletions

View File

@@ -1,17 +1,34 @@
import { useState } from "preact/hooks";
import { useContext, useEffect, useState } from "preact/hooks";
import Modal from "../react/Modal";
import "./PopupEditor.css";
import { useTriliumEvent } from "../react/hooks";
import NoteTitleWidget from "../note_title";
import NoteIcon from "../note_icon";
import NoteContext from "../../components/note_context";
import { ParentComponent } from "../react/react_utils";
const noteContext = new NoteContext("_popup-editor");
export default function PopupEditor() {
const [ shown, setShown ] = useState(false);
const parentComponent = useContext(ParentComponent);
useTriliumEvent("openInPopup", async ({ noteIdOrPath }) => {
await noteContext.setNote(noteIdOrPath, {
viewScope: {
readOnlyTemporarilyDisabled: true
}
});
useTriliumEvent("openInPopup", () => {
setShown(true);
});
// Inject the note context
useEffect(() => {
if (!shown || !parentComponent) return;
parentComponent.handleEventInChildren("activeContextChanged", { noteContext });
}, [ shown ]);
return (
<Modal
title={(