(e: KeyboardEvent)
| 1034 | } |
| 1035 | |
| 1036 | async _handleInsertPaste(e: KeyboardEvent) { |
| 1037 | if (this.readonly || isFirefox()) { |
| 1038 | return; |
| 1039 | } |
| 1040 | |
| 1041 | // For Shift+Insert, try to use navigator.clipboard API |
| 1042 | // If it fails due to permissions, the browser's native paste will be blocked |
| 1043 | try { |
| 1044 | e.preventDefault(); |
| 1045 | const pastedText = await navigator.clipboard.readText(); |
| 1046 | |
| 1047 | if (pastedText) { |
| 1048 | // Use deprecated but still functional document.execCommand for cursor handling |
| 1049 | document.execCommand("insertText", true, pastedText); |
| 1050 | |
| 1051 | // Dispatch input event to ensure the component updates |
| 1052 | const inputEvent = new Event("input", { |
| 1053 | bubbles: true, |
| 1054 | cancelable: true, |
| 1055 | }); |
| 1056 | this._innerInput.dispatchEvent(inputEvent); |
| 1057 | |
| 1058 | this._handleTokenCreationUponPaste(pastedText, e); |
| 1059 | } |
| 1060 | } catch (err) { |
| 1061 | // If clipboard API fails, silently ignore |
| 1062 | // Native paste won't work since we already prevented default |
| 1063 | } |
| 1064 | } |
| 1065 | |
| 1066 | _handleShow(e: KeyboardEvent) { |
| 1067 | const items = this._getItems(); |
no test coverage detected