mirror of
https://github.com/PrimalHQ/primal-web-app.git
synced 2024-10-03 02:10:55 +00:00
Modify editor behavior when quoting a note.
This commit is contained in:
parent
a61738c746
commit
29e53c2224
@ -443,12 +443,28 @@ const EditBox: Component<{
|
|||||||
})
|
})
|
||||||
|
|
||||||
createEffect(() => {
|
createEffect(() => {
|
||||||
if (account?.quotedNote && textArea) {
|
const quote = account?.quotedNote;
|
||||||
setMessage((msg) => `${msg}${account.quotedNote} `);
|
if (!textArea || !quote) return;
|
||||||
textArea.value = message();
|
|
||||||
onExpandableTextareaInput(new InputEvent('input'))
|
let position = textArea.selectionStart;
|
||||||
account.actions.quoteNote(undefined);
|
|
||||||
}
|
const isEmptyMessage = message().length === 0;
|
||||||
|
|
||||||
|
setMessage((msg) => {
|
||||||
|
if (isEmptyMessage) return `\r\n\r\n${quote} `;
|
||||||
|
|
||||||
|
return msg.slice(0, position) + quote + ' ' + msg.slice(position, msg.length);
|
||||||
|
});
|
||||||
|
|
||||||
|
position = isEmptyMessage ? 0 : position + quote.length + 1;
|
||||||
|
|
||||||
|
textArea.value = message();
|
||||||
|
account.actions.quoteNote(undefined);
|
||||||
|
|
||||||
|
onExpandableTextareaInput(new InputEvent('input'));
|
||||||
|
|
||||||
|
textArea.focus();
|
||||||
|
textArea.selectionEnd = position;
|
||||||
})
|
})
|
||||||
|
|
||||||
const onEscape = (e: KeyboardEvent) => {
|
const onEscape = (e: KeyboardEvent) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user