mathjax-angular
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -54,12 +54,3 @@ (function (global, factory) { | ||
this.el = el; | ||
if (this.mathJaxExpressions) { | ||
this.mathJaxExpressions = | ||
'string' === typeof this.mathJaxExpressions | ||
? this.mathJaxExpressions | ||
: this.mathJaxExpressions.latex || | ||
this.mathJaxExpressions.mathml; | ||
} | ||
else { | ||
this.element = el.nativeElement; | ||
} | ||
// | ||
this.element = el.nativeElement; | ||
@@ -77,3 +68,2 @@ } | ||
var _this = this; | ||
var _a; | ||
var expressions = changes.mathjax; | ||
@@ -85,12 +75,33 @@ if (!expressions || | ||
// | ||
if ((_a = (expressions.currentValue + '')) === null || _a === void 0 ? void 0 : _a.match(isMathjax)) { | ||
var filteredVal_1 = this.fixMathjaxBugs(expressions.currentValue + ''); | ||
var value = this.getMathjaxContent(expressions.currentValue) + ''; | ||
// | ||
if (value === null || value === void 0 ? void 0 : value.match(isMathjax)) { | ||
var filteredVal_1 = this.fixMathjaxBugs(value); | ||
this.typeset(function () { | ||
_this.element.innerHTML = "<div>" + filteredVal_1 + "</div>"; | ||
_this.element.innerHTML = "<div class='jax-process'>" + filteredVal_1 + "</div>"; | ||
}); | ||
} | ||
else { | ||
this.element.innerHTML = expressions.currentValue; | ||
this.element.innerHTML = value; | ||
} | ||
}; | ||
/** | ||
* find and return mathjax string from input | ||
* @param expressions | ||
* @returns mathjax string | ||
*/ | ||
MathjaxDirective.prototype.getMathjaxContent = function (expressions) { | ||
var _a, _b; | ||
if (!expressions) | ||
return ''; | ||
else if ('string' === typeof expressions) | ||
return expressions; | ||
else | ||
return (_b = (_a = expressions.latex) !== null && _a !== void 0 ? _a : expressions.mathml) !== null && _b !== void 0 ? _b : ''; | ||
}; | ||
/** | ||
* used to fix few issues with mathjax string in angular | ||
* @param {string} jax mathjax string | ||
* @returns {string} fixed string | ||
*/ | ||
MathjaxDirective.prototype.fixMathjaxBugs = function (jax) { | ||
@@ -97,0 +108,0 @@ return (jax |
@@ -11,2 +11,13 @@ import { ElementRef, OnChanges, SimpleChanges } from '@angular/core'; | ||
ngOnChanges(changes: SimpleChanges): void; | ||
/** | ||
* find and return mathjax string from input | ||
* @param expressions | ||
* @returns mathjax string | ||
*/ | ||
private getMathjaxContent; | ||
/** | ||
* used to fix few issues with mathjax string in angular | ||
* @param {string} jax mathjax string | ||
* @returns {string} fixed string | ||
*/ | ||
private fixMathjaxBugs; | ||
@@ -13,0 +24,0 @@ private typeset; |
@@ -8,12 +8,3 @@ import { Directive, Input, } from '@angular/core'; | ||
this.el = el; | ||
if (this.mathJaxExpressions) { | ||
this.mathJaxExpressions = | ||
'string' === typeof this.mathJaxExpressions | ||
? this.mathJaxExpressions | ||
: this.mathJaxExpressions.latex || | ||
this.mathJaxExpressions.mathml; | ||
} | ||
else { | ||
this.element = el.nativeElement; | ||
} | ||
// | ||
this.element = el.nativeElement; | ||
@@ -26,3 +17,2 @@ } | ||
ngOnChanges(changes) { | ||
var _a; | ||
const expressions = changes.mathjax; | ||
@@ -34,12 +24,33 @@ if (!expressions || | ||
// | ||
if ((_a = (expressions.currentValue + '')) === null || _a === void 0 ? void 0 : _a.match(isMathjax)) { | ||
const filteredVal = this.fixMathjaxBugs(expressions.currentValue + ''); | ||
const value = this.getMathjaxContent(expressions.currentValue) + ''; | ||
// | ||
if (value === null || value === void 0 ? void 0 : value.match(isMathjax)) { | ||
const filteredVal = this.fixMathjaxBugs(value); | ||
this.typeset(() => { | ||
this.element.innerHTML = `<div>${filteredVal}</div>`; | ||
this.element.innerHTML = `<div class='jax-process'>${filteredVal}</div>`; | ||
}); | ||
} | ||
else { | ||
this.element.innerHTML = expressions.currentValue; | ||
this.element.innerHTML = value; | ||
} | ||
} | ||
/** | ||
* find and return mathjax string from input | ||
* @param expressions | ||
* @returns mathjax string | ||
*/ | ||
getMathjaxContent(expressions) { | ||
var _a, _b; | ||
if (!expressions) | ||
return ''; | ||
else if ('string' === typeof expressions) | ||
return expressions; | ||
else | ||
return (_b = (_a = expressions.latex) !== null && _a !== void 0 ? _a : expressions.mathml) !== null && _b !== void 0 ? _b : ''; | ||
} | ||
/** | ||
* used to fix few issues with mathjax string in angular | ||
* @param {string} jax mathjax string | ||
* @returns {string} fixed string | ||
*/ | ||
fixMathjaxBugs(jax) { | ||
@@ -83,2 +94,2 @@ return (jax | ||
}] } }); | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWF0aGpheC5kaXJlY3RpdmUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9wcm9qZWN0cy9tYXRoamF4LWxpYi9zcmMvZGlyZWN0aXZlL21hdGhqYXguZGlyZWN0aXZlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFDTCxTQUFTLEVBRVQsS0FBSyxHQUdOLE1BQU0sZUFBZSxDQUFDO0FBQ3ZCLE9BQU8sRUFBa0IsU0FBUyxFQUFFLE1BQU0sVUFBVSxDQUFDOztBQUtyRCxNQUFNLE9BQU8sZ0JBQWdCO0lBVTNCLEVBQUU7SUFDRixZQUFvQixFQUFjO1FBQWQsT0FBRSxHQUFGLEVBQUUsQ0FBWTtRQUNoQyxJQUFJLElBQUksQ0FBQyxrQkFBa0IsRUFBRTtZQUMzQixJQUFJLENBQUMsa0JBQWtCO2dCQUNyQixRQUFRLEtBQUssT0FBTyxJQUFJLENBQUMsa0JBQWtCO29CQUN6QyxDQUFDLENBQUUsSUFBSSxDQUFDLGtCQUE2QjtvQkFDckMsQ0FBQyxDQUFrQixJQUFJLENBQUMsa0JBQW1CLENBQUMsS0FBSzt3QkFDOUIsSUFBSSxDQUFDLGtCQUFtQixDQUFDLE1BQU0sQ0FBQztTQUN4RDthQUFNO1lBQ0wsSUFBSSxDQUFDLE9BQU8sR0FBRyxFQUFFLENBQUMsYUFBYSxDQUFDO1NBQ2pDO1FBQ0QsSUFBSSxDQUFDLE9BQU8sR0FBRyxFQUFFL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uICAgICAgTWF0aEpheC5zdGFydHVwLnByb21pc2UgPSBNYXRoSmF4LnN0YXJ0dXAucHJvbWlzZVxyXG4gICAgICAgIC50aGVuKCgpID0+IHtcclxuICAgICAgICAgIGNvZGUoKTtcclxuICAgICAgICAgIHJldHVybiBNYXRoSmF4LnR5cGVzZXRQcm9taXNlID8gTWF0aEpheC50eXBlc2V0UHJvbWlzZSgpIDogbnVsbDtcclxuICAgICAgICB9KVxyXG4gICAgICAgIC5jYXRjaCgoZXJyOiBFcnJvcikgPT5cclxuICAgICAgICAgIGNvbnNvbGUuZXJyb3IoJ01hdGhKYXggVHlwZXNldCBmYWlsZWQ6ICcgKyBlcnIubWVzc2FnZSlcclxuICAgICAgICApO1xyXG4gICAgICByZXR1cm4gTWF0aEpheC5zdGFydHVwLnByb21pc2U7XHJcbiAgICB9IGVsc2Uge1xyXG4gICAgICBjb2RlKCk7XHJcbiAgICB9XHJcbiAgfVxyXG59XHJcbiJdfQ== |
@@ -26,12 +26,3 @@ import * as i0 from '@angular/core'; | ||
this.el = el; | ||
if (this.mathJaxExpressions) { | ||
this.mathJaxExpressions = | ||
'string' === typeof this.mathJaxExpressions | ||
? this.mathJaxExpressions | ||
: this.mathJaxExpressions.latex || | ||
this.mathJaxExpressions.mathml; | ||
} | ||
else { | ||
this.element = el.nativeElement; | ||
} | ||
// | ||
this.element = el.nativeElement; | ||
@@ -44,3 +35,2 @@ } | ||
ngOnChanges(changes) { | ||
var _a; | ||
const expressions = changes.mathjax; | ||
@@ -52,12 +42,33 @@ if (!expressions || | ||
// | ||
if ((_a = (expressions.currentValue + '')) === null || _a === void 0 ? void 0 : _a.match(isMathjax)) { | ||
const filteredVal = this.fixMathjaxBugs(expressions.currentValue + ''); | ||
const value = this.getMathjaxContent(expressions.currentValue) + ''; | ||
// | ||
if (value === null || value === void 0 ? void 0 : value.match(isMathjax)) { | ||
const filteredVal = this.fixMathjaxBugs(value); | ||
this.typeset(() => { | ||
this.element.innerHTML = `<div>${filteredVal}</div>`; | ||
this.element.innerHTML = `<div class='jax-process'>${filteredVal}</div>`; | ||
}); | ||
} | ||
else { | ||
this.element.innerHTML = expressions.currentValue; | ||
this.element.innerHTML = value; | ||
} | ||
} | ||
/** | ||
* find and return mathjax string from input | ||
* @param expressions | ||
* @returns mathjax string | ||
*/ | ||
getMathjaxContent(expressions) { | ||
var _a, _b; | ||
if (!expressions) | ||
return ''; | ||
else if ('string' === typeof expressions) | ||
return expressions; | ||
else | ||
return (_b = (_a = expressions.latex) !== null && _a !== void 0 ? _a : expressions.mathml) !== null && _b !== void 0 ? _b : ''; | ||
} | ||
/** | ||
* used to fix few issues with mathjax string in angular | ||
* @param {string} jax mathjax string | ||
* @returns {string} fixed string | ||
*/ | ||
fixMathjaxBugs(jax) { | ||
@@ -64,0 +75,0 @@ return (jax |
{ | ||
"name": "mathjax-angular", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"peerDependencies": { | ||
@@ -5,0 +5,0 @@ "@angular/common": "^12.1.1", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
60422
609