@leafer-ui/worker 1.5.1 → 1.5.3

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/dist/worker.cjs CHANGED
@@ -836,16 +836,20 @@ Object.assign(core.Creator, {
836
836
  core.Platform.layout = Layouter.fullLayout;
837
837
 
838
838
  function fillText(ui, canvas) {
839
- let row;
840
- const { rows, decorationY, decorationHeight } = ui.__.__textDrawData;
839
+ let row, data = ui.__.__textDrawData;
840
+ const { rows, decorationY } = data;
841
841
  for (let i = 0, len = rows.length; i < len; i++) {
842
842
  row = rows[i];
843
843
  if (row.text)
844
844
  canvas.fillText(row.text, row.x, row.y);
845
845
  else if (row.data)
846
846
  row.data.forEach(charData => { canvas.fillText(charData.char, charData.x, row.y); });
847
- if (decorationY)
848
- canvas.fillRect(row.x, row.y + decorationY, row.width, decorationHeight);
847
+ }
848
+ if (decorationY) {
849
+ const { decorationColor, decorationHeight } = data;
850
+ if (decorationColor)
851
+ canvas.fillStyle = decorationColor;
852
+ rows.forEach(row => decorationY.forEach(value => canvas.fillRect(row.x, row.y + value, row.width, decorationHeight)));
849
853
  }
850
854
  }
851
855
 
@@ -916,16 +920,18 @@ function drawAlignStroke(align, stroke, isStrokes, ui, canvas) {
916
920
  out.recycle(ui.__nowWorld);
917
921
  }
918
922
  function drawTextStroke(ui, canvas) {
919
- let row;
920
- const { rows, decorationY, decorationHeight } = ui.__.__textDrawData;
923
+ let row, data = ui.__.__textDrawData;
924
+ const { rows, decorationY } = data;
921
925
  for (let i = 0, len = rows.length; i < len; i++) {
922
926
  row = rows[i];
923
927
  if (row.text)
924
928
  canvas.strokeText(row.text, row.x, row.y);
925
929
  else if (row.data)
926
930
  row.data.forEach(charData => { canvas.strokeText(charData.char, charData.x, row.y); });
927
- if (decorationY)
928
- canvas.strokeRect(row.x, row.y + decorationY, row.width, decorationHeight);
931
+ }
932
+ if (decorationY) {
933
+ const { decorationHeight } = data;
934
+ rows.forEach(row => decorationY.forEach(value => canvas.strokeRect(row.x, row.y + value, row.width, decorationHeight)));
929
935
  }
930
936
  }
931
937
  function drawStrokesStyle(strokes, isText, ui, canvas) {
@@ -1523,6 +1529,8 @@ function recycleImage(attrName, data) {
1523
1529
  }
1524
1530
  image.unload(paints[i].loadId, !input.some((item) => item.url === url));
1525
1531
  }
1532
+ else
1533
+ paints[i].style = null;
1526
1534
  }
1527
1535
  }
1528
1536
  return recycleMap;
@@ -2255,14 +2263,25 @@ function toTextChar(row) {
2255
2263
  }
2256
2264
 
2257
2265
  function decorationText(drawData, style) {
2258
- const { fontSize } = style;
2266
+ let type;
2267
+ const { fontSize, textDecoration } = style;
2259
2268
  drawData.decorationHeight = fontSize / 11;
2260
- switch (style.textDecoration) {
2269
+ if (typeof textDecoration === 'object') {
2270
+ type = textDecoration.type;
2271
+ if (textDecoration.color)
2272
+ drawData.decorationColor = draw.ColorConvert.string(textDecoration.color);
2273
+ }
2274
+ else
2275
+ type = textDecoration;
2276
+ switch (type) {
2261
2277
  case 'under':
2262
- drawData.decorationY = fontSize * 0.15;
2278
+ drawData.decorationY = [fontSize * 0.15];
2263
2279
  break;
2264
2280
  case 'delete':
2265
- drawData.decorationY = -fontSize * 0.35;
2281
+ drawData.decorationY = [-fontSize * 0.35];
2282
+ break;
2283
+ case 'under-delete':
2284
+ drawData.decorationY = [fontSize * 0.15, -fontSize * 0.35];
2266
2285
  }
2267
2286
  }
2268
2287