leafer-ui 1.5.0 → 1.5.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/README.md CHANGED
@@ -19,7 +19,7 @@
19
19
  <img width="98" titel="gitee" src="https://www.leaferjs.com/svg/gitee-stars.svg" />
20
20
  </a>
21
21
  <a target="_blank" href="https://github.com/leaferjs/leafer-ui" aria-label="github" rel="noopener">
22
- <img width="120" title="github" src="https://www.leaferjs.com/svg/github-stars.svg" />
22
+ <img width="120" title="github" src="https://www.leaferjs.com/svg/github-stars.svg?d=0324" />
23
23
  </a>
24
24
  </div>
25
25
 
@@ -78,7 +78,7 @@ LeaferJS 试行 [4 天工作制](https://www.leaferjs.com/ui/blog/2025-02-06.htm
78
78
 
79
79
  【Bug/建议】xxxxxxxxxxx 标题 xxxxxxxxxxxxxx
80
80
 
81
- 环境:电脑 + window 11 + chrome 131 + leaferjs 1.5.0
81
+ 环境:电脑 + window 11 + chrome 131 + leaferjs 1.5.2
82
82
 
83
83
  复现步骤:请提供详细的复现逻辑及可直接运行的代码,以便更快解决问题。
84
84
  ```
@@ -98,7 +98,7 @@ LeaferJS 试行 [4 天工作制](https://www.leaferjs.com/ui/blog/2025-02-06.htm
98
98
 
99
99
  【leaferjs】xxxxxxxxxxx 标题 xxxxxxxxxxxxxx
100
100
 
101
- 环境:电脑 + window 11 + chrome 131 + leaferjs 1.5.0
101
+ 环境:电脑 + window 11 + chrome 131 + leaferjs 1.5.2
102
102
 
103
103
  #LeaferJS (点击知乎提问框底部的 # 号,可绑定话题)
104
104
  ```
@@ -127,7 +127,7 @@ LeaferJS 致力于实现一套简洁、开放、现代化的 UI 绘图语言标
127
127
 
128
128
  通过不断革新的图形渲染技术、配套支持, 吸引更多的开发者加入使用,建立起一个开放的生态环境,沟通有无,互相从中受益,推动行业的快速发展,并诞生出更多有创意的技术和产品。
129
129
 
130
- 我们的目标不仅是让它成为前沿的 2D 和未来的 3D 引擎技术,还希望它能够为开发者带来极致的开发体验,助力开发者快速构建 AI 时代的网页、应用、设计、画布、游戏和动画等可视化生产力工具(如下一代 local-first Figma、Miro、Notion、Unity、Adobe、Canva、Webflow 等)。
130
+ 我们的目标不仅是打造最前沿的 2D 和未来的 3D 引擎技术,更要创造一套简洁、开放、现代化的 UI 绘图标准。我们希望为开发者带来极致的开发体验,助力他们快速构建 AI 时代的网页、应用、设计、画布、游戏和动画等可视化生产力工具,推动下一代本地优先的 Figma、Miro、Notion、Unity、Adobe、Canva、Webflow 等创新产品的诞生。
131
131
 
132
132
  ![leaferjs](https://www.leaferjs.com/ui/svg/leaferjs.svg?d=013007)
133
133
 
package/dist/web.cjs CHANGED
@@ -124,7 +124,7 @@ class LeaferCanvas extends core.LeaferCanvasBase {
124
124
  else {
125
125
  window.addEventListener('resize', this.windowListener = () => {
126
126
  const pixelRatio = core.Platform.devicePixelRatio;
127
- if (this.pixelRatio !== pixelRatio) {
127
+ if (!this.config.pixelRatio && this.pixelRatio !== pixelRatio) {
128
128
  const { width, height } = this;
129
129
  this.emitResize({ width, height, pixelRatio });
130
130
  }
@@ -141,7 +141,7 @@ class LeaferCanvas extends core.LeaferCanvasBase {
141
141
  checkAutoBounds(parentSize) {
142
142
  const view = this.view;
143
143
  const { x, y, width, height } = this.autoBounds.getBoundsFrom(parentSize);
144
- const size = { width, height, pixelRatio: core.Platform.devicePixelRatio };
144
+ const size = { width, height, pixelRatio: this.config.pixelRatio ? this.pixelRatio : core.Platform.devicePixelRatio };
145
145
  if (!this.isSameSize(size)) {
146
146
  const { style } = view;
147
147
  style.marginLeft = x + 'px';
@@ -1326,16 +1326,20 @@ class Interaction extends core$1.InteractionBase {
1326
1326
  }
1327
1327
 
1328
1328
  function fillText(ui, canvas) {
1329
- let row;
1330
- const { rows, decorationY, decorationHeight } = ui.__.__textDrawData;
1329
+ let row, data = ui.__.__textDrawData;
1330
+ const { rows, decorationY } = data;
1331
1331
  for (let i = 0, len = rows.length; i < len; i++) {
1332
1332
  row = rows[i];
1333
1333
  if (row.text)
1334
1334
  canvas.fillText(row.text, row.x, row.y);
1335
1335
  else if (row.data)
1336
1336
  row.data.forEach(charData => { canvas.fillText(charData.char, charData.x, row.y); });
1337
- if (decorationY)
1338
- canvas.fillRect(row.x, row.y + decorationY, row.width, decorationHeight);
1337
+ }
1338
+ if (decorationY) {
1339
+ const { decorationColor, decorationHeight } = data;
1340
+ if (decorationColor)
1341
+ canvas.fillStyle = decorationColor;
1342
+ rows.forEach(row => decorationY.forEach(value => canvas.fillRect(row.x, row.y + value, row.width, decorationHeight)));
1339
1343
  }
1340
1344
  }
1341
1345
 
@@ -1406,16 +1410,18 @@ function drawAlignStroke(align, stroke, isStrokes, ui, canvas) {
1406
1410
  out.recycle(ui.__nowWorld);
1407
1411
  }
1408
1412
  function drawTextStroke(ui, canvas) {
1409
- let row;
1410
- const { rows, decorationY, decorationHeight } = ui.__.__textDrawData;
1413
+ let row, data = ui.__.__textDrawData;
1414
+ const { rows, decorationY } = data;
1411
1415
  for (let i = 0, len = rows.length; i < len; i++) {
1412
1416
  row = rows[i];
1413
1417
  if (row.text)
1414
1418
  canvas.strokeText(row.text, row.x, row.y);
1415
1419
  else if (row.data)
1416
1420
  row.data.forEach(charData => { canvas.strokeText(charData.char, charData.x, row.y); });
1417
- if (decorationY)
1418
- canvas.strokeRect(row.x, row.y + decorationY, row.width, decorationHeight);
1421
+ }
1422
+ if (decorationY) {
1423
+ const { decorationHeight } = data;
1424
+ rows.forEach(row => decorationY.forEach(value => canvas.strokeRect(row.x, row.y + value, row.width, decorationHeight)));
1419
1425
  }
1420
1426
  }
1421
1427
  function drawStrokesStyle(strokes, isText, ui, canvas) {
@@ -2013,6 +2019,8 @@ function recycleImage(attrName, data) {
2013
2019
  }
2014
2020
  image.unload(paints[i].loadId, !input.some((item) => item.url === url));
2015
2021
  }
2022
+ else
2023
+ paints[i].style = null;
2016
2024
  }
2017
2025
  }
2018
2026
  return recycleMap;
@@ -2745,14 +2753,25 @@ function toTextChar(row) {
2745
2753
  }
2746
2754
 
2747
2755
  function decorationText(drawData, style) {
2748
- const { fontSize } = style;
2756
+ let type;
2757
+ const { fontSize, textDecoration } = style;
2749
2758
  drawData.decorationHeight = fontSize / 11;
2750
- switch (style.textDecoration) {
2759
+ if (typeof textDecoration === 'object') {
2760
+ type = textDecoration.type;
2761
+ if (textDecoration.color)
2762
+ drawData.decorationColor = draw.ColorConvert.string(textDecoration.color);
2763
+ }
2764
+ else
2765
+ type = textDecoration;
2766
+ switch (type) {
2751
2767
  case 'under':
2752
- drawData.decorationY = fontSize * 0.15;
2768
+ drawData.decorationY = [fontSize * 0.15];
2753
2769
  break;
2754
2770
  case 'delete':
2755
- drawData.decorationY = -fontSize * 0.35;
2771
+ drawData.decorationY = [-fontSize * 0.35];
2772
+ break;
2773
+ case 'under-delete':
2774
+ drawData.decorationY = [fontSize * 0.15, -fontSize * 0.35];
2756
2775
  }
2757
2776
  }
2758
2777