Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/static/js/ace.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ const Ace2Editor = function () {
this.getDebugProperty = (prop) => info.ace_getDebugProperty(prop);

this.getInInternationalComposition =
() => loaded ? info.ace_getInInternationalComposition() : false;
() => loaded ? info.ace_getInInternationalComposition() : null;

// prepareUserChangeset:
// Returns null if no new changes or ACE not ready. Otherwise, bundles up all user changes
Expand Down
22 changes: 10 additions & 12 deletions src/static/js/ace2_inner.js
Original file line number Diff line number Diff line change
Expand Up @@ -3504,16 +3504,7 @@ function Ace2Inner(editorInfo, cssManagers) {

const teardown = () => _teardownActions.forEach((a) => a());

let inInternationalComposition = false;
const handleCompositionEvent = (evt) => {
// international input events, fired in FF3, at least; allow e.g. Japanese input
if (evt.type === 'compositionstart') {
inInternationalComposition = true;
} else if (evt.type === 'compositionend') {
inInternationalComposition = false;
}
};

let inInternationalComposition = null;
editorInfo.ace_getInInternationalComposition = () => inInternationalComposition;

const bindTheEventHandlers = () => {
Expand Down Expand Up @@ -3602,8 +3593,15 @@ function Ace2Inner(editorInfo, cssManagers) {
});
});

$(document.documentElement).on('compositionstart', handleCompositionEvent);
$(document.documentElement).on('compositionend', handleCompositionEvent);
$(document.documentElement).on('compositionstart', () => {
if (inInternationalComposition) return;
inInternationalComposition = new Promise((resolve) => {
$(document.documentElement).one('compositionend', () => {
inInternationalComposition = null;
resolve();
});
});
});
};

const topLevel = (n) => {
Expand Down
Loading