Skip to content

Commit

Permalink
feat: v3.2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
theajack committed Mar 18, 2023
1 parent f1e19d9 commit 30a809b
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 21 deletions.
16 changes: 13 additions & 3 deletions helper/README.en.md
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
    },
Expand Down Expand Up @@ -390,6 +391,7 @@ declare interface IWriter {
startAnimation(): boolean;
pauseAnimation(): void;
resumeAnimation(): void;
restartAnimation(): void; // Restart drawing
drawNextStroke(onComplete?: ()=>void): boolean;
}
```
Expand Down Expand Up @@ -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<string|number>):Array<string>;
cnchar.idiom(text: string | number | Array<string|number>, mode?: 'char' | 'stroke' | 'spell' | 'tone'):Array<string>;
```

See a specific example
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down
17 changes: 14 additions & 3 deletions helper/README.md
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
},
Expand Down Expand Up @@ -397,6 +398,7 @@ declare interface IWriter {
startAnimation(): boolean;
pauseAnimation(): void;
resumeAnimation(): void;
restartAnimation(): void; // 重头开始绘制
drawNextStroke(onComplete?: ()=>void): boolean;
}
```
Expand Down Expand Up @@ -647,7 +649,7 @@ cnchar在2.2.0加入了成语功能,启用该功能需要安装 `cnchar-idiom`
使用方式如下:

```ts
cnchar.idiom(text: string | number | Array<string|number>):Array<string>;
cnchar.idiom(text: string | number | Array<string|number>, mode?: 'char' | 'stroke' | 'spell' | 'tone'):Array<string>;
```

看一个具体例子
Expand All @@ -663,6 +665,15 @@ cnchar.idiom('shang'); // ["伤风败化", "伤风败俗", ...]
cnchar.idiom('shang4'); // ["上兵伐谋", "上不着天,下不着地", ... ]
```

idiom有四种模式 汉字模式、笔画模式、拼音模式、拼音音调模式

cnchar 会根据输入自动判断采用什么模式,但是在某些情况下,会无法判断是什么模式,需要手动指定模式

```js
cnchar.idiom(['', '', '', ''], 'char'); // 第一个元素是 '', 需要手动指定采用汉字模式查询
```


使用cdn引用时,会在window对向上暴露 `CncharIdiom` 对象

#### 5.8 歇后语功能
Expand Down Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "cnchar",
"version": "3.2.2",
"version": "3.2.3",
"description": "功能全面、多端支持的汉字拼音笔画js库,支持多音字、繁体字、火星文",
"main": "index.html",
"author": "theajack <theajack@qq.com>",
Expand Down
10 changes: 5 additions & 5 deletions vuepress/.vuepress/config.js
Expand Up @@ -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',
}]
],

Expand Down
21 changes: 18 additions & 3 deletions vuepress/doc/draw.md
Expand Up @@ -66,7 +66,9 @@ cnchar.draw('你好', options); // options 为可选参数
<highlight-code lang='typescript'>
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,
Expand All @@ -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,
Expand Down Expand Up @@ -160,6 +162,7 @@ declare interface IWriter {
startAnimation(): boolean;
pauseAnimation(): void;
resumeAnimation(): void;
restartAnimation(): void; // 重头开始绘制
drawNextStroke(onComplete?: ()=>void): boolean;
}
```
Expand Down Expand Up @@ -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 用于开启 **单笔绘制模式**

Expand Down
24 changes: 19 additions & 5 deletions vuepress/doc/idiom.md
@@ -1,4 +1,3 @@

## 1. 介绍

cnchar在2.2.0加入了成语功能,启用该功能需要安装 `cnchar-idiom` 功能库,该库可以独立于cnchar主库运行
Expand All @@ -7,7 +6,7 @@ cnchar在2.2.0加入了成语功能,启用该功能需要安装 `cnchar-idiom`

<div>
<highlight-code lang='typescript'>
cnchar.idiom(text: string | number | Array<string|number>):Array<string>;
cnchar.idiom(text: string | number | (string|number)[], mode?: 'char' | 'stroke' | 'spell' | 'tone'): string[];
</highlight-code>
</div>

Expand All @@ -21,16 +20,21 @@ cnchar.idiom(text: string | number | Array<string|number>):Array<string>;

## 2. idiom 参数

参数调用如下,value表示查询对象,可以试拼音汉字笔画数,所有 arg 参数都是可选的
参数调用如下,value表示查询对象,可以是拼音、汉字、笔画数

<div>
<highlight-code lang='typescript'>
cnchar.idiom(value);
cnchar.idiom(value, mode);
</highlight-code>
</div>

## 3. 实例
mode为查询模式,为可选参数,默认为汉字模式

idiom有四种模式 汉字模式、笔画模式、拼音模式、拼音音调模式 ('char' | 'stroke' | 'spell' | 'tone')

cnchar 会根据输入自动判断采用什么模式,但是在某些情况下,会无法判断是什么模式,需要手动指定模式

## 3. 实例

该库为cnchar扩展了成语功能

Expand All @@ -43,4 +47,14 @@ cnchar.idiom('shang4') // ['伤风败化', '伤风败俗', ... ]
</highlight-code>
</div>

需要手动指定查询模式的情况:

<div>
<highlight-code lang='javascript'>
cnchar.idiom(['', '', '好', ''], 'char'); // 第一个元素是 '', 需要手动指定采用汉字模式查询
</highlight-code>
</div>




2 changes: 1 addition & 1 deletion vuepress/doc/offline.md
Expand Up @@ -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)

Expand Down
16 changes: 16 additions & 0 deletions 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. 蹲靚刹彷 默认多音与词组修复
Expand Down

0 comments on commit 30a809b

Please sign in to comment.