import { useMemo, useRef } from "preact/hooks"; import { useLegacyImperativeHandlers, useTriliumEvents } from "../react/hooks"; import AttributeEditor, { AttributeEditorImperativeHandlers } from "./components/AttributeEditor"; import { TabContext } from "./ribbon-interface"; export default function OwnedAttributesTab({ note, hidden, activate, ntxId, ...restProps }: TabContext) { const api = useRef(null); useTriliumEvents([ "addNewLabel", "addNewRelation" ], ({ ntxId: eventNtxId }) => { if (ntxId === eventNtxId) { activate(); } }); // Interaction with the attribute editor. useLegacyImperativeHandlers(useMemo(() => ({ saveAttributesCommand: () => api.current?.save(), reloadAttributesCommand: () => api.current?.refresh(), updateAttributeListCommand: ({ attributes }) => api.current?.renderOwnedAttributes(attributes) }), [ api ])); return (
{ note && (
) }