Mailspring/internal_packages/composer/lib/contenteditable-toolbar.cjsx
Ben Gotow e4889b390f refactor(participants): Use DragDropMixin, Menu
Summary:
This diff replaces the participant text fields with ones based on TokenizingTextField, a new core
component that handles autocompletion, drag and drop of tokens, etc.

Fix large queries overloading SQLite size limits

New general purpose tokenized text field with token selection, copy paste, etc

Move pre-send logic to the view since DraftStore requests from db, which may not have settled

Tests - still a WIP

Support for contextual menus instead of X

Test Plan: Run new tests. Needs many more, but have higher priority things to fix

Reviewers: evan

Reviewed By: evan

Differential Revision: https://review.inboxapp.com/D1142
2015-02-06 14:46:30 -08:00

36 lines
1.3 KiB
CoffeeScript

React = require 'react'
module.exports =
ContenteditableToolbar = React.createClass
render: ->
style =
display: @state.show and 'initial' or 'none'
<div className="compose-toolbar-wrap" onBlur={@onBlur}>
<button className="btn btn-icon btn-formatting"
onClick={=> @setState { show: !@state.show }}
><i className="fa fa-font"></i></button>
<div ref="toolbar" className="compose-toolbar" style={style}>
<button className="btn btn-bold" onClick={@onClick} data-command-name="bold"><strong>B</strong></button>
<button className="btn btn-italic" onClick={@onClick} data-command-name="italic"><em>I</em></button>
<button className="btn btn-underline" onClick={@onClick} data-command-name="underline"><span style={'textDecoration': 'underline'}>U</span></button>
</div>
</div>
getInitialState: ->
show: false
componentDidUpdate: (lastProps, lastState) ->
if !lastState.show and @state.show
@refs.toolbar.getDOMNode().focus()
onClick: (event) ->
cmd = event.currentTarget.getAttribute 'data-command-name'
document.execCommand(cmd, false, null)
true
onBlur: (event) ->
target = event.nativeEvent.relatedTarget
if target? and target.getAttribute 'data-command-name'
return
@setState
show: false