@leafer-draw/miniapp 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/dist/miniapp.cjs CHANGED
@@ -817,16 +817,20 @@ Object.assign(core.Creator, {
817
817
  core.Platform.layout = Layouter.fullLayout;
818
818
 
819
819
  function fillText(ui, canvas) {
820
- let row;
821
- const { rows, decorationY, decorationHeight } = ui.__.__textDrawData;
820
+ let row, data = ui.__.__textDrawData;
821
+ const { rows, decorationY } = data;
822
822
  for (let i = 0, len = rows.length; i < len; i++) {
823
823
  row = rows[i];
824
824
  if (row.text)
825
825
  canvas.fillText(row.text, row.x, row.y);
826
826
  else if (row.data)
827
827
  row.data.forEach(charData => { canvas.fillText(charData.char, charData.x, row.y); });
828
- if (decorationY)
829
- canvas.fillRect(row.x, row.y + decorationY, row.width, decorationHeight);
828
+ }
829
+ if (decorationY) {
830
+ const { decorationColor, decorationHeight } = data;
831
+ if (decorationColor)
832
+ canvas.fillStyle = decorationColor;
833
+ rows.forEach(row => decorationY.forEach(value => canvas.fillRect(row.x, row.y + value, row.width, decorationHeight)));
830
834
  }
831
835
  }
832
836
 
@@ -897,16 +901,18 @@ function drawAlignStroke(align, stroke, isStrokes, ui, canvas) {
897
901
  out.recycle(ui.__nowWorld);
898
902
  }
899
903
  function drawTextStroke(ui, canvas) {
900
- let row;
901
- const { rows, decorationY, decorationHeight } = ui.__.__textDrawData;
904
+ let row, data = ui.__.__textDrawData;
905
+ const { rows, decorationY } = data;
902
906
  for (let i = 0, len = rows.length; i < len; i++) {
903
907
  row = rows[i];
904
908
  if (row.text)
905
909
  canvas.strokeText(row.text, row.x, row.y);
906
910
  else if (row.data)
907
911
  row.data.forEach(charData => { canvas.strokeText(charData.char, charData.x, row.y); });
908
- if (decorationY)
909
- canvas.strokeRect(row.x, row.y + decorationY, row.width, decorationHeight);
912
+ }
913
+ if (decorationY) {
914
+ const { decorationHeight } = data;
915
+ rows.forEach(row => decorationY.forEach(value => canvas.strokeRect(row.x, row.y + value, row.width, decorationHeight)));
910
916
  }
911
917
  }
912
918
  function drawStrokesStyle(strokes, isText, ui, canvas) {
@@ -1504,6 +1510,8 @@ function recycleImage(attrName, data) {
1504
1510
  }
1505
1511
  image.unload(paints[i].loadId, !input.some((item) => item.url === url));
1506
1512
  }
1513
+ else
1514
+ paints[i].style = null;
1507
1515
  }
1508
1516
  }
1509
1517
  return recycleMap;
@@ -2236,14 +2244,25 @@ function toTextChar(row) {
2236
2244
  }
2237
2245
 
2238
2246
  function decorationText(drawData, style) {
2239
- const { fontSize } = style;
2247
+ let type;
2248
+ const { fontSize, textDecoration } = style;
2240
2249
  drawData.decorationHeight = fontSize / 11;
2241
- switch (style.textDecoration) {
2250
+ if (typeof textDecoration === 'object') {
2251
+ type = textDecoration.type;
2252
+ if (textDecoration.color)
2253
+ drawData.decorationColor = draw.ColorConvert.string(textDecoration.color);
2254
+ }
2255
+ else
2256
+ type = textDecoration;
2257
+ switch (type) {
2242
2258
  case 'under':
2243
- drawData.decorationY = fontSize * 0.15;
2259
+ drawData.decorationY = [fontSize * 0.15];
2244
2260
  break;
2245
2261
  case 'delete':
2246
- drawData.decorationY = -fontSize * 0.35;
2262
+ drawData.decorationY = [-fontSize * 0.35];
2263
+ break;
2264
+ case 'under-delete':
2265
+ drawData.decorationY = [fontSize * 0.15, -fontSize * 0.35];
2247
2266
  }
2248
2267
  }
2249
2268