question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to control cursor position when insert custom tag ?

See original GitHub issue

Hi~

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

  1. Click Template button to insert custom tag
  2. Typing some word.

image image image

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:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:12 (8 by maintainers)

github_iconTop GitHub Comments

3reactions
gallyambcommented, Nov 21, 2017

Following snippet works for me as a workaround:

context.invoke('editor.insertNode', createCustomLink(selectedObject))
context.invoke('editor.pasteHTML', '&zwnj;')
1reaction
mlazovlacommented, Oct 25, 2018

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found