amis
amis copied to clipboard
InputRichText统计的字符有问题
描述问题:
InputRichText统计的字符有问题.
截图或视频:
如何复现(请务必完整填写下面内容):
-
你是如何使用 amis 的?
sdk、npm或其他... -
amis 版本是什么?请先在最新 beta 版本测试问题是否存在
-
粘贴有问题的完整
amis schema代码:
{
"type": "page",
"body": {
"type": "form",
"api": "/amis/api/mock2/form/saveForm",
"body": [
{
"type": "input-rich-text",
"name": "rich",
"label": "Rich Text"
}
]
}
}
- 操作步骤 1、聚焦,连续输入多个a 2、观察右下角,展示的字符数有问题。当点击字符数后,字符数更新
试了下 点击后是字符,默认显示是字 应该默认显示的是中文字数,字符才是真正的你想看到的字数 帮你搞了个解决方法,原理是加载完成后帮你点击一下字数,就默认显示字符了
{
"type": "page",
"body": [
{
"type": "form",
"api": "/amis/api/mock2/form/saveForm",
"body": [
{
"type": "input-rich-text",
"name": "rich",
"label": "Rich Text",
"id": "u:c257075b6d3c",
"vendor": "tinymce",
"options": {
"plugins": "advlist,autolink,link,image,lists,charmap,preview,anchor,pagebreak,searchreplace,wordcount,visualblocks,visualchars,code,fullscreen,insertdatetime,media,nonbreaking,table,emoticons,template,help",
"toolbar": "undo redo bold italic backcolor alignleft formatselect aligncenter alignright alignjustify bullist numlist outdent indent removeformat help",
"menubar": true
}
}
],
"id": "u:bd206f81ec62",
"actions": [
{
"type": "submit",
"label": "提交",
"primary": true,
"id": "u:55e757a5351d"
}
],
"feat": "Insert",
"dsType": "api",
"labelAlign": "left"
}
],
"id": "u:82e74885313f",
"asideResizor": false,
"pullRefresh": {
"disabled": true
},
"onEvent": {
"init": {
"weight": 0,
"actions": [
{
"ignoreError": false,
"script": "let attempts = 0;\nconst check = setInterval(() => {\n const b = document.querySelector(\"button.tox-statusbar__wordcount\");\n attempts > 50 ? clearInterval(check) : b && (clearInterval(check), setTimeout(() => b.click(), 100));\n}, 100);",
"actionType": "custom",
"args": {}
}
]
}
}
}
主要代码:
let attempts = 0;
const check = setInterval(() => {
const b = document.querySelector("button.tox-statusbar__wordcount");
attempts > 50 ? clearInterval(check) : b && (clearInterval(check), setTimeout(() => b.click(), 100));
}, 100);
欢迎加入最大的,人数最多的,含佬量极高的社区群 Amis社区交流群【QQ1群】:717791727 Amis社区交流群【QQ2群】:721182449