@chenchaolong/plugin-trade-compliance-workbench 1.0.133 → 1.0.135

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.
Files changed (32) hide show
  1. package/dist/lib/remote-components/trade-compliance-workbench/app.js +7 -7
  2. package/dist/lib/remote-components/trade-compliance-workbench/editor-source.mjs +14 -3
  3. package/dist/lib/remote-components/trade-compliance-workbench/editor.js +19 -19
  4. package/dist/lib/remote-components/trade-compliance-workbench/preview-source.mjs +42 -13
  5. package/dist/lib/remote-components/trade-compliance-workbench/preview.js +168 -168
  6. package/dist/lib/remote-ui/app-source.d.ts.map +1 -1
  7. package/dist/lib/remote-ui/app-source.js +39 -45
  8. package/dist/lib/remote-ui/app-source.js.map +1 -1
  9. package/dist/lib/remote-ui/components/source-file-preview.d.ts +18 -3
  10. package/dist/lib/remote-ui/components/source-file-preview.d.ts.map +1 -1
  11. package/dist/lib/remote-ui/components/source-file-preview.js +34 -17
  12. package/dist/lib/remote-ui/components/source-file-preview.js.map +1 -1
  13. package/dist/lib/remote-ui/customer-contract-contracts.d.ts +8 -0
  14. package/dist/lib/remote-ui/customer-contract-contracts.d.ts.map +1 -1
  15. package/dist/lib/remote-ui/isolated-runtime.d.ts +36 -0
  16. package/dist/lib/remote-ui/isolated-runtime.d.ts.map +1 -0
  17. package/dist/lib/remote-ui/isolated-runtime.js +158 -0
  18. package/dist/lib/remote-ui/isolated-runtime.js.map +1 -0
  19. package/dist/lib/remote-ui/model.d.ts +1 -0
  20. package/dist/lib/remote-ui/model.d.ts.map +1 -1
  21. package/dist/lib/remote-ui/model.js +17 -0
  22. package/dist/lib/remote-ui/model.js.map +1 -1
  23. package/dist/lib/remote-ui/pages/procurement.d.ts.map +1 -1
  24. package/dist/lib/remote-ui/pages/procurement.js +5 -3
  25. package/dist/lib/remote-ui/pages/procurement.js.map +1 -1
  26. package/dist/lib/remote-ui/procurement-contracts.d.ts +8 -0
  27. package/dist/lib/remote-ui/procurement-contracts.d.ts.map +1 -1
  28. package/dist/lib/workbench-view.provider.d.ts +27 -7
  29. package/dist/lib/workbench-view.provider.d.ts.map +1 -1
  30. package/dist/lib/workbench-view.provider.js +20 -1
  31. package/dist/lib/workbench-view.provider.js.map +1 -1
  32. package/package.json +1 -1
@@ -10,11 +10,14 @@ import ExcelJS from 'exceljs'
10
10
  const LIGHTWEIGHT_EDITOR_MAX_ESTIMATED_CELLS = 25000
11
11
  const LIGHTWEIGHT_EDITOR_MAX_IMAGE_COUNT = 8
12
12
  const LIGHTWEIGHT_EDITOR_MAX_IMAGE_BYTES = 5 * 1024 * 1024
13
+ const MAX_EDITOR_FILE_BYTES = 20 * 1024 * 1024
13
14
 
14
15
  window.TradeComplianceExcelEditor = {
15
16
  async open({ container, base64, onSave }) {
16
- const original = new ExcelJS.Workbook()
17
- await original.xlsx.load(base64ToBytes(base64))
17
+ const sourceBytes = base64ToBytes(base64)
18
+ if (sourceBytes.byteLength > MAX_EDITOR_FILE_BYTES) throw new Error('工作簿超过在线编辑限制(20 MB),请下载原文件修改')
19
+ let original = new ExcelJS.Workbook()
20
+ await original.xlsx.load(sourceBytes)
18
21
  const lightweightMode = shouldUseLightweightEditor(original)
19
22
  const snapshot = toUniverSnapshot(original, { includeStyles: !lightweightMode })
20
23
  const workbookImages = lightweightMode ? [] : extractWorkbookImages(original)
@@ -28,15 +31,23 @@ window.TradeComplianceExcelEditor = {
28
31
  })
29
32
  univerAPI.createWorkbook(snapshot)
30
33
  await insertWorkbookImages(univerAPI, workbookImages)
34
+ let disposed = false
31
35
  return {
32
36
  async save() {
37
+ if (disposed || !original) throw new Error('工作簿编辑器已关闭')
33
38
  const workbook = univerAPI.getActiveWorkbook()
34
39
  if (!workbook) throw new Error('工作簿未加载')
35
40
  applyUniverSnapshot(original, workbook.save())
36
41
  const buffer = await original.xlsx.writeBuffer()
37
42
  await onSave(bytesToBase64(new Uint8Array(buffer)))
38
43
  },
39
- dispose() { univer.dispose() }
44
+ dispose() {
45
+ if (disposed) return
46
+ disposed = true
47
+ univer.dispose()
48
+ original = null
49
+ container.replaceChildren()
50
+ }
40
51
  }
41
52
  }
42
53
  }