Closed loc-trinh closed 9 months ago
@loc-trinh If you want to prevent the default keyboard from appearing on mobile devices for a contenteditable
div, you can use a combination of CSS and JavaScript. For example:
<div id="myEditableDiv" contenteditable="true" style="touch-action: none;"></div>
In this example, the touch-action: none;
CSS property is used to disable touch interactions, which can prevent the default keyboard from appearing on touch devices. However, keep in mind that this approach may have other implications for touch interactions, so you should thoroughly test it based on your specific use case.
You can try the method mentioned above by encapsulating an extension
to add the touch-action: none;
style to the div.cm-content
.
Here's a simple extension
example below, you can refer to and try it out.
Thank you so much for the quick reply, I will give this a try.
Update:
this doesn't work
<div id="myEditableDiv" contenteditable="true" style="touch-action: none;"></div>
this works!
<div
id='myEditableDiv'
className='h-full w-full'
contentEditable='true'
inputmode='none'
>
</div>
Can you elaborate more on how to 'encapsulating an extension to add the touch-action: none; style to the div.cm-content'? I think I want to modify div.cm-content
to add another attribute @jaywcjlove thanks
@loc-trinh, this is the most basic example extensions/events. This extension adds events to the div DOM node, allowing you to add properties to it.
@loc-trinh I extended the extensions-events
plugin.
import { element } from '@uiw/codemirror-extensions-events';
const extension3 = element({
type: 'content',
props: {
inputMode: 'none',
},
});
Wow you are fast, thank you!
For coding on mobile app, I would like to use a custom keyboard instead of default iOS keyboard which is not good for coding.
For a textarea component, you can set
inputType='none'
to disable iOS keyboard from popping up. and with onHover or something I figure you probably can pull up a custom coding keyboard.I was wondering if it's possible to do
inputType='none'
for a CodeMirror instance somehow?