Thinkmill / keystatic

First class CMS experience, TypeScript API, Markdown & YAML/JSON based, no DB
https://keystatic.com
MIT License
1.23k stars 79 forks source link

Document custom blocks #213

Open airtonix opened 1 year ago

airtonix commented 1 year ago

Keystatic should aim to support at its core the ability to add our own field (and collection types if that can be done)

Coming from TheOtherPopularPlatform™️ , people would probably expect it to be able to:

additionally, (and seperately)

Something that didn't make sense to me from TheOtherPopularPlatform™️ was

JedWatson commented 1 year ago

Hey @airtonix thanks for all the feedback, both here and in other issues. We'll get through them individually in the near future and reply to all of it.

On this specific one, the gap is just docs 🙂

(it's probably worth leaving this issue open until those docs are ready though)

In terms of custom field types; all the built-in field functions are just first party implementations of things you can do in user land. Each field type defines how the data is serialised and deserialised, the storage type, and the UI. So all of them can be replaced (or entirely new ones created) in a project without needing any changes in Keystatic.

And in terms of plugins for the WYSIWYG editor, that's also in place, although we are planning some things to make it easier to build your own (including high level components for things like floating toolbars, etc)

The editor is a modified version of the one we built for KeystoneJS, you can see a demo with proper documentation here: https://keystonejs.com/docs/guides/document-field-demo

Basically, you can define as many component types as you like with fields (conceptually very similar to writing a react component and specifying prop types), and either go with the default or provide your own custom component to render the preview, even disabling the default UI in favour of your own (we call this "chromeless" mode)

I'll update here when we have better examples + docs online of how to use all of this, in the meantime please keep the suggestions coming!

Thanks

JPrisk commented 1 year ago

Hey @airtonix, although not perfect - here is an example implementation of a custom colour picker https://github.com/Thinkmill/keystatic-starter-portfolio/pull/1/files