Topic: How to find previus <p>paragraph</p> or text cursor

I want to insert an <div>Picture with capiton</div> just before this paragrapf text-cursor is on mow.
Im using version 4.0.11

<p>text before the picture</p>
==><div>Here i want to put the div</div>
<p>Paragraph textcursor is on</p>

How I try it now, but its end up first
..... lots of code bfore this ....

infogabild() {
..... snipp ....
if ( obj_pic ) 
// Find text cursor and put in it here
// Closes the window
..... snipp ....

I can use some advice here
This is how I made my 'button' and that part works fine

tinymce.PluginManager.add('infogabild', function(editor, url) {
        title: 'Välj en bild först och Infoga vald bild där markören står.',
        text: false,
        image: 'bild/insertimage.png',
        icon: false,
        onclick: function() { infogabild(); }

// Bengt

Last edited by Bengt7jqb (2015-06-29 20:01:28)


Re: How to find previus <p>paragraph</p> or text cursor

Selution :

    if ( obj_infoga ) 
        tag = tinymce.activeEditor.selection.getNode();
        tag.parentElement.insertBefore(obj_infoga, tag );             

Last edited by Bengt7jqb (2015-07-05 12:59:33)