frame-editor-preview 1.0.0
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/README.md +118 -0
- package/dist/index.cjs +154 -0
- package/dist/index.css +1 -0
- package/dist/index.d.ts +153 -0
- package/dist/index.mjs +50900 -0
- package/package.json +49 -0
package/README.md
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
* @Author: Huangjs
|
|
3
|
+
* @Date: 2021-05-10 15:55:29
|
|
4
|
+
* @LastEditors: Huangjs huangjinsong@easyway.net.cn
|
|
5
|
+
* @LastEditTime: 2025-09-18 10:50:57
|
|
6
|
+
* @Description: ******
|
|
7
|
+
-->
|
|
8
|
+
|
|
9
|
+
# @easyway/frame-editor
|
|
10
|
+
|
|
11
|
+
## 安装方式
|
|
12
|
+
|
|
13
|
+
npm install @easyway/frame-editor
|
|
14
|
+
|
|
15
|
+
yarn add @easyway/frame-editor
|
|
16
|
+
|
|
17
|
+
pnpm add @easyway/frame-editor
|
|
18
|
+
|
|
19
|
+
## 使用方法
|
|
20
|
+
|
|
21
|
+
### 全局使用:在 main.ts 引入
|
|
22
|
+
|
|
23
|
+
```javascript
|
|
24
|
+
import { FrameEditor, FramePreview } from '@easyway/frame-editor';
|
|
25
|
+
const app = createApp(App);
|
|
26
|
+
app.use(FrameEditor);
|
|
27
|
+
// app.use(FramePreview);
|
|
28
|
+
// 或者
|
|
29
|
+
// app.component('FrameEditor', FrameEditor);
|
|
30
|
+
// app.component('FramePreview', FramePreview);
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### 局部使用:在 App.vue 引入
|
|
34
|
+
|
|
35
|
+
```html
|
|
36
|
+
<script setup lang="ts">
|
|
37
|
+
import { FrameEditor, FramePreview } from '@easyway/frame-editor';
|
|
38
|
+
</script>
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### 在 template 中使用
|
|
42
|
+
|
|
43
|
+
```html
|
|
44
|
+
<frame-editor></frame-editor> <frame-preview></frame-preview>
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## 帧编辑参数说明
|
|
48
|
+
|
|
49
|
+
| 参数 | 说明 | 类型 |
|
|
50
|
+
| ---- | ---- | ---- |
|
|
51
|
+
| | | |
|
|
52
|
+
|
|
53
|
+
## 帧编辑示例
|
|
54
|
+
|
|
55
|
+
```html
|
|
56
|
+
<template>
|
|
57
|
+
<main>
|
|
58
|
+
<frame-editor></frame-editor>
|
|
59
|
+
</main>
|
|
60
|
+
</template>
|
|
61
|
+
|
|
62
|
+
<script setup lang="ts"></script>
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## 帧预览参数说明
|
|
66
|
+
|
|
67
|
+
| 参数 | 说明 | 类型 |
|
|
68
|
+
| ------------ | ------------------------------------------------------------------------------------------------- | ----------------------------------------------------------- |
|
|
69
|
+
| style | props: 行内样式 | CSSProperties 非必传 |
|
|
70
|
+
| className | props: 内部元素 class | string 非必传 |
|
|
71
|
+
| bgcolor | props: 预览整体背景色 | string 非必传 |
|
|
72
|
+
| xmlString | props: 预览的 xml 字符串 | string 非必传 |
|
|
73
|
+
| useLiveData | props: 预览是否使用实时数据(比如动态表格数据) | boolean 非必传,不传默认 false |
|
|
74
|
+
| autoPlay | props: 是否自动切换帧(多个帧的时候设置自动切换,不设置会显示前一个后一个按钮手动切换) | boolean 非必传,不传默认 false |
|
|
75
|
+
| autoScale | props: 是否自动切缩放,当帧的宽高超出外层元素宽高,指示是滚动条还是缩放 | boolean 非必传,不传默认 false |
|
|
76
|
+
| showElBorder | props: 帧内每个元素是否给一个边框 | boolean 非必传,不传默认 false |
|
|
77
|
+
| selectedData | props: 预览中需要被选中的元素数据信息 | PreviewSelectedData 非必传 |
|
|
78
|
+
| fileBuffer | props: 针对 ppt/word/image/video 四种元素,根据文件名称获取文件数据的方法 | (fileName: string) => Promise(ArrayBuffer) 必传 |
|
|
79
|
+
| action | event: 单击或双击预览内部元素时会触发该事件(可在此事件中配合 selectedData 处理选中其他预览元素) | (type: PreviewEventType, data: PreviewSelectedData) => void |
|
|
80
|
+
| change | event: 帧自动播放活手动播放,帧切换时的事件 | (index: number, data: FrameData) => void |
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
type PreviewEventType = 'click' | 'dblclick';
|
|
84
|
+
type PreviewSelectedData = {
|
|
85
|
+
id: string; // 选中元素的 ID
|
|
86
|
+
key: string; // 选中元素在 xml 中 对应的标签名称
|
|
87
|
+
seq: number; // 选中元素的类型,xml 中的 TP 值
|
|
88
|
+
type: string; // 选中元素的类型,比如 image,richText,table 等
|
|
89
|
+
source: string; // 选中元素的设置的数据源值
|
|
90
|
+
};
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## 帧预览示例
|
|
94
|
+
|
|
95
|
+
```html
|
|
96
|
+
<template>
|
|
97
|
+
<frame-preview
|
|
98
|
+
:xmlString="pXmlString"
|
|
99
|
+
:useLiveData
|
|
100
|
+
:autoPlay="false"
|
|
101
|
+
:selectedData="selectedData"
|
|
102
|
+
:fileBuffer="fetchBuffer"
|
|
103
|
+
@action="handleAction" />
|
|
104
|
+
</template>
|
|
105
|
+
|
|
106
|
+
<script setup lang="ts">
|
|
107
|
+
import { ref, shallowRef, onMounted } from 'vue';
|
|
108
|
+
import { fetchBuffer } from '@/views/pis/frameEdit/frameEditApi';
|
|
109
|
+
|
|
110
|
+
const pXmlString = ref('');
|
|
111
|
+
const selectedData = shallowRef({});
|
|
112
|
+
const handleAction = (type, data) => {
|
|
113
|
+
if (type === 'click') {
|
|
114
|
+
selectedData.value = data;
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
</script>
|
|
118
|
+
```
|