[{"data":1,"prerenderedAt":350},["ShallowReactive",2],{"quirekit-doc:\u002Fplugins\u002Freference\u002Fcharacter-count":3},{"id":4,"title":5,"body":6,"description":12,"extension":338,"keywords":339,"locale":342,"meta":343,"navigation":152,"order":344,"path":345,"section":346,"seo":347,"stem":348,"__hash__":349},"docs\u002Fplugins\u002Freference\u002Fcharacter-count.zh-CN.md","CharacterCount · 字数统计与上限",{"type":7,"value":8,"toc":325},"minimark",[9,13,24,28,34,84,92,95,111,123,183,190,193,204,208,211,218,222,225,231,237,240,243,248,253,257,260,265,270,274,277,281,286,289,292,295,298,309,321],[10,11,12],"p",{},"通过 editor.storage.characterCount 读取字符与词数，也可限制输入长度。默认按字符串长度计字符、空格分词；中文分词需要自定义计数函数。",[10,14,15,19,20],{},[16,17,18],"code",{},"@quirekit\u002Fextensions"," · ",[21,22,23],"strong",{},"MIT",[25,26,27],"h2",{"id":27},"编辑器适用范围",[10,29,30,31],{},"层次：",[21,32,33],{},"共享文档能力",[35,36,37,53],"table",{},[38,39,40],"thead",{},[41,42,43,47,50],"tr",{},[44,45,46],"th",{},"编辑器",[44,48,49],{},"状态",[44,51,52],{},"所需装配与边界",[54,55,56,68],"tbody",{},[41,57,58,62,65],{},[59,60,61],"td",{},"Classic",[59,63,64],{},"需适配",[59,66,67],{},"需由宿主连接本页所列服务、目标与生命周期，并验证所选 View 和文档模型。核心接口可复用，但没有一段无宿主参数的通用产品安装代码。",[41,69,70,73,76],{},[59,71,72],{},"Block",[59,74,75],{},"直接支持",[59,77,78,83],{},[79,80,82],"a",{"href":81},"\u002Fplugins\u002Freference\u002Fcreate-block-editor-preset","createBlockEditorPreset"," — createBlockEditor 默认预设已装配此能力。通过 preset 中对应子项配置；图形编辑使用预设注入的工作区，宿主仍负责保存和资源。不要重复安装同名扩展。",[10,85,86,87,91],{},"“直接支持”指已有上述产品装配；具体交互、宿主服务和格式支持仍有各自条件。",[79,88,90],{"href":89},"\u002Fplugins\u002Fcompatibility","状态与接入规则","。许可独立显示。",[25,93,94],{"id":94},"接入",[96,97,102],"pre",{"className":98,"code":99,"language":100,"meta":101,"style":101},"language-sh shiki shiki-themes github-light github-light github-dark","pnpm add @quirekit\u002Fextensions@alpha\n","sh","",[16,103,104],{"__ignoreMap":101},[105,106,109],"span",{"class":107,"line":108},"line",1,[105,110,99],{},[10,112,113,114,117,118,122],{},"在创建 Editor 时放入 ",[16,115,116],{},"extensions","。挂载容器、视图和保存由宿主提供，见",[79,119,121],{"href":120},"\u002Fguide\u002Fquick-start","快速开始","。",[96,124,128],{"className":125,"code":126,"language":127,"meta":101,"style":101},"language-ts shiki shiki-themes github-light github-light github-dark","import { CharacterCount } from '@quirekit\u002Fextensions'\n\nconst counter = CharacterCount.configure({ limit: 5000 })\n","ts",[16,129,130,147,154],{"__ignoreMap":101},[105,131,132,136,140,143],{"class":107,"line":108},[105,133,135],{"class":134},"sDD9d","import",[105,137,139],{"class":138},"sVPnS"," { CharacterCount } ",[105,141,142],{"class":134},"from",[105,144,146],{"class":145},"s-HEn"," '@quirekit\u002Fextensions'\n",[105,148,150],{"class":107,"line":149},2,[105,151,153],{"emptyLinePlaceholder":152},true,"\n",[105,155,157,160,164,167,170,174,177,180],{"class":107,"line":156},3,[105,158,159],{"class":134},"const",[105,161,163],{"class":162},"sUNQB"," counter",[105,165,166],{"class":134}," =",[105,168,169],{"class":138}," CharacterCount.",[105,171,173],{"class":172},"sgQzM","configure",[105,175,176],{"class":138},"({ limit: ",[105,178,179],{"class":162},"5000",[105,181,182],{"class":138}," })\n",[10,184,185,186,122],{},"安装时按包声明选择兼容版本，外部可用版本以分发源为准。本站使用工作区 Alpha；许可标签来自入口所属包，使用条件见",[79,187,189],{"href":188},"\u002Fsupport","支持与许可",[25,191,192],{"id":192},"按编辑器接入",[10,194,195,196,199,200,203],{},"以下片段沿用已挂载的宿主元素 ",[16,197,198],{},"element","，宿主负责容器尺寸与保存；退出页面时调用 ",[16,201,202],{},"instance.destroy()","。已有预设装配的能力不要再重复追加；需要宿主端口的入口应先完成下方配置。",[205,206],"plugin-integration",{"name":207},"CharacterCount",[25,209,210],{"id":210},"配置",[10,212,213,214,122],{},"下面是扩展自身的默认选项。预设可以覆盖这些值；它们不等于当前文档属性。配置方法见",[79,215,217],{"href":216},"\u002Fplugins\u002Fconfiguration","配置插件",[219,220,221],"h3",{"id":221},"limit",[10,223,224],{},"最大允许字符数。null、undefined 或 0 表示不限制；已有超长内容可能被裁剪。",[10,226,227,228],{},"类型：",[16,229,230],{},"number | null | undefined",[10,232,233,234],{},"默认：",[16,235,236],{},"null",[219,238,239],{"id":239},"mode",[10,241,242],{},"字符统计方式：textSize 计文本，nodeSize 计 ProseMirror 节点尺寸。",[10,244,227,245],{},[16,246,247],{},"\"nodeSize\" | \"textSize\"",[10,249,233,250],{},[16,251,252],{},"\"textSize\"",[219,254,256],{"id":255},"textcounter","textCounter",[10,258,259],{},"字符计数函数，接收提取出的纯文本并返回数量。需要按 Unicode 字符或字形计数时替换默认函数。",[10,261,227,262],{},[16,263,264],{},"(text: string): number",[10,266,233,267],{},[16,268,269],{},"(text: string) => text.length",[219,271,273],{"id":272},"wordcounter","wordCounter",[10,275,276],{},"词数统计函数。默认按空格分词；中文等语言需要自己的分词方法。",[10,278,227,279],{},[16,280,264],{},[10,282,233,283],{},[16,284,285],{},"(text: string) => text.split(\" \").filter((word) => word !== \"\").length",[25,287,288],{"id":288},"命令与运行方式",[10,290,291],{},"此入口没有直接声明可枚举的命令。组合扩展的命令由子扩展提供；产品插件通过 contribution 或文件服务工作。不能把安装入口名称当作命令调用。",[10,293,294],{},"limit 会参与事务过滤；打开已经超限的内容可能触发初始裁剪。需要无损读取外部文档时，先在宿主判断长度，再决定是否启用限制。",[25,296,297],{"id":297},"下一步",[10,299,300,301,305,306,308],{},"返回",[79,302,304],{"href":303},"\u002Fplugins","全部插件","，或阅读",[79,307,217],{"href":216},"区分配置、文档属性与命令。",[10,310,311,312,316,317,122],{},"自己定义能力时见",[79,313,315],{"href":314},"\u002Fbuild\u002Fextension","扩展开发","；搭建完整宿主时见",[79,318,320],{"href":319},"\u002Fbuild","构建产品",[322,323,324],"style",{},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sDD9d, html code.shiki .sDD9d{--shiki-default:#D73A49;--shiki-light:#D73A49;--shiki-dark:#F97583}html pre.shiki code .sVPnS, html code.shiki .sVPnS{--shiki-default:#24292E;--shiki-light:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .s-HEn, html code.shiki .s-HEn{--shiki-default:#032F62;--shiki-light:#032F62;--shiki-dark:#9ECBFF}html pre.shiki code .sUNQB, html code.shiki .sUNQB{--shiki-default:#005CC5;--shiki-light:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .sgQzM, html code.shiki .sgQzM{--shiki-default:#6F42C1;--shiki-light:#6F42C1;--shiki-dark:#B392F0}",{"title":101,"searchDepth":149,"depth":149,"links":326},[327,328,329,330,336,337],{"id":27,"depth":149,"text":27},{"id":94,"depth":149,"text":94},{"id":192,"depth":149,"text":192},{"id":210,"depth":149,"text":210,"children":331},[332,333,334,335],{"id":221,"depth":156,"text":221},{"id":239,"depth":156,"text":239},{"id":255,"depth":156,"text":256},{"id":272,"depth":156,"text":273},{"id":288,"depth":149,"text":288},{"id":297,"depth":149,"text":297},"md",[207,18,340,341,221,239,256,273,207],"字数统计与上限","behavior","zh-CN",{"navigationTitle":207,"license":23},22,"\u002Fplugins\u002Freference\u002Fcharacter-count","编辑行为",{"title":5,"description":12},"plugins\u002Freference\u002Fcharacter-count.zh-CN","B1K_FA3ZEBynXO8_nmQtn1SIOkbSQ7NOik-Wbpk5IJg",1793045213034]