We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 28042 ☆ A M B ☆
    • 24,524 Posts
    MarkItUp is a very nice JQuery content (not code!) markup editor. It comes with several modes, html, bbcode, textile, etc. and it's not at all difficult to add custom modes, such as a modx mode for inserting MODx tags maybe.

    I plan to begin with a crude plugin, then turn it into a proper Revo package. It will have a "front-end" mode to make it easy to embed into front-end forms. The Manager would only have use for its html mode, but a front-end implementation should have the option of using one of its other modes (somebody has already asked about bbcode or markdown editors for the front-end).

    There is an Evo plugin by the Russian community (at least I'm pretty sure that's Russian) http://modx.im/blog/addons/65.html

    So far for the proper Revo package I'm examining the CodeMirror package. This will be very similar in operation, so I'm hoping I can just modify CodeMirror's structure and code.

    For the Manager, the only forms that would have a use for this would be Templates, Chunks and Resources.

    The really nasty part is going to be getting it hooked up with the file browser for inserting images and the resource search feature as well as the file browser for inserting links. I intend to get it to respect media sources so that a limited editor user will only have access to his media source. But that can come later.

    All comments, suggestions and assistance will be more than welcome.
      Studying MODX in the desert - http://sottwell.com
      Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
      Join the Slack Community - http://modx.org
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      One question that comes up immediately is, what form fields do we want this enabled for? All textareas in all of the forms have the classname x-form-textarea, so it would be very easy to enable it for all textarea fields, either by classname or simply by element. It can be invoked by ID, classname, or in all textareas. I'm inclined to go with all text areas in the form.

      Thoughts?

        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 28042 ☆ A M B ☆
        • 24,524 Posts
        Hm. It appears, thanks to the oh-so-clever mix of ExtJS, Smarty and AJAX way of building the Manager pages, that you can't simply do ordinary jquery document.ready stuff to the form fields in a plugin because they don't exist when the page is loaded, until the AJAX does its thing. What fun.
          Studying MODX in the desert - http://sottwell.com
          Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
          Join the Slack Community - http://modx.org
          • 3749
          • 24,544 Posts
          I ran into the same thing and never did find a solution. Some parts of the page don't exist until you click on something.

          You could try:

          $(window).load(function() {
           alert("page is ready");  /* your function here */
          });


          Though it will mean the user will have to wait until *everything* is loaded.
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            Well, I'm still examining the CodeMirror code to see what it does...

            The codemirror.class.php file makes reference to a connector.php file in line 22, but there is no such connector.
            $connectorUrl = $assetsUrl.'connector.php';


            I also noticed that in codemirror.plugin.php lines 2 and 21 are duplicates
            		'OnFileEditFormPrerender',
            		'OnFileEditFormPrerender',
            


            More to the point, however, I see things like this
                case 'OnDocFormPrerender':
                	$options['modx_loader'] = 'onResource';
                    $options['mode'] = 'htmlmixed';
                    $load = true;
                	break;
            

            Then if $load is true, it loads up the javascript and css files with ordinary regClientWhatver() functions.

            So I'm thinking perhaps I can just copy all of the CodeMirror files and settings, then hijack them to read markitup instead of codemirror. Worth a try, anyway...

            A few weirdnesses in the tinymce package, too...
            <?php
            /**
             * TinyMCE Connector
             *
             * @package quip
             */
            

            And in the tinymceclass.php file...
                    /* will need to do $this->modx->controller->addHtml() for Revo 2.2+ */
                    $this->modx->regClientStartupHTMLBlock($script);
                    return '';
            


            Except that codemirror doesn't have a controller file, but it does have an entry in the Actions list. Hm. I'm beginning to see a vague outline of the picture here, I think.
              Studying MODX in the desert - http://sottwell.com
              Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
              Join the Slack Community - http://modx.org
              • 3749
              • 24,544 Posts
              <?php
              /**
               * TinyMCE Connector
               *
               * @package quip
               */

              Just the kind of thing I wrote MyComponent to prevent. wink Before using it, I was always cutting and pasting header comments and doing case-sensitive search-and-replace options that missed stuff, although MyComponent is still not up-to-speed on connectors, controllers, and processors -- someday (sigh).
                Did I help you? Buy me a beer
                Get my Book: MODX:The Official Guide
                MODX info for everyone: http://bobsguides.com/modx.html
                My MODX Extras
                Bob's Guides is now hosted at A2 MODX Hosting