tiptap
A rich-text editor for Vue.js.
What means renderless
?
With renderless components you'll have (almost) full control over markup and styling. I don't want to tell you what a menu should look like or where it should be rendered in the DOM. That's all up to you. There is also a good article about renderless components by Adam Wathan.
How is the data stored under the hood?
You can save your data as a raw HTML
string or can get a JSON
-serializable representation of your document. And of course, you can pass these two types back to the editor.
Examples
To check out some live examples, visit tiptap.scrumpy.io.
Installation
npm install tiptap
or
yarn add tiptap
Basic Setup
Editor Properties
Property | Type | Default | Description |
---|---|---|---|
editable |
Boolean |
true |
When set to false the editor is read-only. |
doc |
Object |
null |
The editor state object used by Prosemirror. You can also pass HTML to the content slot. When used both, the content slot will be ignored. |
watchDoc |
Boolean |
true |
If set to true the content gets updated whenever doc changes. |
extensions |
Array |
[] |
A list of extensions used, by the editor. This can be Nodes , Marks or Plugins . |
@init |
Object |
undefined |
This will return an Object with the current state and view of Prosemirror on init. |
@update |
Object |
undefined |
This will return an Object with the current state of Prosemirror, a getJSON() and getHTML() function on every change. |
Scoped Slots
Name | Description |
---|---|
editor |
Here the content will be rendered. |
menubar |
Here a menu bar will be rendered. |
menububble |
Here a menu bubble will be rendered. |
Slot Properties
The menubar
and menububble
slot will receive some properties.
Property | Type | Description |
---|---|---|
nodes |
Object |
A list of available nodes with active state and command. |
marks |
Object |
A list of available marks with active state and command. |
focused |
Boolean |
Whether the editor is focused. |
focus |
Function |
A function to focus the editor. |
Extensions
By default, the editor will only support paragraphs. Other nodes and marks are available as extensions. There is a package called tiptap-extensions
with the most basic nodes, marks, and plugins.
Available Extensions
Create Custom Extensions
The most powerful feature of tiptap is that you can create your own extensions. There are 3 types of extensions.
Type | Description |
---|---|
Extension |
The most basic type. It's useful to register some Prosemirror plugins or some input rules. |
Node |
Add a custom node. Nodes are block elements like a headline or a paragraph. |
Mark |
Add a custom mark. Marks are used to add extra styling or other information to inline content like a strong tag or links. |
Extension Class
Method | Type | Default | Description |
---|---|---|---|
get name() |
String |
null |
Define a name for your extension. |
get defaultOptions() |
Object |
{} |
Define some default options. The options are available as this.$options . |
get plugins() |
Array |
[] |
Define a list of Prosemirror plugins. |
keys({ schema }) |
Object |
null |
Define some keybindings. |
inputRules({ schema }) |
Array |
[] |
Define a list of input rules. |
Node|Mark Class
Method | Type | Default | Description |
---|---|---|---|
get name() |
String |
null |
Define a name for your node or mark. |
get defaultOptions() |
Object |
{} |
Define some default options. The options are available as this.$options . |
get schema() |
Object |
null |
Define a schema. |
get view() |
Object |
null |
Define a node view as a vue component. |
keys({ type, schema }) |
Object |
null |
Define some keybindings. |
command({ type, schema, attrs }) |
Object |
null |
Define a command. This is used for menus to convert to this node or mark. |
inputRules({ type, schema }) |
Array |
[] |
Define a list of input rules. |
get plugins() |
Array |
[] |
Define a list of Prosemirror plugins. |
Create a Node
Let's take a look at a real example. This is basically how the default blockquote
node from tiptap-extensions
looks like.
Create a Node as a Vue Component
The real power of the nodes comes in combination with Vue components. Let us build an iframe node, where you can change its URL (this can also be found in our examples).
Building a Menu
This is a basic example of building a custom menu. A more advanced menu can be found at the examples page.
Development Setup
Currently, only Yarn is supported for development because of a feature called workspaces we are using here.