UNPKG

jodit-vue

Version:
57 lines (56 loc) 1.6 kB
import { Jodit as n } from "jodit"; import { Jodit as _ } from "jodit"; import { openBlock as r, createElementBlock as u } from "vue"; const a = (t, o) => { const e = t.__vccOpts || t; for (const [i, s] of o) e[i] = s; return e; }, d = { name: "JoditEditor", props: { modelValue: { type: String, required: !0 }, buttons: { type: Array, default: null }, extraButtons: { type: Array, default: null }, config: { type: Object, default: () => ({}) }, plugins: { type: Array, default: () => [] } }, emits: ["update:modelValue"], data: () => ({ editor: null }), computed: { editorConfig() { const t = { ...this.config }; return this.buttons && (t.buttons = this.buttons, t.buttonsMD = this.buttons, t.buttonsSM = this.buttons, t.buttonsXS = this.buttons), this.extraButtons && (t.extraButtons = this.extraButtons), t; } }, watch: { modelValue(t) { this.editor.value !== t && (this.editor.value = t); } }, mounted() { this.plugins.length && this.plugins.forEach((t) => { n.plugins.add(t.name, t.callback); }), this.editor = n.make(this.$el, this.editorConfig), this.editor.value = this.modelValue, this.editor.events.on( "change", (t) => this.$emit("update:modelValue", t) ); }, beforeUnmount() { this.editor.destruct(); } }; function l(t, o, e, i, s, p) { return r(), u("textarea"); } const c = /* @__PURE__ */ a(d, [["render", l]]), m = { install: (t) => { t.component("JoditEditor", c); } }; export { _ as Jodit, c as JoditEditor, c as JoditVue, m as default };