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", "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.", "description": "Arsene is a library for processing CJK text paragraphs, which are mixed with English characters and adding spacing between them.",
"author": "Astrian Zheng", "author": "Astrian Zheng",
"keywords": [ "keywords": [

View File

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