# ckeditor5-custom-element
[![npm version](https://badge.fury.io/js/ckeditor5-custom-element.svg)](https://badge.fury.io/js/ckeditor5-custom-element)
[![Dependency Status](https://david-dm.org/centaur54dev/ckeditor5-custom-element/status.svg)](https://david-dm.org/centaur54dev/ckeditor5-custom-element)
[![devDependency Status](https://david-dm.org/centaur54dev/ckeditor5-custom-element/dev-status.svg)](https://david-dm.org/centaur54dev/ckeditor5-custom-element?type=dev)
## About
This is a plugin for [ckeditor 5](https://github.com/ckeditor/ckeditor5). It allows to add custom elements in the editor. The html conversion of the created elements looks like this:
```
<CustomTag>placeholder text</CustomTag>
```
## Install
Install using NPM:
`npm install ckeditor5-custom-element`
To add the functionality of this plugin you should make a custom build of the editor. Follow the instructions [here](https://docs.ckeditor.com/ckeditor5/latest/builds/guides/development/installing-plugins.html).
To load the plugin, configure ckeditor (e.g. edit file `ckeditor.js`) like this:
#### Import plugin
```
import CustomElementPlugin from 'ckeditor5-custom-element/src/customelement';
```
#### Import toolbar icons (optional)
```
import Icon1 from 'path-to-icon/iconfile.svg';
```
#### Configure plugin
Assuming that the build is based on Classic Editor:
```
export default class ClassicEditor extends ClassicEditorBase {}
// Plugins to include in the build.
ClassicEditor.builtinPlugins = [
...
CustomElementPlugin,
...
],
ClassicEditor.defaultConfig = {
toolbar: {
items: [
...
'custom-element-tagname1',
'custom-element-tagname2',
...
]
},
CustomElement:{
items:[
{tag: 'tagname1', placeholder: 'some text',
attributes:{name:'ABCD'}, icon:Icon1,
inline:false, editable:false},
{tag: 'tagname2'},
...
]
},
...OTHER OPTIONS
};
```
*Note: the toolbar item names should have the format: `custom-element-tagname`, where `tagname` should be replaced by the respective tag of the custom element, the button is going to insert.*
## Custom element(s) options
The elements can be customized through the CustomElement object that is passed to the editor, as shown above. Many different custom elements can be defined. The following options are available for each one:
* `tag` : (string) the tag name for the created custom elements,
* `placeholder` : (optional)(string) the text to be displayed inside the custom element (as a text node). If missing, the tag name is displayed,
* `attributes`: (optional)(object) any attributes for the created custom elements,
* `icon`: (optional)(icon object) icon for the respective toolbar button. If missing, a default icon is used that looks like this: [#],
* `inline`: (optional)(boolean) if true, the custom element can be nested within other blocks (e.g. between text), othrewise it is placed only as a root element. Defaults to false,
* `editable`: (optional)(boolean) if true, the text inside the custom element can be modified. Defaults to false.
## Use
For the time being only addition of custom elements is implemented. If you want to replace a custom element with another, delete first.
没有合适的资源?快使用搜索试试~ 我知道了~
ckeditor5-custom-element:在ckeditor5中插入自定义元素(html标记)
共64个文件
js:58个
json:2个
gitignore:1个
需积分: 50 6 下载量 175 浏览量
2021-04-28
14:25:07
上传
评论
收藏 1010KB ZIP 举报
温馨提示
ckeditor5-自定义元素 关于 这是的插件。 它允许在编辑器中添加自定义元素。 创建的元素的html转换如下所示: <CustomTag>placeholder text</CustomTag> 安装 使用NPM安装: npm install ckeditor5-custom-element 要添加此插件的功能,您应该对编辑器进行自定义构建。 请按照的说明进行操作。 要加载插件,请配置ckeditor(例如,编辑文件ckeditor.js ),如下所示: 导入插件 import CustomElementPlugin from 'ckeditor5-custom-element/src/customelement'; 导入工具栏图标(可选) import Icon1 from 'path-to-icon/iconfile.svg'; 配置插件 假设构建基于经典编辑器: e
资源详情
资源评论
资源推荐
收起资源包目录
ckeditor5-custom-element-master.zip (64个子文件)
ckeditor5-custom-element-master
.gitignore 125B
package.json 665B
package-lock.json 7KB
src
customelem_ui.js 4KB
customelement.js 294B
customelem_command.js 1KB
README.md 3KB
theme
icons
default.svg 3KB
test-builds
ckeditor5-build-classic
ckeditor.js.map 3.53MB
translations
sr.js 3KB
km.js 2KB
fa.js 2KB
ko.js 2KB
da.js 2KB
et.js 2KB
oc.js 2KB
uk.js 3KB
pt.js 2KB
eu.js 2KB
sr-latn.js 2KB
sk.js 2KB
pl.js 2KB
gl.js 2KB
bg.js 2KB
ca.js 2KB
kn.js 2KB
cs.js 2KB
az.js 2KB
ar.js 2KB
no.js 2KB
tr.js 2KB
id.js 2KB
de.js 2KB
nb.js 2KB
sq.js 2KB
el.js 2KB
ro.js 2KB
ru.js 3KB
tt.js 2KB
zh-cn.js 2KB
eo.js 2KB
vi.js 2KB
si.js 2KB
it.js 2KB
gu.js 2KB
ug.js 2KB
pt-br.js 2KB
ast.js 2KB
ne.js 3KB
fr.js 2KB
nl.js 2KB
hu.js 2KB
ja.js 2KB
fi.js 2KB
ku.js 3KB
lv.js 2KB
zh.js 2KB
sv.js 2KB
en-au.js 2KB
de-ch.js 2KB
es.js 2KB
he.js 2KB
hr.js 2KB
ckeditor.js 543KB
共 64 条
- 1
按剑四顾
- 粉丝: 23
- 资源: 4623
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0