fix some examples

This commit is contained in:
Philipp Kühn 2018-10-29 23:31:13 +01:00
parent 253596fb35
commit 68793ea385
11 changed files with 51 additions and 55 deletions

View File

@ -1,7 +1,7 @@
<template>
<div class="editor">
<menu-bar class="menubar" :editor="editor">
<template slot-scope="{ nodes, marks, commands, isActive }">
<template slot-scope="{ commands, isActive }">
<button
class="menubar__button"

View File

@ -2,11 +2,11 @@
<div>
<div class="editor">
<menu-bar class="menubar" :editor="editor">
<template slot-scope="{ nodes, marks, commands }">
<template slot-scope="{ commands, isActive }">
<button
class="menubar__button"
:class="{ 'is-active': marks.bold.active() }"
:class="{ 'is-active': isActive('bold') }"
@click="commands.bold"
>
<icon name="bold" />
@ -14,7 +14,7 @@
<button
class="menubar__button"
:class="{ 'is-active': marks.italic.active() }"
:class="{ 'is-active': isActive('italic') }"
@click="commands.italic"
>
<icon name="italic" />
@ -22,7 +22,7 @@
<button
class="menubar__button"
:class="{ 'is-active': marks.code.active() }"
:class="{ 'is-active': isActive('code') }"
@click="commands.code"
>
<icon name="code" />
@ -30,7 +30,7 @@
<button
class="menubar__button"
:class="{ 'is-active': nodes.paragraph.active() }"
:class="{ 'is-active': isActive('paragraph') }"
@click="commands.paragraph"
>
<icon name="paragraph" />
@ -38,7 +38,7 @@
<button
class="menubar__button"
:class="{ 'is-active': nodes.heading.active({ level: 1 }) }"
:class="{ 'is-active': isActive('heading', { level: 1 }) }"
@click="commands.heading({ level: 1 })"
>
H1
@ -46,7 +46,7 @@
<button
class="menubar__button"
:class="{ 'is-active': nodes.heading.active({ level: 2 }) }"
:class="{ 'is-active': isActive('heading', { level: 2 }) }"
@click="commands.heading({ level: 2 })"
>
H2
@ -54,7 +54,7 @@
<button
class="menubar__button"
:class="{ 'is-active': nodes.heading.active({ level: 3 }) }"
:class="{ 'is-active': isActive('heading', { level: 3 }) }"
@click="commands.heading({ level: 3 })"
>
H3
@ -62,7 +62,7 @@
<button
class="menubar__button"
:class="{ 'is-active': nodes.bullet_list.active() }"
:class="{ 'is-active': isActive('bullet_list') }"
@click="commands.bullet_list"
>
<icon name="ul" />
@ -70,7 +70,7 @@
<button
class="menubar__button"
:class="{ 'is-active': nodes.ordered_list.active() }"
:class="{ 'is-active': isActive('ordered_list') }"
@click="commands.ordered_list"
>
<icon name="ol" />
@ -78,7 +78,7 @@
<button
class="menubar__button"
:class="{ 'is-active': nodes.code_block.active() }"
:class="{ 'is-active': isActive('code_block') }"
@click="commands.code_block"
>
<icon name="code" />

View File

@ -1,11 +1,11 @@
<template>
<div class="editor">
<floating-menu class="editor__floating-menu" :editor="editor">
<template slot-scope="{ nodes, marks, commands }">
<template slot-scope="{ commands, isActive }">
<button
class="menubar__button"
:class="{ 'is-active': nodes.heading.active({ level: 1 }) }"
:class="{ 'is-active': isActive('heading', { level: 1 }) }"
@click="commands.heading({ level: 1 })"
>
H1
@ -13,7 +13,7 @@
<button
class="menubar__button"
:class="{ 'is-active': nodes.heading.active({ level: 2 }) }"
:class="{ 'is-active': isActive('heading', { level: 2 }) }"
@click="commands.heading({ level: 2 })"
>
H2
@ -21,7 +21,7 @@
<button
class="menubar__button"
:class="{ 'is-active': nodes.heading.active({ level: 3 }) }"
:class="{ 'is-active': isActive('heading', { level: 3 }) }"
@click="commands.heading({ level: 3 })"
>
H3
@ -29,7 +29,7 @@
<button
class="menubar__button"
:class="{ 'is-active': nodes.bullet_list.active() }"
:class="{ 'is-active': isActive('bullet_list') }"
@click="commands.bullet_list"
>
<icon name="ul" />
@ -37,7 +37,7 @@
<button
class="menubar__button"
:class="{ 'is-active': nodes.ordered_list.active() }"
:class="{ 'is-active': isActive('ordered_list') }"
@click="commands.ordered_list"
>
<icon name="ol" />
@ -45,7 +45,7 @@
<button
class="menubar__button"
:class="{ 'is-active': nodes.blockquote.active() }"
:class="{ 'is-active': isActive('blockquote') }"
@click="commands.blockquote"
>
<icon name="quote" />
@ -53,7 +53,7 @@
<button
class="menubar__button"
:class="{ 'is-active': nodes.code_block.active() }"
:class="{ 'is-active': isActive('code_block') }"
@click="commands.code_block"
>
<icon name="code" />

