figureone 1.2.1 → 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/index.js CHANGED
@@ -11254,6 +11254,12 @@ var FigureElement = /*#__PURE__*/function () {
11254
11254
  // lastDrawElementTransformPosition: {parentCount: number, elementCount: number};
11255
11255
 
11256
11256
  // True if should be shown in figure
11257
+ // True if equation forms should not initiate any new state changes on this
11258
+ // element: it is excluded from form layout, show/hide, transform/color sets,
11259
+ // and elementMods. Note: form-driven animations on the equation collection
11260
+ // (collectionMethods.stop()) still cancel any in-flight animations on the
11261
+ // element — the contract is "no new form-driven changes", not full isolation.
11262
+
11257
11263
  // Used to reference element in a collection
11258
11264
 
11259
11265
  // Element is able to be moved
@@ -11371,6 +11377,7 @@ var FigureElement = /*#__PURE__*/function () {
11371
11377
  this.uid = (Math.random() * 1e18).toString(36);
11372
11378
  this.uniqueColor = null;
11373
11379
  this.isShown = true;
11380
+ this.isFormIgnored = false;
11374
11381
  this.simple = false;
11375
11382
  this.allowSetColor = 'all';
11376
11383
  this.transform = transform._dup();
@@ -11566,7 +11573,7 @@ var FigureElement = /*#__PURE__*/function () {
11566
11573
  return ['animations', 'color', 'opacity', 'dimColor', 'defaultColor', 'transform', '_custom', 'scene',
11567
11574
  // 'lastDrawTransform',
11568
11575
  // 'parentTransform',
11569
- 'isShown', 'isMovable', 'isTouchable', 'state', 'pulseSettings', 'setTransformCallback', 'move', 'notifications',
11576
+ 'isShown', 'isMovable', 'isTouchable', 'isFormIgnored', 'state', 'pulseSettings', 'setTransformCallback', 'move', 'notifications',
11570
11577
  // 'finishAnimationOnPause',
11571
11578
  'pulseTransforms', 'frozenPulseTransforms', 'customState'].concat(_toConsumableArray(this.stateProperties));
11572
11579
  }
@@ -17218,6 +17225,10 @@ function offsetLocationForGlyphs(glyphs, offset) {
17218
17225
  });
17219
17226
  }
