fastlion-amis
Version:
一种MIS页面生成工具
496 lines (495 loc) • 31.5 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var react_1 = (0, tslib_1.__importDefault)(require("react"));
var editor_for_react_1 = require("@wangeditor/editor-for-react");
require("@wangeditor/editor/dist/css/style.css");
var antd_1 = require("antd");
var Input_1 = (0, tslib_1.__importDefault)(require("antd/lib/input/Input"));
var Html_1 = (0, tslib_1.__importDefault)(require("./Html"));
var ErrorBound_1 = (0, tslib_1.__importDefault)(require("./ErrorBound"));
// 转化旧文本的key
var TRANSLATEKEY = 'TRANSLATEOLD';
// 转化旧文本的key
var TRANSLATERULESKEY = 'TRANSLATERULES';
var onlyNumberReg = /^[-+]?\d+(\.\d+)?$/;
var onlyPriceReg = /[¥$€元][-+]?\d*(\.\d+)?/;
var RichText = /** @class */ (function (_super) {
(0, tslib_1.__extends)(RichText, _super);
function RichText() {
var _a, _b, _c;
var _this = _super.apply(this, arguments) || this;
_this.editorRef = react_1.default.createRef();
_this.state = {
editor: null,
originModel: '',
clickCount: 0,
selectTempLate: (_a = JSON.parse(localStorage.getItem(TRANSLATERULESKEY))) === null || _a === void 0 ? void 0 : _a.lastActiveRule,
templateName: (_b = JSON.parse(localStorage.getItem(TRANSLATERULESKEY))) === null || _b === void 0 ? void 0 : _b.lastActiveRule,
showEmpty: (_c = JSON.parse(localStorage.getItem(TRANSLATERULESKEY))) === null || _c === void 0 ? void 0 : _c.showEmpty,
};
_this.watchInput = function (e) {
if (e.code === 'KeyE')
_this.setState({ clickCount: _this.state.clickCount + 1 });
if (_this.state.clickCount > 3) {
localStorage.setItem(TRANSLATEKEY, '1');
}
};
_this.edit = false;
_this.FontList = [
{ name: '小六(6.5)', value: '8px' },
{ name: '六号(7.5)', value: '10px' },
{ name: '小五(9)', value: '12px' },
{ name: '五号(10.5)', value: '14px' },
{ name: '小四(12)', value: '16px' },
{ name: '四号(14)', value: '18px' },
{ name: '小三(15)', value: '20px' },
{ name: '三号(16)', value: '21px' },
{ name: '小二(18)', value: '24px' },
{ name: '二号(22)', value: '29px' },
{ name: '小一(24)', value: '32px' },
{ name: '一号(26)', value: '34px' },
{ name: '小初(36)', value: '48px' },
{ name: '初号(42)', value: '59px' },
'13px',
'15px',
'19px',
'22px',
'40px',
{ name: '10', value: '10pt' },
{ name: '30', value: '30pt' },
{ name: '50', value: '50pt' },
{ name: '70', value: '70pt' },
];
return _this;
}
;
RichText.prototype.componentDidMount = function () {
this.setState({ originModel: this.props.model });
document.addEventListener('keydown', this.watchInput);
window.editorInstance = this;
};
RichText.prototype.componentWillUnmount = function () {
document.removeEventListener('keydown', this.watchInput);
};
RichText.prototype.componentDidUpdate = function (prevProps, prevState, snapshot) {
};
RichText.prototype.strToHtmlEl = function (str) {
var div = document.createElement('div');
div.innerHTML = str;
return div;
};
RichText.prototype.structuralTextDataToDescripbe = function (htmlStr, templateName) {
var structuralData = this.structuralTextData(htmlStr);
var alignDescribe = { 'start': '居左', 'center': '居中', right: '居右' };
var describe = templateName + "\n";
structuralData.map(function (_, index) {
var _a;
var pText = "\u7B2C" + (index + 1) + "\u884C " + (_.textAlign ? ('文本位置:' + alignDescribe[_.textAlign || '']) : '') + " \u884C\u9AD8\uFF1A" + (_.textLineHeight || '1') + " " + ((_a = _.textIndent) !== null && _a !== void 0 ? _a : "\u7F29\u8FDB" + _.textIndent) + "\n";
_.children.map(function (text, textIndex) {
var textStr = " \u7B2C" + (textIndex + 1) + "\u90E8\u5206 \u5B57\u4F53:" + (text.textFont || '平台默认字体') + " \u5B57\u53F7:" + (text.textSize || '平台字号') + " " + (text.bold ? '加粗' : '') + " " + (text.underLine ? '下划线' : '') + " \u989C\u8272:" + (text.color || '默认颜色') + " \u6587\u5B57\u524D\u7A7A\u683C\uFF1A" + (text.afterWhiteSpceCount || 0) + " \u6587\u5B57\u540E\u7A7A\u683C\uFF1A" + (text.preWhiteSpceCount || 0) + " \u539F\u6587\u5B57:" + text.originText + " |";
pText += textStr + '\t';
});
pText += '\n';
describe += pText;
});
return describe;
};
// 结构化富文本数据
RichText.prototype.structuralTextData = function (htmlStr) {
var rootEl = this.strToHtmlEl(htmlStr);
var structChildTextNodeData = function (childNodes) {
var children = Array.from(childNodes);
var treeArr = [];
// 文本节点
children.map(function (_) {
var textContent = _.textContent;
var nodeName = _.nodeName;
var defaultAttr = {
nodeType: 'text',
children: [],
};
var textArr = [];
// 如果中间有空格 - 分为多块
if ((textContent === null || textContent === void 0 ? void 0 : textContent.trim().split(' ')) && !/^\s+$/.test(textContent)) {
textArr.push.apply(textArr, textContent === null || textContent === void 0 ? void 0 : textContent.trim().split(/\s+/));
}
else {
textArr.push(_);
}
textArr.map(function (childtext, index) {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
var whiteSpaceArr = ((_a = String(_.textContent)) === null || _a === void 0 ? void 0 : _a.trim().match(/\s+/g)) || [];
var textContent = childtext.textContent || childtext;
// 如果是被拆分的空字符串就不用走
if (!((_c = (_b = String(textContent)) === null || _b === void 0 ? void 0 : _b.trim) === null || _c === void 0 ? void 0 : _c.call(_b)) && typeof childtext === 'string')
return;
var attr = (0, tslib_1.__assign)({}, defaultAttr);
// 如果不是纯文本节点
if (nodeName !== '#text') {
var textStyle = _.style;
// 是否粗体
attr.bold = _.innerHTML.includes('\<strong\>');
// 是否下划线
attr.underLine = _.innerHTML.includes('\<u\>');
//文本字体
attr.textFont = textStyle.fontFamily;
//文本大小
attr.textSize = textStyle.fontSize;
//文本颜色
attr.color = textStyle.color;
//背景颜色
attr.bgColor = textStyle.backgroundColor;
// 元字符长度
attr.originTextWidth = (textContent === null || textContent === void 0 ? void 0 : textContent.length) || 0;
attr.originText = typeof textContent === 'string' ? (textContent || '') : '';
//前空格 能直接使用 whiteSpaceArr?.shift() 是因为去掉了首尾空格计算的 故 whiteSpaceArr必定是中间 的
attr.preWhiteSpceCount = index === 0 ? (_f = (_e = (_d = _ === null || _ === void 0 ? void 0 : _.textContent) === null || _d === void 0 ? void 0 : _d.match(/^\s+/g)) === null || _e === void 0 ? void 0 : _e[0]) === null || _f === void 0 ? void 0 : _f.length : (((_g = whiteSpaceArr === null || whiteSpaceArr === void 0 ? void 0 : whiteSpaceArr.shift()) === null || _g === void 0 ? void 0 : _g.length) || 0);
attr.afterWhiteSpceCount = (index === textArr.length - 1) ? (_k = (_j = (_h = _ === null || _ === void 0 ? void 0 : _.textContent) === null || _h === void 0 ? void 0 : _h.match(/\s+$/g)) === null || _j === void 0 ? void 0 : _j[0]) === null || _k === void 0 ? void 0 : _k.length : 0;
//文本类型
if (onlyNumberReg.test(((_l = textContent === null || textContent === void 0 ? void 0 : textContent.trim) === null || _l === void 0 ? void 0 : _l.call(textContent)) || ''))
attr.textType = 'pureNumber';
if (onlyPriceReg.test(((_m = textContent === null || textContent === void 0 ? void 0 : textContent.trim) === null || _m === void 0 ? void 0 : _m.call(textContent)) || ''))
attr.textType = 'purePrice';
}
treeArr.push(attr);
});
});
var validResult = [];
// 前格式剩下的白字符
var preRestWhite = 0;
treeArr.map(function (_) {
var _a;
// 如果前面是纯空串
if (/^\s+$/.test(_.originText || '')) {
preRestWhite += ((_a = _.originText) === null || _a === void 0 ? void 0 : _a.length) || 0;
}
else {
//遇到第一个有文本的内容就进行合并
// 白字符合并
_.preWhiteSpceCount = (_.preWhiteSpceCount || 0) + preRestWhite;
preRestWhite = 0;
validResult.push(_);
// 如果有后空字符串 加入剩下的白字符串
if (_.afterWhiteSpceCount) {
preRestWhite += _.afterWhiteSpceCount;
}
}
});
return validResult;
};
// 结构树
var structTree = [];
// 第一层 段落节点
// 仅有段落功能可以使用
Array.from(rootEl.children).map(function (_) {
var ComputedStyle = _.style;
structTree.push({
nodeType: 'P',
textLineHeight: ComputedStyle.lineHeight,
textAlign: ComputedStyle.textAlign,
textIndent: ComputedStyle.textIndent,
children: structChildTextNodeData(_.childNodes)
});
});
return structTree;
};
RichText.prototype.transFormatToHtml = function (ruleName, textTree, showEmpty) {
if (showEmpty === void 0) { showEmpty = true; }
var translateRuelsStorage = JSON.parse(localStorage.getItem(TRANSLATERULESKEY));
var template = translateRuelsStorage.templates.find(function (_) { return _.name === ruleName; });
var rootEl = this.strToHtmlEl('');
var colorIndex = 0;
var ColorArr = textTree ? [''] : ['#a1c4fd', '#d4fc79', '#f5576c', '#fa71cd', '#008080', '#9B59B6', '#03A9F4'];
// 第一行段落
// 如果是单行的 特殊处理下,根据模板数量自动补齐
if ((textTree === null || textTree === void 0 ? void 0 : textTree.length) === 1) {
var curTextTree_1 = [];
template === null || template === void 0 ? void 0 : template.htmlTemp.map(function (_) {
var _a, _b;
curTextTree_1.push(((_a = textTree === null || textTree === void 0 ? void 0 : textTree[0]) === null || _a === void 0 ? void 0 : _a.splice(0, (_b = _ === null || _ === void 0 ? void 0 : _.children) === null || _b === void 0 ? void 0 : _b.length)) || []);
});
textTree = curTextTree_1;
}
template === null || template === void 0 ? void 0 : template.htmlTemp.map(function (pEl, index) {
var _a;
var p = document.createElement('p');
p.style.lineHeight = pEl.textLineHeight || '';
p.style.textAlign = pEl.textAlign || '';
p.style.textIndent = pEl.textIndent || '';
p.style.margin = '0px';
pEl.children.map(function (textChildren, childIndex) {
var _a, _b;
var lastChildEl;
var span = document.createElement('span');
lastChildEl = span;
// 按照 下划线 粗体 来进行字体添加
if (textChildren.underLine) {
var tempEL = document.createElement('u');
lastChildEl.append(tempEL);
lastChildEl = tempEL;
}
if (textChildren.bold) {
var tempEL = document.createElement('strong');
lastChildEl.append(tempEL);
lastChildEl = tempEL;
}
// 设置文本 如果展示空值 就显示预留文本-如果指定原值展示 就展示原值
var showText = "" + new Array(textChildren.preWhiteSpceCount).fill(' ').join('') + ((!textChildren.lockOriginText ? (_a = textTree === null || textTree === void 0 ? void 0 : textTree[index]) === null || _a === void 0 ? void 0 : _a[childIndex] : textChildren.originText) || '');
lastChildEl.innerHTML = showEmpty ? (((_b = textTree === null || textTree === void 0 ? void 0 : textTree[index]) === null || _b === void 0 ? void 0 : _b[childIndex]) ? showText : "\u7EC4" + (childIndex + 1) + "\uFF1A" + new Array(textChildren.preWhiteSpceCount).fill(' ').join('') + (textChildren.originText || '')) : showText;
span.style.fontFamily = textChildren.textFont || '';
span.style.fontSize = textChildren.textSize || '';
span.style.color = textChildren.color || '';
span.style.backgroundColor = textChildren.bgColor || ColorArr[colorIndex];
colorIndex++;
if (colorIndex > ColorArr.length)
colorIndex = 0;
p.append(span);
});
// 把剩下的加上去
if ((((_a = textTree === null || textTree === void 0 ? void 0 : textTree[index]) === null || _a === void 0 ? void 0 : _a.length) || 0) > pEl.children.length) {
var lastChild = p.lastChild;
if (lastChild === null || lastChild === void 0 ? void 0 : lastChild.innerText)
lastChild.innerText += (textTree === null || textTree === void 0 ? void 0 : textTree[index].slice(pEl.children.length).join('')) || '';
}
rootEl.appendChild(p);
});
return rootEl.innerHTML;
};
// 手动添加样式
RichText.prototype.addMarginToParagraphs = function (htmlText) {
// 创建一个临时div元素,用于将 HTML 文本解析为 DOM 树
var tempDiv = this.strToHtmlEl(htmlText);
// 获取所有的 <p> 标签
var paragraphs = tempDiv.querySelectorAll('p');
// 遍历所有的 <p> 标签,为它们添加 margin: 0; 属性
for (var i = 0; i < paragraphs.length; i++) {
paragraphs[i].style.margin = '0';
}
// 返回修改后的 HTML 字符串
return tempDiv.innerHTML;
};
// 装换editor的文本
RichText.prototype.transFromEditor = function () {
var _a, _b, _c;
var editorText = (_a = this.state.editor) === null || _a === void 0 ? void 0 : _a.getHtml();
// 获取editor文本
var editorEl = this.strToHtmlEl(editorText || '');
// 文本树
var textTree = [];
var children = Array.from(editorEl.childNodes);
// 根据段落进行划分
children.map(function (_, index) {
var _a, _b;
var pTree = [];
if (!((_a = _ === null || _ === void 0 ? void 0 : _.textContent) === null || _a === void 0 ? void 0 : _a.includes('|'))) {
Array.from(_.childNodes).map(function (text) {
var textArea = [];
var textContent = text === null || text === void 0 ? void 0 : text.textContent;
// 前后空行都去掉
// if (!textContent?.trim() && !children[index - 1]?.textContent?.trim()) return
// 纯空字符串不使用
if (/^\s+$/.test(textContent || ''))
return;
// 如果中间有空格-分为多块
if ((textContent === null || textContent === void 0 ? void 0 : textContent.trim().split(' ')) && !/^\s+$/.test(textContent)) {
textArea.push.apply(textArea, textContent === null || textContent === void 0 ? void 0 : textContent.trim().split(/\s+/));
}
else {
textArea.push(textContent || '');
}
pTree.push.apply(pTree, textArea);
});
}
else {
pTree.push.apply(pTree, ((_b = _ === null || _ === void 0 ? void 0 : _.textContent) === null || _b === void 0 ? void 0 : _b.split('|')) || []);
}
// 推入段落
textTree.push(pTree);
});
// 前面是空行的情况全部去除
while (textTree[0].length === 1 && !textTree[0][0]) {
textTree.shift();
}
// 末尾非文字的空行的情况全部去除
while (textTree[textTree.length - 1].length === 1 && !textTree[textTree.length - 1][0]) {
textTree.pop();
}
console.log(textTree);
(_c = (_b = this.props).onModelChange) === null || _c === void 0 ? void 0 : _c.call(_b, this.transFormatToHtml(this.state.selectTempLate, textTree, this.state.showEmpty));
};
RichText.prototype.render = function () {
var _this = this;
var _a = this.props, model = _a.model, onModelChange = _a.onModelChange, readOnly = _a.readOnly, disabled = _a.disabled, onRef = _a.onRef;
var cls = "rich-text-editor keyDownClass";
this.props.readOnly && (cls += ' readOnly');
this.props.disabled && (cls += ' disabled');
var showTranslateButton = localStorage.getItem(TRANSLATEKEY);
var defaultRules = { lastActiveRule: '', showEmpty: false, templates: [] };
var translateRuelsStorage = defaultRules;
if (showTranslateButton) {
translateRuelsStorage = JSON.parse(localStorage.getItem(TRANSLATERULESKEY));
if (!translateRuelsStorage) {
localStorage.setItem(TRANSLATERULESKEY, JSON.stringify(defaultRules));
translateRuelsStorage = defaultRules;
}
}
return react_1.default.createElement(react_1.default.Fragment, null,
showTranslateButton ? react_1.default.createElement("div", { style: { position: 'absolute', zIndex: 1, bottom: 0, right: 0 } },
react_1.default.createElement(antd_1.Button, { onClick: function () { _this.setState({ clickCount: 0 }); localStorage.removeItem(TRANSLATEKEY); } }, "\u9690\u85CF"),
react_1.default.createElement(antd_1.Popconfirm, { okText: "\u786E\u5B9A", cancelText: "\u53D6\u6D88", title: function () {
return react_1.default.createElement(Html_1.default, { html: _this.transFormatToHtml(_this.state.selectTempLate) });
} },
react_1.default.createElement(antd_1.Button, { onClick: function () { return console.log(_this.transFormatToHtml(_this.state.selectTempLate)); } }, "\u9884\u89C8")),
react_1.default.createElement(antd_1.Button, { onClick: function () { return (0, tslib_1.__awaiter)(_this, void 0, void 0, function () {
return (0, tslib_1.__generator)(this, function (_a) {
switch (_a.label) {
case 0:
// 检查浏览器是否支持 Clipboard API
if (!navigator.clipboard) {
antd_1.message.error('不支持复制到剪切板');
return [2 /*return*/];
}
return [4 /*yield*/, navigator.clipboard.writeText(localStorage.getItem(TRANSLATERULESKEY) || '')];
case 1:
_a.sent();
antd_1.message.success('导出成功,ctrl+v粘贴使用');
return [2 /*return*/];
}
});
}); } }, "\u5BFC\u51FA"),
react_1.default.createElement(antd_1.Popconfirm, { okText: "\u786E\u5B9A", cancelText: "\u53D6\u6D88", onConfirm: function () {
var translaterules = JSON.parse(localStorage.getItem(TRANSLATERULESKEY));
var copyRule = JSON.parse(_this.templateStr);
if (!_this.templateStr || typeof copyRule !== 'object' || !copyRule.templates)
return antd_1.message.warn('模板不合法');
// 合并操作
translaterules.templates = (0, tslib_1.__spreadArray)((0, tslib_1.__spreadArray)([], translaterules.templates, true), copyRule.templates, true);
var ruleMap = {};
// 去除重复名字
translaterules.templates.map(function (_) {
ruleMap[_.name] = _;
});
translaterules.templates = Object.values(ruleMap);
localStorage.setItem(TRANSLATERULESKEY, _this.templateStr);
}, title: function () {
return react_1.default.createElement(Input_1.default, { onChange: function (e) {
_this.templateStr = e.target.value;
}, placeholder: "\u8BF7\u8F93\u5165\u5BFC\u51FA\u65F6\u590D\u5236\u7684\u6A21\u677F" });
} },
react_1.default.createElement(antd_1.Button, null, "\u5BFC\u5165")),
react_1.default.createElement(antd_1.Tooltip, { overlay: function () {
return react_1.default.createElement("div", null, (translateRuelsStorage.showEmpty ? '保留空值' : '过滤空值') + "\uFF0C\u53EF\u4EE5\u5728\u6587\u672C\u4E2D\u52A0\u5165|\u7B26\u53F7\u8FDB\u884C\u624B\u5DE5\u5206\u6BB5\uFF0C\u5206\u6BB5\u6837\u5F0F\u53C2\u7167\u6A21\u677F\u9884\u89C8");
} },
react_1.default.createElement(antd_1.Button, { onClick: function () { return _this.transFromEditor(); } }, "\u5E94\u7528\u6A21\u677F")),
react_1.default.createElement(antd_1.Popconfirm, { title: function () {
return react_1.default.createElement("div", null,
"\u8BF7\u8F93\u5165\u6A21\u677F\u540D",
react_1.default.createElement(Input_1.default, { style: {
position: 'relative',
marginTop: '8px',
left: '-22px'
}, value: _this.state.templateName, onChange: function (e) { _this.setState({ templateName: e.target.value }); } }));
}, okText: "\u786E\u5B9A", onConfirm: function () {
var _a;
var templateIndex = translateRuelsStorage.templates.findIndex(function (_) { return _.name === _this.state.templateName; });
var template = {
name: _this.state.templateName,
htmlTemp: _this.structuralTextData(((_a = _this.state.editor) === null || _a === void 0 ? void 0 : _a.getHtml()) || ''),
};
if (templateIndex >= 0) {
translateRuelsStorage.templates[templateIndex] = template;
}
else {
translateRuelsStorage.templates.push(template);
}
localStorage.setItem(TRANSLATERULESKEY, JSON.stringify(translateRuelsStorage));
_this.setState({ selectTempLate: _this.state.templateName });
}, cancelText: "\u53D6\u6D88" },
react_1.default.createElement(antd_1.Button, null, "\u62BD\u51FA\u6A21\u677F")),
react_1.default.createElement(antd_1.Popconfirm, { title: "\u662F\u5426\u786E\u8BA4\u5220\u9664\u6A21\u677F", okText: "\u786E\u5B9A", cancelText: "\u53D6\u6D88", onConfirm: function () {
var curTempIndex = translateRuelsStorage.templates.findIndex(function (_) { return _.name === _this.state.selectTempLate; });
if (curTempIndex >= 0) {
translateRuelsStorage.templates.splice(curTempIndex, 1);
localStorage.setItem(TRANSLATERULESKEY, JSON.stringify(translateRuelsStorage));
_this.setState({ selectTempLate: translateRuelsStorage.templates[0].name, templateName: translateRuelsStorage.templates[0].name });
}
} },
react_1.default.createElement(antd_1.Button, null, "\u5220\u9664\u9009\u4E2D\u6A21\u677F")),
react_1.default.createElement(antd_1.Select, { style: { width: '150px' }, value: this.state.selectTempLate || "请选择模板,无模板请抽出模板", onChange: function (value) {
translateRuelsStorage.lastActiveRule = value;
_this.setState({ selectTempLate: value, templateName: value });
localStorage.setItem(TRANSLATERULESKEY, JSON.stringify(translateRuelsStorage));
}, placeholder: "\u8BF7\u9009\u62E9\u6A21\u677F\uFF0C\u65E0\u6A21\u677F\u8BF7\u62BD\u51FA\u6A21\u677F", options: translateRuelsStorage.templates.map(function (_) { return ({ lable: _.name, value: _.name }); }) || [] })) : null,
react_1.default.createElement(ErrorBound_1.default, { errorText: "\u5BCC\u6587\u672C\u65E0\u6CD5\u89E3\u6790\uFF0C\u8BF7\u8054\u7CFB\u5F00\u53D1\u4EBA\u5458" },
react_1.default.createElement("div", { className: cls, style: { position: 'relative' }, ref: this.editorRef, onTouchMove: function (e) { return e.stopPropagation(); } },
react_1.default.createElement(editor_for_react_1.Toolbar, { className: "email-edit-content-body-toolbar", editor: this.state.editor, mode: "simple", defaultConfig: {
toolbarKeys: ['undo', 'redo', '|', 'fontFamily', 'fontSize', 'lineHeight', '|',
'underline', 'italic', 'color', "bgColor",
"indent", "delIndent", '|',
'bulletedList', 'numberedList', 'justifyLeft', 'justifyRight', 'justifyCenter',]
} }),
react_1.default.createElement(editor_for_react_1.Editor, { className: "email-edit-content-body-editor", defaultConfig: {
hoverbarKeys: {
text: {
menuKeys: ['fontFamily', 'fontSize', 'lineHeight', '|',
'underline', 'italic', 'color', "bgColor",
"indent", "delIndent", '|',
'justifyLeft', 'justifyRight', 'justifyCenter',]
}
},
MENU_CONF: {
fontFamily: {
fontFamilyList: [
"黑体",
"仿宋",
"楷体",
"标楷体",
"华文仿宋",
"华文楷体",
"宋体",
"微软雅黑",
"Arial",
"Tahoma",
"Verdana",
"Times New Roman",
"Courier New",
"思源黑体 CN Bold",
"思源黑体 CN Heavy",
"思源黑体 CN Medium",
"思源黑体 CN Normal",
"思源黑体 CN Regular",
"si"
]
},
fontSize: {
fontSizeList: this.FontList,
},
lineHeight: {
lineHeightList: ['0', '0.125', '0.25', '0.375', '0.5', '0.75', '1', '1.25', '1.5', '1.75', '2', '2.25', '2.5', '5pt', '10pt', '15pt', '20pt', '25pt', '30pt', '35pt', '40pt']
}
},
readOnly: readOnly || disabled,
placeholder: '请输入'
}, mode: "default", value: model, onCreated: function (editor) {
var _a;
(_a = _this.state.editor) === null || _a === void 0 ? void 0 : _a.getAllMenuKeys();
editor.setHtml(model || '');
_this.setState({ editor: editor });
// 2025-03 添加自动聚焦逻辑
if (editor) {
editor.focus();
}
}, onChange: function (editor) {
onModelChange === null || onModelChange === void 0 ? void 0 : onModelChange(_this.addMarginToParagraphs(editor.getHtml()));
onRef && onRef(editor);
} }))));
};
RichText.defaultProps = {
disabled: false,
readOnly: false
};
return RichText;
}(react_1.default.Component));
exports.default = RichText;
//# sourceMappingURL=./components/WangEditor.js.map
;