refactoring

This commit is contained in:
Philipp Kühn 2021-12-16 14:06:35 +01:00
parent 2436e2c8fe
commit 38109831c6
15 changed files with 208 additions and 246 deletions

View File

@ -5,10 +5,6 @@ import { content } from '../content.js'
import './styles.scss'
const MenuBar = ({ editor }) => {
if (!editor) {
return null
}
return (
<>
<button

View File

@ -1,5 +1,4 @@
<template>
<div>
<div v-if="editor">
<button @click="editor.chain().focus().toggleBold().run()" :class="{ 'is-active': editor.isActive('bold') }">
bold
@ -66,7 +65,6 @@
</button>
</div>
<editor-content :editor="editor" />
</div>
</template>
<script>

View File

@ -16,10 +16,6 @@ import lowlight from 'lowlight'
import './styles.scss'
const MenuBar = ({ editor }) => {
if (!editor) {
return null
}
return (
<button onClick={() => editor.chain().focus().toggleCodeBlock().run()} className={editor.isActive('codeBlock') ? 'is-active' : ''}>
code block

View File

@ -3,9 +3,8 @@
<button @click="editor.chain().focus().toggleCodeBlock().run()" :class="{ 'is-active': editor.isActive('codeBlock') }">
code block
</button>
<editor-content :editor="editor" />
</div>
<editor-content :editor="editor" />
</template>
<script>

View File

@ -1,5 +1,4 @@
<template>
<div>
<editor-content :editor="editor" />
<div v-if="editor" :class="{'character-count': true, 'character-count--warning': editor.storage.characterCount.characters() === limit}">
@ -37,7 +36,6 @@
{{ editor.storage.characterCount.characters() }}/{{ limit }} characters
</div>
</div>
</div>
</template>
<script>

View File

@ -4,10 +4,6 @@ import StarterKit from '@tiptap/starter-kit'
import './styles.scss'
const MenuBar = ({ editor }) => {
if (!editor) {
return null
}
return (
<>
<button

View File

@ -1,5 +1,4 @@
<template>
<div>
<div v-if="editor">
<button @click="editor.chain().focus().toggleBold().run()" :class="{ 'is-active': editor.isActive('bold') }">
bold
@ -66,7 +65,6 @@
</button>
</div>
<editor-content :editor="editor" />
</div>
</template>
<script>

View File

@ -1,7 +1,5 @@
<template>
<div v-if="editor">
<editor-content :editor="editor" />
</div>
</template>
<script>

View File

@ -6,10 +6,6 @@ import Highlight from '@tiptap/extension-highlight'
import './styles.scss'
const MenuBar = ({ editor }) => {
if (!editor) {
return null
}
return (
<>
<button onClick={() => editor.chain().focus().toggleHeading({ level: 1 }).run()} className={editor.isActive('heading', { level: 1 }) ? 'is-active' : ''}>

View File

@ -1,5 +1,4 @@
<template>
<div>
<div v-if="editor">
<button @click="editor.chain().focus().toggleHeading({ level: 1 }).run()" :class="{ 'is-active': editor.isActive('heading', { level: 1 }) }">
h1
@ -39,7 +38,6 @@
</button>
</div>
<editor-content :editor="editor" />
</div>
</template>
<script>

View File

@ -3,8 +3,8 @@
<button @click="addImage">
add image from URL
</button>
<editor-content :editor="editor" />
</div>
<editor-content :editor="editor" />
</template>
<script>

View File

@ -1,10 +1,9 @@
<template>
<div>
<div v-if="editor">
<bubble-menu
class="bubble-menu"
:tippy-options="{ duration: 100 }"
:editor="editor"
v-if="editor"
>
<button @click="editor.chain().focus().toggleBold().run()" :class="{ 'is-active': editor.isActive('bold') }">
Bold
@ -21,7 +20,6 @@
class="floating-menu"
:tippy-options="{ duration: 100 }"
:editor="editor"
v-if="editor"
>
<button @click="editor.chain().focus().toggleHeading({ level: 1 }).run()" :class="{ 'is-active': editor.isActive('heading', { level: 1 }) }">
H1
@ -33,9 +31,9 @@
Bullet List
</button>
</floating-menu>
</div>
<editor-content :editor="editor" />
</div>
</template>
<script>

View File

@ -30,9 +30,5 @@ export default () => {
`,
})
if (!editor) {
return null
}
return <EditorContent editor={editor} />
}

View File

@ -54,10 +54,6 @@ export const tableHTML = `
`
const MenuBar = ({ editor }) => {
if (!editor) {
return null
}
return (
<>
<button onClick={() => editor.chain().focus().insertTable({ rows: 3, cols: 3, withHeaderRow: true }).run()}>

View File

@ -54,9 +54,8 @@
<button @click="editor.chain().focus().goToPreviousCell().run()" :disabled="!editor.can().goToPreviousCell()">
goToPreviousCell
</button>
<editor-content :editor="editor" />
</div>
<editor-content :editor="editor" />
</template>
<script>