Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+2 votes
622 views
in Plugins by
I want to use an editor instead of textarea in a plugin I developed. How can I add the editor to the form?
Q2A version: 1.8.5

2 Answers

+3 votes
by
selected by
 
Best answer
+3 votes
by

In order to use an editor, you need to:

  • Include the editor script (usually you put the javascript file(s) between the <head> tags).
  • Your field (here in this case is the textarea field) must contain ID and name values.
  • Another script to "connect" the field' ID with the editor.

Q2A editors, by default, only works if your field contains id="content" name="content"

If your plugin's field isn't "content". You have to make a custom script to "connect" the editor and the field ID.

I once used original CKeditor 4 scripts (downloaded from CKeditor website), and one of the scripts will let you define which textarea field can be integrated with CKeditor.

The easiest trick:

<!DOCTYPE html>
<html>
        <head>
                <meta charset="utf-8">
                <title>CKEditor</title>
                <script src="https://cdn.ckeditor.com/4.15.0/standard/ckeditor.js"></script>
        </head>
        <body>
                <textarea name="editor1"></textarea>
                <script>
                        CKEDITOR.replace( 'editor1' );
                </script>
        </body>
</html>

...