Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
/*
2
 * Remove   entities which were inserted ie. when removing a space and
3
 * immediately inputting a space.
4
 *
5
 * NB: We could also set config.basicEntities to false, but this is stongly
6
 * adviced against since this also does not turn ie. < into &lt;.
7
 * @link http://stackoverflow.com/a/16468264/328272
8
 *
9
 * Based on StackOverflow answer.
10
 * @link http://stackoverflow.com/a/14549010/328272
11
 */
12
CKEDITOR.plugins.add('removeRedundantNBSP', {
13
  afterInit: function(editor) {
14
    var config = editor.config,
15
      dataProcessor = editor.dataProcessor,
16
      htmlFilter = dataProcessor && dataProcessor.htmlFilter;
17
 
18
    if (htmlFilter) {
19
      htmlFilter.addRules({
20
        text: function(text) {
21
          return text.replace(/(\w)&nbsp;/gi, '$1 ');
22
        }
23
      }, {
24
        applyToAll: true,
25
        excludeNestedEditable: true
26
      });
27
    }
28
  }
29
});