simple-code-editor icon indicating copy to clipboard operation
simple-code-editor copied to clipboard

Dont' see text highlight

Open pythonfortinero opened this issue 2 years ago • 8 comments

Hello. I'm testing the library in nuxt 2 (2.17.0) and I don't see the text, the text area is fine and the copy function is fine too, but the text is not visible I think the styles are not being applied, how can I fix it?

code:

Captura de pantalla 2023-08-10 a la(s) 12 47 17

pythonfortinero avatar Aug 10 '23 15:08 pythonfortinero

same

atheerweb avatar Aug 14 '23 11:08 atheerweb

same here

brunoosilva avatar Aug 22 '23 02:08 brunoosilva

same iss

vankhanhpr avatar Aug 27 '23 11:08 vankhanhpr

Same here. Anyone had any luck with a fix or alternative? This looks like the exact component I need!

neil-oliver avatar Aug 28 '23 01:08 neil-oliver

same

MarekNguyen avatar Sep 05 '23 07:09 MarekNguyen

same here

rohitasare7 avatar Oct 13 '23 06:10 rohitasare7

solved in vue 2

YourComponent.vue

this.getQuery() method return raw code

<CodeEditor value="" :languages="[['sql', 'SQL']]" :line-nums="true" :display-language="false" theme="vs" :copy-code="false" @textarea="setTextarea" width="100%" height="380px"></CodeEditor>

setTextarea(textarea) {
  this.textarea = textarea;
},
getQuery() {
  return this.textarea.value;
},

CodeEditor.vue

after

  directives: {
    highlight: {
      insert(el, binding) {
        el.textContent = binding.value;
        hljs.highlightElement(el);
      },
      update(el, binding) {
        if (el.scrolling) {
          el.scrolling = false;
        } else {
          delete el.dataset.highlighted;
          el.textContent = binding.value;
          hljs.highlightElement(el);
        }
      },
    },
  },

webgori avatar Oct 26 '23 06:10 webgori

I am using this as a workaround for Vue 3. I hope this helps:

Template/HTML

<CodeEditor v-model="markup" :line-nums="true" :languages="[['html', 'HTML']]" width="100%" font-size="16px" height="315px" border-radius="5px"></CodeEditor>

Script/JS (Just a v-model. Nothing special and not required.)

const markup = ref('')

Style/CSS

.code-editor .code-area > textarea::selection {
    /* Change to whatever color of text you need */
    color: #FFFFFF;
    /* Change to whatever background color you want (I am using Windows 11 default highlight color for Chrome here) */
    background-color: rgba(0, 116, 255, 0.8); 
}

This works for me as it doesn't remove the highlight.js color and only changes the color of user-selected text as it's being highlighted.

Sneaky1000 avatar Dec 27 '23 21:12 Sneaky1000