| 1 | <!DOCTYPE html> |
|---|
| 2 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> |
|---|
| 3 | <head> |
|---|
| 4 | <meta http-equiv="content-type" content="text/html; charset=utf-8" /> |
|---|
| 5 | <title>IndexSizeError on getData() after delete widget</title> |
|---|
| 6 | <script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> |
|---|
| 7 | <script src="https://cdn.ckeditor.com/4.5.4/standard-all/ckeditor.js"></script> |
|---|
| 8 | <script src="https://cdn.ckeditor.com/4.5.4/standard-all/adapters/jquery.js"></script> |
|---|
| 9 | <script> |
|---|
| 10 | $(function () { |
|---|
| 11 | CKEDITOR.plugins.add('blob', { |
|---|
| 12 | requires: 'widget', |
|---|
| 13 | init: function (editor) { |
|---|
| 14 | editor.widgets.add('blob', { |
|---|
| 15 | template: '<span>widget</span>', |
|---|
| 16 | upcast: function ( element ) { |
|---|
| 17 | return element.name === 'span'; |
|---|
| 18 | } |
|---|
| 19 | }); |
|---|
| 20 | } |
|---|
| 21 | }); |
|---|
| 22 | |
|---|
| 23 | CKEDITOR.config.allowedContent = true; |
|---|
| 24 | CKEDITOR.config.extraPlugins = 'blob'; |
|---|
| 25 | |
|---|
| 26 | var div = $("div[contenteditable]"), |
|---|
| 27 | editor = div.ckeditor().editor; |
|---|
| 28 | |
|---|
| 29 | div.promise.then(function () { |
|---|
| 30 | editor.setData("<span>widget</span>"); |
|---|
| 31 | }); |
|---|
| 32 | |
|---|
| 33 | $("button").click(function () { |
|---|
| 34 | var data; |
|---|
| 35 | try { |
|---|
| 36 | data = editor.getData(); |
|---|
| 37 | } catch (exc) { |
|---|
| 38 | data = exc.stack; |
|---|
| 39 | } |
|---|
| 40 | $(".output").append($("<pre>").text("[" + data + "]")); |
|---|
| 41 | }); |
|---|
| 42 | }); |
|---|
| 43 | </script> |
|---|
| 44 | <style> |
|---|
| 45 | div[contenteditable] { |
|---|
| 46 | margin: 5em; |
|---|
| 47 | } |
|---|
| 48 | </style> |
|---|
| 49 | </head> |
|---|
| 50 | <body> |
|---|
| 51 | <div contenteditable></div> |
|---|
| 52 | <p>Click on and delete the widget above, then click getData</p> |
|---|
| 53 | <button>getData</button> |
|---|
| 54 | <div class="output"></div> |
|---|
| 55 | </body> |
|---|
| 56 | </html> |
|---|