javascript - Modifying a format plugin style using CKEDITOR.style.addCustomHandler -
comments in ckeditor documentation , source code imply it's possible have command on how styles applied, using addcustomhandler, including existing styles. e.g., in core/style.js on line 665 have:
the style handling job, includes such tasks applying, removing, checking state, , checking if style can applied, complex. hence without deep knowledge dom , {@link ckeditor.dom.range ranges} , {@link ckeditor.dom.walker dom walker} impossible implement custom style handler able handle block, inline, , object type styles. however, possible customize default implementation overriding default methods , reusing them.
the lastly sentence leads me think should able modify happens, example, when the format plugin used apply style alter convert text h1 heading using like:
ckeditor.style.addcustomhandler({ element: 'h1', type: 1, apply: function( editor ) { console.log( 'apply' ); }, remove: function( editor ) { console.log( 'remove' ); } }); but above, , several variations on (with different or omitted element , type attributes) has no effect.
i guess either not possible or i'm doing wrong, don't know which. help appreciated.
(note can see docs how have brand new style, created type attribute , modify using addcustomhandler, format plugin creates styles element attribute not type attribute.)
thanks!
however, possible customize default implementation overriding default methods , reusing them.
you misunderstood sentence (apologise this, cause i'm author :d). using ckeditor.style.addcustomhandler can add together new types. overriding meant accessing ckeditor.style.prototype. example:
var originalapply = ckeditor.style.prototype.apply; ckeditor.style.prototype.apply = function( editor ) { originalapply.call( this, editor ); }; javascript ckeditor
No comments:
Post a Comment