当前位置:网站首页>tinymce-plugins
tinymce-plugins
2022-08-02 13:07:00 【InfoQ】
tinymce-plugins
前言
简述
- imagetools [增强优化]: 图片编辑工具插件, 对图片进行处理。优化跨域,功能更丰富;
- table [增强优化]:表格插件,处理表格。 增强优化表格控制,增加表格转图片功能,便捷布局按钮;
- indent2em[增强优化]:首行缩进插件。提供中文段落排版的首行缩进2个字符的功能。增强优化 加入字间距非默认情况,也能实现准确首行缩进2字符;
- letterspacing:设置间距插件。可以设置文档中的文字间距;
- layout: 一键布局插件。可以给文档段落进行一键快速排版布局;
- importword: 导入word插件。可以直接导入word ,并且保证word中图片不会丢失,自动转为base64;
- upfile: 文件上传。可以点击导入文件,可自定义编辑文件名;
- bdmap: 百度地图。 支持更改尺寸,自定义标签,开启导航功能,支持vue;
- axupimgs: 多图上传。可同时上传多组图片,支持vue;
- attachment: 附件上传。拥有附件类型对应图标,支持vue;
下载
npm i @npkg/tinymce-plugins 或 cnpm i @npkg/tinymce-plugins -D
使用说明
imagetools 使用方法:
tinymce.init({
selector: '#tinydemo',
plugins: "image imagetools",
toolbar: "image",
});
table 使用方法:

