Opened 10 years ago
Closed 10 years ago
#12753 closed Bug (fixed)
CodeSnippet's setHighlighter() can be only executed while initialising plugins
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.js
file. - Load the code snippet sample.
- See that 'editor1' and 'editable' were logged correctly.
- Execute:
CKEDITOR.instances.editor1.plugins.codesnippet.setHighlighter( 1 );
- Result:
- Expected:
editor1
should be logged. - Actual:
editable
is 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.
Change History (3)
comment:1 Changed 10 years ago by
Description: | modified (diff) |
---|
comment:2 Changed 10 years ago by
Milestone: | → CKEditor 4.4.7 |
---|---|
Status: | new → confirmed |
comment:3 Changed 10 years ago by
Resolution: | → fixed |
---|---|
Status: | confirmed → closed |
Fixed with git:882e4a1. I also noticed that this method is documented to be in CKEDITOR.plugins.codesnippet
, while it's available in editor.plugins.codesnippet
... Pity that we haven't noticed this earlier.
We decided to improve docs, because this may be only a theoretical issue, so no need to spend more time on it.