Intro To Plate
Current version of Plate in tinacms v36
In our current iteration of Plate as of writing this we are 4 major versions behind.
This Document will need to be updated after we upgrade to the latest version as Plate has changed a lot of how its api is being used.
Read Before Working on Plate
Before we talk about Plate, lets first talk about Slate. I highly recommend giving the following a closer look if you are planning on working on anything Plate. As a lot of this is the absolute core to what Plate is wrapping and what we will be interacting with.
1. Slate Nodes
Are the most important types and make up the core of working with Slate & Plate.
- A root-level
Editornode that contains the entire document's content. - Container
Elementnodes that have semantic meaning in your domain. - And leaf-level
Textnodes which contain the document's text.
These three interfaces are combined to form a tree—just like the DOM.
children: [
{
type: 'paragraph',
children: []
}2. Slate Editor
All of the behaviors, content and state of a Slate editor is rolled up into a single, top-level Editor object.
The Editor has a children property which contains the document tree of nodes that make up the editor's content.
Think of this as the root of everything in the Rich Text Editor (In Tinacms)
3. Slate Element
Element objects are a type of Node in a Slate document that contain other Element nodes or Text nodes.
interface Element {
children: Node[]
}Block vs. Inline
- "block" or "inline" as defined by
editor.isInline
A "block" element can only be siblings with other "block" elements. An "inline" node can be siblings with Text nodes or other "inline" elements.
Void vs Not Void
- "void" or "not void" as defined by
editor.isVoid
In a not "void" element, Slate handles the rendering of its children (e.g. in a paragraph where the Text and Inline children are rendered by Slate). In a "void" element, the children are rendered by the Element's render code.
Plate
Now we've read up on Slate, lets have a look at what Tinacms is using, Plate.
When working with Plate + Rich Text in Tinacms, We can split the work into 5 sections.
- Plugins
- Components
- Parse/Stringify
- Toolbar
- TinaMarkdown
Plugins
Plugins are at the core of Plate, they are what define that a code_block turns into a component that the end user can see.
There are a few concepts that you will need to get familiar with when working with Plate & Tinacms.
First, a Node - A node is internal to Slate