1 | <!DOCTYPE html> |
---|
2 | |
---|
3 | <html lang="en" xmlns="http://www.w3.org/1999/xhtml"> |
---|
4 | <head> |
---|
5 | <meta charset="utf-8" /> |
---|
6 | <title></title> |
---|
7 | </head> |
---|
8 | <body> |
---|
9 | <div class="contenteditable" contenteditable="true" style="height: 100px; width: 200px; border: 1px solid black;"> |
---|
10 | </div> |
---|
11 | <a id="add" href="#">Add another</a> |
---|
12 | <a id="addSpace" href="#">Add space</a> |
---|
13 | |
---|
14 | <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> |
---|
15 | <script type="text/javascript" src="ckeditor.js"></script> |
---|
16 | <script type="text/javascript"> |
---|
17 | CKEDITOR.disableAutoInline = true; |
---|
18 | |
---|
19 | $(".contenteditable").each(function(index, element){ |
---|
20 | CKEDITOR.inline(element, { |
---|
21 | toolbar: [ |
---|
22 | { name: 'basicstyles', groups: ['basicstyles', 'cleanup'], items: ['Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'RemoveFormat'] }, |
---|
23 | ] |
---|
24 | }); |
---|
25 | }); |
---|
26 | |
---|
27 | $("#add").on("click", function () { |
---|
28 | var clone = $(".contenteditable:first").clone(); |
---|
29 | clone.insertAfter(".contenteditable:last"); |
---|
30 | |
---|
31 | $(".contenteditable:last").each(function (index, element) { |
---|
32 | CKEDITOR.inline(element, { |
---|
33 | toolbar: [ |
---|
34 | { name: 'basicstyles', groups: ['basicstyles', 'cleanup'], items: ['Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'RemoveFormat'] }, |
---|
35 | ] |
---|
36 | }); |
---|
37 | }); |
---|
38 | }); |
---|
39 | |
---|
40 | $("#addSpace").on("click", function () { |
---|
41 | $('<div style="height: 100px;"></div>').insertBefore($(".contenteditable:first")); |
---|
42 | }); |
---|
43 | </script> |
---|
44 | </body> |
---|
45 | </html> |
---|