From 7067d7dbb1d26117ce18b7234da8dca361da6c95 Mon Sep 17 00:00:00 2001
From: s-nakajima
Date: Mon, 10 Nov 2025 16:54:01 +0900
Subject: [PATCH 1/4] =?UTF-8?q?change:=20MathJax3=E3=81=AB=E5=AF=BE?=
=?UTF-8?q?=E5=BF=9C?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Test/Case/View/Elements/MathjaxJsTest.php | 26 ++++++++-----------
View/Elements/mathjax_js.ctp | 31 +++++++----------------
bower.json | 2 +-
webroot/js/plugins/tex/iframe.js | 8 +++---
webroot/js/plugins/tex/plugin.js | 10 ++++----
5 files changed, 29 insertions(+), 48 deletions(-)
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/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/js/plugins/tex/iframe.js b/webroot/js/plugins/tex/iframe.js
index 62b6f01..5536225 100644
--- a/webroot/js/plugins/tex/iframe.js
+++ b/webroot/js/plugins/tex/iframe.js
@@ -7,14 +7,14 @@ var TEX_IFR = new (function TEX_IFR() {
var $IFRAME;
var __setMathJax = function(id) {
- MathJax.Hub.Queue(['Typeset', MathJax.Hub, 'preview_ifr']);
+ MathJax.typesetPromise();
};
self.init = function($ifr) {
$IFRAME = $ifr;
// init MathJax
- MathJax.Hub.Config({
- tex2jax: { inlineMath: [['$$', '$$'], ['\\(', '\\)']] }
- });
+ 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 {
From 73308104482f691fb2739eab309acc4f6bb5d30d Mon Sep 17 00:00:00 2001
From: s-nakajima
Date: Tue, 27 Jan 2026 16:00:53 +0900
Subject: [PATCH 2/4] =?UTF-8?q?fix:=20=E3=83=97=E3=83=AC=E3=83=93=E3=83=A5?=
=?UTF-8?q?=E3=83=BC=E3=81=AB=E5=AF=BE=E3=81=97=E3=81=A6=E4=BF=AE=E6=AD=A3?=
=?UTF-8?q?=E6=BC=8F=E3=82=8C=20https://github.com/researchmap/RmNetCommon?=
=?UTF-8?q?s3/issues/3053#issuecomment-3795807293?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
View/Helper/WysiwygHelper.php | 2 +-
webroot/js/plugins/nc3_preview/plugin.js | 77 +++++++++++++++++-------
webroot/js/plugins/tex/iframe.js | 32 +++++-----
3 files changed, 71 insertions(+), 40 deletions(-)
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/webroot/js/plugins/nc3_preview/plugin.js b/webroot/js/plugins/nc3_preview/plugin.js
index f8a2502..957b663 100644
--- a/webroot/js/plugins/nc3_preview/plugin.js
+++ b/webroot/js/plugins/nc3_preview/plugin.js
@@ -15,8 +15,8 @@ tinymce.PluginManager.add('nc3Preview', function(editor) {
editor.addCommand('mcePreview', function() {
var htmlTxt = '';
editor.windowManager.open({
title: 'Preview',
@@ -38,6 +38,14 @@ tinymce.PluginManager.add('nc3Preview', function(editor) {
editor.documentBaseURI.getURI() +
'">';
// new add for Mathjax //////////////////////////////////
+ headHtml += '';
headHtml += '';
@@ -80,27 +88,50 @@ tinymce.PluginManager.add('nc3Preview', function(editor) {
'