Closed almereyda closed 2 years ago
Hi @almereyda, Thanks for posting it!
I did try syntax highlighting in Schemio using highlightjs
but I decided to remove it. Here is the old commit https://github.com/ishubin/schemio/commit/6c3029974021b295d5c6065d2662cb642e8c70cf. I removed it because the resulting bundle was too large and the highlightjs was the top contributor to its size. I didn't want Schemio to become bloated (its js bundle is already 1.6 MB) and I thought that I could sacrifice syntax highlighting, since it wasn't considered the top feature anyway, yet was the heaviest part of Schemio.
I do want to bring syntax highlighting back to Schemio but I would rather do it dynamically and not be a part of js bundle. Lets keep this issue, but I want to make sure we try to implement it using a dynamic js loader (not sure how to achieve this yet, needs investigation)
I like the idea of not adding much more third parties to the bundle.
Maybe this can be optional, and the dependency would only be loaded via CDN at runtime, if a user chooses to do so?
I am thinking of adding something like a lazy JS loader. I could try to package highlightjs in the assets folder and then dynamically load the library as soon as code block is rendered in the document.
@almereyda I have implemented syntax highlighting using a javascript worker for background processing and dynamic loading of highlightjs lib. There is only one problem: due to the way text slots are handled in items, it will not work correctly on your old documents. You would have to clean up <p>
tags as that is what the in-place text editor from tiptap is adding for line breaks.
I only added two themes for now: dark and light.
This is so cool. It was easy to find the settings, and to set another language, if desired. Much wow, many thanks.
As a user of Schemio, I would like to present code blocks with syntax highlighting, in order to make understanding of the visual examples easier.
This could be implemented through hooking in Highlight.js
and have it optionally available through the Item's configuration tab through the right. A dropdown for choice of language can be helpful in determining the correct colouring scheme.