1 | <!DOCTYPE html> |
---|
2 | <html> |
---|
3 | <head> |
---|
4 | <title></title> |
---|
5 | <script type="text/javascript" src="https://raw.github.com/ckeditor/ckeditor-dev/major/ckeditor.js"></script> |
---|
6 | <script type="text/javascript"> |
---|
7 | CKEDITOR.disableAutoInline = true; |
---|
8 | CKEDITOR.plugins.add('ref', { |
---|
9 | requires: 'widget', |
---|
10 | |
---|
11 | init: function (editor) { |
---|
12 | editor.widgets.add('ref', { |
---|
13 | editables: { text: '*' }, |
---|
14 | |
---|
15 | upcast: function (el) { |
---|
16 | return el.attributes['data-type']; |
---|
17 | }, |
---|
18 | }); |
---|
19 | } |
---|
20 | }); |
---|
21 | document.addEventListener('DOMContentLoaded', function () { |
---|
22 | CKEDITOR.inline('editor', { |
---|
23 | customConfig: '', |
---|
24 | allowedContent: true, |
---|
25 | autoParagraph: false, |
---|
26 | fillEmptyBlocks: false, |
---|
27 | |
---|
28 | extraPlugins: 'ref', |
---|
29 | }); |
---|
30 | }); |
---|
31 | </script> |
---|
32 | </head> |
---|
33 | <body> |
---|
34 | <div contenteditable="true" id="editor"> |
---|
35 | <p>Non-widget content</p> |
---|
36 | <p data-type="yes">widget content</p> |
---|
37 | <p>Non-widget content</p> |
---|
38 | </body> |
---|
39 | </html> |
---|