Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

974 B
Raw Blame
import type Term from '../model/Term';
import {
  usePopupContextUpdate,
  usePopupStore,
} from '../signal/definitionPopup';
import { useIsPopup } from '../signal/pdfViewer';
import { DefinitionLookup } from './DefinitionLookup/index';

interface IProps {
  terms: Term[];
}

/**
 * Wrapper on `DefinitionLookup` which positions a list of terms absolutely
 * positioned on the screen (overlayed on top of the PDF)
 */
export function AbsoluteDefinitionLookups(props: IProps) {
  const isPopup = useIsPopup();
  const popupDispatchCtx = usePopupContextUpdate(isPopup);
  const element = usePopupStore(isPopup).element;

  return (
    <DefinitionLookup
      isPinsWindow={false}
      term={props.terms[0]}
      index={0}
      addNextTerm={(term) => {
        popupDispatchCtx({ type: 'ADD_NEXT_TERM', term });
      }}
      removeNextTerms={(index) => {
        popupDispatchCtx({ type: 'REMOVE_NEXT_TERMS', index });
      }}
      anchorRef={element()}
    />
  );
}