@leafer-ui/text 1.0.0-beta.8 → 1.0.0-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,12 +1,15 @@
1
1
  {
2
2
  "name": "@leafer-ui/text",
3
- "version": "1.0.0-beta.8",
3
+ "version": "1.0.0-rc.2",
4
4
  "description": "@leafer-ui/text",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
7
7
  "main": "src/index.ts",
8
+ "types": "types/index.d.ts",
8
9
  "files": [
9
- "src"
10
+ "src",
11
+ "types",
12
+ "dist"
10
13
  ],
11
14
  "repository": {
12
15
  "type": "git",
@@ -19,10 +22,10 @@
19
22
  "leaferjs"
20
23
  ],
21
24
  "dependencies": {
22
- "@leafer-ui/core": "1.0.0-beta.8"
25
+ "@leafer-ui/core": "1.0.0-rc.2"
23
26
  },
24
27
  "devDependencies": {
25
- "@leafer/interface": "1.0.0-beta.8",
26
- "@leafer-ui/interface": "1.0.0-beta.8"
28
+ "@leafer/interface": "1.0.0-rc.2",
29
+ "@leafer-ui/interface": "1.0.0-rc.2"
27
30
  }
28
31
  }
@@ -1,6 +1,6 @@
1
1
  import { MathHelper, Platform } from '@leafer/core'
2
2
 
3
- import { ITextData, ITextDrawData } from '@leafer-ui/interface'
3
+ import { ITextConvertModule, ITextData, ITextDrawData } from '@leafer-ui/interface'
4
4
 
5
5
  import { createRows } from './TextRows'
6
6
  import { layoutChar } from './CharLayout'
@@ -9,7 +9,7 @@ import { clipText } from './TextClip'
9
9
  import { decorationText } from './TextDecoration'
10
10
 
11
11
 
12
- export const TextConvert = {
12
+ export const TextConvert: ITextConvertModule = {
13
13
 
14
14
  getDrawData(content: string, style: ITextData): ITextDrawData {
15
15
 
package/src/TextLayout.ts CHANGED
@@ -11,21 +11,19 @@ export function layoutText(drawData: ITextDrawData, style: ITextData): void {
11
11
 
12
12
  // verticalAlign
13
13
 
14
- if (height) {
15
- if (textOverflow !== 'show' && realHeight > height) {
16
- realHeight = Math.max(height, __lineHeight)
17
- drawData.overflow = rows.length
18
- } else {
19
- switch (verticalAlign) {
20
- case 'middle':
21
- y += (height - realHeight) / 2
22
- break
23
- case 'bottom':
24
- y += (height - realHeight)
25
- }
14
+ if (textOverflow !== 'show' && realHeight > height) {
15
+ realHeight = Math.max(height, __lineHeight)
16
+ drawData.overflow = rows.length
17
+ } else {
18
+ switch (verticalAlign) {
19
+ case 'middle':
20
+ y += (height - realHeight) / 2
21
+ break
22
+ case 'bottom':
23
+ y += (height - realHeight)
26
24
  }
27
- starY += y
28
25
  }
26
+ starY += y
29
27
 
30
28
  // textAlign
31
29
 
@@ -54,7 +52,16 @@ export function layoutText(drawData: ITextDrawData, style: ITextData): void {
54
52
  drawData.overflow = i + 1
55
53
  }
56
54
 
57
- if (row.width > bounds.width) bounds.width = row.width
55
+ if (row.width < 0) { // letterSpacing < 0
56
+ const charWidth = row.words[0].data[0].width
57
+ const rowX = row.x + row.width
58
+ if (rowX < bounds.x) bounds.x = rowX - charWidth
59
+ if (-row.width > bounds.width) bounds.width = -row.width + style.fontSize + charWidth
60
+ } else {
61
+ if (row.x < bounds.x) bounds.x = row.x
62
+ if (row.width > bounds.width) bounds.width = row.width
63
+ }
64
+
58
65
  }
59
66
 
60
67
  bounds.y = y
package/src/TextRows.ts CHANGED
@@ -74,7 +74,11 @@ export function createRows(drawData: ITextDrawData, content: string, style: ITex
74
74
 
75
75
  }
76
76
 
77
- if (!(char === ' ' && (rowWidth + wordWidth) === 0)) {
77
+ if (char === ' ' && paraStart !== true && (rowWidth + wordWidth) === 0) {
78
+
79
+ // trim space
80
+
81
+ } else {
78
82
 
79
83
  if (charType === Break) {
80
84
 
@@ -0,0 +1,5 @@
1
+ import { ITextConvertModule } from '@leafer-ui/interface';
2
+
3
+ declare const TextConvert: ITextConvertModule;
4
+
5
+ export { TextConvert };