import { ReactRenderer } from "../../../../../node_modules/.pnpm/@tiptap_react@2.14.0_@tiptap_core@2.14.0_@tiptap_pm@2.14.0__@tiptap_pm@2.14.0_react-dom_dfcea6344d2cfce7c917261cb98bda6f/node_modules/@tiptap/react/dist/index.js";
import tippy from "../../../../../node_modules/.pnpm/tippy.js@6.3.7/node_modules/tippy.js/dist/tippy.esm.js";
import DatasourceFieldList from "./DatasourceFieldList.js";
const config = {
  char: "{{",
  // Allow all previous characters
  allowedPrefixes: null,
  render: () => {
    let component;
    let popup;
    return {
      onStart: (props) => {
        component = new ReactRenderer(DatasourceFieldList, {
          props,
          editor: props.editor
        });
        if (!props.clientRect) {
          return;
        }
        popup = tippy("body", {
          getReferenceClientRect: props.clientRect,
          appendTo: () => document.body,
          content: component.element,
          showOnCreate: true,
          interactive: true,
          trigger: "manual",
          placement: "bottom-start"
        });
      },
      onUpdate(props) {
        component.updateProps(props);
        if (!props.clientRect) {
          return;
        }
        popup[0].setProps({
          getReferenceClientRect: props.clientRect
        });
      },
      onKeyDown(props) {
        if (props.event.key === "Escape") {
          popup[0].hide();
          return true;
        }
        return component.ref?.onKeyDown(props);
      },
      onExit() {
        popup[0].destroy();
        component.destroy();
      }
    };
  }
};
export {
  config as default
};
//# sourceMappingURL=datasourceFieldSuggestions.js.map
