@khanacademy/perseus-editor 4.1.6 → 4.1.8

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/dist/index.js CHANGED
@@ -64,7 +64,7 @@ var i18n__namespace = /*#__PURE__*/_interopNamespace(i18n$1);
64
64
 
65
65
  // This file is processed by a Rollup plugin (replace) to inject the production
66
66
  const libName = "@khanacademy/perseus-editor";
67
- const libVersion = "4.1.6";
67
+ const libVersion = "4.1.8";
68
68
  perseusCore.addLibraryVersionToPerseusDebug(libName, libVersion);
69
69
 
70
70
  function _extends() {
@@ -20614,6 +20614,7 @@ class WidgetEditor extends React__namespace.Component {
20614
20614
  showWidget: false,
20615
20615
  widgetInfo: _upgradeWidgetInfo(props)
20616
20616
  };
20617
+ this.widget = /*#__PURE__*/React__namespace.createRef();
20617
20618
  }
20618
20619
 
20619
20620
  // eslint-disable-next-line react/no-unsafe
@@ -20629,11 +20630,14 @@ class WidgetEditor extends React__namespace.Component {
20629
20630
  });
20630
20631
  };
20631
20632
  _handleWidgetChange = (newProps, cb, silent) => {
20632
- const newWidgetInfo = Object.assign({}, this.state.widgetInfo);
20633
- newWidgetInfo.options = Object.assign(
20634
- // eslint-disable-next-line react/no-string-refs
20635
- // @ts-expect-error - TS2339 - Property 'serialize' does not exist on type 'ReactInstance'.
20636
- this.refs.widget.serialize(), newProps);
20633
+ const newWidgetInfo = {
20634
+ ...this.state.widgetInfo,
20635
+ options: {
20636
+ ...this.state.widgetInfo.options,
20637
+ ...(this.widget.current?.serialize() ?? {}),
20638
+ ...newProps
20639
+ }
20640
+ };
20637
20641
  this.props.onChange(newWidgetInfo, cb, silent);
20638
20642
  };
