|
|
@ -1,9 +1,12 @@
|
|
|
|
import React from 'react'
|
|
|
|
import React from 'react'
|
|
|
|
|
|
|
|
import { useKeyboardListener } from 'actionsack'
|
|
|
|
import Popout from './Popout'
|
|
|
|
import Popout from './Popout'
|
|
|
|
import Button from './Button'
|
|
|
|
import Button from './Button'
|
|
|
|
import ColorPicker from './ColorPicker'
|
|
|
|
import ColorPicker from './ColorPicker'
|
|
|
|
|
|
|
|
import ThemeIcon from './svg/Theme'
|
|
|
|
import { COLORS } from '../lib/constants'
|
|
|
|
import { COLORS } from '../lib/constants'
|
|
|
|
import { useKeyboardListener } from 'actionsack'
|
|
|
|
|
|
|
|
|
|
|
|
const styleEditorButtonStyle = { width: 32, maxWidth: 32, height: 32, borderRadius: '50%' }
|
|
|
|
|
|
|
|
|
|
|
|
function ModifierButton(props) {
|
|
|
|
function ModifierButton(props) {
|
|
|
|
return (
|
|
|
|
return (
|
|
|
@ -50,9 +53,10 @@ function reducer(state, action) {
|
|
|
|
throw new Error('Invalid action')
|
|
|
|
throw new Error('Invalid action')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function SelectionEditor({ position, onChange, onClose }) {
|
|
|
|
function SelectionEditor({ onChange, onClose }) {
|
|
|
|
useKeyboardListener('Escape', onClose)
|
|
|
|
useKeyboardListener('Escape', onClose)
|
|
|
|
const [open, setOpen] = React.useState(false)
|
|
|
|
const [visible, setVisible] = React.useState(false)
|
|
|
|
|
|
|
|
const [open, setOpen] = React.useState(true)
|
|
|
|
|
|
|
|
|
|
|
|
const [state, dispatch] = React.useReducer(reducer, {
|
|
|
|
const [state, dispatch] = React.useReducer(reducer, {
|
|
|
|
bold: false,
|
|
|
|
bold: false,
|
|
|
@ -66,14 +70,19 @@ function SelectionEditor({ position, onChange, onClose }) {
|
|
|
|
}, [onChange, state])
|
|
|
|
}, [onChange, state])
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<Popout
|
|
|
|
<div style={{ position: 'relative' }}>
|
|
|
|
hidden={false}
|
|
|
|
<Button
|
|
|
|
pointerRight="16px"
|
|
|
|
title="Style Menu"
|
|
|
|
style={{
|
|
|
|
border
|
|
|
|
zIndex: 100,
|
|
|
|
center
|
|
|
|
...position
|
|
|
|
selected={visible}
|
|
|
|
}}
|
|
|
|
style={styleEditorButtonStyle}
|
|
|
|
|
|
|
|
margin="4px 0 0"
|
|
|
|
|
|
|
|
onClick={() => setVisible(v => !v)}
|
|
|
|
>
|
|
|
|
>
|
|
|
|
|
|
|
|
<ThemeIcon />
|
|
|
|
|
|
|
|
</Button>
|
|
|
|
|
|
|
|
<Popout hidden={!visible} pointerLeft="9px">
|
|
|
|
<div className="colorizer">
|
|
|
|
<div className="colorizer">
|
|
|
|
<div className="modifier">
|
|
|
|
<div className="modifier">
|
|
|
|
<ModifierButton selected={state.bold} onClick={() => dispatch({ type: 'BOLD' })}>
|
|
|
|
<ModifierButton selected={state.bold} onClick={() => dispatch({ type: 'BOLD' })}>
|
|
|
@ -133,6 +142,7 @@ function SelectionEditor({ position, onChange, onClose }) {
|
|
|
|
`}
|
|
|
|
`}
|
|
|
|
</style>
|
|
|
|
</style>
|
|
|
|
</Popout>
|
|
|
|
</Popout>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|