@ -4,17 +4,14 @@
* /
/ * *
* @ fileOverview [ Mathematical Formulas ] ( http : //ckeditor.com/addon/mathjax) plugin.
* @ fileOverview The [ Mathematical Formulas ] ( http : //ckeditor.com/addon/mathjax) plugin that allows you to create and modify mathematical equations written in TeX directly in CKEditor. .
* /
'use strict' ;
( function ( ) {
var cdn = 'http:\/\/cdn.mathjax.org\/mathjax\/2.2-latest\/MathJax.js?config=TeX-AMS_HTML' ;
CKEDITOR . plugins . add ( 'mathjax' , {
lang : 'af,ar,ca,cs,cy,da,de,el,en,en-gb,eo,es,fa,fi,fr,gl,he,hr,hu,it,ja,km,ku,lt,nb,nl,no,pl,pt,pt-br,ro,ru,sk,sl,sq,sv,tr,tt,uk,vi,zh,zh-cn' , // %REMOVE_LINE_CORE%
lang : 'af,ar,bg,ca,cs,cy,da,de,el,en,en-gb,eo,es,eu,fa,fi,fr,gl,he,hr,hu,id,it,ja,km,ko,ku,lt,nb,nl,no,pl,pt,pt-br,ro,ru,sk,sl,sq,sv,tr,tt,ug,uk,vi,zh,zh-cn' , // %REMOVE_LINE_CORE%
requires : 'widget,dialog' ,
icons : 'mathjax' ,
hidpi : true , // %REMOVE_LINE_CORE%
@ -22,6 +19,10 @@
init : function ( editor ) {
var cls = editor . config . mathJaxClass || 'math-tex' ;
if ( ! editor . config . mathJaxLib ) {
CKEDITOR . error ( 'mathjax-no-config' ) ;
}
editor . widgets . add ( 'mathjax' , {
inline : true ,
dialog : 'mathjax' ,
@ -127,8 +128,10 @@
// Add MathJax script to page preview.
editor . on ( 'contentPreview' , function ( evt ) {
evt . data . dataValue = evt . data . dataValue . replace ( /<\/head>/ ,
'<script src="' + ( editor . config . mathJaxLib ? CKEDITOR . getUrl ( editor . config . mathJaxLib ) : cdn ) + '"><\/script><\/head>' ) ;
evt . data . dataValue = evt . data . dataValue . replace (
/<\/head>/ ,
'<script src="' + CKEDITOR . getUrl ( editor . config . mathJaxLib ) + '"><\/script><\/head>'
) ;
} ) ;
editor . on ( 'paste' , function ( evt ) {
@ -337,7 +340,7 @@
'</script>' +
// Load MathJax lib.
'<script src="' + ( editor . config . mathJaxLib || cdn ) + '"></script>' +
'<script src="' + ( editor . config . mathJaxLib ) + '"></script>' +
'</head>' +
'<body style="padding:0;margin:0;background:transparent;overflow:hidden">' +
'<span id="preview"></span>' +
@ -431,14 +434,20 @@
} ) ( ) ;
/ * *
* Sets the path to the MathJax library . It can be both a local
* resource and a location different than the default CDN .
* Sets the path to the MathJax library . It can be both a local resource and a location different than the default CDN .
*
* Please note that this must be a full or absolute path .
*
* config . mathJaxLib = 'http:\/\/example.com\/libs\/MathJax.js' ;
* Read more in the [ documentation ] ( # ! / g u i d e / d e v _ m a t h j a x )
* and see the [ SDK sample ] ( http : //sdk.ckeditor.com/samples/mathjax.html).
*
* @ cfg { String } [ mathJaxLib = 'http:\/\/cdn.mathjax.org\/mathjax\/2.2-latest\/MathJax.js?config=TeX-AMS_HTML' ]
* config . mathJaxLib = '//cdn.mathjax.org/mathjax/2.2-latest/MathJax.js?config=TeX-AMS_HTML' ;
*
* * * Note : * * Since CKEditor 4.5 this option does not have a default value , so it must
* be set in order to enable the MathJax plugin .
*
* @ since 4.3
* @ cfg { String } mathJaxLib
* @ member CKEDITOR . config
* /
@ -455,6 +464,9 @@
*
* < span class = "my-math" > \ ( \ sqrt { 4 } = 2 \ ) < / s p a n >
*
* Read more in the [ documentation ] ( # ! / g u i d e / d e v _ m a t h j a x )
* and see the [ SDK sample ] ( http : //sdk.ckeditor.com/samples/mathjax.html).
*
* @ cfg { String } [ mathJaxClass = 'math-tex' ]
* @ member CKEDITOR . config
* /