We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 40088
    • 708 Posts
    Any of you talented addon devs interested in taking a look at Xing http://xing.github.io/wysihtml5/ to see if it can be made to work with MODX, both in the Manager but even more importantly on the front-end?

    Even if on the front-end it only worked as a plain-Jane editor without file upload capability, that would still be great.
      Todd
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      It's certainly easy enough to integrate, the hardest part was the styling of the toolbar.

      Of course, having a processor to handle the POST would be 90% of the battle for the front-end.
        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
        The form, with a minimal toolbar (unstyled):
        [[!processEditorForm]]
        <div id="wysihtml5-toolbar" style="display: none;">
          <a data-wysihtml5-command="bold">bold</a>
          <a data-wysihtml5-command="italic">italic</a>
        
          <!-- Some wysihtml5 commands require extra parameters -->
          <a data-wysihtml5-command="foreColor" data-wysihtml5-command-value="red">red</a>
          <a data-wysihtml5-command="foreColor" data-wysihtml5-command-value="green">green</a>
          <a data-wysihtml5-command="foreColor" data-wysihtml5-command-value="blue">blue</a>
        
          <!-- Some wysihtml5 commands like 'createLink' require extra paramaters specified by the user (eg. href) -->
          <a data-wysihtml5-command="createLink">insert link</a>
          <div data-wysihtml5-dialog="createLink" style="display: none;">
            <label>
              Link:
              <input data-wysihtml5-dialog-field="href" value="http://" class="text">
            </label>
            <a data-wysihtml5-dialog-action="save">OK</a> <a data-wysihtml5-dialog-action="cancel">Cancel</a>
          </div>
        </div>
        <form id="editor-form" action="[[~[[*id]]]]" method="post">
            <textarea id="wysihtml5-textarea" name="content" placeholder="Enter your text ..." autofocus>[[+xing.content]]</textarea>
            <input type="submit" name="submit" value="Submit">
        </form>

        And the snippet to load the javascript and process the form submission
        <?php
        $modx->regClientScript('assets/components/xing/parser_rules/advanced.js');
        $modx->regClientScript('assets/components/xing/dist/wysihtml5-0.3.0.min.js');
        $js = '<script>
            var editor = new wysihtml5.Editor("wysihtml5-textarea", { // id of textarea element
            toolbar:      "wysihtml5-toolbar", // id of toolbar element
            parserRules:  wysihtml5ParserRules // defined in parser rules set 
        });
        </script>';
        $modx->regClientScript($js);
        
        if(isset($_POST['content'])) {
            // sanitize and otherwise process submitted content here
            $modx->toPlaceholder('content', $_POST['content'], 'xing');
        }
        
        return;

          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
          Interesting. The latest version on github has the ability to make a div element editable. Now that would be a front-end editor!
            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
            It does leave a lot to be desired. The HTML mode is read-only, you can't edit the HTML. I'd say it has possibilities, but has a ways to go yet before it becomes really useful.
              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
              • 40088
              • 708 Posts
              Quote from: sottwell at Dec 21, 2014, 01:07 PM
              The HTML mode is read-only, you can't edit the HTML.

              In my brief test (w/ MODX) the HTML mode is indeed editable.
                Todd