Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Omda's avatar
Level 1

How to add plugin to Tinymce

I am working with tinymce and i need to add plugin , i fallow documetation of tinymce to add new plugin..

as documentation on tinymce plugin look like :

tinymce.PluginManager.add('example', function(editor, url) {
  var openDialog = function () {
    return editor.windowManager.open({
      title: 'Example plugin',
      body: {
        type: 'panel',
        items: [
          {
            type: 'input',
            name: 'title',
            label: 'Title'
          }
        ]
      },
      buttons: [
        {
          type: 'cancel',
          text: 'Close'
        },
        {
          type: 'submit',
          text: 'Save',
          primary: true
        }
      ],
      onSubmit: function (api) {
        var data = api.getData();
        // Insert content when the window form is submitted
        editor.insertContent('Title: ' + data.title);
        api.close();
      }
    });
  };
  
  // Add a button that opens a window
  editor.ui.registry.addButton('example', {
    text: 'My button',
    onAction: function () {
      // Open window
      openDialog();
    }
  });

  // Adds a menu item, which can then be included in any menu via the menu/menubar configuration
  editor.ui.registry.addMenuItem('example', {
    text: 'Example plugin',
    onAction: function() {
      // Open window
      openDialog();
    }
  });

  return {
    getMetadata: function () {
      return  {
        name: "Example plugin",
        url: "http://exampleplugindocsurl.com"
      };
    }
  };
});

and put it into seperate file called plugins/example/plugin.js and added to tinymce using this script :

{
  selector: "#editor",
  directionality: "rtl",
  branding: false,
  height: 500,
  theme: "modern",
  // toolbar: 'mybutton',
  external_plugins: {
    'example': "plugins/example/plugin.js",
  },
  plugins:
    "example",
}

and after run it i get undefiend tinymce

what can I do to fixed ??

0 likes
5 replies
bobbybouwmann's avatar

So it's important that the tinymce script is loaded before you add a new plugin. If you don't you can't find tinymce itself as well. So how do you load tinymce in your javascript?

Omda's avatar
Level 1

loading like this :

<template>
   <div class="editor-container">
      <form @submit.prevent="update_content" class="editor-editor">
        <text-editor
          :class="{'element_index_id': true}"
          v-model="content"
          api-key="5qido9zdxhj8pkkpn0b209on29euh2yfnosp41qcu1mw788j"
          :init="tinymce_config"
          @onSaveContent="updateContent"
        ></text-editor>
      </form>
    </div>
</template>

in javascript :

<script>
import textEditor from "@tinymce/tinymce-vue";
import tinymcConfig from "../../../services/config/tinymc";

export default {

    components: {
          textEditor
   },
   computed: {
        tinymce_config() {

            // Load css to indexes
            tinymcConfig.content_style = this.style;

        // Loading  all config
            return tinymcConfig; 
        },
   },
   method:{
    updateContent() {
      this.$store.dispatch("update_content").then(response => {});
    }
   }

}
bobbybouwmann's avatar

Basically you need to load tinymce, which will be stored on the window object. From there you can add the plugin

window.tinymce.PluginManager.add
1 like
Omda's avatar
Level 1

thanks @bobbybouwmann for your consideration to help me, thanks a lot..

it is not working yet but you have brought me closer to the point of view

Please or to participate in this conversation.