20639
20643
  _toggleStatic = e => {
@@ -20650,9 +20654,7 @@ class WidgetEditor extends React__namespace.Component {
20650
20654
  this.props.onChange(newWidgetInfo);
20651
20655
  };
20652
20656
  getSaveWarnings = () => {
20653
- // eslint-disable-next-line react/no-string-refs
20654
- // @ts-expect-error - TS2339 - Property 'getSaveWarnings' does not exist on type 'ReactInstance'.
20655
- const issuesFunc = this.refs.widget.getSaveWarnings;
20657
+ const issuesFunc = this.widget.current?.getSaveWarnings;
20656
20658
  return issuesFunc ? issuesFunc() : [];
20657
20659
  };
20658
20660
  serialize = () => {
@@ -20667,7 +20669,7 @@ class WidgetEditor extends React__namespace.Component {
20667
20669
  graded: widgetInfo.graded,
20668
20670
  // eslint-disable-next-line react/no-string-refs
20669
20671
  // @ts-expect-error - TS2339 - Property 'serialize' does not exist on type 'ReactInstance'.
20670
- options: this.refs.widget.serialize(),
20672
+ options: this.widget.current.serialize(),
20671
20673
  version: widgetInfo.version
20672
20674
  };
20673
20675
  };
@@ -20711,10 +20713,8 @@ class WidgetEditor extends React__namespace.Component {
20711
20713
  title: "Remove image widget"
20712
20714
  })), /*#__PURE__*/React__namespace.createElement("div", {
20713
20715
  className: "perseus-widget-editor-content " + (this.state.showWidget ? "enter" : "leave")
20714
- }, Ed && /*#__PURE__*/React__namespace.createElement(Ed
20715
- // eslint-disable-next-line react/no-string-refs
20716
- , _extends({
20717
- ref: "widget",
20716
+ }, Ed && /*#__PURE__*/React__namespace.createElement(Ed, _extends({
20717
+ ref: this.widget,
20718
20718
  onChange: this._handleWidgetChange,
20719
20719
  static: widgetInfo.static,
20720
20720
  apiOptions: this.props.apiOptions
@@ -24343,366 +24343,222 @@ var i18n = {
24343
24343
  findImagesInItemData: findImagesInItemData
24344
24344
  };
24345
24345
 
24346
- var hubble = {exports: {}};
24346
+ var isObject = function (obj) {
24347
+ return obj === Object(obj);
24348
+ };
24349
+ var merge = function () {
24350
+ var obj = {};
24351
+ for (var i = 0; i < arguments.length; i++) {
24352
+ var source = arguments[i];
24353
+ if (source) {
24354
+ for (var prop in source) {
24355
+ obj[prop] = source[prop];
24356
+ }
24357
+ }
24358
+ }
24359
+ return obj;
24360
+ };
24361
+ var clone = function (obj) {
24362
+ if (!isObject(obj)) {
24363
+ return obj;
24364
+ }
24365
+ return Array.isArray(obj) ? obj.slice() : merge(obj);
24366
+ };
24347
24367
 
24348
- (function (module, exports) {
24349
- (function webpackUniversalModuleDefinition(root, factory) {
24350
- module.exports = factory();
24351
- })(commonjsGlobal, function () {
24352
- return (/******/function (modules) {
24353
- // webpackBootstrap
24354
- /******/ // The module cache
24355
- /******/
24356
- var installedModules = {};
24357
- /******/
24358
- /******/ // The require function
24359
- /******/
24360
- function __webpack_require__(moduleId) {
24361
- /******/
24362
- /******/ // Check if module is in cache
24363
- /******/if (installedModules[moduleId]) {
24364
- /******/return installedModules[moduleId].exports;
24365
- /******/
24366
- }
24367
- /******/ // Create a new module (and put it into the cache)
24368
- /******/
24369
- var module = installedModules[moduleId] = {
24370
- /******/i: moduleId,
24371
- /******/l: false,
24372
- /******/exports: {}
24373
- /******/
24374
- };
24375
- /******/
24376
- /******/ // Execute the module function
24377
- /******/
24378
- modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
24379
- /******/
24380
- /******/ // Flag the module as loaded
24381
- /******/
24382
- module.l = true;
24383
- /******/
24384
- /******/ // Return the exports of the module
24385
- /******/
24386
- return module.exports;
24387
- /******/
24388
- }
24389
- /******/
24390
- /******/
24391
- /******/ // expose the modules object (__webpack_modules__)
24392
- /******/
24393
- __webpack_require__.m = modules;
24394
- /******/
24395
- /******/ // expose the module cache
24396
- /******/
24397
- __webpack_require__.c = installedModules;
24398
- /******/
24399
- /******/ // define getter function for harmony exports
24400
- /******/
24401
- __webpack_require__.d = function (exports, name, getter) {
24402
- /******/if (!__webpack_require__.o(exports, name)) {
24403
- /******/Object.defineProperty(exports, name, {
24404
- /******/configurable: false,
24405
- /******/enumerable: true,
24406
- /******/get: getter
24407
- /******/
24408
- });
24409
- /******/
24410
- }
24411
- /******/
24412
- };
24413
- /******/
24414
- /******/ // getDefaultExport function for compatibility with non-harmony modules
24415
- /******/
24416
- __webpack_require__.n = function (module) {
24417
- /******/var getter = module && module.__esModule ? /******/function getDefault() {
24418
- return module['default'];
24419
- } : /******/function getModuleExports() {
24420
- return module;
24421
- };
24422
- /******/
24423
- __webpack_require__.d(getter, 'a', getter);
24424
- /******/
24425
- return getter;
24426
- /******/
24427
- };
24428
- /******/
24429
- /******/ // Object.prototype.hasOwnProperty.call
24430
- /******/
24431
- __webpack_require__.o = function (object, property) {
24432
- return Object.prototype.hasOwnProperty.call(object, property);
24433
- };
24434
- /******/
24435
- /******/ // __webpack_public_path__
24436
- /******/
24437
- __webpack_require__.p = "";
24438
- /******/
24439
- /******/ // Load entry module and return exports
24440
- /******/
24441
- return __webpack_require__(__webpack_require__.s = 1);
24442
- /******/
24443
- }
24444
- /************************************************************************/
24445
- /******/([/* 0 */
24446
- /***/function (module, exports) {
24447
- var isObject = function (obj) {
24448
- return obj === Object(obj);
24449
- };
24450
- var merge = function () {
24451
- var obj = {};
24452
- for (var i = 0; i < arguments.length; i++) {
24453
- var source = arguments[i];
24454
- if (source) {
24455
- for (var prop in source) {
24456
- obj[prop] = source[prop];
24457
- }
24458
- }
24459
- }
24460
- return obj;
24461
- };
24462
- var clone = function (obj) {
24463
- if (!isObject(obj)) {
24464
- return obj;
24465
- }
24466
- return Array.isArray(obj) ? obj.slice() : merge(obj);
24467
- };
24468
- module.exports = {
24469
- isObject: isObject,
24470
- merge: merge,
24471
- clone: clone
24472
- };
24368
+ /* TODO batch *all* mutations
24369
+ * idea: freeze / thaw implementations for all types
24370
+ * lens constructor thaws, freeze delegates to type's freeze
24371
+ */
24473
24372
 
24474
- /***/
24475
- }, /* 1 */
24476
- /***/function (module, exports, __webpack_require__) {
24477
- /* TODO batch *all* mutations
24478
- * idea: freeze / thaw implementations for all types
24479
- * lens constructor thaws, freeze delegates to type's freeze
24480
- */
24481
-
24482
- var util = __webpack_require__(0);
24483
- var clone = util.clone;
24484
- var isObject = util.isObject;
24485
- var merge = util.merge;
24486
- var arr = __webpack_require__(2);
24487
- var obj = __webpack_require__(3);
24488
- var str = __webpack_require__(4);
24489
-
24490
- // equivalents, without requiring it
24491
- // find the implementation to use for a given object
24492
- var dispatch = function (x) {
24493
- if (Array.isArray(x)) {
24494
- return arr;
24495
- } else if (isObject(x)) {
24496
- return obj;
24497
- } else if (typeof x === "string") {
24498
- return str;
24499
- }
24500
- };
24373
+ // equivalents, without requiring it
24374
+ // find the implementation to use for a given object
24375
+ var dispatch = function (x) {
24376
+ if (Array.isArray(x)) {
24377
+ return arr;
24378
+ } else if (isObject(x)) {
24379
+ return obj;
24380
+ } else if (typeof x === "string") {
24381
+ return str;
24382
+ }
24383
+ };
24501
24384
 
24502
- // This is underscore with a different name
24503
- var lens = function (obj) {
24504
- if (obj instanceof lens) {
24505
- return obj;
24506
- }
24507
- if (!(this instanceof lens)) {
24508
- return new lens(obj);
24509
- }
24510
- var ops = dispatch(obj);
24511
- this._wrapped = ops.thaw ? ops.thaw(obj) : obj;
24512
- };
24513
- lens.prototype.freeze = function () {
24514
- var obj = this._wrapped;
24515
- var ops = dispatch(obj);
24516
- return ops.freeze ? ops.freeze(obj) : obj;
24517
- };
24518
- lens.prototype.zoom = function (lensArr) {
24519
- if (this._zoomStack === undefined) {
24520
- this._zoomStack = [];
24521
- }
24522
- this._zoomStack.push({
24523
- zoom: lensArr,
24524
- wrapped: this._wrapped
24525
- });
24526
- this._wrapped = lens(this._wrapped).get(lensArr);
24527
- return this;
24528
- };
24529
- lens.prototype.deZoom = function () {
24530
- var frame = this._zoomStack.pop();
24531
- this._wrapped = lens(frame.wrapped).set(frame.zoom, this._wrapped).freeze();
24532
- return this;
24533
- };
24534
- lens.prototype.get = function (lensArr) {
24535
- var obj = this._wrapped;
24536
- for (var i = 0; i < lensArr.length; i++) {
24537
- obj = dispatch(obj).get(obj, lensArr[i]);
24538
- }
24539
- return obj;
24540
- };
24541
- lens.prototype.mod = function (lensArr, f) {
24542
- var obj = this._wrapped;
24543
- var newObj = clone(obj);
24544
- var ops = dispatch(obj);
24545
- if (lensArr.length === 0) {
24546
- this._wrapped = f(this._wrapped);
24547
- } else if (lensArr.length === 1) {
24548
- this._wrapped = ops.mod(newObj, lensArr[0], f);
24549
- } else {
24550
- var monocle = lensArr[0];
24551
- var shortLens = lensArr.slice(1);
24385
+ // This is underscore with a different name
24386
+ var lens = function (obj) {
24387
+ if (obj instanceof lens) {
24388
+ return obj;
24389
+ }
24390
+ if (!(this instanceof lens)) {
24391
+ return new lens(obj);
24392
+ }
24393
+ var ops = dispatch(obj);
24394
+ this._wrapped = ops.thaw ? ops.thaw(obj) : obj;
24395
+ };
24396
+ lens.prototype.freeze = function () {
24397
+ var obj = this._wrapped;
24398
+ var ops = dispatch(obj);
24399
+ return ops.freeze ? ops.freeze(obj) : obj;
24400
+ };
24401
+ lens.prototype.zoom = function (lensArr) {
24402
+ if (this._zoomStack === undefined) {
24403
+ this._zoomStack = [];
24404
+ }
24405
+ this._zoomStack.push({
24406
+ zoom: lensArr,
24407
+ wrapped: this._wrapped
24408
+ });
24409
+ this._wrapped = lens(this._wrapped).get(lensArr);
24410
+ return this;
24411
+ };
24412
+ lens.prototype.deZoom = function () {
24413
+ var frame = this._zoomStack.pop();
24414
+ this._wrapped = lens(frame.wrapped).set(frame.zoom, this._wrapped).freeze();
24415
+ return this;
24416
+ };
24417
+ lens.prototype.get = function (lensArr) {
24418
+ var obj = this._wrapped;
24419
+ for (var i = 0; i < lensArr.length; i++) {
24420
+ obj = dispatch(obj).get(obj, lensArr[i]);
24421
+ }
24422
+ return obj;
24423
+ };
24424
+ lens.prototype.mod = function (lensArr, f) {
24425
+ var obj = this._wrapped;
24426
+ var newObj = clone(obj);
24427
+ var ops = dispatch(obj);
24428
+ if (lensArr.length === 0) {
24429
+ this._wrapped = f(this._wrapped);
24430
+ } else if (lensArr.length === 1) {
24431
+ this._wrapped = ops.mod(newObj, lensArr[0], f);
24432
+ } else {
24433
+ var monocle = lensArr[0];
24434
+ var shortLens = lensArr.slice(1);
24552
24435
 
24553
- // newObj = ops.mod(obj[monocle], shortLens, f);
24436
+ // newObj = ops.mod(obj[monocle], shortLens, f);
24554
24437
 
24555
- newObj[monocle] = lens(obj[monocle]).mod(shortLens, f).freeze();
24556
- this._wrapped = newObj;
24557
- }
24558
- return this;
24559
- };
24438
+ newObj[monocle] = lens(obj[monocle]).mod(shortLens, f).freeze();
24439
+ this._wrapped = newObj;
24440
+ }
24441
+ return this;
24442
+ };
24560
24443
 
24561
- // TODO - move to individual files
24562
- lens.prototype.merge = function (lensArr, props) {
24563
- this._wrapped = lens(this._wrapped).mod(lensArr, function (oldProps) {
24564
- return merge(oldProps, props);
24565
- }).freeze();
24566
- return this;
24567
- };
24444
+ // TODO - move to individual files
24445
+ lens.prototype.merge = function (lensArr, props) {
24446
+ this._wrapped = lens(this._wrapped).mod(lensArr, function (oldProps) {
24447
+ return merge(oldProps, props);
24448
+ }).freeze();
24449
+ return this;
24450
+ };
24568
24451
 
24569
- // Lens must have length >= 1 or there would be nothing to return
24570
- lens.prototype.del = function (lensArr) {
24571
- var obj = this._wrapped;
24572
- var ops = dispatch(obj);
24573
- if (lensArr.length === 1) {
24574
- this._wrapped = ops.del(obj, lensArr[0]);
24575
- } else {
24576
- var monocle = lensArr[0];
24577
- var shortLens = lensArr.slice(1);
24578
- var newObj = clone(obj);
24579
- newObj[monocle] = lens(obj[monocle]).del(shortLens).freeze();
24580
- this._wrapped = newObj;
24581
- }
24582
- return this;
24583
- };
24584
- lens.prototype.set = function (lensArr, set) {
24585
- return this.mod(lensArr, function () {
24586
- return set;
24587
- });
24588
- };
24589
- module.exports = lens;
24452
+ // Lens must have length >= 1 or there would be nothing to return
24453
+ lens.prototype.del = function (lensArr) {
24454
+ var obj = this._wrapped;
24455
+ var ops = dispatch(obj);
24456
+ if (lensArr.length === 1) {
24457
+ this._wrapped = ops.del(obj, lensArr[0]);
24458
+ } else {
24459
+ var monocle = lensArr[0];
24460
+ var shortLens = lensArr.slice(1);
24461
+ var newObj = clone(obj);
24462
+ newObj[monocle] = lens(obj[monocle]).del(shortLens).freeze();
24463
+ this._wrapped = newObj;
24464
+ }
24465
+ return this;
24466
+ };
24467
+ lens.prototype.set = function (lensArr, set) {
24468
+ return this.mod(lensArr, function () {
24469
+ return set;
24470
+ });
24471
+ };
24590
24472
 
24591
- /***/
24592
- }, /* 2 */
24593
- /***/function (module, exports) {
24594
- var get = function (arr, monocle) {
24595
- return arr[monocle];
24596
- };
24597
- var set = function (arr, monocle, val) {
24598
- var newArr = arr.splice();
24599
- newArr[monocle] = val;
24600
- return newArr;
24601
- };
24602
- var mod = function (arr, monocle, f) {
24603
- var newArr = arr.slice();
24604
- newArr[monocle] = f(arr[monocle]);
24605
- return newArr;
24606
- };
24607
- var del = function (arr, monocle) {
24608
- var newArr = arr.slice();
24609
- newArr.splice(monocle, 1);
24610
- return newArr;
24611
- };
24473
+ // ARRAY FUNCTIONS
24612
24474
 
24613
- /*
24614
- // Lens must point to a member of an array. We'll insert into that array.
24615
- lens.prototype.insertAt = function(lensArr, toInsert) {
24616
- var obj = this._wrapped;
24617
-
24618
- var arrLens = lensArr.slice(0, -1);
24619
- var arr = lens(obj).get(arrLens).slice(); // slice to copy
24620
-
24621
- var arrIdx = lensArr[lensArr.length-1];
24622
- arr.splice(arrIdx, 0, toInsert);
24623
- return lens(obj).set(arrLens, arr);
24624
- };
24625
-
24626
- lens.prototype.insertBefore = lens.prototype.insertAt;
24627
- lens.prototype.insertAfter = function(lensArr, toInsert) {
24628
- var newLens = lensArr.slice();
24629
- newLens[newLens.length-1] += 1;
24630
- return lens(this._wrapped).insertAt(newLens, toInsert);
24631
- };
24632
- */
24475
+ const arr = {
24476
+ get: function (arr, monocle) {
24477
+ return arr[monocle];
24478
+ },
24479
+ set: function (arr, monocle, val) {
24480
+ var newArr = arr.splice();
24481
+ newArr[monocle] = val;
24482
+ return newArr;
24483
+ },
24484
+ mod: function (arr, monocle, f) {
24485
+ var newArr = arr.slice();
24486
+ newArr[monocle] = f(arr[monocle]);
24487
+ return newArr;
24488
+ },
24489
+ del: function (arr, monocle) {
24490
+ var newArr = arr.slice();
24491
+ newArr.splice(monocle, 1);
24492
+ return newArr;
24493
+ }
24494
+ };
24633
24495
 
24634
- module.exports = {
24635
- get: get,
24636
- set: set,
24637
- mod: mod,
24638
- del: del
24639
- };
24496
+ /*
24497
+ // Lens must point to a member of an array. We'll insert into that array.
24498
+ lens.prototype.insertAt = function(lensArr, toInsert) {
24499
+ var obj = this._wrapped;
24640
24500
 
24641
- /***/
24642
- }, /* 3 */
24643
- /***/function (module, exports, __webpack_require__) {
24644
- var clone = __webpack_require__(0).clone;
24645
- var get = function (obj, monocle) {
24646
- return obj[monocle];
24647
- };
24648
- var set = function (obj, monocle, val) {
24649
- var newObj = clone(obj);
24650
- newObj[monocle] = val;
24651
- return newObj;
24652
- };
24653
- var mod = function (obj, monocle, f) {
24654
- var newObj = clone(obj);
24655
- newObj[monocle] = f(obj[monocle]);
24656
- return newObj;
24657
- };
24658
- var del = function (obj, monocle) {
24659
- var newObj = clone(obj);
24660
- delete newObj[monocle];
24661
- return newObj;
24662
- };
24663
- module.exports = {
24664
- get: get,
24665
- set: set,
24666
- mod: mod,
24667
- del: del
24668
- };
24501
+ var arrLens = lensArr.slice(0, -1);
24502
+ var arr = lens(obj).get(arrLens).slice(); // slice to copy
24669
24503
 
24670
- /***/
24671
- }, /* 4 */
24672
- /***/function (module, exports) {
24673
- var get = function (arr, monocle) {
24674
- return arr[monocle];
24675
- };
24676
- var set = function (arr, monocle, val) {
24677
- var newArr = arr.splice();
24678
- newArr[monocle] = val;
24679
- return newArr;
24680
- };
24681
- var mod = function (arr, monocle, f) {
24682
- var newArr = arr.splice();
24683
- newArr[monocle] = f(arr[monocle]);
24684
- return newArr;
24685
- };
24686
- var del = function (arr, monocle) {
24687
- var newArr = arr.slice();
24688
- newArr.splice(monocle);
24689
- return newArr;
24690
- };
24691
- module.exports = {
24692
- get: get,
24693
- set: set,
24694
- mod: mod,
24695
- del: del
24696
- };
24504
+ var arrIdx = lensArr[lensArr.length-1];
24505
+ arr.splice(arrIdx, 0, toInsert);
24506
+ return lens(obj).set(arrLens, arr);
24507
+ };
24697
24508
 
24698
- /***/
24699
- }
24700
- /******/])
24701
- );
24702
- });
24703
- } (hubble));
24509
+ lens.prototype.insertBefore = lens.prototype.insertAt;
24510
+ lens.prototype.insertAfter = function(lensArr, toInsert) {
24511
+ var newLens = lensArr.slice();
24512
+ newLens[newLens.length-1] += 1;
24513
+ return lens(this._wrapped).insertAt(newLens, toInsert);
24514
+ };
24515
+ */
24516
+
24517
+ // OBJECT FUNCTIONS
24518
+
24519
+ const obj = {
24520
+ get: function (obj, monocle) {
24521
+ return obj[monocle];
24522
+ },
24523
+ set: function (obj, monocle, val) {
24524
+ var newObj = clone(obj);
24525
+ newObj[monocle] = val;
24526
+ return newObj;
24527
+ },
24528
+ mod: function (obj, monocle, f) {
24529
+ var newObj = clone(obj);
24530
+ newObj[monocle] = f(obj[monocle]);
24531
+ return newObj;
24532
+ },
24533
+ del: function (obj, monocle) {
24534
+ var newObj = clone(obj);
24535
+ delete newObj[monocle];
24536
+ return newObj;
24537
+ }
24538
+ };
24539
+
24540
+ // STRING FUNCTIONS
24704
24541
 
24705
- var lens = /*@__PURE__*/getDefaultExportFromCjs(hubble.exports);
24542
+ const str = {
24543
+ get: function (arr, monocle) {
24544
+ return arr[monocle];
24545
+ },
24546
+ set: function (arr, monocle, val) {
24547
+ var newArr = arr.splice();
24548
+ newArr[monocle] = val;
24549
+ return newArr;
24550
+ },
24551
+ mod: function (arr, monocle, f) {
24552
+ var newArr = arr.splice();
24553
+ newArr[monocle] = f(arr[monocle]);
24554
+ return newArr;
24555
+ },
24556
+ del: function (arr, monocle) {
24557
+ var newArr = arr.slice();
24558
+ newArr.splice(monocle);
24559
+ return newArr;
24560
+ }
24561
+ };
24706
24562
 
24707
24563
  class SimpleButton extends React__namespace.Component {
24708
24564
  static propTypes = {