import React from 'react' import { useKeyboardListener } from 'actionsack' import Popout from './Popout' import Button from './Button' import ColorPicker from './ColorPicker' import { COLORS } from '../lib/constants' function ModifierButton(props) { return ( ) } function reducer(state, action) { switch (action.type) { case 'BOLD': { return { ...state, bold: !state.bold, } } case 'ITALICS': { return { ...state, italics: !state.italics, } } case 'UNDERLINE': { return { ...state, underline: Number(state.underline + 1) % 3, } } case 'COLOR': { return { ...state, color: action.color, } } } throw new Error('Invalid action') } function SelectionEditor({ onChange }) { const [open, setOpen] = React.useState(false) useKeyboardListener('Escape', () => setOpen(false)) const [state, dispatch] = React.useReducer(reducer, { bold: null, italics: null, underline: null, color: null, }) React.useEffect(() => { onChange(state) }, [onChange, state]) return (