From 1847aba8587cbef17a9cde8318ea065ffb093445 Mon Sep 17 00:00:00 2001 From: lijinke666 Date: Tue, 7 Nov 2023 15:24:20 +0800 Subject: [PATCH] =?UTF-8?q?test:=20=E5=A2=9E=E5=8A=A0=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../__tests__/data/data-multi-line-text.ts | 525 ++++ .../multi-line-text-spec.ts.snap | 2270 +++++++++++++++++ .../spreadsheet/multi-line-text-spec.ts | 215 ++ packages/s2-core/src/cell/corner-cell.ts | 2 +- packages/s2-core/src/cell/data-cell.ts | 5 +- .../s2-core/src/common/constant/options.ts | 1 - .../s2-core/src/sheet-type/spread-sheet.ts | 2 +- packages/s2-core/src/theme/index.ts | 2 +- packages/s2-react/playground/config.ts | 21 +- 9 files changed, 3016 insertions(+), 27 deletions(-) create mode 100644 packages/s2-core/__tests__/data/data-multi-line-text.ts create mode 100644 packages/s2-core/__tests__/spreadsheet/__snapshots__/multi-line-text-spec.ts.snap create mode 100644 packages/s2-core/__tests__/spreadsheet/multi-line-text-spec.ts diff --git a/packages/s2-core/__tests__/data/data-multi-line-text.ts b/packages/s2-core/__tests__/data/data-multi-line-text.ts new file mode 100644 index 0000000000..03c5d92c67 --- /dev/null +++ b/packages/s2-core/__tests__/data/data-multi-line-text.ts @@ -0,0 +1,525 @@ +import type { S2DataConfig } from '../../src'; + +export const MultiLineTextDataCfg: S2DataConfig = { + fields: { + rows: ['province', 'city'], + columns: ['type', 'sub_type'], + values: ['number'], + valueInCols: true, + }, + meta: [ + { + field: 'number', + name: '数量数量数量数量数量数量数量数量数量数量数量', + description: '数量说明。。', + }, + { + field: 'province', + name: '省份', + description: '省份说明。。', + }, + { + field: 'city', + name: '城市城市城市城市城市城市城市城市城市城市城市城市', + description: '城市说明。。', + }, + { + field: 'type', + name: '类别类别类别类别类别类别类别类别类别类别', + description: '类别说明。。', + }, + { + field: 'sub_type', + name: '子类别', + description: '子类别说明。。', + }, + { + field: 'area', + name: '地区', + description: '地区说明。。', + }, + { + field: 'money', + name: '金额', + description: '金额说明。。', + }, + ], + data: [ + { + number: 236723672361111, + province: '浙江省', + city: '绍兴市', + type: '家具', + sub_type: '桌子', + }, + { + number: '7789778977897789778977897789', + province: '浙江省浙江省浙江省浙江省浙江省浙江省浙江省浙江省浙江省浙江省', + city: '杭州市杭州市杭州市杭州市杭州市杭州市杭州市杭州市杭州市杭州市', + type: '家具家具家具家具家具家具家具家具家具家具家具家具家具家具', + sub_type: '桌子桌子桌子桌子桌子桌子桌子桌子桌子桌子桌子桌子桌子桌子桌子', + }, + { + number: 236723672361111, + province: '浙江省', + city: '绍兴市', + type: '家具', + sub_type: '桌子', + }, + { + number: 3877, + province: '浙江省', + city: '宁波市', + type: '家具', + sub_type: '桌子', + }, + { + number: 4342, + province: '浙江省', + city: '舟山市', + type: '家具', + sub_type: '桌子', + }, + { + number: 5343, + province: '浙江省', + city: '杭州市', + type: '家具', + sub_type: '沙发', + }, + { + number: 632, + province: '浙江省', + city: '绍兴市', + type: '家具', + sub_type: '沙发', + }, + { + number: 7234, + province: '浙江省', + city: '宁波市', + type: '家具', + sub_type: '沙发', + }, + { + number: 834, + province: '浙江省', + city: '舟山市', + type: '家具', + sub_type: '沙发', + }, + { + number: 945, + province: '浙江省', + city: '杭州市', + type: '办公用品', + sub_type: '笔', + }, + { + number: 1304, + province: '浙江省', + city: '绍兴市', + type: '办公用品', + sub_type: '笔', + }, + { + number: 1145, + province: '浙江省', + city: '宁波市', + type: '办公用品', + sub_type: '笔', + }, + { + number: 1432, + province: '浙江省', + city: '舟山市', + type: '办公用品', + sub_type: '笔', + }, + { + number: 1343, + province: '浙江省', + city: '杭州市', + type: '办公用品', + sub_type: '纸张', + }, + { + number: 1354, + province: '浙江省', + city: '绍兴市', + type: '办公用品', + sub_type: '纸张', + }, + { + number: 1523, + province: '浙江省', + city: '宁波市', + type: '办公用品', + sub_type: '纸张', + }, + { + number: 1634, + province: '浙江省', + city: '舟山市', + type: '办公用品', + sub_type: '纸张', + }, + { + number: 1723, + province: '四川省', + city: '成都市', + type: '家具', + sub_type: '桌子', + }, + { + number: 1822, + province: '四川省', + city: '绵阳市', + type: '家具', + sub_type: '桌子', + }, + { + number: 1943, + province: '四川省', + city: '南充市', + type: '家具', + sub_type: '桌子', + }, + { + number: 2330, + province: '四川省', + city: '乐山市', + type: '家具', + sub_type: '桌子', + }, + { + number: 2451, + province: '四川省', + city: '成都市', + type: '家具', + sub_type: '沙发', + }, + { + number: 2244, + province: '四川省', + city: '绵阳市', + type: '家具', + sub_type: '沙发', + }, + { + number: 2333, + province: '四川省', + city: '南充市', + type: '家具', + sub_type: '沙发', + }, + { + number: 2445, + province: '四川省', + city: '乐山市', + type: '家具', + sub_type: '沙发', + }, + { + number: 2335, + province: '四川省', + city: '成都市', + type: '办公用品', + sub_type: '笔', + }, + { + number: 245, + province: '四川省', + city: '绵阳市', + type: '办公用品', + sub_type: '笔', + }, + { + number: 2457, + province: '四川省', + city: '南充市', + type: '办公用品', + sub_type: '笔', + }, + { + number: 2458, + province: '四川省', + city: '乐山市', + type: '办公用品', + sub_type: '笔', + }, + { + number: 4004, + province: '四川省', + city: '成都市', + type: '办公用品', + sub_type: '纸张', + }, + { + number: 3077, + province: '四川省', + city: '绵阳市', + type: '办公用品', + sub_type: '纸张', + }, + { + number: 3551, + province: '四川省', + city: '南充市', + type: '办公用品', + sub_type: '纸张', + }, + { + number: 352, + province: '四川省', + city: '乐山市', + type: '办公用品', + sub_type: '纸张', + }, + ], + totalData: [ + { + number: 26193, + type: '家具', + sub_type: '桌子', + }, + { + number: 49709, + type: '家具', + }, + { + number: 23516, + type: '家具', + sub_type: '沙发', + }, + { + number: 29159, + type: '办公用品', + }, + { + number: 12321, + type: '办公用品', + sub_type: '笔', + }, + { + number: 16838, + type: '办公用品', + sub_type: '纸张', + }, + { + number: 18375, + province: '浙江省', + type: '家具', + sub_type: '桌子', + }, + { + number: 14043, + province: '浙江省', + type: '家具', + sub_type: '沙发', + }, + { + number: 4826, + province: '浙江省', + type: '办公用品', + sub_type: '笔', + }, + { + number: 5854, + province: '浙江省', + type: '办公用品', + sub_type: '纸张', + }, + { + number: 7818, + province: '四川省', + type: '家具', + sub_type: '桌子', + }, + { + number: 9473, + province: '四川省', + type: '家具', + sub_type: '沙发', + }, + { + number: 7495, + province: '四川省', + type: '办公用品', + sub_type: '笔', + }, + { + number: 10984, + province: '四川省', + type: '办公用品', + sub_type: '纸张', + }, + { + number: 13132, + province: '浙江省', + city: '杭州市', + type: '家具', + }, + { + number: 2288, + province: '浙江省', + city: '杭州市', + type: '办公用品', + }, + { + number: 15420, + province: '浙江省', + city: '杭州市', + }, + { + number: 2999, + province: '浙江省', + city: '绍兴市', + type: '家具', + }, + { + number: 2658, + province: '浙江省', + city: '绍兴市', + type: '办公用品', + }, + { + number: 5657, + province: '浙江省', + city: '绍兴市', + }, + { + number: 11111, + province: '浙江省', + city: '宁波市', + type: '家具', + }, + { + number: 2668, + province: '浙江省', + city: '宁波市', + type: '办公用品', + }, + { + number: 13779, + province: '浙江省', + city: '宁波市', + }, + { + number: 5176, + province: '浙江省', + city: '舟山市', + type: '家具', + }, + { + number: 3066, + province: '浙江省', + city: '舟山市', + type: '办公用品', + }, + { + number: 8242, + province: '浙江省', + city: '舟山市', + }, + { + number: 4174, + province: '四川省', + city: '成都市', + type: '家具', + }, + { + number: 6339, + province: '四川省', + city: '成都市', + type: '办公用品', + }, + { + number: 10513, + province: '四川省', + city: '成都市', + }, + { + number: 4066, + province: '四川省', + city: '绵阳市', + type: '家具', + }, + { + number: 3322, + province: '四川省', + city: '绵阳市', + type: '办公用品', + }, + { + number: 7388, + province: '四川省', + city: '绵阳市', + }, + { + number: 4276, + province: '四川省', + city: '南充市', + type: '家具', + }, + { + number: 6008, + province: '四川省', + city: '南充市', + type: '办公用品', + }, + { + number: 10284, + province: '四川省', + city: '南充市', + }, + { + number: 4775, + province: '四川省', + city: '乐山市', + type: '家具', + }, + { + number: 2810, + province: '四川省', + city: '乐山市', + type: '办公用品', + }, + { + number: 7585, + province: '四川省', + city: '乐山市', + }, + { + number: 32418, + province: '浙江省', + type: '家具', + }, + { + number: 10680, + province: '浙江省', + type: '办公用品', + }, + { + number: 43098, + province: '浙江省', + }, + { + number: 17291, + province: '四川省', + type: '家具', + }, + { + number: 18479, + province: '四川省', + type: '办公用品', + }, + { + number: 35770, + province: '四川省', + }, + { + number: 78868, + }, + ], +}; diff --git a/packages/s2-core/__tests__/spreadsheet/__snapshots__/multi-line-text-spec.ts.snap b/packages/s2-core/__tests__/spreadsheet/__snapshots__/multi-line-text-spec.ts.snap new file mode 100644 index 0000000000..a1fb6c717b --- /dev/null +++ b/packages/s2-core/__tests__/spreadsheet/__snapshots__/multi-line-text-spec.ts.snap @@ -0,0 +1,2270 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`SpreadSheet Multi Line Text Tests should custom text overflow text 1`] = ` +Array [ + Object { + "actualText": "序号", + "actualTextHeight": 16, + "actualTextWidth": 25, + "height": 40, + "multiLineActualTexts": Array [ + "序号", + ], + "originalText": "序号", + "width": 80, + }, + Object { + "actualText": "省份", + "actualTextHeight": 16, + "actualTextWidth": 25, + "height": 40, + "multiLineActualTexts": Array [ + "省份", + ], + "originalText": "省份", + "width": 96, + }, + Object { + "actualText": "城我是省略号", + "actualTextHeight": 16, + "actualTextWidth": 73, + "height": 40, + "multiLineActualTexts": Array [ + "城我是省略号", + ], + "originalText": "城市城市城市城市城市城市城市城市城市城市城市城市", + "width": 96, + }, + Object { + "actualText": "类别类别类别类别类别类别类别类别类别类别", + "actualTextHeight": 16, + "actualTextWidth": 241, + "height": 40, + "multiLineActualTexts": Array [ + "类别类别类别类别类别类别类别类别类别类别", + ], + "originalText": "类别类别类别类别类别类别类别类别类别类别", + "width": 272, + }, + Object { + "actualText": "子类别", + "actualTextHeight": 16, + "actualTextWidth": 37, + "height": 40, + "multiLineActualTexts": Array [ + "子类别", + ], + "originalText": "子类别", + "width": 272, + }, +] +`; + +exports[`SpreadSheet Multi Line Text Tests should custom text overflow text 2`] = ` +Array [ + Object { + "actualText": "1", + "actualTextHeight": 15, + "actualTextWidth": 7, + "height": 160, + "multiLineActualTexts": Array [ + "1", + ], + "originalText": "1", + "width": 80, + }, + Object { + "actualText": "2", + "actualTextHeight": 15, + "actualTextWidth": 7, + "height": 40, + "multiLineActualTexts": Array [ + "2", + ], + "originalText": "2", + "width": 80, + }, + Object { + "actualText": "3", + "actualTextHeight": 15, + "actualTextWidth": 7, + "height": 160, + "multiLineActualTexts": Array [ + "3", + ], + "originalText": "3", + "width": 80, + }, +] +`; + +exports[`SpreadSheet Multi Line Text Tests should custom text overflow text 3`] = ` +Array [ + Object { + "actualText": "家具", + "actualTextHeight": 16, + "actualTextWidth": 25, + "height": 40, + "multiLineActualTexts": Array [ + "家具", + ], + "originalText": "家具", + "width": 192, + }, + Object { + "actualText": "桌子", + "actualTextHeight": 16, + "actualTextWidth": 25, + "height": 40, + "multiLineActualTexts": Array [ + "桌子", + ], + "originalText": "桌子", + "width": 96, + }, + Object { + "actualText": "数量数量数😸", + "actualTextHeight": 15, + "actualTextWidth": 73, + "height": 40, + "multiLineActualTexts": Array [ + "数量数量数😸", + ], + "originalText": "数量数量数量数量数量数量数量数量数量数量数量", + "width": 96, + }, + Object { + "actualText": "沙发", + "actualTextHeight": 16, + "actualTextWidth": 25, + "height": 40, + "multiLineActualTexts": Array [ + "沙发", + ], + "originalText": "沙发", + "width": 96, + }, + Object { + "actualText": "数量数量数😸", + "actualTextHeight": 15, + "actualTextWidth": 73, + "height": 40, + "multiLineActualTexts": Array [ + "数量数量数😸", + ], + "originalText": "数量数量数量数量数量数量数量数量数量数量数量", + "width": 96, + }, +] +`; + +exports[`SpreadSheet Multi Line Text Tests should custom text overflow text 4`] = ` +Array [ + Object { + "actualText": "浙江省", + "actualTextHeight": 16, + "actualTextWidth": 37, + "height": 160, + "multiLineActualTexts": Array [ + "浙江省", + ], + "originalText": "浙江省", + "width": 96, + }, + Object { + "actualText": "浙我是省略号", + "actualTextHeight": 16, + "actualTextWidth": 73, + "height": 40, + "multiLineActualTexts": Array [ + "浙我是省略号", + ], + "originalText": "浙江省浙江省浙江省浙江省浙江省浙江省浙江省浙江省浙江省浙江省", + "width": 96, + }, + Object { + "actualText": "四川省", + "actualTextHeight": 16, + "actualTextWidth": 37, + "height": 160, + "multiLineActualTexts": Array [ + "四川省", + ], + "originalText": "四川省", + "width": 96, + }, +] +`; + +exports[`SpreadSheet Multi Line Text Tests should custom text overflow text 5`] = ` +Array [ + Object { + "actualText": "236723@@@", + "actualTextHeight": 15, + "actualTextWidth": 77, + "height": 40, + "multiLineActualTexts": Array [ + "236723@@@", + ], + "originalText": "236723672361111", + "width": 96, + }, + Object { + "actualText": "3877", + "actualTextHeight": 15, + "actualTextWidth": 27, + "height": 40, + "multiLineActualTexts": Array [ + "3877", + ], + "originalText": "3877", + "width": 96, + }, + Object { + "actualText": "4342", + "actualTextHeight": 15, + "actualTextWidth": 27, + "height": 40, + "multiLineActualTexts": Array [ + "4342", + ], + "originalText": "4342", + "width": 96, + }, + Object { + "actualText": "-", + "actualTextHeight": 15, + "actualTextWidth": 4, + "height": 40, + "multiLineActualTexts": Array [ + "-", + ], + "originalText": "-", + "width": 96, + }, + Object { + "actualText": "-", + "actualTextHeight": 15, + "actualTextWidth": 4, + "height": 40, + "multiLineActualTexts": Array [ + "-", + ], + "originalText": "-", + "width": 96, + }, + Object { + "actualText": "1723", + "actualTextHeight": 15, + "actualTextWidth": 27, + "height": 40, + "multiLineActualTexts": Array [ + "1723", + ], + "originalText": "1723", + "width": 96, + }, + Object { + "actualText": "1822", + "actualTextHeight": 15, + "actualTextWidth": 27, + "height": 40, + "multiLineActualTexts": Array [ + "1822", + ], + "originalText": "1822", + "width": 96, + }, + Object { + "actualText": "632", + "actualTextHeight": 15, + "actualTextWidth": 21, + "height": 40, + "multiLineActualTexts": Array [ + "632", + ], + "originalText": "632", + "width": 96, + }, + Object { + "actualText": "7234", + "actualTextHeight": 15, + "actualTextWidth": 27, + "height": 40, + "multiLineActualTexts": Array [ + "7234", + ], + "originalText": "7234", + "width": 96, + }, + Object { + "actualText": "834", + "actualTextHeight": 15, + "actualTextWidth": 21, + "height": 40, + "multiLineActualTexts": Array [ + "834", + ], + "originalText": "834", + "width": 96, + }, + Object { + "actualText": "5343", + "actualTextHeight": 15, + "actualTextWidth": 27, + "height": 40, + "multiLineActualTexts": Array [ + "5343", + ], + "originalText": "5343", + "width": 96, + }, + Object { + "actualText": "-", + "actualTextHeight": 15, + "actualTextWidth": 4, + "height": 40, + "multiLineActualTexts": Array [ + "-", + ], + "originalText": "-", + "width": 96, + }, + Object { + "actualText": "2451", + "actualTextHeight": 15, + "actualTextWidth": 27, + "height": 40, + "multiLineActualTexts": Array [ + "2451", + ], + "originalText": "2451", + "width": 96, + }, + Object { + "actualText": "2244", + "actualTextHeight": 15, + "actualTextWidth": 27, + "height": 40, + "multiLineActualTexts": Array [ + "2244", + ], + "originalText": "2244", + "width": 96, + }, +] +`; + +exports[`SpreadSheet Multi Line Text Tests should custom three max text lines 1`] = ` +Array [ + Object { + "actualText": "序号", + "actualTextHeight": 16, + "actualTextWidth": 25, + "height": 53, + "multiLineActualTexts": Array [ + "序号", + ], + "originalText": "序号", + "width": 80, + }, + Object { + "actualText": "省份", + "actualTextHeight": 16, + "actualTextWidth": 25, + "height": 53, + "multiLineActualTexts": Array [ + "省份", + ], + "originalText": "省份", + "width": 96, + }, + Object { + "actualText": "城市城市城市城市城市城市城市城市城...", + "actualTextHeight": 48, + "actualTextWidth": 217, + "height": 53, + "multiLineActualTexts": Array [ + "城市城市城市", + "城市城市城市", + "城市城市城...", + ], + "originalText": "城市城市城市城市城市城市城市城市城市城市城市城市", + "width": 96, + }, + Object { + "actualText": "类别类别类别类别类别类别类别类别类别类别", + "actualTextHeight": 16, + "actualTextWidth": 241, + "height": 56, + "multiLineActualTexts": Array [ + "类别类别类别类别类别类别类别类别类别类别", + ], + "originalText": "类别类别类别类别类别类别类别类别类别类别", + "width": 272, + }, + Object { + "actualText": "子类别", + "actualTextHeight": 16, + "actualTextWidth": 37, + "height": 56, + "multiLineActualTexts": Array [ + "子类别", + ], + "originalText": "子类别", + "width": 272, + }, +] +`; + +exports[`SpreadSheet Multi Line Text Tests should custom three max text lines 2`] = ` +Array [ + Object { + "actualText": "1", + "actualTextHeight": 15, + "actualTextWidth": 7, + "height": 199, + "multiLineActualTexts": Array [ + "1", + ], + "originalText": "1", + "width": 80, + }, + Object { + "actualText": "2", + "actualTextHeight": 15, + "actualTextWidth": 7, + "height": 53, + "multiLineActualTexts": Array [ + "2", + ], + "originalText": "2", + "width": 80, + }, +] +`; + +exports[`SpreadSheet Multi Line Text Tests should custom three max text lines 3`] = ` +Array [ + Object { + "actualText": "家具", + "actualTextHeight": 16, + "actualTextWidth": 25, + "height": 56, + "multiLineActualTexts": Array [ + "家具", + ], + "originalText": "家具", + "width": 192, + }, + Object { + "actualText": "桌子", + "actualTextHeight": 16, + "actualTextWidth": 25, + "height": 56, + "multiLineActualTexts": Array [ + "桌子", + ], + "originalText": "桌子", + "width": 96, + }, + Object { + "actualText": "数量数量数量数量数量数量数量数量数...", + "actualTextHeight": 45, + "actualTextWidth": 217, + "height": 53, + "multiLineActualTexts": Array [ + "数量数量数量", + "数量数量数量", + "数量数量数...", + ], + "originalText": "数量数量数量数量数量数量数量数量数量数量数量", + "width": 96, + }, + Object { + "actualText": "沙发", + "actualTextHeight": 16, + "actualTextWidth": 25, + "height": 56, + "multiLineActualTexts": Array [ + "沙发", + ], + "originalText": "沙发", + "width": 96, + }, + Object { + "actualText": "数量数量数量数量数量数量数量数量数...", + "actualTextHeight": 45, + "actualTextWidth": 217, + "height": 53, + "multiLineActualTexts": Array [ + "数量数量数量", + "数量数量数量", + "数量数量数...", + ], + "originalText": "数量数量数量数量数量数量数量数量数量数量数量", + "width": 96, + }, +] +`; + +exports[`SpreadSheet Multi Line Text Tests should custom three max text lines 4`] = ` +Array [ + Object { + "actualText": "浙江省", + "actualTextHeight": 16, + "actualTextWidth": 37, + "height": 199, + "multiLineActualTexts": Array [ + "浙江省", + ], + "originalText": "浙江省", + "width": 96, + }, + Object { + "actualText": "浙江省浙江省浙江省浙江省浙江省浙江...", + "actualTextHeight": 48, + "actualTextWidth": 217, + "height": 53, + "multiLineActualTexts": Array [ + "浙江省浙江省", + "浙江省浙江省", + "浙江省浙江...", + ], + "originalText": "浙江省浙江省浙江省浙江省浙江省浙江省浙江省浙江省浙江省浙江省", + "width": 96, + }, +] +`; + +exports[`SpreadSheet Multi Line Text Tests should custom three max text lines 5`] = ` +Array [ + Object { + "actualText": "236723672361111", + "actualTextHeight": 30, + "actualTextWidth": 99, + "height": 40, + "multiLineActualTexts": Array [ + "23672367236", + "1111", + ], + "originalText": "236723672361111", + "width": 96, + }, + Object { + "actualText": "3877", + "actualTextHeight": 15, + "actualTextWidth": 27, + "height": 53, + "multiLineActualTexts": Array [ + "3877", + ], + "originalText": "3877", + "width": 96, + }, + Object { + "actualText": "4342", + "actualTextHeight": 15, + "actualTextWidth": 27, + "height": 53, + "multiLineActualTexts": Array [ + "4342", + ], + "originalText": "4342", + "width": 96, + }, + Object { + "actualText": "-", + "actualTextHeight": 15, + "actualTextWidth": 4, + "height": 53, + "multiLineActualTexts": Array [ + "-", + ], + "originalText": "-", + "width": 96, + }, + Object { + "actualText": "-", + "actualTextHeight": 15, + "actualTextWidth": 4, + "height": 53, + "multiLineActualTexts": Array [ + "-", + ], + "originalText": "-", + "width": 96, + }, + Object { + "actualText": "632", + "actualTextHeight": 15, + "actualTextWidth": 21, + "height": 40, + "multiLineActualTexts": Array [ + "632", + ], + "originalText": "632", + "width": 96, + }, + Object { + "actualText": "7234", + "actualTextHeight": 15, + "actualTextWidth": 27, + "height": 53, + "multiLineActualTexts": Array [ + "7234", + ], + "originalText": "7234", + "width": 96, + }, + Object { + "actualText": "834", + "actualTextHeight": 15, + "actualTextWidth": 21, + "height": 53, + "multiLineActualTexts": Array [ + "834", + ], + "originalText": "834", + "width": 96, + }, + Object { + "actualText": "5343", + "actualTextHeight": 15, + "actualTextWidth": 27, + "height": 53, + "multiLineActualTexts": Array [ + "5343", + ], + "originalText": "5343", + "width": 96, + }, + Object { + "actualText": "-", + "actualTextHeight": 15, + "actualTextWidth": 4, + "height": 53, + "multiLineActualTexts": Array [ + "-", + ], + "originalText": "-", + "width": 96, + }, +] +`; + +exports[`SpreadSheet Multi Line Text Tests should custom two max text lines 1`] = ` +Array [ + Object { + "actualText": "序号", + "actualTextHeight": 16, + "actualTextWidth": 25, + "height": 40, + "multiLineActualTexts": Array [ + "序号", + ], + "originalText": "序号", + "width": 80, + }, + Object { + "actualText": "省份", + "actualTextHeight": 16, + "actualTextWidth": 25, + "height": 40, + "multiLineActualTexts": Array [ + "省份", + ], + "originalText": "省份", + "width": 96, + }, + Object { + "actualText": "城市城市城市城市城市城...", + "actualTextHeight": 32, + "actualTextWidth": 144, + "height": 40, + "multiLineActualTexts": Array [ + "城市城市城市", + "城市城市城...", + ], + "originalText": "城市城市城市城市城市城市城市城市城市城市城市城市", + "width": 96, + }, + Object { + "actualText": "类别类别类别类别类别类别类别类别类别类别", + "actualTextHeight": 16, + "actualTextWidth": 241, + "height": 40, + "multiLineActualTexts": Array [ + "类别类别类别类别类别类别类别类别类别类别", + ], + "originalText": "类别类别类别类别类别类别类别类别类别类别", + "width": 272, + }, + Object { + "actualText": "子类别", + "actualTextHeight": 16, + "actualTextWidth": 37, + "height": 40, + "multiLineActualTexts": Array [ + "子类别", + ], + "originalText": "子类别", + "width": 272, + }, +] +`; + +exports[`SpreadSheet Multi Line Text Tests should custom two max text lines 2`] = ` +Array [ + Object { + "actualText": "1", + "actualTextHeight": 15, + "actualTextWidth": 7, + "height": 160, + "multiLineActualTexts": Array [ + "1", + ], + "originalText": "1", + "width": 80, + }, + Object { + "actualText": "2", + "actualTextHeight": 15, + "actualTextWidth": 7, + "height": 40, + "multiLineActualTexts": Array [ + "2", + ], + "originalText": "2", + "width": 80, + }, + Object { + "actualText": "3", + "actualTextHeight": 15, + "actualTextWidth": 7, + "height": 160, + "multiLineActualTexts": Array [ + "3", + ], + "originalText": "3", + "width": 80, + }, +] +`; + +exports[`SpreadSheet Multi Line Text Tests should custom two max text lines 3`] = ` +Array [ + Object { + "actualText": "家具", + "actualTextHeight": 16, + "actualTextWidth": 25, + "height": 40, + "multiLineActualTexts": Array [ + "家具", + ], + "originalText": "家具", + "width": 192, + }, + Object { + "actualText": "桌子", + "actualTextHeight": 16, + "actualTextWidth": 25, + "height": 40, + "multiLineActualTexts": Array [ + "桌子", + ], + "originalText": "桌子", + "width": 96, + }, + Object { + "actualText": "数量数量数量数量数量数...", + "actualTextHeight": 30, + "actualTextWidth": 144, + "height": 40, + "multiLineActualTexts": Array [ + "数量数量数量", + "数量数量数...", + ], + "originalText": "数量数量数量数量数量数量数量数量数量数量数量", + "width": 96, + }, + Object { + "actualText": "沙发", + "actualTextHeight": 16, + "actualTextWidth": 25, + "height": 40, + "multiLineActualTexts": Array [ + "沙发", + ], + "originalText": "沙发", + "width": 96, + }, + Object { + "actualText": "数量数量数量数量数量数...", + "actualTextHeight": 30, + "actualTextWidth": 144, + "height": 40, + "multiLineActualTexts": Array [ + "数量数量数量", + "数量数量数...", + ], + "originalText": "数量数量数量数量数量数量数量数量数量数量数量", + "width": 96, + }, +] +`; + +exports[`SpreadSheet Multi Line Text Tests should custom two max text lines 4`] = ` +Array [ + Object { + "actualText": "浙江省", + "actualTextHeight": 16, + "actualTextWidth": 37, + "height": 160, + "multiLineActualTexts": Array [ + "浙江省", + ], + "originalText": "浙江省", + "width": 96, + }, + Object { + "actualText": "浙江省浙江省浙江省浙江...", + "actualTextHeight": 32, + "actualTextWidth": 144, + "height": 40, + "multiLineActualTexts": Array [ + "浙江省浙江省", + "浙江省浙江...", + ], + "originalText": "浙江省浙江省浙江省浙江省浙江省浙江省浙江省浙江省浙江省浙江省", + "width": 96, + }, + Object { + "actualText": "四川省", + "actualTextHeight": 16, + "actualTextWidth": 37, + "height": 160, + "multiLineActualTexts": Array [ + "四川省", + ], + "originalText": "四川省", + "width": 96, + }, +] +`; + +exports[`SpreadSheet Multi Line Text Tests should custom two max text lines 5`] = ` +Array [ + Object { + "actualText": "236723672361111", + "actualTextHeight": 30, + "actualTextWidth": 99, + "height": 40, + "multiLineActualTexts": Array [ + "23672367236", + "1111", + ], + "originalText": "236723672361111", + "width": 96, + }, + Object { + "actualText": "3877", + "actualTextHeight": 15, + "actualTextWidth": 27, + "height": 40, + "multiLineActualTexts": Array [ + "3877", + ], + "originalText": "3877", + "width": 96, + }, + Object { + "actualText": "4342", + "actualTextHeight": 15, + "actualTextWidth": 27, + "height": 40, + "multiLineActualTexts": Array [ + "4342", + ], + "originalText": "4342", + "width": 96, + }, + Object { + "actualText": "-", + "actualTextHeight": 15, + "actualTextWidth": 4, + "height": 40, + "multiLineActualTexts": Array [ + "-", + ], + "originalText": "-", + "width": 96, + }, + Object { + "actualText": "-", + "actualTextHeight": 15, + "actualTextWidth": 4, + "height": 40, + "multiLineActualTexts": Array [ + "-", + ], + "originalText": "-", + "width": 96, + }, + Object { + "actualText": "1723", + "actualTextHeight": 15, + "actualTextWidth": 27, + "height": 40, + "multiLineActualTexts": Array [ + "1723", + ], + "originalText": "1723", + "width": 96, + }, + Object { + "actualText": "1822", + "actualTextHeight": 15, + "actualTextWidth": 27, + "height": 40, + "multiLineActualTexts": Array [ + "1822", + ], + "originalText": "1822", + "width": 96, + }, + Object { + "actualText": "632", + "actualTextHeight": 15, + "actualTextWidth": 21, + "height": 40, + "multiLineActualTexts": Array [ + "632", + ], + "originalText": "632", + "width": 96, + }, + Object { + "actualText": "7234", + "actualTextHeight": 15, + "actualTextWidth": 27, + "height": 40, + "multiLineActualTexts": Array [ + "7234", + ], + "originalText": "7234", + "width": 96, + }, + Object { + "actualText": "834", + "actualTextHeight": 15, + "actualTextWidth": 21, + "height": 40, + "multiLineActualTexts": Array [ + "834", + ], + "originalText": "834", + "width": 96, + }, + Object { + "actualText": "5343", + "actualTextHeight": 15, + "actualTextWidth": 27, + "height": 40, + "multiLineActualTexts": Array [ + "5343", + ], + "originalText": "5343", + "width": 96, + }, + Object { + "actualText": "-", + "actualTextHeight": 15, + "actualTextWidth": 4, + "height": 40, + "multiLineActualTexts": Array [ + "-", + ], + "originalText": "-", + "width": 96, + }, + Object { + "actualText": "2451", + "actualTextHeight": 15, + "actualTextWidth": 27, + "height": 40, + "multiLineActualTexts": Array [ + "2451", + ], + "originalText": "2451", + "width": 96, + }, + Object { + "actualText": "2244", + "actualTextHeight": 15, + "actualTextWidth": 27, + "height": 40, + "multiLineActualTexts": Array [ + "2244", + ], + "originalText": "2244", + "width": 96, + }, +] +`; + +exports[`SpreadSheet Multi Line Text Tests should default render two line text 1`] = ` +Array [ + Object { + "actualText": "序号", + "actualTextHeight": 16, + "actualTextWidth": 25, + "height": 40, + "multiLineActualTexts": Array [ + "序号", + ], + "originalText": "序号", + "width": 80, + }, + Object { + "actualText": "省份", + "actualTextHeight": 16, + "actualTextWidth": 25, + "height": 40, + "multiLineActualTexts": Array [ + "省份", + ], + "originalText": "省份", + "width": 96, + }, + Object { + "actualText": "城市城市城...", + "actualTextHeight": 16, + "actualTextWidth": 71, + "height": 40, + "multiLineActualTexts": Array [ + "城市城市城...", + ], + "originalText": "城市城市城市城市城市城市城市城市城市城市城市城市", + "width": 96, + }, + Object { + "actualText": "类别类别类别类别类别类别类别类别类别类别", + "actualTextHeight": 16, + "actualTextWidth": 241, + "height": 40, + "multiLineActualTexts": Array [ + "类别类别类别类别类别类别类别类别类别类别", + ], + "originalText": "类别类别类别类别类别类别类别类别类别类别", + "width": 272, + }, + Object { + "actualText": "子类别", + "actualTextHeight": 16, + "actualTextWidth": 37, + "height": 40, + "multiLineActualTexts": Array [ + "子类别", + ], + "originalText": "子类别", + "width": 272, + }, +] +`; + +exports[`SpreadSheet Multi Line Text Tests should default render two line text 2`] = ` +Array [ + Object { + "actualText": "1", + "actualTextHeight": 15, + "actualTextWidth": 7, + "height": 160, + "multiLineActualTexts": Array [ + "1", + ], + "originalText": "1", + "width": 80, + }, + Object { + "actualText": "2", + "actualTextHeight": 15, + "actualTextWidth": 7, + "height": 40, + "multiLineActualTexts": Array [ + "2", + ], + "originalText": "2", + "width": 80, + }, + Object { + "actualText": "3", + "actualTextHeight": 15, + "actualTextWidth": 7, + "height": 160, + "multiLineActualTexts": Array [ + "3", + ], + "originalText": "3", + "width": 80, + }, +] +`; + +exports[`SpreadSheet Multi Line Text Tests should default render two line text 3`] = ` +Array [ + Object { + "actualText": "家具", + "actualTextHeight": 16, + "actualTextWidth": 25, + "height": 40, + "multiLineActualTexts": Array [ + "家具", + ], + "originalText": "家具", + "width": 192, + }, + Object { + "actualText": "桌子", + "actualTextHeight": 16, + "actualTextWidth": 25, + "height": 40, + "multiLineActualTexts": Array [ + "桌子", + ], + "originalText": "桌子", + "width": 96, + }, + Object { + "actualText": "数量数量数...", + "actualTextHeight": 15, + "actualTextWidth": 71, + "height": 40, + "multiLineActualTexts": Array [ + "数量数量数...", + ], + "originalText": "数量数量数量数量数量数量数量数量数量数量数量", + "width": 96, + }, + Object { + "actualText": "沙发", + "actualTextHeight": 16, + "actualTextWidth": 25, + "height": 40, + "multiLineActualTexts": Array [ + "沙发", + ], + "originalText": "沙发", + "width": 96, + }, + Object { + "actualText": "数量数量数...", + "actualTextHeight": 15, + "actualTextWidth": 71, + "height": 40, + "multiLineActualTexts": Array [ + "数量数量数...", + ], + "originalText": "数量数量数量数量数量数量数量数量数量数量数量", + "width": 96, + }, +] +`; + +exports[`SpreadSheet Multi Line Text Tests should default render two line text 4`] = ` +Array [ + Object { + "actualText": "浙江省", + "actualTextHeight": 16, + "actualTextWidth": 37, + "height": 160, + "multiLineActualTexts": Array [ + "浙江省", + ], + "originalText": "浙江省", + "width": 96, + }, + Object { + "actualText": "浙江省浙江...", + "actualTextHeight": 16, + "actualTextWidth": 71, + "height": 40, + "multiLineActualTexts": Array [ + "浙江省浙江...", + ], + "originalText": "浙江省浙江省浙江省浙江省浙江省浙江省浙江省浙江省浙江省浙江省", + "width": 96, + }, + Object { + "actualText": "四川省", + "actualTextHeight": 16, + "actualTextWidth": 37, + "height": 160, + "multiLineActualTexts": Array [ + "四川省", + ], + "originalText": "四川省", + "width": 96, + }, +] +`; + +exports[`SpreadSheet Multi Line Text Tests should default render two line text 5`] = ` +Array [ + Object { + "actualText": "2367236723...", + "actualTextHeight": 15, + "actualTextWidth": 77, + "height": 40, + "multiLineActualTexts": Array [ + "2367236723...", + ], + "originalText": "236723672361111", + "width": 96, + }, + Object { + "actualText": "3877", + "actualTextHeight": 15, + "actualTextWidth": 27, + "height": 40, + "multiLineActualTexts": Array [ + "3877", + ], + "originalText": "3877", + "width": 96, + }, + Object { + "actualText": "4342", + "actualTextHeight": 15, + "actualTextWidth": 27, + "height": 40, + "multiLineActualTexts": Array [ + "4342", + ], + "originalText": "4342", + "width": 96, + }, + Object { + "actualText": "-", + "actualTextHeight": 15, + "actualTextWidth": 4, + "height": 40, + "multiLineActualTexts": Array [ + "-", + ], + "originalText": "-", + "width": 96, + }, + Object { + "actualText": "-", + "actualTextHeight": 15, + "actualTextWidth": 4, + "height": 40, + "multiLineActualTexts": Array [ + "-", + ], + "originalText": "-", + "width": 96, + }, + Object { + "actualText": "1723", + "actualTextHeight": 15, + "actualTextWidth": 27, + "height": 40, + "multiLineActualTexts": Array [ + "1723", + ], + "originalText": "1723", + "width": 96, + }, + Object { + "actualText": "1822", + "actualTextHeight": 15, + "actualTextWidth": 27, + "height": 40, + "multiLineActualTexts": Array [ + "1822", + ], + "originalText": "1822", + "width": 96, + }, + Object { + "actualText": "632", + "actualTextHeight": 15, + "actualTextWidth": 21, + "height": 40, + "multiLineActualTexts": Array [ + "632", + ], + "originalText": "632", + "width": 96, + }, + Object { + "actualText": "7234", + "actualTextHeight": 15, + "actualTextWidth": 27, + "height": 40, + "multiLineActualTexts": Array [ + "7234", + ], + "originalText": "7234", + "width": 96, + }, + Object { + "actualText": "834", + "actualTextHeight": 15, + "actualTextWidth": 21, + "height": 40, + "multiLineActualTexts": Array [ + "834", + ], + "originalText": "834", + "width": 96, + }, + Object { + "actualText": "5343", + "actualTextHeight": 15, + "actualTextWidth": 27, + "height": 40, + "multiLineActualTexts": Array [ + "5343", + ], + "originalText": "5343", + "width": 96, + }, + Object { + "actualText": "-", + "actualTextHeight": 15, + "actualTextWidth": 4, + "height": 40, + "multiLineActualTexts": Array [ + "-", + ], + "originalText": "-", + "width": 96, + }, + Object { + "actualText": "2451", + "actualTextHeight": 15, + "actualTextWidth": 27, + "height": 40, + "multiLineActualTexts": Array [ + "2451", + ], + "originalText": "2451", + "width": 96, + }, + Object { + "actualText": "2244", + "actualTextHeight": 15, + "actualTextWidth": 27, + "height": 40, + "multiLineActualTexts": Array [ + "2244", + ], + "originalText": "2244", + "width": 96, + }, +] +`; + +exports[`SpreadSheet Multi Line Text Tests should force adaptive adjust cell height if custom cell style less than actual text height 1`] = ` +Array [ + Object { + "actualText": "序号", + "actualTextHeight": 16, + "actualTextWidth": 25, + "height": 38, + "multiLineActualTexts": Array [ + "序号", + ], + "originalText": "序号", + "width": 80, + }, + Object { + "actualText": "省份", + "actualTextHeight": 16, + "actualTextWidth": 25, + "height": 38, + "multiLineActualTexts": Array [ + "省份", + ], + "originalText": "省份", + "width": 96, + }, + Object { + "actualText": "城市城市城市城市城市城...", + "actualTextHeight": 32, + "actualTextWidth": 144, + "height": 38, + "multiLineActualTexts": Array [ + "城市城市城市", + "城市城市城...", + ], + "originalText": "城市城市城市城市城市城市城市城市城市城市城市城市", + "width": 96, + }, + Object { + "actualText": "类别类别类别类别类别类别类别类别类别类别", + "actualTextHeight": 16, + "actualTextWidth": 241, + "height": 40, + "multiLineActualTexts": Array [ + "类别类别类别类别类别类别类别类别类别类别", + ], + "originalText": "类别类别类别类别类别类别类别类别类别类别", + "width": 272, + }, + Object { + "actualText": "子类别", + "actualTextHeight": 16, + "actualTextWidth": 37, + "height": 40, + "multiLineActualTexts": Array [ + "子类别", + ], + "originalText": "子类别", + "width": 272, + }, +] +`; + +exports[`SpreadSheet Multi Line Text Tests should force adaptive adjust cell height if custom cell style less than actual text height 2`] = ` +Array [ + Object { + "actualText": "1", + "actualTextHeight": 15, + "actualTextWidth": 7, + "height": 137, + "multiLineActualTexts": Array [ + "1", + ], + "originalText": "1", + "width": 80, + }, + Object { + "actualText": "2", + "actualTextHeight": 15, + "actualTextWidth": 7, + "height": 38, + "multiLineActualTexts": Array [ + "2", + ], + "originalText": "2", + "width": 80, + }, + Object { + "actualText": "3", + "actualTextHeight": 15, + "actualTextWidth": 7, + "height": 152, + "multiLineActualTexts": Array [ + "3", + ], + "originalText": "3", + "width": 80, + }, +] +`; + +exports[`SpreadSheet Multi Line Text Tests should force adaptive adjust cell height if custom cell style less than actual text height 3`] = ` +Array [ + Object { + "actualText": "家具", + "actualTextHeight": 16, + "actualTextWidth": 25, + "height": 40, + "multiLineActualTexts": Array [ + "家具", + ], + "originalText": "家具", + "width": 192, + }, + Object { + "actualText": "桌子", + "actualTextHeight": 16, + "actualTextWidth": 25, + "height": 40, + "multiLineActualTexts": Array [ + "桌子", + ], + "originalText": "桌子", + "width": 96, + }, + Object { + "actualText": "数量数量数量数量数量数...", + "actualTextHeight": 30, + "actualTextWidth": 144, + "height": 38, + "multiLineActualTexts": Array [ + "数量数量数量", + "数量数量数...", + ], + "originalText": "数量数量数量数量数量数量数量数量数量数量数量", + "width": 96, + }, + Object { + "actualText": "沙发", + "actualTextHeight": 16, + "actualTextWidth": 25, + "height": 40, + "multiLineActualTexts": Array [ + "沙发", + ], + "originalText": "沙发", + "width": 96, + }, + Object { + "actualText": "数量数量数量数量数量数...", + "actualTextHeight": 30, + "actualTextWidth": 144, + "height": 38, + "multiLineActualTexts": Array [ + "数量数量数量", + "数量数量数...", + ], + "originalText": "数量数量数量数量数量数量数量数量数量数量数量", + "width": 96, + }, +] +`; + +exports[`SpreadSheet Multi Line Text Tests should force adaptive adjust cell height if custom cell style less than actual text height 4`] = ` +Array [ + Object { + "actualText": "浙江省", + "actualTextHeight": 16, + "actualTextWidth": 37, + "height": 137, + "multiLineActualTexts": Array [ + "浙江省", + ], + "originalText": "浙江省", + "width": 96, + }, + Object { + "actualText": "浙江省浙江省浙江省浙江...", + "actualTextHeight": 32, + "actualTextWidth": 144, + "height": 38, + "multiLineActualTexts": Array [ + "浙江省浙江省", + "浙江省浙江...", + ], + "originalText": "浙江省浙江省浙江省浙江省浙江省浙江省浙江省浙江省浙江省浙江省", + "width": 96, + }, + Object { + "actualText": "四川省", + "actualTextHeight": 16, + "actualTextWidth": 37, + "height": 152, + "multiLineActualTexts": Array [ + "四川省", + ], + "originalText": "四川省", + "width": 96, + }, +] +`; + +exports[`SpreadSheet Multi Line Text Tests should force adaptive adjust cell height if custom cell style less than actual text height 5`] = ` +Array [ + Object { + "actualText": "236723672361111", + "actualTextHeight": 30, + "actualTextWidth": 99, + "height": 23, + "multiLineActualTexts": Array [ + "23672367236", + "1111", + ], + "originalText": "236723672361111", + "width": 96, + }, + Object { + "actualText": "3877", + "actualTextHeight": 15, + "actualTextWidth": 27, + "height": 38, + "multiLineActualTexts": Array [ + "3877", + ], + "originalText": "3877", + "width": 96, + }, + Object { + "actualText": "4342", + "actualTextHeight": 15, + "actualTextWidth": 27, + "height": 38, + "multiLineActualTexts": Array [ + "4342", + ], + "originalText": "4342", + "width": 96, + }, + Object { + "actualText": "-", + "actualTextHeight": 15, + "actualTextWidth": 4, + "height": 38, + "multiLineActualTexts": Array [ + "-", + ], + "originalText": "-", + "width": 96, + }, + Object { + "actualText": "-", + "actualTextHeight": 15, + "actualTextWidth": 4, + "height": 38, + "multiLineActualTexts": Array [ + "-", + ], + "originalText": "-", + "width": 96, + }, + Object { + "actualText": "1723", + "actualTextHeight": 15, + "actualTextWidth": 27, + "height": 38, + "multiLineActualTexts": Array [ + "1723", + ], + "originalText": "1723", + "width": 96, + }, + Object { + "actualText": "1822", + "actualTextHeight": 15, + "actualTextWidth": 27, + "height": 38, + "multiLineActualTexts": Array [ + "1822", + ], + "originalText": "1822", + "width": 96, + }, + Object { + "actualText": "1943", + "actualTextHeight": 15, + "actualTextWidth": 27, + "height": 38, + "multiLineActualTexts": Array [ + "1943", + ], + "originalText": "1943", + "width": 96, + }, + Object { + "actualText": "632", + "actualTextHeight": 15, + "actualTextWidth": 21, + "height": 23, + "multiLineActualTexts": Array [ + "632", + ], + "originalText": "632", + "width": 96, + }, + Object { + "actualText": "7234", + "actualTextHeight": 15, + "actualTextWidth": 27, + "height": 38, + "multiLineActualTexts": Array [ + "7234", + ], + "originalText": "7234", + "width": 96, + }, + Object { + "actualText": "834", + "actualTextHeight": 15, + "actualTextWidth": 21, + "height": 38, + "multiLineActualTexts": Array [ + "834", + ], + "originalText": "834", + "width": 96, + }, + Object { + "actualText": "5343", + "actualTextHeight": 15, + "actualTextWidth": 27, + "height": 38, + "multiLineActualTexts": Array [ + "5343", + ], + "originalText": "5343", + "width": 96, + }, + Object { + "actualText": "-", + "actualTextHeight": 15, + "actualTextWidth": 4, + "height": 38, + "multiLineActualTexts": Array [ + "-", + ], + "originalText": "-", + "width": 96, + }, + Object { + "actualText": "2451", + "actualTextHeight": 15, + "actualTextWidth": 27, + "height": 38, + "multiLineActualTexts": Array [ + "2451", + ], + "originalText": "2451", + "width": 96, + }, + Object { + "actualText": "2244", + "actualTextHeight": 15, + "actualTextWidth": 27, + "height": 38, + "multiLineActualTexts": Array [ + "2244", + ], + "originalText": "2244", + "width": 96, + }, + Object { + "actualText": "2333", + "actualTextHeight": 15, + "actualTextWidth": 27, + "height": 38, + "multiLineActualTexts": Array [ + "2333", + ], + "originalText": "2333", + "width": 96, + }, +] +`; + +exports[`SpreadSheet Multi Line Text Tests should not adaptive adjust cell height if custom cell style more than actual text height 1`] = ` +Array [ + Object { + "actualText": "序号", + "actualTextHeight": 16, + "actualTextWidth": 25, + "height": 70, + "multiLineActualTexts": Array [ + "序号", + ], + "originalText": "序号", + "width": 80, + }, + Object { + "actualText": "省份", + "actualTextHeight": 16, + "actualTextWidth": 25, + "height": 70, + "multiLineActualTexts": Array [ + "省份", + ], + "originalText": "省份", + "width": 96, + }, + Object { + "actualText": "城市城市城市城市城市城...", + "actualTextHeight": 32, + "actualTextWidth": 144, + "height": 70, + "multiLineActualTexts": Array [ + "城市城市城市", + "城市城市城...", + ], + "originalText": "城市城市城市城市城市城市城市城市城市城市城市城市", + "width": 96, + }, + Object { + "actualText": "类别类别类别类别类别类别类别类别类别类别", + "actualTextHeight": 16, + "actualTextWidth": 241, + "height": 70, + "multiLineActualTexts": Array [ + "类别类别类别类别类别类别类别类别类别类别", + ], + "originalText": "类别类别类别类别类别类别类别类别类别类别", + "width": 272, + }, + Object { + "actualText": "子类别", + "actualTextHeight": 16, + "actualTextWidth": 37, + "height": 70, + "multiLineActualTexts": Array [ + "子类别", + ], + "originalText": "子类别", + "width": 272, + }, +] +`; + +exports[`SpreadSheet Multi Line Text Tests should not adaptive adjust cell height if custom cell style more than actual text height 2`] = ` +Array [ + Object { + "actualText": "数量数量数量数量数量数...", + "actualTextHeight": 30, + "actualTextWidth": 144, + "height": 70, + "multiLineActualTexts": Array [ + "数量数量数量", + "数量数量数...", + ], + "originalText": "数量数量数量数量数量数量数量数量数量数量数量", + "width": 96, + }, + Object { + "actualText": "数量数量数量数量数量数...", + "actualTextHeight": 30, + "actualTextWidth": 144, + "height": 70, + "multiLineActualTexts": Array [ + "数量数量数量", + "数量数量数...", + ], + "originalText": "数量数量数量数量数量数量数量数量数量数量数量", + "width": 96, + }, +] +`; + +exports[`SpreadSheet Multi Line Text Tests should not adaptive adjust cell height if custom cell style more than actual text height 3`] = `Array []`; + +exports[`SpreadSheet Multi Line Text Tests should not adaptive adjust cell height if custom cell style more than actual text height 4`] = ` +Array [ + Object { + "actualText": "236723672361111", + "actualTextHeight": 30, + "actualTextWidth": 99, + "height": 70, + "multiLineActualTexts": Array [ + "23672367236", + "1111", + ], + "originalText": "236723672361111", + "width": 96, + }, + Object { + "actualText": "3877", + "actualTextHeight": 15, + "actualTextWidth": 27, + "height": 70, + "multiLineActualTexts": Array [ + "3877", + ], + "originalText": "3877", + "width": 96, + }, + Object { + "actualText": "4342", + "actualTextHeight": 15, + "actualTextWidth": 27, + "height": 70, + "multiLineActualTexts": Array [ + "4342", + ], + "originalText": "4342", + "width": 96, + }, + Object { + "actualText": "632", + "actualTextHeight": 15, + "actualTextWidth": 21, + "height": 70, + "multiLineActualTexts": Array [ + "632", + ], + "originalText": "632", + "width": 96, + }, + Object { + "actualText": "7234", + "actualTextHeight": 15, + "actualTextWidth": 27, + "height": 70, + "multiLineActualTexts": Array [ + "7234", + ], + "originalText": "7234", + "width": 96, + }, + Object { + "actualText": "834", + "actualTextHeight": 15, + "actualTextWidth": 21, + "height": 70, + "multiLineActualTexts": Array [ + "834", + ], + "originalText": "834", + "width": 96, + }, +] +`; + +exports[`SpreadSheet Multi Line Text Tests should not render word wrap text 1`] = ` +Array [ + Object { + "actualText": "序号", + "actualTextHeight": 16, + "actualTextWidth": 25, + "height": 40, + "multiLineActualTexts": Array [ + "序号", + ], + "originalText": "序号", + "width": 80, + }, + Object { + "actualText": "省份", + "actualTextHeight": 16, + "actualTextWidth": 25, + "height": 40, + "multiLineActualTexts": Array [ + "省份", + ], + "originalText": "省份", + "width": 96, + }, + Object { + "actualText": "城市城市城市城市城市城市城市城市城市城市城市城市", + "actualTextHeight": 16, + "actualTextWidth": 289, + "height": 40, + "multiLineActualTexts": Array [ + "城市城市城市城市城市城市城市城市城市城市城市城市", + ], + "originalText": "城市城市城市城市城市城市城市城市城市城市城市城市", + "width": 96, + }, + Object { + "actualText": "类别类别类别类别类别类别类别类别类别类别", + "actualTextHeight": 16, + "actualTextWidth": 241, + "height": 40, + "multiLineActualTexts": Array [ + "类别类别类别类别类别类别类别类别类别类别", + ], + "originalText": "类别类别类别类别类别类别类别类别类别类别", + "width": 272, + }, + Object { + "actualText": "子类别", + "actualTextHeight": 16, + "actualTextWidth": 37, + "height": 40, + "multiLineActualTexts": Array [ + "子类别", + ], + "originalText": "子类别", + "width": 272, + }, +] +`; + +exports[`SpreadSheet Multi Line Text Tests should not render word wrap text 2`] = ` +Array [ + Object { + "actualText": "1", + "actualTextHeight": 15, + "actualTextWidth": 7, + "height": 160, + "multiLineActualTexts": Array [ + "1", + ], + "originalText": "1", + "width": 80, + }, + Object { + "actualText": "2", + "actualTextHeight": 15, + "actualTextWidth": 7, + "height": 40, + "multiLineActualTexts": Array [ + "2", + ], + "originalText": "2", + "width": 80, + }, + Object { + "actualText": "3", + "actualTextHeight": 15, + "actualTextWidth": 7, + "height": 160, + "multiLineActualTexts": Array [ + "3", + ], + "originalText": "3", + "width": 80, + }, +] +`; + +exports[`SpreadSheet Multi Line Text Tests should not render word wrap text 3`] = ` +Array [ + Object { + "actualText": "家具", + "actualTextHeight": 16, + "actualTextWidth": 25, + "height": 40, + "multiLineActualTexts": Array [ + "家具", + ], + "originalText": "家具", + "width": 192, + }, + Object { + "actualText": "桌子", + "actualTextHeight": 16, + "actualTextWidth": 25, + "height": 40, + "multiLineActualTexts": Array [ + "桌子", + ], + "originalText": "桌子", + "width": 96, + }, + Object { + "actualText": "数量数量数量数量数量数量数量数量数量数量数量", + "actualTextHeight": 15, + "actualTextWidth": 265, + "height": 40, + "multiLineActualTexts": Array [ + "数量数量数量数量数量数量数量数量数量数量数量", + ], + "originalText": "数量数量数量数量数量数量数量数量数量数量数量", + "width": 96, + }, + Object { + "actualText": "沙发", + "actualTextHeight": 16, + "actualTextWidth": 25, + "height": 40, + "multiLineActualTexts": Array [ + "沙发", + ], + "originalText": "沙发", + "width": 96, + }, + Object { + "actualText": "数量数量数量数量数量数量数量数量数量数量数量", + "actualTextHeight": 15, + "actualTextWidth": 265, + "height": 40, + "multiLineActualTexts": Array [ + "数量数量数量数量数量数量数量数量数量数量数量", + ], + "originalText": "数量数量数量数量数量数量数量数量数量数量数量", + "width": 96, + }, +] +`; + +exports[`SpreadSheet Multi Line Text Tests should not render word wrap text 4`] = ` +Array [ + Object { + "actualText": "浙江省", + "actualTextHeight": 16, + "actualTextWidth": 37, + "height": 160, + "multiLineActualTexts": Array [ + "浙江省", + ], + "originalText": "浙江省", + "width": 96, + }, + Object { + "actualText": "浙江省浙江省浙江省浙江省浙江省浙江省浙江省浙江省浙江省浙江省", + "actualTextHeight": 16, + "actualTextWidth": 361, + "height": 40, + "multiLineActualTexts": Array [ + "浙江省浙江省浙江省浙江省浙江省浙江省浙江省浙江省浙江省浙江省", + ], + "originalText": "浙江省浙江省浙江省浙江省浙江省浙江省浙江省浙江省浙江省浙江省", + "width": 96, + }, + Object { + "actualText": "四川省", + "actualTextHeight": 16, + "actualTextWidth": 37, + "height": 160, + "multiLineActualTexts": Array [ + "四川省", + ], + "originalText": "四川省", + "width": 96, + }, +] +`; + +exports[`SpreadSheet Multi Line Text Tests should not render word wrap text 5`] = ` +Array [ + Object { + "actualText": "236723672361111", + "actualTextHeight": 15, + "actualTextWidth": 98, + "height": 40, + "multiLineActualTexts": Array [ + "236723672361111", + ], + "originalText": "236723672361111", + "width": 96, + }, + Object { + "actualText": "3877", + "actualTextHeight": 15, + "actualTextWidth": 27, + "height": 40, + "multiLineActualTexts": Array [ + "3877", + ], + "originalText": "3877", + "width": 96, + }, + Object { + "actualText": "4342", + "actualTextHeight": 15, + "actualTextWidth": 27, + "height": 40, + "multiLineActualTexts": Array [ + "4342", + ], + "originalText": "4342", + "width": 96, + }, + Object { + "actualText": "-", + "actualTextHeight": 15, + "actualTextWidth": 4, + "height": 40, + "multiLineActualTexts": Array [ + "-", + ], + "originalText": "-", + "width": 96, + }, + Object { + "actualText": "-", + "actualTextHeight": 15, + "actualTextWidth": 4, + "height": 40, + "multiLineActualTexts": Array [ + "-", + ], + "originalText": "-", + "width": 96, + }, + Object { + "actualText": "1723", + "actualTextHeight": 15, + "actualTextWidth": 27, + "height": 40, + "multiLineActualTexts": Array [ + "1723", + ], + "originalText": "1723", + "width": 96, + }, + Object { + "actualText": "1822", + "actualTextHeight": 15, + "actualTextWidth": 27, + "height": 40, + "multiLineActualTexts": Array [ + "1822", + ], + "originalText": "1822", + "width": 96, + }, + Object { + "actualText": "632", + "actualTextHeight": 15, + "actualTextWidth": 21, + "height": 40, + "multiLineActualTexts": Array [ + "632", + ], + "originalText": "632", + "width": 96, + }, + Object { + "actualText": "7234", + "actualTextHeight": 15, + "actualTextWidth": 27, + "height": 40, + "multiLineActualTexts": Array [ + "7234", + ], + "originalText": "7234", + "width": 96, + }, + Object { + "actualText": "834", + "actualTextHeight": 15, + "actualTextWidth": 21, + "height": 40, + "multiLineActualTexts": Array [ + "834", + ], + "originalText": "834", + "width": 96, + }, + Object { + "actualText": "5343", + "actualTextHeight": 15, + "actualTextWidth": 27, + "height": 40, + "multiLineActualTexts": Array [ + "5343", + ], + "originalText": "5343", + "width": 96, + }, + Object { + "actualText": "-", + "actualTextHeight": 15, + "actualTextWidth": 4, + "height": 40, + "multiLineActualTexts": Array [ + "-", + ], + "originalText": "-", + "width": 96, + }, + Object { + "actualText": "2451", + "actualTextHeight": 15, + "actualTextWidth": 27, + "height": 40, + "multiLineActualTexts": Array [ + "2451", + ], + "originalText": "2451", + "width": 96, + }, + Object { + "actualText": "2244", + "actualTextHeight": 15, + "actualTextWidth": 27, + "height": 40, + "multiLineActualTexts": Array [ + "2244", + ], + "originalText": "2244", + "width": 96, + }, +] +`; diff --git a/packages/s2-core/__tests__/spreadsheet/multi-line-text-spec.ts b/packages/s2-core/__tests__/spreadsheet/multi-line-text-spec.ts new file mode 100644 index 0000000000..abcf234d19 --- /dev/null +++ b/packages/s2-core/__tests__/spreadsheet/multi-line-text-spec.ts @@ -0,0 +1,215 @@ +import { getContainer } from 'tests/util/helpers'; +import { PivotSheet, type SpreadSheet } from '../../src'; +import type { DefaultCellTheme, S2CellType, S2Options } from '../../src/common'; +import { MultiLineTextDataCfg } from '../data/data-multi-line-text'; + +const s2Options: S2Options = { + width: 300, + height: 400, + showSeriesNumber: true, +}; + +describe('SpreadSheet Multi Line Text Tests', () => { + let s2: SpreadSheet; + + const mapCells = (cells: S2CellType[]) => { + return cells.map((cell) => { + const meta = cell.getMeta(); + + return { + actualText: cell.getActualText(), + originalText: cell.getOriginalText(), + actualTextWidth: Math.floor(cell.getMultiLineActualTextWidth()), + actualTextHeight: Math.floor(cell.getMultiLineActualTextHeight()), + multiLineActualTexts: cell.getMultiLineActualTexts(), + width: meta.width, + height: meta.height, + }; + }); + }; + + const updateTheme = (maxLines: number) => { + const cellTheme: DefaultCellTheme = { + text: { + maxLines, + }, + bolderText: { + maxLines, + }, + measureText: { + maxLines, + }, + }; + + s2.setTheme({ + seriesNumberCell: cellTheme, + colCell: cellTheme, + cornerCell: cellTheme, + rowCell: cellTheme, + dataCell: cellTheme, + }); + }; + + const getCells = () => [ + s2.facet.getCornerCells(), + s2.facet.getSeriesNumberCells(), + s2.facet.getColCells(), + s2.facet.getRowCells(), + s2.facet.getDataCells(), + ]; + + beforeEach(async () => { + s2 = new PivotSheet(getContainer(), MultiLineTextDataCfg, s2Options); + await s2.render(); + }); + + afterEach(() => { + s2.destroy(); + }); + + test('should default render two line text', () => { + getCells().forEach((cells) => { + expect(mapCells(cells)).toMatchSnapshot(); + }); + }); + + test('should custom two max text lines', async () => { + updateTheme(2); + await s2.render(false); + + getCells().forEach((cells) => { + expect(mapCells(cells)).toMatchSnapshot(); + }); + }); + + test('should custom three max text lines', async () => { + updateTheme(3); + await s2.render(false); + + getCells().forEach((cells) => { + expect(mapCells(cells)).toMatchSnapshot(); + }); + }); + + test('should custom text overflow text', async () => { + const cellTheme: DefaultCellTheme = { + text: { + textOverflow: '@@@', + maxLines: 1, + }, + bolderText: { + textOverflow: '我是省略号', + maxLines: 1, + }, + measureText: { + textOverflow: '😸', + maxLines: 1, + }, + }; + + s2.setTheme({ + seriesNumberCell: cellTheme, + colCell: cellTheme, + cornerCell: cellTheme, + rowCell: cellTheme, + dataCell: cellTheme, + }); + await s2.render(false); + + getCells().forEach((cells) => { + expect(mapCells(cells)).toMatchSnapshot(); + }); + }); + + test('should not render word wrap text', async () => { + const cellTheme: DefaultCellTheme = { + text: { + wordWrap: false, + }, + bolderText: { + wordWrap: false, + }, + measureText: { + wordWrap: false, + }, + }; + + s2.setTheme({ + seriesNumberCell: cellTheme, + colCell: cellTheme, + cornerCell: cellTheme, + rowCell: cellTheme, + dataCell: cellTheme, + }); + await s2.render(false); + + getCells().forEach((cells) => { + expect(mapCells(cells)).toMatchSnapshot(); + + // wordWrap 关闭时, 不会渲染省略号 + cells.forEach((cell) => { + expect(cell.getActualText()).not.toContain('...'); + }); + }); + }); + + test('should force adaptive adjust cell height if custom cell style less than actual text height', async () => { + s2.setOptions({ + style: { + rowCell: { + height: 20, + heightByField: { + city: 10, + }, + }, + colCell: { + height: 20, + }, + dataCell: { + height: 20, + }, + }, + }); + + updateTheme(2); + await s2.render(false); + + getCells().forEach((cells) => { + expect(mapCells(cells)).toMatchSnapshot(); + }); + }); + + test('should not adaptive adjust cell height if custom cell style more than actual text height', async () => { + const CUSTOM_CELL_HEIGHT = 70; + + s2.setOptions({ + style: { + rowCell: { + height: CUSTOM_CELL_HEIGHT, + }, + colCell: { + height: CUSTOM_CELL_HEIGHT, + }, + dataCell: { + height: CUSTOM_CELL_HEIGHT, + }, + }, + }); + + updateTheme(2); + await s2.render(false); + + [ + s2.facet.getCornerCells(), + s2.facet.getColLeafCells(), + s2.facet.getRowLeafCells(), + s2.facet.getDataCells(), + ].forEach((cells) => { + expect(mapCells(cells)).toMatchSnapshot(); + + cells.forEach((cell) => { + expect(cell.getMeta().height).toEqual(CUSTOM_CELL_HEIGHT); + }); + }); + }); +}); diff --git a/packages/s2-core/src/cell/corner-cell.ts b/packages/s2-core/src/cell/corner-cell.ts index b8eb766416..82865600d9 100644 --- a/packages/s2-core/src/cell/corner-cell.ts +++ b/packages/s2-core/src/cell/corner-cell.ts @@ -269,7 +269,7 @@ export class CornerCell extends HeaderCell { return { ...textStyle, - // 角头因为要折行,所以在都是按照middle来计算,这里写死,不然用户配置了baseline,会导致计算错误 + // 角头因为要折行,所以在都是按照 middle 来计算,这里写死,不然用户配置了 baseline,会导致计算错误 textBaseline: 'middle', }; } diff --git a/packages/s2-core/src/cell/data-cell.ts b/packages/s2-core/src/cell/data-cell.ts index 897bdedc54..31814695d3 100644 --- a/packages/s2-core/src/cell/data-cell.ts +++ b/packages/s2-core/src/cell/data-cell.ts @@ -251,9 +251,8 @@ export class DataCell extends BaseCell { protected getTextStyle(): TextTheme { const { isTotals } = this.meta; - const textStyle = isTotals - ? this.theme.dataCell?.bolderText - : this.theme.dataCell?.text; + const { dataCell } = this.theme; + const textStyle = isTotals ? dataCell?.bolderText : dataCell?.text; return this.getContainConditionMappingResultTextStyle(textStyle); } diff --git a/packages/s2-core/src/common/constant/options.ts b/packages/s2-core/src/common/constant/options.ts index 12729124ca..43eff9a67b 100644 --- a/packages/s2-core/src/common/constant/options.ts +++ b/packages/s2-core/src/common/constant/options.ts @@ -23,7 +23,6 @@ export const DEFAULT_TREE_ROW_CELL_WIDTH = 120; export const DEFAULT_STYLE: S2Style = { layoutWidthType: LayoutWidthTypes.Adaptive, rowCell: { - // width: 120, showTreeLeafNodeAlignDot: false, widthByField: null, heightByField: null, diff --git a/packages/s2-core/src/sheet-type/spread-sheet.ts b/packages/s2-core/src/sheet-type/spread-sheet.ts index 062fefc76e..0be0750269 100644 --- a/packages/s2-core/src/sheet-type/spread-sheet.ts +++ b/packages/s2-core/src/sheet-type/spread-sheet.ts @@ -53,7 +53,6 @@ import type { BaseDataSet } from '../data-set'; import type { BaseFacet } from '../facet'; import type { Node } from '../facet/layout/node'; import { RootInteraction } from '../interaction/root'; -import { getTheme } from '../theme'; import { HdAdapter } from '../ui/hd-adapter'; import { BaseTooltip } from '../ui/tooltip'; import { removeOffscreenCanvas } from '../utils/canvas'; @@ -67,6 +66,7 @@ import { } from '../utils/merge'; import { injectThemeVars } from '../utils/theme'; import { getTooltipData, getTooltipOptions } from '../utils/tooltip'; +import { getTheme } from '../theme'; /** * 关闭 CSS 解析的开关,可以提升首屏性能, diff --git a/packages/s2-core/src/theme/index.ts b/packages/s2-core/src/theme/index.ts index 5ae15f1378..31ded99ace 100644 --- a/packages/s2-core/src/theme/index.ts +++ b/packages/s2-core/src/theme/index.ts @@ -28,7 +28,7 @@ export const getTheme = ( const getHeaderCellTextOverflow = (): TextTheme => ({ wordWrap: true, - maxLines: 2, + maxLines: 1, textOverflow: 'ellipsis', }); diff --git a/packages/s2-react/playground/config.ts b/packages/s2-react/playground/config.ts index 872a06dab4..9919d2706c 100644 --- a/packages/s2-react/playground/config.ts +++ b/packages/s2-react/playground/config.ts @@ -267,26 +267,7 @@ export const s2Options: SheetComponentOptions = { ], }, }, - style: { - // rowCell: { - // width: 100, - // height: 50, - // }, - colCell: { - width(node) { - if (node?.colIndex === 0) { - return 40; - } - - return null; - }, - // height: 60, - hideValue: false, - }, - // dataCell: { - // height: 50, - // }, - }, + style: {}, }; export const sliderOptions: SliderSingleProps = {