8000 InputRichText统计的字符有问题 · Issue #11953 · baidu/amis · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

InputRichText统计的字符有问题 #11953

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
thinkingc opened this issue May 6, 2025 · 1 comment
Open

InputRichText统计的字符有问题 #11953

thinkingc opened this issue May 6, 2025 · 1 comment

Comments

@thinkingc
Copy link
Contributor

描述问题:

InputRichText统计的字符有问题.

截图或视频:

Image

如何复现(请务必完整填写下面内容):

  1. 你是如何使用 amis 的?
    sdknpm其他...

  2. amis 版本是什么?请先在最新 beta 版本测试问题是否存在

  3. 粘贴有问题的完整 amis schema 代码:

{
  "type": "page",
  "body": {
    "type": "form",
    "api": "/amis/api/mock2/form/saveForm",
    "body": [
      {
        "type": "input-rich-text",
        "name": "rich",
        "label": "Rich Text"
      }
    ]
  }
}
  1. 操作步骤
    1、聚焦,连续输入多个a
    2、观察右下角,展示的字符数有问题。当点击字符数后,字符数更新
@lhtuling
Copy link
Contributor

试了下 点击后是字符,默认显示是字
应该默认显示的是中文字数,字符才是真正的你想看到的字数
帮你搞了个解决方法,原理是加载完成后帮你点击一下字数,就默认显示字符了

{
  "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": {}
        }
      ]
    }
  }
}

Image

主要代码:

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants
0