@leafer-ui/text 1.0.0-rc.22 → 1.0.0-rc.24

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer-ui/text",
3
- "version": "1.0.0-rc.22",
3
+ "version": "1.0.0-rc.24",
4
4
  "description": "@leafer-ui/text",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -22,10 +22,10 @@
22
22
  "leaferjs"
23
23
  ],
24
24
  "dependencies": {
25
- "@leafer/core": "1.0.0-rc.22"
25
+ "@leafer/core": "1.0.0-rc.24"
26
26
  },
27
27
  "devDependencies": {
28
- "@leafer/interface": "1.0.0-rc.22",
29
- "@leafer-ui/interface": "1.0.0-rc.22"
28
+ "@leafer/interface": "1.0.0-rc.24",
29
+ "@leafer-ui/interface": "1.0.0-rc.24"
30
30
  }
31
31
  }
package/src/CharLayout.ts CHANGED
@@ -36,11 +36,11 @@ export function layoutChar(drawData: ITextDrawData, style: ITextData, width: num
36
36
 
37
37
  wordChar = { char: '', x: charX }
38
38
  charX = toWordChar(word.data, charX, wordChar)
39
- if (wordChar.char !== ' ') row.data.push(wordChar)
39
+ if (row.isOverflow || wordChar.char !== ' ') row.data.push(wordChar)
40
40
 
41
41
  } else {
42
42
 
43
- charX = toChar(word.data, charX, row.data)
43
+ charX = toChar(word.data, charX, row.data, row.isOverflow)
44
44
 
45
45
  }
46
46
 
@@ -75,9 +75,9 @@ function toWordChar(data: ITextCharData[], charX: number, wordChar: ITextCharDat
75
75
  return charX
76
76
  }
77
77
 
78
- function toChar(data: ITextCharData[], charX: number, rowData: ITextCharData[]): number {
78
+ function toChar(data: ITextCharData[], charX: number, rowData: ITextCharData[], isOverflow?: boolean): number {
79
79
  data.forEach(char => {
80
- if (char.char !== ' ') {
80
+ if (isOverflow || char.char !== ' ') {
81
81
  char.x = charX
82
82
  rowData.push(char)
83
83
  }
package/src/TextClip.ts CHANGED
@@ -9,12 +9,12 @@ export function clipText(drawData: ITextDrawData, style: ITextData): void {
9
9
  let { textOverflow } = style
10
10
  rows.splice(overflow)
11
11
 
12
-
13
- if (textOverflow !== 'hide') {
14
- if (textOverflow === 'ellipsis') textOverflow = '...'
12
+ if (textOverflow && textOverflow !== 'show') {
13
+ if (textOverflow === 'hide') textOverflow = ''
14
+ else if (textOverflow === 'ellipsis') textOverflow = '...'
15
15
 
16
16
  let char: ITextCharData, charRight: number
17
- const ellipsisWidth = Platform.canvas.measureText(textOverflow).width
17
+ const ellipsisWidth = textOverflow ? Platform.canvas.measureText(textOverflow).width : 0
18
18
  const right = style.x + style.width - ellipsisWidth
19
19
  const list = style.textWrap === 'none' ? rows : [rows[overflow - 1]]
20
20
 
package/src/TextLayout.ts CHANGED
@@ -33,12 +33,14 @@ export function layoutText(drawData: ITextDrawData, style: ITextData): void {
33
33
  row = rows[i]
34
34
  row.x = x
35
35
 
36
- switch (textAlign) {
37
- case 'center':
38
- row.x += (width - row.width) / 2
39
- break
40
- case 'right':
41
- row.x += width - row.width
36
+ if (row.width < width || (row.width > width && !__clipText)) {
37
+ switch (textAlign) {
38
+ case 'center':
39
+ row.x += (width - row.width) / 2
40
+ break
41
+ case 'right':
42
+ row.x += width - row.width
43
+ }
42
44
  }
43
45
 
44
46
  if (row.paraStart && paraSpacing && i > 0) starY += paraSpacing