a few minor improvements to the content

This commit is contained in:
Hans Pagel
2020-09-24 15:58:40 +02:00
parent 299ca72f3e
commit 2848b814b6
4 changed files with 18 additions and 33 deletions

View File

@@ -11,30 +11,26 @@ import Text from '@tiptap/extension-text'
export default {
data() {
return {
doc: {
json: {
type: 'document',
content: [{
type: 'paragraph',
attrs: {
align: 'left',
},
content: [{
type: 'text',
text: 'Example Text',
}],
}],
},
html: '',
}
},
computed: {
html() {
return generateHtml(this.doc, [
mounted() {
this.html = generateHtml(this.json, [
Document(),
Paragraph(),
Text(),
])
},
},
}
</script>

View File

@@ -71,3 +71,9 @@ class Text extends Node {
}
}
```
## Difference between a Node and a Mark
*Nodes* are like blocks of content, for example paragraphs, headlines, code blocks, blockquotes and many more.
*Marks* can apply a different style to specific parts of text inside a *Node*. Thats the case for **bold**, *italic* or ~~striked~~ text. [Links](#) are *Marks*, too.

View File

@@ -2,11 +2,13 @@
If you need to render the content on the server side, e. g. for a blog post that was written with tiptap, youll probably need a way to do just that without an actual editor instance.
Thats what `generateHtml()` is for. Its a utility function that renders HTML without an actual editor instance.
:::warning Work in progress
Currently, that works only in the browser (client side), but were working on making this available to Node.js (to use it on the server side).
Currently, that works only in the browser (client side), but we plan to bring this to Node.js (to use it on the server side).
:::
<demo name="Api/Schema" />
<demo name="Api/Schema/GenerateHtml" highlight="6,29-33"/>
## Converting JSON<>HTML with PHP

View File

@@ -25,22 +25,3 @@ Note that `Document`, `Paragraph` and `Text` are required. Otherwise you wont
<demo name="Guide/BuildYourEditor" highlight="10-13,30-33" />
Thats also the place where you can register custom extensions, which you or someone else built for tiptap.
### Related links
* [List of available commands](/api/commands)
* [List of available extensions](/api/extensions)
* Build custom extensions
## Difference between nodes and marks
tiptap used a JSON schema under the hood. Every part of the text is stored as a specific type. There is a `Document` type (its needed, but invisible  like the `<body>` in HTML).
*Nodes* are like blocks of content, for example a paragraph or a headline. Yes, this paragraph is a node.
*Marks* can apply a different style to parts of text inside a node. A good example is **bold text**. Thats a mark. *Italic*, `inline code` or [links](#) are marks too.
### Related links
* [Learn more about the schema](/api/schema)
* [List of available extensions](/api/extensions)