From 30a809b34dc1d61c6df7c44ac65119f05bc4c26c Mon Sep 17 00:00:00 2001 From: theajack <1506282385@qq.com> Date: Sat, 18 Mar 2023 23:01:20 +0800 Subject: [PATCH] feat: v3.2.3 --- helper/README.en.md | 16 +++++++++++++--- helper/README.md | 17 ++++++++++++++--- package.json | 2 +- vuepress/.vuepress/config.js | 10 +++++----- vuepress/doc/draw.md | 21 ++++++++++++++++++--- vuepress/doc/idiom.md | 24 +++++++++++++++++++----- vuepress/doc/offline.md | 2 +- vuepress/guide/version.md | 16 ++++++++++++++++ 8 files changed, 87 insertions(+), 21 deletions(-) diff --git a/helper/README.en.md b/helper/README.en.md index da1196a..a7f5610 100644 --- a/helper/README.en.md +++ b/helper/README.en.md @@ -331,6 +331,7 @@ declare interface DrawOption {     el?: string|HTMLElement; // The drawn container, support selector or dom, if not filled, a dom will be appended after the body as a container     type?: DrawType; // Drawing mode, default is normal     clear?: boolean; // Whether to clear the container before drawing The default is true + onComplete?: ()=>void; // Draw completed     style?: {// style class         backgroundColor?: string, // The default is #fff         showOutline?: boolean; //: true, @@ -359,7 +360,7 @@ declare interface DrawOption {         delayBetweenStrokes?: number; //: 1000, // value, default 1000. The interval time(in milliseconds) between each stroke in the animation.         delayBetweenLoops?: number; //: 200, // value, default 2000. The time(in milliseconds) between each animation loop when looping animations.         autoAnimate?: boolean; //: true, -        animateComplete?: Function; //:() => {}, +        animateComplete?: Function; //:() => {}, The animation is executed         stepByStep?: boolean; //: true,         loopAnimate?: boolean; //: false,     }, @@ -390,6 +391,7 @@ declare interface IWriter { startAnimation(): boolean; pauseAnimation(): void; resumeAnimation(): void; + restartAnimation(): void; // Restart drawing drawNextStroke(onComplete?: ()=>void): boolean; } ``` @@ -640,7 +642,7 @@ cnchar added the idiom function in 2.2.0. To enable this function, you need to i The usage is as follows: ```ts -cnchar.idiom(text: string | number | Array):Array; +cnchar.idiom(text: string | number | Array, mode?: 'char' | 'stroke' | 'spell' | 'tone'):Array; ``` See a specific example @@ -656,6 +658,14 @@ cnchar.idiom('shang'); // ["伤风败化", "伤风败俗", ...] cnchar.idiom('shang4'); // ["上兵伐谋", "上不着天,下不着地", ... ] ``` +Idiom consists of four modes: Chinese character mode, stroke mode, pinyin mode, and pinyin tone mode + +CNCHAR will automatically determine what mode to use based on the input, but in some cases, it will not be able to determine what mode it is, and you will need to specify the mode manually + +```js +cnchar.idiom(['', '', '好', ''], 'char'); // The first element is '', which needs to be manually specified to query in kanji pattern +``` + When using cdn references, the `CncharIdiom` object will be exposed upward in the window #### 5.8 Xiehouyu function @@ -1170,7 +1180,7 @@ cnchar has added [cnchar-data](https://github.com/cn-char/cnchar-data) in versio For specific usage, please refer to [cnchar-data](https://github.com/cn-char/cnchar-data/blob/master/README.md) -In addition, the three repositories of voice, draw, and explain also support independent setResourceBase +In addition, the three repositories of voice, draw, and explain also support independent `setResourceBase` For details, please refer to [cnchar-types](https://github.com/theajack/cnchar/tree/master/src/cnchar-types) diff --git a/helper/README.md b/helper/README.md index dfa690a..7aee7c0 100644 --- a/helper/README.md +++ b/helper/README.md @@ -337,6 +337,7 @@ declare interface DrawOption { el?: string | HTMLElement; // 绘制的容器,支持选择器或dom,若是不填,会在body后append一个dom作为容器 type?: DrawType; // 绘制模式,默认为normal clear?: boolean; // 绘制前是否清空容器 默认为true + onComplete?: ()=>void; // 绘制完成 style?: { // 样式类 backgroundColor?: string, // 默认为#fff showOutline?: boolean;//: true, @@ -365,7 +366,7 @@ declare interface DrawOption { delayBetweenStrokes?: number;// : 1000, // 数值, 默认 1000。 动画进行中每个笔画之间的间隔时间(以毫秒为单位)。 delayBetweenLoops?: number;// : 200, // 数值, 默认 2000。 循环动画时每个动画循环之间的时间(以毫秒为单位)。 autoAnimate?: boolean;// : true, - animateComplete?: Function;// : () => {}, + animateComplete?: Function;// : () => {}, 动画执行完毕 stepByStep?: boolean;// : true, loopAnimate?: boolean;// : false, }, @@ -397,6 +398,7 @@ declare interface IWriter { startAnimation(): boolean; pauseAnimation(): void; resumeAnimation(): void; + restartAnimation(): void; // 重头开始绘制 drawNextStroke(onComplete?: ()=>void): boolean; } ``` @@ -647,7 +649,7 @@ cnchar在2.2.0加入了成语功能,启用该功能需要安装 `cnchar-idiom` 使用方式如下: ```ts -cnchar.idiom(text: string | number | Array):Array; +cnchar.idiom(text: string | number | Array, mode?: 'char' | 'stroke' | 'spell' | 'tone'):Array; ``` 看一个具体例子 @@ -663,6 +665,15 @@ cnchar.idiom('shang'); // ["伤风败化", "伤风败俗", ...] cnchar.idiom('shang4'); // ["上兵伐谋", "上不着天,下不着地", ... ] ``` +idiom有四种模式 汉字模式、笔画模式、拼音模式、拼音音调模式 + +cnchar 会根据输入自动判断采用什么模式,但是在某些情况下,会无法判断是什么模式,需要手动指定模式 + +```js +cnchar.idiom(['', '', '好', ''], 'char'); // 第一个元素是 '', 需要手动指定采用汉字模式查询 +``` + + 使用cdn引用时,会在window对向上暴露 `CncharIdiom` 对象 #### 5.8 歇后语功能 @@ -1178,7 +1189,7 @@ cnchar 在 3.1.0 版本新增了 [cnchar-data](https://github.com/cn-char/cnchar 具体使用请参考 [cnchar-data](https://github.com/cn-char/cnchar-data/blob/master/README.md) -另外 voice, draw, explain 三个仓库也支持独立 setResourceBase +另外 voice, draw, explain 三个仓库也支持独立 `setResourceBase` 具体请参考 [cnchar-types](https://github.com/theajack/cnchar/tree/master/src/cnchar-types) diff --git a/package.json b/package.json index 8ba5864..4ab5314 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cnchar", - "version": "3.2.2", + "version": "3.2.3", "description": "功能全面、多端支持的汉字拼音笔画js库,支持多音字、繁体字、火星文", "main": "index.html", "author": "theajack ", diff --git a/vuepress/.vuepress/config.js b/vuepress/.vuepress/config.js index 721e2dc..7e55dfe 100644 --- a/vuepress/.vuepress/config.js +++ b/vuepress/.vuepress/config.js @@ -178,13 +178,13 @@ module.exports = { // 官方图片放大组件 目前是所有img都可以点击放大。具体配置见https://v1.vuepress.vuejs.org/zh/plugin/official/plugin-medium-zoom.html ['@vuepress/medium-zoom', {selector: 'img'}], ['vuepress-plugin-tc-comment', { - appName: 'cnchar', + // appName: 'cnchar', // host: 'localhost:6868', // dev - // host: 'www.shiyix.cn', // View https://github.com/theajack/comment for details - // getUrl: '/api/comment/cnchar', - // insertUrl: '/api/comment/cnchar', - // replyUrl: '/api/reply/cnchar', + host: 'www.shiyix.cn', // View https://github.com/theajack/comment for details + getUrl: '/api/comment/cnchar', + insertUrl: '/api/comment/cnchar', + replyUrl: '/api/reply/cnchar', }] ], diff --git a/vuepress/doc/draw.md b/vuepress/doc/draw.md index 9705e7b..581b526 100644 --- a/vuepress/doc/draw.md +++ b/vuepress/doc/draw.md @@ -66,7 +66,9 @@ cnchar.draw('你好', options); // options 为可选参数 declare interface DrawOption { el?: string | HTMLElement; // 绘制的容器,支持id和dom,若是不填,会在body后append一个dom作为容器 - type?: DrawType; // 绘制模式,默认为normal + type?: DrawType; // 绘制模式,默认为normalnormal + clear?: boolean; // 绘制前是否清空容器 默认为true + onComplete?: ()=>void; // 绘制完成 style?: { // 样式类 showOutline?: boolean;//: true, showCharacter?: boolean;//: true, @@ -93,7 +95,7 @@ declare interface DrawOption { strokeAnimationSpeed?: number;// : 1, // 数值, 默认 1。 绘制每个笔划的速度必须大于0。增加此数字可以更快地绘制笔划,减少绘制笔划的速度更慢。 delayBetweenStrokes?: number;// : 1000, // 数值, 默认 1000。 动画进行中每个笔画之间的间隔时间(以毫秒为单位)。 delayBetweenLoops?: number;// : 200, // 数值, 默认 2000。 循环动画时每个动画循环之间的时间(以毫秒为单位)。 - autoAnimate?: boolean;// : true, + autoAnimate?: boolean;// : true, 动画执行完毕 animateComplete?: Function;// : () => {}, stepByStep?: boolean;// : true, loopAnimate?: boolean;// : false, @@ -160,6 +162,7 @@ declare interface IWriter { startAnimation(): boolean; pauseAnimation(): void; resumeAnimation(): void; + restartAnimation(): void; // 重头开始绘制 drawNextStroke(onComplete?: ()=>void): boolean; } ``` @@ -198,7 +201,19 @@ writer.pauseAnimation(); writer.resumeAnimation(); ``` -### 7.3 drawNextStroke +### 7.3 restartAnimation + +用于重新开始绘制动画 + +```js +const writer = cnchar.draw('你好', { + type: cnchar.draw.TYPE.ANIMATION +}); + +writer.restartAnimation(); +``` + +### 7.4 drawNextStroke 该 api 用于开启 **单笔绘制模式** diff --git a/vuepress/doc/idiom.md b/vuepress/doc/idiom.md index fde0875..f807f6c 100644 --- a/vuepress/doc/idiom.md +++ b/vuepress/doc/idiom.md @@ -1,4 +1,3 @@ - ## 1. 介绍 cnchar在2.2.0加入了成语功能,启用该功能需要安装 `cnchar-idiom` 功能库,该库可以独立于cnchar主库运行 @@ -7,7 +6,7 @@ cnchar在2.2.0加入了成语功能,启用该功能需要安装 `cnchar-idiom`
-cnchar.idiom(text: string | number | Array):Array; +cnchar.idiom(text: string | number | (string|number)[], mode?: 'char' | 'stroke' | 'spell' | 'tone'): string[];
@@ -21,16 +20,21 @@ cnchar.idiom(text: string | number | Array):Array; ## 2. idiom 参数 -参数调用如下,value表示查询对象,可以试拼音汉字笔画数,所有 arg 参数都是可选的 +参数调用如下,value表示查询对象,可以是拼音、汉字、笔画数
-cnchar.idiom(value); +cnchar.idiom(value, mode);
-## 3. 实例 +mode为查询模式,为可选参数,默认为汉字模式 +idiom有四种模式 汉字模式、笔画模式、拼音模式、拼音音调模式 ('char' | 'stroke' | 'spell' | 'tone') + +cnchar 会根据输入自动判断采用什么模式,但是在某些情况下,会无法判断是什么模式,需要手动指定模式 + +## 3. 实例 该库为cnchar扩展了成语功能 @@ -43,4 +47,14 @@ cnchar.idiom('shang4') // ['伤风败化', '伤风败俗', ... ]
+需要手动指定查询模式的情况: + +
+ +cnchar.idiom(['', '', '好', ''], 'char'); // 第一个元素是 '', 需要手动指定采用汉字模式查询 + +
+ + + diff --git a/vuepress/doc/offline.md b/vuepress/doc/offline.md index 77d3384..28bf61f 100644 --- a/vuepress/doc/offline.md +++ b/vuepress/doc/offline.md @@ -9,7 +9,7 @@ cnchar 在 3.1.0 版本新增了 [cnchar-data](https://github.com/cn-char/cnchar 具体使用请参考 [cnchar-data](https://github.com/cn-char/cnchar-data/blob/master/README.md) -另外 voice, draw, explain 三个仓库也支持独立 setResourceBase +另外 voice, draw, explain 三个仓库也支持独立 `setResourceBase` 具体请参考 [cnchar-types](https://github.com/theajack/cnchar/tree/master/src/cnchar-types) diff --git a/vuepress/guide/version.md b/vuepress/guide/version.md index 42726f5..a0a3f42 100644 --- a/vuepress/guide/version.md +++ b/vuepress/guide/version.md @@ -1,3 +1,19 @@ + +## 3.2.3 + +1. 馡 姈 字补齐 [done] +2. 梁的繁体也是梁,现在是樑 [done] +3. spellToWord 部分情况下报错 cnchar.spellToWord('dǐnɡ', 'array') [done] 字符错误增加了一个提示 ɡ!==g +4. cnchar.idiom(['','','好','']) -> 模式下仅支持查询首个汉字的拼音 [done] 增加了第二个可选参数 手动指定类型 cnchar.idiom(['','','好',''], 'char') +5. cnchar.voice无法在苹果设备上播放 [done](需要用户交互 增加一个提示) +6. cnchar/src/cnchar/plugin/input/associate/ass-spell.ts 测试代码遗留 [done] 已删除 +7. 字典 离线使用 没有效果 [done] 修复 cnchar.setResourceBase 无效问题 +8. 风的默认读音 [done] +9. draw type为stroke时,没有animateComplete事件,或者说有没有什么其他方式得到绘制完成事件 [done] 增加 onComplete 事件 +10. cnchar.sortSpell 排序中有特殊字符或者标点符号方法拿不到返回值 [done] 对非汉字的内容做兼容处理 +11. 修复word插件在macos ios中的正则零宽断言的兼容性问题 [done] +12. 增加 restartAnimation 方法 并对pause和resume在step模式下做了bugfix [done] + ## 3.2.2 1. 蹲靚刹彷 默认多音与词组修复