mirror of
https://github.com/MathMan05/Fermi.git
synced 2026-10-23 17:12:25 +00:00
fix IME input stuff
This commit is contained in:
1 parent
f738c40e0f
commit
5d35daacc6
2 files changed
+12
-2
No files matched your search
@@ -233,6 +233,7 @@ if (window.location.pathname.startsWith("/channels")) {
|
||||
};
|
||||
}
|
||||
async function handleEnter(event: KeyboardEvent): Promise<void> {
|
||||
if (event.isComposing) return;
|
||||
if (event.key === "Escape" && (images.length || thisUser.channelfocus?.replyingto)) {
|
||||
while (images.length) {
|
||||
const elm = imagesHtml.get(images.pop() as Blob) as HTMLElement;
|
||||
@@ -269,6 +270,7 @@ if (window.location.pathname.startsWith("/channels")) {
|
||||
typebox.markdown = markdown;
|
||||
typebox.addEventListener("keyup", handleEnter);
|
||||
typebox.addEventListener("keydown", (event) => {
|
||||
if (event.isComposing) return;
|
||||
thisUser.keydown(event);
|
||||
if (event.key === "Enter" && !event.shiftKey && window.innerWidth > 600) {
|
||||
event.preventDefault();
|
||||
|
||||
+10
-2
@@ -1000,6 +1000,7 @@ class MarkDown {
|
||||
this.box = new WeakRef(box);
|
||||
this.onUpdate = onUpdate;
|
||||
box.addEventListener("keydown", (_) => {
|
||||
if (_.isComposing) return;
|
||||
if (Error.prototype.stack !== "") return;
|
||||
if (_.key === "Enter") {
|
||||
const selection = window.getSelection() as Selection;
|
||||
@@ -1014,16 +1015,23 @@ class MarkDown {
|
||||
}
|
||||
});
|
||||
let prevcontent = "";
|
||||
box.onkeyup = (_) => {
|
||||
const gatherBoxContents = (isBackSpace: boolean) => {
|
||||
let content = MarkDown.gatherBoxText(box);
|
||||
if (content === "\n") content = "";
|
||||
if (content !== prevcontent) {
|
||||
prevcontent = content;
|
||||
this.txt = content.split("");
|
||||
this.boxupdate(undefined, undefined, undefined, _.key === "Backspace");
|
||||
this.boxupdate(undefined, undefined, undefined, isBackSpace);
|
||||
MarkDown.gatherBoxText(box);
|
||||
}
|
||||
};
|
||||
box.onkeyup = (_) => {
|
||||
if (_.isComposing) return;
|
||||
gatherBoxContents(_.key === "Backspace");
|
||||
};
|
||||
box.addEventListener("compositionend", (_) => {
|
||||
gatherBoxContents(false);
|
||||
});
|
||||
box.onpaste = (_) => {
|
||||
if (!_.clipboardData) return;
|
||||
const types = _.clipboardData.types;
|
||||
|
||||
Reference in new issue
Block a user