2025-11-22 19:11:20 +02:00
|
|
|
import { useContext, useEffect, useState } from "preact/hooks";
|
2025-11-22 19:07:50 +02:00
|
|
|
import Modal from "../react/Modal";
|
|
|
|
|
import "./PopupEditor.css";
|
|
|
|
|
import { useTriliumEvent } from "../react/hooks";
|
|
|
|
|
import NoteTitleWidget from "../note_title";
|
|
|
|
|
import NoteIcon from "../note_icon";
|
2025-11-22 19:11:20 +02:00
|
|
|
import NoteContext from "../../components/note_context";
|
2025-11-22 19:25:27 +02:00
|
|
|
import { NoteContextContext, ParentComponent } from "../react/react_utils";
|
2025-11-22 19:17:50 +02:00
|
|
|
import NoteDetail from "../NoteDetail";
|
2025-11-22 19:11:20 +02:00
|
|
|
|
|
|
|
|
const noteContext = new NoteContext("_popup-editor");
|
2025-11-22 19:07:50 +02:00
|
|
|
|
|
|
|
|
export default function PopupEditor() {
|
|
|
|
|
const [ shown, setShown ] = useState(false);
|
2025-11-22 19:11:20 +02:00
|
|
|
|
|
|
|
|
useTriliumEvent("openInPopup", async ({ noteIdOrPath }) => {
|
|
|
|
|
await noteContext.setNote(noteIdOrPath, {
|
|
|
|
|
viewScope: {
|
|
|
|
|
readOnlyTemporarilyDisabled: true
|
|
|
|
|
}
|
|
|
|
|
});
|
2025-11-22 19:07:50 +02:00
|
|
|
|
|
|
|
|
setShown(true);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return (
|
2025-11-22 19:25:27 +02:00
|
|
|
<NoteContextContext.Provider value={noteContext}>
|
|
|
|
|
<Modal
|
|
|
|
|
title={<TitleRow />}
|
|
|
|
|
className="popup-editor-dialog"
|
|
|
|
|
size="lg"
|
|
|
|
|
show={shown}
|
|
|
|
|
onHidden={() => setShown(false)}
|
|
|
|
|
>
|
|
|
|
|
<NoteDetail />
|
|
|
|
|
</Modal>
|
|
|
|
|
</NoteContextContext.Provider>
|
2025-11-22 19:07:50 +02:00
|
|
|
)
|
|
|
|
|
}
|
2025-11-22 19:17:50 +02:00
|
|
|
|
|
|
|
|
export function TitleRow() {
|
|
|
|
|
return (
|
|
|
|
|
<div className="title-row">
|
|
|
|
|
<NoteIcon />
|
|
|
|
|
<NoteTitleWidget />
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|