This is an automated email from the ASF dual-hosted git repository.
solomax pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openmeetings.git
The following commit(s) were added to refs/heads/master by this push:
new a88e41c19 [OPENMEETINGS-2824] MathJax
a88e41c19 is described below
commit a88e41c197995566a957b365bdcb942790e88a05
Author: Maxim Solodovnik <[email protected]>
AuthorDate: Thu Sep 10 23:59:30 2026 +0700
[OPENMEETINGS-2824] MathJax
---
openmeetings-web/src/main/front/package.json | 3 +-
.../src/main/front/src/chat/cssemoticons.js | 4 +-
openmeetings-web/src/main/front/src/room/index.js | 4 +-
.../src/main/front/src/wb/wb-player.js | 4 +-
.../src/main/front/src/wb/wb-tool-stat-math.js | 111 +++++++++++----------
5 files changed, 67 insertions(+), 59 deletions(-)
diff --git a/openmeetings-web/src/main/front/package.json
b/openmeetings-web/src/main/front/package.json
index c647ff67b..39245fe18 100644
--- a/openmeetings-web/src/main/front/package.json
+++ b/openmeetings-web/src/main/front/package.json
@@ -26,7 +26,8 @@
"dependencies": {
"fabric": "7.4.0",
"freeice": "2.2.2",
- "mathjax-full": "^3.2.2",
+ "@mathjax/mathjax-newcm-font": "^4.1.0",
+ "@mathjax/src": "^4.1.0",
"nosleep.js": "^0.12.0",
"ua-parser-js": "^2.0.10",
"webrtc-adapter": "^9.0.6"
diff --git a/openmeetings-web/src/main/front/src/chat/cssemoticons.js
b/openmeetings-web/src/main/front/src/chat/cssemoticons.js
index 4445dd688..9234240a9 100644
--- a/openmeetings-web/src/main/front/src/chat/cssemoticons.js
+++ b/openmeetings-web/src/main/front/src/chat/cssemoticons.js
@@ -83,7 +83,7 @@ module.exports = {
, matchers: matchers
, defaults: defaults
, emoticonize: function(str, options) {
- const opts = $.extend({}, defaults, options);
+ const opts = Object.assign({}, defaults, options);
let cssClass = 'css-emoticon';
if (opts.animate) {
@@ -97,7 +97,7 @@ module.exports = {
return str;
}
, animate: function(options) {
- const opts = $.extend({}, defaults, options);
+ const opts = Object.assign({}, defaults, options);
// animate emoticons
if (opts.animate) {
setTimeout(function () {
diff --git a/openmeetings-web/src/main/front/src/room/index.js
b/openmeetings-web/src/main/front/src/room/index.js
index a3b511ff9..7bac06097 100644
--- a/openmeetings-web/src/main/front/src/room/index.js
+++ b/openmeetings-web/src/main/front/src/room/index.js
@@ -1,7 +1,7 @@
/* Licensed under the Apache License, Version 2.0 (the "License")
http://www.apache.org/licenses/LICENSE-2.0 */
// Let's re-style jquery-ui dialogs and buttons
-$.extend($.ui.dialog.prototype.options.classes, {
+Object.assign($.ui.dialog.prototype.options.classes, {
'ui-dialog': 'modal-content'
, 'ui-dialog-titlebar': 'modal-header'
, 'ui-dialog-title': 'modal-title'
@@ -9,7 +9,7 @@ $.extend($.ui.dialog.prototype.options.classes, {
, 'ui-dialog-content': 'modal-body'
, 'ui-dialog-buttonpane': 'modal-footer'
});
-$.extend($.ui.button.prototype.options.classes, {
+Object.assign($.ui.button.prototype.options.classes, {
'ui-button': 'btn btn-outline-secondary'
});
diff --git a/openmeetings-web/src/main/front/src/wb/wb-player.js
b/openmeetings-web/src/main/front/src/wb/wb-player.js
index f585e8b1f..ccc1f0e1d 100644
--- a/openmeetings-web/src/main/front/src/wb/wb-player.js
+++ b/openmeetings-web/src/main/front/src/wb/wb-player.js
@@ -140,7 +140,7 @@ export class Player {
};
let request;
- const opts = $.extend({
+ const opts = Object.assign({
subTargetCheck: true
, objectCaching: false
, omType: 'Video'
@@ -256,7 +256,7 @@ export class Player {
}
static modify(g, _o) {
- const opts = $.extend({
+ const opts = Object.assign({
angle: 0
, left: 10
, scaleX: 1
diff --git a/openmeetings-web/src/main/front/src/wb/wb-tool-stat-math.js
b/openmeetings-web/src/main/front/src/wb/wb-tool-stat-math.js
index c3137b9b6..c13934c12 100644
--- a/openmeetings-web/src/main/front/src/wb/wb-tool-stat-math.js
+++ b/openmeetings-web/src/main/front/src/wb/wb-tool-stat-math.js
@@ -1,69 +1,76 @@
/* Licensed under the Apache License, Version 2.0 (the "License")
http://www.apache.org/licenses/LICENSE-2.0 */
-// Based on this example:
https://github.com/mathjax/MathJax-demos-node/blob/master/preload/tex2svg
-const packages = 'base, autoload, require, ams, newcommand,
noundefined'.split(/\s*,\s*/);
+// Based on this example
https://github.com/mathjax/MathJax-demos-node/blob/4.1.0/mjs/direct/tex2svg
+import {TeX} from '@mathjax/src/js/input/tex.js';
+import {SVG} from '@mathjax/src/js/output/svg.js';
+import {RegisterHTMLHandler} from '@mathjax/src/js/handlers/html.js';
+import {liteAdaptor} from '@mathjax/src/js/adaptors/liteAdaptor.js';
+import {mathjax} from '@mathjax/src/js/mathjax.js';
+import {MathJaxNewcmFont} from '@mathjax/mathjax-newcm-font/js/chtml.js';
+import {AmsConfiguration} from
'@mathjax/src/mjs/input/tex/ams/AmsConfiguration.js';
+import {NewcommandConfiguration} from
'@mathjax/src/mjs/input/tex/newcommand/NewcommandConfiguration.js';
+import {TextMacrosConfiguration} from
'@mathjax/src/mjs/input/tex/textmacros/TextMacrosConfiguration.js';
+import {NoUndefinedConfiguration} from
'@mathjax/src/mjs/input/tex/noundefined/NoUndefinedConfiguration.js';
+const FONT_SIZE = 16;
-window.MathJax = {
- options: {}
- , tex: {
- packages: packages
- , noundefined: {
- color: 'red'
- , background: ''
- , size: ''
- }
- , formatError(_, error) {
- throw error;
- }
- }
- , svg: {
- fontCache: 'local'
- }
- , startup: {
- typeset: false
- }
-};
-
-require('mathjax-full/components/src/startup/lib/startup.js');
-require('mathjax-full/components/src/core/core.js');
-require('mathjax-full/js/adaptors/browserAdaptor');
-require('mathjax-full/components/src/input/tex-base/tex-base.js');
-require('mathjax-full/components/src/input/tex/extensions/all-packages/all-packages.js');
-require('mathjax-full/components/src/input/tex/extensions/noundefined/noundefined');
-require('mathjax-full/components/src/output/svg/svg.js');
-require('mathjax-full/components/src/output/svg/fonts/tex/tex.js');
-require('mathjax-full/components/src/startup/startup.js');
+const tex = new TeX({
+ packages: [
+ "base",
+ "ams",
+ "newcommand",
+ "textmacros",
+ "noundefined"
+ ],
+ formatError: (jax, err) => {
+ return jax.formatError(err);
+ },
+});
+const svg = new SVG({
+ exFactor: 0.5,
+ displayAlign: "center",
+ displayIndent: "0em",
+ displayOverflow: "overflow",
+ linebreaks: {
+ inline: false,
+ },
+ mathmlSpacing: false,
+ fontCache: "local",
+ useXlink: false,
+});
-MathJax.loader.preLoad(
- 'core'
- , 'adaptors/browserAdaptor'
- , 'input/tex-base'
- , '[tex]/all-packages'
- , '[tex]/noundefined'
- , 'output/svg'
- , 'output/svg/fonts/tex'
-);
-
-MathJax.config.startup.ready();
+RegisterHTMLHandler(liteAdaptor({fontSize: FONT_SIZE}));
+const mathDoc = mathjax.document('', {
+ InputJax: tex,
+ OutputJax: svg,
+});
import * as fabric from 'fabric';
export class StaticTMath {
static create(o, canvas, callback, errCallback) {
- MathJax.tex2svgPromise(o.formula, {
- display: false
- , em: 16 // em-size in pixels
- , ex: 8 // ex-size in pixels
- , containerWidth: 80 * 16
- }).then(node => node.firstChild.outerHTML) // this extrastep is
required, fabric seems to break on MathJax nodes
+ mathDoc.convertPromise(o.formula, {
+ display: false,
+ em: FONT_SIZE, // em-size in pixels
+ ex: 8, // ex-size in pixels
+ containerWidth: 80 * FONT_SIZE,
+ })
+ .then(node => {
+ const adaptor = mathDoc.adaptor;
+ const svg = adaptor.getElement('svg', node);
+ delete svg.styles;
+ delete svg.attributes.style;
+ return adaptor.serializeXML(svg);
+ })
.then(fabric.loadSVGFromString)
.then(({ objects, options }) => {
- const opts = $.extend({}, o, options)
- , obj = objects.length === 1
+ if (objects.length === 0) {
+ return; // nothing to draw
+ }
+ const opts = Object.assign({}, o, options);
+ const obj = objects.length === 1
? new fabric.Group(objects, opts)
: fabric.util.groupSVGElements(objects,
opts);
obj.selectable = canvas.selection;
- obj.type = 'group';
if (typeof(callback) === 'function') {
callback(obj);
}