update docs

This commit is contained in:
Philipp Kühn
2020-11-16 10:03:12 +01:00
parent c87f49c1fe
commit dac2434cd3
6 changed files with 69 additions and 69 deletions

View File

@@ -23,20 +23,20 @@ You dont have to use it, but we prepared a `@tiptap/vue-starter-kit` which in
Youre free to create your own extensions for tiptap. Here is the boilerplate code thats need to create and register your own extension:
```js
import { createExtension } from '@tiptap/core'
import { Extension } from '@tiptap/core'
const CustomExtension = createExtension({
const CustomExtension = Extension.create({
// Your code here
})
const editor = new Editor({
extensions: [
// Register your custom extension with the editor.
CustomExtension(),
CustomExtension,
// … and dont forget all other extensions.
Document(),
Paragraph(),
Text(),
Document,
Paragraph,
Text,
// …
],
```
@@ -49,7 +49,7 @@ ProseMirror has a fantastic eco system with many amazing plugins. If you want to
```js
import { history } from 'prosemirror-history'
const History = createExtension({
const History = Extension.create({
addProseMirrorPlugins() {
return [
history(),

View File

@@ -38,15 +38,15 @@ In tiptap every node, mark and extension is living in its own file. This allows
```js
// the tiptap schema API
import { createNode } from '@tiptap/core'
import { NodeExtension } from '@tiptap/core'
const Document = createNode({
const Document = NodeExtension.create({
name: 'document',
topNode: true,
content: 'block+',
})
const Paragraph = createNode({
const Paragraph = NodeExtension.create({
name: 'paragraph',
group: 'block',
content: 'inline*',
@@ -55,12 +55,12 @@ const Paragraph = createNode({
{ tag: 'p' },
]
},
renderHTML({ attributes }) {
return ['p', attributes, 0]
renderHTML({ HTMLAttributes }) {
return ['p', HTMLAttributes, 0]
},
})
const Text = createNode({
const Text = NodeExtension.create({
name: 'text',
group: 'inline',
})
@@ -79,7 +79,7 @@ Marks can be applied to specific parts of a node. Thats the case for **bold**
The content attribute defines exactly what kind of content the node can have. ProseMirror is really strict with that. That means, content which doesnt fit the schema is thrown away. It expects a name or group as a string. Here are a few examples:
```js
createNode({
NodeExtension.create({
// must have one ore more blocks
content: 'block+',
@@ -99,7 +99,7 @@ createNode({
You can define which marks are allowed inside of a node with the `marks` setting of the schema. Add a one or more names or groups of marks, allow all or disallow all marks like this:
```js
createNode({
NodeExtension.create({
// allows only the 'bold' mark
marks: 'bold',
@@ -118,7 +118,7 @@ createNode({
Add this node to a group of extensions, which can be referred to in the [content](#content) attribute of the schema.
```js
createNode({
NodeExtension.create({
// add to 'block' group
group: 'block',
@@ -134,7 +134,7 @@ createNode({
Nodes can be rendered inline, too. When setting `inline: true` nodes are rendered in line with the text. Thats the case for mentions. The result is more like a mark, but with the functionality of a node. One difference is the resulting JSON document. Multiple marks are applied at once, inline nodes would result in a nested structure.
```js
createNode({
NodeExtension.create({
// renders nodes in line with the text, for example
inline: true,
})
@@ -144,7 +144,7 @@ createNode({
Nodes with `atom: true` arent directly editable and should be treated as a single unit. Its not so likely to use that in a editor context, but this is how it would look like:
```js
createNode({
NodeExtension.create({
atom: true,
})
```
@@ -153,7 +153,7 @@ createNode({
Besides the already visible text selection, there is an invisible node selection. If you want to make your nodes selectable, you can configure it like this:
```js
createNode({
NodeExtension.create({
selectable: true,
})
```
@@ -162,7 +162,7 @@ createNode({
All nodes can be configured to be draggable (by default they arent) with this setting:
```js
createNode({
NodeExtension.create({
draggable: true,
})
```
@@ -171,7 +171,7 @@ createNode({
Users expect code to behave very differently. For all kind of nodes containing code, you can set `code: true` to take this into account.
```js
createNode({
NodeExtension.create({
code: true,
})
```
@@ -182,7 +182,7 @@ Nodes get dropped when their entire content is replaced (for example, when pasti
Typically, that applies to [`Blockquote`](/api/node/blockquote), [`CodeBlock`](/api/node/code-block), [`Heading`](/api/node/heading), and [`ListItem`](/api/node/list-item).
```js
createNode({
NodeExtension.create({
defining: true,
})
```
@@ -191,7 +191,7 @@ createNode({
For nodes that should fence the cursor for regular editing operations like backspacing, for example a TableCell, set `isolating: true`.
```js
createNode({
NodeExtension.create({
isolating: true,
})
```
@@ -201,7 +201,7 @@ createNode({
If you dont want the mark to be active when the cursor is at its end, set inclusive to `false`. For example, thats how its configured for [`Link`](/api/marks/link) marks:
```js
createMark({
MarkExtension.create({
inclusive: false,
})
```
@@ -210,7 +210,7 @@ createMark({
By default all nodes can be applied at the same time. With the excludes attribute you can define which marks must not coexist with the mark. For example, the inline code mark excludes any other mark (bold, italic, and all others).
```js
createMark({
MarkExtension.create({
// must not coexist with the bold mark
excludes: 'bold'
// exclude any other mark
@@ -222,7 +222,7 @@ createMark({
Add this mark to a group of extensions, which can be referred to in the content attribute of the schema.
```js
createMark({
MarkExtension.create({
// add this mark to the 'basic' group
group: 'basic',
// add this mark to the 'basic' and the 'foobar' group
@@ -234,7 +234,7 @@ createMark({
Users expect code to behave very differently. For all kind of marks containing code, you can set `code: true` to take this into account.
```js
createMark({
MarkExtension.create({
code: true,
})
```
@@ -243,7 +243,7 @@ createMark({
By default marks can span multiple nodes when rendered as HTML. Set `spanning: false` to indicate that a mark must not span multiple nodes.
```js
createMark({
MarkExtension.create({
spanning: false,
})
```
@@ -262,9 +262,9 @@ import Text from '@tiptap/extension-text'
const editor = new Editor({
extensions: [
Document(),
Paragraph(),
Text(),
Document,
Paragraph,
Text,
// add more extensions here
])
})
@@ -282,9 +282,9 @@ import Paragraph from '@tiptap/extension-paragraph'
import Text from '@tiptap/extension-text'
const schema = getSchema([
Document(),
Paragraph(),
Text(),
Document,
Paragraph,
Text,
// add more extensions here
])
```