- align-left-table: 表格居左
- align-center-table: 表格居中
- align-right-table: 表格居右
- table-to-img: 表格转图片
tinymce.init({
selector: '#tinydemo',
plugins: "table",
toolbar: "table"
table_icons: {// 以下下为默认配置
'align-right-table': '<svg width="24" height="24"><path d="M5 5h14c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 1 1 0-2zm6 4h8c.6 0 1 .4 1 1s-.4 1-1 1h-8a1 1 0 0 1 0-2zm0 8h8c.6 0 1 .4 1 1s-.4 1-1 1h-8a1 1 0 0 1 0-2zm-6-4h14c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 0 1 0-2z" fill-rule="evenodd"></path></svg>',
'align-left-table': '<svg width="24" height="24"><path d="M5 5h14c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 1 1 0-2zm0 4h8c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 1 1 0-2zm0 8h8c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 0 1 0-2zm0-4h14c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 0 1 0-2z" fill-rule="evenodd"></path></svg>',
'align-center-table': '<svg width="24" height="24"><path d="M5 5h14c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 1 1 0-2zm3 4h8c.6 0 1 .4 1 1s-.4 1-1 1H8a1 1 0 1 1 0-2zm0 8h8c.6 0 1 .4 1 1s-.4 1-1 1H8a1 1 0 0 1 0-2zm-3-4h14c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 0 1 0-2z" fill-rule="evenodd"></path></svg>'
}
});
indent2em 使用方法:
tinymce.init({
selector: '#tinydemo',
plugins: "indent2em",
toolbar: "indent2em"
});
letterspacing 使用方法:
tinymce.init({
selector: '#tinydemo',
plugins: "letterspacing",
toolbar: "letterspacing"
});
tinymce.init({
selector: '#tinydemo',
plugins: "letterspacing",
toolbar: "letterspacing",
letterspacing: "0px 2px 4px 6px 24px"
});
layout 使用方法:
tinymce.init({
selector: '#tinydemo',
plugins: "layout",
toolbar: "layout"
});
- style : 一键布局默认样式参数【Object】
- filterTags: 【Array】过滤标签,该数组中的标签,一键布局中将会被忽略(默认忽略 ‘table’,‘tbody’,‘td’,‘tr’)
- tagsStyle: 单独标签样式处理【Object】
- clearStyle: 【Array】清除样式 ,一键布局后 ,数组中的样式将会清除掉。
tinymce.init({
selector: '#tinydemo',
plugins: "layout",
toolbar: "layout",
layout_options: {
style: {
'text-align':'justify',
'text-indent':'2em',
'line-height': 1.5
},
filterTags:['table>*','tbody'], //'table,'tbody','td','tr' 将会忽略掉 同时 table>*,忽略table 标签 以及所有子标签
clearStyle: ['text-indent'],//text-indent 将会被清除掉
tagsStyle: {
'table': {
'line-height': 3,
'text-align': 'center'
},
'table,tbody,tr,td': { //支持并集选择
'line-height': 2
},
'tr>td,table>tbody': { //支持, 精准定位 通过 ' > '
'line-height': 3,
'text-align': 'center'
}
}
}
});
importword 使用方法:
tinymce.init({
selector: '#tinydemo',
plugins: "importword",
toolbar: "importword"
});
- editor : editor 编辑器实列【object】
- files : 导入的文件 【object】
- next : 下一步骤回调函数 传入files标签字符串【Function】
- result : 导入word 生成的 html标签字符串【String】
- insert : 插入回调函数 传入 html标签字符串【String】
- message: 转换过程中产生的错误信息集【Array】
tinymce.init({
selector: '#tinydemo',
plugins: "importword",
toolbar: "importword",
importword_handler: function(editor,files,next){
var file_name = files[0].name
if(file_name.substr(file_name.lastIndexOf(".")+1)=='docx'){
editor.notificationManager.open({
text: '正在转换中...',
type: 'info',
closeButton: false,
});
next(files);
}else{
editor.notificationManager.open({
text: '目前仅支持docx文件格式,若为doc111,请将扩展名改为docx',
type: 'warning',
});
}
// next(files);
}
importword_filter: function(result,insert,message){
// 自定义操作部分
insert(result) //回插函数
}
});
upfile 使用方法:
tinymce.init({
selector: '#tinydemo',
plugins: "upfile",
toolbar: "upfile"
});
- file : 文件对象【file】
- succFun : 成功回调函数 传入 html标签字符串【Function类型】(url|string,obj)
tinymce.init({
selector: '#tinydemo',
plugins: "upfile",
toolbar: "upfile",
file_callback: function (file, succFun) {
// 自定义处理文件操作部分
succFun(url,{text: 'xx.pdf'}) //成功回调函数 text 显示的文本
}
});
bdmap 使用方法:
tinymce.init({
selector: '#tinydemo',
plugins: "bdmap",
toolbar: "bdmap"
});
bdmapbdmap_options- width: 百度地图默认宽度 默认 560
- height: 百度地图默认高度 默认 360
- outputIframe: 百度地图输出iframe路径, 默认 ‘.’ (当前路径)
Vue 默认 ‘https://unpkg.com/@npkg/tinymce-plugins/plugins/bdmap/bd.html’
- apiKey: 自定义百度地图apiKey
Vue 中有效
tinymce.init({
selector: '#tinydemo',
plugins: "bdmap",
toolbar: "bdmap",
bdmap_options: {
width: 560,
height: 360,
outputIframe: 'https://unpkg.com/@npkg/tinymce-plugins',
apiKey: 'ONXXXXXXXXXXXXXXnP'
}
});
axupimgs(Vue)使用方法:
tinymce.init({
selector: '#tinydemo',
plugins: "axupimgs",
toolbar: "axupimgs"
});
attachment 使用方法:
tinymce.init({
selector: '#tinydemo',
plugins: "attachment",
toolbar: "attachment"
});
attachmentattachment_max_sizeattachment_styleattachment_icons_pathattachment_upload_handlerVue- file : 文件对象【file】
- succFun : 成功回调函数 传入 (url|string)
- failFun : 失败回调函数 传入 (string)
- progressCallback: 进程回调函数 传入 (string)
var xhrOnProgress = function (fun) {
xhrOnProgress.onprogress = fun;
return function () {
var xhr = $.ajaxSettings.xhr();
if (typeof xhrOnProgress.onprogress !== 'function')
return xhr;
if (xhrOnProgress.onprogress && xhr.upload) {
xhr.upload.onprogress = xhrOnProgress.onprogress;
}
return xhr;
}
}
tinymce.init({
selector: '#tinydemo',
plugins: "attachment",
toolbar: "attachment",
attachment_max_size: 209715200,
attachment_style:'.attachment>img{display:inline-block!important;max-width:30px!important;}'
attachment_icons_path: 'https://unpkg.com/@npkg/tinymce-plugins/plugins/attachment/icons',
attachment_upload_handler: function (file, succFun, failFun, progressCallback) {
var data = new FormData();
data.append("file", file);
$.ajax({
data: data,
type: 'GET',
url: './api/file.json',
cache: false,
contentType: false,
processData: false,
header:{'Content-Type':'multipart/form-data'},
dataType: 'json',
xhr: xhrOnProgress(function (e) {
const percent = (e.loaded / e.total * 100 | 0) + '%';//计算百分比
progressCallback(percent);
}),
}).then(function (data) {
if ( data.code== 200) {
succFun(data.data);
} else {
failFun('上传失败:' + data.data);
}
}).fail(function (error) {
failFun('上传失败:' + error.message)
});
},
});
在vue当中使用
|-- node_modules
| ...
| |-- tinymce
| | .
| |-- |-- plugins
| | | |-- letterspacing
| | | |-- layout
| | | |-- indent2em
| | | |-- importword
| | | |-- imagetools
| | | |-- table
| | | |-- bdmap
| | | |-- axupimgs
| | | |-- attachment
| ...
引入
import '@npkg/tinymce-plugins'
import '@npkg/tinymce-plugins/importword'
import '@npkg/tinymce-plugins/lineheight'
import '@npkg/tinymce-plugins/layout'
import '@npkg/tinymce-plugins/letterspacing'
import '@npkg/tinymce-plugins/indent2em'
import '@npkg/tinymce-plugins/upfile'
import '@npkg/tinymce-plugins/imagetools'
import '@npkg/tinymce-plugins/attachment'
欢迎提出建议,动手点赞 ,或提pr
目前项目正在重构调整
边栏推荐
- UAC绕过学习-总结
- 【C语言】细品分支结构——if-else语句
- Closures in JS
- 高效代码静态测试工具Klocwork 2022.2——Portal全新升级、支持RLM
- Ribbon负载均衡的深度分析和使用
- C语言结构体(入门)
- 【C语言】夏日一题 —— 如何判断素数?
- FreeRTOS creation tasks - dynamic creation, static creation
- 基于华为eNSP的企业网络规划
- There are several ways to jump to js source code, jump on the current page, jump on the blank page
猜你喜欢

国产 GPU 创业潮 喧嚣下的资本游戏

photo-sphere-viewer Chinese documentation

Do you know Dijkstra of graph theory?

【C语言】明解数组(1)

How to create short images and short videos from the media?How to make the click volume reach 10W?

FreeRTOS experiment--one function creates multiple tasks

如何通过DBeaver 连接 TDengine?

How to connect DBeaver TDengine?

js true 3d histogram plugin

GCC版本升级到指定版本
随机推荐
Js scratchable latex style draw plug-in
RISC-V instruction format and 6 basic integer instructions
How to connect DBeaver TDengine?
图论之Prim,最小生成树该怎么解?
设置代理服务器(谷歌+IE)「建议收藏」
基于华为eNSP的企业网络规划
分享一个Chrome控制台数据获取的例子
鲁大师7月新机性能/流畅榜:骁龙8+正面对决天玑9000+,性能跑分突破123万!
Automatically generate code generator recommendation-code-gen
最小割和对偶图(未完成)
GCC版本升级到指定版本
【C语言】夏日一题 —— 求最大公约数和最小公倍数
qt 编译报错 No rule to make target
Flashback Technology of Oracle Database
WeChat applet getPhoneNumber interface code=40013
package.json and package-lock.json
企业用直播平台能实现什么
移动端适配,华为浏览器底色无法正常显示
图论之Floyd,多源图最短路如何暴力美学?
麻烦问一下,对mysql 场景注入故障,是不是不是对mysql server 端注入故障,只是对ja