Only escape when editing (#852)
* Only escape when editing * Base edit change detection on rendered content
This commit is contained in:
parent
c1be57b205
commit
cbd1bf35c6
2 changed files with 7 additions and 5 deletions
|
@ -300,12 +300,12 @@ function MessageEdit({ body, onSave, onCancel }) {
|
||||||
|
|
||||||
if (e.key === 'Enter' && e.shiftKey === false) {
|
if (e.key === 'Enter' && e.shiftKey === false) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
onSave(editInputRef.current.value);
|
onSave(editInputRef.current.value, body);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<form className="message__edit" onSubmit={(e) => { e.preventDefault(); onSave(editInputRef.current.value); }}>
|
<form className="message__edit" onSubmit={(e) => { e.preventDefault(); onSave(editInputRef.current.value, body); }}>
|
||||||
<Input
|
<Input
|
||||||
forwardRef={editInputRef}
|
forwardRef={editInputRef}
|
||||||
onKeyDown={handleKeyDown}
|
onKeyDown={handleKeyDown}
|
||||||
|
@ -806,8 +806,8 @@ function Message({
|
||||||
body={(customHTML
|
body={(customHTML
|
||||||
? html(customHTML, { kind: 'edit', onlyPlain: true }).plain
|
? html(customHTML, { kind: 'edit', onlyPlain: true }).plain
|
||||||
: plain(body, { kind: 'edit', onlyPlain: true }).plain)}
|
: plain(body, { kind: 'edit', onlyPlain: true }).plain)}
|
||||||
onSave={(newBody) => {
|
onSave={(newBody, oldBody) => {
|
||||||
if (newBody !== body) {
|
if (newBody !== oldBody) {
|
||||||
initMatrix.roomsInput.sendEditedMessage(roomId, mEvent, newBody);
|
initMatrix.roomsInput.sendEditedMessage(roomId, mEvent, newBody);
|
||||||
}
|
}
|
||||||
cancelEdit();
|
cancelEdit();
|
||||||
|
|
|
@ -96,7 +96,9 @@ const plainRules = {
|
||||||
text: {
|
text: {
|
||||||
...defaultRules.text,
|
...defaultRules.text,
|
||||||
match: anyScopeRegex(/^[\s\S]+?(?=[^0-9A-Za-z\s\u00c0-\uffff]| *\n|\w+:\S|$)/),
|
match: anyScopeRegex(/^[\s\S]+?(?=[^0-9A-Za-z\s\u00c0-\uffff]| *\n|\w+:\S|$)/),
|
||||||
plain: (node) => node.content.replace(/(\*|_|!\[|\[|\|\||\$\$?)/g, '\\$1'),
|
plain: (node, _, state) => (state.kind === 'edit'
|
||||||
|
? node.content.replace(/(\*|_|!\[|\[|\|\||\$\$?)/g, '\\$1')
|
||||||
|
: node.content),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue