1.0.1 • Published 4 months ago

linkdood-editor v1.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
4 months ago

linkdood-editor

目的

替换uditor,既uditor异步加载文件方式,UI渲染慢,与异步加载css导致工具栏滑动不宜复现滚动问题

描述

基于tiptap开发一套适用于豆豆后台需求富文本编辑器,icon使用remixicon,主题偏向Antd现代、简洁风格,支持段落、附件、图片、视频(上传、拖拽),可扩展富文本编辑器

目录介绍:

启动:npm run dev 打包:npm run build examples:本地测试页面 src: 核心项目文件夹 components: 富文本内部使用公用组件 editor: 富文本内容 bubble: 富文本气泡菜单 constant: 常量 css: 样式 data: 数据源 extend: tiptap源生重写 extension: tiptap扩展 footer: 底部dom global: 全局hook locales: 国际化 source-code: 查看源代码实现 toolbars: 顶部工具栏 utils:工具类

使用

使用富文本

npm i -S linkdood-editor

import VEditor,{editorHtmlConvert} from 'linkdood-editor-alpha';

<v-editor
    v-model:content="content"
/>
注:
为video方便拖拽,拖拽触发播放问题,生成html为 
<video src="" /> 

非标准浏览器解析 
<video>
	<resource src="" />
</video>

保存时需要额外调用editorHtmlConvert(content) 转换content中video中内容

预览

@import "/node_modules/linkdood-editor/dist/css/index.css";

<div class="ldd-editor-preview" v-html="content"/>

API

属性描述类型默认值
content(v-model)富文本内容stirng‘’
loading是否加载中booleanfalse
disabled是否禁用booleanfalse
modalMaskClosable弹框点击框蒙层是否允许关闭booleanfalse
contentHeight内容高度(超出显示滚动条)number0
contentMaxLength内容最大长度(包含html标签)-字节number0
locales国际化可,选值为 zhenstringzh
attachmentAccept附件文件类型string''
imageAccept图片文件类型string.png,.jpg,.jpeg
videoAccept视频文件类型string.mp4
upload上传接口(file, type{attachment|image|video}) => promise.resolve(url)Promise.resolve('')
uploadValidate上传校验(file, type{attachment|image|video}) => booleantrue
toolbars自定义工具栏array'html', '|','retreat'....
toolbarsExtend工具栏扩展{key1: {title,icon,click,iconClass,disabled}}object

工具栏

名称描述
html源代码
retreat后退
forward前进
bold加粗
ltalic斜体
underLine下划线
deleteLine删除线
superscript上标
subscript下标
clearFormat清除格式
textSizeMagnify字体放大
textSizeShrink字体缩小
fontColor字体颜色
fontBack背景色
orderedList有序列表
bulletList无序列表
marginTop段前句
marginBottom段后句
lineHeight行间距
paragraph段落
family字体
fontSize字号
textIndent首行缩进
textAlignLeft居左对齐
textAlignCenter居中对齐
textAlignRight居中对齐
textAlignJustify两端对齐
link超链接
code代码块
date日期
time时间
table插入表格
tableAddRowBefore前插入行
tableAddRowAfter后插入行
tableDeleteRow删除行
tableAddColBefore前插入列
tableAddColAfter后插入列
tableDeleteCol删除列
tableMerge合并
tableSplit拆分
attachment附件上传
image网络或上传图片
video网络或上传视频
fullScreen全屏

自定义富文本总评

基于tiptap二次开发,受tiptap本身优缺点影响 优点: 1.UI层自定义扩展新功能方便 2.提供直量操作符文本API 3.轻量 4.插件相对丰富

缺点: 1.基于ProseMirror, 为定制,非常规w3c标准,学习曲线陡 2.文档不详细,需要自己探索或尝试

本次2次封装富文本,仅提供项目上需求内容,非完整性富文本编辑器API,待需求补充扩展