rte: remove logging and fix new history
This commit is contained in:
parent
6004f6d610
commit
8dc7f8efe2
3 changed files with 8 additions and 6 deletions
|
@ -44,14 +44,20 @@ export default class ComposerHistoryManager {
|
||||||
|
|
||||||
// TODO: Performance issues?
|
// TODO: Performance issues?
|
||||||
for(; sessionStorage.getItem(`${this.prefix}[${this.lastIndex}]`); this.lastIndex++, this.currentIndex++) {
|
for(; sessionStorage.getItem(`${this.prefix}[${this.lastIndex}]`); this.lastIndex++, this.currentIndex++) {
|
||||||
history.push(JSON.parse(sessionStorage.getItem(`${this.prefix}[${this.lastIndex}]`)));
|
this.history.push(
|
||||||
|
Object.assign(
|
||||||
|
new HistoryItem(),
|
||||||
|
JSON.parse(sessionStorage.getItem(`${this.prefix}[${this.lastIndex}]`)),
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
this.currentIndex--;
|
||||||
}
|
}
|
||||||
|
|
||||||
addItem(message: string, format: MessageFormat) {
|
addItem(message: string, format: MessageFormat) {
|
||||||
const item = new HistoryItem(message, format);
|
const item = new HistoryItem(message, format);
|
||||||
this.history.push(item);
|
this.history.push(item);
|
||||||
this.currentIndex = this.lastIndex;
|
this.currentIndex = this.lastIndex + 1;
|
||||||
sessionStorage.setItem(`${this.prefix}[${this.lastIndex++}]`, JSON.stringify(item));
|
sessionStorage.setItem(`${this.prefix}[${this.lastIndex++}]`, JSON.stringify(item));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -197,7 +197,6 @@ export default class Autocomplete extends React.Component {
|
||||||
|
|
||||||
setState(state, func) {
|
setState(state, func) {
|
||||||
super.setState(state, func);
|
super.setState(state, func);
|
||||||
console.log(state);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|
|
@ -320,7 +320,6 @@ export default class MessageComposerInput extends React.Component {
|
||||||
const selection = RichText.selectionStateToTextOffsets(
|
const selection = RichText.selectionStateToTextOffsets(
|
||||||
this.state.editorState.getSelection(),
|
this.state.editorState.getSelection(),
|
||||||
this.state.editorState.getCurrentContent().getBlocksAsArray());
|
this.state.editorState.getCurrentContent().getBlocksAsArray());
|
||||||
console.log(textContent);
|
|
||||||
this.props.onContentChanged(textContent, selection);
|
this.props.onContentChanged(textContent, selection);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -541,7 +540,6 @@ export default class MessageComposerInput extends React.Component {
|
||||||
|
|
||||||
// tab and shift-tab are mapped to down and up arrow respectively
|
// tab and shift-tab are mapped to down and up arrow respectively
|
||||||
onTab = async (e) => {
|
onTab = async (e) => {
|
||||||
console.log('onTab');
|
|
||||||
e.preventDefault(); // we *never* want tab's default to happen, but we do want up/down sometimes
|
e.preventDefault(); // we *never* want tab's default to happen, but we do want up/down sometimes
|
||||||
if (this.autocomplete.state.completionList.length === 0) {
|
if (this.autocomplete.state.completionList.length === 0) {
|
||||||
await this.autocomplete.forceComplete();
|
await this.autocomplete.forceComplete();
|
||||||
|
@ -567,7 +565,6 @@ export default class MessageComposerInput extends React.Component {
|
||||||
|
|
||||||
if (displayedCompletion == null) {
|
if (displayedCompletion == null) {
|
||||||
if (this.state.originalEditorState) {
|
if (this.state.originalEditorState) {
|
||||||
console.log('setting editorState to originalEditorState');
|
|
||||||
let editorState = this.state.originalEditorState;
|
let editorState = this.state.originalEditorState;
|
||||||
// This is a workaround from https://github.com/facebook/draft-js/issues/458
|
// This is a workaround from https://github.com/facebook/draft-js/issues/458
|
||||||
// Due to the way we swap editorStates, Draft does not rerender at times
|
// Due to the way we swap editorStates, Draft does not rerender at times
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue