JSFiddle - React, Tailwind, and code Playground
by ckissi
HTML
<link rel="stylesheet" href="https://cdn.bootcss.com/font-awesome/4.4.0/css/font-awesome.css">
<link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap.css">
<link rel="stylesheet" href="https://cdn.bootcss.com/summernote/0.8.3/summernote.css">
<script src="https://cdn.bootcss.com/jquery/2.1.4/jquery.js"></script>
<script src="https://cdn.bootcss.com/bootstrap/3.3.4/js/bootstrap.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.3/summernote.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.2.6/vue.min.js"></script>
<div class="container" id="app">
<editor :model.sync="text"></editor>
<div style="margin-top:40px">
<div> The HTML contents are as follows:</div>
<hr>
<div v-html="text"></div>
</div>
</div>
JavaScript
var summernoteComponent = {
replace: true,
inherit: false,
template: "<textarea class='form-control' :name='name'></textarea>",
props: {
model: {
required: true,
twoWay: true
},
language: {
type: String,
required: false,
default: "en-US"
},
height: {
type: Number,
required: false,
default: 160
},
minHeight: {
type: Number,
required: false,
default: 160
},
maxHeight: {
type: Number,
required: false,
default: 800
},
name: {
type: String,
required: false,
default: ""
},
toolbar: {
type: Array,
required: false,
default: function() {
return [
["font", ["bold", "italic", "underline", "clear"]],
["fontsize", ["fontsize"]],
["para", ["ul", "ol", "paragraph"]],
["color", ["color"]],
["insert", ["link", "hr", "img"]]
];
}
}
},
created: function() {
this.isChanging = false;
this.control = null;
},
mounted: function() {
// initialize the summernote
if (this.minHeight > this.height) {
this.minHeight = this.height;
}
if (this.maxHeight < this.height) {
this.maxHeight = this.height;
}
var me = this;
this.control = $(this.$el);
this.control.summernote({
lang: this.language,
height: this.height,
minHeight: this.minHeight,
maxHeight: this.maxHeight,
toolbar: this.toolbar,
callbacks: {
onInit: function() {
me.control.summernote("code", me.model);
...