chore(react/type_widgets): get render to work

This commit is contained in:
Elian Doran 2025-09-21 22:33:11 +03:00
parent 70d0a5441a
commit 344607d437
No known key found for this signature in database
2 changed files with 10 additions and 9 deletions

View File

@ -6,15 +6,22 @@ import Alert from "../react/Alert";
import "./Render.css"; import "./Render.css";
import { t } from "../../services/i18n"; import { t } from "../../services/i18n";
import RawHtml from "../react/RawHtml"; import RawHtml from "../react/RawHtml";
import { useTriliumEvent } from "../react/hooks";
export default function Render({ note }: TypeWidgetProps) { export default function Render({ note, noteContext }: TypeWidgetProps) {
const contentRef = useRef<HTMLDivElement>(null); const contentRef = useRef<HTMLDivElement>(null);
const [ renderNotesFound, setRenderNotesFound ] = useState(false); const [ renderNotesFound, setRenderNotesFound ] = useState(false);
useEffect(() => { function refresh() {
if (!contentRef) return; if (!contentRef) return;
render.render(note, refToJQuerySelector(contentRef)).then(setRenderNotesFound); render.render(note, refToJQuerySelector(contentRef)).then(setRenderNotesFound);
}, [ note ]); }
useEffect(refresh, [ note ]);
useTriliumEvent("renderActiveNote", () => {
if (noteContext?.isActive()) return;
refresh();
});
return ( return (
<div className="note-detail-render note-detail-printable"> <div className="note-detail-render note-detail-printable">

View File

@ -32,12 +32,6 @@ export default class RenderTypeWidget extends TypeWidget {
this.$noteDetailRenderContent.empty(); this.$noteDetailRenderContent.empty();
} }
renderActiveNoteEvent() {
if (this.noteContext?.isActive()) {
this.refresh();
}
}
async executeWithContentElementEvent({ resolve, ntxId }: EventData<"executeWithContentElement">) { async executeWithContentElementEvent({ resolve, ntxId }: EventData<"executeWithContentElement">) {
if (!this.isNoteContext(ntxId)) { if (!this.isNoteContext(ntxId)) {
return; return;