avoid tabindex in editor and add placehoder
This commit is contained in:
@@ -3,93 +3,60 @@
|
|||||||
editor-menu-bar.menubar.is-hidden(:editor='editor'
|
editor-menu-bar.menubar.is-hidden(:editor='editor'
|
||||||
:keep-in-bounds='true' v-slot='{ commands, isActive, getMarkAttrs, focused }')
|
:keep-in-bounds='true' v-slot='{ commands, isActive, getMarkAttrs, focused }')
|
||||||
v-btn-toggle(dense :class="{ focused }")
|
v-btn-toggle(dense :class="{ focused }")
|
||||||
v-btn(icon text
|
v-btn(icon text tabindex='-1'
|
||||||
:class="{ primary: isActive.bold() }"
|
:class="{ primary: isActive.bold() }"
|
||||||
@click="commands.bold")
|
@click="commands.bold")
|
||||||
v-icon mdi-format-bold
|
v-icon mdi-format-bold
|
||||||
|
|
||||||
v-btn(icon text
|
v-btn(icon text tabindex='-1'
|
||||||
:class="{ primary: isActive.underline() }"
|
:class="{ primary: isActive.underline() }"
|
||||||
@click="commands.underline")
|
@click="commands.underline")
|
||||||
v-icon mdi-format-underline
|
v-icon mdi-format-underline
|
||||||
|
|
||||||
v-btn(icon text
|
v-btn(icon text tabindex='-1'
|
||||||
:class="{ primary: isActive.strike() }"
|
:class="{ primary: isActive.strike() }"
|
||||||
@click="commands.strike")
|
@click="commands.strike")
|
||||||
v-icon mdi-format-strikethrough-variant
|
v-icon mdi-format-strikethrough-variant
|
||||||
|
|
||||||
v-btn(icon text
|
v-btn(icon text tabindex='-1'
|
||||||
:class="{ primary: isActive.italic() }"
|
:class="{ primary: isActive.italic() }"
|
||||||
@click="commands.italic")
|
@click="commands.italic")
|
||||||
v-icon mdi-format-italic
|
v-icon mdi-format-italic
|
||||||
|
|
||||||
v-btn(icon text
|
v-btn(icon text tabindex='-1'
|
||||||
:class="{ primary: isActive.heading({level: 1}) }"
|
:class="{ primary: isActive.heading({level: 1}) }"
|
||||||
@click="commands.heading({level: 1})")
|
@click="commands.heading({level: 1})")
|
||||||
v-icon mdi-format-header-1
|
v-icon mdi-format-header-1
|
||||||
|
|
||||||
v-btn(icon text
|
v-btn(icon text tabindex='-1'
|
||||||
:class="{ primary: isActive.heading({level: 2}) }"
|
:class="{ primary: isActive.heading({level: 2}) }"
|
||||||
@click="commands.heading({level: 2})")
|
@click="commands.heading({level: 2})")
|
||||||
v-icon mdi-format-header-2
|
v-icon mdi-format-header-2
|
||||||
|
|
||||||
v-btn(icon text
|
v-btn(icon text tabindex='-1'
|
||||||
:class="{ primary: isActive.heading({level: 3}) }"
|
:class="{ primary: isActive.heading({level: 3}) }"
|
||||||
@click="commands.heading({level: 3})")
|
@click="commands.heading({level: 3})")
|
||||||
v-icon mdi-format-header-3
|
v-icon mdi-format-header-3
|
||||||
|
|
||||||
v-btn(icon text
|
v-btn(icon text tabindex='-1'
|
||||||
:class="{ primary: isActive.code() }"
|
:class="{ primary: isActive.code() }"
|
||||||
@click="commands.code")
|
@click="commands.code")
|
||||||
v-icon mdi-code-tags
|
v-icon mdi-code-tags
|
||||||
|
|
||||||
v-btn(icon text
|
v-btn(icon text tabindex='-1'
|
||||||
:class="{ primary: isActive.blockquote() }"
|
:class="{ primary: isActive.blockquote() }"
|
||||||
@click="commands.blockquote")
|
@click="commands.blockquote")
|
||||||
v-icon mdi-format-quote-open
|
v-icon mdi-format-quote-open
|
||||||
|
|
||||||
v-btn(icon text
|
v-btn(icon text tabindex='-1'
|
||||||
:class="{ primary: isActive.bullet_list() }"
|
:class="{ primary: isActive.bullet_list() }"
|
||||||
@click="commands.bullet_list")
|
@click="commands.bullet_list")
|
||||||
v-icon mdi-format-list-bulleted
|
v-icon mdi-format-list-bulleted
|
||||||
|
|
||||||
v-btn(icon text :class='{ primary: isActive.link() }'
|
v-btn(icon text tabindex='-1' :class='{ primary: isActive.link() }'
|
||||||
@click='commands.link({href: ""}); $refs.link.focus(); linkActive=true')
|
@click='commands.link({href: ""}); $refs.link.focus(); linkActive=true')
|
||||||
v-icon mdi-link
|
v-icon mdi-link
|
||||||
|
|
||||||
//- v-btn-toggle.menububble(:class="{ 'is-active': menu.isActive }" :style="`left: ${menu.left}px; bottom: ${menu.bottom}px;`")
|
|
||||||
v-popover(trigger='hover' placement='bottom-start')
|
|
||||||
v-btn.float-left(slot='reference' size='mini') <v-icon name='question'/>
|
|
||||||
template
|
|
||||||
span This editor supports inline <code>markdown</code>
|
|
||||||
div <v-icon name='heading'/> → Title ⇒ Start a line with <code>#</code>
|
|
||||||
div <v-icon name='bold'/> → Bold ⇒ <code>ctrl+b</code>
|
|
||||||
div <v-icon name='italic'/> → Italic ⇒ <code>ctrl+i</code>
|
|
||||||
div <v-icon name='underline'/> → Underline ⇒ <code>ctrl+u</code>
|
|
||||||
div <v-icon name='list-ul'/> → List ⇒ Start a line with <code>-</code>
|
|
||||||
div <v-icon name='list-ol'/> → Ordered List ⇒ Start a line with <code>1.</code>
|
|
||||||
div <v-icon name='quote-right'/> → Quote ⇒ Start a line with <code>></code>
|
|
||||||
div <v-icon name='code'/> → Code ⇒ Use backtick <code>`</code>
|
|
||||||
div <v-icon name='link'/> → Link ⇒ Select a word and fill the input
|
|
||||||
//- el-button(size='mini' :class='{ "is-active": isActive.heading({level:4})}' @click='commands.heading({level: 4})') <v-icon name='heading'/>
|
|
||||||
//- el-button(size='mini' :class='{ "is-active": isActive.bold() }' @click='commands.bold')
|
|
||||||
<v-icon name='bold' />
|
|
||||||
//- el-button(size='mini' :class='{ "is-active": isActive.italic() }' @click='commands.italic') <v-icon name='italic'/>
|
|
||||||
//- el-button(size='mini' :class='{ "is-active": isActive.underline() }' @click='commands.underline') <v-icon name='underline'/>
|
|
||||||
v-btn(size='mini' :class='{ "is-active": isActive.link() }' @click='commands.link({href: ""}); $refs.link.focus(); linkActive=true') <v-icon name='link'/>
|
|
||||||
input(:value='isActive.link() && getMarkAttrs("link") && getMarkAttrs("link").href || ""' ref='link' :class='{ "is-active": isActive.link() || linkActive }'
|
|
||||||
placeholder='https://' @keypress.enter='commands.link({ href: $event.target.value})')
|
|
||||||
//- el-button(size='mini' :class='{ "is-active": isActive.strike() }' @click='commands.strike') <v-icon name='strikethrough'/>
|
|
||||||
//- br
|
|
||||||
//- el-button-group
|
|
||||||
//- el-button(size='mini' :class='{ "is-active": isActive.code() }' @click='commands.code') <v-icon size=16 name='code'/>
|
|
||||||
//- el-button(size='mini' :class='{ "is-active": isActive.bullet_list() }' @click='commands.bullet_list') <v-icon name='list-ul'/>
|
|
||||||
//- //- el-button(size='mini' :class='{ "is-active": isActive.ordered_list() }' @click='commands.ordered_list') <v-icon name='list-ol'/>
|
|
||||||
//- el-button(size='mini' :class='{ "is-active": isActive.blockquote() }' @click='commands.blockquote') <v-icon name='quote-right'/>
|
|
||||||
|
|
||||||
//- el-button.float-right(v-if='!noSave' size='mini' type='success' plain icon='el-icon-check'
|
|
||||||
//- @click='$emit("save", editor.getHTML())') {{$t('common.save')}}
|
|
||||||
|
|
||||||
editor-content.content(:editor='editor' spellcheck='false' :style="{ 'max-height': maxHeight }")
|
editor-content.content(:editor='editor' spellcheck='false' :style="{ 'max-height': maxHeight }")
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
@@ -109,7 +76,8 @@ import {
|
|||||||
Link,
|
Link,
|
||||||
History,
|
History,
|
||||||
Strike,
|
Strike,
|
||||||
Underline
|
Underline,
|
||||||
|
Placeholder
|
||||||
} from 'tiptap-extensions'
|
} from 'tiptap-extensions'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@@ -119,7 +87,8 @@ export default {
|
|||||||
value: { type: String, default: '' },
|
value: { type: String, default: '' },
|
||||||
border: { type: Boolean, default: false },
|
border: { type: Boolean, default: false },
|
||||||
noSave: { type: Boolean, default: false },
|
noSave: { type: Boolean, default: false },
|
||||||
maxHeight: { type: String, Number, default: '' }
|
maxHeight: { type: String, Number, default: '' },
|
||||||
|
placeholder: { type: String, default: '' }
|
||||||
},
|
},
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
@@ -143,7 +112,7 @@ export default {
|
|||||||
onUpdate: _.debounce(({ getHTML }) => {
|
onUpdate: _.debounce(({ getHTML }) => {
|
||||||
this.update = true
|
this.update = true
|
||||||
this.$emit('input', getHTML())
|
this.$emit('input', getHTML())
|
||||||
}, 300),
|
}, 1000),
|
||||||
content: this.value,
|
content: this.value,
|
||||||
extensions: [
|
extensions: [
|
||||||
new Blockquote(),
|
new Blockquote(),
|
||||||
@@ -159,7 +128,14 @@ export default {
|
|||||||
new Bold(),
|
new Bold(),
|
||||||
new Italic(),
|
new Italic(),
|
||||||
new Strike(),
|
new Strike(),
|
||||||
new Underline()
|
new Underline(),
|
||||||
|
new Placeholder({
|
||||||
|
emptyEditorClass: 'is-editor-empty',
|
||||||
|
emptyNodeClass: 'is-empty',
|
||||||
|
emptyNodeText: this.placeholder,
|
||||||
|
showOnlyWhenEditable: true,
|
||||||
|
showOnlyCurrent: true,
|
||||||
|
})
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
@@ -169,7 +145,15 @@ export default {
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<style lang='less'>
|
<style lang='less'>
|
||||||
|
.editor p.is-editor-empty:first-child::before {
|
||||||
|
content: attr(data-empty-text);
|
||||||
|
float: left;
|
||||||
|
color: #aaa;
|
||||||
|
// opacity: .4;
|
||||||
|
pointer-events: none;
|
||||||
|
height: 0;
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
.editor {
|
.editor {
|
||||||
// max-height: auto;
|
// max-height: auto;
|
||||||
// height: auto;
|
// height: auto;
|
||||||
@@ -188,7 +172,6 @@ export default {
|
|||||||
}
|
}
|
||||||
.menubar {
|
.menubar {
|
||||||
opacity: .3;
|
opacity: .3;
|
||||||
|
|
||||||
// position: absolute;
|
// position: absolute;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user