{({ locale }) => {
return (
{
changeValue(e.target.value);
}}
/>
{!!maxLength && (
{`${locale.alreadyInput} ${(value || '').length}/${maxLength}`}
)}
);
}}
);
}
// 表格部分
const table = document.getElementById(`apolloTable_${tableId}`);
const cell = document.getElementById(`cellUnit_${tableId}_${rowId}_${columnName}`);
const tableRect = table && table.getBoundingClientRect();
const cellRect = cell && cell.getBoundingClientRect();
const style: any = {};
if (maxPopHeight) {
style.maxHeight = maxPopHeight;
}
if (tableRect && cellRect && maxPopHeight && maxPopHeight + cellRect.top > tableRect.bottom) {
style.bottom = 0;
style.top = 'auto';
}
delete selfProps.autoSize;
let lock = true;
// 中文输入法问题
const onCompositionStart = () => {
lock = false;
};
const onCompositionEnd = (e: any) => {
lock = true;
changeDivValue(e);
};
const changeDivValue = (e: any) => {
if (lock) {
let text = e.target.innerText;
if (text.length > maxLength) {
text = text.substr(0, maxLength);
e.target.innerText = text;
placeCaretAtEnd(divInput.current);
}
changeValue(text);
}
};
// 粘贴div(contenteditable = "true")富文本转为纯文本
const onPaste = (e: any) => {
e.stopPropagation();
e.preventDefault();
let text = '';
const event = e.originalEvent || e;
if (event.clipboardData && event.clipboardData.getData) {
text = event.clipboardData.getData('text/plain');
} else if (window.clipboardData && window.clipboardData.getData) {
text = window.clipboardData.getData('Text');
}
if (document.queryCommandSupported('insertText')) {
document.execCommand('insertText', false, text);
} else {
document.execCommand('paste', false, text);
}
};
return (