Ckeditor5: How to make the marker to be displayed in the document with color?

Created on 27 Mar 2020  Â·  4Comments  Â·  Source: ckeditor/ckeditor5

writer.addMarker( "search:blue", {range: range, usingOperation: false} );

Above code does not generate span in the view . Hence the markerline and marker dot is not visible.

​

Please let me know how to add marker and view it in the document. Any sample code will be very useful for my implementation of find functionality.

Thanks.

question

All 4 comments

Marker

Hi, thanks for the report. Adding a marker to your model only, will not make it look highlighted in the view. To achieve this, you also need to add a conversion using marker-to-highlight downcast helper. You can do it like this:

// conversion between model and view
// don't forget to add a CSS class for 'my_marker_css_class' in your html file
editor.conversion.for( 'downcast' ).markerToHighlight( { model: 'my_marker', view: { classes: 'my_marker_css_class' } } );

// create a marker
editor.model.change( writer => {
    writer.addMarker( "my_marker", {range: range, usingOperation: false})
} );

You can start with this snippet and then further modify it to fit your particular needs.
Hope that helps!

Thanks Filip Tokarski. Let me try and get back to you.

Filip Tokarski, It is working like charm.
Thanks a lot for the help. Really appreciate it

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wwalc picture wwalc  Â·  3Comments

Reinmar picture Reinmar  Â·  3Comments

metalelf0 picture metalelf0  Â·  3Comments

pandora-iuz picture pandora-iuz  Â·  3Comments

pjasiun picture pjasiun  Â·  3Comments