wcoder / highlightjs-line-numbers.js

Line numbering plugin for Highlight.js
https://wcoder.github.io/highlightjs-line-numbers.js/
MIT License
541 stars 125 forks source link

Multiply number column after calling lineNumbersBlock multiply times #74

Open XianfuZhengAfterpay opened 4 years ago

XianfuZhengAfterpay commented 4 years ago

Is your feature request related to a problem? Please describe. In our use case, we have an editable highlight js component by adding contenteditable attribute. We want to update the line number whenever the content is changed (lose focus event).

The problem here is , it adds a new column for the line number after each lineNumbersBlock. Is the right function to call to update the line number?

Describe the solution you'd like I expect it should maintain the internal state so only one line column should be shown.

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

Additional context Add any other context or screenshots about the feature request here.

The below code is what we are using: element.addEventListener( 'focusout', function( event ) { hljsWithLineNumber.highlightBlock( event.currentTarget ); hljsWithLineNumber.lineNumbersBlock(event.currentTarget); }, false ); Please see screen shot: image

guillaume-dorczynski commented 4 years ago

highlightjs is not meant to be a code editor, it should be used only for highlighting code. If you want a code editor, look at Ace or CodeMirror