How to insert text to editor programmatically in J

2019-08-01 08:21发布

问题:

I am using joomla 1.7 and I am made a custom button (editor-xtd plugin) that I want to insert some string into the current editor content.

Like in the Readmore button. I have searched through the Readmore code and found :

        $js = "
        function insertReadmore(editor) {
            var content = $getContent
            if (content.match(/<hr\s+id=(\"|')system-readmore(\"|')\s*\/*>/i)) {
                alert('$present');
                return false;
            } else {
                jInsertEditorText('<hr id=\"system-readmore\" />', editor);
            }
        }
        ";

now when I try to call jInsertEditorText, I seem to get an error that's it's missing. some forum suggested I import mootools.js, but that didn't seem to do the trick.

Where can I find it or is there some other approach?

回答1:

jInsertEditorText is defined by the editor, not in mootools. Try using TinyMCE editor or JCE, both support it fully.



标签: joomla editor