Coder Social home page Coder Social logo

Comments (7)

antonmedv avatar antonmedv commented on June 4, 2024

I think this is unrelated to codejar. CodeJar is code editor. Html generation should be done by your highligting function.

from codejar.

stepancheg avatar stepancheg commented on June 4, 2024

CodeJar modifies style attributes of existing HTML, so to replicate initial rendering, a part of CodeJar sources would need to be copied into client code. But as you say...

from codejar.

antonmedv avatar antonmedv commented on June 4, 2024

CodeJar modifies it only on user triggered events. I think you should take better look at docs and/or source code. If you need SSR proceed with your highlight func, codejar is obsolete on server.

from codejar.

stepancheg avatar stepancheg commented on June 4, 2024

CodeJar also modifies style on initialization: here.

from codejar.

antonmedv avatar antonmedv commented on June 4, 2024

Yes, true. I forgot about it.

from codejar.

cheuksing avatar cheuksing commented on June 4, 2024

I don't think this makes any sense, it has no reason to init code-jar during SSR.
The purpose of the editor is handling user events and this only happens on the client-side.

During SSR, if you want to highlight your code block, just use highlight.js and sent the pre-processed HTML to the client.
If you use prism.js, it doesn't work in a server environment and you need node-prism.js.

In the script @stepancheg mentioned, code-jar detects client browser to apply a suitable style, with a browser-only API.
Although the user can pass the HTML request header to code-jar during initialization, this makes things very complex.

I think a better and cleaner approach is to render a placeholder in serverside and initialize code-jar and highlight codes in clientside.

from codejar.

stepancheg avatar stepancheg commented on June 4, 2024

I think a better and cleaner approach is to render a placeholder in serverside

That's exactly what I would want.

highlight codes in clientside.

We could also highlight code on the server-side too (to avoid page blinking at client page rerender), but that's a lesser issue.

code-jar detects client browser to apply a suitable style

As far as I see, the only difference between browsers is contentEditable attribute, which does not affect rendering.

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.