Merge pull request #2850 from keymanapp/refactor/web/engine/embedded-insert-text

refactor(web/engine): reworks use of embedded's keyman['oninserttext']
This commit is contained in:
Joshua Horton 2020-03-23 12:51:34 +07:00 • committed by GitHub
commit 348cd65497
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 12 deletions

View file

@ -832,11 +832,6 @@ namespace com.keyman.text {
output(dn: number, outputTarget: OutputTarget, s:string): void {
this.resetContextCache();
let keyman = com.keyman.singleton;
// KeymanTouch for Android uses direct insertion of the character string
if('oninserttext' in keyman && !(outputTarget instanceof Mock)) {
keyman['oninserttext'](dn,s);
}
outputTarget.saveProperties();
outputTarget.clearSelection();
@ -1041,9 +1036,6 @@ namespace com.keyman.text {
}
this.output(1, outputTarget, "");
if(outputTarget.getElement()) {
this.doInputEvent(outputTarget.getElement());
}
}
/**

View file

@ -95,10 +95,6 @@ namespace com.keyman.text {
}
break;
case Codes.keyCodes['K_ENTER']:
// Ensure the newline is forwarded when in an embedded context! It doesn't yet have its own specialized OutputTarget type.
if(keyman.isEmbedded && !quiet) { // Don't pass it along for Mocks, though. They're (currently) only used in predictive text.
keyman['oninserttext'](0, '\n');
}
outputTarget.handleNewlineAtCaret();
return '\n'; // We still return this, as it ensures we generate a rule-match.
@ -531,11 +527,19 @@ namespace com.keyman.text {
DOMEventHandlers.states.changed = true;
}
}
// -- All keystroke (and 'alternate') processing is now complete. Time to finalize everything! --
// Notify the ModelManager of new input - it's predictive text time!
ruleBehavior.transcription.alternates = alternates;
keyman.modelManager.predict(ruleBehavior.transcription);
// KMEA and KMEI (embedded mode) use direct insertion of the character string
if(keyman.isEmbedded) {
// A special embedded callback used to setup direct callbacks to app-native code.
keyman['oninserttext'](ruleTransform.deleteLeft, ruleTransform.insert, ruleTransform.deleteRight);
}
// Since this method now performs changes for 'default' keystrokes, synthetic 'change' event generation
// belongs here, rather than only in interface.processKeystroke() as in versions pre-12.
if(outputTarget.getElement()) {