GithubHelp home page GithubHelp logo

Comments (22)

antonmedv avatar antonmedv commented on June 6, 2024

What browser?

from codejar.

mattduffield avatar mattduffield commented on June 6, 2024

In Chrome.

from codejar.

mattduffield avatar mattduffield commented on June 6, 2024

However when I play with the demo on the CodeJar website it works.
It only happens in my own code which is why I was thinking I might need some custom code...

from codejar.

antonmedv avatar antonmedv commented on June 6, 2024

Please show code.

from codejar.

mattduffield avatar mattduffield commented on June 6, 2024

Okay, I am uploading two screen shots....The first one will be when I click on the editor and try to add a line.....and then after....

Screen Shot 2021-01-26 at 4 34 06 PM
Screen Shot 2021-01-26 at 4 34 20 PM

from codejar.

mattduffield avatar mattduffield commented on June 6, 2024

It is a little hard to see but the cursor goes from the middle to the bottom....

from codejar.

mattduffield avatar mattduffield commented on June 6, 2024
    const editor = this.element.querySelector(".editor");
    const options = {tab: ' '.repeat(2)}
    const highlight = (editor) => {
      editor.textContent = editor.textContent
      hljs.highlightBlock(editor)
    }
    this.codejar = new CodeJar(editor, highlight, options);

    if (this.content) {
      this.codejar.updateCode(this.content);
    }

from codejar.

mattduffield avatar mattduffield commented on June 6, 2024

This is the code that sets up the editor....I am using HighlightJS.

from codejar.

mattduffield avatar mattduffield commented on June 6, 2024

Here is the HTML:

<div class="editor ${language}" contenteditable="true" spellcheck="false"></div>

The ${language} is rendered as language-html, etc.

from codejar.

antonmedv avatar antonmedv commented on June 6, 2024

Take a look at https://github.com/antonmedv/codejar/blob/master/index.html#L51-L56
And try:

  const highlight = editor => {
    // highlight.js does not trim old tags,
    // let's do it by this hack.
    editor.textContent = editor.textContent
    hljs.highlightBlock(editor)
  }

from codejar.

mattduffield avatar mattduffield commented on June 6, 2024

I am already doing that from code I provided.

from codejar.

antonmedv avatar antonmedv commented on June 6, 2024

Try to debug. Place debug point before restore call.

from codejar.

mattduffield avatar mattduffield commented on June 6, 2024

Okay, where is the restore call?
Is it this?

editor.textContent = editor.textContent

from codejar.

mattduffield avatar mattduffield commented on June 6, 2024

Okay, I have created a working example for you to look at. Try and interact with the editor and you will see the behavior I am talking about.

https://gist.dumber.app/?gist=2d92b9a716610764fe4d4a9210b5c388

from codejar.

mattduffield avatar mattduffield commented on June 6, 2024

The code to look at is in code-editor.js in the attached function. You will see that is where I am setting up CodeJar....

from codejar.

mattduffield avatar mattduffield commented on June 6, 2024

Okay, it appears that CodeJar doesn't support ShadowDOM. I have been testing by building web components with ShadowDOM turned on and the moment I turned it off, it seems to work fine.

It would be really nice to support this. It is very easy to detect this on an element checking for shadowRoot.

I would love to see this support get added!

from codejar.

antonmedv avatar antonmedv commented on June 6, 2024

Nice!

from codejar.

mattduffield avatar mattduffield commented on June 6, 2024

So, do you plan on supporting ShadowDOM?

from codejar.

mattduffield avatar mattduffield commented on June 6, 2024

I was able to modify the source code slightly to support ShadowDOM.

from codejar.

antonmedv avatar antonmedv commented on June 6, 2024

Please send PR.

from codejar.

mattduffield avatar mattduffield commented on June 6, 2024

Done. I updated the .gitignore in my version. Sorry about that.

from codejar.

claudebarde avatar claudebarde commented on June 6, 2024

I am running into the same issue myself with the editor inside a web component using the Shadow DOM. I hope the PR will be merged soon 😊

from codejar.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.