From 0dd600746af178086f9f34e106fc35199615a5e9 Mon Sep 17 00:00:00 2001 From: senderfm Date: Wed, 10 Jul 2019 09:18:47 +0200 Subject: [PATCH] maximum number of characters in content without html tags is 2000, characters are counted and number is displayed. regex is strongly shortened. --- .../ContributionForm/ContributionForm.vue | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/webapp/components/ContributionForm/ContributionForm.vue b/webapp/components/ContributionForm/ContributionForm.vue index 9f7ffa7e4..8b4aa6b9e 100644 --- a/webapp/components/ContributionForm/ContributionForm.vue +++ b/webapp/components/ContributionForm/ContributionForm.vue @@ -10,6 +10,7 @@ /> + {{ form.title.length }}/64 + {{ form.contentLength }}/2000 - {{ $t('actions.cancel') }} - + >{{ $t('actions.cancel') }} - {{ $t('actions.save') }} - + >{{ $t('actions.save') }} @@ -86,6 +84,7 @@ export default { form: { title: '', content: '', + contentLength: 0, teaserImage: null, image: null, language: null, @@ -94,14 +93,18 @@ 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: [], +<<<<<<< HEAD hashtags: [], +======= + n: 0, +>>>>>>> maximum number of characters in content without html tags is 2000, characters are counted and number is displayed. regex is strongly shortened. } }, watch: { @@ -176,17 +179,15 @@ export default { }, updateEditorContent(value) { // this.form.content = value + this.$refs.contributionForm.update('content', value) + this.disabled = true - if ( - value.replace( - /

|<\/p>|

|<\/h3>|

|<\/h4>|
    |<\/ul>|
      |<\/ol>|
    1. |<\/li>|
      |<\/blockquote>||<\/strong>||<\/em>||<\/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 => {