Revert unrelated changes

This commit is contained in:
mattwr18 2019-12-16 11:00:55 +01:00
parent a7a1e4affc
commit 65b92786b7
3 changed files with 35 additions and 2 deletions

View File

@ -24,6 +24,7 @@
import { Editor, EditorContent } from 'tiptap'
import { History } from 'tiptap-extensions'
import linkify from 'linkify-it'
import stringHash from 'string-hash'
import { replace, build } from 'xregexp/xregexp-all.js'
import * as key from '../../constants/keycodes'
@ -106,7 +107,29 @@ export default {
return extensions
},
},
mounted() {
watch: {
value: {
immediate: true,
handler: function(content, old) {
const contentHash = stringHash(content)
if (!content || contentHash === this.lastValueHash) {
return
}
this.lastValueHash = contentHash
this.$nextTick(() => this.editor.setContent(content))
},
},
placeholder: {
immediate: true,
handler: function(val) {
if (!val || !this.editor) {
return
}
this.editor.extensions.options.placeholder.emptyNodeText = val
},
},
},
created() {
this.editor = new Editor({
content: this.value || '',
doc: this.doc,
@ -224,7 +247,11 @@ export default {
},
onUpdate(e) {
const content = e.getHTML()
this.$emit('input', content)
const contentHash = stringHash(content)
if (contentHash !== this.lastValueHash) {
this.lastValueHash = contentHash
this.$emit('input', content)
}
},
toggleLinkInput(attrs, element) {
if (!this.isLinkInputActive && attrs && element) {

View File

@ -80,6 +80,7 @@
"nuxt-dropzone": "^1.0.4",
"nuxt-env": "~0.1.0",
"stack-utils": "^1.0.2",
"string-hash": "^1.1.3",
"tippy.js": "^4.3.5",
"tiptap": "~1.26.3",
"tiptap-extensions": "~1.28.5",

View File

@ -15052,6 +15052,11 @@ strict-uri-encode@^1.0.0:
resolved "https://registry.yarnpkg.com/strict-uri-encode/-/strict-uri-encode-1.1.0.tgz#279b225df1d582b1f54e65addd4352e18faa0713"
integrity sha1-J5siXfHVgrH1TmWt3UNS4Y+qBxM=
string-hash@^1.1.3:
version "1.1.3"
resolved "https://registry.yarnpkg.com/string-hash/-/string-hash-1.1.3.tgz#e8aafc0ac1855b4666929ed7dd1275df5d6c811b"
integrity sha1-6Kr8CsGFW0Zmkp7X3RJ1311sgRs=
string-length@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/string-length/-/string-length-2.0.0.tgz#d40dbb686a3ace960c1cffca562bf2c45f8363ed"