update quill autofocus

dev_static
tangjiang 5 years ago
parent fc1b0895bb
commit 6f5ea589f4

@ -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}>

@ -4,7 +4,7 @@
* @Github:
* @Date: 2019-11-20 10:35:40
* @LastEditors : tangjiang
* @LastEditTime : 2020-01-09 16:54:45
* @LastEditTime : 2020-01-10 15:06:23
*/
import './index.scss';
// import 'katex/dist/katex.css';
@ -453,6 +453,7 @@ class EditTab extends React.Component {
colon={ false }
>
<QuillForEditor
autoFocus={true}
style={{ height: '200px' }}
placeholder="请输入描述信息"
onContentChange={handleContentChange}

Loading…
Cancel
Save