2014-02-19 6 views

답변

0

HTMLArea의 원본 버전은이 기능을 지원하지 않습니다. TYPO3에는 몇 년 전에 word count feature이 구현 된 HTMLArea의 수정 된 버전이 함께 제공됩니다.

나는 TYPO3s RTE HTMLArea의 소스 코드를 살펴 보았고 단어 수는 하드 코드되었으며 구성 할 수 없습니다.

char 수를 추가 할 수있는 것은 HTMLArea의 선적 된 버전을 수정하는 것입니다.

파일 \typo3\sysext\rtehtmlarea\htmlarea\htmlarea.js을 열고 기능 updateWordCount을 다음으로 바꿉니다.

updateWordCount: function() { 
    var wordCount = 0; 
    if (this.getEditor().getMode() == 'wysiwyg') { 
      // Get the html content 
     var text = this.getEditor().getHTML(); 
     if (!Ext.isEmpty(text)) { 
       // Replace html tags with spaces 
      text = text.replace(HTMLArea.RE_htmlTag, ' '); 
       // Replace html space entities 
      text = text.replace(/ | /gi, ' '); 
       // Remove numbers and punctuation 
      text = text.replace(HTMLArea.RE_numberOrPunctuation, ''); 
       // Get the number of word 
      wordCount = text.length; 
     } 
    } 
     // Update the word count of the status bar 
    this.statusBarWordCount.dom.innerHTML = wordCount + ' ' + (wordCount == 1 ? 'char' : 'chars'); 
}, 

"char"및 "chars"단어의 번역을 고려하지 않는 빠르며 더러운 해결책입니다.

htmlarea.js을 수정하는 경우 각 TYPO3 핵심 업데이트 후에 수동으로 변경 사항을 업데이트해야한다는 점에 유의하십시오.

0

당신이 TYPO3 7을 사용하는 경우는 previos 답변에서이 변형 한 스크립트를 사용해야합니다 :

this.statusBarWordCount.dom.innerHTML 
:

updateWordCount: function() { 
var wordCount = 0; 
if (this.getEditor().getMode() == 'wysiwyg') { 
     // Get the html content 
    var text = this.getEditor().getHTML(); 
    if (!Ext.isEmpty(text)) { 
      // Replace html tags with spaces 
     text = text.replace(HTMLArea.RE_htmlTag, ' '); 
      // Replace html space entities 
     text = text.replace(/ | /gi, ' '); 
      // Remove numbers and punctuation 
     text = text.replace(HTMLArea.RE_numberOrPunctuation, ''); 
      // Get the number of word 
     wordCount = text.length; 
    } 
} 
    // Update the word count of the status bar 
this.statusBarWordCount.innerHTML = wordCount + ' ' + (wordCount == 1 ? 'char' : 'chars'); 
}, 

내가 다음 줄에서 .dom을 제거했다

관련 문제