import React from 'react' import { useKeyboardListener } from 'actionsack' import Popout from './Popout' import Button from './Button' import ColorPicker from './ColorPicker' import ThemeIcon from './svg/Theme' import { COLORS } from '../lib/constants' const styleEditorButtonStyle = { width: 32, maxWidth: 32, height: 32, borderRadius: '50%' } 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: !state.underline } } case 'COLOR': { return { ...state, color: action.color } } } throw new Error('Invalid action') } function SelectionEditor({ onChange, onClose }) { useKeyboardListener('Escape', onClose) const [visible, setVisible] = React.useState(false) const [open, setOpen] = React.useState(true) const [state, dispatch] = React.useReducer(reducer, { bold: false, italics: false, underline: false, color: null }) React.useEffect(() => { onChange(state) }, [onChange, state]) return (