Changing spacing parameter

This commit is contained in:
Astrian Zheng 2024-04-18 09:00:06 +10:00
parent c028ea3454
commit 84f2e6dd3d
Signed by: Astrian
SSH Key Fingerprint: SHA256:rVnhx3DAKjujCwWE13aDl7uV6+9U1MvydLkNRXJrBiA
3 changed files with 15 additions and 15 deletions

View File

@ -1,6 +1,6 @@
{
"name": "arsene",
"version": "1.0.1",
"version": "1.1.0",
"description": "Arsene is a library for processing CJK text paragraphs, which are mixed with English characters and adding spacing between them.",
"author": "Astrian Zheng",
"keywords": [

View File

@ -33,19 +33,19 @@ function App() {
```
## 额外功能
### 自定义空格宽度
### 自定义间隙宽度
```ts
arsene(selectedNode: string, spacing: 3|4|5|6|10 = 10)
arsene(selectedNode: string, spacing: 's'|'m'|'l'|'xl'|'2xl' = 10)
// sample
arsene(node, 5)
```
你可以在第二个参数中选择一个你认为合适的空格宽度。可选参数如下:
你可以在第二个参数中选择一个你认为合适的间隙宽度。可选参数如下:
- `3`:添加 1/3 em 空格 `U+2004`
- `4`:添加 1/4 em 空格 `U+2005`
- `5`:添加 1/5 em 空格 `U+2009`
- `6`:添加 1/6 em 空格 `U+2006`
- `10`:添加小空`U+200A`
- `2xl`:添加非常大间隙 `U+2004`
- `xl`:添加超大间隙 `U+2005`
- `l`:添加大间隙 `U+2009`
- `m`:添加中间隙 `U+2006`
- `s`:添加小间`U+200A`
默认(不填写第二个参数时)将添加 `U+200A`

View File

@ -1,19 +1,19 @@
export default function (selectedNode: string, spacing: 3|4|5|6|10 = 10) {
export default function (selectedNode: string, spacing: '2xl'|'xl'|'l'|'m'|'s' = 's') {
let spacingCharacter = ''
switch (spacing) {
case 3:
case '2xl':
spacingCharacter = '\u2004'
break
case 4:
case 'xl':
spacingCharacter = '\u2005'
break
case 5:
case 'l':
spacingCharacter = '\u2009'
break
case 6:
case 'm':
spacingCharacter = '\u2006'
break
case 10:
case 's':
spacingCharacter = '\u200A'
break
default: