mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 09:46:22 +00:00
use composition input
This commit is contained in:
@@ -7,6 +7,7 @@ import ee from 'browser/main/lib/eventEmitter'
|
|||||||
import NewNoteButton from 'browser/main/NewNoteButton'
|
import NewNoteButton from 'browser/main/NewNoteButton'
|
||||||
import i18n from 'browser/lib/i18n'
|
import i18n from 'browser/lib/i18n'
|
||||||
import debounce from 'lodash/debounce'
|
import debounce from 'lodash/debounce'
|
||||||
|
import CInput from 'react-composition-input'
|
||||||
|
|
||||||
class TopBar extends React.Component {
|
class TopBar extends React.Component {
|
||||||
constructor (props) {
|
constructor (props) {
|
||||||
@@ -15,10 +16,7 @@ class TopBar extends React.Component {
|
|||||||
this.state = {
|
this.state = {
|
||||||
search: '',
|
search: '',
|
||||||
searchOptions: [],
|
searchOptions: [],
|
||||||
isSearching: false,
|
isSearching: false
|
||||||
isAlphabet: false,
|
|
||||||
isIME: false,
|
|
||||||
isConfirmTranslation: false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.focusSearchHandler = () => {
|
this.focusSearchHandler = () => {
|
||||||
@@ -30,6 +28,7 @@ class TopBar extends React.Component {
|
|||||||
this.handleSearchFocus = this.handleSearchFocus.bind(this)
|
this.handleSearchFocus = this.handleSearchFocus.bind(this)
|
||||||
this.handleSearchBlur = this.handleSearchBlur.bind(this)
|
this.handleSearchBlur = this.handleSearchBlur.bind(this)
|
||||||
this.handleSearchChange = this.handleSearchChange.bind(this)
|
this.handleSearchChange = this.handleSearchChange.bind(this)
|
||||||
|
this.handleSearchClearButton = this.handleSearchClearButton.bind(this)
|
||||||
|
|
||||||
this.debouncedUpdateKeyword = debounce((keyword) => {
|
this.debouncedUpdateKeyword = debounce((keyword) => {
|
||||||
this.context.router.push(`/searched/${encodeURIComponent(keyword)}`)
|
this.context.router.push(`/searched/${encodeURIComponent(keyword)}`)
|
||||||
@@ -91,7 +90,7 @@ class TopBar extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleSearchChange (e) {
|
handleSearchChange (e) {
|
||||||
const keyword = this.refs.searchInput.value
|
const keyword = e.target.value
|
||||||
this.debouncedUpdateKeyword(keyword)
|
this.debouncedUpdateKeyword(keyword)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,7 +129,7 @@ class TopBar extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleCodeInit () {
|
handleCodeInit () {
|
||||||
ee.emit('top:search', this.refs.searchInput.value)
|
ee.emit('top:search', this.refs.searchInput.value || '')
|
||||||
}
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
@@ -148,10 +147,10 @@ class TopBar extends React.Component {
|
|||||||
tabIndex='-1'
|
tabIndex='-1'
|
||||||
ref='search'
|
ref='search'
|
||||||
>
|
>
|
||||||
<input
|
<CInput
|
||||||
ref='searchInput'
|
ref='searchInput'
|
||||||
value={this.state.search}
|
value={this.state.search}
|
||||||
onChange={(e) => this.debouncedUpdateKeyword(this.refs.searchInput.value)}
|
onInputChange={this.handleSearchChange}
|
||||||
onKeyDown={this.handleKeyDown}
|
onKeyDown={this.handleKeyDown}
|
||||||
placeholder={i18n.__('Search')}
|
placeholder={i18n.__('Search')}
|
||||||
type='text'
|
type='text'
|
||||||
@@ -159,7 +158,7 @@ class TopBar extends React.Component {
|
|||||||
/>
|
/>
|
||||||
{this.state.search !== '' &&
|
{this.state.search !== '' &&
|
||||||
<button styleName='control-search-input-clear'
|
<button styleName='control-search-input-clear'
|
||||||
onClick={this.handleSearchChange}
|
onClick={this.handleSearchClearButton}
|
||||||
>
|
>
|
||||||
<i className='fa fa-fw fa-times' />
|
<i className='fa fa-fw fa-times' />
|
||||||
<span styleName='control-search-input-clear-tooltip'>{i18n.__('Clear Search')}</span>
|
<span styleName='control-search-input-clear-tooltip'>{i18n.__('Clear Search')}</span>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "boost",
|
"name": "boost",
|
||||||
"productName": "Boostnote",
|
"productName": "Boostnote",
|
||||||
"version": "0.11.16",
|
"version": "0.11.16",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"description": "Boostnote",
|
"description": "Boostnote",
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
@@ -101,6 +101,7 @@
|
|||||||
"react-autosuggest": "^9.4.0",
|
"react-autosuggest": "^9.4.0",
|
||||||
"react-codemirror": "^0.3.0",
|
"react-codemirror": "^0.3.0",
|
||||||
"react-color": "^2.2.2",
|
"react-color": "^2.2.2",
|
||||||
|
"react-composition-input": "^1.1.1",
|
||||||
"react-debounce-render": "^4.0.1",
|
"react-debounce-render": "^4.0.1",
|
||||||
"react-dom": "^15.0.2",
|
"react-dom": "^15.0.2",
|
||||||
"react-image-carousel": "^2.0.18",
|
"react-image-carousel": "^2.0.18",
|
||||||
|
|||||||
@@ -7524,6 +7524,13 @@ react-color@^2.2.2:
|
|||||||
reactcss "^1.2.0"
|
reactcss "^1.2.0"
|
||||||
tinycolor2 "^1.4.1"
|
tinycolor2 "^1.4.1"
|
||||||
|
|
||||||
|
react-composition-input@^1.1.1:
|
||||||
|
version "1.1.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/react-composition-input/-/react-composition-input-1.1.1.tgz#51fc711f8b1c7d11e39210639175f0b48de44aff"
|
||||||
|
integrity sha512-xzRAUvsrEdSjI1tQXu3ouPHkHVZnunx6OoAFsv4YxVV6fIBHc9XZuxkmJwoxSatPxJ6WN94k91PBWQTsL6h/ZA==
|
||||||
|
dependencies:
|
||||||
|
prop-types "^15.6.2"
|
||||||
|
|
||||||
react-css-modules@^3.7.6:
|
react-css-modules@^3.7.6:
|
||||||
version "3.7.10"
|
version "3.7.10"
|
||||||
resolved "https://registry.yarnpkg.com/react-css-modules/-/react-css-modules-3.7.10.tgz#300da561e550eeec5ebc0bc8c7d51d77d88ae2d7"
|
resolved "https://registry.yarnpkg.com/react-css-modules/-/react-css-modules-3.7.10.tgz#300da561e550eeec5ebc0bc8c7d51d77d88ae2d7"
|
||||||
|
|||||||
Reference in New Issue
Block a user