wcoder / highlightjs-line-numbers.js

Line numbering plugin for Highlight.js

Home Page:https://wcoder.github.io/highlightjs-line-numbers.js/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Multiply number column after calling lineNumbersBlock multiply times

XianfuZhengAfterpay opened this issue · comments

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

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