mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-12-13 01:19:01 +08:00
fix some examples
This commit is contained in:
parent
b913c84b58
commit
7437992dd5
@ -188,5 +188,8 @@ export default {
|
|||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
beforeDestroy() {
|
||||||
|
this.editor.destroy()
|
||||||
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
@ -1,23 +1,11 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div class="editor">
|
||||||
<editor class="editor" :extensions="extensions">
|
<editor-content class="editor__content" :editor="editor" />
|
||||||
|
|
||||||
<div class="editor__content" slot="content" slot-scope="props">
|
|
||||||
<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>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</editor>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { Editor } from 'tiptap'
|
import { Editor, EditorContent } from 'tiptap'
|
||||||
import {
|
import {
|
||||||
HardBreakNode,
|
HardBreakNode,
|
||||||
HeadingNode,
|
HeadingNode,
|
||||||
@ -29,10 +17,11 @@ import IframeNode from './Iframe.js'
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
Editor,
|
EditorContent,
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
editor: new Editor({
|
||||||
extensions: [
|
extensions: [
|
||||||
new HardBreakNode(),
|
new HardBreakNode(),
|
||||||
new HeadingNode({ maxLevel: 3 }),
|
new HeadingNode({ maxLevel: 3 }),
|
||||||
@ -42,8 +31,21 @@ export default {
|
|||||||
// custom extension
|
// custom extension
|
||||||
new IframeNode(),
|
new IframeNode(),
|
||||||
],
|
],
|
||||||
|
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()
|
||||||
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div class="editor">
|
||||||
<editor class="editor" :extensions="extensions">
|
<menu-bar :editor="editor">
|
||||||
|
<template slot-scope="{ nodes, marks, focused }">
|
||||||
<div class="menubar is-hidden" :class="{ 'is-focused': focused }" slot="menubar" slot-scope="{ nodes, marks, focused }">
|
<div class="menubar is-hidden" :class="{ 'is-focused': focused }">
|
||||||
<div v-if="nodes && marks">
|
|
||||||
|
|
||||||
<button
|
<button
|
||||||
class="menubar__button"
|
class="menubar__button"
|
||||||
@ -21,6 +20,22 @@
|
|||||||
<icon name="italic" />
|
<icon name="italic" />
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
<button
|
||||||
|
class="menubar__button"
|
||||||
|
:class="{ 'is-active': marks.strike.active() }"
|
||||||
|
@click="marks.strike.command"
|
||||||
|
>
|
||||||
|
<icon name="strike" />
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<button
|
||||||
|
class="menubar__button"
|
||||||
|
:class="{ 'is-active': marks.underline.active() }"
|
||||||
|
@click="marks.underline.command"
|
||||||
|
>
|
||||||
|
<icon name="underline" />
|
||||||
|
</button>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
class="menubar__button"
|
class="menubar__button"
|
||||||
@click="marks.code.command"
|
@click="marks.code.command"
|
||||||
@ -77,6 +92,14 @@
|
|||||||
<icon name="ol" />
|
<icon name="ol" />
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
<button
|
||||||
|
class="menubar__button"
|
||||||
|
:class="{ 'is-active': nodes.blockquote.active() }"
|
||||||
|
@click="nodes.blockquote.command"
|
||||||
|
>
|
||||||
|
<icon name="quote" />
|
||||||
|
</button>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
class="menubar__button"
|
class="menubar__button"
|
||||||
:class="{ 'is-active': nodes.code_block.active() }"
|
:class="{ 'is-active': nodes.code_block.active() }"
|
||||||
@ -86,24 +109,16 @@
|
|||||||
</button>
|
</button>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</template>
|
||||||
|
</menu-bar>
|
||||||
|
|
||||||
<div class="editor__content" slot="content" slot-scope="props">
|
<editor-content class="editor__content" :editor="editor" />
|
||||||
<h2>
|
|
||||||
Hiding Menu Bar
|
|
||||||
</h2>
|
|
||||||
<p>
|
|
||||||
Click into this text to see the menu. Click outside and the menu will disappear. It's like magic.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</editor>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import Icon from 'Components/Icon'
|
import Icon from 'Components/Icon'
|
||||||
import { Editor } from 'tiptap'
|
import { Editor, EditorContent, MenuBar } from 'tiptap'
|
||||||
import {
|
import {
|
||||||
BlockquoteNode,
|
BlockquoteNode,
|
||||||
BulletListNode,
|
BulletListNode,
|
||||||
@ -118,16 +133,20 @@ import {
|
|||||||
CodeMark,
|
CodeMark,
|
||||||
ItalicMark,
|
ItalicMark,
|
||||||
LinkMark,
|
LinkMark,
|
||||||
|
StrikeMark,
|
||||||
|
UnderlineMark,
|
||||||
HistoryExtension,
|
HistoryExtension,
|
||||||
} from 'tiptap-extensions'
|
} from 'tiptap-extensions'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
Editor,
|
EditorContent,
|
||||||
|
MenuBar,
|
||||||
Icon,
|
Icon,
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
editor: new Editor({
|
||||||
extensions: [
|
extensions: [
|
||||||
new BlockquoteNode(),
|
new BlockquoteNode(),
|
||||||
new BulletListNode(),
|
new BulletListNode(),
|
||||||
@ -142,9 +161,23 @@ export default {
|
|||||||
new CodeMark(),
|
new CodeMark(),
|
||||||
new ItalicMark(),
|
new ItalicMark(),
|
||||||
new LinkMark(),
|
new LinkMark(),
|
||||||
|
new StrikeMark(),
|
||||||
|
new UnderlineMark(),
|
||||||
new HistoryExtension(),
|
new HistoryExtension(),
|
||||||
],
|
],
|
||||||
|
content: `
|
||||||
|
<h2>
|
||||||
|
Hiding Menu Bar
|
||||||
|
</h2>
|
||||||
|
<p>
|
||||||
|
Click into this text to see the menu. Click outside and the menu will disappear. It's like magic.
|
||||||
|
</p>
|
||||||
|
`,
|
||||||
|
}),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
beforeDestroy() {
|
||||||
|
this.editor.destroy()
|
||||||
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
@ -94,5 +94,8 @@ export default {
|
|||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
beforeDestroy() {
|
||||||
|
this.editor.destroy()
|
||||||
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
@ -10,6 +10,8 @@ export default {
|
|||||||
return createElement('div', this.$scopedSlots.default({
|
return createElement('div', this.$scopedSlots.default({
|
||||||
nodes: this.editor.menuActions.nodes,
|
nodes: this.editor.menuActions.nodes,
|
||||||
marks: this.editor.menuActions.marks,
|
marks: this.editor.menuActions.marks,
|
||||||
|
focused: this.editor.view.focused,
|
||||||
|
focus: this.editor.focus,
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -24,6 +24,8 @@ export default {
|
|||||||
return createElement('div', this.$scopedSlots.default({
|
return createElement('div', this.$scopedSlots.default({
|
||||||
nodes: this.editor.menuActions.nodes,
|
nodes: this.editor.menuActions.nodes,
|
||||||
marks: this.editor.menuActions.marks,
|
marks: this.editor.menuActions.marks,
|
||||||
|
focused: this.editor.view.focused,
|
||||||
|
focus: this.editor.focus,
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user