- Hey, try to select some text here. There will popup a menu for selecting some inline styles. Remember: you have full control about content and styling of this menu.
+ Try to select this text to see what we call the bubble menu.
+
+
+ Neat, isn’t it? Add an empty paragraph to see the floating menu.
- Hey, try to select some text here. You’ll see a formatting menu pop up. And as always, you are in full control about content and styling of this menu.
+ Try to select this text to see what we call the bubble menu.
+
+
+ Neat, isn’t it? Add an empty paragraph to see the floating menu.
- This is an example of a medium-like editor. Enter a new line and some buttons will appear.
+ This is an example of a Medium-like editor. Enter a new line and some buttons will appear.
- This is an example of a medium-like editor. Enter a new line and some buttons will appear.
+ This is an example of a Medium-like editor. Enter a new line and some buttons will appear.
+
`,
})
},
diff --git a/docs/src/docPages/api/commands.md b/docs/src/docPages/api/commands.md
index 4419036a..18e723c9 100644
--- a/docs/src/docPages/api/commands.md
+++ b/docs/src/docPages/api/commands.md
@@ -31,6 +31,26 @@ In the example above two different commands are executed at once. When a user cl
All chained commands are kind of queued up. They are combined to one single transaction. That means, the content is only updated once, also the `update` event is only triggered once.
+#### Chaining inside custom commands
+When chaining a command, the transaction is held back. If you want to chain commands inside your custom commands, you’ll need to use said transaction and add to it. Here is how you would do that:
+
+```js
+addCommands() {
+ return {
+ insertTimecode: attributes => ({ chain }) => {
+ // Doesn’t work:
+ // return editor.chain() …
+
+ // Does work:
+ return chain()
+ .insertNode('timecode', attributes)
+ .insertText(' ')
+ .run()
+ },
+ }
+}
+```
+
### Inline commands
In some cases, it’s helpful to put some more logic in a command. That’s why you can execute commands in commands. I know, that sounds crazy, but let’s look at an example:
@@ -208,9 +228,26 @@ this.editor
.createParagraphNear()
.insertHTML('')
.run()
-``` -->
+```
-## Add your own commands
+Add a custom command to insert a node.
+```js
+addCommands() {
+ return {
+ insertTimecode: attributes => ({ chain }) => {
+ return chain()
+ .focus()
+ .insertNode('timecode', attributes)
+ .insertText(' ')
+ .run();
+ },
+ }
+},
+```
+-->
+
+## Add custom commands
All extensions can add additional commands (and most do), check out the specific [documentation for the provided nodes](/api/nodes), [marks](/api/marks), and [extensions](/api/extensions) to learn more about those.
Of course, you can [add your custom extensions](/guide/build-extensions) with custom commands aswell.
+
diff --git a/docs/src/docPages/api/concept.md b/docs/src/docPages/api/concept.md
index 920750ca..4d26a5eb 100644
--- a/docs/src/docPages/api/concept.md
+++ b/docs/src/docPages/api/concept.md
@@ -23,3 +23,4 @@ ProseMirror has its own vocabulary and you’ll stumble upon all those words now
| Node | Adds blocks, like heading, paragraph. |
| Mark | Adds inline formatting, for example bold or italic. |
| Command | Execute an action inside the editor, that somehow changes the state. |
+| Decoration | Styling on top of the document, for example to highlight mistakes. |
diff --git a/docs/src/docPages/api/editor.md b/docs/src/docPages/api/editor.md
index 755d821a..616c66d0 100644
--- a/docs/src/docPages/api/editor.md
+++ b/docs/src/docPages/api/editor.md
@@ -5,8 +5,30 @@
## Introduction
This class is a central building block of tiptap. It does most of the heavy lifting of creating a working [ProseMirror](https://ProseMirror.net/) editor such as creating the [`EditorView`](https://ProseMirror.net/docs/ref/#view.EditorView), setting the initial [`EditorState`](https://ProseMirror.net/docs/ref/#state.Editor_State) and so on.
-## List of available settings
-Check out the API documentation to see [all available options](/api/editor/).
+## Methods
+The editor instance will provide a bunch of public methods. They’ll help you to work with the editor.
+
+Don’t confuse methods with [commands](/api/commands). Commands are used to change the state of editor (content, selection, and so on) and only return `true` or `false`. Methods are regular functions and can return anything.
+
+| Method | Parameters | Description |
+| --------------------- | ----------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------- |
+| `can()` | - | Check if a command or a command chain can be executed. Without executing it. |
+| `chain()` | - | Create a command chain to call multiple commands at once. |
+| `createDocument()` | `content` EditorContent `parseOptions` | Creates a ProseMirror document. |
+| `destroy()` | – | Stops the editor instance and unbinds all events. |
+| `getHTML()` | – | Returns the current content as HTML. |
+| `getJSON()` | – | Returns the current content as JSON. |
+| `getMarkAttributes()` | `name` Name of the mark | Get attributes of the currently selected mark. |
+| `getNodeAttributes()` | `name` Name of the node | Get attributes of the currently selected node. |
+| `isActive()` | `name` Name of the node or mark `attrs` Attributes of the node or mark | Returns if the currently selected node or mark is active. |
+| `isEditable()` | - | Returns whether the editor is editable. |
+| `isEmpty()` | - | Check if there is no content. |
+| `getCharacterCount()` | - | Get the number of characters for the current document. |
+| `registerPlugin()` | `plugin` A ProseMirror plugin `handlePlugins` Control how to merge the plugin into the existing plugins. | Register a ProseMirror plugin. |
+| `setOptions()` | `options` A list of options | Update editor options. |
+| `unregisterPlugin()` | `name` The plugins name | Unregister a ProseMirror plugin. |
+
+## Settings
### Element
The `element` specifies the HTML element the editor will be binded too. The following code will integrate tiptap with an element with the `.element` class:
@@ -147,37 +169,28 @@ new Editor({
})
```
-
+### Editor props
+For advanced use cases, you can pass `editorProps` which will be handled by [ProseMirror](https://prosemirror.net/docs/ref/#view.EditorProps). Here is an example how you can pass a few [Tailwind](https://tailwindcss.com/) classes to the editor container, but there is a lot more you can do.
-## List of available methods
-An editor instance will provide the following public methods. They’ll help you to work with the editor.
+```js
+new Editor({
+ // Learn more: https://prosemirror.net/docs/ref/#view.EditorProps
+ editorProps: {
+ attributes: {
+ class: 'prose prose-sm sm:prose lg:prose-lg xl:prose-2xl mx-auto focus:outline-none',
+ }
+ },
+})
+```
-Don’t confuse methods with [commands](/api/commands), which are used to change the state of editor (content, selection, and so on) and only return `true` or `false`.
+### Parse options
+Passed content is parsed by ProseMirror. To hook into the parsing, you can pass `parseOptions` which are then handled by [ProseMirror](https://prosemirror.net/docs/ref/#model.ParseOptions).
-| Method | Parameters | Description |
-| --------------------- | ----------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------- |
-| `can()` | - | Check if a command or a command chain can be executed. Without executing it. |
-| `chain()` | - | Create a command chain to call multiple commands at once. |
-| `createDocument()` | `content` EditorContent `parseOptions` | Creates a ProseMirror document. |
-| `destroy()` | – | Stops the editor instance and unbinds all events. |
-| `getHTML()` | – | Returns the current content as HTML. |
-| `getJSON()` | – | Returns the current content as JSON. |
-| `getMarkAttributes()` | `name` Name of the mark | Get attributes of the currently selected mark. |
-| `getNodeAttributes()` | `name` Name of the node | Get attributes of the currently selected node. |
-| `isActive()` | `name` Name of the node or mark `attrs` Attributes of the node or mark | Returns if the currently selected node or mark is active. |
-| `isEditable()` | - | Returns whether the editor is editable. |
-| `isEmpty()` | - | Check if there is no content. |
-| `getCharacterCount()` | - | Get the number of characters for the current document. |
-| `registerPlugin()` | `plugin` A ProseMirror plugin `handlePlugins` Control how to merge the plugin into the existing plugins. | Register a ProseMirror plugin. |
-| `setOptions()` | `options` A list of options | Update editor options. |
-| `unregisterPlugin()` | `name` The plugins name | Unregister a ProseMirror plugin. |
+```js
+new Editor({
+ // Learn more: https://prosemirror.net/docs/ref/#model.ParseOptions
+ parseOptions: {
+ preserveWhitespace: 'full',
+ },
+})
+```
diff --git a/docs/src/docPages/api/extensions/collaboration-cursor.md b/docs/src/docPages/api/extensions/collaboration-cursor.md
index 271b584a..5c2b0f21 100644
--- a/docs/src/docPages/api/extensions/collaboration-cursor.md
+++ b/docs/src/docPages/api/extensions/collaboration-cursor.md
@@ -41,5 +41,5 @@ This extension requires the [`Collaboration`](/api/extensions/collaboration) ext
The content of this editor is shared with other users.
:::
-
+
diff --git a/docs/src/docPages/api/extensions/collaboration.md b/docs/src/docPages/api/extensions/collaboration.md
index ed1365dd..6954c883 100644
--- a/docs/src/docPages/api/extensions/collaboration.md
+++ b/docs/src/docPages/api/extensions/collaboration.md
@@ -48,5 +48,5 @@ yarn add @tiptap/extension-collaboration yjs y-websocket
:::warning Public
The content of this editor is shared with other users.
:::
-
+
diff --git a/docs/src/docPages/api/nodes/code-block-lowlight.md b/docs/src/docPages/api/nodes/code-block-lowlight.md
new file mode 100644
index 00000000..97fc8537
--- /dev/null
+++ b/docs/src/docPages/api/nodes/code-block-lowlight.md
@@ -0,0 +1,7 @@
+# CodeBlockLowlight
+
+:::pro Fund the development ♥
+We need your support to maintain, update, support and develop tiptap 2. If you’re waiting for this extension, [become a sponsor and fund our work](/sponsor).
+:::
+
+TODO
diff --git a/docs/src/docPages/api/nodes/code-block.md b/docs/src/docPages/api/nodes/code-block.md
index caba885e..646ff68b 100644
--- a/docs/src/docPages/api/nodes/code-block.md
+++ b/docs/src/docPages/api/nodes/code-block.md
@@ -7,7 +7,7 @@ With the CodeBlock extension you can add fenced code blocks to your documents. I
Type ``` (three backticks and a space) or ∼∼∼ (three tildes and a space) and a code block is instantly added for you. You can even specify the language, try writing ```css . That should add a `language-css` class to the ``-tag.
::: warning Restrictions
-The CodeBlock extension doesn’t come with styling and has no syntax highlighting built-in. It’s on our roadmap though.
+The CodeBlock extension doesn’t come with styling and has no syntax highlighting built-in. It’s [on our roadmap](/api/nodes/code-block-lowlight) though.
:::
## Installation
diff --git a/docs/src/docPages/guide/content.md b/docs/src/docPages/guide/content.md
index cb23bc28..2d68bc80 100644
--- a/docs/src/docPages/guide/content.md
+++ b/docs/src/docPages/guide/content.md
@@ -40,7 +40,7 @@ editor.commands.setContent({
Here is an interactive example where you can see that in action:
-
+
### Option 2: HTML
HTML can be easily rendered in other places, for example in emails and it’s wildly used, so it’s probably easier to switch the editor at some point. Anyway, every editor instance provides a method to get HTML from the current document:
@@ -64,7 +64,7 @@ editor.commands.setContent(`
Example Text
`)
Use this interactive example to fiddle around:
-
+
### Option 3: Y.js
Our editor has amazing support for Y.js, which is amazing to add [realtime collaboration, offline editing, or syncing between devices](/guide/collaborative-editing).
diff --git a/docs/src/docPages/guide/menus.md b/docs/src/docPages/guide/menus.md
new file mode 100644
index 00000000..16cd8825
--- /dev/null
+++ b/docs/src/docPages/guide/menus.md
@@ -0,0 +1,115 @@
+# Create menus
+
+## toc
+
+## Introduction
+tiptap comes very raw, but that’s a good thing. You have full control (and when we say full, we mean full) about the appearance of it. That also means you can (and have to) build a menu on your own. You can start with a few buttons, and we help you to wire everything up.
+
+## Menus
+The editor provides a fluent API to trigger commands and add active states. You can use any markup you like. To make the positioning of line menus easier, we provide a few utilities and components. Let’s go through the most typical use cases one by one.
+
+### Fixed menu
+A fixed menu, for example on top of the editor, can be anything. We don’t provide such menu. Just add a `