From c09a7140b26d6746e06b2950550a5fe9b274c6e8 Mon Sep 17 00:00:00 2001
From: yujiaxinwt <1157613664@qq.com>
Date: Fri, 5 Jan 2024 09:23:50 +0800
Subject: [PATCH 01/22] =?UTF-8?q?=E8=BE=93=E5=85=A5=E6=B3=95=E9=80=9A?=
=?UTF-8?q?=E9=81=93=E5=AE=9E=E7=8E=B0=E5=A4=8D=E5=88=B6=E7=B2=98=E8=B4=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sdk/src/AppController.js | 15 +++++++++++++++
sdk/src/KeyboardInput.js | 13 ++++++++++---
sdk/src/config/protocolConfig.js | 5 ++++-
3 files changed, 29 insertions(+), 4 deletions(-)
diff --git a/sdk/src/AppController.js b/sdk/src/AppController.js
index 4e9085d..478655b 100644
--- a/sdk/src/AppController.js
+++ b/sdk/src/AppController.js
@@ -353,6 +353,9 @@ class AppController {
if (this.player) {
this.keyboardInput = new KeyboardInput(this.options.containerId, this.send);
this.keyboardInput.init();
+ if (!this.options.isMobile) {
+ this.keyboardInput.listenPaste();
+ }
this.touchHandler = new TouchHandler({
player: this.player,
isMobile: this.options.isMobile,
@@ -782,6 +785,18 @@ class AppController {
} else if (type === PROTOCOL_CONFIG.KEYBOARD_INPUT_MSG_TYPE.HIDE_KEYBOARD_EVENT) {
this.keyboardInput.stop();
this.touchHandler.updateKeyBoardMode('KEYBOARD_MAP');
+ } else if (type === PROTOCOL_CONFIG.KEYBOARD_INPUT_MSG_TYPE.IME_PASTE_TO_SDK) {
+ const len = (highBytesSize << 8) + lowByteSize;
+ const input = len > 0 ? this.util.decodeUTF8(pkg, PROTOCOL_CONFIG.KEYBOARD_INPUT_HEADER_LENGTH,
+ PROTOCOL_CONFIG.KEYBOARD_INPUT_HEADER_LENGTH + len) : '';
+ // 将信息给端侧的剪贴板
+ navigator.clipboard.writeText(input)
+ .then(() => {
+ console.log("Copy success");
+ })
+ .catch((error) => {
+ console.error("Copy failed", error);
+ });
}
}
diff --git a/sdk/src/KeyboardInput.js b/sdk/src/KeyboardInput.js
index 59541b6..39b8a4f 100644
--- a/sdk/src/KeyboardInput.js
+++ b/sdk/src/KeyboardInput.js
@@ -79,7 +79,7 @@ export default class KeyboardInput {
}
onInput() {
- this.handleInputMsg(this.input.value, 'KEYBOARD_INPUT');
+ this.handleInputMsg(this.input.value, 'KEYBOARD_INPUT', PROTOCOL_CONFIG.KEYBOARD_INPUT_MSG_TYPE.TEXT_UPDATE);
}
onKeyup(event) {
@@ -88,7 +88,7 @@ export default class KeyboardInput {
}
}
- handleInputMsg(input, msgType) {
+ handleInputMsg(input, msgType, textType) {
const PACKAGE_HEADER_LENGTH = 8;
const INPUT_HEADER_LENGTH = 3;
const msgData = this.util.encodeUTF8(input);
@@ -101,7 +101,7 @@ export default class KeyboardInput {
cmdBuf[5] = (INPUT_HEADER_LENGTH + msgData.length) >> 16;
cmdBuf[6] = (INPUT_HEADER_LENGTH + msgData.length) >> 8;
cmdBuf[7] = (INPUT_HEADER_LENGTH + msgData.length);
- cmdBuf[8] = PROTOCOL_CONFIG.KEYBOARD_INPUT_MSG_TYPE.TEXT_UPDATE;
+ cmdBuf[8] = textType;
cmdBuf[9] = msgData.length >> 8;
cmdBuf[10] = msgData.length;
@@ -115,4 +115,11 @@ export default class KeyboardInput {
this.inputContainer.remove();
this.inputContainer = null;
}
+
+ listenPaste() {
+ document.addEventListener('paste', (event) => {
+ const pasteContent = event.clipboardData.getData('text/plain');
+ this.handleInputMsg(pasteContent, 'KEYBOARD_INPUT' , PROTOCOL_CONFIG.KEYBOARD_INPUT_MSG_TYPE.IME_PASTE_FROM_PC_SDK);
+ });
+ }
}
\ No newline at end of file
diff --git a/sdk/src/config/protocolConfig.js b/sdk/src/config/protocolConfig.js
index 69b0bdf..9d00b6f 100644
--- a/sdk/src/config/protocolConfig.js
+++ b/sdk/src/config/protocolConfig.js
@@ -150,7 +150,10 @@ const PROTOCOL_CONFIG = {
KEYBOARD_INPUT_MSG_TYPE: {
INPUT_EVENT: 0X00,
HIDE_KEYBOARD_EVENT: 0X01,
- TEXT_UPDATE: 0X02
+ TEXT_UPDATE: 0X02,
+ IME_PASTE_TO_SDK: 6,
+ IME_PASTE_FROM_SDK: 7,
+ IME_PASTE_FROM_PC_SDK: 8
},
KEYBOARD_INPUT_HEADER_LENGTH:3,
REMOTE_IME: {
--
Gitee
From 9da566d9c996634d792dad185e98b771cc8fee70 Mon Sep 17 00:00:00 2001
From: yujiaxinwt <1157613664@qq.com>
Date: Mon, 8 Jan 2024 16:36:08 +0800
Subject: [PATCH 02/22] =?UTF-8?q?=E6=9A=B4=E9=9C=B2=E5=8F=8C=E5=90=91?=
=?UTF-8?q?=E5=A4=8D=E5=88=B6=E7=B2=98=E8=B4=B4=E6=8E=A5=E5=8F=A3=EF=BC=9B?=
=?UTF-8?q?=E5=88=A0=E9=99=A4vconsole=E4=BD=BF=E7=94=A8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sdk/demo/demo.html | 14 +++++++++++---
sdk/enter.html | 3 +--
sdk/index.html | 14 +++++++++++---
sdk/login.html | 2 --
sdk/phone.html | 2 --
sdk/src/AppController.js | 20 ++++++++------------
sdk/src/CPHCloudApp.js | 4 ++++
sdk/src/CloudApp.js | 4 ++++
sdk/src/KeyboardInput.js | 7 ++-----
9 files changed, 41 insertions(+), 29 deletions(-)
diff --git a/sdk/demo/demo.html b/sdk/demo/demo.html
index da8381b..1f4c818 100644
--- a/sdk/demo/demo.html
+++ b/sdk/demo/demo.html
@@ -452,7 +452,6 @@ Copyright 2022 Huawei Cloud Computing Technology Co., Ltd.
-
+
-