1.0.3 • Published 6 months ago
oh-gov-docblack-beta v1.0.3
说明
oh-gov-docblack,是一个红头文件的编辑器,便捷的工具会让您信手拈来,如鱼得水
安装
使用 npm 安装
npm install oh-gov-docblack-beta
使用 yarn 安装
yarn add oh-gov-docblack-beta
使用 pnpm 安装
pnpm install oh-gov-docblack-beta
配置
main.js
import OhGovDocblack from 'oh-gov-docblack-beta';
// 引入样式
import "oh-gov-docblack/lib/oh-gov-docblack.css";
Vue.use(OhGovDocblack);
快速上手
在main.js引入后,在需要的页面直接引用即可。
<block-editor-module
ref="editorRef"
:autoHeight="true"
:docId="85">
</block-editor-module>
API
props
参数 | 说明 | 类型 | 默认值 | 可选值 |
---|---|---|---|---|
docId | 文档id(编辑时回显文档,未传新增,传了编辑) | Number | - | - |
height | 设置可编辑区域初始化高度(不传代表高度自适应页面高度) | Number/String | - | - |
zIndex | block-editor-module层级 | Number | 1000 | - |
token | token,用来请求公文模板、保存等接口 | String | - | - |
userInfo | 用户信息 | Object | - | 详见 |
setting | 基于tinymce的配置项 | Object | 详见 | 详见 |
mode | 编辑器展示效果 | String | nomal(普通模式,展示所有功能界面) | simple(极简模式,不显示头部和工具栏) |
content | 编辑器出事内容 | String | - | - |
appkey | - | - | - | - |
methods
方法 | 说明 | 参数 |
---|---|---|
tomyDocList | 点击我的公文处理方法 | - |
save | 自定义保存方法 | 公文内容 |
ref
下述的editorRef
表示this.$refs.editorRef
参数 | 说明 | 示例 |
---|---|---|
settingTitle | 设置/修改文件名称 | editorRef.settingTitle('测试文件名') |
settingEditorContent | 设置/修改公文标签 | editorRef.settingEditorContent(['标签1','标签2']) |
save_docment | 保存 | editorRef.save_docment() |
correction_docment | 公文纠错 | editorRef.correction_docment() |
uploadBtn | 打开导出弹框 | editorRef.uploadBtn() |
exportDoc | 导出对应文件(参数可选项:word、pdf、image、html、txt、markdown) | editorRef.uploadBtn('pdf') |
tomyDocList | 我的公文(使用前应先传入点击我的公文处理方法tomyDocList ) | editorRef.tomyDocList() |
openShareDialog | 打开分享弹框 | editorRef.openShareDialog() |
showHistory | 打开公文历史弹框 | editorRef.showHistory() |
wordGenHistList | 打开文件生成记录弹框 | editorRef.wordGenHistList() |
devhelp | 打开开发对接说明弹框 | editorRef.devhelp() |
showDocTemplate | 打开选择模板弹框 | editorRef.showDocTemplate() |
handleCommandNew | 打开插入弹框(参数详情) | editorRef.handleCommandNew('gov_fwjg') |
tinyMceCommand | 撤销/重做(可选参数:undo:撤销、redo:重做) | editorRef.tinyMceCommand('undo') |
userInfo可选项
参数 | 说明 | 类型 |
---|---|---|
userName | 用户名 | String |
userId | 用户id | Number |
setting默认值
{
placeholder: '开始拟写您的公文吧~',
menubar: false,
toolbar: false,
statusbar: false,
quickbars_selection_toolbar: " alignleft aligncenter alignright alignjustify | bold italic underline strikethrough ",
plugins: "govdoc_title1 link image media table lists fullscreen quickbars imagetools",
quickbars_insert_toolbar: " quickimage table | undo redo ",
language: 'zh_CN',
inline: true,
images_upload_handler: (blobInfo, success, failure) => {
const img = 'data:image/jpeg;base64,' + blobInfo.base64()
success(img)
},
mobile: {
toolbar: "undo redo | fullscreen | formatselect alignleft aligncenter alignright alignjustify | link unlink | numlist bullist | image media table | fontselect fontsizeselect forecolor backcolor | bold italic underline strikethrough | indent outdent | superscript subscript | removeformat |",
toolbar_location: "bottom",
},
font_formats: "微软雅黑=Microsoft YaHei,Helvetica Neue;PingFang SC;sans-serif;苹果苹方=PingFang SC,Microsoft YaHei,sans-serif;宋体=simsun;serifsans-serif;Terminal=terminal;monaco;Times New Roman=times new roman;times", //字体
extended_valid_elements: '*[id|class|title|style|data*|oh_*|oh_gb_type|path|src],svg[*],path[*],div[*],span[*],p[*],table[*],ul[*],li[*],a[*],td[*],tr[*],strong[*],u[*],oh:b[*],oh:s[*]',
custom_elements: "~oh:b[*],~ohp[*]",
short_ended_elements: 'area base basefont br col frame hr img input isindex link meta param embed source wbr track oh:b oh:s',
forced_root_block: true,
forced_root_block_attrs: {
'class': 'oh_gov_block gov_zw',
'oh_gb_type': "gov_zw",
'id': `gov_${uuidv4()}`
},
auto_focus: true,
table_default_attributes: {
class: 'oh_gov_block gov_table',
'oh_gb_type': "gov_table"
},
init_instance_callback: function (editor) {
this.DFREditor = editor
console.log('DFEditor: ' + editor.id + ' is now initialized.');
},
autoresize_min_height: 400,
autoresize_max_height: 800
}
handleCommandNew参数选项
参数 | 说明 |
---|---|
gov_fwjg | 公文红头/发文机关 |
gov_fwzh | 发文字号 |
gov_fj | 附件 |
gov_zw | 正文 |
gov_gwbt | 公文标题 |
gov_yjbt | 一级标题 |
gov_ejbt | 二级标题 |
gov_fwjg_x1 | 红头线 |
gov_fwjg_x2 | 红头线2 |
gov_lk | 公文落款 |
gov_bj | 公文版记 |
gov_recive_dept | 接收单位 |
gov_next_page | 换页符 |