Skip to content

Commit

Permalink
Add wordcount plugin, feature request #36
Browse files Browse the repository at this point in the history
  • Loading branch information
Jelte Lagendijk committed May 11, 2016
1 parent 9c39917 commit 8c060c5
Show file tree
Hide file tree
Showing 29 changed files with 888 additions and 7 deletions.
10 changes: 10 additions & 0 deletions src/CKEditorForMendix/CKEditorForMendix.xml
Original file line number Diff line number Diff line change
Expand Up @@ -188,5 +188,15 @@
<category>Images</category>
<description>This constraint might be used to filter the set of browsable images. (not functional right now)</description>
</property>
<property key="countPlugin" type="boolean" required="true" defaultValue="false">
<caption>Count plugin</caption>
<category>Count</category>
<description>Enable/disable wordcount plugin. This will have the ability to set a max amount of characters</description>
</property>
<property key="countPluginMaxCount" type="integer" required="true" defaultValue="0">
<caption>Maximum characters</caption>
<category>Count</category>
<description>If the Count plugin is enabled, specifiy the max amount of characters (including HTML). If you set this to 0, it will be unlimited.</description>
</property>
</properties>
</widget>
27 changes: 20 additions & 7 deletions src/CKEditorForMendix/widget/CKEditorForMendix.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ define([
"maximize",
"uploadimage",
"simple-image-browser",
"pastebase64"
"pastebase64",
"wordcount"
],

// CKEditor instances.
Expand Down Expand Up @@ -183,7 +184,7 @@ define([
},

_editorChange: function (data) {
logger.debug(this.id + "._editorChange:", data);
logger.debug(this.id + "._editorChange:");
if (this._contextObj !== null) {
this._contextObj.set(this.messageString, data);
}
Expand Down Expand Up @@ -331,14 +332,28 @@ define([
}

this._settings[this.id].config.imageUploadUrl = "http://localhost/"; // not used
this._settings[this.id].config.extraPlugins = this._getPlugins();

if (!this._useImageUpload) {
this._settings[this.id].config.extraPlugins = this._getPlugins(false);
this._settings[this.id].config.removePlugins = "simple-image-browser,uploadimage";
} else {
this._settings[this.id].config.extraPlugins = this._getPlugins(true);
this._settings[this.id].config.removePlugins = "pastebase64";
}

if (!this.countPlugin) {
this._settings[this.id].config.removePlugins = "wordcount";
} else {
this._settings[this.id].config.wordcount = {
showParagraphs: false,
showWordCount: true,
showCharCount: true,
countSpacesAsChars: true,
countHTML: true,
maxWordCount: -1,
maxCharCount: this.countPluginMaxCount > 0 ? this.countPluginMaxCount : -1
};
}

this._settings[this.id].config.extraAllowedContent = "*[data-*]";

// Create a CKEditor from HTML element.
Expand Down Expand Up @@ -615,6 +630,4 @@ define([
});
});

require(["CKEditorForMendix/widget/CKEditorForMendix"], function () {
"use strict";
});
require(["CKEditorForMendix/widget/CKEditorForMendix"]);
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.cke_wordcount {display:block;float:right;margin-top:-2px;margin-right:3px;color:black;}

.cke_wordcountLimitReached {color:red! important}
11 changes: 11 additions & 0 deletions src/CKEditorForMendix/widget/lib/plugins/wordcount/lang/ar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Arabic Translation by Amine BENHAMIDA

CKEDITOR.plugins.setLang('wordcount', 'ar', {
WordCount: 'كلمات:',
CharCount: 'حروف:',
CharCountWithHTML: 'حروف مع إتش تي إم إل',
Paragraphs: 'فقرات',
pasteWarning: 'لا يمكن اضافة هذا المحتوى لانه تجاوز الحد الاقصى',
Selected: 'محدد: ',
title: 'احصائيات'
});
13 changes: 13 additions & 0 deletions src/CKEditorForMendix/widget/lib/plugins/wordcount/lang/ca.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
CKEDITOR.plugins.setLang('wordcount', 'ca', {
WordCount: 'Paraules:',
CharCount: 'Caràcters:',
CharCountWithHTML: 'Caràcters (including HTML):',
Paragraphs: 'Paragraphs:',
pasteWarning: 'Content can not be pasted because it is above the allowed limit',
Selected: 'Selected: ',
title: 'Estadístiques'
});
13 changes: 13 additions & 0 deletions src/CKEditorForMendix/widget/lib/plugins/wordcount/lang/da.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
CKEDITOR.plugins.setLang('wordcount', 'da', {
WordCount: 'Ord:',
CharCount: 'Karakterer:',
CharCountWithHTML: 'Karakterer (med HTML):',
Paragraphs: 'Afsnit:',
pasteWarning: 'Indholdet kan ikke indsættes da det er længere end den tilladte grænse.',
Selected: 'Markeret: ',
title: 'Statistik'
});
13 changes: 13 additions & 0 deletions src/CKEditorForMendix/widget/lib/plugins/wordcount/lang/de.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
CKEDITOR.plugins.setLang('wordcount', 'de', {
WordCount: 'Wörter:',
CharCount: 'Zeichen:',
CharCountWithHTML: 'Zeichen (inkl. HTML):',
Paragraphs: 'Absätze:',
pasteWarning: 'Content can not be pasted because it is above the allowed limit',
Selected: 'Selected: ',
title: 'Statistik'
});
13 changes: 13 additions & 0 deletions src/CKEditorForMendix/widget/lib/plugins/wordcount/lang/el.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
CKEDITOR.plugins.setLang('wordcount', 'el', {
WordCount: 'Λέξεις:',
CharCount: 'Χαρακτήρες:',
CharCountWithHTML: 'Χαρακτήρες (μαζί με HTML):',
Paragraphs: 'Paragraphs:',
pasteWarning: 'Content can not be pasted because it is above the allowed limit',
Selected: 'Selected: ',
title: 'Στατιστικά'
});
13 changes: 13 additions & 0 deletions src/CKEditorForMendix/widget/lib/plugins/wordcount/lang/en.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
CKEDITOR.plugins.setLang('wordcount', 'en', {
WordCount: 'Words:',
CharCount: 'Characters:',
CharCountWithHTML: 'Characters (with HTML):',
Paragraphs: 'Paragraphs:',
pasteWarning: 'Content can not be pasted because it is above the allowed limit',
Selected: 'Selected: ',
title: 'Statistics'
});
13 changes: 13 additions & 0 deletions src/CKEditorForMendix/widget/lib/plugins/wordcount/lang/es.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
CKEDITOR.plugins.setLang('wordcount', 'es', {
WordCount: 'Palabras:',
CharCount: 'Carácteres:',
CharCountWithHTML: 'Carácteres (con HTML):',
Paragraphs: 'Párrafos:',
pasteWarning: 'El contenido no se puede pegar, ya que se encuentra fuera del límite permitido',
Selected: 'Seleccionado: ',
title: 'Estadísticas'
});
14 changes: 14 additions & 0 deletions src/CKEditorForMendix/widget/lib/plugins/wordcount/lang/fi.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* Finnish localisation.
*
* @author Joel Posti / Response200.pro
*/
CKEDITOR.plugins.setLang('wordcount', 'fi', {
WordCount: 'Sanoja:',
CharCount: 'Merkkejä:',
CharCountWithHTML: 'Merkkejä (ml. HTML):',
Paragraphs: 'Kappaleita:',
pasteWarning: 'Sisältöä ei voida liittää, koska se ylittää sallitun rajan.',
Selected: 'Valittuna: ',
title: 'Statistiikkaa'
});
11 changes: 11 additions & 0 deletions src/CKEditorForMendix/widget/lib/plugins/wordcount/lang/fr.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// French Translation by Nicolas M. et Pierre-Luc Auclair

CKEDITOR.plugins.setLang('wordcount', 'fr', {
WordCount: 'Mots :',
CharCount: 'Caractères :',
CharCountWithHTML: 'Caractères (incluant HTML) :',
Paragraphs: 'Paragraphes :',
pasteWarning: 'Le contenu ne peut pas être collé car il dépasse la limite autorisée',
Selected: 'Sélectionné :',
title: 'Statistiques'
});
13 changes: 13 additions & 0 deletions src/CKEditorForMendix/widget/lib/plugins/wordcount/lang/he.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
CKEDITOR.plugins.setLang('wordcount', 'he', {
WordCount: 'מילים:',
CharCount: 'תווים:',
CharCountWithHTML: 'תווים (כולל HTML):',
Paragraphs: 'פסקאות:',
pasteWarning: 'לא ניתן להדביק תוכן בשל עודף תווים',
Selected: 'נבחר: ',
title: 'סטטיסטיקות'
});
13 changes: 13 additions & 0 deletions src/CKEditorForMendix/widget/lib/plugins/wordcount/lang/hr.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
CKEDITOR.plugins.setLang('wordcount', 'hr', {
WordCount: 'Riječi:',
CharCount: 'Znakova:',
CharCountWithHTML: 'Znakova (uključujući HTML):',
Paragraphs: 'Paragraphs:',
pasteWarning: 'Content can not be pasted because it is above the allowed limit',
Selected: 'Selected: ',
title: 'Statistika'
});
14 changes: 14 additions & 0 deletions src/CKEditorForMendix/widget/lib/plugins/wordcount/lang/it.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
@author translation: Davide Montorio
*/
CKEDITOR.plugins.setLang('wordcount', 'it', {
WordCount: 'Parole:',
CharCount: 'Caratteri:',
CharCountWithHTML: 'Caratteri (HTML incluso):',
Paragraphs: 'Paragraphs:',
pasteWarning: 'Content can not be pasted because it is above the allowed limit',
Selected: 'Selected: ',
title: 'Statistiche'
});
13 changes: 13 additions & 0 deletions src/CKEditorForMendix/widget/lib/plugins/wordcount/lang/jp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
CKEDITOR.plugins.setLang('wordcount', 'jp', {
WordCount: '単語数:',
CharCount: '文字数:',
CharCountWithHTML: '文字数 (with HTML):',
Paragraphs: 'Paragraphs:',
pasteWarning: 'Content can not be pasted because it is above the allowed limit',
Selected: 'Selected: ',
title: 'ワードカウント'
});
13 changes: 13 additions & 0 deletions src/CKEditorForMendix/widget/lib/plugins/wordcount/lang/nl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
CKEDITOR.plugins.setLang('wordcount', 'nl', {
WordCount: 'Woorden:',
CharCount: 'Tekens:',
CharCountWithHTML: 'Tekens (inclusief HTML):',
Paragraphs: 'Paragraven:',
pasteWarning: 'De tekst kan niet worden geplakt omdat de limiet is overschreden',
Selected: 'Selected: ',
title: 'Statistieken'
});
10 changes: 10 additions & 0 deletions src/CKEditorForMendix/widget/lib/plugins/wordcount/lang/no.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Norwegian translation by Vegard S.
CKEDITOR.plugins.setLang('wordcount', 'no', {
WordCount: 'Ord:',
CharCount: 'Tegn:',
CharCountWithHTML: 'Tegn (including HTML):',
Paragraphs: 'Paragraphs:',
pasteWarning: 'Content can not be pasted because it is above the allowed limit',
Selected: 'Selected: ',
title: 'Statistikk'
});
13 changes: 13 additions & 0 deletions src/CKEditorForMendix/widget/lib/plugins/wordcount/lang/pl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
CKEDITOR.plugins.setLang('wordcount', 'pl', {
WordCount: 'Słów:',
CharCount: 'Znaków:',
CharCountWithHTML: 'Znaków (wraz z kodem HTML):',
Paragraphs: 'Paragraphs:',
pasteWarning: 'Content can not be pasted because it is above the allowed limit',
Selected: 'Selected: ',
title: 'Statystyka'
});
13 changes: 13 additions & 0 deletions src/CKEditorForMendix/widget/lib/plugins/wordcount/lang/pt-br.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
CKEDITOR.plugins.setLang('wordcount', 'pt-br', {
WordCount: 'Contagem de palavras:',
CharCount: 'Contagem de carateres:',
CharCountWithHTML: 'Carateres (incluindo HTML):',
Paragraphs: 'Parágrafos:',
pasteWarning: 'Conteúdo não pode ser colado porque ultrapassa o limite permitido',
Selected: 'Selecionado: ',
title: 'Estatísticas'
});
9 changes: 9 additions & 0 deletions src/CKEditorForMendix/widget/lib/plugins/wordcount/lang/pt.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CKEDITOR.plugins.setLang('wordcount', 'pt', {
WordCount: 'Palavras:',
CharCount: 'Caracteres:',
CharCountWithHTML: 'Carateres (incluindo HTML):',
Paragraphs: 'Parágrafos:',
pasteWarning: 'O conteúdo não pode ser colado porque ultrapassa o limite permitido',
Selected: 'Selecionado: ',
title: 'Estatísticas'
});
13 changes: 13 additions & 0 deletions src/CKEditorForMendix/widget/lib/plugins/wordcount/lang/ru.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
CKEDITOR.plugins.setLang('wordcount', 'ru', {
WordCount: 'Слов:',
CharCount: 'Символов:',
CharCountWithHTML: ' (включая HTML разметку):',
Paragraphs: 'Параграфов:',
pasteWarning: 'Контент не может быть вставлен, т.к. привышает допустимый лимит',
Selected: 'Выделено: ',
title: 'Статистика'
});
13 changes: 13 additions & 0 deletions src/CKEditorForMendix/widget/lib/plugins/wordcount/lang/sv.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
CKEDITOR.plugins.setLang('wordcount', 'sv', {
WordCount: 'Ord:',
CharCount: 'Tecken:',
CharCountWithHTML: 'Tecken (inklusive HTML):',
Paragraphs: 'Paragraphs:',
pasteWarning: 'Content can not be pasted because it is above the allowed limit',
Selected: 'Selected: ',
title: 'Statistik'
});
13 changes: 13 additions & 0 deletions src/CKEditorForMendix/widget/lib/plugins/wordcount/lang/tr.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
Mesut ÇAKIR
[email protected]
*/
CKEDITOR.plugins.setLang('wordcount', 'tr', {
WordCount: 'Kelime:',
CharCount: 'Karakter:',
CharCountWithHTML: 'Karakter (HTML dahil):',
Paragraphs: 'Paragraf:',
pasteWarning: 'Content can not be pasted because it is above the allowed limit',
Selected: 'Selected: ',
title: 'İstatistik'
});
13 changes: 13 additions & 0 deletions src/CKEditorForMendix/widget/lib/plugins/wordcount/lang/zh-cn.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
CKEDITOR.plugins.setLang('wordcount', 'zh-cn', {
WordCount: '词数:',
CharCount: '字符:',
CharCountWithHTML: '字符 (含HTML)',
Paragraphs: '段落:',
pasteWarning: '由于上限允许,内容不能粘贴',
Selected: '已选择: ',
title: '统计'
});
Loading

0 comments on commit 8c060c5

Please sign in to comment.