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 Piotrek Koszuliński)

TC:

  1. Add console.log( editor.name ); at the beginning of setHighlighter() in the codesnippet/plugin.js file.
  2. Load the code snippet sample.
  3. See that 'editor1' and 'editable' were logged correctly.
  4. Execute: CKEDITOR.instances.editor1.plugins.codesnippet.setHighlighter( 1 );
  5. Result:
    • Expected: editor1 should be logged.
    • Actual: editable is logged.

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 (1)

comment:1 Changed 11 years ago by Piotrek Koszuliński

Description: modified (diff)
Note: See TracTickets for help on using tickets.
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy