|
|
@@ -1,12 +1,13 @@ |
|
|
|
frappe.ui.form.ControlMarkdownEditor = frappe.ui.form.ControlCode.extend({ |
|
|
|
editor_class: 'markdown', |
|
|
|
make_ace_editor() { |
|
|
|
this._super(); |
|
|
|
|
|
|
|
this.ace_editor_target.wrap('<div class="markdown-container">'); |
|
|
|
this.markdown_container = this.$input_wrapper.find('.markdown-container'); |
|
|
|
this.ace_editor_target.wrap(`<div class="${this.editor_class}-container">`); |
|
|
|
this.markdown_container = this.$input_wrapper.find(`.${this.editor_class}-container`); |
|
|
|
|
|
|
|
this.showing_preview = false; |
|
|
|
this.preview_toggle_btn = $(`<button class="btn btn-default btn-xs markdown-toggle">${__('Preview')}</button>`) |
|
|
|
this.preview_toggle_btn = $(`<button class="btn btn-default btn-xs ${this.editor_class}-toggle">${__('Preview')}</button>`) |
|
|
|
.click(e => { |
|
|
|
if (!this.showing_preview) { |
|
|
|
this.update_preview(); |
|
|
@@ -19,12 +20,10 @@ frappe.ui.form.ControlMarkdownEditor = frappe.ui.form.ControlCode.extend({ |
|
|
|
this.showing_preview = !this.showing_preview; |
|
|
|
|
|
|
|
$btn.text(this.showing_preview ? __('Edit') : __('Preview')); |
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
this.markdown_container.prepend(this.preview_toggle_btn); |
|
|
|
|
|
|
|
this.markdown_preview = $('<div class="markdown-preview border rounded">').hide(); |
|
|
|
this.markdown_preview = $(`<div class="${this.editor_class}-preview border rounded">`).hide(); |
|
|
|
this.markdown_container.append(this.markdown_preview); |
|
|
|
}, |
|
|
|
|
|
|
|