figureone 1.3.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/figureone.min.js +1 -1
- package/index.js +136 -26
- package/package.json +1 -1
- package/types/js/figure/Equation/Elements/BaseAnnotationFunction.d.ts +1 -0
- package/types/js/figure/Equation/Elements/BaseEquationFunction.d.ts +1 -0
- package/types/js/figure/Equation/Equation.d.ts +24 -0
- package/types/js/figure/Equation/EquationFunctions.d.ts +27 -0
package/index.js
CHANGED
|
@@ -17225,6 +17225,10 @@ function offsetLocationForGlyphs(glyphs, offset) {
|
|
|
17225
17225
|
});
|
|
17226
17226
|
}
|
|
17227
17227
|
var BaseAnnotationFunction = /*#__PURE__*/function () {
|
|
17228
|
+
// Optional caller-supplied identifier, assigned post-dispatch by
|
|
17229
|
+
// EquationFunctions.eqnMethod. Has no layout effect; used by
|
|
17230
|
+
// Equation.getElementsInForm to look up the contents of a sub-tree.
|
|
17231
|
+
|
|
17228
17232
|
function BaseAnnotationFunction(content, annotations, glyphs, options) {
|
|
17229
17233
|
var showContent = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
|
|
17230
17234
|
_classCallCheck(this, BaseAnnotationFunction);
|
|
@@ -17236,6 +17240,7 @@ var BaseAnnotationFunction = /*#__PURE__*/function () {
|
|
|
17236
17240
|
this.showContent = showContent;
|
|
17237
17241
|
this.scale = 1;
|
|
17238
17242
|
this.color = null;
|
|
17243
|
+
this.functionName = null;
|
|
17239
17244
|
}
|
|
17240
17245
|
return _createClass(BaseAnnotationFunction, [{
|
|
17241
17246
|
key: "_dup",
|
|
@@ -17870,6 +17875,10 @@ function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf
|
|
|
17870
17875
|
|
|
17871
17876
|
|
|
17872
17877
|
var BaseEquationFunction = /*#__PURE__*/function (_Elements) {
|
|
17878
|
+
// Optional caller-supplied identifier, assigned post-dispatch by
|
|
17879
|
+
// EquationFunctions.eqnMethod. Has no layout effect; used by
|
|
17880
|
+
// Equation.getElementsInForm to look up the contents of a sub-tree.
|
|
17881
|
+
|
|
17873
17882
|
function BaseEquationFunction(content, glyph, options) {
|
|
17874
17883
|
var _this;
|
|
17875
17884
|
var showContent = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
|
|
@@ -17908,6 +17917,7 @@ var BaseEquationFunction = /*#__PURE__*/function (_Elements) {
|
|
|
17908
17917
|
});
|
|
17909
17918
|
_this.options = options;
|
|
17910
17919
|
_this.showContent = showContent;
|
|
17920
|
+
_this.functionName = null;
|
|
17911
17921
|
return _this;
|
|
17912
17922
|
}
|
|
17913
17923
|
_inherits(BaseEquationFunction, _Elements);
|
|
@@ -19441,11 +19451,12 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
19441
19451
|
/* harmony import */ var _DrawingObjects_TextObject_TextObject__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../DrawingObjects/TextObject/TextObject */ "./src/js/figure/DrawingObjects/TextObject/TextObject.ts");
|
|
19442
19452
|
/* harmony import */ var _Elements_Element__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Elements/Element */ "./src/js/figure/Equation/Elements/Element.ts");
|
|
19443
19453
|
/* harmony import */ var _Elements_BaseAnnotationFunction__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Elements/BaseAnnotationFunction */ "./src/js/figure/Equation/Elements/BaseAnnotationFunction.ts");
|
|
19444
|
-
/* harmony import */ var
|
|
19445
|
-
/* harmony import */ var
|
|
19446
|
-
/* harmony import */ var
|
|
19447
|
-
/* harmony import */ var
|
|
19448
|
-
/* harmony import */ var
|
|
19454
|
+
/* harmony import */ var _Elements_BaseEquationFunction__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Elements/BaseEquationFunction */ "./src/js/figure/Equation/Elements/BaseEquationFunction.ts");
|
|
19455
|
+
/* harmony import */ var _EquationForm__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./EquationForm */ "./src/js/figure/Equation/EquationForm.ts");
|
|
19456
|
+
/* harmony import */ var _tools_htmlGenerator__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../tools/htmlGenerator */ "./src/js/tools/htmlGenerator.ts");
|
|
19457
|
+
/* harmony import */ var _EquationSymbols__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./EquationSymbols */ "./src/js/figure/Equation/EquationSymbols.ts");
|
|
19458
|
+
/* harmony import */ var _EquationFunctions__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./EquationFunctions */ "./src/js/figure/Equation/EquationFunctions.ts");
|
|
19459
|
+
/* harmony import */ var _Animation_Animation__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Animation/Animation */ "./src/js/figure/Animation/Animation.ts");
|
|
19449
19460
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
19450
19461
|
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
19451
19462
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
@@ -19480,6 +19491,7 @@ function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf
|
|
|
19480
19491
|
|
|
19481
19492
|
|
|
19482
19493
|
|
|
19494
|
+
|
|
19483
19495
|
// import HTMLObject from '../DrawingObjects/HTMLObject/HTMLObject';
|
|
19484
19496
|
|
|
19485
19497
|
|
|
@@ -20178,7 +20190,7 @@ var NextFormAnimationStep = /*#__PURE__*/function (_TriggerAnimationStep) {
|
|
|
20178
20190
|
}
|
|
20179
20191
|
_inherits(NextFormAnimationStep, _TriggerAnimationStep);
|
|
20180
20192
|
return _createClass(NextFormAnimationStep);
|
|
20181
|
-
}(
|
|
20193
|
+
}(_Animation_Animation__WEBPACK_IMPORTED_MODULE_11__.TriggerAnimationStep);
|
|
20182
20194
|
/**
|
|
20183
20195
|
* GoToForm form animation step
|
|
20184
20196
|
*
|
|
@@ -20229,7 +20241,7 @@ var GoToFormAnimationStep = /*#__PURE__*/function (_TriggerAnimationStep2) {
|
|
|
20229
20241
|
}
|
|
20230
20242
|
_inherits(GoToFormAnimationStep, _TriggerAnimationStep2);
|
|
20231
20243
|
return _createClass(GoToFormAnimationStep);
|
|
20232
|
-
}(
|
|
20244
|
+
}(_Animation_Animation__WEBPACK_IMPORTED_MODULE_11__.TriggerAnimationStep); // export const foo = () => {};
|
|
20233
20245
|
// An Equation is a collection of elements that can be arranged into different
|
|
20234
20246
|
// forms.
|
|
20235
20247
|
// Equation allows setting of forms, and navigating through form series
|
|
@@ -20430,8 +20442,8 @@ var Equation = /*#__PURE__*/function (_FigureElementCollect) {
|
|
|
20430
20442
|
layout: optionsToUse.formDefaults.layout,
|
|
20431
20443
|
ignoreColor: optionsToUse.formDefaults.ignoreColor
|
|
20432
20444
|
},
|
|
20433
|
-
functions: new
|
|
20434
|
-
symbols: new
|
|
20445
|
+
functions: new _EquationFunctions__WEBPACK_IMPORTED_MODULE_10__.EquationFunctions(_this.elements, _this.addElementFromKey.bind(_this), _this.getExistingOrAddSymbol.bind(_this), _this.makeInlineElement.bind(_this)),
|
|
20446
|
+
symbols: new _EquationSymbols__WEBPACK_IMPORTED_MODULE_9__["default"](_this.shapes, _this.color),
|
|
20435
20447
|
font: optionsToUse.font,
|
|
20436
20448
|
textFont: optionsToUse.textFont,
|
|
20437
20449
|
// fontText: optionsToUse.fontText,
|
|
@@ -20531,7 +20543,7 @@ var Equation = /*#__PURE__*/function (_FigureElementCollect) {
|
|
|
20531
20543
|
o.delay = 0;
|
|
20532
20544
|
o.setToEnd = '_showForm';
|
|
20533
20545
|
o.timeKeeper = _this.timeKeeper;
|
|
20534
|
-
return new
|
|
20546
|
+
return new _Animation_Animation__WEBPACK_IMPORTED_MODULE_11__.TriggerAnimationStep(o);
|
|
20535
20547
|
};
|
|
20536
20548
|
_this.animations.customSteps.push({
|
|
20537
20549
|
step: _this.animations.goToForm.bind(_this),
|
|
@@ -20577,7 +20589,7 @@ var Equation = /*#__PURE__*/function (_FigureElementCollect) {
|
|
|
20577
20589
|
o.delay = 0;
|
|
20578
20590
|
o.setToEnd = '_showForm';
|
|
20579
20591
|
o.timeKeeper = _this.timeKeeper;
|
|
20580
|
-
return new
|
|
20592
|
+
return new _Animation_Animation__WEBPACK_IMPORTED_MODULE_11__.TriggerAnimationStep(o);
|
|
20581
20593
|
};
|
|
20582
20594
|
_this.animations.customSteps.push({
|
|
20583
20595
|
step: _this.animations.nextForm.bind(_this),
|
|
@@ -21221,7 +21233,7 @@ var Equation = /*#__PURE__*/function (_FigureElementCollect) {
|
|
|
21221
21233
|
key: "checkFixTo",
|
|
21222
21234
|
value: function checkFixTo(fixTo, formElements) {
|
|
21223
21235
|
if (typeof fixTo === 'string') {
|
|
21224
|
-
var element = (0,
|
|
21236
|
+
var element = (0,_EquationFunctions__WEBPACK_IMPORTED_MODULE_10__.getFigureElement)(this, fixTo);
|
|
21225
21237
|
if (element != null && formElements.indexOf(element) >= 0) {
|
|
21226
21238
|
return element;
|
|
21227
21239
|
}
|
|
@@ -21239,7 +21251,7 @@ var Equation = /*#__PURE__*/function (_FigureElementCollect) {
|
|
|
21239
21251
|
key: "createForm",
|
|
21240
21252
|
value: function createForm() {
|
|
21241
21253
|
var elements = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.elements;
|
|
21242
|
-
return new
|
|
21254
|
+
return new _EquationForm__WEBPACK_IMPORTED_MODULE_7__["default"](elements, {
|
|
21243
21255
|
getAllElements: this.getChildren.bind(this),
|
|
21244
21256
|
hideAll: this.hideAll.bind(this),
|
|
21245
21257
|
show: this.show.bind(this),
|
|
@@ -21269,6 +21281,87 @@ var Equation = /*#__PURE__*/function (_FigureElementCollect) {
|
|
|
21269
21281
|
return this.eqn.forms[form].content[0].getAllElements(includeHidden);
|
|
21270
21282
|
}
|
|
21271
21283
|
|
|
21284
|
+
/**
|
|
21285
|
+
* Return all the elements inside the named equation function within a given
|
|
21286
|
+
* form.
|
|
21287
|
+
*
|
|
21288
|
+
* Any equation function (container, fraction, matrix, etc.) can be tagged
|
|
21289
|
+
* with a `name` property in its options — this has no layout effect, but
|
|
21290
|
+
* makes the function's sub-tree addressable here.
|
|
21291
|
+
*
|
|
21292
|
+
* With `mode: 'first'` (default), returns the elements inside the first
|
|
21293
|
+
* matching function found by a depth-first traversal. With `mode: 'all'`,
|
|
21294
|
+
* walks the entire tree, collects every matching function (including those
|
|
21295
|
+
* nested inside other matches), and returns the de-duplicated union of
|
|
21296
|
+
* their elements.
|
|
21297
|
+
*
|
|
21298
|
+
* Returns an empty array if the form does not exist, or no matching
|
|
21299
|
+
* function is found.
|
|
21300
|
+
*
|
|
21301
|
+
* @param {string} formName
|
|
21302
|
+
* @param {string} name
|
|
21303
|
+
* @param {'first' | 'all'} [mode] (`'first'`)
|
|
21304
|
+
* @param {boolean} [includeHidden] (`false`)
|
|
21305
|
+
* @return {Array<FigureElement>}
|
|
21306
|
+
*/
|
|
21307
|
+
}, {
|
|
21308
|
+
key: "getElementsInForm",
|
|
21309
|
+
value: function getElementsInForm(formName, name) {
|
|
21310
|
+
var mode = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'first';
|
|
21311
|
+
var includeHidden = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
21312
|
+
var form = this.eqn.forms[formName];
|
|
21313
|
+
if (form == null) {
|
|
21314
|
+
return [];
|
|
21315
|
+
}
|
|
21316
|
+
// Single typed accessor that hides the structural differences between
|
|
21317
|
+
// Elements (.content: ElementInterface[]) and BaseAnnotationFunction
|
|
21318
|
+
// (.content: ElementInterface + .annotations[].content). All `as any`
|
|
21319
|
+
// casts for this walk live here.
|
|
21320
|
+
var childrenOf = function childrenOf(node) {
|
|
21321
|
+
var out = [];
|
|
21322
|
+
var c = node.content;
|
|
21323
|
+
if (Array.isArray(c)) {
|
|
21324
|
+
out.push.apply(out, _toConsumableArray(c));
|
|
21325
|
+
} else if (c != null) {
|
|
21326
|
+
out.push(c);
|
|
21327
|
+
}
|
|
21328
|
+
var annotations = node.annotations;
|
|
21329
|
+
if (Array.isArray(annotations)) {
|
|
21330
|
+
annotations.forEach(function (a) {
|
|
21331
|
+
if (a != null && a.content != null) out.push(a.content);
|
|
21332
|
+
});
|
|
21333
|
+
}
|
|
21334
|
+
return out;
|
|
21335
|
+
};
|
|
21336
|
+
var matches = [];
|
|
21337
|
+
var _walk = function walk(nodes) {
|
|
21338
|
+
for (var i = 0; i < nodes.length; i += 1) {
|
|
21339
|
+
var node = nodes[i];
|
|
21340
|
+
if ((node instanceof _Elements_BaseEquationFunction__WEBPACK_IMPORTED_MODULE_6__["default"] || node instanceof _Elements_BaseAnnotationFunction__WEBPACK_IMPORTED_MODULE_5__["default"]) && node.functionName === name) {
|
|
21341
|
+
matches.push(node);
|
|
21342
|
+
if (mode === 'first') return true;
|
|
21343
|
+
}
|
|
21344
|
+
if (_walk(childrenOf(node))) return true;
|
|
21345
|
+
}
|
|
21346
|
+
return false;
|
|
21347
|
+
};
|
|
21348
|
+
_walk(form.content);
|
|
21349
|
+
if (matches.length === 0) {
|
|
21350
|
+
return [];
|
|
21351
|
+
}
|
|
21352
|
+
var seen = new Set();
|
|
21353
|
+
var out = [];
|
|
21354
|
+
matches.forEach(function (m) {
|
|
21355
|
+
m.getAllElements(includeHidden).forEach(function (el) {
|
|
21356
|
+
if (!seen.has(el)) {
|
|
21357
|
+
seen.add(el);
|
|
21358
|
+
out.push(el);
|
|
21359
|
+
}
|
|
21360
|
+
});
|
|
21361
|
+
});
|
|
21362
|
+
return out;
|
|
21363
|
+
}
|
|
21364
|
+
|
|
21272
21365
|
/**
|
|
21273
21366
|
* Return all the elements that are used in an equation phrase.
|
|
21274
21367
|
* @param {TypeEquationPhrase} phrase
|
|
@@ -21403,7 +21496,7 @@ var Equation = /*#__PURE__*/function (_FigureElementCollect) {
|
|
|
21403
21496
|
var newMods = {};
|
|
21404
21497
|
Object.keys(elementMods).forEach(function (elementName) {
|
|
21405
21498
|
var mods = elementMods[elementName];
|
|
21406
|
-
var figureElement = (0,
|
|
21499
|
+
var figureElement = (0,_EquationFunctions__WEBPACK_IMPORTED_MODULE_10__.getFigureElement)(_this9, elementName);
|
|
21407
21500
|
if (figureElement != null) {
|
|
21408
21501
|
newMods[elementName] = {
|
|
21409
21502
|
element: figureElement,
|
|
@@ -21416,7 +21509,7 @@ var Equation = /*#__PURE__*/function (_FigureElementCollect) {
|
|
|
21416
21509
|
var transformTranslation = function transformTranslation(trans) {
|
|
21417
21510
|
var newTranslation = {};
|
|
21418
21511
|
Object.keys(trans).forEach(function (elementName) {
|
|
21419
|
-
var figureElement = (0,
|
|
21512
|
+
var figureElement = (0,_EquationFunctions__WEBPACK_IMPORTED_MODULE_10__.getFigureElement)(_this9, elementName);
|
|
21420
21513
|
var mods = trans[elementName];
|
|
21421
21514
|
var direction;
|
|
21422
21515
|
var style;
|
|
@@ -21594,7 +21687,7 @@ var Equation = /*#__PURE__*/function (_FigureElementCollect) {
|
|
|
21594
21687
|
value: function getForm(formOrName
|
|
21595
21688
|
// subForm: ?string,
|
|
21596
21689
|
) {
|
|
21597
|
-
if (formOrName instanceof
|
|
21690
|
+
if (formOrName instanceof _EquationForm__WEBPACK_IMPORTED_MODULE_7__["default"]) {
|
|
21598
21691
|
return formOrName;
|
|
21599
21692
|
}
|
|
21600
21693
|
if (formOrName in this.eqn.forms) {
|
|
@@ -21938,7 +22031,7 @@ var Equation = /*#__PURE__*/function (_FigureElementCollect) {
|
|
|
21938
22031
|
) {
|
|
21939
22032
|
var form = this.getForm(formOrName);
|
|
21940
22033
|
if (form != null && form.description != null) {
|
|
21941
|
-
return
|
|
22034
|
+
return _tools_htmlGenerator__WEBPACK_IMPORTED_MODULE_8__.applyModifiers(form.description, form.modifiers);
|
|
21942
22035
|
}
|
|
21943
22036
|
return '';
|
|
21944
22037
|
}
|
|
@@ -22741,9 +22834,10 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
22741
22834
|
/* harmony import */ var _Elements_Scale__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Elements/Scale */ "./src/js/figure/Equation/Elements/Scale.ts");
|
|
22742
22835
|
/* harmony import */ var _Elements_Container__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Elements/Container */ "./src/js/figure/Equation/Elements/Container.ts");
|
|
22743
22836
|
/* harmony import */ var _Elements_BaseAnnotationFunction__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Elements/BaseAnnotationFunction */ "./src/js/figure/Equation/Elements/BaseAnnotationFunction.ts");
|
|
22744
|
-
/* harmony import */ var
|
|
22745
|
-
/* harmony import */ var
|
|
22746
|
-
/* harmony import */ var
|
|
22837
|
+
/* harmony import */ var _Elements_BaseEquationFunction__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Elements/BaseEquationFunction */ "./src/js/figure/Equation/Elements/BaseEquationFunction.ts");
|
|
22838
|
+
/* harmony import */ var _Symbols_Line__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./Symbols/Line */ "./src/js/figure/Equation/Symbols/Line.ts");
|
|
22839
|
+
/* harmony import */ var _Elements_Offset__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Elements/Offset */ "./src/js/figure/Equation/Elements/Offset.ts");
|
|
22840
|
+
/* harmony import */ var _Elements_Color__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Elements/Color */ "./src/js/figure/Equation/Elements/Color.ts");
|
|
22747
22841
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
22748
22842
|
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
22749
22843
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
@@ -22773,6 +22867,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
22773
22867
|
|
|
22774
22868
|
|
|
22775
22869
|
|
|
22870
|
+
|
|
22776
22871
|
// import type {
|
|
22777
22872
|
// EQN_Annotation, EQN_EncompassGlyph, EQN_LeftRightGlyph, EQN_TopBottomGlyph,
|
|
22778
22873
|
// } from './Elements/BaseAnnotationFunction';
|
|
@@ -22893,6 +22988,9 @@ function getFigureElement(elementsObject, name) {
|
|
|
22893
22988
|
* @property {boolean} [fullContentBounds] - (`false`)
|
|
22894
22989
|
* @property {boolean} [showContent] - if `false`, a container will be created
|
|
22895
22990
|
* around the content, but the content will not be shown (`true`)
|
|
22991
|
+
* @property {string} [name] - optional identifier (available on every equation
|
|
22992
|
+
* function). Has no effect on layout, but allows the function's contents to be
|
|
22993
|
+
* looked up later with {@link Equation.getElementsInForm} (`null`)
|
|
22896
22994
|
*
|
|
22897
22995
|
* @see To test examples, append them to the
|
|
22898
22996
|
* <a href="#drawing-boilerplate">boilerplate</a>
|
|
@@ -25529,6 +25627,18 @@ var EquationFunctions = /*#__PURE__*/function () {
|
|
|
25529
25627
|
}, {
|
|
25530
25628
|
key: "eqnMethod",
|
|
25531
25629
|
value: function eqnMethod(name, params) {
|
|
25630
|
+
var result = this.dispatchEqnMethod(name, params);
|
|
25631
|
+
// Allow any equation function to be tagged with a caller-supplied
|
|
25632
|
+
// `name` via its options object. The tag has no layout effect; it's
|
|
25633
|
+
// used by Equation.getElementsInForm to look up the function's sub-tree.
|
|
25634
|
+
if (result != null && params != null && !Array.isArray(params) && _typeof(params) === 'object' && params.name != null && (result instanceof _Elements_BaseEquationFunction__WEBPACK_IMPORTED_MODULE_10__["default"] || result instanceof _Elements_BaseAnnotationFunction__WEBPACK_IMPORTED_MODULE_9__["default"])) {
|
|
25635
|
+
result.functionName = params.name;
|
|
25636
|
+
}
|
|
25637
|
+
return result;
|
|
25638
|
+
}
|
|
25639
|
+
}, {
|
|
25640
|
+
key: "dispatchEqnMethod",
|
|
25641
|
+
value: function dispatchEqnMethod(name, params) {
|
|
25532
25642
|
if (name === 'frac') {
|
|
25533
25643
|
return this.frac(params);
|
|
25534
25644
|
}
|
|
@@ -25723,7 +25833,7 @@ var EquationFunctions = /*#__PURE__*/function () {
|
|
|
25723
25833
|
fullContentBounds: fullContentBounds
|
|
25724
25834
|
};
|
|
25725
25835
|
var o = (0,_tools_tools__WEBPACK_IMPORTED_MODULE_1__.joinObjects)(defaultOptions, optionsIn);
|
|
25726
|
-
return new
|
|
25836
|
+
return new _Elements_Offset__WEBPACK_IMPORTED_MODULE_12__["default"]([this.contentToElement(content)], [], o);
|
|
25727
25837
|
} catch (e) {
|
|
25728
25838
|
throw new Error("FigureOne Equation Offset Error: ".concat(e.message));
|
|
25729
25839
|
}
|
|
@@ -26229,7 +26339,7 @@ var EquationFunctions = /*#__PURE__*/function () {
|
|
|
26229
26339
|
fullContentBounds: fullContentBounds
|
|
26230
26340
|
};
|
|
26231
26341
|
var o = (0,_tools_tools__WEBPACK_IMPORTED_MODULE_1__.joinObjects)(defaultOptions, optionsIn);
|
|
26232
|
-
return new
|
|
26342
|
+
return new _Elements_Color__WEBPACK_IMPORTED_MODULE_13__["default"]([this.contentToElement(content)], [], o);
|
|
26233
26343
|
} catch (e) {
|
|
26234
26344
|
throw new Error("FigureOne Equation Color Error: ".concat(e.message));
|
|
26235
26345
|
}
|
|
@@ -27462,7 +27572,7 @@ var EquationFunctions = /*#__PURE__*/function () {
|
|
|
27462
27572
|
});
|
|
27463
27573
|
}
|
|
27464
27574
|
var glyph = this.getExistingOrAddSymbol(symbol);
|
|
27465
|
-
if (glyph instanceof
|
|
27575
|
+
if (glyph instanceof _Symbols_Line__WEBPACK_IMPORTED_MODULE_11__["default"]) {
|
|
27466
27576
|
annotations[0].offset = [0, commentSpaceToUse + contentSpaceToUse];
|
|
27467
27577
|
return this.annotate({
|
|
27468
27578
|
content: content,
|
|
@@ -27545,7 +27655,7 @@ var EquationFunctions = /*#__PURE__*/function () {
|
|
|
27545
27655
|
});
|
|
27546
27656
|
}
|
|
27547
27657
|
var glyph = this.getExistingOrAddSymbol(symbol);
|
|
27548
|
-
if (glyph instanceof
|
|
27658
|
+
if (glyph instanceof _Symbols_Line__WEBPACK_IMPORTED_MODULE_11__["default"]) {
|
|
27549
27659
|
annotations[0].offset = [0, -commentSpaceToUse - contentSpaceToUse];
|
|
27550
27660
|
return this.annotate({
|
|
27551
27661
|
content: content,
|
|
@@ -80682,8 +80792,8 @@ var tools = {
|
|
|
80682
80792
|
*/
|
|
80683
80793
|
|
|
80684
80794
|
var Fig = {
|
|
80685
|
-
version: "1.
|
|
80686
|
-
gitHash: "
|
|
80795
|
+
version: "1.4.0",
|
|
80796
|
+
gitHash: "77f124c53",
|
|
80687
80797
|
tools: tools,
|
|
80688
80798
|
Figure: _js_figure_Figure__WEBPACK_IMPORTED_MODULE_5__["default"],
|
|
80689
80799
|
Recorder: _js_figure_Recorder_Recorder__WEBPACK_IMPORTED_MODULE_7__.Recorder,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "figureone",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "Draw, animate and interact with shapes, text, plots and equations in Javascript. Create interactive slide shows, and interactive videos.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "types/index.d.ts",
|
|
@@ -101,6 +101,7 @@ export default class BaseAnnotationFunction implements ElementInterface {
|
|
|
101
101
|
annotations: Array<EQN_Annotation>;
|
|
102
102
|
glyphs: EQN_Glyphs;
|
|
103
103
|
options: Record<string, any>;
|
|
104
|
+
functionName: string | null;
|
|
104
105
|
constructor(content: ElementInterface, annotations: Array<EQN_Annotation>, glyphs: EQN_Glyphs, options: Record<string, any>, showContent?: boolean);
|
|
105
106
|
_dup(namedCollection?: Record<string, any>): any;
|
|
106
107
|
cleanup(): void;
|
|
@@ -10,6 +10,7 @@ export default class BaseEquationFunction extends Elements {
|
|
|
10
10
|
glyphHeights: Array<number>;
|
|
11
11
|
showContent: boolean;
|
|
12
12
|
options: Record<string, any>;
|
|
13
|
+
functionName: string | null;
|
|
13
14
|
constructor(content: Elements | null | Array<Elements | null>, glyph: Symbol | null | undefined | Array<Symbol | null | undefined>, options: Record<string, any>, showContent?: boolean);
|
|
14
15
|
_dup(namedCollection?: Record<string, any>): any;
|
|
15
16
|
getAllElements(includeHidden?: boolean): any[];
|
|
@@ -906,6 +906,30 @@ export declare class Equation extends FigureElementCollection {
|
|
|
906
906
|
* @return {Array<FigureElement>}
|
|
907
907
|
*/
|
|
908
908
|
getFormElements(form: string, includeHidden?: boolean): (FigureElementCollection | FigureElementPrimitive | ElementInterface)[];
|
|
909
|
+
/**
|
|
910
|
+
* Return all the elements inside the named equation function within a given
|
|
911
|
+
* form.
|
|
912
|
+
*
|
|
913
|
+
* Any equation function (container, fraction, matrix, etc.) can be tagged
|
|
914
|
+
* with a `name` property in its options — this has no layout effect, but
|
|
915
|
+
* makes the function's sub-tree addressable here.
|
|
916
|
+
*
|
|
917
|
+
* With `mode: 'first'` (default), returns the elements inside the first
|
|
918
|
+
* matching function found by a depth-first traversal. With `mode: 'all'`,
|
|
919
|
+
* walks the entire tree, collects every matching function (including those
|
|
920
|
+
* nested inside other matches), and returns the de-duplicated union of
|
|
921
|
+
* their elements.
|
|
922
|
+
*
|
|
923
|
+
* Returns an empty array if the form does not exist, or no matching
|
|
924
|
+
* function is found.
|
|
925
|
+
*
|
|
926
|
+
* @param {string} formName
|
|
927
|
+
* @param {string} name
|
|
928
|
+
* @param {'first' | 'all'} [mode] (`'first'`)
|
|
929
|
+
* @param {boolean} [includeHidden] (`false`)
|
|
930
|
+
* @return {Array<FigureElement>}
|
|
931
|
+
*/
|
|
932
|
+
getElementsInForm(formName: string, name: string, mode?: 'first' | 'all', includeHidden?: boolean): any[];
|
|
909
933
|
/**
|
|
910
934
|
* Return all the elements that are used in an equation phrase.
|
|
911
935
|
* @param {TypeEquationPhrase} phrase
|
|
@@ -170,6 +170,9 @@ export type TypeEquationPhrase = string | number | {
|
|
|
170
170
|
* @property {boolean} [fullContentBounds] - (`false`)
|
|
171
171
|
* @property {boolean} [showContent] - if `false`, a container will be created
|
|
172
172
|
* around the content, but the content will not be shown (`true`)
|
|
173
|
+
* @property {string} [name] - optional identifier (available on every equation
|
|
174
|
+
* function). Has no effect on layout, but allows the function's contents to be
|
|
175
|
+
* looked up later with {@link Equation.getElementsInForm} (`null`)
|
|
173
176
|
*
|
|
174
177
|
* @see To test examples, append them to the
|
|
175
178
|
* <a href="#drawing-boilerplate">boilerplate</a>
|
|
@@ -236,6 +239,7 @@ export type EQN_Container = {
|
|
|
236
239
|
scale?: number;
|
|
237
240
|
fullContentBounds?: boolean;
|
|
238
241
|
showContent?: boolean;
|
|
242
|
+
name?: string;
|
|
239
243
|
} | [
|
|
240
244
|
TypeEquationPhrase,
|
|
241
245
|
(number | null | undefined),
|
|
@@ -288,6 +292,7 @@ export type EQN_Offset = {
|
|
|
288
292
|
offset?: TypeParsablePoint;
|
|
289
293
|
inSize?: boolean;
|
|
290
294
|
fullContentBounds?: boolean;
|
|
295
|
+
name?: string;
|
|
291
296
|
} | [
|
|
292
297
|
TypeEquationPhrase,
|
|
293
298
|
(TypeParsablePoint | null | undefined),
|
|
@@ -411,6 +416,7 @@ export type EQN_Fraction = {
|
|
|
411
416
|
offsetY?: number;
|
|
412
417
|
baseline?: 'numerator' | 'denominator' | 'vinculum';
|
|
413
418
|
fullContentBounds?: boolean;
|
|
419
|
+
name?: string;
|
|
414
420
|
} | [
|
|
415
421
|
TypeEquationPhrase,
|
|
416
422
|
string,
|
|
@@ -486,6 +492,7 @@ export type EQN_Scale = {
|
|
|
486
492
|
content: TypeEquationPhrase;
|
|
487
493
|
scale?: number;
|
|
488
494
|
fullContentBounds?: boolean;
|
|
495
|
+
name?: string;
|
|
489
496
|
} | [
|
|
490
497
|
TypeEquationPhrase,
|
|
491
498
|
(number | null | undefined),
|
|
@@ -564,6 +571,7 @@ export type EQN_Color = {
|
|
|
564
571
|
content: TypeEquationPhrase;
|
|
565
572
|
color: TypeColor;
|
|
566
573
|
fullContentBounds?: boolean;
|
|
574
|
+
name?: string;
|
|
567
575
|
} | [
|
|
568
576
|
TypeEquationPhrase,
|
|
569
577
|
TypeColor,
|
|
@@ -677,6 +685,7 @@ export type EQN_Bracket = {
|
|
|
677
685
|
descent?: number;
|
|
678
686
|
fullContentBounds?: boolean;
|
|
679
687
|
useFullBounds?: boolean;
|
|
688
|
+
name?: string;
|
|
680
689
|
} | [
|
|
681
690
|
string,
|
|
682
691
|
TypeEquationPhrase,
|
|
@@ -812,6 +821,7 @@ export type EQN_Root = {
|
|
|
812
821
|
rootScale?: number;
|
|
813
822
|
fullContentBounds?: boolean;
|
|
814
823
|
useFullBounds?: boolean;
|
|
824
|
+
name?: string;
|
|
815
825
|
} | [
|
|
816
826
|
string,
|
|
817
827
|
TypeEquationPhrase,
|
|
@@ -928,6 +938,7 @@ export type EQN_Strike = {
|
|
|
928
938
|
leftSpace?: number;
|
|
929
939
|
fullContentBounds?: boolean;
|
|
930
940
|
useFullBounds?: boolean;
|
|
941
|
+
name?: string;
|
|
931
942
|
} | [
|
|
932
943
|
TypeEquationPhrase,
|
|
933
944
|
string,
|
|
@@ -1045,6 +1056,7 @@ export type EQN_Box = {
|
|
|
1045
1056
|
leftSpace?: number;
|
|
1046
1057
|
fullContentBounds?: boolean;
|
|
1047
1058
|
useFullBounds?: boolean;
|
|
1059
|
+
name?: string;
|
|
1048
1060
|
} | [
|
|
1049
1061
|
TypeEquationPhrase,
|
|
1050
1062
|
string,
|
|
@@ -1092,6 +1104,7 @@ export type EQN_TouchBox = {
|
|
|
1092
1104
|
rightSpace?: number;
|
|
1093
1105
|
bottomSpace?: number;
|
|
1094
1106
|
leftSpace?: number;
|
|
1107
|
+
name?: string;
|
|
1095
1108
|
} | [
|
|
1096
1109
|
TypeEquationPhrase,
|
|
1097
1110
|
string,
|
|
@@ -1232,6 +1245,7 @@ export type EQN_Bar = {
|
|
|
1232
1245
|
descent?: number;
|
|
1233
1246
|
fullContentBounds?: boolean;
|
|
1234
1247
|
useFullBounds?: boolean;
|
|
1248
|
+
name?: string;
|
|
1235
1249
|
} | [
|
|
1236
1250
|
TypeEquationPhrase,
|
|
1237
1251
|
(string | null | undefined),
|
|
@@ -1403,6 +1417,7 @@ export type EQN_Integral = {
|
|
|
1403
1417
|
toYAlign?: 'bottom' | 'top' | 'middle' | 'baseline' | number;
|
|
1404
1418
|
fullBoundsContent?: boolean;
|
|
1405
1419
|
useFullBounds?: boolean;
|
|
1420
|
+
name?: string;
|
|
1406
1421
|
} | [
|
|
1407
1422
|
(string | null | undefined),
|
|
1408
1423
|
(TypeEquationPhrase | null | undefined),
|
|
@@ -1543,6 +1558,7 @@ export type EQN_SumOf = {
|
|
|
1543
1558
|
toOffset?: TypeParsablePoint;
|
|
1544
1559
|
fullBoundsContent?: boolean;
|
|
1545
1560
|
useFullBounds?: boolean;
|
|
1561
|
+
name?: string;
|
|
1546
1562
|
} | [
|
|
1547
1563
|
(string | null | undefined),
|
|
1548
1564
|
TypeEquationPhrase,
|
|
@@ -1675,6 +1691,7 @@ export type EQN_ProdOf = {
|
|
|
1675
1691
|
toOffset?: TypeParsablePoint;
|
|
1676
1692
|
fullBoundsContent?: boolean;
|
|
1677
1693
|
useFullBounds?: boolean;
|
|
1694
|
+
name?: string;
|
|
1678
1695
|
} | [
|
|
1679
1696
|
(string | null | undefined),
|
|
1680
1697
|
TypeEquationPhrase,
|
|
@@ -1764,6 +1781,7 @@ export type EQN_Subscript = {
|
|
|
1764
1781
|
scale?: number;
|
|
1765
1782
|
offset?: TypeParsablePoint;
|
|
1766
1783
|
inSize: boolean;
|
|
1784
|
+
name?: string;
|
|
1767
1785
|
} | [
|
|
1768
1786
|
TypeEquationPhrase,
|
|
1769
1787
|
TypeEquationPhrase,
|
|
@@ -1831,6 +1849,7 @@ export type EQN_Superscript = {
|
|
|
1831
1849
|
scale?: number;
|
|
1832
1850
|
offset?: TypeParsablePoint;
|
|
1833
1851
|
inSize: boolean;
|
|
1852
|
+
name?: string;
|
|
1834
1853
|
} | [
|
|
1835
1854
|
TypeEquationPhrase,
|
|
1836
1855
|
TypeEquationPhrase,
|
|
@@ -1900,6 +1919,7 @@ export type EQN_SuperscriptSubscript = {
|
|
|
1900
1919
|
superscriptOffset?: TypeParsablePoint;
|
|
1901
1920
|
subscriptOffset?: TypeParsablePoint;
|
|
1902
1921
|
inSize?: boolean;
|
|
1922
|
+
name?: string;
|
|
1903
1923
|
} | [
|
|
1904
1924
|
TypeEquationPhrase,
|
|
1905
1925
|
TypeEquationPhrase,
|
|
@@ -2012,6 +2032,7 @@ export type EQN_Comment = {
|
|
|
2012
2032
|
inSize?: boolean;
|
|
2013
2033
|
fullContentBounds?: boolean;
|
|
2014
2034
|
useFullBounds?: boolean;
|
|
2035
|
+
name?: string;
|
|
2015
2036
|
} | [
|
|
2016
2037
|
TypeEquationPhrase,
|
|
2017
2038
|
TypeEquationPhrase,
|
|
@@ -2108,6 +2129,7 @@ export type EQN_StrikeComment = {
|
|
|
2108
2129
|
space?: number;
|
|
2109
2130
|
scale?: number;
|
|
2110
2131
|
commentSpace?: number;
|
|
2132
|
+
name?: string;
|
|
2111
2133
|
} | [
|
|
2112
2134
|
(TypeEquationPhrase | null | undefined),
|
|
2113
2135
|
(string | null | undefined),
|
|
@@ -2184,6 +2206,7 @@ export type EQN_Pad = {
|
|
|
2184
2206
|
right?: number;
|
|
2185
2207
|
bottom?: number;
|
|
2186
2208
|
left?: number;
|
|
2209
|
+
name?: string;
|
|
2187
2210
|
} | [
|
|
2188
2211
|
TypeEquationPhrase,
|
|
2189
2212
|
(number | null | undefined),
|
|
@@ -2306,6 +2329,7 @@ export type EQN_Matrix = {
|
|
|
2306
2329
|
yAlign?: 'baseline' | 'middle';
|
|
2307
2330
|
brac?: EQN_Bracket;
|
|
2308
2331
|
fullContentBounds?: boolean;
|
|
2332
|
+
name?: string;
|
|
2309
2333
|
} | [
|
|
2310
2334
|
([number, number] | null | undefined),
|
|
2311
2335
|
(string | null | undefined),
|
|
@@ -2460,6 +2484,7 @@ export type EQN_Lines = {
|
|
|
2460
2484
|
space?: number;
|
|
2461
2485
|
yAlign?: 'bottom' | 'top' | 'middle' | number;
|
|
2462
2486
|
fullContentBounds?: boolean;
|
|
2487
|
+
name?: string;
|
|
2463
2488
|
};
|
|
2464
2489
|
/**
|
|
2465
2490
|
* Annotation options object.
|
|
@@ -3214,6 +3239,7 @@ export type EQN_Annotate = {
|
|
|
3214
3239
|
leftSpace?: number;
|
|
3215
3240
|
rightSpace?: number;
|
|
3216
3241
|
contentScale?: number;
|
|
3242
|
+
name?: string;
|
|
3217
3243
|
};
|
|
3218
3244
|
/**
|
|
3219
3245
|
* Equation Functions.
|
|
@@ -3247,6 +3273,7 @@ export declare class EquationFunctions {
|
|
|
3247
3273
|
parseContent(content: TypeEquationPhrase | null | undefined): any;
|
|
3248
3274
|
contentToElement(content: TypeEquationPhrase | Elements | FigureElementPrimitive | FigureElementCollection): Elements;
|
|
3249
3275
|
eqnMethod(name: string, params: any): BaseAnnotationFunction | Fraction | Matrix | Lines | Scale | Container | Offset | Color | null;
|
|
3276
|
+
dispatchEqnMethod(name: string, params: any): BaseAnnotationFunction | Fraction | Matrix | Lines | Scale | Container | Offset | Color | null;
|
|
3250
3277
|
/**
|
|
3251
3278
|
* Equation container function
|
|
3252
3279
|
* @see {@link EQN_Container} for description and examples
|