-
☆ 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.
-
☆ 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;
-
☆ 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!
-
☆ 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.