[RFC] Split markdown rendering to a separate package.#595
[RFC] Split markdown rendering to a separate package.#595ditman wants to merge 39 commits intogoogle:mainfrom
Conversation
ditman
left a comment
There was a problem hiding this comment.
I posted some comments to guide through the PR, and maybe start some discussions. PTAL!
There was a problem hiding this comment.
I don't understand why am I getting these .JSON updates, is my branch too old? Is this being updated off of master, instead of the contents of my branch?
Updating off of master sounds dangerous.
There was a problem hiding this comment.
This is the gist of the "integration" for Lit users, I think it turned out fairly simple, but still it's a breaking change with the previous version of the package, unfortunately.
| export class A2UILayoutEditor extends SignalWatcher(LitElement) { | ||
| @provide({ context: UI.Context.themeContext }) | ||
| accessor theme: v0_8.Types.Theme = uiTheme; | ||
| @provide({ context: UI.Context.theme }) |
There was a problem hiding this comment.
Renaming UI.Context.themeContext to UI.Context.theme is also a breaking change, but IMO it improves legibility a little bit (especially now that there's more than one inhabitant in the UI.Context namespace.
|
(Rebasing to resolve merge conflicts) |
6ac6fd5 to
ecf80b1
Compare
|
I had to tweak the build script task a little bit to ensure the new packages I added as path dependencies for the lit renderer are being built. |
|
I didn't go through all the code changes. Overall, I agree with the approach. nit: I see the default is noop. is it possible to make the default renderer capable to handle very basic markdown? So that it can be used out of box without a markdown provider? |
63cdbaa to
dc38cb6
Compare
@yuantian-agentspace I've made the NoopMarkdownRenderer a very very very simple MinimalMarkdownRenderer (you'll be familiar with it :P). It also warns programmers the first time it's used, pointing them to the more fully-featured one. |
dc38cb6 to
e07cef8
Compare
…o the noop version.
…enderer dependencies.
e07cef8 to
cffb557
Compare
|
I've added the Angular integration that allows for DI, and removed the |
jacobsimionato
left a comment
There was a problem hiding this comment.
This looks super neat!
I think my main concern here is just that it adds a lot of boilerplate.
Another option here might be for us to focus on separating the standard catalog from the central renderer, and also breaking down catalogs into freestanding component implementations which are composed together into a catalog.
That way, Google internal customers could import the code and just fork the "Text" Component implementation, and the BasicCatalog definition, substituting it with a different implementation of Text, with a different Markdown dependency. I think that might be neater overall rather than us needing to formalize the concept of a Markdown renderer in this way.
It's a bit of a hack, because we'd still import all the code and then just have BUILD rule that excludes the sources with the unwanted dependency, but maybe simpler overall?
All that said, I'm still happy to land this, and maybe it's still beneficial. I don't understand the markdown rendering landscape across the industry and whether people have strong opinions or specific needs which make this injection approach valuable!
There was a problem hiding this comment.
I wonder if it makes sense for us to not include this, just so that it's less code to maintain. I think that having a partial implementation of Markdown could ultimately be frustrating for developers, and it shouldn't be too hard to wire up a real markdown renderer.
Important
This PR is too big to land in one go, but luckily we can land this in stages quite easily by landing the
markdown-it-*packages first, and then the modifications to the renderers and samples. That also gives us some time to figure out how to publish themarkdown-it-*packages automatically without the pressure of them being "depended on", or needed within G3.Description
This PR separates the
markdown-itdependency from thelitrenderer, by allowing users to@providea markdown renderer of their own.BREAKING CHANGE: By default, now incoming markdown is rendered as a
preelement, and users must inject a markdown renderer of their choosing for markdown to be rendered (see below).In order to keep the "batteries" somewhat included in the sdk, a couple of new packages are introduced:
@a2ui/markdown-it-shared: the pre-configuredmarkdown-itinstance for all web renderers. This allows us to have a single configured markdown renderer withmarkdown-itanddompurify(TBD) that can be reused across all packages. This is pretty much a markdown string -> html string converter, but if we want to add plugins tomarkdown-itlater, all packages get the new output at once.@a2ui/markdown-it-lit: the bridge package between thelitrenderer andmarkdown-it-shared. This is what people will use when using thelitrenderer to@providethemarkdownrenderer. They can also use this package as a jumping off point to create their own markdown renderer, if they prefer anything else other thanmarkdown-it.@a2ui/markdown-it-angular: the bridge package between theangularrenderer andmarkdown-it-shared. This package provides aMarkdownItMarkdownRendererclass that canprovide: MarkdownRenderer.The
litsamples, and theangularrestaurant sample are updated to inject the new markdown renderer.Fixes
Tests
Pre-launch Checklist
If you need help, consider asking for advice on the discussion board.