@chenchaolong/plugin-trade-compliance-workbench 1.0.127 → 1.0.129
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/lib/import-jobs/import-command.builder.js +1 -1
- package/dist/lib/import-jobs/import-command.builder.js.map +1 -1
- package/dist/lib/remote-components/trade-compliance-workbench/app.css +1 -1
- package/dist/lib/remote-components/trade-compliance-workbench/app.js +4 -4
- package/dist/lib/remote-components/trade-compliance-workbench/editor-source.mjs +18 -4
- package/dist/lib/remote-components/trade-compliance-workbench/editor.js +97 -97
- package/dist/lib/remote-components/trade-compliance-workbench/preview-source.mjs +26 -4
- package/dist/lib/remote-components/trade-compliance-workbench/preview.js +21 -21
- package/dist/lib/remote-ui/components/forms.d.ts +2 -1
- package/dist/lib/remote-ui/components/forms.d.ts.map +1 -1
- package/dist/lib/remote-ui/components/forms.js +3 -3
- package/dist/lib/remote-ui/components/forms.js.map +1 -1
- package/dist/lib/remote-ui/components/source-file-preview.d.ts.map +1 -1
- package/dist/lib/remote-ui/components/source-file-preview.js +32 -4
- package/dist/lib/remote-ui/components/source-file-preview.js.map +1 -1
- package/dist/lib/remote-ui/pages/catalogs.d.ts +1 -0
- package/dist/lib/remote-ui/pages/catalogs.d.ts.map +1 -1
- package/dist/lib/remote-ui/pages/catalogs.js +15 -2
- package/dist/lib/remote-ui/pages/catalogs.js.map +1 -1
- package/dist/lib/remote-ui/pages/procurement.d.ts.map +1 -1
- package/dist/lib/remote-ui/pages/procurement.js +85 -16
- package/dist/lib/remote-ui/pages/procurement.js.map +1 -1
- package/dist/lib/remote-ui/styles.css +23 -6
- package/package.json +1 -1
|
@@ -7,12 +7,17 @@ import '@univerjs/preset-sheets-core/lib/index.css'
|
|
|
7
7
|
import '@univerjs/preset-sheets-drawing/lib/index.css'
|
|
8
8
|
import ExcelJS from 'exceljs'
|
|
9
9
|
|
|
10
|
+
const LIGHTWEIGHT_EDITOR_MAX_ESTIMATED_CELLS = 25000
|
|
11
|
+
const LIGHTWEIGHT_EDITOR_MAX_IMAGE_COUNT = 8
|
|
12
|
+
const LIGHTWEIGHT_EDITOR_MAX_IMAGE_BYTES = 5 * 1024 * 1024
|
|
13
|
+
|
|
10
14
|
window.TradeComplianceExcelEditor = {
|
|
11
15
|
async open({ container, base64, onSave }) {
|
|
12
16
|
const original = new ExcelJS.Workbook()
|
|
13
17
|
await original.xlsx.load(base64ToBytes(base64))
|
|
14
|
-
const
|
|
15
|
-
const
|
|
18
|
+
const lightweightMode = shouldUseLightweightEditor(original)
|
|
19
|
+
const snapshot = toUniverSnapshot(original, { includeStyles: !lightweightMode })
|
|
20
|
+
const workbookImages = lightweightMode ? [] : extractWorkbookImages(original)
|
|
16
21
|
const { univer, univerAPI } = createUniver({
|
|
17
22
|
locale: 'zhCN',
|
|
18
23
|
locales: { zhCN },
|
|
@@ -36,6 +41,14 @@ window.TradeComplianceExcelEditor = {
|
|
|
36
41
|
}
|
|
37
42
|
}
|
|
38
43
|
|
|
44
|
+
function shouldUseLightweightEditor(workbook) {
|
|
45
|
+
const estimatedCells = workbook.worksheets.reduce((total, worksheet) => total + Math.max(worksheet.rowCount, 1) * Math.max(worksheet.columnCount, 1), 0)
|
|
46
|
+
const media = workbook.model.media || []
|
|
47
|
+
const imageCount = workbook.worksheets.reduce((total, worksheet) => total + worksheet.getImages().length, 0)
|
|
48
|
+
const imageBytes = media.reduce((total, item) => total + Number(item?.buffer?.byteLength || item?.buffer?.length || 0), 0)
|
|
49
|
+
return estimatedCells > LIGHTWEIGHT_EDITOR_MAX_ESTIMATED_CELLS || imageCount > LIGHTWEIGHT_EDITOR_MAX_IMAGE_COUNT || imageBytes > LIGHTWEIGHT_EDITOR_MAX_IMAGE_BYTES
|
|
50
|
+
}
|
|
51
|
+
|
|
39
52
|
function extractWorkbookImages(workbook) {
|
|
40
53
|
const media = workbook.model.media || []
|
|
41
54
|
const byIndex = new Map(media.map((item, index) => [item.index ?? index, item]))
|
|
@@ -93,7 +106,8 @@ async function insertWorkbookImages(univerAPI, images) {
|
|
|
93
106
|
}
|
|
94
107
|
}
|
|
95
108
|
|
|
96
|
-
function toUniverSnapshot(workbook) {
|
|
109
|
+
function toUniverSnapshot(workbook, options = {}) {
|
|
110
|
+
const includeStyles = options.includeStyles !== false
|
|
97
111
|
const sheets = {}; const sheetOrder = []
|
|
98
112
|
workbook.worksheets.forEach((worksheet, index) => {
|
|
99
113
|
const id = `sheet-${index + 1}`; sheetOrder.push(id); const cellData = {}
|
|
@@ -101,7 +115,7 @@ function toUniverSnapshot(workbook) {
|
|
|
101
115
|
const rowIndex = rowNumber - 1; const columnIndex = columnNumber - 1
|
|
102
116
|
cellData[rowIndex] ||= {}
|
|
103
117
|
const raw = excelCellDisplayValue(cell.value)
|
|
104
|
-
cellData[rowIndex][columnIndex] = { v: raw instanceof Date ? raw.toISOString().slice(0, 10) : raw == null ? '' : String(raw), t: typeof raw === 'number' ? 2 : 1, s: cellStyle(cell) }
|
|
118
|
+
cellData[rowIndex][columnIndex] = { v: raw instanceof Date ? raw.toISOString().slice(0, 10) : raw == null ? '' : String(raw), t: typeof raw === 'number' ? 2 : 1, s: includeStyles ? cellStyle(cell) : undefined }
|
|
105
119
|
}))
|
|
106
120
|
sheets[id] = { id, name: worksheet.name, rowCount: Math.max(worksheet.rowCount + 20, 100), columnCount: Math.max(worksheet.columnCount + 5, 26), cellData, mergeData: mergeData(worksheet), rowData: rowData(worksheet), columnData: columnData(worksheet) }
|
|
107
121
|
})
|