maximum number of characters in content without html tags is 2000, characters are counted and number is displayed. regex is strongly shortened.

This commit is contained in:
senderfm 2019-07-10 09:18:47 +02:00
parent aa264a0d56
commit 3481b1f24b

View File

@ -10,8 +10,10 @@
/>
</hc-teaser-image>
<ds-input model="title" class="post-title" placeholder="Title" name="title" autofocus />
<small style="width:100%;position:relative;left:90%">{{ form.title.length }}/64</small>
<no-ssr>
<hc-editor :users="users" :value="form.content" @input="updateEditorContent" />
<small style="width:100%;position:relative;left:90%">{{ form.contentLength }}/2000</small>
</no-ssr>
<ds-space margin-bottom="xxx-large" />
<hc-categories-select
@ -80,6 +82,7 @@ export default {
form: {
title: '',
content: '',
contentLength: 0,
teaserImage: null,
image: null,
language: null,
@ -88,13 +91,14 @@ export default {
},
formSchema: {
title: { required: true, min: 3, max: 64 },
content: { required: true, min: 3 },
content: { required: true, min: 3, max: 2000 },
},
id: null,
loading: false,
disabled: true,
slug: null,
users: [],
n: 0,
}
},
watch: {
@ -169,17 +173,15 @@ export default {
},
updateEditorContent(value) {
// this.form.content = value
this.$refs.contributionForm.update('content', value)
this.disabled = true
if (
value.replace(
/<p>|<\/p>|<h3>|<\/h3>|<h4>|<\/h4>|<ul>|<\/ul>|<ol>|<\/ol>|<li>|<\/li>|<blockquote>|<\/blockquote>|<strong>|<\/strong>|<em>|<\/em>|<a.*>|<\/a>/gm,
'',
).length > 3
) {
this.n = value.replace(/<\/?[^>]+(>|$)/gm, '').length
this.form.contentLength = this.n
if (this.n > 3 && this.n < 2000) {
this.disabled = false
}
this.$refs.contributionForm.update('content', value)
},
availableLocales() {
orderBy(locales, 'name').map(locale => {