Updating Rich Text editor x 1
This commit is contained in:
parent
f7e0528d3b
commit
2387c3314a
@ -86,21 +86,3 @@ export function normalizePoll(poll) {
|
|||||||
|
|
||||||
return normalPoll;
|
return normalPoll;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// <p><h1>attention!</h1></p>
|
|
||||||
// <p>#test @bob #nice https://bob.com http://techcrunch.com <del>strike it</del></p>
|
|
||||||
// <p><del>https://twitter.com</del></p>
|
|
||||||
// <p><em>@bobitalic</em></p>
|
|
||||||
// <p><pre><code>jonincode</code></pre></p>
|
|
||||||
|
|
||||||
// # attention!
|
|
||||||
// #test @bob #nice https://bob.com http://techcrunch.com ~~strike it~~
|
|
||||||
|
|
||||||
// ~~https://twitter.com~~
|
|
||||||
|
|
||||||
// _@bobitalic_
|
|
||||||
|
|
||||||
// ```
|
|
||||||
// jonincode
|
|
||||||
// ```
|
|
@ -210,30 +210,6 @@ export default class AutosuggestTextbox extends ImmutablePureComponent {
|
|||||||
} = this.props
|
} = this.props
|
||||||
|
|
||||||
const { suggestionsHidden } = this.state
|
const { suggestionsHidden } = this.state
|
||||||
const style = {
|
|
||||||
direction: isRtl(value) ? 'rtl' : 'ltr',
|
|
||||||
}
|
|
||||||
|
|
||||||
const textareaClasses = CX({
|
|
||||||
default: 1,
|
|
||||||
font: 1,
|
|
||||||
wrap: 1,
|
|
||||||
resizeNone: 1,
|
|
||||||
bgTransparent: 1,
|
|
||||||
outlineNone: 1,
|
|
||||||
lineHeight125: 1,
|
|
||||||
colorPrimary: 1,
|
|
||||||
width100PC: !small,
|
|
||||||
pt15: !small,
|
|
||||||
px15: !small,
|
|
||||||
px10: small,
|
|
||||||
pb10: !small,
|
|
||||||
fs16PX: !small,
|
|
||||||
fs14PX: small,
|
|
||||||
heightMax200PX: small,
|
|
||||||
heightMax80VH: !small,
|
|
||||||
heightMin80PX: !small,
|
|
||||||
})
|
|
||||||
|
|
||||||
const textareaContainerClasses = CX({
|
const textareaContainerClasses = CX({
|
||||||
default: 1,
|
default: 1,
|
||||||
@ -254,7 +230,6 @@ export default class AutosuggestTextbox extends ImmutablePureComponent {
|
|||||||
inputRef={this.setTextbox}
|
inputRef={this.setTextbox}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
placeholder={placeholder}
|
placeholder={placeholder}
|
||||||
autoFocus={autoFocus}
|
|
||||||
value={value}
|
value={value}
|
||||||
valueMarkdown={valueMarkdown}
|
valueMarkdown={valueMarkdown}
|
||||||
onChange={this.onChange}
|
onChange={this.onChange}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import {
|
import {
|
||||||
|
getDefaultKeyBinding,
|
||||||
Editor,
|
Editor,
|
||||||
EditorState,
|
EditorState,
|
||||||
CompositeDecorator,
|
CompositeDecorator,
|
||||||
@ -86,7 +87,6 @@ export default class Composer extends PureComponent {
|
|||||||
valueMarkdown: PropTypes.string,
|
valueMarkdown: PropTypes.string,
|
||||||
onChange: PropTypes.func,
|
onChange: PropTypes.func,
|
||||||
onKeyDown: PropTypes.func,
|
onKeyDown: PropTypes.func,
|
||||||
onKeyUp: PropTypes.func,
|
|
||||||
onFocus: PropTypes.func,
|
onFocus: PropTypes.func,
|
||||||
onBlur: PropTypes.func,
|
onBlur: PropTypes.func,
|
||||||
onPaste: PropTypes.func,
|
onPaste: PropTypes.func,
|
||||||
@ -94,6 +94,7 @@ export default class Composer extends PureComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
state = {
|
state = {
|
||||||
|
active: false,
|
||||||
editorState: EditorState.createEmpty(compositeDecorator),
|
editorState: EditorState.createEmpty(compositeDecorator),
|
||||||
plainText: this.props.value,
|
plainText: this.props.value,
|
||||||
}
|
}
|
||||||
@ -158,8 +159,34 @@ export default class Composer extends PureComponent {
|
|||||||
this.props.onChange(null, plainText, markdownString, selectionStart)
|
this.props.onChange(null, plainText, markdownString, selectionStart)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleOnFocus = () => {
|
||||||
|
document.addEventListener('paste', this.handleOnPaste)
|
||||||
|
this.setState({ active: true })
|
||||||
|
this.props.onFocus()
|
||||||
|
}
|
||||||
|
|
||||||
|
handleOnBlur = () => {
|
||||||
|
document.removeEventListener('paste', this.handleOnPaste, true)
|
||||||
|
this.setState({ active: false })
|
||||||
|
this.props.onBlur()
|
||||||
|
}
|
||||||
|
|
||||||
focus = () => {
|
focus = () => {
|
||||||
this.textbox.editor.focus()
|
this.textbox.focus()
|
||||||
|
}
|
||||||
|
|
||||||
|
handleOnPaste = (e) => {
|
||||||
|
if (this.state.active) {
|
||||||
|
this.props.onPaste(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
keyBindingFn = (e) => {
|
||||||
|
if (e.type === 'keydown') {
|
||||||
|
this.props.onKeyDown(e)
|
||||||
|
}
|
||||||
|
|
||||||
|
return getDefaultKeyBinding(e)
|
||||||
}
|
}
|
||||||
|
|
||||||
handleKeyCommand = (command) => {
|
handleKeyCommand = (command) => {
|
||||||
@ -193,7 +220,6 @@ export default class Composer extends PureComponent {
|
|||||||
disabled,
|
disabled,
|
||||||
placeholder,
|
placeholder,
|
||||||
onKeyDown,
|
onKeyDown,
|
||||||
onKeyUp,
|
|
||||||
onFocus,
|
onFocus,
|
||||||
onBlur,
|
onBlur,
|
||||||
onPaste,
|
onPaste,
|
||||||
@ -231,7 +257,6 @@ export default class Composer extends PureComponent {
|
|||||||
>
|
>
|
||||||
<Editor
|
<Editor
|
||||||
blockStyleFn={getBlockStyle}
|
blockStyleFn={getBlockStyle}
|
||||||
// customStyleMap={styleMap}
|
|
||||||
editorState={editorState}
|
editorState={editorState}
|
||||||
handleKeyCommand={this.handleKeyCommand}
|
handleKeyCommand={this.handleKeyCommand}
|
||||||
onChange={this.onChange}
|
onChange={this.onChange}
|
||||||
@ -239,8 +264,9 @@ export default class Composer extends PureComponent {
|
|||||||
placeholder={placeholder}
|
placeholder={placeholder}
|
||||||
ref={this.setRef}
|
ref={this.setRef}
|
||||||
readOnly={disabled}
|
readOnly={disabled}
|
||||||
onBlur={onBlur}
|
onBlur={this.handleOnBlur}
|
||||||
onFocus={onFocus}
|
onFocus={this.handleOnFocus}
|
||||||
|
keyBindingFn={this.keyBindingFn}
|
||||||
stripPastedStyles
|
stripPastedStyles
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user