import { Button, Popover, FormLabel, Gridicon } from '@automattic/components'; import { Spinner } from '@wordpress/components'; import { localize } from 'i18n-calypso'; import { get, pick } from 'lodash'; import PropTypes from 'prop-types'; import { Component, createRef } from 'react'; import { connect } from 'react-redux'; import AsyncLoad from 'calypso/components/async-load'; import QuerySiteSettings from 'calypso/components/data/query-site-settings'; import FormButton from 'calypso/components/forms/form-button'; import FormFieldset from 'calypso/components/forms/form-fieldset'; import FormTextInput from 'calypso/components/forms/form-text-input'; import InfoPopover from 'calypso/components/info-popover'; import { withLocalizedMoment } from 'calypso/components/localized-moment'; import PostSchedule from 'calypso/components/post-schedule'; import { decodeEntities } from 'calypso/lib/formatting'; import CommentHtmlEditor from 'calypso/my-sites/comments/comment/comment-html-editor'; import { bumpStat, composeAnalytics, recordTracksEvent, withAnalytics, } from 'calypso/state/analytics/actions'; import { editComment } from 'calypso/state/comments/actions'; import { getSiteComment } from 'calypso/state/comments/selectors'; import { removeNotice, successNotice } from 'calypso/state/notices/actions'; import getSiteSetting from 'calypso/state/selectors/get-site-setting'; import { getSelectedSiteId } from 'calypso/state/ui/selectors'; import { hasBlocks } from './utils'; const noop = () => {}; export class CommentEdit extends Component { static propTypes = { commentId: PropTypes.number, toggleEditMode: PropTypes.func, }; state = { authorDisplayName: this.props.authorDisplayName || '', authorUrl: this.props.authorUrl || '', commentContent: this.props.commentContent || '', commentDate: this.props.commentDate || '', isDatePopoverVisible: false, storedCommentDate: '', // Cache whether the comment has blocks. We don't want change that mid-typing (in case the user adds `