leafer-draw 1.5.1 → 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/dist/web.esm.js CHANGED
@@ -860,16 +860,20 @@ Object.assign(Creator, {
860
860
  Platform.layout = Layouter.fullLayout;
861
861
 
862
862
  function fillText(ui, canvas) {
863
- let row;
864
- const { rows, decorationY, decorationHeight } = ui.__.__textDrawData;
863
+ let row, data = ui.__.__textDrawData;
864
+ const { rows, decorationY } = data;
865
865
  for (let i = 0, len = rows.length; i < len; i++) {
866
866
  row = rows[i];
867
867
  if (row.text)
868
868
  canvas.fillText(row.text, row.x, row.y);
869
869
  else if (row.data)
870
870
  row.data.forEach(charData => { canvas.fillText(charData.char, charData.x, row.y); });
871
- if (decorationY)
872
- canvas.fillRect(row.x, row.y + decorationY, row.width, decorationHeight);
871
+ }
872
+ if (decorationY) {
873
+ const { decorationColor, decorationHeight } = data;
874
+ if (decorationColor)
875
+ canvas.fillStyle = decorationColor;
876
+ rows.forEach(row => decorationY.forEach(value => canvas.fillRect(row.x, row.y + value, row.width, decorationHeight)));
873
877
  }
874
878
  }
875
879
 
@@ -940,16 +944,18 @@ function drawAlignStroke(align, stroke, isStrokes, ui, canvas) {
940
944
  out.recycle(ui.__nowWorld);
941
945
  }
942
946
  function drawTextStroke(ui, canvas) {
943
- let row;
944
- const { rows, decorationY, decorationHeight } = ui.__.__textDrawData;
947
+ let row, data = ui.__.__textDrawData;
948
+ const { rows, decorationY } = data;
945
949
  for (let i = 0, len = rows.length; i < len; i++) {
946
950
  row = rows[i];
947
951
  if (row.text)
948
952
  canvas.strokeText(row.text, row.x, row.y);
949
953
  else if (row.data)
950
954
  row.data.forEach(charData => { canvas.strokeText(charData.char, charData.x, row.y); });
951
- if (decorationY)
952
- canvas.strokeRect(row.x, row.y + decorationY, row.width, decorationHeight);
955
+ }
956
+ if (decorationY) {
957
+ const { decorationHeight } = data;
958
+ rows.forEach(row => decorationY.forEach(value => canvas.strokeRect(row.x, row.y + value, row.width, decorationHeight)));
953
959
  }
954
960
  }
955
961
  function drawStrokesStyle(strokes, isText, ui, canvas) {
@@ -1547,6 +1553,8 @@ function recycleImage(attrName, data) {
1547
1553
  }
1548
1554
  image.unload(paints[i].loadId, !input.some((item) => item.url === url));
1549
1555
  }
1556
+ else
1557
+ paints[i].style = null;
1550
1558
  }
1551
1559
  }
1552
1560
  return recycleMap;
@@ -2279,14 +2287,25 @@ function toTextChar(row) {
2279
2287
  }
2280
2288
 
2281
2289
  function decorationText(drawData, style) {
2282
- const { fontSize } = style;
2290
+ let type;
2291
+ const { fontSize, textDecoration } = style;
2283
2292
  drawData.decorationHeight = fontSize / 11;
2284
- switch (style.textDecoration) {
2293
+ if (typeof textDecoration === 'object') {
2294
+ type = textDecoration.type;
2295
+ if (textDecoration.color)
2296
+ drawData.decorationColor = ColorConvert.string(textDecoration.color);
2297
+ }
2298
+ else
2299
+ type = textDecoration;
2300
+ switch (type) {
2285
2301
  case 'under':
2286
- drawData.decorationY = fontSize * 0.15;
2302
+ drawData.decorationY = [fontSize * 0.15];
2287
2303
  break;
2288
2304
  case 'delete':
2289
- drawData.decorationY = -fontSize * 0.35;
2305
+ drawData.decorationY = [-fontSize * 0.35];
2306
+ break;
2307
+ case 'under-delete':
2308
+ drawData.decorationY = [fontSize * 0.15, -fontSize * 0.35];
2290
2309
  }
2291
2310
  }
2292
2311