We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 4574
    • 2 Posts
    I’m a little stuck. I’ve attempted to load the relevant files (those that are called by the Manager when TinyMCE is needed to edit a Resource):


    // header.php

    $modx->regClientStartupScript($modx->config[’assets_url’].’components/tinymce/jscripts/tiny_mce/tiny_mce.js’);
    $modx->regClientStartupScript($modx->config[’assets_url’].’components/tinymce/xconfig.js’);
    $modx->regClientStartupScript($modx->config[’assets_url’].’components/tinymce/tiny.min.js’);

    // ...snip...

    ...and initialize an editor...


    $modx->regClientStartupHTMLBlock(
    ’<script type="text/javascript">
    Ext.onReady(function() {

    tinyMCE.init({
    theme : "advanced",
    mode : "none",
    theme_advanced_buttons1 : "bold,italic,underline,undo,redo,link,unlink,formatselect,removeformat,cleanup",
    theme_advanced_buttons2 : "",
    theme_advanced_buttons3 : "",
    theme_advanced_toolbar_location : "top",
    theme_advanced_toolbar_align : "center",
    theme_advanced_styles : "Code=codeStyle;Quote=quoteStyle",
    entity_encoding : "raw",
    add_unload_trigger : false,
    remove_linebreaks : false,
    inline_styles : false,
    convert_fonts_to_spans : false
    });

    // ...

    });

    </script>’);

    Here’s the ExtJS window that contains the rich-text field:

    Shepherd.window.CreateArticle = function(config) {
        config = config || {};
        Ext.applyIf(config,{
                title: _('shepherd.article_create')
               ,url: Shepherd.config.connectorUrl
               ,baseParams: { action: 'mgr/article/create' }
               ,width: 800
               ,fields:
                  [{ xtype: 'textfield'
                         ,fieldLabel: _('shepherd.article_title')
                         ,name: 'title'
                         ,width: 300
                         },{
                     xtype: 'textarea'
                         ,fieldLabel: _('shepherd.article_content')
                         ,name: 'content'
                         ,id: 'shepherd-article-content'
                         ,width: 600
                         },{
                     xtype: 'shepherd-combo-authors'
                         ,fieldLabel: 'Author'
                         } ]
        });
        Shepherd.window.CreateArticle.superclass.constructor.call(this,config);
    };


    Blindly, I tried adding
    tinyMCE.execCommand('mceToggleEditor', false, 'shepherd-article-content');
    before the final line of the definition, to no avail.

    Any help much appreciated.
      • 4574
      • 2 Posts
      For future explorers: you can use the Ext.ux.TinyMCE extension to make the ’tinymce’ xtype available to your scripts.



      Cool!
        • 33976 ☆ A M B ☆
        • 571 Posts
        Much thanks for the link
        --
        A future explorer wink
          • 19534
          • 183 Posts
          Hey!

          Thanks for sharing. Can you provide some more details how you were able to use 'tinymce' xtype? Which libraries did you include? I tried to get it working but didn't succeed.

          Thanks!
            Add-On to easily manage your multilingual sites: Babel
            • 33976 ☆ A M B ☆
            • 571 Posts
            mikrobi,

            Since this post, Mark found a cleaner way to integrate TinyMCE in CMPs. You might want to check how he did for Gallery : https://github.com/Mark-H/Gallery/commit/417f203685d147e018363cb4df0d627757d029da
              • 1778
              • 659 Posts
              Hello
              I checked and attempt to apply the integration of TMCE in a CMP ass you suggest in your post...
              It works but I have a NOTICE error
              Notice: Undefined index: resource in C:\wamp\www\revo23\core\components\tinymce\tinymce.class.php on line 186
              

              At this time I just disabled the E_NOTICE when loading TinyMCE to avoid it ... not sure it's the best way...
              Cheers [ed. note: anso last edited this post 14 years, 4 months ago.]
                • 15083
                • 697 Posts
                Guys I would argue that cantlins solution is more straight forward smiley

                If your familiar with ExtJs it just creates an new xtype, so swapping out Ext.htmleditors is made very easy for their more "advanced" TinyMCE cousins smiley