hxy-editor
pd-editor
基于 UniverJS 的 Vue 3 编辑器组件库,提供电子表格(<pd-excel>)和文档(<pd-doc>)编辑能力。
安装
npm install hxy-editor
引入
全局注册(推荐)
import { createApp } from 'vue'
import pd from 'hxy-editor'
const app = createApp(App)
app.use(pd)
注册后可在任意组件中使用 <pd-doc> 和 <pd-excel>。
按需引入
import { PdDoc, PdExcel } from 'hxy-editor'
组件 API
<pd-doc> — 文档编辑器
<template>
<pd-doc ref="editorRef" type="edit" />
</template>
Props
| Prop | 类型 | 默认值 | 说明 |
|---|---|---|---|
type |
string |
'edit' |
'edit' 编辑模式 / 'view' 只读模式 |
Exposes(通过 ref 调用)
| 方法 | 参数 | 返回值 | 说明 |
|---|---|---|---|
setData |
docData: object |
boolean |
灌入文档数据(body / tableSource / documentStyle) |
getData |
— | object |
获取当前文档快照(含 version) |
getVersion |
— | number |
获取数据版本号 |
isDirty |
— | boolean |
自上次 getData 以来是否有变更 |
<pd-excel> — 电子表格编辑器
<template>
<pd-excel ref="sheetRef" type="edit" />
</template>
Props
| Prop | 类型 | 默认值 | 说明 |
|---|---|---|---|
type |
string |
'edit' |
'edit' 编辑模式 / 'view' 只读模式 |
Exposes(通过 ref 调用)
| 方法 | 参数 | 返回值 | 说明 |
|---|---|---|---|
setData |
sheetData: object |
boolean |
灌入表格数据(workbooks / activeWorkbookId) |
getData |
— | object |
获取当前表格快照 |
navigateTo |
workbookId: string |
— | 切换到指定工作簿 |
getVersion |
— | number |
获取数据版本号 |
isDirty |
— | boolean |
自上次 getData 以来是否有变更 |
使用示例
<template>
<pd-doc ref="editorRef" type="edit" />
<button @click="save">保存</button>
</template>
<script setup>
import { ref } from 'vue'
const editorRef = ref(null)
function save() {
const data = editorRef.value?.getData()
console.log('文档数据:', data)
}
</script>
技术栈
- Vue 3.4+
- Univer 0.25.1
- Vite 8(构建)
License
MIT
Related Packages
xlsx-vue-viewer
Vue 3 component for the Excel spreadsheet editor. Self-contained: includes the e...
2,632
25
Version History
| Version | Released | License |
|---|---|---|
| 0.4.23 | MIT | |
| 0.4.22 | MIT | |
| 0.4.21 | MIT | |
| 0.4.20 | MIT | |
| 0.4.19 | MIT | |
| 0.4.18 | MIT | |
| 0.4.17 | MIT | |
| 0.4.16 | MIT | |
| 0.4.15 | MIT | |
| 0.4.14 | MIT | |
| 0.4.13 | MIT | |
| 0.4.12 | MIT | |
| 0.4.11 | MIT | |
| 0.4.10 | MIT | |
| 0.4.9 | MIT | |
| 0.4.8 | MIT | |
| 0.4.7 | MIT | |
| 0.4.6 | MIT | |
| 0.4.5 | MIT | |
| 0.4.4 | MIT | |
| 0.4.3 | MIT | |
| 0.4.2 | MIT | |
| 0.4.1 | MIT | |
| 0.4.0 | MIT | |
| 0.3.0 | MIT | |
| 0.2.0 | MIT | |
| 0.1.3 | MIT | |
| 0.1.2 | MIT | |
| 0.1.1 | MIT | |
| 0.1.0 | MIT |