refactoring

This commit is contained in:
Philipp Kühn
2021-03-16 22:22:13 +01:00
parent a76de1ab6d
commit 49fcf829f3
9 changed files with 91 additions and 55 deletions

View File

@@ -1,6 +1,9 @@
/* eslint-disable */
import React, { useState } from 'react'
import tippy from 'tippy.js'
import { useEditor, EditorContent, ReactRenderer, ReactNodeViewRenderer, NodeViewWrapper, NodeViewContent } from '@tiptap/react'
import {
useEditor, EditorContent, ReactRenderer, ReactNodeViewRenderer, NodeViewWrapper, NodeViewContent,
} from '@tiptap/react'
import { defaultExtensions } from '@tiptap/starter-kit'
import Heading from '@tiptap/extension-heading'
import Paragraph from '@tiptap/extension-paragraph'
@@ -127,13 +130,13 @@ const MenuBar = ({ editor }) => {
)
}
const MentionList = (props) => {
console.log({props})
const MentionList = props => {
console.log({ props })
return (
<div>
mentions
{props.items.map((item) => (
{props.items.map(item => (
<div>
{item}
</div>
@@ -174,7 +177,7 @@ export default () => {
Heading.extend({
draggable: true,
addNodeView() {
return ReactNodeViewRenderer((props) => {
return ReactNodeViewRenderer(props => {
return (
<NodeViewWrapper>
<div className="heading">
@@ -193,7 +196,7 @@ export default () => {
</NodeViewWrapper>
)
})
}
},
}),
Mention.configure({
suggestion: {
@@ -238,45 +241,45 @@ export default () => {
reactRenderer.destroy()
},
}
}
},
},
})
}),
],
content: `
<h1>heading</h1>
<h2>heading</h2>
<p>paragraph</p>
`,
// content: `
// <h2>
// Hi there,
// </h2>
// <p>
// this is a basic <em>basic</em> example of <strong>tiptap</strong>. Sure, there are all kind of basic text styles youd probably expect from a text editor. But wait until you see the lists:
// </p>
// <ul>
// <li>
// Thats a bullet list with one …
// </li>
// <li>
// … or two list items.
// </li>
// </ul>
// <p>
// Isnt that great? And all of that is editable. But wait, theres more. Lets try a code block:
// </p>
// <pre><code class="language-css">body {
// display: none;
// }</code></pre>
// <p>
// I know, I know, this is impressive. Its only the tip of the iceberg though. Give it a try and click a little bit around. Dont forget to check the other examples too.
// </p>
// <blockquote>
// Wow, thats amazing. Good work, boy! 👏
// <br />
// — Mom
// </blockquote>
// `,
// content: `
// <h2>
// Hi there,
// </h2>
// <p>
// this is a basic <em>basic</em> example of <strong>tiptap</strong>. Sure, there are all kind of basic text styles youd probably expect from a text editor. But wait until you see the lists:
// </p>
// <ul>
// <li>
// Thats a bullet list with one …
// </li>
// <li>
// … or two list items.
// </li>
// </ul>
// <p>
// Isnt that great? And all of that is editable. But wait, theres more. Lets try a code block:
// </p>
// <pre><code class="language-css">body {
// display: none;
// }</code></pre>
// <p>
// I know, I know, this is impressive. Its only the tip of the iceberg though. Give it a try and click a little bit around. Dont forget to check the other examples too.
// </p>
// <blockquote>
// Wow, thats amazing. Good work, boy! 👏
// <br />
// — Mom
// </blockquote>
// `,
})
return (