@fileverse-dev/fortune-core 1.2.29 → 1.2.31

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.
@@ -133,26 +133,26 @@ export function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_
133
133
  if (attr === "tb" && canvas && foucsStatus === "2") {
134
134
  var currentColWidth_1 = ((_y = cfg.columnlen) === null || _y === void 0 ? void 0 : _y[c]) || ctx.luckysheetfile[sheetIndex].defaultColWidth || 100;
135
135
  var lineCount_1 = 1;
136
- var fontString_1 = '10px Arial';
136
+ var fontString_1 = "10px Arial";
137
137
  if (value.fs) {
138
- fontString_1 = value.fs * 1.5 + "px Arial";
138
+ fontString_1 = "".concat(value.fs * 1.5, "px Arial");
139
139
  }
140
140
  if (value === null || value === void 0 ? void 0 : value.bl) {
141
- lineCount_1 = lineCount_1 + 1;
141
+ lineCount_1 += 1;
142
142
  }
143
143
  if (value.m) {
144
144
  lineCount_1 = getLineCount(value.m, currentColWidth_1, fontString_1);
145
- var hOffset = lineCount_1 < 4 ? 2 : 1.8;
145
+ var hOffset = lineCount_1 < 4 ? 1.9 : 1.7;
146
146
  lineCount_1 = lineCount_1 * hOffset + 1;
147
147
  } else if ((_1 = (_0 = (_z = value === null || value === void 0 ? void 0 : value.ct) === null || _z === void 0 ? void 0 : _z.s) === null || _0 === void 0 ? void 0 : _0[0]) === null || _1 === void 0 ? void 0 : _1.v) {
148
- lineCount_1 = lineCount_1 - 1;
148
+ lineCount_1 -= 1;
149
149
  var line = (_4 = (_3 = (_2 = value === null || value === void 0 ? void 0 : value.ct) === null || _2 === void 0 ? void 0 : _2.s) === null || _3 === void 0 ? void 0 : _3[0]) === null || _4 === void 0 ? void 0 : _4.v.split("\n");
150
150
  line.forEach(function (item) {
151
151
  var subLineCount = getLineCount(item, currentColWidth_1, fontString_1);
152
- lineCount_1 = lineCount_1 + subLineCount;
152
+ lineCount_1 += subLineCount;
153
153
  });
154
- var hOffset = lineCount_1 < 4 ? 2.2 : 1.9;
155
- lineCount_1 = lineCount_1 * 1.9;
154
+ var hOffset = lineCount_1 < 4 ? 2.2 : 1.6;
155
+ lineCount_1 *= hOffset;
156
156
  }
157
157
  var fontSize = (value === null || value === void 0 ? void 0 : value.fs) || 10;
158
158
  var rowHeight = fontSize * lineCount_1;
package/es/utils/index.js CHANGED
@@ -334,26 +334,26 @@ export function checkIsCol(str) {
334
334
  }
335
335
  export function getLineCount(sentence, maxWidthPx, font) {
336
336
  if (font === void 0) {
337
- font = '12px Arial';
337
+ font = "12px Arial";
338
338
  }
339
- var canvas = document.createElement('canvas');
340
- var context = canvas.getContext('2d');
339
+ var canvas = document.createElement("canvas");
340
+ var context = canvas.getContext("2d");
341
341
  if (context) {
342
342
  context.font = font;
343
343
  }
344
- var words = sentence.split(' ');
345
- var currentLine = '';
344
+ var words = sentence.split(" ");
345
+ var currentLine = "";
346
346
  var lineCount = 0;
347
347
  words.forEach(function (word) {
348
- var testLine = currentLine ? currentLine + ' ' + word : word;
348
+ var testLine = currentLine ? "".concat(currentLine, " ").concat(word) : word;
349
349
  var testWidth = context === null || context === void 0 ? void 0 : context.measureText(testLine).width;
350
350
  if (testWidth && testWidth > maxWidthPx && currentLine) {
351
- lineCount++;
351
+ lineCount += 1;
352
352
  currentLine = word;
353
353
  } else {
354
354
  currentLine = testLine;
355
355
  }
356
356
  });
357
- if (currentLine) lineCount++;
357
+ if (currentLine) lineCount += 1;
358
358
  return lineCount;
359
359
  }
@@ -166,26 +166,26 @@ function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_st, col
166
166
  if (attr === "tb" && canvas && foucsStatus === "2") {
167
167
  var currentColWidth_1 = ((_y = cfg.columnlen) === null || _y === void 0 ? void 0 : _y[c]) || ctx.luckysheetfile[sheetIndex].defaultColWidth || 100;
168
168
  var lineCount_1 = 1;
169
- var fontString_1 = '10px Arial';
169
+ var fontString_1 = "10px Arial";
170
170
  if (value.fs) {
171
- fontString_1 = value.fs * 1.5 + "px Arial";
171
+ fontString_1 = "".concat(value.fs * 1.5, "px Arial");
172
172
  }
173
173
  if (value === null || value === void 0 ? void 0 : value.bl) {
174
- lineCount_1 = lineCount_1 + 1;
174
+ lineCount_1 += 1;
175
175
  }
176
176
  if (value.m) {
177
177
  lineCount_1 = (0, _utils.getLineCount)(value.m, currentColWidth_1, fontString_1);
178
- var hOffset = lineCount_1 < 4 ? 2 : 1.8;
178
+ var hOffset = lineCount_1 < 4 ? 1.9 : 1.7;
179
179
  lineCount_1 = lineCount_1 * hOffset + 1;
180
180
  } else if ((_1 = (_0 = (_z = value === null || value === void 0 ? void 0 : value.ct) === null || _z === void 0 ? void 0 : _z.s) === null || _0 === void 0 ? void 0 : _0[0]) === null || _1 === void 0 ? void 0 : _1.v) {
181
- lineCount_1 = lineCount_1 - 1;
181
+ lineCount_1 -= 1;
182
182
  var line = (_4 = (_3 = (_2 = value === null || value === void 0 ? void 0 : value.ct) === null || _2 === void 0 ? void 0 : _2.s) === null || _3 === void 0 ? void 0 : _3[0]) === null || _4 === void 0 ? void 0 : _4.v.split("\n");
183
183
  line.forEach(function (item) {
184
184
  var subLineCount = (0, _utils.getLineCount)(item, currentColWidth_1, fontString_1);
185
- lineCount_1 = lineCount_1 + subLineCount;
185
+ lineCount_1 += subLineCount;
186
186
  });
187
- var hOffset = lineCount_1 < 4 ? 2.2 : 1.9;
188
- lineCount_1 = lineCount_1 * 1.9;
187
+ var hOffset = lineCount_1 < 4 ? 2.2 : 1.6;
188
+ lineCount_1 *= hOffset;
189
189
  }
190
190
  var fontSize = (value === null || value === void 0 ? void 0 : value.fs) || 10;
191
191
  var rowHeight = fontSize * lineCount_1;
@@ -408,26 +408,26 @@ function checkIsCol(str) {
408
408
  }
409
409
  function getLineCount(sentence, maxWidthPx, font) {
410
410
  if (font === void 0) {
411
- font = '12px Arial';
411
+ font = "12px Arial";
412
412
  }
413
- var canvas = document.createElement('canvas');
414
- var context = canvas.getContext('2d');
413
+ var canvas = document.createElement("canvas");
414
+ var context = canvas.getContext("2d");
415
415
  if (context) {
416
416
  context.font = font;
417
417
  }
418
- var words = sentence.split(' ');
419
- var currentLine = '';
418
+ var words = sentence.split(" ");
419
+ var currentLine = "";
420
420
  var lineCount = 0;
421
421
  words.forEach(function (word) {
422
- var testLine = currentLine ? currentLine + ' ' + word : word;
422
+ var testLine = currentLine ? "".concat(currentLine, " ").concat(word) : word;
423
423
  var testWidth = context === null || context === void 0 ? void 0 : context.measureText(testLine).width;
424
424
  if (testWidth && testWidth > maxWidthPx && currentLine) {
425
- lineCount++;
425
+ lineCount += 1;
426
426
  currentLine = word;
427
427
  } else {
428
428
  currentLine = testLine;
429
429
  }
430
430
  });
431
- if (currentLine) lineCount++;
431
+ if (currentLine) lineCount += 1;
432
432
  return lineCount;
433
433
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fileverse-dev/fortune-core",
3
- "version": "1.2.29",
3
+ "version": "1.2.31",
4
4
  "main": "lib/index.js",
5
5
  "module": "es/index.js",
6
6
  "typings": "lib/index.d.ts",