Opened 11 years ago
Last modified 11 years ago
#12753 closed Bug
CodeSnippet's setHighlighter() can be only executed while initialising plugins — at Version 1
| Reported by: | Piotrek Koszuliński | Owned by: | |
|---|---|---|---|
| Priority: | Normal | Milestone: | CKEditor 4.4.7 |
| Component: | General | Version: | |
| Keywords: | Cc: |
Description (last modified by )
TC:
- Add
console.log( editor.name );at the beginning ofsetHighlighter()in thecodesnippet/plugin.jsfile. - Load the code snippet sample.
- See that 'editor1' and 'editable' were logged correctly.
- Execute:
CKEDITOR.instances.editor1.plugins.codesnippet.setHighlighter( 1 ); - Result:
- Expected:
editor1should be logged. - Actual:
editableis logged.
- Expected:
Note: If in step 3 the order for you was different, then in next steps switch the names (editor1 and editable).
The reason why setHighlighter() will always set it for the last editor is that it's bound to the plugin instance and unfortunately plugins instances are shared between editors.
This sounds terribly, but it's not that bad, since all plugins for one editor are always initialised synchronously, so the setHighlighter() method will always work correctly in the init callbacks of a plugin.
Therefore, the easiest solution is adding this information to the documentation. A real solution, unfortunately, will be to move setHighlighter() to CKEDITOR.plugins.codeSnippet and pass editor instance to it. This is of course not backwards compatible change, but we could keep the editor.plugins.codesnippet.setHighlighter() method and mark it as deprecated.
