Skip to content

Instantly share code, notes, and snippets.

@jdcauley
Last active December 17, 2015 19:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jdcauley/5660115 to your computer and use it in GitHub Desktop.
Save jdcauley/5660115 to your computer and use it in GitHub Desktop.
Add Ace Editor to Anchor Post and Page Area
<style type="text/css" media="screen">
#editor {
position: relative;
height: 400px;
}
</style>
<div id="editor"></div>
<fieldset class="main">
<div class="wrap">
<?php echo Form::textarea('html', Input::previous('html', $article->html), array(
'placeholder' => __('posts.content_explain'),
'id' => 'p-editor',
)); ?>
<?// php echo $editor; ?>
</div>
</fieldset>
<script src="http://rawgithub.com/ajaxorg/ace-builds/master/src-noconflict/ace.js" type="text/javascript" charset="utf-8"></script>
<script>
$( document ).ready(function() {
var editor = ace.edit("editor");
var textarea = $('textarea[id="p-editor"]').hide();
editor.getSession().setMode("ace/mode/html");
editor.getSession().setUseWrapMode(true);
editor.setShowPrintMargin(false);
editor.getSession().setValue(textarea.val());
editor.getSession().on('change', function(){
textarea.val(editor.getSession().getValue());
});
});
</script>
<fieldset class="main">
<div class="wrap">
<?php echo Form::textarea('html', Input::previous('html', $article->html), array(
'placeholder' => __('posts.content_explain')
)); ?>
<?php echo $editor; ?>
</div>
</fieldset>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment