mirror of
https://github.com/element-hq/element-web
synced 2024-11-27 11:47:23 +03:00
RTE: Remove dead code, fix <del> styling
This commit is contained in:
parent
c11232742b
commit
8da7b98ad0
1 changed files with 13 additions and 17 deletions
|
@ -29,7 +29,7 @@ marked.setOptions({
|
||||||
|
|
||||||
import {Editor, EditorState, RichUtils, CompositeDecorator,
|
import {Editor, EditorState, RichUtils, CompositeDecorator,
|
||||||
convertFromRaw, convertToRaw, Modifier, EditorChangeType,
|
convertFromRaw, convertToRaw, Modifier, EditorChangeType,
|
||||||
getDefaultKeyBinding, KeyBindingUtil, ContentState, SelectionState} from 'draft-js';
|
getDefaultKeyBinding, KeyBindingUtil, ContentState, ContentBlock, SelectionState} from 'draft-js';
|
||||||
|
|
||||||
import {stateToMarkdown} from 'draft-js-export-markdown';
|
import {stateToMarkdown} from 'draft-js-export-markdown';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
|
@ -296,21 +296,6 @@ export default class MessageComposerInput extends React.Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onKeyDown(ev) {
|
|
||||||
if (ev.keyCode === KeyCode.UP || ev.keyCode === KeyCode.DOWN) {
|
|
||||||
var oldSelectionStart = this.refs.textarea.selectionStart;
|
|
||||||
// Remember the keyCode because React will recycle the synthetic event
|
|
||||||
var keyCode = ev.keyCode;
|
|
||||||
// set a callback so we can see if the cursor position changes as
|
|
||||||
// a result of this event. If it doesn't, we cycle history.
|
|
||||||
setTimeout(() => {
|
|
||||||
if (this.refs.textarea.selectionStart == oldSelectionStart) {
|
|
||||||
this.sentHistory.next(keyCode === KeyCode.UP ? 1 : -1);
|
|
||||||
}
|
|
||||||
}, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onTypingActivity() {
|
onTypingActivity() {
|
||||||
this.isTyping = true;
|
this.isTyping = true;
|
||||||
if (!this.userTypingTimer) {
|
if (!this.userTypingTimer) {
|
||||||
|
@ -404,7 +389,9 @@ export default class MessageComposerInput extends React.Component {
|
||||||
contentState = RichText.HTMLtoContentState(html);
|
contentState = RichText.HTMLtoContentState(html);
|
||||||
} else {
|
} else {
|
||||||
let markdown = stateToMarkdown(this.state.editorState.getCurrentContent());
|
let markdown = stateToMarkdown(this.state.editorState.getCurrentContent());
|
||||||
markdown = markdown.substring(0, markdown.length - 1); // stateToMarkdown tacks on an extra newline (?!?)
|
if (markdown[markdown.length - 1] === '\n') {
|
||||||
|
markdown = markdown.substring(0, markdown.length - 1); // stateToMarkdown tacks on an extra newline (?!?)
|
||||||
|
}
|
||||||
contentState = ContentState.createFromText(markdown);
|
contentState = ContentState.createFromText(markdown);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -635,6 +622,14 @@ export default class MessageComposerInput extends React.Component {
|
||||||
this.handleKeyCommand('toggle-mode');
|
this.handleKeyCommand('toggle-mode');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getBlockStyle(block: ContentBlock): ?string {
|
||||||
|
if (block.getType() === 'strikethrough') {
|
||||||
|
return 'mx_Markdown_STRIKETHROUGH';
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {editorState} = this.state;
|
const {editorState} = this.state;
|
||||||
|
|
||||||
|
@ -663,6 +658,7 @@ export default class MessageComposerInput extends React.Component {
|
||||||
placeholder="Type a message…"
|
placeholder="Type a message…"
|
||||||
editorState={this.state.editorState}
|
editorState={this.state.editorState}
|
||||||
onChange={this.setEditorState}
|
onChange={this.setEditorState}
|
||||||
|
blockStyleFn={this.getBlockStyle}
|
||||||
keyBindingFn={MessageComposerInput.getKeyBinding}
|
keyBindingFn={MessageComposerInput.getKeyBinding}
|
||||||
handleKeyCommand={this.handleKeyCommand}
|
handleKeyCommand={this.handleKeyCommand}
|
||||||
handleReturn={this.handleReturn}
|
handleReturn={this.handleReturn}
|
||||||
|
|
Loading…
Reference in a new issue