Very often, they handle a few cases in some of these functions and fall back to the default behavior for the rest. They take a Slate editor, override whatever functions they need to override and return the modified editor back. ![]() tells slate that certain nodes are inline and should flow with text, like // the link in our example aboveīy convention, their names start with with. tells slate that certain nodes don't have any text content (they're _void_) // super handy for stuff like images and diagrams do something interesting! normalizeNode(entry) we'll dedicate a whole post to this one, but the gist is that it's used // to enforce your own custom schema to the document JSON do something interesting! insertData(data) called when the users pastes or drags things into the editor do something interesting! insertText(text) called whenever text is inserted into the document (e.g. Slate uses a very simple JSON format for representing documents, and the document above would look like this in Slate’s representation: [ = editor Here’s an annotated screenshot of a Slate editor to explain these concepts visually: Marks - annotations placed on the text, such as marking text as bold or italicĪstute readers will notice that this is structured very similar to the DOM, and text, block and inlines in Slate behave very much like their counterparts in the DOM.Text nodes - these contain the actual text in the document.Inline elements - special elements that flow inline with the text of your document, like links.These are the things you can draw horizontal lines between in your document Block level elements - the domain-specific “chunks” that make up your documents, like paragraphs, code blocks and lists.Editor - the top level container of your document.One of the best parts of Slate is how it holds very few opinions about how documents are structured. It has a thriving community, particularly on Slack.We really like the philosophy behind it.It lays the foundation for collaborative editing which is something we believe is important for Kitemaker. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |