File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed
Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change 8585 let loaded = false ;
8686 let recording = false ;
8787
88+ let isComposing = false ;
89+
8890 let chatInputContainerElement;
8991 let chatInputElement;
9092
707709 console .log (res );
708710 return res ;
709711 }}
712+ oncompositionstart ={() => (isComposing = true )}
713+ oncompositionend ={() => (isComposing = false )}
710714 on:keydown ={async (e ) => {
711715 e = e .detail .event ;
712716
806810 navigator .msMaxTouchPoints > 0
807811 )
808812 ) {
813+ if (isComposing ) {
814+ return ;
815+ }
816+
809817 // Uses keyCode '13' for Enter key for chinese/japanese keyboards.
810818 //
811819 // Depending on the user's settings, it will send the message
882890 class =" scrollbar-hidden bg-transparent dark:text-gray-100 outline-hidden w-full pt-3 px-1 resize-none"
883891 placeholder ={placeholder ? placeholder : $i18n .t (' Send a Message' )}
884892 bind:value ={prompt }
893+ on:compositionstart ={() => (isComposing = true )}
894+ on:compositionend ={() => (isComposing = false )}
885895 on:keydown ={async (e ) => {
886896 const isCtrlPressed = e .ctrlKey || e .metaKey ; // metaKey is for Cmd key on Mac
887897
983993 navigator .msMaxTouchPoints > 0
984994 )
985995 ) {
996+ if (isComposing ) {
997+ return ;
998+ }
999+
9861000 console .log (' keypress' , e );
9871001 // Prevent Enter key from creating a new line
9881002 const isCtrlPressed = e .ctrlKey || e .metaKey ;
Original file line number Diff line number Diff line change 2727
2828 import { PASTED_TEXT_CHARACTER_LIMIT } from ' $lib/constants' ;
2929
30+ export let oncompositionstart = (e ) => {};
31+ export let oncompositionend = (e ) => {};
32+
3033 // create a lowlight instance with all languages loaded
3134 const lowlight = createLowlight (all );
3235
226229 editorProps: {
227230 attributes: { id },
228231 handleDOMEvents: {
232+ compositionstart : (view , event ) => {
233+ oncompositionstart (event );
234+ return false ;
235+ },
236+ compositionend : (view , event ) => {
237+ oncompositionend (event );
238+ return false ;
239+ },
229240 focus : (view , event ) => {
230241 eventDispatch (' focus' , { event });
231242 return false ;
You can’t perform that action at this time.
0 commit comments