From 0e372e90681d0c06226f1c739c8740933926a5a5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=B5=94=E9=98=B3=E9=99=8C=E5=AE=A2?=
 <virtualtengfei@163.com>
Date: Sat, 6 Apr 2024 14:48:25 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9textinput=E5=92=8Ctextarea?=
 =?UTF-8?q?=E7=9A=84=E5=9B=9E=E8=B0=83=E5=87=BD=E6=95=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 src/index.ts              | 2 ++
 src/libs/setting-utils.ts | 4 ++--
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/index.ts b/src/index.ts
index a444fb8..df1131b 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -178,6 +178,7 @@ export default class PluginSample extends Plugin {
             title: "Readonly text",
             description: "Input description",
             action: {
+                // Called when focus is lost and content changes
                 callback: () => {
                     // Return data and save it in real time
                     let value = this.settingUtils.takeAndSave("Input")
@@ -191,6 +192,7 @@ export default class PluginSample extends Plugin {
             type: "textarea",
             title: "Readonly text",
             description: "Input description",
+            // Called when focus is lost and content changes
             action: {
                 callback: () => {
                     // Read data in real time
diff --git a/src/libs/setting-utils.ts b/src/libs/setting-utils.ts
index 8d2bc53..321b019 100644
--- a/src/libs/setting-utils.ts
+++ b/src/libs/setting-utils.ts
@@ -212,7 +212,7 @@ export class SettingUtils {
                 let textInputElement: HTMLInputElement = document.createElement('input');
                 textInputElement.className = 'b3-text-field fn__flex-center fn__size200';
                 textInputElement.value = item.value;
-                textInputElement.onkeyup = item.action?.callback ?? (() => { });
+                textInputElement.onchange = item.action?.callback ?? (() => { });
                 itemElement = textInputElement;
 
                 break;
@@ -220,7 +220,7 @@ export class SettingUtils {
                 let textareaElement: HTMLTextAreaElement = document.createElement('textarea');
                 textareaElement.className = "b3-text-field fn__block";
                 textareaElement.value = item.value;
-                textareaElement.onkeyup = item.action?.callback ?? (() => { });
+                textareaElement.onchange = item.action?.callback ?? (() => { });
                 itemElement = textareaElement;
                 break;
             case 'number':