adtec-core-package 3.2.0 → 3.2.2
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/package.json +1 -1
- package/src/assets/style/index.less +14 -0
- package/src/components/upload/DocxJsViewer.vue +35 -14
- package/src/components/upload/FileView.vue +110 -4
- package/src/components/upload/OfficePreview.vue +14 -1
- package/src/components/upload/PdfJsViewer.vue +1 -1
- package/src/config/VxeTableConfig.ts +10 -4
- package/src/css/vxeTableUI/components/table.scss +14 -2
- package/vite/umoCjsVirtual.ts +24 -2
- package/vite/umoIntegration.js +41 -3
- package/vite/umoIntegration.ts +26 -0
package/package.json
CHANGED
|
@@ -158,6 +158,20 @@ div:focus {
|
|
|
158
158
|
.adtec-scrollbar-active();
|
|
159
159
|
}
|
|
160
160
|
|
|
161
|
+
/* vxe-table 使用独立滚动条手柄,禁止全局 hover 样式作用于表格内部(含固定列) */
|
|
162
|
+
.vxe-table,
|
|
163
|
+
.vxe-table *,
|
|
164
|
+
.vxe-table *:hover {
|
|
165
|
+
.adtec-scrollbar-hidden();
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
.vxe-table:hover {
|
|
169
|
+
.vxe-table--scroll-x-handle,
|
|
170
|
+
.vxe-table--scroll-y-handle {
|
|
171
|
+
.adtec-vxe-scrollbar-active();
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
161
175
|
/* 附件预览:常显滚动条,避免 hover 才出现导致“没有滚动条” */
|
|
162
176
|
.pdf-js-viewer,
|
|
163
177
|
.docx-js-viewer,
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div ref="scrollRef" class="docx-js-viewer">
|
|
3
|
-
<div
|
|
4
|
-
<div v-else-if="loadError" class="docx-error-tip">
|
|
5
|
-
<el-empty :description="loadError" />
|
|
6
|
-
</div>
|
|
7
|
-
<div v-else class="docx-body">
|
|
3
|
+
<div class="docx-body">
|
|
8
4
|
<div ref="styleHostRef" class="docx-style-host" />
|
|
9
5
|
<div class="docx-scale-host" :style="scaleHostStyle">
|
|
10
6
|
<div ref="bodyHostRef" class="docx-render-host" :style="renderStyle" />
|
|
11
7
|
</div>
|
|
12
8
|
</div>
|
|
9
|
+
<div v-if="loading" class="docx-overlay docx-loading">正在解析 Word 文档…</div>
|
|
10
|
+
<div v-else-if="loadError" class="docx-overlay docx-error-tip">
|
|
11
|
+
<el-empty :description="loadError" />
|
|
12
|
+
</div>
|
|
13
13
|
</div>
|
|
14
14
|
</template>
|
|
15
15
|
|
|
@@ -98,16 +98,23 @@ const collectPageSections = () => {
|
|
|
98
98
|
emit('page-change', 1)
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
+
let loadToken = 0
|
|
102
|
+
|
|
101
103
|
const loadDocument = async (src: Blob | ArrayBuffer) => {
|
|
104
|
+
const token = ++loadToken
|
|
102
105
|
loading.value = true
|
|
103
|
-
|
|
106
|
+
loadError.value = ''
|
|
104
107
|
try {
|
|
105
108
|
const buffer = src instanceof Blob ? await src.arrayBuffer() : src
|
|
109
|
+
if (token !== loadToken) return
|
|
110
|
+
|
|
111
|
+
await nextTick()
|
|
106
112
|
const bodyHost = bodyHostRef.value
|
|
107
113
|
const styleHost = styleHostRef.value
|
|
108
114
|
if (!bodyHost || !styleHost) {
|
|
109
115
|
throw new Error('预览容器未就绪')
|
|
110
116
|
}
|
|
117
|
+
resetViewer()
|
|
111
118
|
await renderAsync(buffer, bodyHost, styleHost, {
|
|
112
119
|
className: 'docx',
|
|
113
120
|
inWrapper: true,
|
|
@@ -119,14 +126,18 @@ const loadDocument = async (src: Blob | ArrayBuffer) => {
|
|
|
119
126
|
renderFootnotes: true,
|
|
120
127
|
renderEndnotes: true,
|
|
121
128
|
})
|
|
129
|
+
if (token !== loadToken) return
|
|
122
130
|
await nextTick()
|
|
123
131
|
collectPageSections()
|
|
124
132
|
emit('loaded')
|
|
125
133
|
} catch (err) {
|
|
134
|
+
if (token !== loadToken) return
|
|
126
135
|
loadError.value = 'Word 文档解析失败,请下载后查看'
|
|
127
136
|
emit('error', err)
|
|
128
137
|
} finally {
|
|
129
|
-
|
|
138
|
+
if (token === loadToken) {
|
|
139
|
+
loading.value = false
|
|
140
|
+
}
|
|
130
141
|
}
|
|
131
142
|
}
|
|
132
143
|
|
|
@@ -196,7 +207,11 @@ watch(
|
|
|
196
207
|
() => props.src,
|
|
197
208
|
(src) => {
|
|
198
209
|
if (src) void loadDocument(src)
|
|
199
|
-
else
|
|
210
|
+
else {
|
|
211
|
+
++loadToken
|
|
212
|
+
loading.value = false
|
|
213
|
+
resetViewer()
|
|
214
|
+
}
|
|
200
215
|
},
|
|
201
216
|
{ immediate: true },
|
|
202
217
|
)
|
|
@@ -213,6 +228,7 @@ defineExpose({
|
|
|
213
228
|
|
|
214
229
|
<style scoped lang="scss">
|
|
215
230
|
.docx-js-viewer {
|
|
231
|
+
position: relative;
|
|
216
232
|
flex: 1;
|
|
217
233
|
width: 100%;
|
|
218
234
|
min-height: 0;
|
|
@@ -220,6 +236,16 @@ defineExpose({
|
|
|
220
236
|
background: #e5e7eb;
|
|
221
237
|
}
|
|
222
238
|
|
|
239
|
+
.docx-overlay {
|
|
240
|
+
position: absolute;
|
|
241
|
+
inset: 0;
|
|
242
|
+
z-index: 2;
|
|
243
|
+
display: flex;
|
|
244
|
+
align-items: center;
|
|
245
|
+
justify-content: center;
|
|
246
|
+
background: #e5e7eb;
|
|
247
|
+
}
|
|
248
|
+
|
|
223
249
|
.docx-body {
|
|
224
250
|
min-height: 100%;
|
|
225
251
|
padding: 12px;
|
|
@@ -238,12 +264,7 @@ defineExpose({
|
|
|
238
264
|
background: transparent;
|
|
239
265
|
}
|
|
240
266
|
|
|
241
|
-
.docx-loading
|
|
242
|
-
.docx-error-tip {
|
|
243
|
-
display: flex;
|
|
244
|
-
align-items: center;
|
|
245
|
-
justify-content: center;
|
|
246
|
-
min-height: 240px;
|
|
267
|
+
.docx-loading {
|
|
247
268
|
color: #6b7280;
|
|
248
269
|
font-size: 14px;
|
|
249
270
|
}
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
v-loading="showOverlayLoading"
|
|
9
9
|
element-loading-text="加载中,请稍后。。。"
|
|
10
10
|
class="file-view-overlay"
|
|
11
|
+
:class="{ 'is-preview-fullscreen': isFullscreen }"
|
|
11
12
|
>
|
|
12
13
|
<office-preview-toolbar
|
|
13
14
|
v-if="!isHeaderPreview"
|
|
@@ -15,13 +16,23 @@
|
|
|
15
16
|
:zoom="previewScale"
|
|
16
17
|
:show-zoom="false"
|
|
17
18
|
:show-download="!!url"
|
|
19
|
+
:show-fullscreen="true"
|
|
18
20
|
:show-close="true"
|
|
21
|
+
:fullscreen="isFullscreen"
|
|
19
22
|
:download-loading="loading"
|
|
20
23
|
@download="download"
|
|
21
|
-
@
|
|
24
|
+
@toggle-fullscreen="toggleFullscreen"
|
|
25
|
+
@close="closePreview"
|
|
22
26
|
/>
|
|
23
27
|
|
|
24
|
-
<div
|
|
28
|
+
<div
|
|
29
|
+
ref="previewContainerRef"
|
|
30
|
+
class="office-preview"
|
|
31
|
+
:class="{
|
|
32
|
+
'has-rich-header': isHeaderPreview,
|
|
33
|
+
'fullscreen-mode': isFullscreen,
|
|
34
|
+
}"
|
|
35
|
+
>
|
|
25
36
|
<office-preview
|
|
26
37
|
v-if="url"
|
|
27
38
|
v-model:scale="previewScale"
|
|
@@ -30,19 +41,22 @@
|
|
|
30
41
|
:file-name="title"
|
|
31
42
|
:show-header="isHeaderPreview"
|
|
32
43
|
:show-download="!!url"
|
|
44
|
+
:show-fullscreen="isHeaderPreview"
|
|
33
45
|
:show-close="isHeaderPreview"
|
|
46
|
+
:fullscreen="isFullscreen"
|
|
34
47
|
:download-loading="loading"
|
|
35
48
|
@loaded="loading = false"
|
|
36
49
|
@error="loading = false"
|
|
37
50
|
@download="download"
|
|
38
|
-
@
|
|
51
|
+
@toggle-fullscreen="toggleFullscreen"
|
|
52
|
+
@close="closePreview"
|
|
39
53
|
/>
|
|
40
54
|
</div>
|
|
41
55
|
</div>
|
|
42
56
|
</Teleport>
|
|
43
57
|
</template>
|
|
44
58
|
<script setup lang="ts">
|
|
45
|
-
import { computed, ref, watch } from 'vue'
|
|
59
|
+
import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
|
46
60
|
import { useVModel } from '@vueuse/core'
|
|
47
61
|
import framework from '../../api/framework'
|
|
48
62
|
import frameworkUtils from '../../utils/FrameworkUtils'
|
|
@@ -58,6 +72,8 @@ import {
|
|
|
58
72
|
const model = defineModel()
|
|
59
73
|
const loading = ref(false)
|
|
60
74
|
const previewScale = ref(1)
|
|
75
|
+
const previewContainerRef = ref<HTMLElement | null>(null)
|
|
76
|
+
const isFullscreen = ref(false)
|
|
61
77
|
|
|
62
78
|
const props = defineProps({
|
|
63
79
|
title: {
|
|
@@ -89,6 +105,46 @@ const isHeaderPreview = computed(() =>
|
|
|
89
105
|
/** 富文本预览由 OfficePreview 自带 loading,避免与 v-loading 双层转圈 */
|
|
90
106
|
const showOverlayLoading = computed(() => loading.value && !isHeaderPreview.value)
|
|
91
107
|
|
|
108
|
+
const getContainerEl = () => previewContainerRef.value
|
|
109
|
+
|
|
110
|
+
const syncFullscreenState = () => {
|
|
111
|
+
const el = getContainerEl()
|
|
112
|
+
isFullscreen.value = !!el && document.fullscreenElement === el
|
|
113
|
+
document.body.style.overflow = isFullscreen.value ? 'hidden' : ''
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const exitFullscreen = async () => {
|
|
117
|
+
try {
|
|
118
|
+
if (document.fullscreenElement === getContainerEl()) {
|
|
119
|
+
await document.exitFullscreen()
|
|
120
|
+
}
|
|
121
|
+
} catch {
|
|
122
|
+
// ignore
|
|
123
|
+
}
|
|
124
|
+
isFullscreen.value = false
|
|
125
|
+
document.body.style.overflow = ''
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const toggleFullscreen = async () => {
|
|
129
|
+
const el = getContainerEl()
|
|
130
|
+
if (!el) return
|
|
131
|
+
try {
|
|
132
|
+
if (document.fullscreenElement === el) {
|
|
133
|
+
await document.exitFullscreen()
|
|
134
|
+
} else {
|
|
135
|
+
await el.requestFullscreen()
|
|
136
|
+
}
|
|
137
|
+
} catch {
|
|
138
|
+
isFullscreen.value = !isFullscreen.value
|
|
139
|
+
document.body.style.overflow = isFullscreen.value ? 'hidden' : ''
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const closePreview = async () => {
|
|
144
|
+
await exitFullscreen()
|
|
145
|
+
model.value = false
|
|
146
|
+
}
|
|
147
|
+
|
|
92
148
|
watch(
|
|
93
149
|
[model, url],
|
|
94
150
|
([visible, fileUrl]) => {
|
|
@@ -100,11 +156,21 @@ watch(
|
|
|
100
156
|
} else if (!visible) {
|
|
101
157
|
loading.value = false
|
|
102
158
|
previewScale.value = 1
|
|
159
|
+
void exitFullscreen()
|
|
103
160
|
}
|
|
104
161
|
},
|
|
105
162
|
{ immediate: true },
|
|
106
163
|
)
|
|
107
164
|
|
|
165
|
+
onMounted(() => {
|
|
166
|
+
document.addEventListener('fullscreenchange', syncFullscreenState)
|
|
167
|
+
})
|
|
168
|
+
|
|
169
|
+
onBeforeUnmount(() => {
|
|
170
|
+
document.removeEventListener('fullscreenchange', syncFullscreenState)
|
|
171
|
+
void exitFullscreen()
|
|
172
|
+
})
|
|
173
|
+
|
|
108
174
|
const getFileType = () => resolveOfficeFileExt(undefined, title.value, url.value)
|
|
109
175
|
|
|
110
176
|
const download = async () => {
|
|
@@ -143,6 +209,10 @@ const download = async () => {
|
|
|
143
209
|
display: flex;
|
|
144
210
|
align-items: center;
|
|
145
211
|
justify-content: center;
|
|
212
|
+
|
|
213
|
+
&.is-preview-fullscreen {
|
|
214
|
+
background: transparent;
|
|
215
|
+
}
|
|
146
216
|
}
|
|
147
217
|
|
|
148
218
|
.file-view-toolbar {
|
|
@@ -163,5 +233,41 @@ const download = async () => {
|
|
|
163
233
|
display: flex;
|
|
164
234
|
flex-direction: column;
|
|
165
235
|
}
|
|
236
|
+
|
|
237
|
+
&:fullscreen {
|
|
238
|
+
display: flex;
|
|
239
|
+
flex-direction: column;
|
|
240
|
+
width: 100% !important;
|
|
241
|
+
height: 100% !important;
|
|
242
|
+
border-radius: 0;
|
|
243
|
+
background: #f5f5f5 !important;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
&.fullscreen-mode {
|
|
247
|
+
position: fixed !important;
|
|
248
|
+
inset: 0 !important;
|
|
249
|
+
z-index: 10000;
|
|
250
|
+
display: flex;
|
|
251
|
+
flex-direction: column;
|
|
252
|
+
width: 100vw !important;
|
|
253
|
+
height: 100vh !important;
|
|
254
|
+
border-radius: 0;
|
|
255
|
+
background: #f5f5f5 !important;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
&:fullscreen,
|
|
259
|
+
&.fullscreen-mode {
|
|
260
|
+
:deep(.office-preview-root) {
|
|
261
|
+
flex: 1;
|
|
262
|
+
min-height: 0;
|
|
263
|
+
height: 100%;
|
|
264
|
+
background: #f5f5f5 !important;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
:deep(.office-rich-wrap),
|
|
268
|
+
:deep(.pdf-js-viewer) {
|
|
269
|
+
background: #f5f5f5;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
166
272
|
}
|
|
167
273
|
</style>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div class="office-preview-root" :class="{ 'is-rich-preview': isRichPreview }">
|
|
2
|
+
<div class="office-preview-root" :class="{ 'is-rich-preview': isRichPreview, 'is-fullscreen': fullscreen }">
|
|
3
3
|
<template v-if="isRichPreview">
|
|
4
4
|
<office-preview-header-bar
|
|
5
5
|
v-if="showHeader"
|
|
@@ -386,6 +386,19 @@ defineExpose({
|
|
|
386
386
|
flex-direction: column;
|
|
387
387
|
overflow: hidden;
|
|
388
388
|
}
|
|
389
|
+
|
|
390
|
+
&.is-fullscreen {
|
|
391
|
+
height: 100%;
|
|
392
|
+
background: #f5f5f5 !important;
|
|
393
|
+
|
|
394
|
+
&.is-rich-preview {
|
|
395
|
+
.office-rich-wrap {
|
|
396
|
+
flex: 1;
|
|
397
|
+
min-height: 0;
|
|
398
|
+
background: #f5f5f5;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
}
|
|
389
402
|
}
|
|
390
403
|
|
|
391
404
|
.office-rich-viewer {
|
|
@@ -104,7 +104,7 @@ const showPlaceholder = computed(
|
|
|
104
104
|
const placeholderText = computed(() => {
|
|
105
105
|
if (isPending.value) return '等待预览区域就绪…'
|
|
106
106
|
if (totalPages.value > 0) return '正在渲染页面…'
|
|
107
|
-
return '
|
|
107
|
+
return '正在解析文档…'
|
|
108
108
|
})
|
|
109
109
|
|
|
110
110
|
const setPageRef = (pageNum: number, el: HTMLElement | null) => {
|
|
@@ -7,11 +7,9 @@ import {
|
|
|
7
7
|
import VxeUIPluginRenderElement from '@vxe-ui/plugin-render-element'
|
|
8
8
|
import '@vxe-ui/plugin-render-element/dist/style.css'
|
|
9
9
|
import VxeUIPluginExportXLSX from '@vxe-ui/plugin-export-xlsx'
|
|
10
|
-
import ExcelJS from 'exceljs'
|
|
11
10
|
import 'vxe-pc-ui/lib/style.css'
|
|
12
11
|
import '../css/vxeTableUI/all.scss'
|
|
13
12
|
import VxeUIPluginExportPDF from '@vxe-ui/plugin-export-pdf'
|
|
14
|
-
import { jsPDF } from 'jspdf'
|
|
15
13
|
// 导入默认的语言
|
|
16
14
|
import zhCN from 'vxe-table/lib/locale/lang/zh-CN'
|
|
17
15
|
|
|
@@ -29,8 +27,16 @@ export function initVxeTableInPage(
|
|
|
29
27
|
VxeUI.component(VxeTooltip)
|
|
30
28
|
// 局部注册插件
|
|
31
29
|
enableElementPlus && VxeUI.use(VxeUIPluginRenderElement)
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
if (enableExcel) {
|
|
31
|
+
void import('exceljs').then(({ default: ExcelJS }) => {
|
|
32
|
+
VxeUI.use(VxeUIPluginExportXLSX, { ExcelJS })
|
|
33
|
+
})
|
|
34
|
+
}
|
|
35
|
+
if (enablePdf) {
|
|
36
|
+
void import('jspdf').then(({ jsPDF }) => {
|
|
37
|
+
VxeUI.use(VxeUIPluginExportPDF, { jsPDF })
|
|
38
|
+
})
|
|
39
|
+
}
|
|
34
40
|
|
|
35
41
|
// 设置表格配置(可复制你在 VxeTableConfig.ts 中的配置)
|
|
36
42
|
VxeUI.setConfig({
|
|
@@ -51,11 +51,20 @@
|
|
|
51
51
|
.vxe-table--body-wrapper,
|
|
52
52
|
.vxe-table--footer-wrapper,
|
|
53
53
|
.vxe-table--fixed-left-body-wrapper,
|
|
54
|
-
.vxe-table--fixed-right-body-wrapper
|
|
54
|
+
.vxe-table--fixed-right-body-wrapper,
|
|
55
|
+
.vxe-table--fixed-left-wrapper,
|
|
56
|
+
.vxe-table--fixed-right-wrapper {
|
|
55
57
|
overflow: hidden;
|
|
56
58
|
outline: 0;
|
|
57
59
|
scrollbar-width: none;
|
|
60
|
+
-ms-overflow-style: none;
|
|
58
61
|
-webkit-overflow-scrolling: touch;
|
|
62
|
+
|
|
63
|
+
&::-webkit-scrollbar {
|
|
64
|
+
display: none;
|
|
65
|
+
width: 0;
|
|
66
|
+
height: 0;
|
|
67
|
+
}
|
|
59
68
|
}
|
|
60
69
|
.vxe-table--header-inner-wrapper,
|
|
61
70
|
.vxe-table--body-inner-wrapper,
|
|
@@ -66,8 +75,11 @@
|
|
|
66
75
|
scrollbar-width: none;
|
|
67
76
|
-ms-overflow-style: none;
|
|
68
77
|
-webkit-overflow-scrolling: touch;
|
|
78
|
+
|
|
69
79
|
&::-webkit-scrollbar {
|
|
70
80
|
display: none;
|
|
81
|
+
width: 0;
|
|
82
|
+
height: 0;
|
|
71
83
|
}
|
|
72
84
|
}
|
|
73
85
|
.vxe-table--header-inner-wrapper,
|
|
@@ -80,7 +92,7 @@
|
|
|
80
92
|
overflow-x: scroll;
|
|
81
93
|
}
|
|
82
94
|
|
|
83
|
-
/* vxe 表格:hover
|
|
95
|
+
/* vxe 表格:hover 时仅在手柄上显示现代圆角滚动条(全局 index.less 已排除表格内部) */
|
|
84
96
|
.vxe-table--scroll-x-handle,
|
|
85
97
|
.vxe-table--scroll-y-handle {
|
|
86
98
|
@include classic.adtec-scrollbar-hidden;
|
package/vite/umoCjsVirtual.ts
CHANGED
|
@@ -6,6 +6,12 @@ import { transformWithEsbuild } from 'vite'
|
|
|
6
6
|
import type { Plugin } from 'vite'
|
|
7
7
|
import { getProjectRoot } from './projectRoot'
|
|
8
8
|
|
|
9
|
+
const UMO_CJS_ENTRY_OVERRIDES: Record<string, string> = {
|
|
10
|
+
/** browser 字段会落到 min.js(无 ESM default);用完整 UMD 构建再转 ESM */
|
|
11
|
+
jszip: 'dist/jszip.js',
|
|
12
|
+
exceljs: 'dist/exceljs.js',
|
|
13
|
+
}
|
|
14
|
+
|
|
9
15
|
const UMO_CJS_SPECS = [
|
|
10
16
|
'dom-to-image-more',
|
|
11
17
|
'hotkeys-js',
|
|
@@ -15,6 +21,8 @@ const UMO_CJS_SPECS = [
|
|
|
15
21
|
'smooth-signature',
|
|
16
22
|
'pure-svg-code',
|
|
17
23
|
'nzh/cn',
|
|
24
|
+
'jszip',
|
|
25
|
+
'exceljs',
|
|
18
26
|
] as const
|
|
19
27
|
|
|
20
28
|
const UMO_CJS_NAMED_EXPORTS: Record<string, string[]> = {
|
|
@@ -37,8 +45,15 @@ function resolvePackageMain(pkgDir: string): string | null {
|
|
|
37
45
|
module?: string
|
|
38
46
|
}
|
|
39
47
|
const main = pkgJson.module || pkgJson.main || 'index.js'
|
|
40
|
-
const
|
|
41
|
-
|
|
48
|
+
const candidates = [
|
|
49
|
+
path.join(pkgDir, main),
|
|
50
|
+
path.join(pkgDir, `${main}.js`),
|
|
51
|
+
path.join(pkgDir, main, 'index.js'),
|
|
52
|
+
]
|
|
53
|
+
for (const entry of candidates) {
|
|
54
|
+
if (fs.existsSync(entry) && fs.statSync(entry).isFile()) return entry
|
|
55
|
+
}
|
|
56
|
+
return null
|
|
42
57
|
}
|
|
43
58
|
|
|
44
59
|
function findUmoPackageDir(pkgName: string): string | null {
|
|
@@ -63,6 +78,13 @@ function findUmoPackageEntryForSpec(spec: string): string | null {
|
|
|
63
78
|
if (!pkgDir) return null
|
|
64
79
|
|
|
65
80
|
if (subParts.length === 0) {
|
|
81
|
+
const override = UMO_CJS_ENTRY_OVERRIDES[pkgName]
|
|
82
|
+
if (override) {
|
|
83
|
+
const overridePath = path.join(pkgDir, override)
|
|
84
|
+
if (fs.existsSync(overridePath) && fs.statSync(overridePath).isFile()) {
|
|
85
|
+
return overridePath
|
|
86
|
+
}
|
|
87
|
+
}
|
|
66
88
|
return resolvePackageMain(pkgDir)
|
|
67
89
|
}
|
|
68
90
|
|
package/vite/umoIntegration.js
CHANGED
|
@@ -433,6 +433,11 @@ import path4 from "node:path";
|
|
|
433
433
|
import { createRequire as createRequire4 } from "node:module";
|
|
434
434
|
import { pathToFileURL } from "node:url";
|
|
435
435
|
import { transformWithEsbuild as transformWithEsbuild2 } from "vite";
|
|
436
|
+
var UMO_CJS_ENTRY_OVERRIDES = {
|
|
437
|
+
/** browser 字段会落到 min.js(无 ESM default);用完整 UMD 构建再转 ESM */
|
|
438
|
+
jszip: "dist/jszip.js",
|
|
439
|
+
exceljs: "dist/exceljs.js"
|
|
440
|
+
};
|
|
436
441
|
var UMO_CJS_SPECS = [
|
|
437
442
|
"dom-to-image-more",
|
|
438
443
|
"hotkeys-js",
|
|
@@ -441,7 +446,9 @@ var UMO_CJS_SPECS = [
|
|
|
441
446
|
"pretty-bytes",
|
|
442
447
|
"smooth-signature",
|
|
443
448
|
"pure-svg-code",
|
|
444
|
-
"nzh/cn"
|
|
449
|
+
"nzh/cn",
|
|
450
|
+
"jszip",
|
|
451
|
+
"exceljs"
|
|
445
452
|
];
|
|
446
453
|
var UMO_CJS_NAMED_EXPORTS = {
|
|
447
454
|
"file-saver": ["saveAs"],
|
|
@@ -456,8 +463,15 @@ function resolvePackageMain(pkgDir) {
|
|
|
456
463
|
if (!fs5.existsSync(pkgJsonPath)) return null;
|
|
457
464
|
const pkgJson = JSON.parse(fs5.readFileSync(pkgJsonPath, "utf-8"));
|
|
458
465
|
const main = pkgJson.module || pkgJson.main || "index.js";
|
|
459
|
-
const
|
|
460
|
-
|
|
466
|
+
const candidates = [
|
|
467
|
+
path4.join(pkgDir, main),
|
|
468
|
+
path4.join(pkgDir, `${main}.js`),
|
|
469
|
+
path4.join(pkgDir, main, "index.js")
|
|
470
|
+
];
|
|
471
|
+
for (const entry of candidates) {
|
|
472
|
+
if (fs5.existsSync(entry) && fs5.statSync(entry).isFile()) return entry;
|
|
473
|
+
}
|
|
474
|
+
return null;
|
|
461
475
|
}
|
|
462
476
|
function findUmoPackageDir(pkgName) {
|
|
463
477
|
const projectRoot2 = getProjectRoot();
|
|
@@ -476,6 +490,13 @@ function findUmoPackageEntryForSpec(spec) {
|
|
|
476
490
|
const pkgDir = findUmoPackageDir(pkgName);
|
|
477
491
|
if (!pkgDir) return null;
|
|
478
492
|
if (subParts.length === 0) {
|
|
493
|
+
const override = UMO_CJS_ENTRY_OVERRIDES[pkgName];
|
|
494
|
+
if (override) {
|
|
495
|
+
const overridePath = path4.join(pkgDir, override);
|
|
496
|
+
if (fs5.existsSync(overridePath) && fs5.statSync(overridePath).isFile()) {
|
|
497
|
+
return overridePath;
|
|
498
|
+
}
|
|
499
|
+
}
|
|
479
500
|
return resolvePackageMain(pkgDir);
|
|
480
501
|
}
|
|
481
502
|
const sub = subParts.join("/");
|
|
@@ -620,12 +641,28 @@ function yjsPeerResolve() {
|
|
|
620
641
|
}
|
|
621
642
|
|
|
622
643
|
// vite/umoIntegration.ts
|
|
644
|
+
function docxPreviewViteFix() {
|
|
645
|
+
return {
|
|
646
|
+
name: "core-docx-preview-vite",
|
|
647
|
+
config() {
|
|
648
|
+
return {
|
|
649
|
+
optimizeDeps: {
|
|
650
|
+
exclude: ["docx-preview", "jszip", "exceljs"]
|
|
651
|
+
}
|
|
652
|
+
};
|
|
653
|
+
}
|
|
654
|
+
};
|
|
655
|
+
}
|
|
656
|
+
function coreOfficePreviewVitePlugins() {
|
|
657
|
+
return [createProjectRootPlugin(), umoCjsVirtual(), docxPreviewViteFix()];
|
|
658
|
+
}
|
|
623
659
|
function coreUmoVitePlugins() {
|
|
624
660
|
return [
|
|
625
661
|
createProjectRootPlugin(),
|
|
626
662
|
tiptapVueRendererFix(),
|
|
627
663
|
highlightJsLibVirtual(),
|
|
628
664
|
umoCjsVirtual(),
|
|
665
|
+
docxPreviewViteFix(),
|
|
629
666
|
tiptapUmoResolve(),
|
|
630
667
|
yjsPeerResolve()
|
|
631
668
|
];
|
|
@@ -653,6 +690,7 @@ function coreUmoManualChunk(id) {
|
|
|
653
690
|
return void 0;
|
|
654
691
|
}
|
|
655
692
|
export {
|
|
693
|
+
coreOfficePreviewVitePlugins,
|
|
656
694
|
coreUmoManualChunk,
|
|
657
695
|
coreUmoResolveConfig,
|
|
658
696
|
coreUmoVitePlugins,
|
package/vite/umoIntegration.ts
CHANGED
|
@@ -6,6 +6,31 @@ import { tiptapVueRendererFix } from './tiptapVueRendererFix'
|
|
|
6
6
|
import { umoCjsVirtual } from './umoCjsVirtual'
|
|
7
7
|
import { buildYjsPeerAliases, yjsPeerResolve } from './yjsPeerResolve'
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* docx-preview / exceljs 等 CJS 包在 Vite 浏览器解析会落到 *.min.js(无 default 导出)。
|
|
11
|
+
* 排除预构建,让 umoCjsVirtual 在 resolve 阶段接管。
|
|
12
|
+
*/
|
|
13
|
+
function docxPreviewViteFix(): Plugin {
|
|
14
|
+
return {
|
|
15
|
+
name: 'core-docx-preview-vite',
|
|
16
|
+
config() {
|
|
17
|
+
return {
|
|
18
|
+
optimizeDeps: {
|
|
19
|
+
exclude: ['docx-preview', 'jszip', 'exceljs'],
|
|
20
|
+
},
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* 核心包 CJS 兼容(附件预览 docx-preview/jszip、表格导出 exceljs 等)在宿主 Vite 中的插件。
|
|
28
|
+
* 前端系统框架等未接入完整 Umo 插件链的宿主也应引入。
|
|
29
|
+
*/
|
|
30
|
+
export function coreOfficePreviewVitePlugins(): Plugin[] {
|
|
31
|
+
return [createProjectRootPlugin(), umoCjsVirtual(), docxPreviewViteFix()]
|
|
32
|
+
}
|
|
33
|
+
|
|
9
34
|
/**
|
|
10
35
|
* Umo 富文本(editor-main 源码)在宿主 Vite 中所需的全部构建插件。
|
|
11
36
|
* 必须放在 vue() 之前,且需配合 coreUmoResolveConfig()。
|
|
@@ -16,6 +41,7 @@ export function coreUmoVitePlugins(): Plugin[] {
|
|
|
16
41
|
tiptapVueRendererFix(),
|
|
17
42
|
highlightJsLibVirtual(),
|
|
18
43
|
umoCjsVirtual(),
|
|
44
|
+
docxPreviewViteFix(),
|
|
19
45
|
tiptapUmoResolve(),
|
|
20
46
|
yjsPeerResolve(),
|
|
21
47
|
]
|