一、vue-quill-editor 与 quill
若使用版本1.0,这两个组件使用哪个都是一样的,无非代码有点偏差;若需要使用表格功能,必须使用 quill2.0 版本,因为 vue-quill-editor 不支持table功能。
二、webpack版本问题
在使用 quill-image-resize-module 组件做图片缩放功能时,需要全局引入quill,及在 vue.config.js 文件中进行如下配置:
const webpack = require('webpack');
// configureWebpack下添加
plugins: [
new webpack.ProvidePlugin({
'window.Quill': 'quill/dist/quill.js',
'Quill': 'quill/dist/quill.js'
})
]
但配置完发现项目还是报错,这里需要将 webpack5.0版本更换为 webpack4.0
三、图片文字复制粘贴功能
配合 quill-image-extend-module 组件实现图片上传到服务器的功能,具体参考:https://www.kancloud.cn/liuwave/quill/1434141
编辑器内粘贴文字基本没啥问题,好多人都困在了粘贴图片需要上传至文件服务器的问题上,最简单的方法就是添加一个粘贴事件,示例如下:
<div class="editor" ref="editor" @paste="imgPasteHandler($event)"></div>
// 监听粘贴事件
imgPasteHandler(e) {
if (e.clipboardData && e.clipboardData.files && e.clipboardData.files.length) {
e.preventDefault();
[].forEach.call(e.clipboardData.files, file => {
let fileName = file.name;
let fileType = fileName.substring(fileName.lastIndexOf('.') + 1, fileName.length);
console.log('file