add new example, update content

This commit is contained in:
Hans Pagel
2020-10-30 16:13:47 +01:00
parent 4482ad00d5
commit e7c7ea16c7
16 changed files with 236 additions and 69 deletions

View File

@@ -11,6 +11,26 @@ import Document from '@tiptap/extension-document'
import Paragraph from '@tiptap/extension-paragraph'
import Text from '@tiptap/extension-text'
const CustomParagraph = Paragraph.extend({
addAttributes() {
return {
color: {
default: null,
parseHTML: element => {
return {
color: element.getAttribute('data-color'),
}
},
renderHTML: attributes => {
return {
style: `color: ${attributes.color}`,
}
},
},
}
},
})
export default {
components: {
EditorContent,
@@ -26,11 +46,11 @@ export default {
this.editor = new Editor({
extensions: [
Document(),
Paragraph(),
CustomParagraph(),
Text(),
],
content: `
<p>The Paragraph extension is not required, but its very likely you want to use it. Its needed to write paragraphs of text. 🤓</p>
<p data-color="blue">The Paragraph extension is not required, but its very likely you want to use it. Its needed to write paragraphs of text. 🤓</p>
`,
})
},