|
|
|
@ -4,7 +4,7 @@
|
|
|
|
|
* @Github:
|
|
|
|
|
* @Date: 2019-12-18 08:49:30
|
|
|
|
|
* @LastEditors : tangjiang
|
|
|
|
|
* @LastEditTime : 2020-01-09 14:52:58
|
|
|
|
|
* @LastEditTime : 2020-01-10 15:05:27
|
|
|
|
|
*/
|
|
|
|
|
import './index.scss';
|
|
|
|
|
import 'quill/dist/quill.core.css'; // 核心样式
|
|
|
|
@ -40,7 +40,7 @@ Quill.register({
|
|
|
|
|
function QuillForEditor ({
|
|
|
|
|
placeholder,
|
|
|
|
|
readOnly,
|
|
|
|
|
autoFocus,
|
|
|
|
|
autoFocus = false,
|
|
|
|
|
options,
|
|
|
|
|
value,
|
|
|
|
|
imgAttrs = {}, // 指定图片的宽高
|
|
|
|
@ -196,7 +196,7 @@ function QuillForEditor ({
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
_quill.getModule('toolbar').addHandler('fill', (e) => {
|
|
|
|
|
console.log('点击了填空=====>>>>>>', e);
|
|
|
|
|
// console.log('点击了填空=====>>>>>>', e);
|
|
|
|
|
setFillCount(fillCount + 1);
|
|
|
|
|
const range = _quill.getSelection(true);
|
|
|
|
|
// _quill.insertText(range.index, '▁', { 'data_index': fillCount });
|
|
|
|
@ -232,16 +232,21 @@ function QuillForEditor ({
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const current = value
|
|
|
|
|
// console.log('+++++', current);
|
|
|
|
|
if (!deepEqual(previous, current)) {
|
|
|
|
|
setSelection(quill.getSelection())
|
|
|
|
|
if (typeof value === 'string') {
|
|
|
|
|
quill.clipboard.dangerouslyPasteHTML(value, 'api')
|
|
|
|
|
quill.clipboard.dangerouslyPasteHTML(value, 'api');
|
|
|
|
|
if (autoFocus) {
|
|
|
|
|
quill.focus();
|
|
|
|
|
} else {
|
|
|
|
|
quill.blur();
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
quill.setContents(value)
|
|
|
|
|
if (autoFocus) quill.focus();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}, [quill, value, setQuill]);
|
|
|
|
|
}, [quill, value, setQuill, autoFocus]);
|
|
|
|
|
|
|
|
|
|
// 清除选择区域
|
|
|
|
|
useEffect(() => {
|
|
|
|
@ -275,13 +280,6 @@ function QuillForEditor ({
|
|
|
|
|
}
|
|
|
|
|
}, [quill, handleOnChange]);
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (!quill) return;
|
|
|
|
|
if (autoFocus) {
|
|
|
|
|
quill.focus();
|
|
|
|
|
}
|
|
|
|
|
}, [quill, autoFocus]);
|
|
|
|
|
|
|
|
|
|
// 返回结果
|
|
|
|
|
return (
|
|
|
|
|
<div className='quill_editor_for_react_area' style={wrapStyle}>
|
|
|
|
|