@khanacademy/perseus-editor 4.0.0 → 4.1.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/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @khanacademy/perseus-editor
2
2
 
3
+ ## 4.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#895](https://github.com/Khan/perseus/pull/895) [`15b4bc02`](https://github.com/Khan/perseus/commit/15b4bc02d65fd1900e01ce7dd35863c1be579d73) Thanks [@jeremywiebe](https://github.com/jeremywiebe)! - Convert ImageEditor compoment to modern React class component
8
+
9
+ * [#937](https://github.com/Khan/perseus/pull/937) [`ef898f77`](https://github.com/Khan/perseus/commit/ef898f77f45f3494f5012d2db52a3461aad93c69) Thanks [@nishasy](https://github.com/nishasy)! - bumped mathquill version + minor type updates
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies [[`15b4bc02`](https://github.com/Khan/perseus/commit/15b4bc02d65fd1900e01ce7dd35863c1be579d73), [`0b737502`](https://github.com/Khan/perseus/commit/0b7375023826ef5ee46eb5ae00136b2356e10be4), [`ef898f77`](https://github.com/Khan/perseus/commit/ef898f77f45f3494f5012d2db52a3461aad93c69), [`319e330e`](https://github.com/Khan/perseus/commit/319e330ed77d2145266a9b231693ac65320032a2), [`3bfd44e3`](https://github.com/Khan/perseus/commit/3bfd44e37643cdd13392fbaabb9fb4370378d2b3), [`59ce1e09`](https://github.com/Khan/perseus/commit/59ce1e0990cecd1123d7b9a671b032fcd03ce1b1), [`ef898f77`](https://github.com/Khan/perseus/commit/ef898f77f45f3494f5012d2db52a3461aad93c69), [`f16e4184`](https://github.com/Khan/perseus/commit/f16e4184a24dcdaafc0cb4ebde5651f5bb135df9), [`247f8b1b`](https://github.com/Khan/perseus/commit/247f8b1be0647c39a5cabd9ce72a216d750a707b), [`62e04cfa`](https://github.com/Khan/perseus/commit/62e04cfa3139c6417442cbb96f8012d098a7c279), [`583becef`](https://github.com/Khan/perseus/commit/583becefbf690e96df709bcb7f8150cf686deadf)]:
14
+ - @khanacademy/perseus@19.1.0
15
+ - @khanacademy/math-input@17.0.0
16
+ - @khanacademy/kmath@0.1.9
17
+
3
18
  ## 4.0.0
4
19
 
5
20
  ### Major Changes
package/dist/es/index.js CHANGED
@@ -25,7 +25,7 @@ import * as i18n$1 from '@khanacademy/wonder-blocks-i18n';
25
25
 
26
26
  // This file is processed by a Rollup plugin (replace) to inject the production
27
27
  const libName = "@khanacademy/perseus-editor";
28
- const libVersion = "4.0.0";
28
+ const libVersion = "4.1.0";
29
29
  addLibraryVersionToPerseusDebug(libName, libVersion);
30
30
 
31
31
  function _extends() {
@@ -28112,6 +28112,7 @@ IframeEditor.defaultProps = {
28112
28112
  allowTopNavigation: false
28113
28113
  };
28114
28114
 
28115
+ /* eslint-disable jsx-a11y/anchor-is-valid, react/sort-comp */
28115
28116
  const {
28116
28117
  InfoTip: InfoTip$f,
28117
28118
  InlineIcon: InlineIcon$4,
@@ -28136,37 +28137,23 @@ const INTERNALLY_HOSTED_URL_RE = new RegExp("^(https?|web\\+graphie)://[^/]*" +
28136
28137
  * Alignment option for captions, relative to specified coordinates.
28137
28138
  */
28138
28139
  const captionAlignments = ["center", "above", "above right", "right", "below right", "below", "below left", "left", "above left"];
28139
- const ImageEditor = createReactClass({
28140
- displayName: "ImageEditor",
28141
- propTypes: _extends({}, Changeable.propTypes),
28142
- statics: {
28143
- widgetName: "image"
28144
- },
28145
- componentDidMount: function () {
28140
+ class ImageEditor extends React.Component {
28141
+ constructor(...args) {
28142
+ super(...args);
28143
+ this._isMounted = false;
28144
+ this.state = {
28145
+ backgroundImageError: ""
28146
+ };
28147
+ }
28148
+ componentDidMount() {
28146
28149
  // TODO(scottgrant): This is a hack to remove the deprecated call to
28147
28150
  // this.isMounted() but is still considered an anti-pattern.
28148
28151
  this._isMounted = true;
28149
- },
28150
- componentWillUnmount: function () {
28152
+ }
28153
+ componentWillUnmount() {
28151
28154
  this._isMounted = false;
28152
- },
28153
- getDefaultProps: function () {
28154
- return {
28155
- title: "",
28156
- range: [defaultRange, defaultRange],
28157
- box: [defaultBoxSize, defaultBoxSize],
28158
- backgroundImage: defaultBackgroundImage$1,
28159
- labels: [],
28160
- alt: "",
28161
- caption: ""
28162
- };
28163
- },
28164
- getInitialState: function () {
28165
- return {
28166
- backgroundImageError: ""
28167
- };
28168
- },
28169
- render: function () {
28155
+ }
28156
+ render() {
28170
28157
  const backgroundImage = this.props.backgroundImage;
28171
28158
  const imageSettings = /*#__PURE__*/React.createElement("div", {
28172
28159
  className: "image-settings"
@@ -28207,8 +28194,8 @@ const ImageEditor = createReactClass({
28207
28194
  },
28208
28195
  onChange: url => this.onUrlChange(url, false)
28209
28196
  })), backgroundImage.url && imageSettings);
28210
- },
28211
- _renderRowForLabel: function (label, i) {
28197
+ }
28198
+ _renderRowForLabel(label, i) {
28212
28199
  return /*#__PURE__*/React.createElement("tr", {
28213
28200
  key: i
28214
28201
  }, /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement(RangeInput$4, {
@@ -28247,19 +28234,19 @@ const ImageEditor = createReactClass({
28247
28234
  ,
28248
28235
  onClick: this.removeLabel.bind(this, i)
28249
28236
  }, /*#__PURE__*/React.createElement(InlineIcon$4, icons.iconTrash))));
28250
- },
28237
+ }
28251
28238
  change(...args) {
28252
28239
  return Changeable.change.apply(this, args);
28253
- },
28254
- removeLabel: function (labelIndex, e) {
28240
+ }
28241
+ removeLabel(labelIndex, e) {
28255
28242
  e.preventDefault();
28256
- const labels = _(this.props.labels).clone();
28243
+ const labels = [...this.props.labels];
28257
28244
  labels.splice(labelIndex, 1);
28258
28245
  this.props.onChange({
28259
28246
  labels: labels
28260
28247
  });
28261
- },
28262
- onCoordinateChange: function (labelIndex, newCoordinates) {
28248
+ }
28249
+ onCoordinateChange(labelIndex, newCoordinates) {
28263
28250
  const labels = this.props.labels.slice();
28264
28251
  labels[labelIndex] = _.extend({}, labels[labelIndex], {
28265
28252
  coordinates: newCoordinates
@@ -28267,8 +28254,8 @@ const ImageEditor = createReactClass({
28267
28254
  this.props.onChange({
28268
28255
  labels: labels
28269
28256
  });
28270
- },
28271
- onContentChange: function (labelIndex, e) {
28257
+ }
28258
+ onContentChange(labelIndex, e) {
28272
28259
  const newContent = e.target.value;
28273
28260
  const labels = this.props.labels.slice();
28274
28261
  labels[labelIndex] = _.extend({}, labels[labelIndex], {
@@ -28277,8 +28264,8 @@ const ImageEditor = createReactClass({
28277
28264
  this.props.onChange({
28278
28265
  labels: labels
28279
28266
  });
28280
- },
28281
- onAlignmentChange: function (labelIndex, e) {
28267
+ }
28268
+ onAlignmentChange(labelIndex, e) {
28282
28269
  const newAlignment = e.target.value;
28283
28270
  const labels = this.props.labels.slice();
28284
28271
  labels[labelIndex] = _.extend({}, labels[labelIndex], {
@@ -28287,8 +28274,8 @@ const ImageEditor = createReactClass({
28287
28274
  this.props.onChange({
28288
28275
  labels: labels
28289
28276
  });
28290
- },
28291
- setUrl: function (url, width, height, silent) {
28277
+ }
28278
+ setUrl(url, width, height, silent) {
28292
28279
  // Because this calls into WidgetEditor._handleWidgetChange, which
28293
28280
  // checks for this widget's ref to serialize it.
28294
28281
  //
@@ -28306,11 +28293,12 @@ const ImageEditor = createReactClass({
28306
28293
  backgroundImage: image,
28307
28294
  box: box
28308
28295
  }, null, silent);
28309
- },
28296
+ }
28297
+
28310
28298
  // silently load the image when the component mounts
28311
28299
  // silently update url and sizes when the image loads
28312
28300
  // noisily load the image in response to the author changing it
28313
- onUrlChange: async function (url, silent) {
28301
+ async onUrlChange(url, silent) {
28314
28302
  // Check if we've been passed something that looks like a URL
28315
28303
  if (!url) {
28316
28304
  this.setUrl(url, 0, 0, silent);
@@ -28337,18 +28325,29 @@ const ImageEditor = createReactClass({
28337
28325
  backgroundImageError: `There was an error loading the image URL: ${JSON.stringify(error, null, 2)}`
28338
28326
  });
28339
28327
  }
28340
- },
28341
- onRangeChange: function (type, newRange) {
28328
+ }
28329
+ onRangeChange(type, newRange) {
28342
28330
  const range = this.props.range.slice();
28343
28331
  range[type] = newRange;
28344
28332
  this.props.onChange({
28345
28333
  range: range
28346
28334
  });
28347
- },
28335
+ }
28348
28336
  serialize() {
28349
28337
  return EditorJsonify.serialize.call(this);
28350
28338
  }
28351
- });
28339
+ }
28340
+ ImageEditor.displayName = "ImageEditor";
28341
+ ImageEditor.widgetName = "image";
28342
+ ImageEditor.defaultProps = {
28343
+ title: "",
28344
+ range: [defaultRange, defaultRange],
28345
+ box: [defaultBoxSize, defaultBoxSize],
28346
+ backgroundImage: defaultBackgroundImage$1,
28347
+ labels: [],
28348
+ alt: "",
28349
+ caption: ""
28350
+ };
28352
28351
 
28353
28352
  /* eslint-disable react/sort-comp */
28354
28353
  const {