@fileverse-dev/fortune-core 1.3.1 → 1.3.2-format-1

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/es/canvas.js CHANGED
@@ -1012,7 +1012,7 @@ var Canvas = function () {
1012
1012
  renderCtx.clip();
1013
1013
  renderCtx.scale(this.sheetCtx.zoomRatio, this.sheetCtx.zoomRatio);
1014
1014
  var measureText = getMeasureText(value, renderCtx, this.sheetCtx);
1015
- var textMetrics = measureText.width + 14;
1015
+ var textMetrics = measureText.width + 18;
1016
1016
  var oneLineTextHeight = measureText.actualBoundingBoxDescent + measureText.actualBoundingBoxAscent;
1017
1017
  var horizonAlignPos = pos_x + space_width;
1018
1018
  if (horizonAlign === 0) {
@@ -12,6 +12,7 @@ export declare function fixPositionOnFrozenCells(freeze: Freezen | undefined, x:
12
12
  export declare function handleCellAreaMouseDown(ctx: Context, globalCache: GlobalCache, e: MouseEvent, cellInput: HTMLDivElement, container: HTMLDivElement, fxInput?: HTMLDivElement | null, canvas?: CanvasRenderingContext2D): void;
13
13
  export declare function handleCellAreaDoubleClick(ctx: Context, globalCache: GlobalCache, settings: Settings, e: MouseEvent, container: HTMLElement): void;
14
14
  export declare function handleContextMenu(ctx: Context, settings: Settings, e: MouseEvent, workbookContainer: HTMLDivElement, container: HTMLDivElement, area: "cell" | "rowHeader" | "columnHeader"): void;
15
+ export declare function mouseRender(ctx: Context, globalCache: GlobalCache, e: MouseEvent, cellInput: HTMLDivElement, scrollX: HTMLDivElement, scrollY: HTMLDivElement, container: HTMLDivElement, fxInput?: HTMLDivElement | null): void;
15
16
  export declare function handleOverlayMouseMove(ctx: Context, globalCache: GlobalCache, e: MouseEvent, cellInput: HTMLDivElement, scrollX: HTMLDivElement, scrollY: HTMLDivElement, container: HTMLDivElement, fxInput?: HTMLDivElement | null): void;
16
17
  export declare function handleOverlayMouseUp(ctx: Context, globalCache: GlobalCache, settings: Settings, e: MouseEvent, scrollbarX: HTMLDivElement, scrollbarY: HTMLDivElement, container: HTMLDivElement, cellInput: HTMLDivElement | null, fxInput: HTMLDivElement | null): void;
17
18
  export declare function handleRowHeaderMouseDown(ctx: Context, globalCache: GlobalCache, e: MouseEvent, container: HTMLDivElement, cellInput: HTMLDivElement, fxInput: HTMLDivElement | null): void;
@@ -696,7 +696,7 @@ export function handleContextMenu(ctx, settings, e, workbookContainer, container
696
696
  });
697
697
  }
698
698
  }
