PR feedback: put findPrev/NextEditableEvent in one function with flag
This commit is contained in:
parent
4626581dbe
commit
e193522db1
3 changed files with 25 additions and 30 deletions
|
@ -23,7 +23,7 @@ import EditorModel from '../../../editor/model';
|
|||
import {setCaretPosition} from '../../../editor/caret';
|
||||
import {getCaretOffsetAndText} from '../../../editor/dom';
|
||||
import {htmlSerializeIfNeeded, textSerialize} from '../../../editor/serialize';
|
||||
import {findPreviousEditableEvent, findNextEditableEvent} from '../../../utils/EventUtils';
|
||||
import {findEditableEvent} from '../../../utils/EventUtils';
|
||||
import {parseEvent} from '../../../editor/deserialize';
|
||||
import Autocomplete from '../rooms/Autocomplete';
|
||||
import {PartCreator} from '../../../editor/parts';
|
||||
|
@ -133,7 +133,7 @@ export default class MessageEditor extends React.Component {
|
|||
if (this._hasModifications || !this._isCaretAtStart()) {
|
||||
return;
|
||||
}
|
||||
const previousEvent = findPreviousEditableEvent(this._getRoom(), this.props.event.getId());
|
||||
const previousEvent = findEditableEvent(this._getRoom(), false, this.props.event.getId());
|
||||
if (previousEvent) {
|
||||
dis.dispatch({action: 'edit_event', event: previousEvent});
|
||||
event.preventDefault();
|
||||
|
@ -142,7 +142,7 @@ export default class MessageEditor extends React.Component {
|
|||
if (this._hasModifications || !this._isCaretAtEnd()) {
|
||||
return;
|
||||
}
|
||||
const nextEvent = findNextEditableEvent(this._getRoom(), this.props.event.getId());
|
||||
const nextEvent = findEditableEvent(this._getRoom(), true, this.props.event.getId());
|
||||
if (nextEvent) {
|
||||
dis.dispatch({action: 'edit_event', event: nextEvent});
|
||||
} else {
|
||||
|
|
|
@ -59,7 +59,7 @@ import RoomViewStore from '../../../stores/RoomViewStore';
|
|||
import ReplyThread from "../elements/ReplyThread";
|
||||
import {ContentHelpers} from 'matrix-js-sdk';
|
||||
import AccessibleButton from '../elements/AccessibleButton';
|
||||
import { findPreviousEditableEvent } from '../../../utils/EventUtils';
|
||||
import {findEditableEvent} from '../../../utils/EventUtils';
|
||||
|
||||
const REGEX_EMOTICON_WHITESPACE = new RegExp('(?:^|\\s)(' + EMOTICON_REGEX.source + ')\\s$');
|
||||
|
||||
|
@ -1181,7 +1181,7 @@ export default class MessageComposerInput extends React.Component {
|
|||
if (up) {
|
||||
if (!selection.anchor.isAtStartOfNode(document)) return;
|
||||
|
||||
const editEvent = findPreviousEditableEvent(this.props.room);
|
||||
const editEvent = findEditableEvent(this.props.room, false);
|
||||
if (editEvent) {
|
||||
// We're selecting history, so prevent the key event from doing anything else
|
||||
e.preventDefault();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue