Skip to content

Instantly share code, notes, and snippets.

@CosmoMyzrailGorynych
Created July 19, 2017 00:29
Show Gist options
  • Save CosmoMyzrailGorynych/e61dfc0a51a564631670af199311ad8c to your computer and use it in GitHub Desktop.
Save CosmoMyzrailGorynych/e61dfc0a51a564631670af199311ad8c to your computer and use it in GitHub Desktop.
// * ———————————————————————————————————————————————————————— * //
// * markdown directives for SimpleMDE
// * ———————————————————————————————————————————————————————— * //
$.ajaxSetup({
cache: true
})
// inject SimpleMDE's css into the admin interface
$('head')
.append('<link rel="stylesheet" type="text/css" href="/assets/vendor/simplemde/dist/simplemde.min.css">')
.append(`
<style>
.control-simplemde .CodeMirror {
max-height: 30rem;
}
</style>
`)
enduro_admin_app.compileProvider
.directive('marked', function() {
return {
link: function(scope, element, attrs) {
$.getScript('/assets/vendor/simplemde/dist/simplemde.min.js', function () {
var options = {
element: element[0],
spellChecker: false
}
var mde = new SimpleMDE(options)
mde.codemirror.on('change', function () {
scope.context[scope.terminatedkey] = mde.value()
})
scope.simplemde = {
instance: mde
}
scope.$watch('current_culture', function () {
mde.value(scope.context[scope.terminatedkey] || '');
})
})
}
}
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment