Incoporate iframe social networks on wysiwyg - TinyMce

-1

Oops, anyone know how I can add option to add or in ckeditor or tinymce, options similar to this:

Byaddingtheiframeofasocialnetwork,theembeddingblockgoesdirectlytotheeditor'sbody.

IwasabletoinsertacustombuttoninTinyMCE,byclickingonitamodalisopened,fromthereinsertedintheeditorbody,but,Icouldnotaddmorethanonebutton,howcanIaddmorethanonebuttoninTinyMCE?

<head><scriptsrc="http://cdn.tinymce.com/4/tinymce.min.js"></script>
    <script>
        tinymce.init({
            selector: 'textarea#textarea_content',
            height: 500,
            toolbar: 'mybutton',
            menubar: false,

            setup : function(editor)
            {
                editor.addButton('mybutton', {
                  text: 'My button',
                  icon: false,
                  onclick: function () {
                        editor.windowManager.open({
                            title: 'Example plugin',
                            body: [
                                {type: 'textbox', name: 'title', label: 'Title'}
                            ],
                            onsubmit: function(e) {
                                editor.insertContent(e.data.title);
                            }
                        });
                  }
                });
            }
        });
    </script>
</head>
<body>
    <textarea id="textarea_content" cols="85" rows="10"></textarea>

</body>
    
asked by anonymous 09.09.2016 / 22:54

1 answer

0

I solved it as follows:

<!DOCTYPE html>
<html>
    <head>
        <script src="http://cdn.tinymce.com/4/tinymce.min.js"></script><scriptasyncsrc="//platform.twitter.com/widgets.js" charset="utf-8"></script>

        <script>

        tinyMCE.PluginManager.add('stylebuttons', function(editor, url) {
          ['pre', 'p', 'code', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'].forEach(function(name){
           editor.addButton("style-" + name, {
               tooltip: "Toggle " + name,
                 text: name.toUpperCase(),
                 onClick: function() { editor.execCommand('mceToggleFormat', false, name); },
                 onPostRender: function() {
                     var self = this, setup = function() {
                         editor.formatter.formatChanged(name, function(state) {
                             self.active(state);
                         });
                     };
                     editor.formatter ? setup() : editor.on('init', setup);
                 }
             })
          });
        });
            tinymce.init({
                selector: 'textarea#textarea_content',
                themes: "advanced",
                height: 500,
                toolbar: 'undo redo | bold italic |  style-h2 style-h3  | bullist numlist | link | facebook youtube twitter | code',
                menubar: false,
                plugins: "stylebuttons link code",
                default_link_target: "_blank",
                language_url : 'langs/pt_BR.js',
                language: 'pt_BR',
                setup : function(editor)
                {
                    editor.addButton('facebook', {
                      title:'Adicionar Incorporação do Facebook',
                      text: '',
                      image: 'https://image.freepik.com/free-icon/facebook-symbol_318-37686.jpg',
                      icon: true,
                      onclick: function () {
                            editor.windowManager.open({
                                title: 'Adicione conteúdo do Facebook',
                                body: [
                                    {type: 'textbox', name: 'title', label: 'Link'}
                                ],
                                onsubmit: function(e) {
                                    editor.insertContent(e.data.title);
                                }
                            });
                      }
                    });

                        editor.addButton('youtube', {
                            title:'Adicionar Incorporação do Youtube',
                            text: '',
                            image: 'http://safari-adventures.com/wp-content/uploads/2015/07/you-tube-icon.png',
                            icon: true,
                          onclick: function () {
                                editor.windowManager.open({
                                    title: 'Adicione conteúdo do Youtube',
                                    body: [
                                        {type: 'textbox', name: 'title', label: 'Link'}
                                    ],
                                    onsubmit: function(e) {
                                        editor.insertContent(e.data.title);
                                    }
                                });
                          }
                        });

                            editor.addButton('twitter', {
                                title:'Adicionar Incorporação do Twitter',
                                text: '',
                                image: 'http://www.bentleys.com.au/getattachment/sa/Twitter-B-W2.png',
                                icon: true,
                              onclick: function () {
                                    editor.windowManager.open({
                                        title: 'Adicione conteúdo do Twitter',
                                        body: [
                                            {type: 'textbox', name: 'title', label: 'Link'}
                                        ],
                                        onsubmit: function(e) {
                                            editor.insertContent(e.data.title);
                                        }
                                    });
                              }
                            });
                }
            });
        </script>
    </head>
    <body>
        <textarea id="textarea_content" cols="85" rows="10"></textarea>

    </body>
</html>

For the Portuguese translation, just download the pt_BR on this page:

link

and add the langs folder, as it is in the language setting in: language_url: 'langs/pt_BR.js'

    
10.09.2016 / 23:17