mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-27 10:07:15 +02:00
LibWeb: Send a beforeinput event for pasting
This allows us to paste text into Discord.
This commit is contained in:
committed by
Andreas Kling
parent
8d02f28cc2
commit
a2f3a5a6ce
Notes:
github-actions[bot]
2025-07-23 20:05:52 +00:00
Author: https://github.com/Lubrsi Commit: https://github.com/LadybirdBrowser/ladybird/commit/a2f3a5a6ce8 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5577
@@ -13,13 +13,19 @@
|
||||
const input = document.getElementById("input");
|
||||
input.addEventListener("beforeinput", (e) => {
|
||||
println(`beforeinput data=(${e.data}) inputType=(${e.inputType})`);
|
||||
if (e.data !== 'r' && e.data !== 'e') {
|
||||
if (e.data !== 'r' && e.data !== 'e' && e.data !== "non-cancelled paste") {
|
||||
e.preventDefault();
|
||||
return;
|
||||
}
|
||||
});
|
||||
internals.sendText(input, "raebece");
|
||||
internals.commitText();
|
||||
println(`Text in input: ${input.textContent}`);
|
||||
println(`Text in input before any paste: ${input.textContent}`);
|
||||
internals.paste(input, "non-cancelled paste");
|
||||
internals.commitText();
|
||||
println(`Text in input after non-cancelled paste: ${input.textContent}`);
|
||||
internals.paste(input, "cancelled paste");
|
||||
internals.commitText();
|
||||
println(`Text in input after cancelled paste: ${input.textContent}`);
|
||||
});
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user