View File

@ -1,12 +1,12 @@
<template>
<div class="editor">
<menu-bar :editor="editor">
<template slot-scope="{ nodes, marks, commands, focused }">
<template slot-scope="{ commands, isActive, focused }">
<div class="menubar is-hidden" :class="{ 'is-focused': focused }">
<button
class="menubar__button"
:class="{ 'is-active': marks.bold.active() }"
:class="{ 'is-active': isActive('bold') }"
@click="commands.bold"
>
<icon name="bold" />
@ -14,7 +14,7 @@
<button
class="menubar__button"
:class="{ 'is-active': marks.italic.active() }"
:class="{ 'is-active': isActive('italic') }"
@click="commands.italic"
>
<icon name="italic" />
@ -22,7 +22,7 @@
<button
class="menubar__button"
:class="{ 'is-active': marks.strike.active() }"
:class="{ 'is-active': isActive('strike') }"
@click="commands.strike"
>
<icon name="strike" />
@ -30,7 +30,7 @@
<button
class="menubar__button"
:class="{ 'is-active': marks.underline.active() }"
:class="{ 'is-active': isActive('underline') }"
@click="commands.underline"
>
<icon name="underline" />
@ -38,7 +38,7 @@
<button
class="menubar__button"
:class="{ 'is-active': marks.code.active() }"
:class="{ 'is-active': isActive('code') }"
@click="commands.code"
>
<icon name="code" />
@ -46,7 +46,7 @@
<button
class="menubar__button"
:class="{ 'is-active': nodes.paragraph.active() }"
:class="{ 'is-active': isActive('paragraph') }"
@click="commands.paragraph"
>
<icon name="paragraph" />
@ -54,7 +54,7 @@
<button
class="menubar__button"
:class="{ 'is-active': nodes.heading.active({ level: 1 }) }"
:class="{ 'is-active': isActive('heading', { level: 1 }) }"
@click="commands.heading({ level: 1 })"
>
H1
@ -62,7 +62,7 @@
<button
class="menubar__button"
:class="{ 'is-active': nodes.heading.active({ level: 2 }) }"
:class="{ 'is-active': isActive('heading', { level: 2 }) }"
@click="commands.heading({ level: 2 })"
>
H2
@ -70,7 +70,7 @@
<button
class="menubar__button"
:class="{ 'is-active': nodes.heading.active({ level: 3 }) }"
:class="{ 'is-active': isActive('heading', { level: 3 }) }"
@click="commands.heading({ level: 3 })"
>
H3
@ -78,7 +78,7 @@
<button
class="menubar__button"
:class="{ 'is-active': nodes.bullet_list.active() }"
:class="{ 'is-active': isActive('bullet_list') }"
@click="commands.bullet_list"
>
<icon name="ul" />
@ -86,7 +86,7 @@
<button
class="menubar__button"
:class="{ 'is-active': nodes.ordered_list.active() }"
:class="{ 'is-active': isActive('ordered_list') }"
@click="commands.ordered_list"
>
<icon name="ol" />
@ -94,7 +94,7 @@
<button
class="menubar__button"
:class="{ 'is-active': nodes.blockquote.active() }"
:class="{ 'is-active': isActive('blockquote') }"
@click="commands.blockquote"
>
<icon name="quote" />
@ -102,7 +102,7 @@
<button
class="menubar__button"
:class="{ 'is-active': nodes.code_block.active() }"
:class="{ 'is-active': isActive('code_block') }"
@click="commands.code_block"
>
<icon name="code" />

View File

