Fix spaces not handled properly when entering text around MathJax (#2307)
Regressed in #2288 https://forums.ankiweb.net/t/2-1-56-qt6-pressing-space-after-mathjax-inserts-nbsp-with-escaped/26147
This commit is contained in:
parent
6df7be90c5
commit
25def4f741
@ -95,7 +95,7 @@ function restoreHandleContent(mutations: MutationRecord[]): void {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
referenceNode = target.parentElement.moveTextOutOfFrame();
|
referenceNode = target.parentElement.moveTextOutOfFrame(target.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -200,9 +200,9 @@ export abstract class FrameHandle extends HTMLElement {
|
|||||||
|
|
||||||
abstract notifyMoveIn(offset: number): void;
|
abstract notifyMoveIn(offset: number): void;
|
||||||
|
|
||||||
moveTextOutOfFrame(): Text {
|
moveTextOutOfFrame(data: string): Text {
|
||||||
const frameElement = this.parentElement! as FrameElement;
|
const frameElement = this.parentElement! as FrameElement;
|
||||||
const cleaned = this.innerHTML.replace(spaceRegex, "");
|
const cleaned = data.replace(spaceRegex, "");
|
||||||
const text = new Text(cleaned);
|
const text = new Text(cleaned);
|
||||||
|
|
||||||
if (this.placement === "beforebegin") {
|
if (this.placement === "beforebegin") {
|
||||||
@ -223,7 +223,9 @@ export abstract class FrameHandle extends HTMLElement {
|
|||||||
subscribeToCompositionEvent(): void {
|
subscribeToCompositionEvent(): void {
|
||||||
this.unsubscribe = isComposing.subscribe((composing) => {
|
this.unsubscribe = isComposing.subscribe((composing) => {
|
||||||
if (!composing) {
|
if (!composing) {
|
||||||
placeCaretAfter(this.moveTextOutOfFrame());
|
if (this.firstChild && nodeIsText(this.firstChild)) {
|
||||||
|
placeCaretAfter(this.moveTextOutOfFrame(this.firstChild.data));
|
||||||
|
}
|
||||||
this.unsubscribeToCompositionEvent();
|
this.unsubscribeToCompositionEvent();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user