Permalink
Browse files

Merge branch 't/12948' into major

  • Loading branch information...
Reinmar committed Mar 16, 2015
2 parents 85a9d3e + 73a4ee9 commit 4d77c1bb2bd880dfafef2f4779764fcbb862aadc
View
@@ -10,17 +10,19 @@
'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%
requires: 'widget,dialog',
icons: 'mathjax',
hidpi: true, // %REMOVE_LINE_CORE%
init: function( editor ) {
var cls = editor.config.mathJaxClass || 'math-tex';
var cls = editor.config.mathJaxClass || 'math-tex',
docsUrl = 'http://docs.ckeditor.com/#!/api/CKEDITOR.config-cfg-mathJaxLib';
if ( !editor.config.mathJaxLib && ( window.console && window.console.log ) ) {
window.console.log( 'Error: config.mathJaxLib property is not set. For more information visit: ', docsUrl );
}
editor.widgets.add( 'mathjax', {
inline: true,
@@ -127,8 +129,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 +341,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 +435,17 @@
} )();
/**
* 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';
* config.mathJaxLib = 'http://cdn.mathjax.org/mathjax/2.2-latest/MathJax.js?config=TeX-AMS_HTML';
*
* **Note:** Since CKEditor 4.5.0 this option does not have a default value, so it must
* be set in order to enable the MathJax plugin.
*
* @cfg {String} [mathJaxLib='http:\/\/cdn.mathjax.org\/mathjax\/2.2-latest\/MathJax.js?config=TeX-AMS_HTML']
* @since 4.3
* @cfg {String} mathJaxLib
* @member CKEDITOR.config
*/
@@ -24,53 +24,6 @@ <h1 class="samples">
<div class="warning deprecated">
This sample is not maintained anymore. Check out its <a href="http://sdk.ckeditor.com/samples/mathjax.html">brand new version in CKEditor SDK</a>.
</div>
<div class="description">
<p>
This sample shows the usage of the CKEditor mathematical plugin that introduces a MathJax widget. You can now use it to create or modify equations using TeX.
</p>
<p>
TeX content will be automatically replaced by a widget when you put it in a <code>&lt;span class="math-tex"&gt;</code> element. You can also add new equations by using the <strong>Math</strong> toolbar button and entering TeX content in the plugin dialog window. After you click <strong>OK</strong>, a widget will be inserted into the editor content.
</p>
<p>
The output of the editor will be plain TeX with <a href="http://www.mathjax.org/">MathJax</a> delimiters: <code>\(</code> and <code>\)</code>, as in the code below:
</p>
<pre class="samples">
&lt;span class="math-tex"&gt;\( \sqrt{1} + (1)^2 = 2 \)&lt;/span&gt;
</pre>
<p>
To transform TeX into a visual equation, a page must include the <a href="http://docs.mathjax.org/en/latest/start.html">MathJax script</a>.
</p>
<p>
In order to use the new plugin, include it in the <code><a class="samples" href="http://docs.ckeditor.com/#!/api/CKEDITOR.config-cfg-extraPlugins">config.extraPlugins</a></code> configuration setting.
</p>
<pre class="samples">
CKEDITOR.replace( '<em>textarea_id</em>', {
<strong>extraPlugins: 'mathjax'</strong>
} );
</pre>
<p id="ie8-warning">
Please note that this plugin is not compatible with Internet Explorer 8.
</p>
</div>
<textarea id="editor1" cols="10" rows="10">
&lt;p&gt;The following equations are represented in the HTML source code as LaTeX expressions.&lt;/p&gt;&lt;h1&gt;The Cauchy-Schwarz Inequality&lt;/h1&gt;&lt;p&gt;&lt;span class=&quot;math-tex&quot;&gt;\( \left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right) \)&lt;/span&gt;&lt;/p&gt;&lt;h1&gt;The probability of getting &lt;span class=&quot;math-tex&quot;&gt;\(k\)&lt;/span&gt; heads when flipping &lt;span class=&quot;math-tex&quot;&gt;\(n\)&lt;/span&gt; coins is&lt;/h1&gt;&lt;p&gt;&lt;span class=&quot;math-tex&quot;&gt;\(P(E) = {n \choose k} p^k (1-p)^{ n-k} \)&lt;/span&gt;&lt;/p&gt;&lt;p&gt;Finally, while displaying equations is useful for demonstration purposes, the ability to mix math and text in a paragraph is also important. This expression &lt;span class=&quot;math-tex&quot;&gt;\(\sqrt{3x-1}+(1+x)^2\)&lt;/span&gt; is an example of an inline equation. As you see, MathJax equations can be used this way as well, without disturbing the spacing between the lines.&lt;/p&gt;
</textarea>
<script>
CKEDITOR.replace( 'editor1', {
extraPlugins: 'mathjax',
height: 350
} );
if ( CKEDITOR.env.ie && CKEDITOR.env.version == 8 )
document.getElementById( 'ie8-warning' ).className = 'warning';
</script>
<div id="footer">
<hr>
<p>
@@ -4,6 +4,12 @@
( function() {
'use strict';
var mathJaxLib = bender.config.mathJaxLibPath;
if ( !mathJaxLib ) {
throw new Error( 'bender.config.mathJaxLibPath should be defined with the path to MathJax lib (MathJax.js?config=TeX-AMS_HTML).' );
}
bender.test( {
checkIFrame: function( config ) {
if ( CKEDITOR.env.ie && CKEDITOR.env.version < 9 )
@@ -17,7 +23,7 @@
doc = iFrame.getFrameDocument(),
fakeEditor = {
config: {
mathJaxLib: ''
mathJaxLib: mathJaxLib
},
fire: function() {
//mock
@@ -7,6 +7,12 @@
CKEDITOR.disableAutoInline = true;
var mathJaxLib = CKEDITOR.config.mathJaxLib = bender.config.mathJaxLibPath;
if ( !mathJaxLib ) {
throw new Error( 'bender.config.mathJaxLibPath should be defined with the path to MathJax lib (MathJax.js?config=TeX-AMS_HTML).' );
}
bender.editors = {
classic: {
name: 'classic'
@@ -8,6 +8,10 @@
var mathJaxLib = bender.config.mathJaxLibPath;
if ( !mathJaxLib ) {
throw new Error( 'bender.config.mathJaxLibPath should be defined with the path to MathJax lib (MathJax.js?config=TeX-AMS_HTML).' );
}
var editor;
function assertIFrame( iFrame ) {
@@ -51,9 +55,6 @@
assert.ignore();
}
assert.isString( mathJaxLib,
'bender.config.mathJaxLibPath should be defined with the path to MathJax lib (MathJax.js?config=TeX-AMS_HTML).' );
var tc = this;
editor = new CKEDITOR.replace( 'editor_mathjax', {

0 comments on commit 4d77c1b

Please sign in to comment.