vendredi 8 mai 2015

How do you make changes from a new windowManager window?

I'm fairly new to JavaScript, so I'm learning as I'm doing things. On my internship I was asked to adjust a WYSIWYG html editor so it can be used with e-mails. I'm using placeholders to later be replaced by the user.

My question: How do I detect the input in the textbox and replace it in the editor?

I had a look at other posts, like this one, but I still can't get it to work.

My code so far:

setup: function(ed) {
    // on mouse up gets selected text
        ed.on('mouseup', function(ed, e) {
            var highlighted = tinyMCE.activeEditor.selection.getContent();
            // Checks if highlighted texts contains a placeholder
            if (highlighted.indexOf("[!") > -1) {
                //alert(highlighted);
                tinyMCE.activeEditor.windowManager.open({
                    title: 'replace',
                    width: 320,
                    height: 240,
                    body: [
                        {type: 'textbox'}
                    ]
                })
            }
        });
    }

Thanks in advance!

Aucun commentaire:

Enregistrer un commentaire