WebCoder49 / code-input

Fully customisable, editable, syntax-highlighted textareas + plugins
https://css-tricks.com/creating-an-editable-textarea-that-supports-syntax-highlighted-code/
MIT License
171 stars 23 forks source link

recommended get and set for data? #94

Closed WhyFenceCode closed 6 months ago

WhyFenceCode commented 6 months ago

This is actually 2 qs:

  1. Is there a recommended way to set/change the highlight language other than just set attribute?
  2. Is there a recommended way to get and set the content, preferably one that de-sanitises /sanitises based on direction?
WebCoder49 commented 6 months ago
  1. To change the highlight language you should use (code-input element).setAttribute("language", newLanguage);.
  2. To get/set the content you should use (code-input element).value. This should auto-escape/unescape the code in the preview <pre><code> element but doesn't sanitise in any other way. Please let me know if you have any other questions / suggestions.