if (e.key === 'Enter' && e.shiftKey === false) {
e.preventDefault();
- onSave(editInputRef.current.value);
+ onSave(editInputRef.current.value, body);
}
};
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
forwardRef={editInputRef}
onKeyDown={handleKeyDown}
body={(customHTML
? html(customHTML, { kind: 'edit', onlyPlain: true }).plain
: plain(body, { kind: 'edit', onlyPlain: true }).plain)}
- onSave={(newBody) => {
- if (newBody !== body) {
+ onSave={(newBody, oldBody) => {
+ if (newBody !== oldBody) {
initMatrix.roomsInput.sendEditedMessage(roomId, mEvent, newBody);
}
cancelEdit();
text: {
...defaultRules.text,
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),
},
};