diff --git a/Test/Case/View/Elements/MathjaxJsTest.php b/Test/Case/View/Elements/MathjaxJsTest.php index 1d1c55f..95b0de3 100644 --- a/Test/Case/View/Elements/MathjaxJsTest.php +++ b/Test/Case/View/Elements/MathjaxJsTest.php @@ -66,30 +66,24 @@ public function testMathjaxJs() { $this->assertRegExp($pattern, $view); $expected = - ''; + $this->assertTextContains($expected, $view); $pattern = preg_quote('', '/'); + '\/components\/MathJax\/es5\/tex-chtml\.js\?[0-9]+">\<\/script>'; $this->assertRegExp('/' . $pattern . '/', $view); - $expected = - ''; $this->assertTextContains($expected, $view); } diff --git a/View/Elements/mathjax_js.ctp b/View/Elements/mathjax_js.ctp index 9919626..68c3520 100644 --- a/View/Elements/mathjax_js.ctp +++ b/View/Elements/mathjax_js.ctp @@ -9,17 +9,16 @@ */ // skipStartupTypeset: true によって MathJaxの自動読み込みを無効にする -echo $this->Html->scriptStart(array('inline' => false, 'type' => 'text/x-mathjax-config')); +echo $this->Html->scriptStart(array('inline' => false)); ?> -MathJax.Hub.Config({ - skipStartupTypeset: true, - tex2jax: { - inlineMath: [['$$','$$'], ['\\\\(','\\\\)']], - displayMath: [['\\\\[','\\\\]']] - }, - asciimath2jax: { - delimiters: [['$$','$$']] +MathJax = { + tex: { + inlineMath: [['$$', '$$'], ['\\\\(', '\\\\)']], + displayMath: [['\\\\[', '\\\\]']] } +}; +$(document).ready(function(){ + MathJax.typesetPromise(); }); Html->scriptEnd(); @@ -27,18 +26,6 @@ echo $this->Html->scriptEnd(); // wysiwyg呼び出し echo $this->NetCommonsHtml->script( array( - '/components/MathJax/MathJax.js?config=TeX-MML-AM_CHTML', + '/components/MathJax/es5/tex-chtml.js', ) ); -?> - -Html->scriptStart(array('inline' => false)); -?> -$(document).ready(function(){ - MathJax.Hub.Queue(['Typeset', MathJax.Hub, 'nc-container']); -}); -Html->scriptEnd(); diff --git a/View/Helper/WysiwygHelper.php b/View/Helper/WysiwygHelper.php index 282635b..5bd7b33 100644 --- a/View/Helper/WysiwygHelper.php +++ b/View/Helper/WysiwygHelper.php @@ -119,7 +119,7 @@ public function wysiwygScript() { 'tex_icon' => $this->NetCommonsHtml->url('/wysiwyg/img/title_icons/tex.svg'), // MathJax JSのリンク 'mathjax_js' => $this->NetCommonsHtml->url( - '/components/MathJax/MathJax.js?config=TeX-MML-AM_CHTML' + '/components/MathJax/es5/tex-chtml.js' ), // ファイル・画像アップロードパス 'file_upload_path' => $this->NetCommonsHtml->url('/wysiwyg/file/upload'), diff --git a/bower.json b/bower.json index bea47f8..472c0fe 100644 --- a/bower.json +++ b/bower.json @@ -10,7 +10,7 @@ ], "license": "NetCommons License", "dependencies": { - "MathJax": "components/MathJax#>=2.6", + "MathJax": ">=3.0 <4.0", "jquery.simplePagination": "*" } } diff --git a/webroot/css/tex.css b/webroot/css/tex.css index 9a0e2fe..9a1b7cb 100644 --- a/webroot/css/tex.css +++ b/webroot/css/tex.css @@ -7,43 +7,54 @@ #tex-preview-body, #tex-dialog #tex-preview, #tex-dialog #tex-preview .MathJax_Preview { - line-height: initial; + line-height: initial; } /** tinymceのstyle補正 */ -#tex-preview.mce-container * { - line-height: 0 !important; - /** defaut reset */ +#tex-preview-body.mce-container-body { + width: 100% !important; +} +#tex-preview.mce-container mjx-math { + display: none; +} +#tex-preview.mce-container mjx-assistive-mml, +#tex-preview.mce-container mjx-assistive-mml * { + all: revert; +/* line-height: 0 !important; + * defaut reset margin: initial; - padding: initial; - border: initial; - outline: initial; - vertical-align: initial; - background: initial; - text-decoration: initial; - color: initial; - font-size: initial; - text-shadow: initial; - float: initial; - position: initial; - width: initial; - height: initial; - white-space: initial; - cursor: initial; - -webkit-tap-highlight-color: initial; - line-height: initial; - font-weight: initial; - text-align: initial; - -moz-box-sizing: initial; - -webkit-box-sizing: initial; - box-sizing: initial; - direction: initial; - max-width: initial; + padding: initial; + border: initial; + outline: initial; + vertical-align: initial; + background: initial; + text-decoration: initial; + color: initial; + font-family: initial; + font-size: initial; + text-shadow: initial; + float: initial; + position: initial; + width: initial; + height: initial; + white-space: initial; + cursor: initial; + -webkit-tap-highlight-color: initial; + line-height: initial; + font-weight: initial; + text-align: initial; + -moz-box-sizing: initial; + -webkit-box-sizing: initial; + box-sizing: initial; + direction: initial; + max-width: initial;*/ } + /** * jsから挿入されるstyleタグの中身抜き出し(.mjx-chtml関連) * (セレクタ先頭に#tex-previewを付与) */ -#tex-preview .mjx-chtml {display: inline-block; line-height: 0; text-indent: 0; text-align: left; text-transform: none; font-style: normal; font-weight: normal; font-size: 100%; font-size-adjust: none; letter-spacing: normal; word-wrap: normal; word-spacing: normal; white-space: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0; min-height: 0; border: 0; margin: 0; padding: 1px 0} +/* +/*#tex-preview .mjx-chtml {display: inline-block; line-height: 0; text-indent: 0; text-align: left; text-transform: none; font-style: normal; font-weight: normal; font-size: 100%; font-size-adjust: none; letter-spacing: normal; word-wrap: normal; word-spacing: normal; white-space: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0; min-height: 0; border: 0; margin: 0; padding: 1px 0} #tex-preview .MJXc-display {display: block; text-align: center; margin: 1em 0; padding: 0} #tex-preview .mjx-chtml[tabindex]:focus, body :focus .mjx-chtml[tabindex] {display: inline-table} #tex-preview .mjx-math {display: inline-block; border-collapse: separate; border-spacing: 0} @@ -120,53 +131,53 @@ #tex-preview .MJXc-TeX-size3-R {font-family: MJXc-TeX-size3-R,MJXc-TeX-size3-Rw} #tex-preview .MJXc-TeX-size4-R {font-family: MJXc-TeX-size4-R,MJXc-TeX-size4-Rw} @font-face {font-family: MJXc-TeX-ams-R; src: local('MathJax_AMS'), local('MathJax_AMS-Regular')} -@font-face {font-family: MJXc-TeX-ams-Rw; src /*1*/: url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/eot/MathJax_AMS-Regular.eot'); src /*2*/: url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/woff/MathJax_AMS-Regular.woff') format('woff'), url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/otf/MathJax_AMS-Regular.otf') format('opentype')} +@font-face {font-family: MJXc-TeX-ams-Rw; src 1: url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/eot/MathJax_AMS-Regular.eot'); src 2: url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/woff/MathJax_AMS-Regular.woff') format('woff'), url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/otf/MathJax_AMS-Regular.otf') format('opentype')} @font-face {font-family: MJXc-TeX-cal-B; src: local('MathJax_Caligraphic Bold'), local('MathJax_Caligraphic-Bold')} @font-face {font-family: MJXc-TeX-cal-Bx; src: local('MathJax_Caligraphic'); font-weight: bold} -@font-face {font-family: MJXc-TeX-cal-Bw; src /*1*/: url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/eot/MathJax_Caligraphic-Bold.eot'); src /*2*/: url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/woff/MathJax_Caligraphic-Bold.woff') format('woff'), url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/otf/MathJax_Caligraphic-Bold.otf') format('opentype')} +@font-face {font-family: MJXc-TeX-cal-Bw; src 1: url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/eot/MathJax_Caligraphic-Bold.eot'); src 2: url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/woff/MathJax_Caligraphic-Bold.woff') format('woff'), url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/otf/MathJax_Caligraphic-Bold.otf') format('opentype')} @font-face {font-family: MJXc-TeX-frak-R; src: local('MathJax_Fraktur'), local('MathJax_Fraktur-Regular')} -@font-face {font-family: MJXc-TeX-frak-Rw; src /*1*/: url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/eot/MathJax_Fraktur-Regular.eot'); src /*2*/: url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/woff/MathJax_Fraktur-Regular.woff') format('woff'), url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/otf/MathJax_Fraktur-Regular.otf') format('opentype')} +@font-face {font-family: MJXc-TeX-frak-Rw; src 1: url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/eot/MathJax_Fraktur-Regular.eot'); src 2: url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/woff/MathJax_Fraktur-Regular.woff') format('woff'), url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/otf/MathJax_Fraktur-Regular.otf') format('opentype')} @font-face {font-family: MJXc-TeX-frak-B; src: local('MathJax_Fraktur Bold'), local('MathJax_Fraktur-Bold')} @font-face {font-family: MJXc-TeX-frak-Bx; src: local('MathJax_Fraktur'); font-weight: bold} -@font-face {font-family: MJXc-TeX-frak-Bw; src /*1*/: url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/eot/MathJax_Fraktur-Bold.eot'); src /*2*/: url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/woff/MathJax_Fraktur-Bold.woff') format('woff'), url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/otf/MathJax_Fraktur-Bold.otf') format('opentype')} +@font-face {font-family: MJXc-TeX-frak-Bw; src 1: url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/eot/MathJax_Fraktur-Bold.eot'); src 2: url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/woff/MathJax_Fraktur-Bold.woff') format('woff'), url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/otf/MathJax_Fraktur-Bold.otf') format('opentype')} @font-face {font-family: MJXc-TeX-math-BI; src: local('MathJax_Math BoldItalic'), local('MathJax_Math-BoldItalic')} @font-face {font-family: MJXc-TeX-math-BIx; src: local('MathJax_Math'); font-weight: bold; font-style: italic} -@font-face {font-family: MJXc-TeX-math-BIw; src /*1*/: url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/eot/MathJax_Math-BoldItalic.eot'); src /*2*/: url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/woff/MathJax_Math-BoldItalic.woff') format('woff'), url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/otf/MathJax_Math-BoldItalic.otf') format('opentype')} +@font-face {font-family: MJXc-TeX-math-BIw; src 1: url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/eot/MathJax_Math-BoldItalic.eot'); src 2: url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/woff/MathJax_Math-BoldItalic.woff') format('woff'), url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/otf/MathJax_Math-BoldItalic.otf') format('opentype')} @font-face {font-family: MJXc-TeX-sans-R; src: local('MathJax_SansSerif'), local('MathJax_SansSerif-Regular')} -@font-face {font-family: MJXc-TeX-sans-Rw; src /*1*/: url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/eot/MathJax_SansSerif-Regular.eot'); src /*2*/: url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/woff/MathJax_SansSerif-Regular.woff') format('woff'), url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/otf/MathJax_SansSerif-Regular.otf') format('opentype')} +@font-face {font-family: MJXc-TeX-sans-Rw; src 1: url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/eot/MathJax_SansSerif-Regular.eot'); src 2: url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/woff/MathJax_SansSerif-Regular.woff') format('woff'), url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/otf/MathJax_SansSerif-Regular.otf') format('opentype')} @font-face {font-family: MJXc-TeX-sans-B; src: local('MathJax_SansSerif Bold'), local('MathJax_SansSerif-Bold')} @font-face {font-family: MJXc-TeX-sans-Bx; src: local('MathJax_SansSerif'); font-weight: bold} -@font-face {font-family: MJXc-TeX-sans-Bw; src /*1*/: url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/eot/MathJax_SansSerif-Bold.eot'); src /*2*/: url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/woff/MathJax_SansSerif-Bold.woff') format('woff'), url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/otf/MathJax_SansSerif-Bold.otf') format('opentype')} +@font-face {font-family: MJXc-TeX-sans-Bw; src 1: url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/eot/MathJax_SansSerif-Bold.eot'); src 2: url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/woff/MathJax_SansSerif-Bold.woff') format('woff'), url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/otf/MathJax_SansSerif-Bold.otf') format('opentype')} @font-face {font-family: MJXc-TeX-sans-I; src: local('MathJax_SansSerif Italic'), local('MathJax_SansSerif-Italic')} @font-face {font-family: MJXc-TeX-sans-Ix; src: local('MathJax_SansSerif'); font-style: italic} -@font-face {font-family: MJXc-TeX-sans-Iw; src /*1*/: url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/eot/MathJax_SansSerif-Italic.eot'); src /*2*/: url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/woff/MathJax_SansSerif-Italic.woff') format('woff'), url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/otf/MathJax_SansSerif-Italic.otf') format('opentype')} +@font-face {font-family: MJXc-TeX-sans-Iw; src 1: url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/eot/MathJax_SansSerif-Italic.eot'); src 2: url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/woff/MathJax_SansSerif-Italic.woff') format('woff'), url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/otf/MathJax_SansSerif-Italic.otf') format('opentype')} @font-face {font-family: MJXc-TeX-script-R; src: local('MathJax_Script'), local('MathJax_Script-Regular')} -@font-face {font-family: MJXc-TeX-script-Rw; src /*1*/: url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/eot/MathJax_Script-Regular.eot'); src /*2*/: url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/woff/MathJax_Script-Regular.woff') format('woff'), url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/otf/MathJax_Script-Regular.otf') format('opentype')} +@font-face {font-family: MJXc-TeX-script-Rw; src 1: url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/eot/MathJax_Script-Regular.eot'); src 2: url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/woff/MathJax_Script-Regular.woff') format('woff'), url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/otf/MathJax_Script-Regular.otf') format('opentype')} @font-face {font-family: MJXc-TeX-type-R; src: local('MathJax_Typewriter'), local('MathJax_Typewriter-Regular')} -@font-face {font-family: MJXc-TeX-type-Rw; src /*1*/: url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/eot/MathJax_Typewriter-Regular.eot'); src /*2*/: url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/woff/MathJax_Typewriter-Regular.woff') format('woff'), url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/otf/MathJax_Typewriter-Regular.otf') format('opentype')} +@font-face {font-family: MJXc-TeX-type-Rw; src 1: url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/eot/MathJax_Typewriter-Regular.eot'); src 2: url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/woff/MathJax_Typewriter-Regular.woff') format('woff'), url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/otf/MathJax_Typewriter-Regular.otf') format('opentype')} @font-face {font-family: MJXc-TeX-cal-R; src: local('MathJax_Caligraphic'), local('MathJax_Caligraphic-Regular')} -@font-face {font-family: MJXc-TeX-cal-Rw; src /*1*/: url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/eot/MathJax_Caligraphic-Regular.eot'); src /*2*/: url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/woff/MathJax_Caligraphic-Regular.woff') format('woff'), url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/otf/MathJax_Caligraphic-Regular.otf') format('opentype')} +@font-face {font-family: MJXc-TeX-cal-Rw; src 1: url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/eot/MathJax_Caligraphic-Regular.eot'); src 2: url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/woff/MathJax_Caligraphic-Regular.woff') format('woff'), url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/otf/MathJax_Caligraphic-Regular.otf') format('opentype')} @font-face {font-family: MJXc-TeX-main-B; src: local('MathJax_Main Bold'), local('MathJax_Main-Bold')} @font-face {font-family: MJXc-TeX-main-Bx; src: local('MathJax_Main'); font-weight: bold} -@font-face {font-family: MJXc-TeX-main-Bw; src /*1*/: url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/eot/MathJax_Main-Bold.eot'); src /*2*/: url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/woff/MathJax_Main-Bold.woff') format('woff'), url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/otf/MathJax_Main-Bold.otf') format('opentype')} +@font-face {font-family: MJXc-TeX-main-Bw; src 1: url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/eot/MathJax_Main-Bold.eot'); src 2: url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/woff/MathJax_Main-Bold.woff') format('woff'), url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/otf/MathJax_Main-Bold.otf') format('opentype')} @font-face {font-family: MJXc-TeX-main-I; src: local('MathJax_Main Italic'), local('MathJax_Main-Italic')} @font-face {font-family: MJXc-TeX-main-Ix; src: local('MathJax_Main'); font-style: italic} -@font-face {font-family: MJXc-TeX-main-Iw; src /*1*/: url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/eot/MathJax_Main-Italic.eot'); src /*2*/: url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/woff/MathJax_Main-Italic.woff') format('woff'), url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/otf/MathJax_Main-Italic.otf') format('opentype')} +@font-face {font-family: MJXc-TeX-main-Iw; src 1: url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/eot/MathJax_Main-Italic.eot'); src 2: url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/woff/MathJax_Main-Italic.woff') format('woff'), url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/otf/MathJax_Main-Italic.otf') format('opentype')} @font-face {font-family: MJXc-TeX-main-R; src: local('MathJax_Main'), local('MathJax_Main-Regular')} -@font-face {font-family: MJXc-TeX-main-Rw; src /*1*/: url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/eot/MathJax_Main-Regular.eot'); src /*2*/: url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/woff/MathJax_Main-Regular.woff') format('woff'), url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/otf/MathJax_Main-Regular.otf') format('opentype')} +@font-face {font-family: MJXc-TeX-main-Rw; src 1: url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/eot/MathJax_Main-Regular.eot'); src 2: url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/woff/MathJax_Main-Regular.woff') format('woff'), url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/otf/MathJax_Main-Regular.otf') format('opentype')} @font-face {font-family: MJXc-TeX-math-I; src: local('MathJax_Math Italic'), local('MathJax_Math-Italic')} @font-face {font-family: MJXc-TeX-math-Ix; src: local('MathJax_Math'); font-style: italic} -@font-face {font-family: MJXc-TeX-math-Iw; src /*1*/: url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/eot/MathJax_Math-Italic.eot'); src /*2*/: url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/woff/MathJax_Math-Italic.woff') format('woff'), url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/otf/MathJax_Math-Italic.otf') format('opentype')} +@font-face {font-family: MJXc-TeX-math-Iw; src 1: url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/eot/MathJax_Math-Italic.eot'); src 2: url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/woff/MathJax_Math-Italic.woff') format('woff'), url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/otf/MathJax_Math-Italic.otf') format('opentype')} @font-face {font-family: MJXc-TeX-size1-R; src: local('MathJax_Size1'), local('MathJax_Size1-Regular')} -@font-face {font-family: MJXc-TeX-size1-Rw; src /*1*/: url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/eot/MathJax_Size1-Regular.eot'); src /*2*/: url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/woff/MathJax_Size1-Regular.woff') format('woff'), url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/otf/MathJax_Size1-Regular.otf') format('opentype')} +@font-face {font-family: MJXc-TeX-size1-Rw; src 1: url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/eot/MathJax_Size1-Regular.eot'); src 2: url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/woff/MathJax_Size1-Regular.woff') format('woff'), url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/otf/MathJax_Size1-Regular.otf') format('opentype')} @font-face {font-family: MJXc-TeX-size2-R; src: local('MathJax_Size2'), local('MathJax_Size2-Regular')} -@font-face {font-family: MJXc-TeX-size2-Rw; src /*1*/: url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/eot/MathJax_Size2-Regular.eot'); src /*2*/: url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/woff/MathJax_Size2-Regular.woff') format('woff'), url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/otf/MathJax_Size2-Regular.otf') format('opentype')} +@font-face {font-family: MJXc-TeX-size2-Rw; src 1: url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/eot/MathJax_Size2-Regular.eot'); src 2: url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/woff/MathJax_Size2-Regular.woff') format('woff'), url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/otf/MathJax_Size2-Regular.otf') format('opentype')} @font-face {font-family: MJXc-TeX-size3-R; src: local('MathJax_Size3'), local('MathJax_Size3-Regular')} -@font-face {font-family: MJXc-TeX-size3-Rw; src /*1*/: url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/eot/MathJax_Size3-Regular.eot'); src /*2*/: url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/woff/MathJax_Size3-Regular.woff') format('woff'), url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/otf/MathJax_Size3-Regular.otf') format('opentype')} +@font-face {font-family: MJXc-TeX-size3-Rw; src 1: url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/eot/MathJax_Size3-Regular.eot'); src 2: url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/woff/MathJax_Size3-Regular.woff') format('woff'), url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/otf/MathJax_Size3-Regular.otf') format('opentype')} @font-face {font-family: MJXc-TeX-size4-R; src: local('MathJax_Size4'), local('MathJax_Size4-Regular')} -@font-face {font-family: MJXc-TeX-size4-Rw; src /*1*/: url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/eot/MathJax_Size4-Regular.eot'); src /*2*/: url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/woff/MathJax_Size4-Regular.woff') format('woff'), url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/otf/MathJax_Size4-Regular.otf') format('opentype')} +@font-face {font-family: MJXc-TeX-size4-Rw; src 1: url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/eot/MathJax_Size4-Regular.eot'); src 2: url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/woff/MathJax_Size4-Regular.woff') format('woff'), url('https://cdn.mathjax.org/mathjax/2.6-latest/fonts/HTML-CSS/TeX/otf/MathJax_Size4-Regular.otf') format('opentype')} -/** svg用 */ +* svg用 #tex-preview .MathJax_SVG_Display {text-align: center; margin: 1em 0em; position: relative; display: block!important; text-indent: 0; max-width: none; max-height: none; min-width: 0; min-height: 0; width: 100%} #tex-preview .MathJax_SVG .MJX-monospace {font-family: monospace} #tex-preview .MathJax_SVG .MJX-sans-serif {font-family: sans-serif} @@ -177,4 +188,4 @@ #tex-preview .MathJax_SVG_Processing {visibility: hidden; position: absolute; top: 0; left: 0; width: 0; height: 0; overflow: hidden; display: block!important} #tex-preview .MathJax_SVG_Processed {display: none!important} #tex-preview .MathJax_SVG_ExBox {display: block!important; overflow: hidden; width: 1px; height: 60ex; min-height: 0; max-height: none; padding: 0; border: 0; margin: 0} -#tex-preview .MathJax_SVG .noError {font-size: 90%; text-align: left; color: black; padding: 1px 3px; border: 1px solid} +#tex-preview .MathJax_SVG .noError {font-size: 90%; text-align: left; color: black; padding: 1px 3px; border: 1px solid}*/ diff --git a/webroot/js/plugins/nc3_preview/plugin.js b/webroot/js/plugins/nc3_preview/plugin.js index f8a2502..2ff104a 100644 --- a/webroot/js/plugins/nc3_preview/plugin.js +++ b/webroot/js/plugins/nc3_preview/plugin.js @@ -15,8 +15,7 @@ tinymce.PluginManager.add('nc3Preview', function(editor) { editor.addCommand('mcePreview', function() { var htmlTxt = ''; editor.windowManager.open({ title: 'Preview', @@ -38,6 +37,14 @@ tinymce.PluginManager.add('nc3Preview', function(editor) { editor.documentBaseURI.getURI() + '">'; // new add for Mathjax ////////////////////////////////// + headHtml += ''; headHtml += ''; @@ -80,27 +87,50 @@ tinymce.PluginManager.add('nc3Preview', function(editor) { '' ); - if (!sandbox) { - // IE 6-11 doesn't support data uris on iframes - // so I guess they will have to be less secure since we - // can't sandbox on those - // TODO: Use sandbox if future versions of IE supports - // iframes with data: uris. - var doc = - this.getEl('body').firstChild.contentWindow.document; - doc.open(); - doc.write(previewHtml); - doc.close(); - } else { - this.getEl('body').firstChild.src = - 'data:text/html;charset=utf-8,' + - encodeURIComponent(previewHtml); - } - // add for Tex - var body = this.getEl('body'); - $(body).find('iframe').load('', function() { - TEX_IFR.init($(this)); - }); + //if (!sandbox) { + // // IE 6-11 doesn't support data uris on iframes + // // so I guess they will have to be less secure since we + // // can't sandbox on those + // // TODO: Use sandbox if future versions of IE supports + // // iframes with data: uris. + // var doc = + // this.getEl('body').firstChild.contentWindow.document; + // doc.open(); + // doc.write(previewHtml); + // doc.close(); + //} else { + // this.getEl('body').firstChild.src = + // 'data:text/html;charset=utf-8,' + + // encodeURIComponent(previewHtml); + //} + //// add for Tex + //var body = this.getEl('body'); + //$(body).find('iframe').load('', function() { + // TEX_IFR.init($(this)); + //}); + + // woffファイルでクロスオリジンエラー(Access-Control-Allow-Origin)が生じるため、 + // data: を使わず about:blank にして同一オリジンで書く + var iframe = this.getEl('body').firstChild; + var doc = iframe.contentWindow.document; + doc.open(); + doc.write(previewHtml); + doc.close(); + + // iframe内のMathJaxを、iframe内で「ロード完了後」に typeset + iframe.onload = function() { + var w = iframe.contentWindow; + if (w && w.MathJax) { + // MathJax v3: startup がある場合はそれを待つ + if (w.MathJax.startup && w.MathJax.startup.promise) { + w.MathJax.startup.promise.then(function() { + w.MathJax.typesetPromise(); + }); + } else { + w.MathJax.typesetPromise(); + } + } + }; } }); }); diff --git a/webroot/js/plugins/tex/iframe.js b/webroot/js/plugins/tex/iframe.js index 62b6f01..1cfc0e8 100644 --- a/webroot/js/plugins/tex/iframe.js +++ b/webroot/js/plugins/tex/iframe.js @@ -2,19 +2,19 @@ * tex.iframe.js * iframe内でのtexを使うためのscript */ -var TEX_IFR = new (function TEX_IFR() { - var self = this; - var $IFRAME; - - var __setMathJax = function(id) { - MathJax.Hub.Queue(['Typeset', MathJax.Hub, 'preview_ifr']); - }; - self.init = function($ifr) { - $IFRAME = $ifr; - // init MathJax - MathJax.Hub.Config({ - tex2jax: { inlineMath: [['$$', '$$'], ['\\(', '\\)']] } - }); - __setMathJax(); - }; -})(); +//var TEX_IFR = new (function TEX_IFR() { +// var self = this; +// var $IFRAME; +// +// var __setMathJax = function(id) { +// MathJax.typesetPromise(); +// }; +// self.init = function($ifr) { +// $IFRAME = $ifr; +// // init MathJax +// MathJax = { +// tex: { inlineMath: [['$$', '$$'], ['\\(', '\\)']] } +// }; +// __setMathJax(); +// }; +//})(); diff --git a/webroot/js/plugins/tex/plugin.js b/webroot/js/plugins/tex/plugin.js index be3454b..5e3ae2c 100644 --- a/webroot/js/plugins/tex/plugin.js +++ b/webroot/js/plugins/tex/plugin.js @@ -18,8 +18,8 @@ tinymce.PluginManager.add('tex', function(editor, url) { var preview = function() { // TODO tinymce処理版にできるかどうか var txt = $(vals.iptTextArea).val(); - $('#tex-preview').text('$$' + txt + '$$'); - MathJax.Hub.Queue(['Typeset', MathJax.Hub, 'tex-preview']); + $('#tex-preview').text('$$ ' + txt + ' $$'); + MathJax.typesetPromise(); return false; }; @@ -29,7 +29,7 @@ tinymce.PluginManager.add('tex', function(editor, url) { console.debug('Editor was clicked: ' + e.target); if ($(e.target).hasClass('tex-char')) { var txt = $(e.target).text(); - var rep = txt.replace(/\$\$\s|\s\$\$/g, ''); + var rep = txt.replace(/\$\$|\$\$/g, ''); showDialog(); } }); @@ -77,7 +77,7 @@ tinymce.PluginManager.add('tex', function(editor, url) { var isTarget = selectedNode.tagName == 'SPAN' && editor.dom.hasClass(selectedNode, vals.tex_elm_class) == true; if (isTarget) { - val = selectedNode.innerText.replace(/\$\$\s|\s\$\$/g, ''); + val = selectedNode.innerText.replace(/\$\$|\$\$/g, ''); } editor.windowManager.open({ @@ -95,7 +95,7 @@ tinymce.PluginManager.add('tex', function(editor, url) { var txt = e.data.tex; // 再編集の場合 if (isTarget) { - selectedNode.innerText = '$$' + txt + '$$'; + selectedNode.innerText = '$$ ' + txt + ' $$'; } // 新規挿入の場合 else {