add initial marp implementation with sample content and build configuration
This commit is contained in:
31
node_modules/mathjax-full/js/ui/lazy/LazyHandler.d.ts
generated
vendored
Normal file
31
node_modules/mathjax-full/js/ui/lazy/LazyHandler.d.ts
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
import { MathDocumentConstructor } from '../../core/MathDocument.js';
|
||||
import { MathItem } from '../../core/MathItem.js';
|
||||
import { HTMLMathItem } from '../../handlers/html/HTMLMathItem.js';
|
||||
import { HTMLDocument } from '../../handlers/html/HTMLDocument.js';
|
||||
import { HTMLHandler } from '../../handlers/html/HTMLHandler.js';
|
||||
export declare type Constructor<T> = new (...args: any[]) => T;
|
||||
export declare type LazySet = Set<string>;
|
||||
export declare class LazyList<N, T, D> {
|
||||
protected id: number;
|
||||
protected items: Map<string, LazyMathItem<N, T, D>>;
|
||||
add(math: LazyMathItem<N, T, D>): string;
|
||||
get(id: string): LazyMathItem<N, T, D>;
|
||||
delete(id: string): boolean;
|
||||
}
|
||||
export declare const LAZYID = "data-mjx-lazy";
|
||||
export interface LazyMathItem<N, T, D> extends MathItem<N, T, D> {
|
||||
lazyCompile: boolean;
|
||||
lazyTypeset: boolean;
|
||||
lazyMarker: N;
|
||||
lazyTex: boolean;
|
||||
}
|
||||
export declare function LazyMathItemMixin<N, T, D, B extends Constructor<HTMLMathItem<N, T, D>>>(BaseMathItem: B): Constructor<LazyMathItem<N, T, D>> & B;
|
||||
export interface LazyMathDocument<N, T, D> extends HTMLDocument<N, T, D> {
|
||||
lazyObserver: IntersectionObserver;
|
||||
lazyList: LazyList<N, T, D>;
|
||||
lazyAlwaysContainers: N[];
|
||||
lazyTypesetAll(): Promise<void>;
|
||||
lazyAlways(): void;
|
||||
}
|
||||
export declare function LazyMathDocumentMixin<N, T, D, B extends MathDocumentConstructor<HTMLDocument<N, T, D>>>(BaseDocument: B): MathDocumentConstructor<HTMLDocument<N, T, D>> & B;
|
||||
export declare function LazyHandler<N, T, D>(handler: HTMLHandler<N, T, D>): HTMLHandler<N, T, D>;
|
||||
482
node_modules/mathjax-full/js/ui/lazy/LazyHandler.js
generated
vendored
Normal file
482
node_modules/mathjax-full/js/ui/lazy/LazyHandler.js
generated
vendored
Normal file
@@ -0,0 +1,482 @@
|
||||
"use strict";
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
return function (d, b) {
|
||||
if (typeof b !== "function" && b !== null)
|
||||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
var __assign = (this && this.__assign) || function () {
|
||||
__assign = Object.assign || function(t) {
|
||||
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
||||
s = arguments[i];
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
||||
t[p] = s[p];
|
||||
}
|
||||
return t;
|
||||
};
|
||||
return __assign.apply(this, arguments);
|
||||
};
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
||||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
while (_) try {
|
||||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
||||
if (y = 0, t) op = [op[0] & 2, t.value];
|
||||
switch (op[0]) {
|
||||
case 0: case 1: t = op; break;
|
||||
case 4: _.label++; return { value: op[1], done: false };
|
||||
case 5: _.label++; y = op[1]; op = [0]; continue;
|
||||
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
||||
default:
|
||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
||||
if (t[2]) _.ops.pop();
|
||||
_.trys.pop(); continue;
|
||||
}
|
||||
op = body.call(thisArg, _);
|
||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||
}
|
||||
};
|
||||
var __read = (this && this.__read) || function (o, n) {
|
||||
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
||||
if (!m) return o;
|
||||
var i = m.call(o), r, ar = [], e;
|
||||
try {
|
||||
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
||||
}
|
||||
catch (error) { e = { error: error }; }
|
||||
finally {
|
||||
try {
|
||||
if (r && !r.done && (m = i["return"])) m.call(i);
|
||||
}
|
||||
finally { if (e) throw e.error; }
|
||||
}
|
||||
return ar;
|
||||
};
|
||||
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
||||
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
||||
if (ar || !(i in from)) {
|
||||
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
||||
ar[i] = from[i];
|
||||
}
|
||||
}
|
||||
return to.concat(ar || Array.prototype.slice.call(from));
|
||||
};
|
||||
var __values = (this && this.__values) || function(o) {
|
||||
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
||||
if (m) return m.call(o);
|
||||
if (o && typeof o.length === "number") return {
|
||||
next: function () {
|
||||
if (o && i >= o.length) o = void 0;
|
||||
return { value: o && o[i++], done: !o };
|
||||
}
|
||||
};
|
||||
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.LazyHandler = exports.LazyMathDocumentMixin = exports.LazyMathItemMixin = exports.LAZYID = exports.LazyList = void 0;
|
||||
var MathItem_js_1 = require("../../core/MathItem.js");
|
||||
var Retries_js_1 = require("../../util/Retries.js");
|
||||
var LazyList = (function () {
|
||||
function LazyList() {
|
||||
this.id = 0;
|
||||
this.items = new Map();
|
||||
}
|
||||
LazyList.prototype.add = function (math) {
|
||||
var id = String(this.id++);
|
||||
this.items.set(id, math);
|
||||
return id;
|
||||
};
|
||||
LazyList.prototype.get = function (id) {
|
||||
return this.items.get(id);
|
||||
};
|
||||
LazyList.prototype.delete = function (id) {
|
||||
return this.items.delete(id);
|
||||
};
|
||||
return LazyList;
|
||||
}());
|
||||
exports.LazyList = LazyList;
|
||||
(0, MathItem_js_1.newState)('LAZYALWAYS', MathItem_js_1.STATE.FINDMATH + 3);
|
||||
exports.LAZYID = 'data-mjx-lazy';
|
||||
function LazyMathItemMixin(BaseMathItem) {
|
||||
return (function (_super) {
|
||||
__extends(class_1, _super);
|
||||
function class_1() {
|
||||
var args = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
args[_i] = arguments[_i];
|
||||
}
|
||||
var _this = _super.apply(this, __spreadArray([], __read(args), false)) || this;
|
||||
_this.lazyCompile = true;
|
||||
_this.lazyTypeset = true;
|
||||
_this.lazyTex = false;
|
||||
if (!_this.end.node) {
|
||||
_this.lazyCompile = _this.lazyTypeset = false;
|
||||
}
|
||||
return _this;
|
||||
}
|
||||
class_1.prototype.compile = function (document) {
|
||||
if (!this.lazyCompile) {
|
||||
_super.prototype.compile.call(this, document);
|
||||
return;
|
||||
}
|
||||
if (this.state() < MathItem_js_1.STATE.COMPILED) {
|
||||
this.lazyTex = (this.inputJax.name === 'TeX');
|
||||
this.root = document.mmlFactory.create('math');
|
||||
this.state(MathItem_js_1.STATE.COMPILED);
|
||||
}
|
||||
};
|
||||
class_1.prototype.state = function (state, restore) {
|
||||
if (state === void 0) { state = null; }
|
||||
if (restore === void 0) { restore = false; }
|
||||
if (restore !== null)
|
||||
_super.prototype.state.call(this, state, restore);
|
||||
return _super.prototype.state.call(this);
|
||||
};
|
||||
class_1.prototype.typeset = function (document) {
|
||||
var _a;
|
||||
if (!this.lazyTypeset) {
|
||||
_super.prototype.typeset.call(this, document);
|
||||
return;
|
||||
}
|
||||
if (this.state() < MathItem_js_1.STATE.TYPESET) {
|
||||
var adaptor = document.adaptor;
|
||||
if (!this.lazyMarker) {
|
||||
var id = document.lazyList.add(this);
|
||||
this.lazyMarker = adaptor.node('mjx-lazy', (_a = {}, _a[exports.LAZYID] = id, _a));
|
||||
this.typesetRoot = adaptor.node('mjx-container', {}, [this.lazyMarker]);
|
||||
}
|
||||
this.state(MathItem_js_1.STATE.TYPESET);
|
||||
}
|
||||
};
|
||||
class_1.prototype.updateDocument = function (document) {
|
||||
_super.prototype.updateDocument.call(this, document);
|
||||
if (this.lazyTypeset) {
|
||||
document.lazyObserver.observe(this.lazyMarker);
|
||||
}
|
||||
};
|
||||
return class_1;
|
||||
}(BaseMathItem));
|
||||
}
|
||||
exports.LazyMathItemMixin = LazyMathItemMixin;
|
||||
function LazyMathDocumentMixin(BaseDocument) {
|
||||
var _a;
|
||||
return _a = (function (_super) {
|
||||
__extends(BaseClass, _super);
|
||||
function BaseClass() {
|
||||
var args = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
args[_i] = arguments[_i];
|
||||
}
|
||||
var _this = _super.apply(this, __spreadArray([], __read(args), false)) || this;
|
||||
_this.lazyAlwaysContainers = null;
|
||||
_this.lazyAlwaysIndex = 0;
|
||||
_this.lazyPromise = Promise.resolve();
|
||||
_this.lazyIdle = false;
|
||||
_this.lazySet = new Set();
|
||||
_this.options.MathItem =
|
||||
LazyMathItemMixin(_this.options.MathItem);
|
||||
var ProcessBits = _this.constructor.ProcessBits;
|
||||
!ProcessBits.has('lazyAlways') && ProcessBits.allocate('lazyAlways');
|
||||
_this.lazyObserver = new IntersectionObserver(_this.lazyObserve.bind(_this), { rootMargin: _this.options.lazyMargin });
|
||||
_this.lazyList = new LazyList();
|
||||
var callback = _this.lazyHandleSet.bind(_this);
|
||||
_this.lazyProcessSet = (window && window.requestIdleCallback ?
|
||||
function () { return window.requestIdleCallback(callback); } :
|
||||
function () { return setTimeout(callback, 10); });
|
||||
if (window) {
|
||||
var done_1 = false;
|
||||
var handler = function () {
|
||||
!done_1 && _this.lazyTypesetAll();
|
||||
done_1 = true;
|
||||
};
|
||||
window.matchMedia('print').addListener(handler);
|
||||
window.addEventListener('beforeprint', handler);
|
||||
}
|
||||
return _this;
|
||||
}
|
||||
BaseClass.prototype.lazyAlways = function () {
|
||||
var e_1, _a;
|
||||
if (!this.lazyAlwaysContainers || this.processed.isSet('lazyAlways'))
|
||||
return;
|
||||
try {
|
||||
for (var _b = __values(this.math), _c = _b.next(); !_c.done; _c = _b.next()) {
|
||||
var item = _c.value;
|
||||
var math = item;
|
||||
if (math.lazyTypeset && this.lazyIsAlways(math)) {
|
||||
math.lazyCompile = math.lazyTypeset = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
||||
finally {
|
||||
try {
|
||||
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
||||
}
|
||||
finally { if (e_1) throw e_1.error; }
|
||||
}
|
||||
this.processed.set('lazyAlways');
|
||||
};
|
||||
BaseClass.prototype.lazyIsAlways = function (math) {
|
||||
if (math.state() < MathItem_js_1.STATE.LAZYALWAYS) {
|
||||
math.state(MathItem_js_1.STATE.LAZYALWAYS);
|
||||
var node = math.start.node;
|
||||
var adaptor = this.adaptor;
|
||||
var start = this.lazyAlwaysIndex;
|
||||
var end = this.lazyAlwaysContainers.length;
|
||||
do {
|
||||
var container = this.lazyAlwaysContainers[this.lazyAlwaysIndex];
|
||||
if (adaptor.contains(container, node))
|
||||
return true;
|
||||
if (++this.lazyAlwaysIndex >= end) {
|
||||
this.lazyAlwaysIndex = 0;
|
||||
}
|
||||
} while (this.lazyAlwaysIndex !== start);
|
||||
}
|
||||
return false;
|
||||
};
|
||||
BaseClass.prototype.state = function (state, restore) {
|
||||
if (restore === void 0) { restore = false; }
|
||||
_super.prototype.state.call(this, state, restore);
|
||||
if (state < MathItem_js_1.STATE.LAZYALWAYS) {
|
||||
this.processed.clear('lazyAlways');
|
||||
}
|
||||
return this;
|
||||
};
|
||||
BaseClass.prototype.lazyTypesetAll = function () {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var state, _a, _b, item, math, fontCache;
|
||||
var e_2, _c;
|
||||
var _this = this;
|
||||
return __generator(this, function (_d) {
|
||||
state = MathItem_js_1.STATE.LAST;
|
||||
try {
|
||||
for (_a = __values(this.math), _b = _a.next(); !_b.done; _b = _a.next()) {
|
||||
item = _b.value;
|
||||
math = item;
|
||||
if (!math.lazyCompile && !math.lazyTypeset)
|
||||
continue;
|
||||
if (math.lazyCompile) {
|
||||
math.state(MathItem_js_1.STATE.COMPILED - 1);
|
||||
state = MathItem_js_1.STATE.COMPILED;
|
||||
}
|
||||
else {
|
||||
math.state(MathItem_js_1.STATE.TYPESET - 1);
|
||||
if (MathItem_js_1.STATE.TYPESET < state)
|
||||
state = MathItem_js_1.STATE.TYPESET;
|
||||
}
|
||||
math.lazyCompile = math.lazyTypeset = false;
|
||||
math.lazyMarker && this.lazyObserver.unobserve(math.lazyMarker);
|
||||
}
|
||||
}
|
||||
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
||||
finally {
|
||||
try {
|
||||
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
||||
}
|
||||
finally { if (e_2) throw e_2.error; }
|
||||
}
|
||||
if (state === MathItem_js_1.STATE.LAST)
|
||||
return [2, Promise.resolve()];
|
||||
this.state(state - 1, null);
|
||||
fontCache = this.outputJax.options.fontCache;
|
||||
if (fontCache)
|
||||
this.outputJax.options.fontCache = 'none';
|
||||
this.reset();
|
||||
return [2, (0, Retries_js_1.handleRetriesFor)(function () { return _this.render(); }).then(function () {
|
||||
if (fontCache)
|
||||
_this.outputJax.options.fontCache = fontCache;
|
||||
})];
|
||||
});
|
||||
});
|
||||
};
|
||||
BaseClass.prototype.lazyObserve = function (entries) {
|
||||
var e_3, _a;
|
||||
try {
|
||||
for (var entries_1 = __values(entries), entries_1_1 = entries_1.next(); !entries_1_1.done; entries_1_1 = entries_1.next()) {
|
||||
var entry = entries_1_1.value;
|
||||
var id = this.adaptor.getAttribute(entry.target, exports.LAZYID);
|
||||
var math = this.lazyList.get(id);
|
||||
if (!math)
|
||||
continue;
|
||||
if (!entry.isIntersecting) {
|
||||
this.lazySet.delete(id);
|
||||
continue;
|
||||
}
|
||||
this.lazySet.add(id);
|
||||
if (!this.lazyIdle) {
|
||||
this.lazyIdle = true;
|
||||
this.lazyProcessSet();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
||||
finally {
|
||||
try {
|
||||
if (entries_1_1 && !entries_1_1.done && (_a = entries_1.return)) _a.call(entries_1);
|
||||
}
|
||||
finally { if (e_3) throw e_3.error; }
|
||||
}
|
||||
};
|
||||
BaseClass.prototype.lazyHandleSet = function () {
|
||||
var _this = this;
|
||||
var set = this.lazySet;
|
||||
this.lazySet = new Set();
|
||||
this.lazyPromise = this.lazyPromise.then(function () {
|
||||
var state = _this.compileEarlierItems(set) ? MathItem_js_1.STATE.COMPILED : MathItem_js_1.STATE.TYPESET;
|
||||
state = _this.resetStates(set, state);
|
||||
_this.state(state - 1, null);
|
||||
return (0, Retries_js_1.handleRetriesFor)(function () {
|
||||
_this.render();
|
||||
_this.lazyIdle = false;
|
||||
});
|
||||
});
|
||||
};
|
||||
BaseClass.prototype.resetStates = function (set, state) {
|
||||
var e_4, _a;
|
||||
try {
|
||||
for (var _b = __values(set.values()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
||||
var id = _c.value;
|
||||
var math = this.lazyList.get(id);
|
||||
if (math.lazyCompile) {
|
||||
math.state(MathItem_js_1.STATE.COMPILED - 1);
|
||||
state = MathItem_js_1.STATE.COMPILED;
|
||||
}
|
||||
else {
|
||||
math.state(MathItem_js_1.STATE.TYPESET - 1);
|
||||
}
|
||||
math.lazyCompile = math.lazyTypeset = false;
|
||||
math.lazyMarker && this.lazyObserver.unobserve(math.lazyMarker);
|
||||
}
|
||||
}
|
||||
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
||||
finally {
|
||||
try {
|
||||
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
||||
}
|
||||
finally { if (e_4) throw e_4.error; }
|
||||
}
|
||||
return state;
|
||||
};
|
||||
BaseClass.prototype.compileEarlierItems = function (set) {
|
||||
var e_5, _a;
|
||||
var math = this.earliestTex(set);
|
||||
if (!math)
|
||||
return false;
|
||||
var compile = false;
|
||||
try {
|
||||
for (var _b = __values(this.math), _c = _b.next(); !_c.done; _c = _b.next()) {
|
||||
var item = _c.value;
|
||||
var earlier = item;
|
||||
if (earlier === math || !(earlier === null || earlier === void 0 ? void 0 : earlier.lazyCompile) || !earlier.lazyTex) {
|
||||
break;
|
||||
}
|
||||
earlier.lazyCompile = false;
|
||||
earlier.lazyMarker && this.lazyObserver.unobserve(earlier.lazyMarker);
|
||||
earlier.state(MathItem_js_1.STATE.COMPILED - 1);
|
||||
compile = true;
|
||||
}
|
||||
}
|
||||
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
||||
finally {
|
||||
try {
|
||||
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
||||
}
|
||||
finally { if (e_5) throw e_5.error; }
|
||||
}
|
||||
return compile;
|
||||
};
|
||||
BaseClass.prototype.earliestTex = function (set) {
|
||||
var e_6, _a;
|
||||
var min = null;
|
||||
var minMath = null;
|
||||
try {
|
||||
for (var _b = __values(set.values()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
||||
var id = _c.value;
|
||||
var math = this.lazyList.get(id);
|
||||
if (!math.lazyTex)
|
||||
continue;
|
||||
if (min === null || parseInt(id) < min) {
|
||||
min = parseInt(id);
|
||||
minMath = math;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
||||
finally {
|
||||
try {
|
||||
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
||||
}
|
||||
finally { if (e_6) throw e_6.error; }
|
||||
}
|
||||
return minMath;
|
||||
};
|
||||
BaseClass.prototype.clearMathItemsWithin = function (containers) {
|
||||
var e_7, _a;
|
||||
var items = _super.prototype.clearMathItemsWithin.call(this, containers);
|
||||
try {
|
||||
for (var items_1 = __values(items), items_1_1 = items_1.next(); !items_1_1.done; items_1_1 = items_1.next()) {
|
||||
var math = items_1_1.value;
|
||||
var marker = math.lazyMarker;
|
||||
if (marker) {
|
||||
this.lazyObserver.unobserve(marker);
|
||||
this.lazyList.delete(this.adaptor.getAttribute(marker, exports.LAZYID));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
||||
finally {
|
||||
try {
|
||||
if (items_1_1 && !items_1_1.done && (_a = items_1.return)) _a.call(items_1);
|
||||
}
|
||||
finally { if (e_7) throw e_7.error; }
|
||||
}
|
||||
return items;
|
||||
};
|
||||
BaseClass.prototype.render = function () {
|
||||
var always = this.options.lazyAlwaysTypeset;
|
||||
this.lazyAlwaysContainers = !always ? null :
|
||||
this.adaptor.getElements(Array.isArray(always) ? always : [always], this.document);
|
||||
this.lazyAlwaysIndex = 0;
|
||||
_super.prototype.render.call(this);
|
||||
return this;
|
||||
};
|
||||
return BaseClass;
|
||||
}(BaseDocument)),
|
||||
_a.OPTIONS = __assign(__assign({}, BaseDocument.OPTIONS), { lazyMargin: '200px', lazyAlwaysTypeset: null, renderActions: __assign(__assign({}, BaseDocument.OPTIONS.renderActions), { lazyAlways: [MathItem_js_1.STATE.LAZYALWAYS, 'lazyAlways', '', false] }) }),
|
||||
_a;
|
||||
}
|
||||
exports.LazyMathDocumentMixin = LazyMathDocumentMixin;
|
||||
function LazyHandler(handler) {
|
||||
if (typeof IntersectionObserver !== 'undefined') {
|
||||
handler.documentClass =
|
||||
LazyMathDocumentMixin(handler.documentClass);
|
||||
}
|
||||
return handler;
|
||||
}
|
||||
exports.LazyHandler = LazyHandler;
|
||||
//# sourceMappingURL=LazyHandler.js.map
|
||||
1
node_modules/mathjax-full/js/ui/lazy/LazyHandler.js.map
generated
vendored
Normal file
1
node_modules/mathjax-full/js/ui/lazy/LazyHandler.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
26
node_modules/mathjax-full/js/ui/menu/MJContextMenu.d.ts
generated
vendored
Normal file
26
node_modules/mathjax-full/js/ui/menu/MJContextMenu.d.ts
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
import { MathItem } from '../../core/MathItem.js';
|
||||
import { MmlNode } from '../../core/MmlTree/MmlNode.js';
|
||||
import { SelectableInfo } from './SelectableInfo.js';
|
||||
import { ContextMenu } from 'mj-context-menu/js/context_menu.js';
|
||||
import { SubMenu } from 'mj-context-menu/js/sub_menu.js';
|
||||
import { Submenu } from 'mj-context-menu/js/item_submenu.js';
|
||||
import { Item } from 'mj-context-menu/js/item.js';
|
||||
export declare class MJContextMenu extends ContextMenu {
|
||||
static DynamicSubmenus: Map<string, (menu: MJContextMenu, sub: Submenu) => SubMenu>;
|
||||
mathItem: MathItem<HTMLElement, Text, Document>;
|
||||
annotation: string;
|
||||
showAnnotation: SelectableInfo;
|
||||
copyAnnotation: () => void;
|
||||
annotationTypes: {
|
||||
[type: string]: string[];
|
||||
};
|
||||
post(x?: any, y?: number): void;
|
||||
unpost(): void;
|
||||
findID(...names: string[]): Item;
|
||||
protected getAnnotationMenu(): void;
|
||||
protected getSemanticNode(): MmlNode | null;
|
||||
protected getAnnotations(node: MmlNode): [string, string][];
|
||||
protected annotationMatch(child: MmlNode): string | null;
|
||||
protected createAnnotationMenu(id: string, annotations: [string, string][], action: () => void): void;
|
||||
dynamicSubmenus(): void;
|
||||
}
|
||||
222
node_modules/mathjax-full/js/ui/menu/MJContextMenu.js
generated
vendored
Normal file
222
node_modules/mathjax-full/js/ui/menu/MJContextMenu.js
generated
vendored
Normal file
@@ -0,0 +1,222 @@
|
||||
"use strict";
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
return function (d, b) {
|
||||
if (typeof b !== "function" && b !== null)
|
||||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
var __values = (this && this.__values) || function(o) {
|
||||
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
||||
if (m) return m.call(o);
|
||||
if (o && typeof o.length === "number") return {
|
||||
next: function () {
|
||||
if (o && i >= o.length) o = void 0;
|
||||
return { value: o && o[i++], done: !o };
|
||||
}
|
||||
};
|
||||
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
||||
};
|
||||
var __read = (this && this.__read) || function (o, n) {
|
||||
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
||||
if (!m) return o;
|
||||
var i = m.call(o), r, ar = [], e;
|
||||
try {
|
||||
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
||||
}
|
||||
catch (error) { e = { error: error }; }
|
||||
finally {
|
||||
try {
|
||||
if (r && !r.done && (m = i["return"])) m.call(i);
|
||||
}
|
||||
finally { if (e) throw e.error; }
|
||||
}
|
||||
return ar;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.MJContextMenu = void 0;
|
||||
var context_menu_js_1 = require("mj-context-menu/js/context_menu.js");
|
||||
var item_submenu_js_1 = require("mj-context-menu/js/item_submenu.js");
|
||||
var MJContextMenu = (function (_super) {
|
||||
__extends(MJContextMenu, _super);
|
||||
function MJContextMenu() {
|
||||
var _this = _super !== null && _super.apply(this, arguments) || this;
|
||||
_this.mathItem = null;
|
||||
_this.annotation = '';
|
||||
_this.annotationTypes = {};
|
||||
return _this;
|
||||
}
|
||||
MJContextMenu.prototype.post = function (x, y) {
|
||||
if (this.mathItem) {
|
||||
if (y !== undefined) {
|
||||
var input = this.mathItem.inputJax.name;
|
||||
var original = this.findID('Show', 'Original');
|
||||
original.content = (input === 'MathML' ? 'Original MathML' : input + ' Commands');
|
||||
var clipboard = this.findID('Copy', 'Original');
|
||||
clipboard.content = original.content;
|
||||
var semantics = this.findID('Settings', 'semantics');
|
||||
input === 'MathML' ? semantics.disable() : semantics.enable();
|
||||
this.getAnnotationMenu();
|
||||
this.dynamicSubmenus();
|
||||
}
|
||||
_super.prototype.post.call(this, x, y);
|
||||
}
|
||||
};
|
||||
MJContextMenu.prototype.unpost = function () {
|
||||
_super.prototype.unpost.call(this);
|
||||
this.mathItem = null;
|
||||
};
|
||||
MJContextMenu.prototype.findID = function () {
|
||||
var e_1, _a;
|
||||
var names = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
names[_i] = arguments[_i];
|
||||
}
|
||||
var menu = this;
|
||||
var item = null;
|
||||
try {
|
||||
for (var names_1 = __values(names), names_1_1 = names_1.next(); !names_1_1.done; names_1_1 = names_1.next()) {
|
||||
var name_1 = names_1_1.value;
|
||||
if (menu) {
|
||||
item = menu.find(name_1);
|
||||
menu = (item instanceof item_submenu_js_1.Submenu ? item.submenu : null);
|
||||
}
|
||||
else {
|
||||
item = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
||||
finally {
|
||||
try {
|
||||
if (names_1_1 && !names_1_1.done && (_a = names_1.return)) _a.call(names_1);
|
||||
}
|
||||
finally { if (e_1) throw e_1.error; }
|
||||
}
|
||||
return item;
|
||||
};
|
||||
MJContextMenu.prototype.getAnnotationMenu = function () {
|
||||
var _this = this;
|
||||
var annotations = this.getAnnotations(this.getSemanticNode());
|
||||
this.createAnnotationMenu('Show', annotations, function () { return _this.showAnnotation.post(); });
|
||||
this.createAnnotationMenu('Copy', annotations, function () { return _this.copyAnnotation(); });
|
||||
};
|
||||
MJContextMenu.prototype.getSemanticNode = function () {
|
||||
var node = this.mathItem.root;
|
||||
while (node && !node.isKind('semantics')) {
|
||||
if (node.isToken || node.childNodes.length !== 1)
|
||||
return null;
|
||||
node = node.childNodes[0];
|
||||
}
|
||||
return node;
|
||||
};
|
||||
MJContextMenu.prototype.getAnnotations = function (node) {
|
||||
var e_2, _a;
|
||||
var annotations = [];
|
||||
if (!node)
|
||||
return annotations;
|
||||
try {
|
||||
for (var _b = __values(node.childNodes), _c = _b.next(); !_c.done; _c = _b.next()) {
|
||||
var child = _c.value;
|
||||
if (child.isKind('annotation')) {
|
||||
var match = this.annotationMatch(child);
|
||||
if (match) {
|
||||
var value = child.childNodes.reduce(function (text, chars) { return text + chars.toString(); }, '');
|
||||
annotations.push([match, value]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
||||
finally {
|
||||
try {
|
||||
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
||||
}
|
||||
finally { if (e_2) throw e_2.error; }
|
||||
}
|
||||
return annotations;
|
||||
};
|
||||
MJContextMenu.prototype.annotationMatch = function (child) {
|
||||
var e_3, _a;
|
||||
var encoding = child.attributes.get('encoding');
|
||||
try {
|
||||
for (var _b = __values(Object.keys(this.annotationTypes)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
||||
var type = _c.value;
|
||||
if (this.annotationTypes[type].indexOf(encoding) >= 0) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
||||
finally {
|
||||
try {
|
||||
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
||||
}
|
||||
finally { if (e_3) throw e_3.error; }
|
||||
}
|
||||
return null;
|
||||
};
|
||||
MJContextMenu.prototype.createAnnotationMenu = function (id, annotations, action) {
|
||||
var _this = this;
|
||||
var menu = this.findID(id, 'Annotation');
|
||||
menu.submenu = this.factory.get('subMenu')(this.factory, {
|
||||
items: annotations.map(function (_a) {
|
||||
var _b = __read(_a, 2), type = _b[0], value = _b[1];
|
||||
return {
|
||||
type: 'command',
|
||||
id: type,
|
||||
content: type,
|
||||
action: function () {
|
||||
_this.annotation = value;
|
||||
action();
|
||||
}
|
||||
};
|
||||
}),
|
||||
id: 'annotations'
|
||||
}, menu);
|
||||
if (annotations.length) {
|
||||
menu.enable();
|
||||
}
|
||||
else {
|
||||
menu.disable();
|
||||
}
|
||||
};
|
||||
MJContextMenu.prototype.dynamicSubmenus = function () {
|
||||
var e_4, _a;
|
||||
try {
|
||||
for (var _b = __values(MJContextMenu.DynamicSubmenus), _c = _b.next(); !_c.done; _c = _b.next()) {
|
||||
var _d = __read(_c.value, 2), id = _d[0], method = _d[1];
|
||||
var menu = this.find(id);
|
||||
if (!menu)
|
||||
continue;
|
||||
var sub = method(this, menu);
|
||||
menu.submenu = sub;
|
||||
if (sub.items.length) {
|
||||
menu.enable();
|
||||
}
|
||||
else {
|
||||
menu.disable();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
||||
finally {
|
||||
try {
|
||||
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
||||
}
|
||||
finally { if (e_4) throw e_4.error; }
|
||||
}
|
||||
};
|
||||
MJContextMenu.DynamicSubmenus = new Map();
|
||||
return MJContextMenu;
|
||||
}(context_menu_js_1.ContextMenu));
|
||||
exports.MJContextMenu = MJContextMenu;
|
||||
//# sourceMappingURL=MJContextMenu.js.map
|
||||
1
node_modules/mathjax-full/js/ui/menu/MJContextMenu.js.map
generated
vendored
Normal file
1
node_modules/mathjax-full/js/ui/menu/MJContextMenu.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"MJContextMenu.js","sourceRoot":"","sources":["../../../ts/ui/menu/MJContextMenu.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,sEAA+D;AAE/D,sEAA2D;AAU3D;IAAmC,iCAAW;IAA9C;QAAA,qEAyMC;QA5LQ,cAAQ,GAA0C,IAAI,CAAC;QAKvD,gBAAU,GAAW,EAAE,CAAC;QAexB,qBAAe,GAA+B,EAAE,CAAC;;IAwK1D,CAAC;IA9JQ,4BAAI,GAAX,UAAY,CAAO,EAAE,CAAU;QAC7B,IAAI,IAAI,CAAC,QAAQ,EAAE;YACjB,IAAI,CAAC,KAAK,SAAS,EAAE;gBAEnB,IAAM,KAAK,GAA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AAE,IAAI;oBACb,MAAM,EAAE;wBACN,KAAI,CAAC,UAAU,GAAG,KAAK,CAAC;wBACxB,MAAM,EAAE,CAAC;oBACX,CAAC;iBACF,CAAC;YACJ,CAAC,CAAC;YACF,EAAE,EAAE,aAAa;SAClB,EAAE,IAAI,CAAC,CAAC;QACT,IAAI,WAAW,CAAC,MAAM,EAAE;YACtB,IAAI,CAAC,MAAM,EAAE,CAAC;SACf;aAAM;YACL,IAAI,CAAC,OAAO,EAAE,CAAC;SAChB;IACH,CAAC;IAOM,uCAAe,GAAtB;;;YACE,KAA2B,IAAA,KAAA,SAAA,aAAa,CAAC,eAAe,CAAA,gBAAA,4BAAE;gBAA/C,IAAA,KAAA,mBAAY,EAAX,EAAE,QAAA,EAAE,MAAM,QAAA;gBACpB,IAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAY,CAAC;gBACtC,IAAI,CAAC,IAAI;oBAAE,SAAS;gBACpB,IAAM,GAAG,GAAG,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;gBAC/B,IAAI,CAAC,OAAO,GAAG,GAAG,CAAC;gBACnB,IAAI,GAAG,CAAC,KAAK,CAAC,MAAM,EAAE;oBACpB,IAAI,CAAC,MAAM,EAAE,CAAC;iBACf;qBAAM;oBACL,IAAI,CAAC,OAAO,EAAE,CAAC;iBAChB;aACF;;;;;;;;;IACH,CAAC;IAjMa,6BAAe,GAEhB,IAAI,GAAG,EAAE,CAAC;IAiMzB,oBAAC;CAAA,AAzMD,CAAmC,6BAAW,GAyM7C;AAzMY,sCAAa"}
|
||||
115
node_modules/mathjax-full/js/ui/menu/Menu.d.ts
generated
vendored
Normal file
115
node_modules/mathjax-full/js/ui/menu/Menu.d.ts
generated
vendored
Normal file
@@ -0,0 +1,115 @@
|
||||
import { MathItem } from '../../core/MathItem.js';
|
||||
import { OutputJax } from '../../core/OutputJax.js';
|
||||
import { OptionList } from '../../util/Options.js';
|
||||
import { MJContextMenu } from './MJContextMenu.js';
|
||||
import { MmlVisitor } from './MmlVisitor.js';
|
||||
import { SelectableInfo } from './SelectableInfo.js';
|
||||
import { MenuMathDocument } from './MenuHandler.js';
|
||||
import { Info } from 'mj-context-menu/js/info.js';
|
||||
export interface MenuSettings {
|
||||
texHints: boolean;
|
||||
semantics: boolean;
|
||||
zoom: string;
|
||||
zscale: string;
|
||||
renderer: string;
|
||||
alt: boolean;
|
||||
cmd: boolean;
|
||||
ctrl: boolean;
|
||||
shift: boolean;
|
||||
scale: string;
|
||||
autocollapse: boolean;
|
||||
collapsible: boolean;
|
||||
inTabOrder: boolean;
|
||||
assistiveMml: boolean;
|
||||
backgroundColor: string;
|
||||
backgroundOpacity: string;
|
||||
braille: boolean;
|
||||
explorer: boolean;
|
||||
foregroundColor: string;
|
||||
foregroundOpacity: string;
|
||||
highlight: string;
|
||||
locale: string;
|
||||
infoPrefix: boolean;
|
||||
infoRole: boolean;
|
||||
infoType: boolean;
|
||||
magnification: string;
|
||||
magnify: string;
|
||||
speech: boolean;
|
||||
speechRules: string;
|
||||
subtitles: boolean;
|
||||
treeColoring: boolean;
|
||||
viewBraille: boolean;
|
||||
}
|
||||
export declare type HTMLMATHITEM = MathItem<HTMLElement, Text, Document>;
|
||||
export declare class Menu {
|
||||
static MENU_STORAGE: string;
|
||||
static OPTIONS: OptionList;
|
||||
protected static loading: number;
|
||||
protected static loadingPromises: Map<string, Promise<void>>;
|
||||
protected static _loadingPromise: Promise<void>;
|
||||
protected static _loadingOK: Function;
|
||||
protected static _loadingFailed: Function;
|
||||
options: OptionList;
|
||||
settings: MenuSettings;
|
||||
defaultSettings: MenuSettings;
|
||||
menu: MJContextMenu;
|
||||
MmlVisitor: MmlVisitor<HTMLElement, Text, Document>;
|
||||
protected document: MenuMathDocument;
|
||||
protected jax: {
|
||||
[name: string]: OutputJax<HTMLElement, Text, Document>;
|
||||
};
|
||||
protected rerenderStart: number;
|
||||
get isLoading(): boolean;
|
||||
get loadingPromise(): Promise<void>;
|
||||
protected about: Info;
|
||||
protected help: Info;
|
||||
protected mathmlCode: SelectableInfo;
|
||||
protected originalText: SelectableInfo;
|
||||
protected annotationText: SelectableInfo;
|
||||
protected zoomBox: Info;
|
||||
constructor(document: MenuMathDocument, options?: OptionList);
|
||||
protected initSettings(): void;
|
||||
protected initMenu(): void;
|
||||
protected checkLoadableItems(): void;
|
||||
protected enableExplorerItems(enable: boolean): void;
|
||||
protected mergeUserSettings(): void;
|
||||
protected saveUserSettings(): void;
|
||||
protected setA11y(options: {
|
||||
[key: string]: any;
|
||||
}): void;
|
||||
protected getA11y(option: string): any;
|
||||
protected applySettings(): void;
|
||||
protected setScale(scale: string): void;
|
||||
protected setRenderer(jax: string): void;
|
||||
protected setOutputJax(jax: string): void;
|
||||
protected setTabOrder(tab: boolean): void;
|
||||
protected setAssistiveMml(mml: boolean): void;
|
||||
protected setExplorer(explore: boolean): void;
|
||||
protected setCollapsible(collapse: boolean): void;
|
||||
protected scaleAllMath(): void;
|
||||
protected resetDefaults(): void;
|
||||
checkComponent(name: string): void;
|
||||
protected loadComponent(name: string, callback: () => void): void;
|
||||
loadA11y(component: string): void;
|
||||
protected transferMathList(document: MenuMathDocument): void;
|
||||
protected formatSource(text: string): string;
|
||||
protected toMML(math: HTMLMATHITEM): string;
|
||||
protected zoom(event: MouseEvent, type: string, math: HTMLMATHITEM): void;
|
||||
protected isZoomEvent(event: MouseEvent, zoom: string): boolean;
|
||||
protected rerender(start?: number): void;
|
||||
protected copyMathML(): void;
|
||||
protected copyOriginal(): void;
|
||||
copyAnnotation(): void;
|
||||
protected copyToClipboard(text: string): void;
|
||||
addMenu(math: HTMLMATHITEM): void;
|
||||
clear(): void;
|
||||
variable<T extends (string | boolean)>(name: keyof MenuSettings, action?: (value: T) => void): Object;
|
||||
a11yVar<T extends (string | boolean)>(name: keyof MenuSettings, action?: (value: T) => void): Object;
|
||||
submenu(id: string, content: string, entries?: any[], disabled?: boolean): Object;
|
||||
command(id: string, content: string, action: () => void, other?: Object): Object;
|
||||
checkbox(id: string, content: string, variable: string, other?: Object): Object;
|
||||
radioGroup(variable: string, radios: string[][]): Object[];
|
||||
radio(id: string, content: string, variable: string, other?: Object): Object;
|
||||
label(id: string, content: string): Object;
|
||||
rule(): Object;
|
||||
}
|
||||
822
node_modules/mathjax-full/js/ui/menu/Menu.js
generated
vendored
Normal file
822
node_modules/mathjax-full/js/ui/menu/Menu.js
generated
vendored
Normal file
@@ -0,0 +1,822 @@
|
||||
"use strict";
|
||||
var __read = (this && this.__read) || function (o, n) {
|
||||
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
||||
if (!m) return o;
|
||||
var i = m.call(o), r, ar = [], e;
|
||||
try {
|
||||
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
||||
}
|
||||
catch (error) { e = { error: error }; }
|
||||
finally {
|
||||
try {
|
||||
if (r && !r.done && (m = i["return"])) m.call(i);
|
||||
}
|
||||
finally { if (e) throw e.error; }
|
||||
}
|
||||
return ar;
|
||||
};
|
||||
var __values = (this && this.__values) || function(o) {
|
||||
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
||||
if (m) return m.call(o);
|
||||
if (o && typeof o.length === "number") return {
|
||||
next: function () {
|
||||
if (o && i >= o.length) o = void 0;
|
||||
return { value: o && o[i++], done: !o };
|
||||
}
|
||||
};
|
||||
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Menu = void 0;
|
||||
var mathjax_js_1 = require("../../mathjax.js");
|
||||
var MathItem_js_1 = require("../../core/MathItem.js");
|
||||
var global_js_1 = require("../../components/global.js");
|
||||
var Options_js_1 = require("../../util/Options.js");
|
||||
var MJContextMenu_js_1 = require("./MJContextMenu.js");
|
||||
var MmlVisitor_js_1 = require("./MmlVisitor.js");
|
||||
var SelectableInfo_js_1 = require("./SelectableInfo.js");
|
||||
var info_js_1 = require("mj-context-menu/js/info.js");
|
||||
var parse_js_1 = require("mj-context-menu/js/parse.js");
|
||||
var item_rule_js_1 = require("mj-context-menu/js/item_rule.js");
|
||||
var css_util_js_1 = require("mj-context-menu/js/css_util.js");
|
||||
var sre_js_1 = __importDefault(require("../../a11y/sre.js"));
|
||||
var MathJax = global_js_1.MathJax;
|
||||
var isMac = (typeof window !== 'undefined' &&
|
||||
window.navigator && window.navigator.platform.substr(0, 3) === 'Mac');
|
||||
var Menu = (function () {
|
||||
function Menu(document, options) {
|
||||
if (options === void 0) { options = {}; }
|
||||
var _this = this;
|
||||
this.settings = null;
|
||||
this.defaultSettings = null;
|
||||
this.menu = null;
|
||||
this.MmlVisitor = new MmlVisitor_js_1.MmlVisitor();
|
||||
this.jax = {
|
||||
CHTML: null,
|
||||
SVG: null
|
||||
};
|
||||
this.rerenderStart = MathItem_js_1.STATE.LAST;
|
||||
this.about = new info_js_1.Info('<b style="font-size:120%;">MathJax</b> v' + mathjax_js_1.mathjax.version, function () {
|
||||
var lines = [];
|
||||
lines.push('Input Jax: ' + _this.document.inputJax.map(function (jax) { return jax.name; }).join(', '));
|
||||
lines.push('Output Jax: ' + _this.document.outputJax.name);
|
||||
lines.push('Document Type: ' + _this.document.kind);
|
||||
return lines.join('<br/>');
|
||||
}, '<a href="https://www.mathjax.org">www.mathjax.org</a>');
|
||||
this.help = new info_js_1.Info('<b>MathJax Help</b>', function () {
|
||||
return [
|
||||
'<p><b>MathJax</b> is a JavaScript library that allows page',
|
||||
' authors to include mathematics within their web pages.',
|
||||
' As a reader, you don\'t need to do anything to make that happen.</p>',
|
||||
'<p><b>Browsers</b>: MathJax works with all modern browsers including',
|
||||
' Edge, Firefox, Chrome, Safari, Opera, and most mobile browsers.</p>',
|
||||
'<p><b>Math Menu</b>: MathJax adds a contextual menu to equations.',
|
||||
' Right-click or CTRL-click on any mathematics to access the menu.</p>',
|
||||
'<div style="margin-left: 1em;">',
|
||||
'<p><b>Show Math As:</b> These options allow you to view the formula\'s',
|
||||
' source markup (as MathML or in its original format).</p>',
|
||||
'<p><b>Copy to Clipboard:</b> These options copy the formula\'s source markup,',
|
||||
' as MathML or in its original format, to the clipboard',
|
||||
' (in browsers that support that).</p>',
|
||||
'<p><b>Math Settings:</b> These give you control over features of MathJax,',
|
||||
' such the size of the mathematics, and the mechanism used',
|
||||
' to display equations.</p>',
|
||||
'<p><b>Accessibility</b>: MathJax can work with screen',
|
||||
' readers to make mathematics accessible to the visually impaired.',
|
||||
' Turn on the explorer to enable generation of speech strings',
|
||||
' and the ability to investigate expressions interactively.</p>',
|
||||
'<p><b>Language</b>: This menu lets you select the language used by MathJax',
|
||||
' for its menus and warning messages. (Not yet implemented in version 3.)</p>',
|
||||
'</div>',
|
||||
'<p><b>Math Zoom</b>: If you are having difficulty reading an',
|
||||
' equation, MathJax can enlarge it to help you see it better, or',
|
||||
' you can scall all the math on the page to make it larger.',
|
||||
' Turn these features on in the <b>Math Settings</b> menu.</p>',
|
||||
'<p><b>Preferences</b>: MathJax uses your browser\'s localStorage database',
|
||||
' to save the preferences set via this menu locally in your browser. These',
|
||||
' are not used to track you, and are not transferred or used remotely by',
|
||||
' MathJax in any way.</p>'
|
||||
].join('\n');
|
||||
}, '<a href="https://www.mathjax.org">www.mathjax.org</a>');
|
||||
this.mathmlCode = new SelectableInfo_js_1.SelectableInfo('MathJax MathML Expression', function () {
|
||||
if (!_this.menu.mathItem)
|
||||
return '';
|
||||
var text = _this.toMML(_this.menu.mathItem);
|
||||
return '<pre>' + _this.formatSource(text) + '</pre>';
|
||||
}, '');
|
||||
this.originalText = new SelectableInfo_js_1.SelectableInfo('MathJax Original Source', function () {
|
||||
if (!_this.menu.mathItem)
|
||||
return '';
|
||||
var text = _this.menu.mathItem.math;
|
||||
return '<pre style="font-size:125%; margin:0">' + _this.formatSource(text) + '</pre>';
|
||||
}, '');
|
||||
this.annotationText = new SelectableInfo_js_1.SelectableInfo('MathJax Annotation Text', function () {
|
||||
if (!_this.menu.mathItem)
|
||||
return '';
|
||||
var text = _this.menu.annotation;
|
||||
return '<pre style="font-size:125%; margin:0">' + _this.formatSource(text) + '</pre>';
|
||||
}, '');
|
||||
this.zoomBox = new info_js_1.Info('MathJax Zoomed Expression', function () {
|
||||
if (!_this.menu.mathItem)
|
||||
return '';
|
||||
var element = _this.menu.mathItem.typesetRoot.cloneNode(true);
|
||||
element.style.margin = '0';
|
||||
var scale = 1.25 * parseFloat(_this.settings.zscale);
|
||||
return '<div style="font-size: ' + scale + '%">' + element.outerHTML + '</div>';
|
||||
}, '');
|
||||
this.document = document;
|
||||
this.options = (0, Options_js_1.userOptions)((0, Options_js_1.defaultOptions)({}, this.constructor.OPTIONS), options);
|
||||
this.initSettings();
|
||||
this.mergeUserSettings();
|
||||
this.initMenu();
|
||||
this.applySettings();
|
||||
}
|
||||
Object.defineProperty(Menu.prototype, "isLoading", {
|
||||
get: function () {
|
||||
return Menu.loading > 0;
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(Menu.prototype, "loadingPromise", {
|
||||
get: function () {
|
||||
if (!this.isLoading) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
if (!Menu._loadingPromise) {
|
||||
Menu._loadingPromise = new Promise(function (ok, failed) {
|
||||
Menu._loadingOK = ok;
|
||||
Menu._loadingFailed = failed;
|
||||
});
|
||||
}
|
||||
return Menu._loadingPromise;
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
Menu.prototype.initSettings = function () {
|
||||
this.settings = this.options.settings;
|
||||
this.jax = this.options.jax;
|
||||
var jax = this.document.outputJax;
|
||||
this.jax[jax.name] = jax;
|
||||
this.settings.renderer = jax.name;
|
||||
if (MathJax._.a11y && MathJax._.a11y.explorer) {
|
||||
Object.assign(this.settings, this.document.options.a11y);
|
||||
}
|
||||
this.settings.scale = jax.options.scale;
|
||||
this.defaultSettings = Object.assign({}, this.settings);
|
||||
};
|
||||
Menu.prototype.initMenu = function () {
|
||||
var _this = this;
|
||||
var parser = new parse_js_1.Parser([['contextMenu', MJContextMenu_js_1.MJContextMenu.fromJson.bind(MJContextMenu_js_1.MJContextMenu)]]);
|
||||
this.menu = parser.parse({
|
||||
type: 'contextMenu',
|
||||
id: 'MathJax_Menu',
|
||||
pool: [
|
||||
this.variable('texHints'),
|
||||
this.variable('semantics'),
|
||||
this.variable('zoom'),
|
||||
this.variable('zscale'),
|
||||
this.variable('renderer', function (jax) { return _this.setRenderer(jax); }),
|
||||
this.variable('alt'),
|
||||
this.variable('cmd'),
|
||||
this.variable('ctrl'),
|
||||
this.variable('shift'),
|
||||
this.variable('scale', function (scale) { return _this.setScale(scale); }),
|
||||
this.variable('explorer', function (explore) { return _this.setExplorer(explore); }),
|
||||
this.a11yVar('highlight'),
|
||||
this.a11yVar('backgroundColor'),
|
||||
this.a11yVar('backgroundOpacity'),
|
||||
this.a11yVar('foregroundColor'),
|
||||
this.a11yVar('foregroundOpacity'),
|
||||
this.a11yVar('speech'),
|
||||
this.a11yVar('subtitles'),
|
||||
this.a11yVar('braille'),
|
||||
this.a11yVar('viewBraille'),
|
||||
this.a11yVar('locale', function (value) { return sre_js_1.default.setupEngine({ locale: value }); }),
|
||||
this.a11yVar('speechRules', function (value) {
|
||||
var _a = __read(value.split('-'), 2), domain = _a[0], style = _a[1];
|
||||
_this.document.options.sre.domain = domain;
|
||||
_this.document.options.sre.style = style;
|
||||
}),
|
||||
this.a11yVar('magnification'),
|
||||
this.a11yVar('magnify'),
|
||||
this.a11yVar('treeColoring'),
|
||||
this.a11yVar('infoType'),
|
||||
this.a11yVar('infoRole'),
|
||||
this.a11yVar('infoPrefix'),
|
||||
this.variable('autocollapse'),
|
||||
this.variable('collapsible', function (collapse) { return _this.setCollapsible(collapse); }),
|
||||
this.variable('inTabOrder', function (tab) { return _this.setTabOrder(tab); }),
|
||||
this.variable('assistiveMml', function (mml) { return _this.setAssistiveMml(mml); })
|
||||
],
|
||||
items: [
|
||||
this.submenu('Show', 'Show Math As', [
|
||||
this.command('MathMLcode', 'MathML Code', function () { return _this.mathmlCode.post(); }),
|
||||
this.command('Original', 'Original Form', function () { return _this.originalText.post(); }),
|
||||
this.submenu('Annotation', 'Annotation')
|
||||
]),
|
||||
this.submenu('Copy', 'Copy to Clipboard', [
|
||||
this.command('MathMLcode', 'MathML Code', function () { return _this.copyMathML(); }),
|
||||
this.command('Original', 'Original Form', function () { return _this.copyOriginal(); }),
|
||||
this.submenu('Annotation', 'Annotation')
|
||||
]),
|
||||
this.rule(),
|
||||
this.submenu('Settings', 'Math Settings', [
|
||||
this.submenu('Renderer', 'Math Renderer', this.radioGroup('renderer', [['CHTML'], ['SVG']])),
|
||||
this.rule(),
|
||||
this.submenu('ZoomTrigger', 'Zoom Trigger', [
|
||||
this.command('ZoomNow', 'Zoom Once Now', function () { return _this.zoom(null, '', _this.menu.mathItem); }),
|
||||
this.rule(),
|
||||
this.radioGroup('zoom', [
|
||||
['Click'], ['DoubleClick', 'Double-Click'], ['NoZoom', 'No Zoom']
|
||||
]),
|
||||
this.rule(),
|
||||
this.label('TriggerRequires', 'Trigger Requires:'),
|
||||
this.checkbox((isMac ? 'Option' : 'Alt'), (isMac ? 'Option' : 'Alt'), 'alt'),
|
||||
this.checkbox('Command', 'Command', 'cmd', { hidden: !isMac }),
|
||||
this.checkbox('Control', 'Control', 'ctrl', { hiddne: isMac }),
|
||||
this.checkbox('Shift', 'Shift', 'shift')
|
||||
]),
|
||||
this.submenu('ZoomFactor', 'Zoom Factor', this.radioGroup('zscale', [
|
||||
['150%'], ['175%'], ['200%'], ['250%'], ['300%'], ['400%']
|
||||
])),
|
||||
this.rule(),
|
||||
this.command('Scale', 'Scale All Math...', function () { return _this.scaleAllMath(); }),
|
||||
this.rule(),
|
||||
this.checkbox('texHints', 'Add TeX hints to MathML', 'texHints'),
|
||||
this.checkbox('semantics', 'Add original as annotation', 'semantics'),
|
||||
this.rule(),
|
||||
this.command('Reset', 'Reset to defaults', function () { return _this.resetDefaults(); })
|
||||
]),
|
||||
this.submenu('Accessibility', 'Accessibility', [
|
||||
this.checkbox('Activate', 'Activate', 'explorer'),
|
||||
this.submenu('Speech', 'Speech', [
|
||||
this.checkbox('Speech', 'Speech Output', 'speech'),
|
||||
this.checkbox('Subtitles', 'Speech Subtitles', 'subtitles'),
|
||||
this.checkbox('Braille', 'Braille Output', 'braille'),
|
||||
this.checkbox('View Braille', 'Braille Subtitles', 'viewBraille'),
|
||||
this.rule(),
|
||||
this.submenu('A11yLanguage', 'Language'),
|
||||
this.rule(),
|
||||
this.submenu('Mathspeak', 'Mathspeak Rules', this.radioGroup('speechRules', [
|
||||
['mathspeak-default', 'Verbose'],
|
||||
['mathspeak-brief', 'Brief'],
|
||||
['mathspeak-sbrief', 'Superbrief']
|
||||
])),
|
||||
this.submenu('Clearspeak', 'Clearspeak Rules', this.radioGroup('speechRules', [
|
||||
['clearspeak-default', 'Auto']
|
||||
])),
|
||||
this.submenu('ChromeVox', 'ChromeVox Rules', this.radioGroup('speechRules', [
|
||||
['chromevox-default', 'Standard'],
|
||||
['chromevox-alternative', 'Alternative']
|
||||
]))
|
||||
]),
|
||||
this.submenu('Highlight', 'Highlight', [
|
||||
this.submenu('Background', 'Background', this.radioGroup('backgroundColor', [
|
||||
['Blue'], ['Red'], ['Green'], ['Yellow'], ['Cyan'], ['Magenta'], ['White'], ['Black']
|
||||
])),
|
||||
{ 'type': 'slider',
|
||||
'variable': 'backgroundOpacity',
|
||||
'content': ' '
|
||||
},
|
||||
this.submenu('Foreground', 'Foreground', this.radioGroup('foregroundColor', [
|
||||
['Black'], ['White'], ['Magenta'], ['Cyan'], ['Yellow'], ['Green'], ['Red'], ['Blue']
|
||||
])),
|
||||
{ 'type': 'slider',
|
||||
'variable': 'foregroundOpacity',
|
||||
'content': ' '
|
||||
},
|
||||
this.rule(),
|
||||
this.radioGroup('highlight', [
|
||||
['None'], ['Hover'], ['Flame']
|
||||
]),
|
||||
this.rule(),
|
||||
this.checkbox('TreeColoring', 'Tree Coloring', 'treeColoring')
|
||||
]),
|
||||
this.submenu('Magnification', 'Magnification', [
|
||||
this.radioGroup('magnification', [
|
||||
['None'], ['Keyboard'], ['Mouse']
|
||||
]),
|
||||
this.rule(),
|
||||
this.radioGroup('magnify', [
|
||||
['200%'], ['300%'], ['400%'], ['500%']
|
||||
])
|
||||
]),
|
||||
this.submenu('Semantic Info', 'Semantic Info', [
|
||||
this.checkbox('Type', 'Type', 'infoType'),
|
||||
this.checkbox('Role', 'Role', 'infoRole'),
|
||||
this.checkbox('Prefix', 'Prefix', 'infoPrefix')
|
||||
], true),
|
||||
this.rule(),
|
||||
this.checkbox('Collapsible', 'Collapsible Math', 'collapsible'),
|
||||
this.checkbox('AutoCollapse', 'Auto Collapse', 'autocollapse', { disabled: true }),
|
||||
this.rule(),
|
||||
this.checkbox('InTabOrder', 'Include in Tab Order', 'inTabOrder'),
|
||||
this.checkbox('AssistiveMml', 'Include Hidden MathML', 'assistiveMml')
|
||||
]),
|
||||
this.submenu('Language', 'Language'),
|
||||
this.rule(),
|
||||
this.command('About', 'About MathJax', function () { return _this.about.post(); }),
|
||||
this.command('Help', 'MathJax Help', function () { return _this.help.post(); })
|
||||
]
|
||||
});
|
||||
var menu = this.menu;
|
||||
this.about.attachMenu(menu);
|
||||
this.help.attachMenu(menu);
|
||||
this.originalText.attachMenu(menu);
|
||||
this.annotationText.attachMenu(menu);
|
||||
this.mathmlCode.attachMenu(menu);
|
||||
this.zoomBox.attachMenu(menu);
|
||||
this.checkLoadableItems();
|
||||
this.enableExplorerItems(this.settings.explorer);
|
||||
menu.showAnnotation = this.annotationText;
|
||||
menu.copyAnnotation = this.copyAnnotation.bind(this);
|
||||
menu.annotationTypes = this.options.annotationTypes;
|
||||
css_util_js_1.CssStyles.addInfoStyles(this.document.document);
|
||||
css_util_js_1.CssStyles.addMenuStyles(this.document.document);
|
||||
};
|
||||
Menu.prototype.checkLoadableItems = function () {
|
||||
var e_1, _a;
|
||||
if (MathJax && MathJax._ && MathJax.loader && MathJax.startup) {
|
||||
if (this.settings.collapsible && (!MathJax._.a11y || !MathJax._.a11y.complexity)) {
|
||||
this.loadA11y('complexity');
|
||||
}
|
||||
if (this.settings.explorer && (!MathJax._.a11y || !MathJax._.a11y.explorer)) {
|
||||
this.loadA11y('explorer');
|
||||
}
|
||||
if (this.settings.assistiveMml && (!MathJax._.a11y || !MathJax._.a11y['assistive-mml'])) {
|
||||
this.loadA11y('assistive-mml');
|
||||
}
|
||||
}
|
||||
else {
|
||||
var menu = this.menu;
|
||||
try {
|
||||
for (var _b = __values(Object.keys(this.jax)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
||||
var name_1 = _c.value;
|
||||
if (!this.jax[name_1]) {
|
||||
menu.findID('Settings', 'Renderer', name_1).disable();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
||||
finally {
|
||||
try {
|
||||
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
||||
}
|
||||
finally { if (e_1) throw e_1.error; }
|
||||
}
|
||||
menu.findID('Accessibility', 'Activate').disable();
|
||||
menu.findID('Accessibility', 'AutoCollapse').disable();
|
||||
menu.findID('Accessibility', 'Collapsible').disable();
|
||||
}
|
||||
};
|
||||
Menu.prototype.enableExplorerItems = function (enable) {
|
||||
var e_2, _a;
|
||||
var menu = this.menu.findID('Accessibility', 'Activate').menu;
|
||||
try {
|
||||
for (var _b = __values(menu.items.slice(1)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
||||
var item = _c.value;
|
||||
if (item instanceof item_rule_js_1.Rule)
|
||||
break;
|
||||
enable ? item.enable() : item.disable();
|
||||
}
|
||||
}
|
||||
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
||||
finally {
|
||||
try {
|
||||
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
||||
}
|
||||
finally { if (e_2) throw e_2.error; }
|
||||
}
|
||||
};
|
||||
Menu.prototype.mergeUserSettings = function () {
|
||||
try {
|
||||
var settings = localStorage.getItem(Menu.MENU_STORAGE);
|
||||
if (!settings)
|
||||
return;
|
||||
Object.assign(this.settings, JSON.parse(settings));
|
||||
this.setA11y(this.settings);
|
||||
}
|
||||
catch (err) {
|
||||
console.log('MathJax localStorage error: ' + err.message);
|
||||
}
|
||||
};
|
||||
Menu.prototype.saveUserSettings = function () {
|
||||
var e_3, _a;
|
||||
var settings = {};
|
||||
try {
|
||||
for (var _b = __values(Object.keys(this.settings)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
||||
var name_2 = _c.value;
|
||||
if (this.settings[name_2] !== this.defaultSettings[name_2]) {
|
||||
settings[name_2] = this.settings[name_2];
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
||||
finally {
|
||||
try {
|
||||
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
||||
}
|
||||
finally { if (e_3) throw e_3.error; }
|
||||
}
|
||||
try {
|
||||
if (Object.keys(settings).length) {
|
||||
localStorage.setItem(Menu.MENU_STORAGE, JSON.stringify(settings));
|
||||
}
|
||||
else {
|
||||
localStorage.removeItem(Menu.MENU_STORAGE);
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
console.log('MathJax localStorage error: ' + err.message);
|
||||
}
|
||||
};
|
||||
Menu.prototype.setA11y = function (options) {
|
||||
if (MathJax._.a11y && MathJax._.a11y.explorer) {
|
||||
MathJax._.a11y.explorer_ts.setA11yOptions(this.document, options);
|
||||
}
|
||||
};
|
||||
Menu.prototype.getA11y = function (option) {
|
||||
if (MathJax._.a11y && MathJax._.a11y.explorer) {
|
||||
if (this.document.options.a11y[option] !== undefined) {
|
||||
return this.document.options.a11y[option];
|
||||
}
|
||||
return this.document.options.sre[option];
|
||||
}
|
||||
};
|
||||
Menu.prototype.applySettings = function () {
|
||||
this.setTabOrder(this.settings.inTabOrder);
|
||||
this.document.options.enableAssistiveMml = this.settings.assistiveMml;
|
||||
this.document.outputJax.options.scale = parseFloat(this.settings.scale);
|
||||
if (this.settings.renderer !== this.defaultSettings.renderer) {
|
||||
this.setRenderer(this.settings.renderer);
|
||||
}
|
||||
};
|
||||
Menu.prototype.setScale = function (scale) {
|
||||
this.document.outputJax.options.scale = parseFloat(scale);
|
||||
this.document.rerender();
|
||||
};
|
||||
Menu.prototype.setRenderer = function (jax) {
|
||||
var _this = this;
|
||||
if (this.jax[jax]) {
|
||||
this.setOutputJax(jax);
|
||||
}
|
||||
else {
|
||||
var name_3 = jax.toLowerCase();
|
||||
this.loadComponent('output/' + name_3, function () {
|
||||
var startup = MathJax.startup;
|
||||
if (name_3 in startup.constructors) {
|
||||
startup.useOutput(name_3, true);
|
||||
startup.output = startup.getOutputJax();
|
||||
_this.jax[jax] = startup.output;
|
||||
_this.setOutputJax(jax);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
Menu.prototype.setOutputJax = function (jax) {
|
||||
this.jax[jax].setAdaptor(this.document.adaptor);
|
||||
this.document.outputJax = this.jax[jax];
|
||||
this.rerender();
|
||||
};
|
||||
Menu.prototype.setTabOrder = function (tab) {
|
||||
this.menu.store.inTaborder(tab);
|
||||
};
|
||||
Menu.prototype.setAssistiveMml = function (mml) {
|
||||
this.document.options.enableAssistiveMml = mml;
|
||||
if (!mml || (MathJax._.a11y && MathJax._.a11y['assistive-mml'])) {
|
||||
this.rerender();
|
||||
}
|
||||
else {
|
||||
this.loadA11y('assistive-mml');
|
||||
}
|
||||
};
|
||||
Menu.prototype.setExplorer = function (explore) {
|
||||
this.enableExplorerItems(explore);
|
||||
this.document.options.enableExplorer = explore;
|
||||
if (!explore || (MathJax._.a11y && MathJax._.a11y.explorer)) {
|
||||
this.rerender(this.settings.collapsible ? MathItem_js_1.STATE.RERENDER : MathItem_js_1.STATE.COMPILED);
|
||||
}
|
||||
else {
|
||||
this.loadA11y('explorer');
|
||||
}
|
||||
};
|
||||
Menu.prototype.setCollapsible = function (collapse) {
|
||||
this.document.options.enableComplexity = collapse;
|
||||
if (!collapse || (MathJax._.a11y && MathJax._.a11y.complexity)) {
|
||||
this.rerender(MathItem_js_1.STATE.COMPILED);
|
||||
}
|
||||
else {
|
||||
this.loadA11y('complexity');
|
||||
}
|
||||
};
|
||||
Menu.prototype.scaleAllMath = function () {
|
||||
var scale = (parseFloat(this.settings.scale) * 100).toFixed(1).replace(/.0$/, '');
|
||||
var percent = prompt('Scale all mathematics (compared to surrounding text) by', scale + '%');
|
||||
if (percent) {
|
||||
if (percent.match(/^\s*\d+(\.\d*)?\s*%?\s*$/)) {
|
||||
var scale_1 = parseFloat(percent) / 100;
|
||||
if (scale_1) {
|
||||
this.menu.pool.lookup('scale').setValue(String(scale_1));
|
||||
}
|
||||
else {
|
||||
alert('The scale should not be zero');
|
||||
}
|
||||
}
|
||||
else {
|
||||
alert('The scale should be a percentage (e.g., 120%)');
|
||||
}
|
||||
}
|
||||
};
|
||||
Menu.prototype.resetDefaults = function () {
|
||||
var e_4, _a;
|
||||
Menu.loading++;
|
||||
var pool = this.menu.pool;
|
||||
var settings = this.defaultSettings;
|
||||
try {
|
||||
for (var _b = __values(Object.keys(this.settings)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
||||
var name_4 = _c.value;
|
||||
var variable = pool.lookup(name_4);
|
||||
if (variable) {
|
||||
variable.setValue(settings[name_4]);
|
||||
var item = variable.items[0];
|
||||
if (item) {
|
||||
item.executeCallbacks_();
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.settings[name_4] = settings[name_4];
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
||||
finally {
|
||||
try {
|
||||
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
||||
}
|
||||
finally { if (e_4) throw e_4.error; }
|
||||
}
|
||||
Menu.loading--;
|
||||
this.rerender(MathItem_js_1.STATE.COMPILED);
|
||||
};
|
||||
Menu.prototype.checkComponent = function (name) {
|
||||
var promise = Menu.loadingPromises.get(name);
|
||||
if (promise) {
|
||||
mathjax_js_1.mathjax.retryAfter(promise);
|
||||
}
|
||||
};
|
||||
Menu.prototype.loadComponent = function (name, callback) {
|
||||
if (Menu.loadingPromises.has(name))
|
||||
return;
|
||||
var loader = MathJax.loader;
|
||||
if (!loader)
|
||||
return;
|
||||
Menu.loading++;
|
||||
var promise = loader.load(name).then(function () {
|
||||
Menu.loading--;
|
||||
Menu.loadingPromises.delete(name);
|
||||
callback();
|
||||
if (Menu.loading === 0 && Menu._loadingPromise) {
|
||||
Menu._loadingPromise = null;
|
||||
Menu._loadingOK();
|
||||
}
|
||||
}).catch(function (err) {
|
||||
if (Menu._loadingPromise) {
|
||||
Menu._loadingPromise = null;
|
||||
Menu._loadingFailed(err);
|
||||
}
|
||||
else {
|
||||
console.log(err);
|
||||
}
|
||||
});
|
||||
Menu.loadingPromises.set(name, promise);
|
||||
};
|
||||
Menu.prototype.loadA11y = function (component) {
|
||||
var _this = this;
|
||||
var noEnrich = !MathItem_js_1.STATE.ENRICHED;
|
||||
this.loadComponent('a11y/' + component, function () {
|
||||
var startup = MathJax.startup;
|
||||
mathjax_js_1.mathjax.handlers.unregister(startup.handler);
|
||||
startup.handler = startup.getHandler();
|
||||
mathjax_js_1.mathjax.handlers.register(startup.handler);
|
||||
var document = _this.document;
|
||||
_this.document = startup.document = startup.getDocument();
|
||||
_this.document.menu = _this;
|
||||
_this.document.outputJax.reset();
|
||||
_this.transferMathList(document);
|
||||
_this.document.processed = document.processed;
|
||||
if (!Menu._loadingPromise) {
|
||||
_this.document.outputJax.reset();
|
||||
_this.rerender(component === 'complexity' || noEnrich ? MathItem_js_1.STATE.COMPILED : MathItem_js_1.STATE.TYPESET);
|
||||
}
|
||||
});
|
||||
};
|
||||
Menu.prototype.transferMathList = function (document) {
|
||||
var e_5, _a;
|
||||
var MathItem = this.document.options.MathItem;
|
||||
try {
|
||||
for (var _b = __values(document.math), _c = _b.next(); !_c.done; _c = _b.next()) {
|
||||
var item = _c.value;
|
||||
var math = new MathItem();
|
||||
Object.assign(math, item);
|
||||
this.document.math.push(math);
|
||||
}
|
||||
}
|
||||
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
||||
finally {
|
||||
try {
|
||||
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
||||
}
|
||||
finally { if (e_5) throw e_5.error; }
|
||||
}
|
||||
};
|
||||
Menu.prototype.formatSource = function (text) {
|
||||
return text.trim().replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
|
||||
};
|
||||
Menu.prototype.toMML = function (math) {
|
||||
return this.MmlVisitor.visitTree(math.root, math, {
|
||||
texHints: this.settings.texHints,
|
||||
semantics: (this.settings.semantics && math.inputJax.name !== 'MathML')
|
||||
});
|
||||
};
|
||||
Menu.prototype.zoom = function (event, type, math) {
|
||||
if (!event || this.isZoomEvent(event, type)) {
|
||||
this.menu.mathItem = math;
|
||||
if (event) {
|
||||
this.menu.post(event);
|
||||
}
|
||||
this.zoomBox.post();
|
||||
}
|
||||
};
|
||||
Menu.prototype.isZoomEvent = function (event, zoom) {
|
||||
return (this.settings.zoom === zoom &&
|
||||
(!this.settings.alt || event.altKey) &&
|
||||
(!this.settings.ctrl || event.ctrlKey) &&
|
||||
(!this.settings.cmd || event.metaKey) &&
|
||||
(!this.settings.shift || event.shiftKey));
|
||||
};
|
||||
Menu.prototype.rerender = function (start) {
|
||||
if (start === void 0) { start = MathItem_js_1.STATE.TYPESET; }
|
||||
this.rerenderStart = Math.min(start, this.rerenderStart);
|
||||
if (!Menu.loading) {
|
||||
if (this.rerenderStart <= MathItem_js_1.STATE.COMPILED) {
|
||||
this.document.reset({ inputJax: [] });
|
||||
}
|
||||
this.document.rerender(this.rerenderStart);
|
||||
this.rerenderStart = MathItem_js_1.STATE.LAST;
|
||||
}
|
||||
};
|
||||
Menu.prototype.copyMathML = function () {
|
||||
this.copyToClipboard(this.toMML(this.menu.mathItem));
|
||||
};
|
||||
Menu.prototype.copyOriginal = function () {
|
||||
this.copyToClipboard(this.menu.mathItem.math.trim());
|
||||
};
|
||||
Menu.prototype.copyAnnotation = function () {
|
||||
this.copyToClipboard(this.menu.annotation.trim());
|
||||
};
|
||||
Menu.prototype.copyToClipboard = function (text) {
|
||||
var input = document.createElement('textarea');
|
||||
input.value = text;
|
||||
input.setAttribute('readonly', '');
|
||||
input.style.cssText = 'height: 1px; width: 1px; padding: 1px; position: absolute; left: -10px';
|
||||
document.body.appendChild(input);
|
||||
input.select();
|
||||
try {
|
||||
document.execCommand('copy');
|
||||
}
|
||||
catch (error) {
|
||||
alert('Can\'t copy to clipboard: ' + error.message);
|
||||
}
|
||||
document.body.removeChild(input);
|
||||
};
|
||||
Menu.prototype.addMenu = function (math) {
|
||||
var _this = this;
|
||||
var element = math.typesetRoot;
|
||||
element.addEventListener('contextmenu', function () { return _this.menu.mathItem = math; }, true);
|
||||
element.addEventListener('keydown', function () { return _this.menu.mathItem = math; }, true);
|
||||
element.addEventListener('click', function (event) { return _this.zoom(event, 'Click', math); }, true);
|
||||
element.addEventListener('dblclick', function (event) { return _this.zoom(event, 'DoubleClick', math); }, true);
|
||||
this.menu.store.insert(element);
|
||||
};
|
||||
Menu.prototype.clear = function () {
|
||||
this.menu.store.clear();
|
||||
};
|
||||
Menu.prototype.variable = function (name, action) {
|
||||
var _this = this;
|
||||
return {
|
||||
name: name,
|
||||
getter: function () { return _this.settings[name]; },
|
||||
setter: function (value) {
|
||||
_this.settings[name] = value;
|
||||
action && action(value);
|
||||
_this.saveUserSettings();
|
||||
}
|
||||
};
|
||||
};
|
||||
Menu.prototype.a11yVar = function (name, action) {
|
||||
var _this = this;
|
||||
return {
|
||||
name: name,
|
||||
getter: function () { return _this.getA11y(name); },
|
||||
setter: function (value) {
|
||||
_this.settings[name] = value;
|
||||
var options = {};
|
||||
options[name] = value;
|
||||
_this.setA11y(options);
|
||||
action && action(value);
|
||||
_this.saveUserSettings();
|
||||
}
|
||||
};
|
||||
};
|
||||
Menu.prototype.submenu = function (id, content, entries, disabled) {
|
||||
var e_6, _a;
|
||||
if (entries === void 0) { entries = []; }
|
||||
if (disabled === void 0) { disabled = false; }
|
||||
var items = [];
|
||||
try {
|
||||
for (var entries_1 = __values(entries), entries_1_1 = entries_1.next(); !entries_1_1.done; entries_1_1 = entries_1.next()) {
|
||||
var entry = entries_1_1.value;
|
||||
if (Array.isArray(entry)) {
|
||||
items = items.concat(entry);
|
||||
}
|
||||
else {
|
||||
items.push(entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
||||
finally {
|
||||
try {
|
||||
if (entries_1_1 && !entries_1_1.done && (_a = entries_1.return)) _a.call(entries_1);
|
||||
}
|
||||
finally { if (e_6) throw e_6.error; }
|
||||
}
|
||||
return { type: 'submenu', id: id, content: content, menu: { items: items }, disabled: (items.length === 0) || disabled };
|
||||
};
|
||||
Menu.prototype.command = function (id, content, action, other) {
|
||||
if (other === void 0) { other = {}; }
|
||||
return Object.assign({ type: 'command', id: id, content: content, action: action }, other);
|
||||
};
|
||||
Menu.prototype.checkbox = function (id, content, variable, other) {
|
||||
if (other === void 0) { other = {}; }
|
||||
return Object.assign({ type: 'checkbox', id: id, content: content, variable: variable }, other);
|
||||
};
|
||||
Menu.prototype.radioGroup = function (variable, radios) {
|
||||
var _this = this;
|
||||
return radios.map(function (def) { return _this.radio(def[0], def[1] || def[0], variable); });
|
||||
};
|
||||
Menu.prototype.radio = function (id, content, variable, other) {
|
||||
if (other === void 0) { other = {}; }
|
||||
return Object.assign({ type: 'radio', id: id, content: content, variable: variable }, other);
|
||||
};
|
||||
Menu.prototype.label = function (id, content) {
|
||||
return { type: 'label', id: id, content: content };
|
||||
};
|
||||
Menu.prototype.rule = function () {
|
||||
return { type: 'rule' };
|
||||
};
|
||||
Menu.MENU_STORAGE = 'MathJax-Menu-Settings';
|
||||
Menu.OPTIONS = {
|
||||
settings: {
|
||||
texHints: true,
|
||||
semantics: false,
|
||||
zoom: 'NoZoom',
|
||||
zscale: '200%',
|
||||
renderer: 'CHTML',
|
||||
alt: false,
|
||||
cmd: false,
|
||||
ctrl: false,
|
||||
shift: false,
|
||||
scale: 1,
|
||||
autocollapse: false,
|
||||
collapsible: false,
|
||||
inTabOrder: true,
|
||||
assistiveMml: true,
|
||||
explorer: false
|
||||
},
|
||||
jax: {
|
||||
CHTML: null,
|
||||
SVG: null
|
||||
},
|
||||
annotationTypes: (0, Options_js_1.expandable)({
|
||||
TeX: ['TeX', 'LaTeX', 'application/x-tex'],
|
||||
StarMath: ['StarMath 5.0'],
|
||||
Maple: ['Maple'],
|
||||
ContentMathML: ['MathML-Content', 'application/mathml-content+xml'],
|
||||
OpenMath: ['OpenMath']
|
||||
})
|
||||
};
|
||||
Menu.loading = 0;
|
||||
Menu.loadingPromises = new Map();
|
||||
Menu._loadingPromise = null;
|
||||
Menu._loadingOK = null;
|
||||
Menu._loadingFailed = null;
|
||||
return Menu;
|
||||
}());
|
||||
exports.Menu = Menu;
|
||||
//# sourceMappingURL=Menu.js.map
|
||||
1
node_modules/mathjax-full/js/ui/menu/Menu.js.map
generated
vendored
Normal file
1
node_modules/mathjax-full/js/ui/menu/Menu.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
23
node_modules/mathjax-full/js/ui/menu/MenuHandler.d.ts
generated
vendored
Normal file
23
node_modules/mathjax-full/js/ui/menu/MenuHandler.d.ts
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
import { MathDocumentConstructor } from '../../core/MathDocument.js';
|
||||
import { Handler } from '../../core/Handler.js';
|
||||
import { ComplexityMathDocument, ComplexityMathItem } from '../../a11y/complexity.js';
|
||||
import { ExplorerMathDocument, ExplorerMathItem } from '../../a11y/explorer.js';
|
||||
import { AssistiveMmlMathDocument, AssistiveMmlMathItem } from '../../a11y/assistive-mml.js';
|
||||
import { Menu } from './Menu.js';
|
||||
export declare type Constructor<T> = new (...args: any[]) => T;
|
||||
export declare type A11yMathItemConstructor = {
|
||||
new (...args: any[]): ComplexityMathItem<HTMLElement, Text, Document> & ExplorerMathItem & AssistiveMmlMathItem<HTMLElement, Text, Document>;
|
||||
};
|
||||
export declare type A11yDocumentConstructor = MathDocumentConstructor<ComplexityMathDocument<HTMLElement, Text, Document> & ExplorerMathDocument & AssistiveMmlMathDocument<HTMLElement, Text, Document>>;
|
||||
export interface MenuMathItem extends ComplexityMathItem<HTMLElement, Text, Document> {
|
||||
addMenu(document: MenuMathDocument, force?: boolean): void;
|
||||
checkLoading(document: MenuMathDocument): void;
|
||||
}
|
||||
export declare function MenuMathItemMixin<B extends A11yMathItemConstructor>(BaseMathItem: B): Constructor<MenuMathItem> & B;
|
||||
export interface MenuMathDocument extends ComplexityMathDocument<HTMLElement, Text, Document> {
|
||||
menu: Menu;
|
||||
addMenu(): MenuMathDocument;
|
||||
checkLoading(): MenuMathDocument;
|
||||
}
|
||||
export declare function MenuMathDocumentMixin<B extends A11yDocumentConstructor>(BaseDocument: B): Constructor<MenuMathDocument> & B;
|
||||
export declare function MenuHandler(handler: Handler<HTMLElement, Text, Document>): Handler<HTMLElement, Text, Document>;
|
||||
173
node_modules/mathjax-full/js/ui/menu/MenuHandler.js
generated
vendored
Normal file
173
node_modules/mathjax-full/js/ui/menu/MenuHandler.js
generated
vendored
Normal file
@@ -0,0 +1,173 @@
|
||||
"use strict";
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
return function (d, b) {
|
||||
if (typeof b !== "function" && b !== null)
|
||||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
var __assign = (this && this.__assign) || function () {
|
||||
__assign = Object.assign || function(t) {
|
||||
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
||||
s = arguments[i];
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
||||
t[p] = s[p];
|
||||
}
|
||||
return t;
|
||||
};
|
||||
return __assign.apply(this, arguments);
|
||||
};
|
||||
var __read = (this && this.__read) || function (o, n) {
|
||||
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
||||
if (!m) return o;
|
||||
var i = m.call(o), r, ar = [], e;
|
||||
try {
|
||||
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
||||
}
|
||||
catch (error) { e = { error: error }; }
|
||||
finally {
|
||||
try {
|
||||
if (r && !r.done && (m = i["return"])) m.call(i);
|
||||
}
|
||||
finally { if (e) throw e.error; }
|
||||
}
|
||||
return ar;
|
||||
};
|
||||
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
||||
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
||||
if (ar || !(i in from)) {
|
||||
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
||||
ar[i] = from[i];
|
||||
}
|
||||
}
|
||||
return to.concat(ar || Array.prototype.slice.call(from));
|
||||
};
|
||||
var __values = (this && this.__values) || function(o) {
|
||||
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
||||
if (m) return m.call(o);
|
||||
if (o && typeof o.length === "number") return {
|
||||
next: function () {
|
||||
if (o && i >= o.length) o = void 0;
|
||||
return { value: o && o[i++], done: !o };
|
||||
}
|
||||
};
|
||||
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.MenuHandler = exports.MenuMathDocumentMixin = exports.MenuMathItemMixin = void 0;
|
||||
var mathjax_js_1 = require("../../mathjax.js");
|
||||
var MathItem_js_1 = require("../../core/MathItem.js");
|
||||
var Options_js_1 = require("../../util/Options.js");
|
||||
var Menu_js_1 = require("./Menu.js");
|
||||
(0, MathItem_js_1.newState)('CONTEXT_MENU', 170);
|
||||
function MenuMathItemMixin(BaseMathItem) {
|
||||
return (function (_super) {
|
||||
__extends(class_1, _super);
|
||||
function class_1() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
class_1.prototype.addMenu = function (document, force) {
|
||||
if (force === void 0) { force = false; }
|
||||
if (this.state() >= MathItem_js_1.STATE.CONTEXT_MENU)
|
||||
return;
|
||||
if (!this.isEscaped && (document.options.enableMenu || force)) {
|
||||
document.menu.addMenu(this);
|
||||
}
|
||||
this.state(MathItem_js_1.STATE.CONTEXT_MENU);
|
||||
};
|
||||
class_1.prototype.checkLoading = function (document) {
|
||||
document.checkLoading();
|
||||
};
|
||||
return class_1;
|
||||
}(BaseMathItem));
|
||||
}
|
||||
exports.MenuMathItemMixin = MenuMathItemMixin;
|
||||
function MenuMathDocumentMixin(BaseDocument) {
|
||||
var _a;
|
||||
return _a = (function (_super) {
|
||||
__extends(class_2, _super);
|
||||
function class_2() {
|
||||
var args = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
args[_i] = arguments[_i];
|
||||
}
|
||||
var _this = _super.apply(this, __spreadArray([], __read(args), false)) || this;
|
||||
_this.menu = new _this.options.MenuClass(_this, _this.options.menuOptions);
|
||||
var ProcessBits = _this.constructor.ProcessBits;
|
||||
if (!ProcessBits.has('context-menu')) {
|
||||
ProcessBits.allocate('context-menu');
|
||||
}
|
||||
_this.options.MathItem = MenuMathItemMixin(_this.options.MathItem);
|
||||
return _this;
|
||||
}
|
||||
class_2.prototype.addMenu = function () {
|
||||
var e_1, _a;
|
||||
if (!this.processed.isSet('context-menu')) {
|
||||
try {
|
||||
for (var _b = __values(this.math), _c = _b.next(); !_c.done; _c = _b.next()) {
|
||||
var math = _c.value;
|
||||
math.addMenu(this);
|
||||
}
|
||||
}
|
||||
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
||||
finally {
|
||||
try {
|
||||
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
||||
}
|
||||
finally { if (e_1) throw e_1.error; }
|
||||
}
|
||||
this.processed.set('context-menu');
|
||||
}
|
||||
return this;
|
||||
};
|
||||
class_2.prototype.checkLoading = function () {
|
||||
if (this.menu.isLoading) {
|
||||
mathjax_js_1.mathjax.retryAfter(this.menu.loadingPromise.catch(function (err) { return console.log(err); }));
|
||||
}
|
||||
var settings = this.menu.settings;
|
||||
if (settings.collapsible) {
|
||||
this.options.enableComplexity = true;
|
||||
this.menu.checkComponent('a11y/complexity');
|
||||
}
|
||||
if (settings.explorer) {
|
||||
this.options.enableEnrichment = true;
|
||||
this.options.enableExplorer = true;
|
||||
this.menu.checkComponent('a11y/explorer');
|
||||
}
|
||||
return this;
|
||||
};
|
||||
class_2.prototype.state = function (state, restore) {
|
||||
if (restore === void 0) { restore = false; }
|
||||
_super.prototype.state.call(this, state, restore);
|
||||
if (state < MathItem_js_1.STATE.CONTEXT_MENU) {
|
||||
this.processed.clear('context-menu');
|
||||
}
|
||||
return this;
|
||||
};
|
||||
class_2.prototype.updateDocument = function () {
|
||||
_super.prototype.updateDocument.call(this);
|
||||
this.menu.menu.store.sort();
|
||||
return this;
|
||||
};
|
||||
return class_2;
|
||||
}(BaseDocument)),
|
||||
_a.OPTIONS = __assign(__assign({ enableEnrichment: true, enableComplexity: true, enableExplorer: true, enrichSpeech: 'none', enrichError: function (_doc, _math, err) {
|
||||
return console.warn('Enrichment Error:', err);
|
||||
} }, BaseDocument.OPTIONS), { MenuClass: Menu_js_1.Menu, menuOptions: Menu_js_1.Menu.OPTIONS, enableMenu: true, sre: (BaseDocument.OPTIONS.sre || (0, Options_js_1.expandable)({})), a11y: (BaseDocument.OPTIONS.a11y || (0, Options_js_1.expandable)({})), renderActions: (0, Options_js_1.expandable)(__assign(__assign({}, BaseDocument.OPTIONS.renderActions), { addMenu: [MathItem_js_1.STATE.CONTEXT_MENU], checkLoading: [MathItem_js_1.STATE.UNPROCESSED + 1] })) }),
|
||||
_a;
|
||||
}
|
||||
exports.MenuMathDocumentMixin = MenuMathDocumentMixin;
|
||||
function MenuHandler(handler) {
|
||||
handler.documentClass = MenuMathDocumentMixin(handler.documentClass);
|
||||
return handler;
|
||||
}
|
||||
exports.MenuHandler = MenuHandler;
|
||||
//# sourceMappingURL=MenuHandler.js.map
|
||||
1
node_modules/mathjax-full/js/ui/menu/MenuHandler.js.map
generated
vendored
Normal file
1
node_modules/mathjax-full/js/ui/menu/MenuHandler.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"MenuHandler.js","sourceRoot":"","sources":["../../../ts/ui/menu/MenuHandler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuBA,+CAAyC;AAEzC,sDAAuD;AAMvD,oDAAiD;AAEjD,qCAA+B;AA6B/B,IAAA,sBAAQ,EAAC,cAAc,EAAE,GAAG,CAAC,CAAC;AA4B9B,SAAgB,iBAAiB,CAC/B,YAAe;IAGf;QAAqB,2BAAY;QAA1B;;QAqBP,CAAC;QAfQ,yBAAO,GAAd,UAAe,QAA0B,EAAE,KAAsB;YAAtB,sBAAA,EAAA,aAAsB;YAC/D,IAAI,IAAI,CAAC,KAAK,EAAE,IAAI,mBAAK,CAAC,YAAY;gBAAE,OAAO;YAC/C,IAAI,CAAC,IAAI,CAAC,SAAS,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,UAAU,IAAI,KAAK,CAAC,EAAE;gBAC7D,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;aAC7B;YACD,IAAI,CAAC,KAAK,CAAC,mBAAK,CAAC,YAAY,CAAC,CAAC;QACjC,CAAC;QAKM,8BAAY,GAA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,IAAsB,EAAE,KAAmB,EAAE,GAAU;gBACnE,OAAA,OAAO,CAAC,IAAI,CAAC,mBAAmB,EAAE,GAAG,CAAC;YAAtC,CAAsC,IACrC,YAAY,CAAC,OAAO,KACvB,SAAS,EAAE,cAAI,EACf,WAAW,EAAE,cAAI,CAAC,OAAO,EACzB,UAAU,EAAE,IAAI,EAChB,GAAG,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,IAAI,IAAA,uBAAU,EAAC,EAAE,CAAC,CAAC,EACjD,IAAI,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,IAAI,IAAA,uBAAU,EAAC,EAAE,CAAC,CAAC,EACnD,aAAa,EAAE,IAAA,uBAAU,wBACpB,YAAY,CAAC,OAAO,CAAC,aAAa,KACrC,OAAO,EAAE,CAAC,mBAAK,CAAC,YAAY,CAAC,EAC7B,YAAY,EAAE,CAAC,mBAAK,CAAC,WAAW,GAAG,CAAC,CAAC,IACrC,GACF;WAgFF;AAEJ,CAAC;AApHD,sDAoHC;AAUD,SAAgB,WAAW,CAAC,OAA6C;IACvE,OAAO,CAAC,aAAa,GAAG,qBAAqB,CAA0B,OAAO,CAAC,aAAoB,CAAC,CAAC;IACrG,OAAO,OAAO,CAAC;AACjB,CAAC;AAHD,kCAGC"}
|
||||
11
node_modules/mathjax-full/js/ui/menu/MmlVisitor.d.ts
generated
vendored
Normal file
11
node_modules/mathjax-full/js/ui/menu/MmlVisitor.d.ts
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
import { MathItem } from '../../core/MathItem.js';
|
||||
import { MmlNode } from '../../core/MmlTree/MmlNode.js';
|
||||
import { SerializedMmlVisitor } from '../../core/MmlTree/SerializedMmlVisitor.js';
|
||||
import { OptionList } from '../../util/Options.js';
|
||||
export declare class MmlVisitor<N, T, D> extends SerializedMmlVisitor {
|
||||
options: OptionList;
|
||||
mathItem: MathItem<N, T, D>;
|
||||
visitTree(node: MmlNode, math?: MathItem<N, T, D>, options?: OptionList): any;
|
||||
visitTeXAtomNode(node: MmlNode, space: string): any;
|
||||
visitMathNode(node: MmlNode, space: string): string;
|
||||
}
|
||||
67
node_modules/mathjax-full/js/ui/menu/MmlVisitor.js
generated
vendored
Normal file
67
node_modules/mathjax-full/js/ui/menu/MmlVisitor.js
generated
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
"use strict";
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
return function (d, b) {
|
||||
if (typeof b !== "function" && b !== null)
|
||||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.MmlVisitor = void 0;
|
||||
var SerializedMmlVisitor_js_1 = require("../../core/MmlTree/SerializedMmlVisitor.js");
|
||||
var Options_js_1 = require("../../util/Options.js");
|
||||
var MmlVisitor = (function (_super) {
|
||||
__extends(MmlVisitor, _super);
|
||||
function MmlVisitor() {
|
||||
var _this = _super !== null && _super.apply(this, arguments) || this;
|
||||
_this.options = {
|
||||
texHints: true,
|
||||
semantics: false,
|
||||
};
|
||||
_this.mathItem = null;
|
||||
return _this;
|
||||
}
|
||||
MmlVisitor.prototype.visitTree = function (node, math, options) {
|
||||
if (math === void 0) { math = null; }
|
||||
if (options === void 0) { options = {}; }
|
||||
this.mathItem = math;
|
||||
(0, Options_js_1.userOptions)(this.options, options);
|
||||
return this.visitNode(node, '');
|
||||
};
|
||||
MmlVisitor.prototype.visitTeXAtomNode = function (node, space) {
|
||||
if (this.options.texHints) {
|
||||
return _super.prototype.visitTeXAtomNode.call(this, node, space);
|
||||
}
|
||||
if (node.childNodes[0] && node.childNodes[0].childNodes.length === 1) {
|
||||
return this.visitNode(node.childNodes[0], space);
|
||||
}
|
||||
return space + '<mrow' + this.getAttributes(node) + '>\n'
|
||||
+ this.childNodeMml(node, space + ' ', '\n')
|
||||
+ space + '</mrow>';
|
||||
};
|
||||
MmlVisitor.prototype.visitMathNode = function (node, space) {
|
||||
if (!this.options.semantics || this.mathItem.inputJax.name !== 'TeX') {
|
||||
return _super.prototype.visitDefault.call(this, node, space);
|
||||
}
|
||||
var addRow = node.childNodes.length && node.childNodes[0].childNodes.length > 1;
|
||||
return space + '<math' + this.getAttributes(node) + '>\n'
|
||||
+ space + ' <semantics>\n'
|
||||
+ (addRow ? space + ' <mrow>\n' : '')
|
||||
+ this.childNodeMml(node, space + (addRow ? ' ' : ' '), '\n')
|
||||
+ (addRow ? space + ' </mrow>\n' : '')
|
||||
+ space + ' <annotation encoding="application/x-tex">' + this.mathItem.math + '</annotation>\n'
|
||||
+ space + ' </semantics>\n'
|
||||
+ space + '</math>';
|
||||
};
|
||||
return MmlVisitor;
|
||||
}(SerializedMmlVisitor_js_1.SerializedMmlVisitor));
|
||||
exports.MmlVisitor = MmlVisitor;
|
||||
//# sourceMappingURL=MmlVisitor.js.map
|
||||
1
node_modules/mathjax-full/js/ui/menu/MmlVisitor.js.map
generated
vendored
Normal file
1
node_modules/mathjax-full/js/ui/menu/MmlVisitor.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"MmlVisitor.js","sourceRoot":"","sources":["../../../ts/ui/menu/MmlVisitor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAyBA,sFAAgF;AAChF,oDAA8D;AAW9D;IAAyC,8BAAoB;IAA7D;QAAA,qEA8DC;QAzDQ,aAAO,GAAe;YAC3B,QAAQ,EAAE,IAAI;YACd,SAAS,EAAE,KAAK;SACjB,CAAC;QA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,MAAM,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC;QAClF,OAAO,KAAK,GAAG,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,GAAG,KAAK;cAC1C,KAAK,GAAG,iBAAiB;cACzB,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG,cAAc,CAAC,CAAC,CAAC,EAAE,CAAC;cACtC,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,KAAK,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC;cACnE,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC;cACvC,KAAK,GAAG,+CAA+C,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,GAAG,iBAAiB;cAChG,KAAK,GAAG,kBAAkB;cAC1B,KAAK,GAAG,SAAS,CAAC;IACnC,CAAC;IAEH,iBAAC;AAAD,CAAC,AA9DD,CAAyC,8CAAoB,GA8D5D;AA9DY,gCAAU"}
|
||||
7
node_modules/mathjax-full/js/ui/menu/SelectableInfo.d.ts
generated
vendored
Normal file
7
node_modules/mathjax-full/js/ui/menu/SelectableInfo.d.ts
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
import { Info } from 'mj-context-menu/js/info.js';
|
||||
export declare class SelectableInfo extends Info {
|
||||
addEvents(element: HTMLElement): void;
|
||||
selectAll(): void;
|
||||
copyToClipboard(): void;
|
||||
generateHtml(): void;
|
||||
}
|
||||
61
node_modules/mathjax-full/js/ui/menu/SelectableInfo.js
generated
vendored
Normal file
61
node_modules/mathjax-full/js/ui/menu/SelectableInfo.js
generated
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
"use strict";
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
return function (d, b) {
|
||||
if (typeof b !== "function" && b !== null)
|
||||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.SelectableInfo = void 0;
|
||||
var info_js_1 = require("mj-context-menu/js/info.js");
|
||||
var html_classes_js_1 = require("mj-context-menu/js/html_classes.js");
|
||||
var SelectableInfo = (function (_super) {
|
||||
__extends(SelectableInfo, _super);
|
||||
function SelectableInfo() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
SelectableInfo.prototype.addEvents = function (element) {
|
||||
var _this = this;
|
||||
element.addEventListener('keypress', function (event) {
|
||||
if (event.key === 'a' && (event.ctrlKey || event.metaKey)) {
|
||||
_this.selectAll();
|
||||
_this.stop(event);
|
||||
}
|
||||
});
|
||||
};
|
||||
SelectableInfo.prototype.selectAll = function () {
|
||||
var selection = document.getSelection();
|
||||
selection.selectAllChildren(this.html.querySelector('pre'));
|
||||
};
|
||||
SelectableInfo.prototype.copyToClipboard = function () {
|
||||
this.selectAll();
|
||||
try {
|
||||
document.execCommand('copy');
|
||||
}
|
||||
catch (err) {
|
||||
alert('Can\'t copy to clipboard: ' + err.message);
|
||||
}
|
||||
document.getSelection().removeAllRanges();
|
||||
};
|
||||
SelectableInfo.prototype.generateHtml = function () {
|
||||
var _this = this;
|
||||
_super.prototype.generateHtml.call(this);
|
||||
var footer = this.html.querySelector('span.' + html_classes_js_1.HtmlClasses['INFOSIGNATURE']);
|
||||
var button = footer.appendChild(document.createElement('input'));
|
||||
button.type = 'button';
|
||||
button.value = 'Copy to Clipboard';
|
||||
button.addEventListener('click', function (_event) { return _this.copyToClipboard(); });
|
||||
};
|
||||
return SelectableInfo;
|
||||
}(info_js_1.Info));
|
||||
exports.SelectableInfo = SelectableInfo;
|
||||
//# sourceMappingURL=SelectableInfo.js.map
|
||||
1
node_modules/mathjax-full/js/ui/menu/SelectableInfo.js.map
generated
vendored
Normal file
1
node_modules/mathjax-full/js/ui/menu/SelectableInfo.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"SelectableInfo.js","sourceRoot":"","sources":["../../../ts/ui/menu/SelectableInfo.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAuBA,sDAAgD;AAChD,sEAA+D;AAO/D;IAAoC,kCAAI;IAAxC;;IAkDA,CAAC;IA1CQ,kCAAS,GAAhB,UAAiB,OAAoB;QAArC,iBAOC;QANC,OAAO,CAAC,gBAAgB,CAAC,UAAU,EAAE,UAAC,KAAoB;YACxD,IAAI,KAAK,CAAC,GAAG,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC,EAAE;gBACzD,KAAI,CAAC,SAAS,EAAE,CAAC;gBACjB,KAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aAClB;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAKM,kCAAS,GAAhB;QACE,IAAM,SAAS,GAAG,QAAQ,CAAC,YAAY,EAAE,CAAC;QAC1C,SAAS,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC;IAC9D,CAAC;IAKM,wCAAe,GAAtB;QACE,IAAI,CAAC,SAAS,EAAE,CAAC;QACjB,IAAI;YACF,QAAQ,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;SAC9B;QAAC,OAAO,GAAG,EAAE;YACZ,KAAK,CAAC,4BAA4B,GAAG,GAAG,CAAC,OAAO,CAAC,CAAC;SACnD;QACD,QAAQ,CAAC,YAAY,EAAE,CAAC,eAAe,EAAE,CAAC;IAC5C,CAAC;IAKM,qCAAY,GAAnB;QAAA,iBAOC;QANC,iBAAM,YAAY,WAAE,CAAC;QACrB,IAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,OAAO,GAAG,6BAAW,CAAC,eAAe,CAAC,CAAC,CAAC;QAC/E,IAAM,MAAM,GAAG,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC;QACnE,MAAM,CAAC,IAAI,GAAG,QAAQ,CAAC;QACvB,MAAM,CAAC,KAAK,GAAG,mBAAmB,CAAC;QACnC,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,UAAC,MAAkB,IAAK,OAAA,KAAI,CAAC,eAAe,EAAE,EAAtB,CAAsB,CAAC,CAAC;IACnF,CAAC;IAEH,qBAAC;AAAD,CAAC,AAlDD,CAAoC,cAAI,GAkDvC;AAlDY,wCAAc"}
|
||||
9
node_modules/mathjax-full/js/ui/safe/SafeHandler.d.ts
generated
vendored
Normal file
9
node_modules/mathjax-full/js/ui/safe/SafeHandler.d.ts
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import { MathDocument, MathDocumentConstructor } from '../../core/MathDocument.js';
|
||||
import { Handler } from '../../core/Handler.js';
|
||||
import { Safe } from './safe.js';
|
||||
export declare type Constructor<T> = new (...args: any[]) => T;
|
||||
export interface SafeMathDocument<N, T, D> extends MathDocument<N, T, D> {
|
||||
safe: Safe<N, T, D>;
|
||||
}
|
||||
export declare function SafeMathDocumentMixin<N, T, D, B extends MathDocumentConstructor<MathDocument<N, T, D>>>(BaseDocument: B): Constructor<SafeMathDocument<N, T, D>> & B;
|
||||
export declare function SafeHandler<N, T, D>(handler: Handler<N, T, D>): Handler<N, T, D>;
|
||||
119
node_modules/mathjax-full/js/ui/safe/SafeHandler.js
generated
vendored
Normal file
119
node_modules/mathjax-full/js/ui/safe/SafeHandler.js
generated
vendored
Normal file
@@ -0,0 +1,119 @@
|
||||
"use strict";
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
return function (d, b) {
|
||||
if (typeof b !== "function" && b !== null)
|
||||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
var __assign = (this && this.__assign) || function () {
|
||||
__assign = Object.assign || function(t) {
|
||||
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
||||
s = arguments[i];
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
||||
t[p] = s[p];
|
||||
}
|
||||
return t;
|
||||
};
|
||||
return __assign.apply(this, arguments);
|
||||
};
|
||||
var __read = (this && this.__read) || function (o, n) {
|
||||
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
||||
if (!m) return o;
|
||||
var i = m.call(o), r, ar = [], e;
|
||||
try {
|
||||
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
||||
}
|
||||
catch (error) { e = { error: error }; }
|
||||
finally {
|
||||
try {
|
||||
if (r && !r.done && (m = i["return"])) m.call(i);
|
||||
}
|
||||
finally { if (e) throw e.error; }
|
||||
}
|
||||
return ar;
|
||||
};
|
||||
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
||||
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
||||
if (ar || !(i in from)) {
|
||||
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
||||
ar[i] = from[i];
|
||||
}
|
||||
}
|
||||
return to.concat(ar || Array.prototype.slice.call(from));
|
||||
};
|
||||
var __values = (this && this.__values) || function(o) {
|
||||
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
||||
if (m) return m.call(o);
|
||||
if (o && typeof o.length === "number") return {
|
||||
next: function () {
|
||||
if (o && i >= o.length) o = void 0;
|
||||
return { value: o && o[i++], done: !o };
|
||||
}
|
||||
};
|
||||
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.SafeHandler = exports.SafeMathDocumentMixin = void 0;
|
||||
var safe_js_1 = require("./safe.js");
|
||||
function SafeMathDocumentMixin(BaseDocument) {
|
||||
var _a;
|
||||
return _a = (function (_super) {
|
||||
__extends(class_1, _super);
|
||||
function class_1() {
|
||||
var e_1, _a;
|
||||
var args = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
args[_i] = arguments[_i];
|
||||
}
|
||||
var _this = _super.apply(this, __spreadArray([], __read(args), false)) || this;
|
||||
_this.safe = new _this.options.SafeClass(_this, _this.options.safeOptions);
|
||||
var ProcessBits = _this.constructor.ProcessBits;
|
||||
if (!ProcessBits.has('safe')) {
|
||||
ProcessBits.allocate('safe');
|
||||
}
|
||||
try {
|
||||
for (var _b = __values(_this.inputJax), _c = _b.next(); !_c.done; _c = _b.next()) {
|
||||
var jax = _c.value;
|
||||
if (jax.name.match(/MathML/)) {
|
||||
jax.mathml.filterAttribute = _this.safe.mmlAttribute.bind(_this.safe);
|
||||
jax.mathml.filterClassList = _this.safe.mmlClassList.bind(_this.safe);
|
||||
}
|
||||
else if (jax.name.match(/TeX/)) {
|
||||
jax.postFilters.add(_this.sanitize.bind(jax), -5.5);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
||||
finally {
|
||||
try {
|
||||
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
||||
}
|
||||
finally { if (e_1) throw e_1.error; }
|
||||
}
|
||||
return _this;
|
||||
}
|
||||
class_1.prototype.sanitize = function (data) {
|
||||
data.math.root = this.parseOptions.root;
|
||||
data.document.safe.sanitize(data.math, data.document);
|
||||
};
|
||||
return class_1;
|
||||
}(BaseDocument)),
|
||||
_a.OPTIONS = __assign(__assign({}, BaseDocument.OPTIONS), { safeOptions: __assign({}, safe_js_1.Safe.OPTIONS), SafeClass: safe_js_1.Safe }),
|
||||
_a;
|
||||
}
|
||||
exports.SafeMathDocumentMixin = SafeMathDocumentMixin;
|
||||
function SafeHandler(handler) {
|
||||
handler.documentClass = SafeMathDocumentMixin(handler.documentClass);
|
||||
return handler;
|
||||
}
|
||||
exports.SafeHandler = SafeHandler;
|
||||
//# sourceMappingURL=SafeHandler.js.map
|
||||
1
node_modules/mathjax-full/js/ui/safe/SafeHandler.js.map
generated
vendored
Normal file
1
node_modules/mathjax-full/js/ui/safe/SafeHandler.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"SafeHandler.js","sourceRoot":"","sources":["../../../ts/ui/safe/SafeHandler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,qCAA+B;AA8B/B,SAAgB,qBAAqB,CACnC,YAAe;;IAGf;YAAqB,2BAAY;YAwB/B;;gBAAY,cAAc;qBAAd,UAAc,EAAd,qBAAc,EAAd,IAAc;oBAAd,yBAAc;;gBAA1B,wDACW,IAAI,mBAcd;gBAbC,KAAI,CAAC,IAAI,GAAG,IAAI,KAAI,CAAC,OAAO,CAAC,SAAS,CAAC,KAAI,EAAE,KAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;gBACvE,IAAM,WAAW,GAAI,KAAI,CAAC,WAAmC,CAAC,WAAW,CAAC;gBAC1E,IAAI,CAAC,WAAW,CA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B,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;IACrE,OAAO,OAAO,CAAC;AACjB,CAAC;AAHD,kCAGC"}
|
||||
4
node_modules/mathjax-full/js/ui/safe/SafeMethods.d.ts
generated
vendored
Normal file
4
node_modules/mathjax-full/js/ui/safe/SafeMethods.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import { FilterFunction } from './safe.js';
|
||||
export declare const SafeMethods: {
|
||||
[name: string]: FilterFunction<any, any, any>;
|
||||
};
|
||||
158
node_modules/mathjax-full/js/ui/safe/SafeMethods.js
generated
vendored
Normal file
158
node_modules/mathjax-full/js/ui/safe/SafeMethods.js
generated
vendored
Normal file
@@ -0,0 +1,158 @@
|
||||
"use strict";
|
||||
var __values = (this && this.__values) || function(o) {
|
||||
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
||||
if (m) return m.call(o);
|
||||
if (o && typeof o.length === "number") return {
|
||||
next: function () {
|
||||
if (o && i >= o.length) o = void 0;
|
||||
return { value: o && o[i++], done: !o };
|
||||
}
|
||||
};
|
||||
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
||||
};
|
||||
var __read = (this && this.__read) || function (o, n) {
|
||||
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
||||
if (!m) return o;
|
||||
var i = m.call(o), r, ar = [], e;
|
||||
try {
|
||||
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
||||
}
|
||||
catch (error) { e = { error: error }; }
|
||||
finally {
|
||||
try {
|
||||
if (r && !r.done && (m = i["return"])) m.call(i);
|
||||
}
|
||||
finally { if (e) throw e.error; }
|
||||
}
|
||||
return ar;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.SafeMethods = void 0;
|
||||
var lengths_js_1 = require("../../util/lengths.js");
|
||||
exports.SafeMethods = {
|
||||
filterURL: function (safe, url) {
|
||||
var protocol = (url.match(/^\s*([a-z]+):/i) || [null, ''])[1].toLowerCase();
|
||||
var allow = safe.allow.URLs;
|
||||
return (allow === 'all' || (allow === 'safe' &&
|
||||
(safe.options.safeProtocols[protocol] || !protocol))) ? url : null;
|
||||
},
|
||||
filterClassList: function (safe, list) {
|
||||
var _this = this;
|
||||
var classes = list.trim().replace(/\s\s+/g, ' ').split(/ /);
|
||||
return classes.map(function (name) { return _this.filterClass(safe, name) || ''; }).join(' ').trim().replace(/\s\s+/g, '');
|
||||
},
|
||||
filterClass: function (safe, CLASS) {
|
||||
var allow = safe.allow.classes;
|
||||
return (allow === 'all' || (allow === 'safe' && CLASS.match(safe.options.classPattern))) ? CLASS : null;
|
||||
},
|
||||
filterID: function (safe, id) {
|
||||
var allow = safe.allow.cssIDs;
|
||||
return (allow === 'all' || (allow === 'safe' && id.match(safe.options.idPattern))) ? id : null;
|
||||
},
|
||||
filterStyles: function (safe, styles) {
|
||||
var e_1, _a, e_2, _b;
|
||||
if (safe.allow.styles === 'all')
|
||||
return styles;
|
||||
if (safe.allow.styles !== 'safe')
|
||||
return null;
|
||||
var adaptor = safe.adaptor;
|
||||
var options = safe.options;
|
||||
try {
|
||||
var div1 = adaptor.node('div', { style: styles });
|
||||
var div2 = adaptor.node('div');
|
||||
try {
|
||||
for (var _c = __values(Object.keys(options.safeStyles)), _d = _c.next(); !_d.done; _d = _c.next()) {
|
||||
var style = _d.value;
|
||||
if (options.styleParts[style]) {
|
||||
try {
|
||||
for (var _e = (e_2 = void 0, __values(['Top', 'Right', 'Bottom', 'Left'])), _f = _e.next(); !_f.done; _f = _e.next()) {
|
||||
var sufix = _f.value;
|
||||
var name_1 = style + sufix;
|
||||
var value = this.filterStyle(safe, name_1, div1);
|
||||
if (value) {
|
||||
adaptor.setStyle(div2, name_1, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
||||
finally {
|
||||
try {
|
||||
if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
||||
}
|
||||
finally { if (e_2) throw e_2.error; }
|
||||
}
|
||||
}
|
||||
else {
|
||||
var value = this.filterStyle(safe, style, div1);
|
||||
if (value) {
|
||||
adaptor.setStyle(div2, style, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
||||
finally {
|
||||
try {
|
||||
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
||||
}
|
||||
finally { if (e_1) throw e_1.error; }
|
||||
}
|
||||
styles = adaptor.allStyles(div2);
|
||||
}
|
||||
catch (err) {
|
||||
styles = '';
|
||||
}
|
||||
return styles;
|
||||
},
|
||||
filterStyle: function (safe, style, div) {
|
||||
var value = safe.adaptor.getStyle(div, style);
|
||||
if (typeof value !== 'string' || value === '' || value.match(/^\s*calc/) ||
|
||||
(value.match(/javascript:/) && !safe.options.safeProtocols.javascript) ||
|
||||
(value.match(/data:/) && !safe.options.safeProtocols.data)) {
|
||||
return null;
|
||||
}
|
||||
var name = style.replace(/Top|Right|Left|Bottom/, '');
|
||||
if (!safe.options.safeStyles[style] && !safe.options.safeStyles[name]) {
|
||||
return null;
|
||||
}
|
||||
return this.filterStyleValue(safe, style, value, div);
|
||||
},
|
||||
filterStyleValue: function (safe, style, value, div) {
|
||||
var name = safe.options.styleLengths[style];
|
||||
if (!name) {
|
||||
return value;
|
||||
}
|
||||
if (typeof name !== 'string') {
|
||||
return this.filterStyleLength(safe, style, value);
|
||||
}
|
||||
var length = this.filterStyleLength(safe, name, safe.adaptor.getStyle(div, name));
|
||||
if (!length) {
|
||||
return null;
|
||||
}
|
||||
safe.adaptor.setStyle(div, name, length);
|
||||
return safe.adaptor.getStyle(div, style);
|
||||
},
|
||||
filterStyleLength: function (safe, style, value) {
|
||||
if (!value.match(/^(.+)(em|ex|ch|rem|px|mm|cm|in|pt|pc|%)$/))
|
||||
return null;
|
||||
var em = (0, lengths_js_1.length2em)(value, 1);
|
||||
var lengths = safe.options.styleLengths[style];
|
||||
var _a = __read((Array.isArray(lengths) ? lengths : [-safe.options.lengthMax, safe.options.lengthMax]), 2), m = _a[0], M = _a[1];
|
||||
return (m <= em && em <= M ? value : (em < m ? m : M).toFixed(3).replace(/\.?0+$/, '') + 'em');
|
||||
},
|
||||
filterFontSize: function (safe, size) {
|
||||
return this.filterStyleLength(safe, 'fontSize', size);
|
||||
},
|
||||
filterSizeMultiplier: function (safe, size) {
|
||||
var _a = __read(safe.options.scriptsizemultiplierRange || [-Infinity, Infinity], 2), m = _a[0], M = _a[1];
|
||||
return Math.min(M, Math.max(m, parseFloat(size))).toString();
|
||||
},
|
||||
filterScriptLevel: function (safe, level) {
|
||||
var _a = __read(safe.options.scriptlevelRange || [-Infinity, Infinity], 2), m = _a[0], M = _a[1];
|
||||
return Math.min(M, Math.max(m, parseInt(level))).toString();
|
||||
},
|
||||
filterData: function (safe, value, id) {
|
||||
return (id.match(safe.options.dataPattern) ? value : null);
|
||||
}
|
||||
};
|
||||
//# sourceMappingURL=SafeMethods.js.map
|
||||
1
node_modules/mathjax-full/js/ui/safe/SafeMethods.js.map
generated
vendored
Normal file
1
node_modules/mathjax-full/js/ui/safe/SafeMethods.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
22
node_modules/mathjax-full/js/ui/safe/safe.d.ts
generated
vendored
Normal file
22
node_modules/mathjax-full/js/ui/safe/safe.d.ts
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
import { Property } from '../../core/Tree/Node.js';
|
||||
import { MmlNode } from '../../core/MmlTree/MmlNode.js';
|
||||
import { MathItem } from '../../core/MathItem.js';
|
||||
import { MathDocument } from '../../core/MathDocument.js';
|
||||
import { OptionList } from '../../util/Options.js';
|
||||
import { DOMAdaptor } from '../../core/DOMAdaptor.js';
|
||||
export declare type FilterFunction<N, T, D> = (safe: Safe<N, T, D>, value: Property, ...args: any[]) => Property;
|
||||
export declare class Safe<N, T, D> {
|
||||
static OPTIONS: OptionList;
|
||||
filterAttributes: Map<string, string>;
|
||||
options: OptionList;
|
||||
allow: OptionList;
|
||||
adaptor: DOMAdaptor<N, T, D>;
|
||||
filterMethods: {
|
||||
[name: string]: FilterFunction<N, T, D>;
|
||||
};
|
||||
constructor(document: MathDocument<N, T, D>, options: OptionList);
|
||||
sanitize(math: MathItem<N, T, D>, document: MathDocument<N, T, D>): void;
|
||||
protected sanitizeNode(node: MmlNode): void;
|
||||
mmlAttribute(id: string, value: string): string | null;
|
||||
mmlClassList(list: string[]): string[];
|
||||
}
|
||||
165
node_modules/mathjax-full/js/ui/safe/safe.js
generated
vendored
Normal file
165
node_modules/mathjax-full/js/ui/safe/safe.js
generated
vendored
Normal file
@@ -0,0 +1,165 @@
|
||||
"use strict";
|
||||
var __assign = (this && this.__assign) || function () {
|
||||
__assign = Object.assign || function(t) {
|
||||
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
||||
s = arguments[i];
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
||||
t[p] = s[p];
|
||||
}
|
||||
return t;
|
||||
};
|
||||
return __assign.apply(this, arguments);
|
||||
};
|
||||
var __values = (this && this.__values) || function(o) {
|
||||
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
||||
if (m) return m.call(o);
|
||||
if (o && typeof o.length === "number") return {
|
||||
next: function () {
|
||||
if (o && i >= o.length) o = void 0;
|
||||
return { value: o && o[i++], done: !o };
|
||||
}
|
||||
};
|
||||
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Safe = void 0;
|
||||
var Options_js_1 = require("../../util/Options.js");
|
||||
var SafeMethods_js_1 = require("./SafeMethods.js");
|
||||
var Safe = (function () {
|
||||
function Safe(document, options) {
|
||||
this.filterAttributes = new Map([
|
||||
['href', 'filterURL'],
|
||||
['src', 'filterURL'],
|
||||
['altimg', 'filterURL'],
|
||||
['class', 'filterClassList'],
|
||||
['style', 'filterStyles'],
|
||||
['id', 'filterID'],
|
||||
['fontsize', 'filterFontSize'],
|
||||
['mathsize', 'filterFontSize'],
|
||||
['scriptminsize', 'filterFontSize'],
|
||||
['scriptsizemultiplier', 'filterSizeMultiplier'],
|
||||
['scriptlevel', 'filterScriptLevel'],
|
||||
['data-', 'filterData']
|
||||
]);
|
||||
this.filterMethods = __assign({}, SafeMethods_js_1.SafeMethods);
|
||||
this.adaptor = document.adaptor;
|
||||
this.options = options;
|
||||
this.allow = this.options.allow;
|
||||
}
|
||||
Safe.prototype.sanitize = function (math, document) {
|
||||
try {
|
||||
math.root.walkTree(this.sanitizeNode.bind(this));
|
||||
}
|
||||
catch (err) {
|
||||
document.options.compileError(document, math, err);
|
||||
}
|
||||
};
|
||||
Safe.prototype.sanitizeNode = function (node) {
|
||||
var e_1, _a;
|
||||
var attributes = node.attributes.getAllAttributes();
|
||||
try {
|
||||
for (var _b = __values(Object.keys(attributes)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
||||
var id = _c.value;
|
||||
var method = this.filterAttributes.get(id);
|
||||
if (method) {
|
||||
var value = this.filterMethods[method](this, attributes[id]);
|
||||
if (value) {
|
||||
if (value !== (typeof value === 'number' ? parseFloat(attributes[id]) : attributes[id])) {
|
||||
attributes[id] = value;
|
||||
}
|
||||
}
|
||||
else {
|
||||
delete attributes[id];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
||||
finally {
|
||||
try {
|
||||
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
||||
}
|
||||
finally { if (e_1) throw e_1.error; }
|
||||
}
|
||||
};
|
||||
Safe.prototype.mmlAttribute = function (id, value) {
|
||||
if (id === 'class')
|
||||
return null;
|
||||
var method = this.filterAttributes.get(id);
|
||||
var filter = (method || (id.substr(0, 5) === 'data-' ? this.filterAttributes.get('data-') : null));
|
||||
if (!filter) {
|
||||
return value;
|
||||
}
|
||||
var result = this.filterMethods[filter](this, value, id);
|
||||
return (typeof result === 'number' || typeof result === 'boolean' ? String(result) : result);
|
||||
};
|
||||
Safe.prototype.mmlClassList = function (list) {
|
||||
var _this = this;
|
||||
return list.map(function (name) { return _this.filterMethods.filterClass(_this, name); })
|
||||
.filter(function (value) { return value !== null; });
|
||||
};
|
||||
Safe.OPTIONS = {
|
||||
allow: {
|
||||
URLs: 'safe',
|
||||
classes: 'safe',
|
||||
cssIDs: 'safe',
|
||||
styles: 'safe'
|
||||
},
|
||||
lengthMax: 3,
|
||||
scriptsizemultiplierRange: [.6, 1],
|
||||
scriptlevelRange: [-2, 2],
|
||||
classPattern: /^mjx-[-a-zA-Z0-9_.]+$/,
|
||||
idPattern: /^mjx-[-a-zA-Z0-9_.]+$/,
|
||||
dataPattern: /^data-mjx-/,
|
||||
safeProtocols: (0, Options_js_1.expandable)({
|
||||
http: true,
|
||||
https: true,
|
||||
file: true,
|
||||
javascript: false,
|
||||
data: false
|
||||
}),
|
||||
safeStyles: (0, Options_js_1.expandable)({
|
||||
color: true,
|
||||
backgroundColor: true,
|
||||
border: true,
|
||||
cursor: true,
|
||||
margin: true,
|
||||
padding: true,
|
||||
textShadow: true,
|
||||
fontFamily: true,
|
||||
fontSize: true,
|
||||
fontStyle: true,
|
||||
fontWeight: true,
|
||||
opacity: true,
|
||||
outline: true
|
||||
}),
|
||||
styleParts: (0, Options_js_1.expandable)({
|
||||
border: true,
|
||||
padding: true,
|
||||
margin: true,
|
||||
outline: true
|
||||
}),
|
||||
styleLengths: (0, Options_js_1.expandable)({
|
||||
borderTop: 'borderTopWidth',
|
||||
borderRight: 'borderRightWidth',
|
||||
borderBottom: 'borderBottomWidth',
|
||||
borderLeft: 'borderLeftWidth',
|
||||
paddingTop: true,
|
||||
paddingRight: true,
|
||||
paddingBottom: true,
|
||||
paddingLeft: true,
|
||||
marginTop: true,
|
||||
marginRight: true,
|
||||
marginBottom: true,
|
||||
marginLeft: true,
|
||||
outlineTop: true,
|
||||
outlineRight: true,
|
||||
outlineBottom: true,
|
||||
outlineLeft: true,
|
||||
fontSize: [.707, 1.44]
|
||||
})
|
||||
};
|
||||
return Safe;
|
||||
}());
|
||||
exports.Safe = Safe;
|
||||
//# sourceMappingURL=safe.js.map
|
||||
1
node_modules/mathjax-full/js/ui/safe/safe.js.map
generated
vendored
Normal file
1
node_modules/mathjax-full/js/ui/safe/safe.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"safe.js","sourceRoot":"","sources":["../../../ts/ui/safe/safe.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,oDAA6D;AAE7D,mDAA6C;AAmB7C;IAsJE,cAAY,QAA+B,EAAE,OAAmB;QA5CzD,qBAAgB,GAAwB,IAAI,GAAG,CAAC;YAIrD,CAAC,MAAM,EAAE,WAAW,CAAC;YACrB,CAAC,KAAK,EAAG,WAAW,CAAC;YACrB,CAAC,QAAQ,EAAE,WAAW,CAAC;YACvB,CAAC,OAAO,EAAE,iBAAiB,CAAC;YAC5B,CAAC,OAAO,EAAE,cAAc,CAAC;YACzB,CAAC,IAAI,EAAE,UAAU,CAAC;YAClB,CAAC,UAAU,EAAE,gBAAgB,CAAC;YAC9B,CAAC,UAAU,EAAE,gBAAgB,CAAC;YAC9B,CAAC,eAAe,EAAE,gBAAgB,CAAC;YACnC,CAAC,sBAAsB,EAAE,sBAAsB,CAAC;YAChD,CAAC,aAAa,EAAE,mBAAmB,CAAC;YACpC,CAAC,OAAO,EAAE,YAAY,CAAC;SACxB,CAAC,CAAC;QAoBI,kBAAa,gBACf,4BAAW,EACd;QAOA,IAAI,CAAC,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC;QAChC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;IAClC,CAAC;IAQM,uBAAQ,GAAf,UAAgB,IAAuB,EAAE,QAA+B;QACtE,IAAI;YACF,IAAI,CAAC,IAAI,CAAC,QA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