Opened 9 years ago

Closed 9 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 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 (3)

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

Description: modified (diff)

comment:2 Changed 9 years ago by Piotrek Koszuliński

Milestone: CKEditor 4.4.7
Status: newconfirmed

We decided to improve docs, because this may be only a theoretical issue, so no need to spend more time on it.

comment:3 Changed 9 years ago by Piotrek Koszuliński

Resolution: fixed
Status: confirmedclosed

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.

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