MurhafSousli / ngx-highlightjs

Angular syntax highlighting module
https://ngx-highlight.netlify.app/
MIT License
273 stars 35 forks source link

Highlight TextArea #50

Closed mrbormeth closed 5 years ago

mrbormeth commented 5 years ago

Bug Report or Feature Request (mark with an x)

- [ ] bug report -> please search issues before submitting
- [X] feature request
- [ ] question

OS and Version?

WINDOWS 10

Versions

@angular/cli (6.2.4)

Repro steps

<div highlight="textarea"> <textarea name="codes" [(ngModel)]="itemValue" placeholder="Codes..."></textarea> </div>

Desired functionality

Would love a way to somehow use ngx-highlightjs directly on a textArea, that way i have a "code editor" directly build in. I already made a side by side view, using a textarea and a pre/code box, but the it feels odd that you type one place and reads it in another box.

Hope that you can help me with my request or maybe point me in the right direction.

Have a great weekend! 👍

rhwilburn commented 6 months ago

Was this ever implemented? Or was it not possible?

I have this which is close:

      <input #editor [(ngModel)]="this.value" />
      <pre>
        <code [highlight]="this.value">
        </code>
      </pre>

But was wondering if I need to hack it so that the pre>code is over the top visually but the input focus goes to the input control; or whether its possible in an input control. I was looking at this code:

@ViewChild("editor") editor: any;
...
this.highlightJS.highlightElement(this.editor);

but it didn't seem to do anything that I could work out. Will look more into that service tonight.