Commit 2c868f47 authored by Pan's avatar Pan

fix:fix tinymce bug in <keep-alive>

parent 1ae31fdd
......@@ -52,6 +52,16 @@ export default {
}
},
mounted() {
this.initTinymce()
},
activated() {
this.initTinymce()
},
deactivated() {
this.destroyTinymce()
},
methods: {
initTinymce() {
const _this = this
window.tinymce.init({
selector: `#${this.tinymceId}`,
......@@ -67,7 +77,6 @@ export default {
code_dialog_width: 1000,
advlist_bullet_styles: 'square',
advlist_number_styles: 'default',
block_formats: '普通标签=p;小标题=h2;',
imagetools_cors_hosts: ['wpimg.wallstcn.com', 'wallstreetcn.com'],
imagetools_toolbar: 'watermark',
default_link_target: '_blank',
......@@ -81,7 +90,7 @@ export default {
this.hasChange = true
this.$emit('input', editor.getContent({ format: 'raw' }))
})
},
}
// 整合七牛上传
// images_dataimg_filter(img) {
// setTimeout(() => {
......@@ -115,41 +124,11 @@ export default {
// console.log(err);
// });
// },
setup(editor) {
editor.addButton('h2', {
title: '小标题', // tooltip text seen on mouseover
text: '小标题',
onclick() {
editor.execCommand('mceToggleFormat', false, 'h2')
},
onPostRender() {
const btn = this
editor.on('init', () => {
editor.formatter.formatChanged('h2', state => {
btn.active(state)
})
})
}
})
editor.addButton('p', {
title: '正文',
text: '正文',
onclick() {
editor.execCommand('mceToggleFormat', false, 'p')
},
onPostRender() {
const btn = this
editor.on('init', () => {
editor.formatter.formatChanged('p', state => {
btn.active(state)
})
})
}
})
}
})
destroyTinymce() {
window.tinymce.get(this.tinymceId).destroy()
},
methods: {
setContent(value) {
window.tinymce.get(this.tinymceId).setContent(value)
},
......@@ -164,7 +143,7 @@ export default {
}
},
destroyed() {
window.tinymce.get(this.tinymceId).destroy()
this.destroyTinymce()
}
}
</script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment