add command for adding images

This commit is contained in:
Philipp Kühn
2018-09-29 22:49:38 +02:00
parent 8f66c19c7e
commit efdf45de4c
3 changed files with 34 additions and 0 deletions

View File

@@ -2,6 +2,19 @@
<div>
<editor class="editor" :extensions="extensions">
<div class="menubar" slot="menubar" slot-scope="{ nodes }">
<div v-if="nodes">
<button
class="menubar__button"
@click="showImagePrompt(nodes.image.command)"
>
<icon name="image" />
</button>
</div>
</div>
<div class="editor__content" slot="content" slot-scope="props">
<h2>
Images
@@ -17,6 +30,7 @@
</template>
<script>
import Icon from 'Components/Icon'
import { Editor } from 'tiptap'
import {
HardBreakNode,
@@ -29,6 +43,7 @@ import {
export default {
components: {
Icon,
Editor,
},
data() {
@@ -43,5 +58,13 @@ export default {
],
}
},
methods: {
showImagePrompt(command) {
const src = prompt('Enter the url of your image here')
if (src !== null) {
command({ src })
}
},
},
}
</script>