Mark js marker cancels the user selection

109 Views Asked by At

I'm using mark.js to mark the user selection text on some html element (like an ordinary text editor). However, the mark js marker cancels the user selection and its disapear so i can't use it anymore.

I have tried to use rangy.saveSelection() and rangy.restoreSelection() but it didn't help.

My code is something like this:

$(document).ready(function() {
            $("#p").on('mouseup', function() {
                $("#p").unmark({
                    done: function() {
                        $("#p").mark(window.getSelection().toString(), {
                            seperateWordSearch: false
                });
            }
        })
    });
})
0

There are 0 best solutions below