17220
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
+
17221
17232
  function BaseAnnotationFunction(content, annotations, glyphs, options) {
17222
17233
  var showContent = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
17223
17234
  _classCallCheck(this, BaseAnnotationFunction);
@@ -17229,6 +17240,7 @@ var BaseAnnotationFunction = /*#__PURE__*/function () {
17229
17240
  this.showContent = showContent;
17230
17241
  this.scale = 1;
17231
17242
  this.color = null;
17243
+ this.functionName = null;
17232
17244
  }
17233
17245
  return _createClass(BaseAnnotationFunction, [{
17234
17246
  key: "_dup",
@@ -17863,6 +17875,10 @@ function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf
17863
17875
 
17864
17876
 
17865
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
+
17866
17882
  function BaseEquationFunction(content, glyph, options) {
17867
17883
  var _this;
17868
17884
  var showContent = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
@@ -17901,6 +17917,7 @@ var BaseEquationFunction = /*#__PURE__*/function (_Elements) {
17901
17917
  });
17902
17918
  _this.options = options;
17903
17919
  _this.showContent = showContent;
17920
+ _this.functionName = null;
17904
17921
  return _this;
17905
17922
  }
17906
17923
  _inherits(BaseEquationFunction, _Elements);
@@ -18467,20 +18484,31 @@ var Element = /*#__PURE__*/function () {
18467
18484
  if (content.measureAndAlignText != null) {
18468
18485
  content.measureAndAlignText();
18469
18486
  }
18470
- content.transform.updateTranslation([location.x, location.y]);
18471
- content.transform.updateScale([scale, scale]);
18472
- if (content.internalSetTransformCallback != null) {
18473
- this.fnMap.exec(content.internalSetTransformCallback, content.transform);
18474
- }
18487
+ if (content.isFormIgnored) {
18488
+ // Form-ignored elements contribute zero size to the layout so adjacent
18489
+ // elements aren't sized off whatever transform the user has applied.
18490
+ this.location = location._dup();
18491
+ this.scale = scale;
18492
+ this.ascent = 0;
18493
+ this.descent = 0;
18494
+ this.height = 0;
18495
+ this.width = 0;
18496
+ } else {
18497
+ content.transform.updateTranslation([location.x, location.y]);
18498
+ content.transform.updateScale([scale, scale]);
18499
+ if (content.internalSetTransformCallback != null) {
18500
+ this.fnMap.exec(content.internalSetTransformCallback, content.transform);
18501
+ }
18475
18502
 
18476
- // Get the boundaries of element
18477
- var r = content.getRelativeBoundingRect('draw', 'border', null, false);
18478
- this.location = location._dup();
18479
- this.scale = scale;
18480
- this.ascent = r.top * scale;
18481
- this.descent = -r.bottom * scale;
18482
- this.height = r.height * scale;
18483
- this.width = r.width * scale;
18503
+ // Get the boundaries of element
18504
+ var r = content.getRelativeBoundingRect('draw', 'border', null, false);
18505
+ this.location = location._dup();
18506
+ this.scale = scale;
18507
+ this.ascent = r.top * scale;
18508
+ this.descent = -r.bottom * scale;
18509
+ this.height = r.height * scale;
18510
+ this.width = r.width * scale;
18511
+ }
18484
18512
  }
18485
18513
  this.fullSize = {
18486
18514
  leftOffset: 0,
@@ -18528,6 +18556,9 @@ var Element = /*#__PURE__*/function () {
18528
18556
  value: function setPositions() {
18529
18557
  var content = this.content;
18530
18558
  if (content instanceof _Element__WEBPACK_IMPORTED_MODULE_3__.FigureElementCollection || content instanceof _Element__WEBPACK_IMPORTED_MODULE_3__.FigureElementPrimitive) {
18559
+ if (content.isFormIgnored) {
18560
+ return;
18561
+ }
18531
18562
  content.transform.updateTranslation([this.location.x, this.location.y]);
18532
18563
  content.transform.updateScale([this.scale, this.scale]);
18533
18564
  }
@@ -18544,6 +18575,9 @@ var Element = /*#__PURE__*/function () {
18544
18575
  }
18545
18576
  var content = this.content;
18546
18577
  if (content instanceof _Element__WEBPACK_IMPORTED_MODULE_3__.FigureElementCollection || content instanceof _Element__WEBPACK_IMPORTED_MODULE_3__.FigureElementPrimitive) {
18578
+ if (content.isFormIgnored) {
18579
+ return;
18580
+ }
18547
18581
  content.setColor(color);
18548
18582
  }
18549
18583
  }
@@ -19417,11 +19451,12 @@ __webpack_require__.r(__webpack_exports__);
19417
19451
  /* harmony import */ var _DrawingObjects_TextObject_TextObject__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../DrawingObjects/TextObject/TextObject */ "./src/js/figure/DrawingObjects/TextObject/TextObject.ts");
19418
19452
  /* harmony import */ var _Elements_Element__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Elements/Element */ "./src/js/figure/Equation/Elements/Element.ts");
19419
19453
  /* harmony import */ var _Elements_BaseAnnotationFunction__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Elements/BaseAnnotationFunction */ "./src/js/figure/Equation/Elements/BaseAnnotationFunction.ts");
19420
- /* harmony import */ var _EquationForm__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./EquationForm */ "./src/js/figure/Equation/EquationForm.ts");
19421
- /* harmony import */ var _tools_htmlGenerator__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../tools/htmlGenerator */ "./src/js/tools/htmlGenerator.ts");
19422
- /* harmony import */ var _EquationSymbols__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./EquationSymbols */ "./src/js/figure/Equation/EquationSymbols.ts");
19423
- /* harmony import */ var _EquationFunctions__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./EquationFunctions */ "./src/js/figure/Equation/EquationFunctions.ts");
19424
- /* harmony import */ var _Animation_Animation__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Animation/Animation */ "./src/js/figure/Animation/Animation.ts");
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");
19425
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); }
19426
19461
  function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
19427
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."); }
@@ -19456,6 +19491,7 @@ function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf
19456
19491
 
19457
19492
 
19458
19493
 
19494
+
19459
19495
  // import HTMLObject from '../DrawingObjects/HTMLObject/HTMLObject';
19460
19496
 
19461
19497
 
