diff --git a/web/source/text/kbdInterface.ts b/web/source/text/kbdInterface.ts
index 91d28cb028..92ab9eb373 100644
--- a/web/source/text/kbdInterface.ts
+++ b/web/source/text/kbdInterface.ts
@@ -1,5 +1,6 @@
///
///
+///
/***
KeymanWeb 11.0
@@ -162,41 +163,6 @@ namespace com.keyman.text {
//#endregion
- /**
- * Represents the commands and state changes that result from a matched keyboard rule.
- */
- export class RuleBehavior {
- /**
- * The before-and-after Transform from matching a keyboard rule.
- */
- transcription: Transcription;
-
- /**
- * Indicates whether or not a BEEP command was issued by the matched keyboard rule.
- */
- beep?: boolean;
-
- /**
- * A set of changed store values triggered by the matched keyboard rule.
- */
- setStore: {[id: number]: string} = {};
-
- /**
- * Denotes a non-output default behavior; this should be evaluated later, against the true keystroke.
- */
- triggersDefaultCommand?: boolean;
-
- /**
- * Denotes error log messages generated when attempting to generate this behavior.
- */
- errorLog?: string;
-
- /**
- * Denotes warning log messages generated when attempting to generate this behavior.
- */
- warningLog?: string;
- }
-
export class KeyboardInterface {
cachedContext: CachedContext = new CachedContext();
cachedContextEx: CachedContextEx = new CachedContextEx();
diff --git a/web/source/text/processor.ts b/web/source/text/processor.ts
index f1ffd3ac8b..9092593cf9 100644
--- a/web/source/text/processor.ts
+++ b/web/source/text/processor.ts
@@ -2,6 +2,8 @@
///
// Defines our generalized "KeyEvent" class.
///
+// Defines the RuleBehavior keyboard-processing return object.
+///
// Defines default key handling behaviors.
///
@@ -403,43 +405,9 @@ namespace com.keyman.text {
}
}
- // - start: application of 'delayed' effects specified by RuleBehaviors -
-
- if(ruleBehavior.beep) {
- // TODO: Must be relocated further 'out' to complete the full, planned web-core refactor.
- // We're still referencing the DOM, even if only the manager object. (It's an improvement, at least.)
- keyman.domManager.doBeep(outputTarget);
- }
-
- for(let storeID in ruleBehavior.setStore) {
- // TODO: Must be relocated further 'out' to complete the full, planned web-core refactor.
- // `Processor` shouldn't be directly setting anything on the OSK when the refactor is complete.
-
- // How would this be handled in an eventual headless mode?
- switch(Number.parseInt(storeID)) { // Because the number was converted into a String for 'dictionary' use.
- case KeyboardInterface.TSS_LAYER:
- keyman.osk.vkbd.showLayer(ruleBehavior.setStore[storeID]); //Build 350, osk reference now OK, so should work
- break;
- case KeyboardInterface.TSS_PLATFORM:
- console.error("Rule attempted to perform illegal operation - 'platform' may not be changed.");
- break;
- default:
- console.warn("Unknown store affected by keyboard rule: " + storeID);
- }
- }
-
- if(ruleBehavior.triggersDefaultCommand) {
- let keyEvent = ruleBehavior.transcription.keystroke;
- DefaultOutput.applyCommand(keyEvent);
- }
-
- if(ruleBehavior.warningLog) {
- console.warn(ruleBehavior.warningLog);
- } else if(ruleBehavior.errorLog) {
- console.error(ruleBehavior.errorLog);
- }
-
- // - end section
+ // Now that we've done all the keystroke processing needed, ensure any extra effects triggered
+ // by the actual keystroke occur.
+ ruleBehavior.finalize();
// If the transform isn't empty, we've changed text - which should produce a 'changed' event in the DOM.
//
diff --git a/web/source/text/ruleBehavior.ts b/web/source/text/ruleBehavior.ts
new file mode 100644
index 0000000000..329f6dbcea
--- /dev/null
+++ b/web/source/text/ruleBehavior.ts
@@ -0,0 +1,79 @@
+namespace com.keyman.text {
+ /**
+ * Represents the commands and state changes that result from a matched keyboard rule.
+ */
+ export class RuleBehavior {
+ /**
+ * The before-and-after Transform from matching a keyboard rule.
+ */
+ transcription: Transcription;
+
+ /**
+ * Indicates whether or not a BEEP command was issued by the matched keyboard rule.
+ */
+ beep?: boolean;
+
+ /**
+ * A set of changed store values triggered by the matched keyboard rule.
+ */
+ setStore: {[id: number]: string} = {};
+
+ /**
+ * Denotes a non-output default behavior; this should be evaluated later, against the true keystroke.
+ */
+ triggersDefaultCommand?: boolean;
+
+ /**
+ * Denotes error log messages generated when attempting to generate this behavior.
+ */
+ errorLog?: string;
+
+ /**
+ * Denotes warning log messages generated when attempting to generate this behavior.
+ */
+ warningLog?: string;
+
+ finalize() {
+ let keyman = com.keyman.singleton;
+ let outputTarget = this.transcription.keystroke.Ltarg;
+
+ if(this.beep) {
+ // TODO: Must be relocated further 'out' to complete the full, planned web-core refactor.
+ // We're still referencing the DOM, even if only the manager object. (It's an improvement, at least.)
+ keyman.domManager.doBeep(outputTarget);
+ }
+
+ for(let storeID in this.setStore) {
+ // TODO: Must be relocated further 'out' to complete the full, planned web-core refactor.
+ // `Processor` shouldn't be directly setting anything on the OSK when the refactor is complete.
+ //
+ // There's also the issue of Stores in general, which rely on cookies...
+ // Gotta handle variable stores as well, which we currently do nothing for!
+
+ // How would this be handled in an eventual headless mode?
+ switch(Number.parseInt(storeID)) { // Because the number was converted into a String for 'dictionary' use.
+ case KeyboardInterface.TSS_LAYER:
+ keyman.osk.vkbd.showLayer(this.setStore[storeID]); //Build 350, osk reference now OK, so should work
+ break;
+ case KeyboardInterface.TSS_PLATFORM:
+ console.error("Rule attempted to perform illegal operation - 'platform' may not be changed.");
+ break;
+ default:
+ console.warn("Unknown store affected by keyboard rule: " + storeID);
+ }
+ }
+
+ if(this.triggersDefaultCommand) {
+ let keyEvent = this.transcription.keystroke;
+ DefaultOutput.applyCommand(keyEvent);
+ }
+
+ // Safe both in browser and Node contexts.
+ if(this.warningLog) {
+ console.warn(this.warningLog);
+ } else if(this.errorLog) {
+ console.error(this.errorLog);
+ }
+ }
+ }
+}
\ No newline at end of file