/*! * Copyright (c) 2024 PLANKA Software GmbH * Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md */ import React, { useCallback, useImperativeHandle } from 'react'; import PropTypes from 'prop-types'; import { useTranslation } from 'react-i18next'; import { Dropdown, Input } from 'semantic-ui-react'; import { useNestedRef } from '../../../hooks'; import WEBHOOK_EVENTS from '../../../constants/WebhookEvents'; import styles from './Editor.module.scss'; const Editor = React.forwardRef(({ data, isReadOnly, onFieldChange }, ref) => { const [t] = useTranslation(); const [nameFieldRef, handleNameFieldRef] = useNestedRef('inputRef'); const [urlFieldRef, handleUrlFieldRef] = useNestedRef('inputRef'); const focusNameField = useCallback(() => { nameFieldRef.current.focus({ preventScroll: true, }); }, [nameFieldRef]); const selectNameField = useCallback(() => { nameFieldRef.current.select(); }, [nameFieldRef]); const selectUrlField = useCallback(() => { urlFieldRef.current.select(); }, [urlFieldRef]); useImperativeHandle( ref, () => ({ focusNameField, selectNameField, selectUrlField, }), [focusNameField, selectNameField, selectUrlField], ); return ( <>