@@ -20154,7 +20190,7 @@ var NextFormAnimationStep = /*#__PURE__*/function (_TriggerAnimationStep) {
20154
20190
  }
20155
20191
  _inherits(NextFormAnimationStep, _TriggerAnimationStep);
20156
20192
  return _createClass(NextFormAnimationStep);
20157
- }(_Animation_Animation__WEBPACK_IMPORTED_MODULE_10__.TriggerAnimationStep);
20193
+ }(_Animation_Animation__WEBPACK_IMPORTED_MODULE_11__.TriggerAnimationStep);
20158
20194
  /**
20159
20195
  * GoToForm form animation step
20160
20196
  *
@@ -20205,7 +20241,7 @@ var GoToFormAnimationStep = /*#__PURE__*/function (_TriggerAnimationStep2) {
20205
20241
  }
20206
20242
  _inherits(GoToFormAnimationStep, _TriggerAnimationStep2);
20207
20243
  return _createClass(GoToFormAnimationStep);
20208
- }(_Animation_Animation__WEBPACK_IMPORTED_MODULE_10__.TriggerAnimationStep); // export const foo = () => {};
20244
+ }(_Animation_Animation__WEBPACK_IMPORTED_MODULE_11__.TriggerAnimationStep); // export const foo = () => {};
20209
20245
  // An Equation is a collection of elements that can be arranged into different
20210
20246
  // forms.
20211
20247
  // Equation allows setting of forms, and navigating through form series
@@ -20406,8 +20442,8 @@ var Equation = /*#__PURE__*/function (_FigureElementCollect) {
20406
20442
  layout: optionsToUse.formDefaults.layout,
20407
20443
  ignoreColor: optionsToUse.formDefaults.ignoreColor
20408
20444
  },
20409
- functions: new _EquationFunctions__WEBPACK_IMPORTED_MODULE_9__.EquationFunctions(_this.elements, _this.addElementFromKey.bind(_this), _this.getExistingOrAddSymbol.bind(_this), _this.makeInlineElement.bind(_this)),
20410
- symbols: new _EquationSymbols__WEBPACK_IMPORTED_MODULE_8__["default"](_this.shapes, _this.color),
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),
20411
20447
  font: optionsToUse.font,
20412
20448
  textFont: optionsToUse.textFont,
20413
20449
  // fontText: optionsToUse.fontText,
@@ -20507,7 +20543,7 @@ var Equation = /*#__PURE__*/function (_FigureElementCollect) {
20507
20543
  o.delay = 0;
20508
20544
  o.setToEnd = '_showForm';
20509
20545
  o.timeKeeper = _this.timeKeeper;
20510
- return new _Animation_Animation__WEBPACK_IMPORTED_MODULE_10__.TriggerAnimationStep(o);
20546
+ return new _Animation_Animation__WEBPACK_IMPORTED_MODULE_11__.TriggerAnimationStep(o);
20511
20547
  };
