mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-01-18 06:03:22 +08:00
Merge branch 'main' of github.com:ueberdosis/tiptap-next into main
This commit is contained in:
commit
480f863de3
@ -82,7 +82,7 @@ export default {
|
||||
computed: {
|
||||
mainFile() {
|
||||
const file = this.files
|
||||
.find(item => item.path.endsWith('.vue') || item.path.endsWith('.jsx'))
|
||||
.find(item => item.path.endsWith('index.vue') || item.path.endsWith('.jsx'))
|
||||
|
||||
if (!file) {
|
||||
return
|
||||
@ -122,7 +122,7 @@ export default {
|
||||
.filter(item => {
|
||||
return ['vue', 'jsx', 'scss'].includes(item.extension)
|
||||
})
|
||||
.sortBy(item => item.path.split('/').length)
|
||||
.sortBy(item => item.path.split('/').length && !item.path.endsWith('index.vue'))
|
||||
.toArray()
|
||||
},
|
||||
}
|
||||
|
@ -1,12 +1,11 @@
|
||||
<template>
|
||||
<div>
|
||||
<editor-content :editor="editor" />
|
||||
</div>
|
||||
<editor-content :editor="editor" />
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { Editor } from '@tiptap/core'
|
||||
import EditorContent from './EditorContent.ts'
|
||||
import { EditorContent } from '@tiptap/vue'
|
||||
import { defaultExtensions } from '@tiptap/starter-kit'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
@ -15,15 +14,9 @@ export default {
|
||||
|
||||
props: {
|
||||
value: {
|
||||
type: [String, Object],
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
|
||||
extensions: {
|
||||
type: Array,
|
||||
required: true,
|
||||
default: () => [],
|
||||
},
|
||||
},
|
||||
|
||||
data() {
|
||||
@ -32,9 +25,21 @@ export default {
|
||||
}
|
||||
},
|
||||
|
||||
watch: {
|
||||
value(value) {
|
||||
const isSame = this.editor.getHTML() === value
|
||||
|
||||
if (isSame) {
|
||||
return
|
||||
}
|
||||
|
||||
this.editor.commands.setContent(this.value, false)
|
||||
},
|
||||
},
|
||||
|
||||
mounted() {
|
||||
this.editor = new Editor({
|
||||
extensions: this.extensions,
|
||||
extensions: defaultExtensions(),
|
||||
content: this.value,
|
||||
})
|
||||
|
@ -1,26 +1,50 @@
|
||||
<template>
|
||||
<div>
|
||||
<full-editor v-model="content" :extensions="extensions" />
|
||||
<div>
|
||||
{{ content }}
|
||||
<editor v-model="content" />
|
||||
|
||||
<div class="content">
|
||||
<h3>Content</h3>
|
||||
<pre><code>{{ content }}</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { FullEditor } from '@tiptap/vue'
|
||||
import { defaultExtensions } from '@tiptap/starter-kit'
|
||||
import Editor from './Editor'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
FullEditor,
|
||||
Editor,
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
extensions: defaultExtensions(),
|
||||
content: '<p>A Vue.js wrapper component for tiptap to use <code>v-model</code>.</p>',
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.content {
|
||||
padding: 1rem 0 0;
|
||||
|
||||
h3 {
|
||||
margin: 1rem 0 0.5rem;
|
||||
}
|
||||
|
||||
pre {
|
||||
border-radius: 5px;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
code {
|
||||
display: block;
|
||||
white-space: pre-wrap;
|
||||
font-size: 0.8rem;
|
||||
padding: 0.75rem 1rem;
|
||||
background-color:#e9ecef;
|
||||
color: #495057;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
@ -1,4 +1,3 @@
|
||||
export * from '@tiptap/core'
|
||||
export { default as VueRenderer } from './VueRenderer'
|
||||
export { default as EditorContent } from './components/EditorContent'
|
||||
export { default as FullEditor } from './components/FullEditor.vue'
|
||||
|
Loading…
Reference in New Issue
Block a user