699
- function mouseRender(ctx, globalCache, e, cellInput, scrollX, scrollY, container, fxInput) {
699
+ export function mouseRender(ctx, globalCache, e, cellInput, scrollX, scrollY, container, fxInput) {
700
700
  var _a, _b, _c, _d;
701
701
  var rect = container.getBoundingClientRect();
702
702
  if (ctx.luckysheet_scroll_status && !ctx.luckysheet_cols_change_size && !ctx.luckysheet_rows_change_size) {
@@ -110,7 +110,7 @@ export function getCellValue(r, c, data, attr) {
110
110
  return retv;
111
111
  }
112
112
  export function setCellValue(ctx, r, c, d, v) {
113
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
113
+ var _a, _b, _c, _d, _e, _f, _g;
114
114
  if (ctx.allowEdit === false || ctx.isFlvReadOnly) return;
115
115
  if (_.isNil(d)) {
116
116
  d = getFlowdata(ctx);
@@ -276,10 +276,7 @@ export function setCellValue(ctx, r, c, d, v) {
276
276
  } else if (!_.isNil(cell.ct) && !_.isNil(cell.ct.fa) && cell.ct.fa !== "General") {
277
277
  var fa = cell.ct.fa;
278
278
  if (isRealNum(vupdate)) {
279
- if (commaPresent && !fa.includes(",") || String(vupdate).includes(".") && ((_j = (_h = String(vupdate).split(".")) === null || _h === void 0 ? void 0 : _h[1]) === null || _j === void 0 ? void 0 : _j.length) !== ((_l = (_k = fa.split(".")) === null || _k === void 0 ? void 0 : _k[1]) === null || _l === void 0 ? void 0 : _l.length) || fa.includes(",") !== String(vupdate).includes(",")) {
280
- if (fa.includes(",") !== String(vupdate).includes(",")) {
281
- commaPresent = true;
282
- }
279
+ if (commaPresent && !fa.includes(",")) {
283
280
  fa = getNumberFormat(String(vupdate), commaPresent);
284
281
  }
285
282
  vupdate = parseFloat(vupdate);
@@ -289,6 +286,9 @@ export function setCellValue(ctx, r, c, d, v) {
289
286
  t: "n"
290
287
  });
291
288
  }
289
+ if (!cell.ht) {
290
+ cell.ht = 2;
291
+ }
292
292
  }
293
293
  var mask = update(fa, vupdate);
294
294
  if (mask === vupdate) {
@@ -180,6 +180,7 @@ export function selectTitlesRange(map) {
180
180
  return rangeArr;
181
181
  }
182
182
  export function pasteHandlerOfPaintModel(ctx, copyRange) {
183
+ var _a;
183
184
  var cfg = ctx.config;
184
185
  if (cfg.merge == null) {
185
186
  cfg.merge = {};
@@ -369,36 +370,40 @@ export function pasteHandlerOfPaintModel(ctx, copyRange) {
369
370
  }
370
371
  var currFile = ctx.luckysheetfile[getSheetIndex(ctx, ctx.currentSheetId)];
371
372
  currFile.config = cfg;
372
- currFile.dataVerification = dataVerification;
373
- var cdformat = null;
373
+ if (dataVerification != null) {
374
+ currFile.dataVerification = dataVerification;
375
+ }
374
376
  var copyIndex = getSheetIndex(ctx, copySheetIndex);
375
- if (!copyIndex) return;
376
- var ruleArr = _.cloneDeep(ctx.luckysheetfile[copyIndex].luckysheet_conditionformat_save);
377
- if (!_.isNil(ruleArr) && ruleArr.length > 0) {
378
- var currentIndex = getSheetIndex(ctx, ctx.currentSheetId);
379
- cdformat = _.cloneDeep(ctx.luckysheetfile[currentIndex].luckysheet_conditionformat_save);
380
- for (var i = 0; i < ruleArr.length; i += 1) {
381
- var cdformat_cellrange = ruleArr[i].cellrange;
382
- var emptyRange = [];
383
- for (var j = 0; j < cdformat_cellrange.length; j += 1) {
384
- var range = CFSplitRange(cdformat_cellrange[j], {
385
- row: [c_r1, c_r2],
386
- column: [c_c1, c_c2]
387
- }, {
388
- row: [minh, maxh],
389
- column: [minc, maxc]
390
- }, "operatePart");
391
- if (range.length > 0) {
392
- emptyRange = emptyRange.concat(range);
377
+ if (copyIndex != null) {
378
+ var ruleArr = _.cloneDeep(ctx.luckysheetfile[copyIndex].luckysheet_conditionformat_save);
379
+ if (!_.isNil(ruleArr) && ruleArr.length > 0) {
380
+ var currentIndex = getSheetIndex(ctx, ctx.currentSheetId);
381
+ var existingCf = ctx.luckysheetfile[currentIndex].luckysheet_conditionformat_save;
382
+ var cdformat = (_a = _.cloneDeep(existingCf)) !== null && _a !== void 0 ? _a : [];
383
+ for (var i = 0; i < ruleArr.length; i += 1) {
384
+ var cdformat_cellrange = ruleArr[i].cellrange;
385
+ var emptyRange = [];
386
+ for (var j = 0; j < cdformat_cellrange.length; j += 1) {
387
+ var range = CFSplitRange(cdformat_cellrange[j], {
388
+ row: [c_r1, c_r2],
389
+ column: [c_c1, c_c2]
390
+ }, {
391
+ row: [minh, maxh],
392
+ column: [minc, maxc]
393
+ }, "operatePart");
394
+ if (range.length > 0) {
395
+ emptyRange = emptyRange.concat(range);
396
+ }
397
+ }
398
+ if (emptyRange.length > 0) {
399
+ ruleArr[i].cellrange = [{
400
+ row: [minh, maxh],
401
+ column: [minc, maxc]
402
+ }];
403
+ cdformat.push(ruleArr[i]);
393
404
  }
394
405
  }
395
- if (emptyRange.length > 0) {
396
- ruleArr[i].cellrange = [{
397
- row: [minh, maxh],
398
- column: [minc, maxc]
399
- }];
400
- cdformat.push(ruleArr[i]);
401
- }
406
+ currFile.luckysheet_conditionformat_save = cdformat;
402
407
  }
403
408
  }
404
409
  }
@@ -33,21 +33,36 @@ export function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_
33
33
  } else {
34
34
  value = cell;
35
35
  }
36
+ var type = "n";
37
+ if (is_date(foucsStatus) || foucsStatus === 14 || foucsStatus === 15 || foucsStatus === 16 || foucsStatus === 17 || foucsStatus === 18 || foucsStatus === 19 || foucsStatus === 20 || foucsStatus === 21 || foucsStatus === 22 || foucsStatus === 45 || foucsStatus === 46 || foucsStatus === 47) {
38
+ type = "d";
39
+ } else if (foucsStatus === "@" || foucsStatus === 49) {
40
+ type = "s";
41
+ }
36
42
  if (_.isNil(value)) {
43
+ if (!_.isNil(d[r])) {
44
+ if (_.isNil(d[r][c])) {
45
+ d[r][c] = {
46
+ ct: {
47
+ fa: foucsStatus,
48
+ t: type
49
+ }
50
+ };
51
+ } else if (_.isPlainObject(d[r][c])) {
52
+ if (_.isNil(d[r][c].ct)) d[r][c].ct = {};
53
+ d[r][c].ct.fa = foucsStatus;
54
+ d[r][c].ct.t = type;
55
+ }
56
+ }
37
57
  continue;
38
58
  }
39
59
  if (foucsStatus !== "@" && isRealNum(value)) {
40
60
  value = Number(value);
41
61
  }
42
- var mask = update(foucsStatus, value);
43
- var type = "n";
44
- if (is_date(foucsStatus) || foucsStatus === 14 || foucsStatus === 15 || foucsStatus === 16 || foucsStatus === 17 || foucsStatus === 18 || foucsStatus === 19 || foucsStatus === 20 || foucsStatus === 21 || foucsStatus === 22 || foucsStatus === 45 || foucsStatus === 46 || foucsStatus === 47) {
45
- type = "d";
46
- } else if (foucsStatus === "@" || foucsStatus === 49) {
47
- type = "s";
48
- } else if (foucsStatus === "General" || foucsStatus === 0) {
62
+ if (foucsStatus === "General" || foucsStatus === 0) {
49
63
  type = isRealNum(value) ? "n" : "g";
50
64
  }
65
+ var mask = update(foucsStatus, value);
51
66
  if (cell && _.isPlainObject(cell)) {
52
67
  cell.m = "".concat(mask);
53
68
  if (_.isNil(cell.ct)) {
package/lib/canvas.js CHANGED
@@ -1019,7 +1019,7 @@ var Canvas = exports.Canvas = function () {
1019
1019
  renderCtx.clip();
1020
1020
  renderCtx.scale(this.sheetCtx.zoomRatio, this.sheetCtx.zoomRatio);
1021
1021
  var measureText = (0, _text.getMeasureText)(value, renderCtx, this.sheetCtx);
1022
- var textMetrics = measureText.width + 14;
1022
+ var textMetrics = measureText.width + 18;
1023
1023
  var oneLineTextHeight = measureText.actualBoundingBoxDescent + measureText.actualBoundingBoxAscent;
1024
1024
  var horizonAlignPos = pos_x + space_width;
1025
1025
  if (horizonAlign === 0) {
@@ -12,6 +12,7 @@ export declare function fixPositionOnFrozenCells(freeze: Freezen | undefined, x:
12
12
  export declare function handleCellAreaMouseDown(ctx: Context, globalCache: GlobalCache, e: MouseEvent, cellInput: HTMLDivElement, container: HTMLDivElement, fxInput?: HTMLDivElement | null, canvas?: CanvasRenderingContext2D): void;
13
13
  export declare function handleCellAreaDoubleClick(ctx: Context, globalCache: GlobalCache, settings: Settings, e: MouseEvent, container: HTMLElement): void;
14
14
  export declare function handleContextMenu(ctx: Context, settings: Settings, e: MouseEvent, workbookContainer: HTMLDivElement, container: HTMLDivElement, area: "cell" | "rowHeader" | "columnHeader"): void;
15
+ export declare function mouseRender(ctx: Context, globalCache: GlobalCache, e: MouseEvent, cellInput: HTMLDivElement, scrollX: HTMLDivElement, scrollY: HTMLDivElement, container: HTMLDivElement, fxInput?: HTMLDivElement | null): void;
15
16
  export declare function handleOverlayMouseMove(ctx: Context, globalCache: GlobalCache, e: MouseEvent, cellInput: HTMLDivElement, scrollX: HTMLDivElement, scrollY: HTMLDivElement, container: HTMLDivElement, fxInput?: HTMLDivElement | null): void;
16
17
  export declare function handleOverlayMouseUp(ctx: Context, globalCache: GlobalCache, settings: Settings, e: MouseEvent, scrollbarX: HTMLDivElement, scrollbarY: HTMLDivElement, container: HTMLDivElement, cellInput: HTMLDivElement | null, fxInput: HTMLDivElement | null): void;
17
18
  export declare function handleRowHeaderMouseDown(ctx: Context, globalCache: GlobalCache, e: MouseEvent, container: HTMLDivElement, cellInput: HTMLDivElement, fxInput: HTMLDivElement | null): void;
@@ -16,6 +16,7 @@ exports.handleOverlayMouseUp = handleOverlayMouseUp;
16
16
  exports.handleRowFreezeHandleMouseDown = handleRowFreezeHandleMouseDown;
17
17
  exports.handleRowHeaderMouseDown = handleRowHeaderMouseDown;
18
18
  exports.handleRowSizeHandleMouseDown = handleRowSizeHandleMouseDown;
19
+ exports.mouseRender = mouseRender;
19
20
  var _lodash = _interopRequireDefault(require("lodash"));
20
21
  var _context = require("../context");
21
22
  var _modules = require("../modules");
@@ -143,7 +143,7 @@ function getCellValue(r, c, data, attr) {
143
143
  return retv;
144
144
  }
145
145
  function setCellValue(ctx, r, c, d, v) {
146
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
146
+ var _a, _b, _c, _d, _e, _f, _g;
147
147
  if (ctx.allowEdit === false || ctx.isFlvReadOnly) return;
148
148
  if (_lodash.default.isNil(d)) {
149
149
  d = (0, _context.getFlowdata)(ctx);
@@ -309,10 +309,7 @@ function setCellValue(ctx, r, c, d, v) {
309
309
  } else if (!_lodash.default.isNil(cell.ct) && !_lodash.default.isNil(cell.ct.fa) && cell.ct.fa !== "General") {
310
310
  var fa = cell.ct.fa;
311
311
  if ((0, _validation.isRealNum)(vupdate)) {
312
- if (commaPresent && !fa.includes(",") || String(vupdate).includes(".") && ((_j = (_h = String(vupdate).split(".")) === null || _h === void 0 ? void 0 : _h[1]) === null || _j === void 0 ? void 0 : _j.length) !== ((_l = (_k = fa.split(".")) === null || _k === void 0 ? void 0 : _k[1]) === null || _l === void 0 ? void 0 : _l.length) || fa.includes(",") !== String(vupdate).includes(",")) {
313
- if (fa.includes(",") !== String(vupdate).includes(",")) {
314
- commaPresent = true;
315
- }
312
+ if (commaPresent && !fa.includes(",")) {
316
313
  fa = (0, _utils.getNumberFormat)(String(vupdate), commaPresent);
317
314
  }
318
315
  vupdate = parseFloat(vupdate);
@@ -322,6 +319,9 @@ function setCellValue(ctx, r, c, d, v) {
322
319
  t: "n"
323
320
  });
324
321
  }
322
+ if (!cell.ht) {
323
+ cell.ht = 2;
324
+ }
325
325
  }
326
326
  var mask = (0, _format.update)(fa, vupdate);
327
327
  if (mask === vupdate) {
@@ -215,6 +215,7 @@ function selectTitlesRange(map) {
215
215
  return rangeArr;
216
216
  }
217
217
  function pasteHandlerOfPaintModel(ctx, copyRange) {
218
+ var _a;
218
219
  var cfg = ctx.config;
219
220
  if (cfg.merge == null) {
220
221
  cfg.merge = {};
@@ -404,36 +405,40 @@ function pasteHandlerOfPaintModel(ctx, copyRange) {
404
405
  }
405
406
  var currFile = ctx.luckysheetfile[(0, _utils.getSheetIndex)(ctx, ctx.currentSheetId)];
406
407
  currFile.config = cfg;
407
- currFile.dataVerification = dataVerification;
408
- var cdformat = null;
408
+ if (dataVerification != null) {
409
+ currFile.dataVerification = dataVerification;
410
+ }
409
411
  var copyIndex = (0, _utils.getSheetIndex)(ctx, copySheetIndex);
410
- if (!copyIndex) return;
411
- var ruleArr = _lodash.default.cloneDeep(ctx.luckysheetfile[copyIndex].luckysheet_conditionformat_save);
412
- if (!_lodash.default.isNil(ruleArr) && ruleArr.length > 0) {
413
- var currentIndex = (0, _utils.getSheetIndex)(ctx, ctx.currentSheetId);
414
- cdformat = _lodash.default.cloneDeep(ctx.luckysheetfile[currentIndex].luckysheet_conditionformat_save);
415
- for (var i = 0; i < ruleArr.length; i += 1) {
416
- var cdformat_cellrange = ruleArr[i].cellrange;
417
- var emptyRange = [];
418
- for (var j = 0; j < cdformat_cellrange.length; j += 1) {
419
- var range = (0, _ConditionFormat.CFSplitRange)(cdformat_cellrange[j], {
420
- row: [c_r1, c_r2],
421
- column: [c_c1, c_c2]
422
- }, {
423
- row: [minh, maxh],
424
- column: [minc, maxc]
425
- }, "operatePart");
426
- if (range.length > 0) {
427
- emptyRange = emptyRange.concat(range);
412
+ if (copyIndex != null) {
413
+ var ruleArr = _lodash.default.cloneDeep(ctx.luckysheetfile[copyIndex].luckysheet_conditionformat_save);
414
+ if (!_lodash.default.isNil(ruleArr) && ruleArr.length > 0) {
415
+ var currentIndex = (0, _utils.getSheetIndex)(ctx, ctx.currentSheetId);
416
+ var existingCf = ctx.luckysheetfile[currentIndex].luckysheet_conditionformat_save;
417
+ var cdformat = (_a = _lodash.default.cloneDeep(existingCf)) !== null && _a !== void 0 ? _a : [];
418
+ for (var i = 0; i < ruleArr.length; i += 1) {
419
+ var cdformat_cellrange = ruleArr[i].cellrange;
420
+ var emptyRange = [];
421
+ for (var j = 0; j < cdformat_cellrange.length; j += 1) {
422
+ var range = (0, _ConditionFormat.CFSplitRange)(cdformat_cellrange[j], {
423
+ row: [c_r1, c_r2],
424
+ column: [c_c1, c_c2]
425
+ }, {
426
+ row: [minh, maxh],
427
+ column: [minc, maxc]
428
+ }, "operatePart");
429
+ if (range.length > 0) {
430
+ emptyRange = emptyRange.concat(range);
431
+ }
432
+ }
433
+ if (emptyRange.length > 0) {
434
+ ruleArr[i].cellrange = [{
435
+ row: [minh, maxh],
436
+ column: [minc, maxc]
437
+ }];
438
+ cdformat.push(ruleArr[i]);
428
439
  }
429
440
  }
430
- if (emptyRange.length > 0) {
431
- ruleArr[i].cellrange = [{
432
- row: [minh, maxh],
433
- column: [minc, maxc]
434
- }];
435
- cdformat.push(ruleArr[i]);
436
- }
441
+ currFile.luckysheet_conditionformat_save = cdformat;
437
442
  }
438
443
  }
439
444
  }
@@ -66,21 +66,36 @@ function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_st, col
66
66
  } else {
67
67
  value = cell;
68
68
  }
69
+ var type = "n";
70
+ if ((0, _format.is_date)(foucsStatus) || foucsStatus === 14 || foucsStatus === 15 || foucsStatus === 16 || foucsStatus === 17 || foucsStatus === 18 || foucsStatus === 19 || foucsStatus === 20 || foucsStatus === 21 || foucsStatus === 22 || foucsStatus === 45 || foucsStatus === 46 || foucsStatus === 47) {
71
+ type = "d";
72
+ } else if (foucsStatus === "@" || foucsStatus === 49) {
73
+ type = "s";
74
+ }
69
75
  if (_lodash.default.isNil(value)) {
76
+ if (!_lodash.default.isNil(d[r])) {
77
+ if (_lodash.default.isNil(d[r][c])) {
78
+ d[r][c] = {
79
+ ct: {
80
+ fa: foucsStatus,
81
+ t: type
82
+ }
83
+ };
84
+ } else if (_lodash.default.isPlainObject(d[r][c])) {
85
+ if (_lodash.default.isNil(d[r][c].ct)) d[r][c].ct = {};
86
+ d[r][c].ct.fa = foucsStatus;
87
+ d[r][c].ct.t = type;
88
+ }
89
+ }
70
90
  continue;
71
91
  }
72
92
  if (foucsStatus !== "@" && (0, _validation.isRealNum)(value)) {
73
93
  value = Number(value);
74
94
  }
75
- var mask = (0, _format.update)(foucsStatus, value);
76
- var type = "n";
77
- if ((0, _format.is_date)(foucsStatus) || foucsStatus === 14 || foucsStatus === 15 || foucsStatus === 16 || foucsStatus === 17 || foucsStatus === 18 || foucsStatus === 19 || foucsStatus === 20 || foucsStatus === 21 || foucsStatus === 22 || foucsStatus === 45 || foucsStatus === 46 || foucsStatus === 47) {
78
- type = "d";
79
- } else if (foucsStatus === "@" || foucsStatus === 49) {
80
- type = "s";
81
- } else if (foucsStatus === "General" || foucsStatus === 0) {
95
+ if (foucsStatus === "General" || foucsStatus === 0) {
82
96
  type = (0, _validation.isRealNum)(value) ? "n" : "g";
83
97
  }
98
+ var mask = (0, _format.update)(foucsStatus, value);
84
99
  if (cell && _lodash.default.isPlainObject(cell)) {
85
100
  cell.m = "".concat(mask);
86
101
  if (_lodash.default.isNil(cell.ct)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fileverse-dev/fortune-core",
3
- "version": "1.3.1",
3
+ "version": "1.3.2-format-1",
4
4
  "main": "lib/index.js",
5
5
  "module": "es/index.js",
6
6
  "typings": "lib/index.d.ts",