import { Button } from '@wordpress/components'; import { RichText } from '@wordpress/editor'; import { Component } from '@wordpress/element'; import { Icon, check, cancelCircleFilled, arrowDown, arrowUp } from '@wordpress/icons'; export const ItemEditor = class extends Component { constructor() { super( ...arguments ); this.toggleDone = this.toggleDone.bind( this ); this.updateValue = this.updateValue.bind( this ); this.onSetup = this.onSetup.bind( this ); this.editor = undefined; } // @TODO: Please update https://github.com/Automattic/wp-calypso/issues/58453 if you are refactoring away from UNSAFE_* lifecycle methods! UNSAFE_componentWillReceiveProps( newProps ) { if ( newProps.shouldFocus && ! this.props.shouldFocus ) { window.requestAnimationFrame( () => { this.editor.focus(); } ); } } toggleDone() { const { item } = this.props; item.done = ! item.done; this.props.onChange( item ); } updateValue( newValue ) { const { item } = this.props; item.value = newValue; this.props.onChange( item ); } onSetup( editor ) { const { shouldFocus } = this.props; this.editor = editor; if ( shouldFocus ) { window.requestAnimationFrame( () => { this.editor.focus(); } ); } } render() { const { item, moveUp, moveDown, canMoveUp, canMoveDown, classNames, onDelete } = this.props; const { done, value } = item; return (