@ -1,11 +1,11 @@
<template>
<div class="editor">
<menu-bubble class="menububble" :editor="editor">
<template slot-scope="{ nodes, marks, commands }">
<template slot-scope="{ commands, isActive }">
<button
class="menububble__button"
:class="{ 'is-active': marks.bold.active() }"
:class="{ 'is-active': isActive('bold') }"
@click="commands.bold"
>
<icon name="bold" />
@ -13,7 +13,7 @@
<button
class="menububble__button"
:class="{ 'is-active': marks.italic.active() }"
:class="{ 'is-active': isActive('italic') }"
@click="commands.italic"
>
<icon name="italic" />
@ -21,7 +21,7 @@
<button
class="menububble__button"
:class="{ 'is-active': marks.code.active() }"
:class="{ 'is-active': isActive('code') }"
@click="commands.code"
>
<icon name="code" />

View File

@ -1,11 +1,11 @@
<template>
<div class="editor">
<menu-bar class="menubar" :editor="editor">
<template slot-scope="{ nodes, marks, commands }">
<template slot-scope="{ commands, isActive }">
<button
class="menubar__button"
:class="{ 'is-active': nodes.paragraph.active({ textAlign: 'left' }) }"
:class="{ 'is-active': isActive('paragraph', { textAlign: 'left' }) }"
@click="commands.paragraph({ textAlign: 'left' })"
>
<icon name="align-left" />
@ -13,7 +13,7 @@
<button
class="menubar__button"
:class="{ 'is-active': nodes.paragraph.active({ textAlign: 'center' }) }"
:class="{ 'is-active': isActive('paragraph', { textAlign: 'center' }) }"
@click="commands.paragraph({ textAlign: 'center' })"
>
<icon name="align-center" />
@ -21,7 +21,7 @@
<button
class="menubar__button"
:class="{ 'is-active': nodes.paragraph.active({ textAlign: 'right' }) }"
:class="{ 'is-active': isActive('paragraph', { textAlign: 'right' }) }"
@click="commands.paragraph({ textAlign: 'right' })"
>
<icon name="align-right" />

View File

@ -1,11 +1,11 @@
<template>
<div class="editor">
<menu-bar class="menubar" :editor="editor">
<template slot-scope="{ nodes, marks, commands }">
<template slot-scope="{ commands, isActive }">
<button
class="menubar__button"
:class="{ 'is-active': marks.bold.active() }"
:class="{ 'is-active': isActive('bold') }"
@click="commands.bold"
>
<icon name="bold" />
@ -13,7 +13,7 @@
<button
class="menubar__button"
:class="{ 'is-active': marks.italic.active() }"
:class="{ 'is-active': isActive('italic') }"
@click="commands.italic"
>
<icon name="italic" />
@ -21,7 +21,7 @@
<button
class="menubar__button"
:class="{ 'is-active': marks.code.active() }"
:class="{ 'is-active': isActive('code') }"
@click="commands.code"
>
<icon name="code" />
@ -29,7 +29,7 @@
<button
class="menubar__button"
:class="{ 'is-active': nodes.todo_list.active() }"
:class="{ 'is-active': isActive('todo_list') }"
@click="commands.todo_list"
>
<icon name="checklist" />

View File

@ -13,9 +13,9 @@ export default {
this.$nextTick(() => this.$el.append(element.firstChild))
}
},
}
},
},
render(createElement) {
return createElement('div')
},
}
}

View File

@ -22,11 +22,10 @@ export default {
render(createElement) {
if (this.editor) {
return createElement('div', this.$scopedSlots.default({
nodes: this.editor.menuActions.nodes,
marks: this.editor.menuActions.marks,
focused: this.editor.view.focused,
focus: this.editor.focus,
commands: this.editor.commands,
isActive: this.editor.isActive.bind(this.editor),
}))
}
},

View File

@ -8,8 +8,6 @@ export default {
render(createElement) {
if (this.editor) {
return createElement('div', this.$scopedSlots.default({
nodes: this.editor.menuActions.nodes,
marks: this.editor.menuActions.marks,
focused: this.editor.view.focused,
focus: this.editor.focus,
commands: this.editor.commands,

View File

@ -22,11 +22,10 @@ export default {
render(createElement) {
if (this.editor) {
return createElement('div', this.$scopedSlots.default({
nodes: this.editor.menuActions.nodes,
marks: this.editor.menuActions.marks,
focused: this.editor.view.focused,
focus: this.editor.focus,
commands: this.editor.commands,
isActive: this.editor.isActive.bind(this.editor),
}))
}
},