20512
20548
  _this.animations.customSteps.push({
20513
20549
  step: _this.animations.goToForm.bind(_this),
@@ -20553,7 +20589,7 @@ var Equation = /*#__PURE__*/function (_FigureElementCollect) {
20553
20589
  o.delay = 0;
20554
20590
  o.setToEnd = '_showForm';
20555
20591
  o.timeKeeper = _this.timeKeeper;
20556
- return new _Animation_Animation__WEBPACK_IMPORTED_MODULE_10__.TriggerAnimationStep(o);
20592
+ return new _Animation_Animation__WEBPACK_IMPORTED_MODULE_11__.TriggerAnimationStep(o);
20557
20593
  };
20558
20594
  _this.animations.customSteps.push({
20559
20595
  step: _this.animations.nextForm.bind(_this),
@@ -21197,7 +21233,7 @@ var Equation = /*#__PURE__*/function (_FigureElementCollect) {
21197
21233
  key: "checkFixTo",
21198
21234
  value: function checkFixTo(fixTo, formElements) {
21199
21235
  if (typeof fixTo === 'string') {
21200
- var element = (0,_EquationFunctions__WEBPACK_IMPORTED_MODULE_9__.getFigureElement)(this, fixTo);
21236
+ var element = (0,_EquationFunctions__WEBPACK_IMPORTED_MODULE_10__.getFigureElement)(this, fixTo);
21201
21237
  if (element != null && formElements.indexOf(element) >= 0) {
21202
21238
  return element;
21203
21239
  }
@@ -21215,7 +21251,7 @@ var Equation = /*#__PURE__*/function (_FigureElementCollect) {
21215
21251
  key: "createForm",
21216
21252
  value: function createForm() {
21217
21253
  var elements = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.elements;
21218
- return new _EquationForm__WEBPACK_IMPORTED_MODULE_6__["default"](elements, {
21254
+ return new _EquationForm__WEBPACK_IMPORTED_MODULE_7__["default"](elements, {
21219
21255
  getAllElements: this.getChildren.bind(this),
21220
21256
  hideAll: this.hideAll.bind(this),
21221
21257
  show: this.show.bind(this),
@@ -21245,6 +21281,87 @@ var Equation = /*#__PURE__*/function (_FigureElementCollect) {
21245
21281
  return this.eqn.forms[form].content[0].getAllElements(includeHidden);
21246
21282
  }
21247
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
+
21248
21365
  /**
21249
21366
  * Return all the elements that are used in an equation phrase.
21250
21367
  * @param {TypeEquationPhrase} phrase
@@ -21379,7 +21496,7 @@ var Equation = /*#__PURE__*/function (_FigureElementCollect) {
21379
21496
  var newMods = {};
21380
21497
  Object.keys(elementMods).forEach(function (elementName) {
21381
21498
  var mods = elementMods[elementName];
21382
- var figureElement = (0,_EquationFunctions__WEBPACK_IMPORTED_MODULE_9__.getFigureElement)(_this9, elementName);
21499
+ var figureElement = (0,_EquationFunctions__WEBPACK_IMPORTED_MODULE_10__.getFigureElement)(_this9, elementName);
21383
21500
  if (figureElement != null) {
21384
21501
  newMods[elementName] = {
21385
21502
  element: figureElement,
@@ -21392,7 +21509,7 @@ var Equation = /*#__PURE__*/function (_FigureElementCollect) {
21392
21509
  var transformTranslation = function transformTranslation(trans) {
21393
21510
  var newTranslation = {};
21394
21511
  Object.keys(trans).forEach(function (elementName) {
21395
- var figureElement = (0,_EquationFunctions__WEBPACK_IMPORTED_MODULE_9__.getFigureElement)(_this9, elementName);
21512
+ var figureElement = (0,_EquationFunctions__WEBPACK_IMPORTED_MODULE_10__.getFigureElement)(_this9, elementName);
21396
21513
  var mods = trans[elementName];
21397
21514
  var direction;
21398
21515
  var style;
@@ -21570,7 +21687,7 @@ var Equation = /*#__PURE__*/function (_FigureElementCollect) {
21570
21687
  value: function getForm(formOrName
21571
21688
  // subForm: ?string,
21572
21689
  ) {
21573
- if (formOrName instanceof _EquationForm__WEBPACK_IMPORTED_MODULE_6__["default"]) {
21690
+ if (formOrName instanceof _EquationForm__WEBPACK_IMPORTED_MODULE_7__["default"]) {
21574
21691
  return formOrName;
21575
21692
  }
21576
21693
  if (formOrName in this.eqn.forms) {
@@ -21914,7 +22031,7 @@ var Equation = /*#__PURE__*/function (_FigureElementCollect) {
21914
22031
  ) {
21915
22032
  var form = this.getForm(formOrName);
21916
22033
  if (form != null && form.description != null) {
21917
- return _tools_htmlGenerator__WEBPACK_IMPORTED_MODULE_7__.applyModifiers(form.description, form.modifiers);
22034
+ return _tools_htmlGenerator__WEBPACK_IMPORTED_MODULE_8__.applyModifiers(form.description, form.modifiers);
21918
22035
  }
21919
22036
  return '';
21920
22037
  }
@@ -22312,9 +22429,11 @@ var EquationForm = /*#__PURE__*/function (_Elements) {
22312
22429
  value: function getElementsToShowAndHide() {
22313
22430
  var allElements = this.collectionMethods.getAllElements();
22314
22431
  var elementsShown = allElements.filter(function (e) {
22315
- return e.isShown;
22432
+ return e.isShown && !e.isFormIgnored;
22433
+ });
22434
+ var elementsShownTarget = this.getAllElements(false).filter(function (e) {
22435
+ return !e.isFormIgnored;
22316
22436
  });
22317
- var elementsShownTarget = this.getAllElements(false);
22318
22437
  var elementsToHide = elementsShown.filter(function (e) {
22319
22438
  return elementsShownTarget.indexOf(e) === -1;
22320
22439
  });
@@ -22405,9 +22524,11 @@ var EquationForm = /*#__PURE__*/function (_Elements) {
22405
22524
  this.collectionMethods.stop();
22406
22525
  var allElements = this.collectionMethods.getAllElements();
22407
22526
  var elementsShown = allElements.filter(function (e) {
22408
- return e.isShown;
22527
+ return e.isShown && !e.isFormIgnored;
22528
+ });
22529
+ var elementsToShow = this.getAllElements(false).filter(function (e) {
22530
+ return !e.isFormIgnored;
22409
22531
  });
22410
- var elementsToShow = this.getAllElements(false);
22411
22532
  var elementsToDelayShowing = elementsToShow.filter(function (e) {
22412
22533
  return !e.isShown;
22413
22534
  });
@@ -22473,6 +22594,9 @@ var EquationForm = /*#__PURE__*/function (_Elements) {
22473
22594
  var _elementMods$elementN = elementMods[elementName],
22474
22595
  element = _elementMods$elementN.element,
22475
22596
  mods = _elementMods$elementN.mods;
22597
+ if (element != null && element.isFormIgnored) {
22598
+ return;
22599
+ }
22476
22600
  if (element != null && mods != null) {
22477
22601
  element.setProperties(mods);
22478
22602
  if (mods.color != null) {
@@ -22499,7 +22623,9 @@ var EquationForm = /*#__PURE__*/function (_Elements) {
22499
22623
  var dissolveInBeforeMove = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
22500
22624
  var allElements = this.collectionMethods.getAllElements();
22501
22625
  this.collectionMethods.stop();
22502
- var elementsShownTarget = this.getAllElements(false);
22626
+ var elementsShownTarget = this.getAllElements(false).filter(function (e) {
22627
+ return !e.isFormIgnored;
22628
+ });
22503
22629
  elementsShownTarget.forEach(function (e) {
22504
22630
  if (e.opacity === 0.001) {
22505
22631
  e.hide();
@@ -22509,7 +22635,7 @@ var EquationForm = /*#__PURE__*/function (_Elements) {
22509
22635
  }
22510
22636
  });
22511
22637
  var elementsShown = allElements.filter(function (e) {
22512
- return e.isShown;
22638
+ return e.isShown && !e.isFormIgnored;
22513
22639
  });
22514
22640
  var elementsToHide = elementsShown.filter(function (e) {
22515
22641
  return elementsShownTarget.indexOf(e) === -1;
@@ -22708,9 +22834,10 @@ __webpack_require__.r(__webpack_exports__);
22708
22834
  /* harmony import */ var _Elements_Scale__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Elements/Scale */ "./src/js/figure/Equation/Elements/Scale.ts");
22709
22835
  /* harmony import */ var _Elements_Container__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Elements/Container */ "./src/js/figure/Equation/Elements/Container.ts");
22710
22836
  /* harmony import */ var _Elements_BaseAnnotationFunction__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Elements/BaseAnnotationFunction */ "./src/js/figure/Equation/Elements/BaseAnnotationFunction.ts");
22711
- /* harmony import */ var _Symbols_Line__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Symbols/Line */ "./src/js/figure/Equation/Symbols/Line.ts");
22712
- /* harmony import */ var _Elements_Offset__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./Elements/Offset */ "./src/js/figure/Equation/Elements/Offset.ts");
22713
- /* harmony import */ var _Elements_Color__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Elements/Color */ "./src/js/figure/Equation/Elements/Color.ts");
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");
22714
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); }
22715
22842
  function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
22716
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."); }
@@ -22740,6 +22867,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
22740
22867
 
22741
22868
 
22742
22869
 
22870
+
22743
22871
  // import type {
22744
22872
  // EQN_Annotation, EQN_EncompassGlyph, EQN_LeftRightGlyph, EQN_TopBottomGlyph,
22745
22873
  // } from './Elements/BaseAnnotationFunction';
@@ -22860,6 +22988,9 @@ function getFigureElement(elementsObject, name) {
22860
22988
  * @property {boolean} [fullContentBounds] - (`false`)
22861
22989
  * @property {boolean} [showContent] - if `false`, a container will be created
22862
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`)
22863
22994
  *
22864
22995
  * @see To test examples, append them to the
22865
22996
  * <a href="#drawing-boilerplate">boilerplate</a>
@@ -25496,6 +25627,18 @@ var EquationFunctions = /*#__PURE__*/function () {
25496
25627
  }, {
25497
25628
  key: "eqnMethod",
25498
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) {
25499
25642
  if (name === 'frac') {
25500
25643
  return this.frac(params);
25501
25644
  }
@@ -25690,7 +25833,7 @@ var EquationFunctions = /*#__PURE__*/function () {
25690
25833
  fullContentBounds: fullContentBounds
25691
25834
  };
25692
25835
  var o = (0,_tools_tools__WEBPACK_IMPORTED_MODULE_1__.joinObjects)(defaultOptions, optionsIn);
25693
- return new _Elements_Offset__WEBPACK_IMPORTED_MODULE_11__["default"]([this.contentToElement(content)], [], o);
25836
+ return new _Elements_Offset__WEBPACK_IMPORTED_MODULE_12__["default"]([this.contentToElement(content)], [], o);
25694
25837
  } catch (e) {
25695
25838
  throw new Error("FigureOne Equation Offset Error: ".concat(e.message));
25696
25839
  }
@@ -26196,7 +26339,7 @@ var EquationFunctions = /*#__PURE__*/function () {
26196
26339
  fullContentBounds: fullContentBounds
26197
26340
  };
26198
26341
  var o = (0,_tools_tools__WEBPACK_IMPORTED_MODULE_1__.joinObjects)(defaultOptions, optionsIn);
26199
- return new _Elements_Color__WEBPACK_IMPORTED_MODULE_12__["default"]([this.contentToElement(content)], [], o);
26342
+ return new _Elements_Color__WEBPACK_IMPORTED_MODULE_13__["default"]([this.contentToElement(content)], [], o);
26200
26343
  } catch (e) {
26201
26344
  throw new Error("FigureOne Equation Color Error: ".concat(e.message));
26202
26345
  }
@@ -27429,7 +27572,7 @@ var EquationFunctions = /*#__PURE__*/function () {
27429
27572
  });
27430
27573
  }
27431
27574
  var glyph = this.getExistingOrAddSymbol(symbol);
27432
- if (glyph instanceof _Symbols_Line__WEBPACK_IMPORTED_MODULE_10__["default"]) {
27575
+ if (glyph instanceof _Symbols_Line__WEBPACK_IMPORTED_MODULE_11__["default"]) {
27433
27576
  annotations[0].offset = [0, commentSpaceToUse + contentSpaceToUse];
27434
27577
  return this.annotate({
27435
27578
  content: content,
@@ -27512,7 +27655,7 @@ var EquationFunctions = /*#__PURE__*/function () {
27512
27655
  });
27513
27656
  }
27514
27657
  var glyph = this.getExistingOrAddSymbol(symbol);
27515
- if (glyph instanceof _Symbols_Line__WEBPACK_IMPORTED_MODULE_10__["default"]) {
27658
+ if (glyph instanceof _Symbols_Line__WEBPACK_IMPORTED_MODULE_11__["default"]) {
27516
27659
  annotations[0].offset = [0, -commentSpaceToUse - contentSpaceToUse];
27517
27660
  return this.annotate({
27518
27661
  content: content,
@@ -80649,8 +80792,8 @@ var tools = {
80649
80792
  */
80650
80793
 
80651
80794
  var Fig = {
80652
- version: "1.2.1",
80653
- gitHash: "40843fa58",
80795
+ version: "1.4.0",
80796
+ gitHash: "77f124c53",
80654
80797
  tools: tools,
80655
80798
  Figure: _js_figure_Figure__WEBPACK_IMPORTED_MODULE_5__["default"],
80656
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.2.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",
@@ -414,6 +414,7 @@ declare class FigureElement {
414
414
  lastDrawOpacity: number;
415
415
  parent: FigureElement | null;
416
416
  isShown: boolean;
417
+ isFormIgnored: boolean;
417
418
  name: string;
418
419
  isMovable: boolean;
419
420
  isTouchable: boolean;
@@ -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