From b5c81d272108633696dd7a7787977dded3d1c0d7 Mon Sep 17 00:00:00 2001 From: Saq Imtiaz Date: Thu, 28 Oct 2021 20:15:50 +0200 Subject: [PATCH] Provide actionValue variable to actions fired by EditTextWidget (#6145) * feat: provide actionValue variable to actions fired by EditTextWidget * also extend CodeMirror engine to set actionValue variable when invoking actions --- core/modules/editor/engines/framed.js | 2 +- core/modules/editor/engines/simple.js | 2 +- editions/tw5.com/tiddlers/widgets/EditTextWidget.tid | 2 +- plugins/tiddlywiki/codemirror/engine.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/core/modules/editor/engines/framed.js b/core/modules/editor/engines/framed.js index 45958ff06..441ccc243 100644 --- a/core/modules/editor/engines/framed.js +++ b/core/modules/editor/engines/framed.js @@ -205,7 +205,7 @@ FramedEngine.prototype.handleInputEvent = function(event) { this.widget.saveChanges(this.getText()); this.fixHeight(); if(this.widget.editInputActions) { - this.widget.invokeActionString(this.widget.editInputActions); + this.widget.invokeActionString(this.widget.editInputActions,this,event,{actionValue: this.getText()}); } return true; }; diff --git a/core/modules/editor/engines/simple.js b/core/modules/editor/engines/simple.js index e1b6bda64..e8be19a75 100644 --- a/core/modules/editor/engines/simple.js +++ b/core/modules/editor/engines/simple.js @@ -133,7 +133,7 @@ SimpleEngine.prototype.handleInputEvent = function(event) { this.widget.saveChanges(this.getText()); this.fixHeight(); if(this.widget.editInputActions) { - this.widget.invokeActionString(this.widget.editInputActions); + this.widget.invokeActionString(this.widget.editInputActions,this,event,{actionValue: this.getText()}); } return true; }; diff --git a/editions/tw5.com/tiddlers/widgets/EditTextWidget.tid b/editions/tw5.com/tiddlers/widgets/EditTextWidget.tid index 7cde23345..e0720bc3c 100644 --- a/editions/tw5.com/tiddlers/widgets/EditTextWidget.tid +++ b/editions/tw5.com/tiddlers/widgets/EditTextWidget.tid @@ -33,7 +33,7 @@ The content of the `<$edit-text>` widget is ignored. |minHeight |Minimum height for automatically resized `textarea` editors, specified in CSS length units such as "px", "em" or "%" | |rows|Sets the rows attribute of a generated textarea | |cancelPopups |<<.from-version "5.1.23">> if set to "yes", cancels all popups when the input gets focus | -|inputActions |<<.from-version 5.1.23>> Optional actions that are triggered every time an input event occurs within the input field or textarea | +|inputActions |<<.from-version 5.1.23>> Optional actions that are triggered every time an input event occurs within the input field or textarea.
<<.from-version "5.2.1">> The variable `actionValue` is available to the `inputActions` and contains the value of the input field. | |refreshTitle |<<.from-version 5.1.23>> An optional tiddler title that makes the input field update whenever the specified tiddler changes | |disabled|<<.from-version "5.1.23">> Optional, disables the text input if set to "yes". Defaults to "no"| |fileDrop|<<.from-version "5.2.0">> Optional. When set to "yes" allows dropping or pasting images into the editor to import them. Defaults to "no"| diff --git a/plugins/tiddlywiki/codemirror/engine.js b/plugins/tiddlywiki/codemirror/engine.js index e5e241a47..684e6149a 100755 --- a/plugins/tiddlywiki/codemirror/engine.js +++ b/plugins/tiddlywiki/codemirror/engine.js @@ -122,7 +122,7 @@ function CodeMirrorEngine(options) { this.cm.on("change",function() { self.widget.saveChanges(self.getText()); if(self.widget.editInputActions) { - self.widget.invokeActionString(self.widget.editInputActions); + self.widget.invokeActionString(self.widget.editInputActions,this,event,{actionValue: this.getText()}); } });