Skip to main content
1 of 3
Steve
  • 313
  • 9
  • 21

Custom Shortcode: define cursor position/insertion point?

I have created a shortcode and TinyMCE plugin for a shortcode. Click the button, it inserts [my-shortcode][/my-shortcode].

But it adds the code and then the editor cursor is after the closing shortcode. I want to type content inside this shortcode, so I need to click the cursor between the ][ every time.

Is there a way to position the cursor in the button js so that when the shortcode is added, the cursor is in my desired spot?

Yes, I have also set the shortcode to wrap text if there is an active selection, but what if I want to add content after adding the shortcode?

Steve
  • 313
  • 9
  • 21