@hxy2193/pd-editor

基于 UniverJS 的 Vue 3 编辑器组件,提供电子表格(pd-excel)和文档(pd-doc)编辑能力
563
Install
npm install @hxy2193/pd-editor
Latest Version:0.1.3
Vue:3
License:MIT
Last Updated:Sep 11, 2026
Links: npm
Maintainer: hxy2193

pd-editor

基于 UniverJS 的 Vue 3 编辑器组件库,提供电子表格(<pd-excel>)和文档(<pd-doc>)编辑能力。

安装

npm install @hxy2193/pd-editor

引入

全局注册(推荐)

import { createApp } from 'vue'
import pd from '@hxy2193/pd-editor'

const app = createApp(App)
app.use(pd)

注册后可在任意组件中使用 <pd-doc> 和 <pd-excel>。

按需引入

import { PdDoc, PdExcel } from '@hxy2193/pd-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

hxy-editor

基于 UniverJS 的 Vue 3 编辑器组件,提供电子表格(pd-excel)和文档(pd-doc)编辑...

3,996
@vervedoc/excel

VerveDoc Excel 编辑器UI组件

0
xlsx-vue-viewer

Vue 3 component for the Excel spreadsheet editor. Self-contained: includes the e...

2,632 25
nuvra

Word-style document editor for Vue 3: page view, tables, images, find & replace,...

2,088 0
@billtaofbj/editor

File document editor component

3,123

Version History

Version Released Vue License
0.1.3 ^3.4.0 MIT
0.1.2 ^3.4.0 MIT
0.1.1 ^3.4.0 MIT
0.1.0 ^3.4.0 MIT