How to control cursor position when insert custom tag ?
See original GitHub issueHi~
I try to create a plugin to insert my custom tag bdb (<bdb>{{ MONTH | yyyyMM | -1 }}</bdb>
)
then i typing some words in editor but these words always add in my custom tag ,
have any way to control cursor or range to avoid this problem ?
I want to get the result <bdb>{{ MONTH | yyyyMM | -1 }} </bdb>typing something...
steps to reproduce
- Click Template button to insert custom tag
- Typing some word.
browser version and os version and summernote version
Browser : Chrome v62.0.3202.94 / 64 bit Summernote : v0.8.8
Thanks a lot.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:12 (8 by maintainers)
Top Results From Across the Web
How to set the caret (cursor) position in a contenteditable ...
I want simple thing - when I click the button, I want to place caret(cursor) into specific place in the editable div. From...
Read more >How to set cursor position in content-editable element using ...
First, create Range and set position using above syntax. Get user input from input tag using jQuery $("input']").val();
Read more >cursor - CSS: Cascading Style Sheets - MDN Web Docs
The cursor CSS property sets the mouse cursor, if any, to show when the mouse pointer is over an element.
Read more >How to set and get cursor position in a text area - TinyMCE
Setting the cursor position · 1. Select content, and then bookmark the position of the content · 2. Set the caret position on...
Read more >How to Change Cursor on Hover in CSS - W3docs
If you want to change a mouse pointer into a hand pointer when hovering over a list item, you can set a class...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Following snippet works for me as a workaround:
If you want to insert text to cursor position, you just simple use event on mousedown and preventDefault() instead of click.
this.$legendaryBtn.on(“mousedown”, “.legend-item”, (e) => { e.preventDefault(); this.$summernote.summernote(“pasteHTML”, “Text on cursor position”); });
Bum! Its that 🏆 !
Becouse you so not want to loose focus (make a blur) on summernote.