tiptap/examples/Components/Routes/Embeds/index.vue

75 lines
1.5 KiB
Vue
Raw Normal View History

2018-08-23 05:12:19 +08:00
<template>
2018-11-09 05:03:10 +08:00
<div class="editor">
<editor-content class="editor__content" :editor="editor" />
</div>
2018-08-23 05:12:19 +08:00
</template>
<script>
2018-10-23 03:40:12 +08:00
import { Editor, EditorContent } from 'tiptap'
2018-08-24 04:08:19 +08:00
import {
2018-11-09 05:03:10 +08:00
HardBreak,
Heading,
Bold,
Italic,
History,
2019-07-24 00:30:59 +08:00
TrailingNode,
2018-08-24 04:08:19 +08:00
} from 'tiptap-extensions'
2018-10-24 13:46:47 +08:00
import Iframe from './Iframe.js'
2018-08-23 05:12:19 +08:00
export default {
2018-11-09 05:03:10 +08:00
components: {
EditorContent,
},
data() {
return {
editor: new Editor({
extensions: [
new HardBreak(),
new Heading({ levels: [1, 2, 3] }),
new Bold(),
new Italic(),
new History(),
2019-07-24 00:30:59 +08:00
new TrailingNode(),
2018-11-09 05:03:10 +08:00
// custom extension
new Iframe(),
],
content: `
<h2>
Embeds
</h2>
<p>
This is an example of a custom iframe node. This iframe is rendered as a <strong>vue component</strong>. This makes it possible to render the input below to change its source.
</p>
<iframe src="https://www.youtube.com/embed/XIMLoLxmTDw" frameborder="0" allowfullscreen></iframe>
`,
}),
}
},
beforeDestroy() {
this.editor.destroy()
},
2018-08-23 05:12:19 +08:00
}
</script>
<style lang="scss">
@import "~variables";
.iframe {
2018-11-09 05:03:10 +08:00
&__embed {
width: 100%;
height: 15rem;
border: 0;
}
2018-08-23 05:12:19 +08:00
2018-11-09 05:03:10 +08:00
&__input {
display: block;
width: 100%;
font: inherit;
border: 0;
border-radius: 5px;
background-color: rgba($color-black, 0.1);
padding: 0.3rem 0.5rem;
}
2018-08-23 05:12:19 +08:00
}
</style>