Last active
December 17, 2015 19:28
-
-
Save jdcauley/5660115 to your computer and use it in GitHub Desktop.
Add Ace Editor to Anchor Post and Page Area
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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