@pie-element/extended-text-entry 6.8.7 → 6.8.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/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [6.8.8](https://github.com/pie-framework/pie-elements/compare/@pie-element/extended-text-entry@6.8.7...@pie-element/extended-text-entry@6.8.8) (2022-05-03)
7
+
8
+ **Note:** Version bump only for package @pie-element/extended-text-entry
9
+
10
+
11
+
12
+
13
+
6
14
  ## [6.8.7](https://github.com/pie-framework/pie-elements/compare/@pie-element/extended-text-entry@6.8.6...@pie-element/extended-text-entry@6.8.7) (2022-04-12)
7
15
 
8
16
  **Note:** Version bump only for package @pie-element/extended-text-entry
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [5.4.17](https://github.com/pie-framework/pie-elements/compare/@pie-element/extended-text-entry-configure@5.4.16...@pie-element/extended-text-entry-configure@5.4.17) (2022-05-03)
7
+
8
+ **Note:** Version bump only for package @pie-element/extended-text-entry-configure
9
+
10
+
11
+
12
+
13
+
6
14
  ## [5.4.16](https://github.com/pie-framework/pie-elements/compare/@pie-element/extended-text-entry-configure@5.4.15...@pie-element/extended-text-entry-configure@5.4.16) (2022-04-12)
7
15
 
8
16
  **Note:** Version bump only for package @pie-element/extended-text-entry-configure
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pie-element/extended-text-entry-configure",
3
3
  "private": true,
4
- "version": "5.4.16",
4
+ "version": "5.4.17",
5
5
  "description": "",
6
6
  "main": "lib/index.js",
7
7
  "module": "src/index.js",
@@ -10,8 +10,8 @@
10
10
  "dependencies": {
11
11
  "@material-ui/core": "^3.9.2",
12
12
  "@pie-framework/pie-configure-events": "^1.2.0",
13
- "@pie-lib/config-ui": "^10.11.0",
14
- "@pie-lib/editable-html": "^7.20.0",
13
+ "@pie-lib/config-ui": "^10.12.1",
14
+ "@pie-lib/editable-html": "^7.22.1",
15
15
  "lodash": "^4.17.15",
16
16
  "prop-types": "^15.6.2",
17
17
  "react": "^16.8.1",
@@ -1,6 +1,6 @@
1
- import {_dll_react, _dll_prop_types, _dll_material_ui__core, _dll_material_ui__core_styles, _dll_react_dom} from "../../../@pie-lib/shared-module@^1.4.10/module/index.js";
2
- import {_dll_pie_lib__config_ui} from "../../../@pie-lib/config-module@^1.0.33/module/index.js";
3
- import {_dll_pie_lib__editable_html} from "../../../@pie-lib/editable-html-module@^1.2.9/module/index.js";
1
+ import {_dll_react, _dll_prop_types, _dll_material_ui__core, _dll_material_ui__core_styles, _dll_react_dom} from "../../../@pie-lib/shared-module@^1.4.13/module/index.js";
2
+ import {_dll_pie_lib__config_ui} from "../../../@pie-lib/config-module@^1.2.0/module/index.js";
3
+ import {_dll_pie_lib__editable_html} from "../../../@pie-lib/editable-html-module@^1.5.0/module/index.js";
4
4
  var lib = {};
5
5
  Object.defineProperty(lib, "__esModule", {
6
6
  value: true
package/module/element.js CHANGED
@@ -1,7 +1,7 @@
1
- import {_dll_debug, _dll_lodash, _dll_react_dom, _dll_prop_types, _dll_react, _dll_react_dom_server, _dll_material_ui__core, _dll_classnames, _dll_material_ui__core_styles, _dll_material_ui__icons, _dll_pie_lib__render_ui} from "../../../@pie-lib/shared-module@^1.4.10/module/index.js";
2
- import {_dll_pie_lib__math_rendering} from "../../../@pie-lib/math-rendering-module@^1.0.35/module/index.js";
3
- import {_dll_pie_lib__math_toolbar} from "../../../@pie-lib/math-edit-module@^1.1.31/module/index.js";
4
- import {_dll_pie_lib__drag} from "../../../@pie-lib/drag-module@^1.0.33/module/index.js";
1
+ import {_dll_debug, _dll_lodash, _dll_react_dom, _dll_prop_types, _dll_react, _dll_react_dom_server, _dll_material_ui__core, _dll_classnames, _dll_material_ui__core_styles, _dll_material_ui__icons, _dll_pie_lib__render_ui} from "../../../@pie-lib/shared-module@^1.4.13/module/index.js";
2
+ import {_dll_pie_lib__math_rendering} from "../../../@pie-lib/math-rendering-module@^1.1.1/module/index.js";
3
+ import {_dll_pie_lib__math_toolbar} from "../../../@pie-lib/math-edit-module@^1.2.0/module/index.js";
4
+ import {_dll_pie_lib__drag} from "../../../@pie-lib/drag-module@^1.0.36/module/index.js";
5
5
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
6
6
  function getDefaultExportFromCjs(x) {
7
7
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
@@ -21861,6 +21861,13 @@ const styles$6 = () => ({
21861
21861
  },
21862
21862
  active: {
21863
21863
  color: 'black'
21864
+ },
21865
+ disabled: {
21866
+ opacity: 0.7,
21867
+ cursor: 'not-allowed',
21868
+ '& :hover': {
21869
+ color: 'grey'
21870
+ }
21864
21871
  }
21865
21872
  });
21866
21873
  const log$j = debug$j('pie-elements:editable-html:raw-button');
@@ -21871,6 +21878,7 @@ class RawButton extends React$s.Component {
21871
21878
  classes: PropTypes$k.object.isRequired,
21872
21879
  children: PropTypes$k.oneOfType([PropTypes$k.arrayOf(PropTypes$k.node), PropTypes$k.node]).isRequired,
21873
21880
  active: PropTypes$k.bool,
21881
+ disabled: PropTypes$k.bool,
21874
21882
  extraStyles: PropTypes$k.object
21875
21883
  };
21876
21884
  }
@@ -21887,8 +21895,11 @@ class RawButton extends React$s.Component {
21887
21895
  };
21888
21896
  }
21889
21897
  render() {
21890
- const {active, classes, children, extraStyles} = this.props;
21891
- const names = classNames$4(classes.button, active && classes.active);
21898
+ const {active, classes, children, disabled, extraStyles} = this.props;
21899
+ const names = classNames$4(classes.button, {
21900
+ [classes.active]: active,
21901
+ [classes.disabled]: disabled
21902
+ });
21892
21903
  return React$s.createElement('div', {
21893
21904
  style: extraStyles,
21894
21905
  className: names,
@@ -21896,7 +21907,7 @@ class RawButton extends React$s.Component {
21896
21907
  __self: this,
21897
21908
  __source: {
21898
21909
  fileName: _jsxFileName$r,
21899
- lineNumber: 48
21910
+ lineNumber: 59
21900
21911
  }
21901
21912
  }, children);
21902
21913
  }
@@ -21932,7 +21943,7 @@ class RawMarkButton extends React$s.Component {
21932
21943
  __self: this,
21933
21944
  __source: {
21934
21945
  fileName: _jsxFileName$r,
21935
- lineNumber: 79
21946
+ lineNumber: 90
21936
21947
  }
21937
21948
  }, children);
21938
21949
  }
@@ -25767,20 +25778,22 @@ const ToolbarButton = props => {
25767
25778
  __self: undefined,
25768
25779
  __source: {
25769
25780
  fileName: _jsxFileName$h,
25770
- lineNumber: 24
25781
+ lineNumber: 27
25771
25782
  }
25772
25783
  }, props.icon);
25773
25784
  } else {
25785
+ const {disabled} = props;
25774
25786
  const isActive = props.isActive ? props.isActive(props.value, props.type) : hasBlock(props.value, props.type);
25775
25787
  log$b('[ToolbarButton] block:isActive: ', isActive);
25776
25788
  return React$i.createElement(Button$1, {
25777
25789
  active: isActive,
25790
+ disabled: disabled,
25778
25791
  onClick: () => props.onClick(props.value, props.onChange),
25779
25792
  extraStyles: props.buttonStyles,
25780
25793
  __self: undefined,
25781
25794
  __source: {
25782
25795
  fileName: _jsxFileName$h,
25783
- lineNumber: 34
25796
+ lineNumber: 40
25784
25797
  }
25785
25798
  }, props.icon);
25786
25799
  }
@@ -25796,14 +25809,14 @@ const DefaultToolbar = ({plugins, pluginProps, value, onChange, onDone, classes,
25796
25809
  __self: undefined,
25797
25810
  __source: {
25798
25811
  fileName: _jsxFileName$h,
25799
- lineNumber: 63
25812
+ lineNumber: 71
25800
25813
  }
25801
25814
  }, React$i.createElement('div', {
25802
25815
  className: classes.buttonsContainer,
25803
25816
  __self: undefined,
25804
25817
  __source: {
25805
25818
  fileName: _jsxFileName$h,
25806
- lineNumber: 64
25819
+ lineNumber: 72
25807
25820
  }
25808
25821
  }, filtered.map((p, index) => {
25809
25822
  return React$i.createElement(ToolbarButton, {
@@ -25814,7 +25827,7 @@ const DefaultToolbar = ({plugins, pluginProps, value, onChange, onDone, classes,
25814
25827
  __self: undefined,
25815
25828
  __source: {
25816
25829
  fileName: _jsxFileName$h,
25817
- lineNumber: 66
25830
+ lineNumber: 74
25818
25831
  }
25819
25832
  });
25820
25833
  })), showDone && !deletable && React$i.createElement(DoneButton, {
@@ -25822,7 +25835,7 @@ const DefaultToolbar = ({plugins, pluginProps, value, onChange, onDone, classes,
25822
25835
  __self: undefined,
25823
25836
  __source: {
25824
25837
  fileName: _jsxFileName$h,
25825
- lineNumber: 69
25838
+ lineNumber: 77
25826
25839
  }
25827
25840
  }));
25828
25841
  };
@@ -27407,7 +27420,7 @@ const React$a = _dll_react;
27407
27420
  const PropTypes$5 = _dll_prop_types;
27408
27421
  const _jsxFileName$9 = "/home/circleci/repo/node_modules/@pie-lib/editable-html/src/plugins/respArea/explicit-constructed-response/index.jsx";
27409
27422
  const ExplicitConstructedResponse = props => {
27410
- const {attributes, value} = props;
27423
+ const {attributes, value, error} = props;
27411
27424
  return React$a.createElement('span', {
27412
27425
  ...attributes,
27413
27426
  style: {
@@ -27430,7 +27443,7 @@ const ExplicitConstructedResponse = props => {
27430
27443
  minHeight: '36px',
27431
27444
  height: '36px',
27432
27445
  background: '#FFF',
27433
- border: '1px solid #C0C3CF',
27446
+ border: `1px solid ${error ? 'red' : '#C0C3CF'}`,
27434
27447
  boxSizing: 'border-box',
27435
27448
  borderRadius: '3px',
27436
27449
  overflow: 'hidden',
@@ -27497,12 +27510,13 @@ const elTypesMap = {
27497
27510
  };
27498
27511
  const elTypesArray = Object.values(elTypesMap);
27499
27512
  function ResponseAreaPlugin(opts) {
27513
+ const isOfCurrentType = d => d.type === opts.type || d.type === elTypesMap[opts.type];
27500
27514
  const toolbar = {
27501
27515
  icon: React$9.createElement(ToolbarIcon, {
27502
27516
  __self: this,
27503
27517
  __source: {
27504
27518
  fileName: _jsxFileName$8,
27505
- lineNumber: 23
27519
+ lineNumber: 25
27506
27520
  }
27507
27521
  }),
27508
27522
  buttonStyles: {
@@ -27511,6 +27525,10 @@ function ResponseAreaPlugin(opts) {
27511
27525
  onClick: (value, onChange) => {
27512
27526
  log$8('[toolbar] onClick');
27513
27527
  const change = value.change();
27528
+ const currentRespAreaList = change.value.document.filterDescendants(isOfCurrentType);
27529
+ if (currentRespAreaList.size >= opts.maxResponseAreas) {
27530
+ return;
27531
+ }
27514
27532
  const type = opts.type.replace(/-/g, '_');
27515
27533
  const prevIndex = lastIndexMap[type];
27516
27534
  const newIndex = prevIndex === 0 ? prevIndex : prevIndex + 1;
@@ -27559,13 +27577,18 @@ function ResponseAreaPlugin(opts) {
27559
27577
  const {attributes, node: n} = props;
27560
27578
  if (n.type === 'explicit_constructed_response') {
27561
27579
  const data = n.data.toJSON();
27580
+ let error;
27581
+ if (opts.error) {
27582
+ error = opts.error();
27583
+ }
27562
27584
  return React$9.createElement(ExplicitConstructedResponse, {
27563
27585
  attributes: attributes,
27564
27586
  value: data.value,
27587
+ error: error && error[data.index] && error[data.index][0],
27565
27588
  __self: this,
27566
27589
  __source: {
27567
27590
  fileName: _jsxFileName$8,
27568
- lineNumber: 93
27591
+ lineNumber: 107
27569
27592
  }
27570
27593
  });
27571
27594
  }
@@ -27580,7 +27603,7 @@ function ResponseAreaPlugin(opts) {
27580
27603
  __self: this,
27581
27604
  __source: {
27582
27605
  fileName: _jsxFileName$8,
27583
- lineNumber: 100
27606
+ lineNumber: 119
27584
27607
  }
27585
27608
  });
27586
27609
  }
@@ -27592,7 +27615,7 @@ function ResponseAreaPlugin(opts) {
27592
27615
  __self: this,
27593
27616
  __source: {
27594
27617
  fileName: _jsxFileName$8,
27595
- lineNumber: 107
27618
+ lineNumber: 126
27596
27619
  }
27597
27620
  });
27598
27621
  }
@@ -27613,9 +27636,13 @@ function ResponseAreaPlugin(opts) {
27613
27636
  if (!editor.value) {
27614
27637
  return;
27615
27638
  }
27616
- const isOfCurrentType = d => d.type === opts.type || d.type === elTypesMap[opts.type];
27617
27639
  const currentRespAreaList = change.value.document.filterDescendants(isOfCurrentType);
27618
27640
  const oldRespAreaList = editor.value.document.filterDescendants(isOfCurrentType);
27641
+ if (currentRespAreaList.size >= opts.maxResponseAreas) {
27642
+ toolbar.disabled = true;
27643
+ } else {
27644
+ toolbar.disabled = false;
27645
+ }
27619
27646
  const arrayToFilter = oldRespAreaList.size > currentRespAreaList.size ? oldRespAreaList : currentRespAreaList;
27620
27647
  const arrayToUseForFilter = arrayToFilter === oldRespAreaList ? currentRespAreaList : oldRespAreaList;
27621
27648
  const elementsWithChangedStatus = arrayToFilter.filter(d => !arrayToUseForFilter.find(e => e.data.get('index') === d.data.get('index')));
@@ -27685,7 +27712,7 @@ const serialization = {
27685
27712
  __self: this,
27686
27713
  __source: {
27687
27714
  fileName: _jsxFileName$8,
27688
- lineNumber: 207
27715
+ lineNumber: 231
27689
27716
  }
27690
27717
  });
27691
27718
  }
@@ -27699,7 +27726,7 @@ const serialization = {
27699
27726
  __self: this,
27700
27727
  __source: {
27701
27728
  fileName: _jsxFileName$8,
27702
- lineNumber: 213
27729
+ lineNumber: 237
27703
27730
  }
27704
27731
  });
27705
27732
  }
@@ -27715,7 +27742,7 @@ const serialization = {
27715
27742
  __self: this,
27716
27743
  __source: {
27717
27744
  fileName: _jsxFileName$8,
27718
- lineNumber: 224
27745
+ lineNumber: 248
27719
27746
  }
27720
27747
  });
27721
27748
  }
@@ -27980,7 +28007,7 @@ serializer.deserialize = function deserialize(html) {
27980
28007
  }
27981
28008
  };
27982
28009
  let i;
27983
- for (i = 0; i < 1000; i++) {
28010
+ for (i = 0; i < 3000; i++) {
27984
28011
  json.schema.rules.push({
27985
28012
  match: {
27986
28013
  object: 'document'
@@ -27998,7 +28025,14 @@ serializer.deserialize = function deserialize(html) {
27998
28025
  }
27999
28026
  return null;
28000
28027
  };
28001
- const htmlToValue = html => serializer.deserialize(html);
28028
+ const htmlToValue = html => {
28029
+ try {
28030
+ return serializer.deserialize(html);
28031
+ } catch (e) {
28032
+ console.log("Couldn't parse html: ", e);
28033
+ return {};
28034
+ }
28035
+ };
28002
28036
  const valueToHtml = value => serializer.serialize(value);
28003
28037
  const {Delete: Delete} = _dll_material_ui__icons;
28004
28038
  const {IconButton: IconButton} = _dll_material_ui__core;
@@ -28984,8 +29018,10 @@ class Editor extends React$3.Component {
28984
29018
  responseArea: {
28985
29019
  type: normalizedResponseAreaProps.type,
28986
29020
  options: normalizedResponseAreaProps.options,
29021
+ maxResponseAreas: normalizedResponseAreaProps.maxResponseAreas,
28987
29022
  respAreaToolbar: normalizedResponseAreaProps.respAreaToolbar,
28988
29023
  onHandleAreaChange: normalizedResponseAreaProps.onHandleAreaChange,
29024
+ error: normalizedResponseAreaProps.error,
28989
29025
  onFocus: () => {
28990
29026
  log$3('[table:onFocus]...');
28991
29027
  this.onPluginFocus();
@@ -29306,7 +29342,7 @@ class Editor extends React$3.Component {
29306
29342
  __self: this,
29307
29343
  __source: {
29308
29344
  fileName: _jsxFileName$2,
29309
- lineNumber: 559
29345
+ lineNumber: 561
29310
29346
  }
29311
29347
  }, React$3.createElement(Editor$2, {
29312
29348
  plugins: this.plugins,
@@ -29345,7 +29381,7 @@ class Editor extends React$3.Component {
29345
29381
  __self: this,
29346
29382
  __source: {
29347
29383
  fileName: _jsxFileName$2,
29348
- lineNumber: 564
29384
+ lineNumber: 566
29349
29385
  }
29350
29386
  }));
29351
29387
  }
@@ -29387,6 +29423,14 @@ const PropTypes$1 = _dll_prop_types;
29387
29423
  const debug$2 = _dll_debug;
29388
29424
  const _jsxFileName$1 = "/home/circleci/repo/node_modules/@pie-lib/editable-html/src/index.jsx";
29389
29425
  const log$2 = debug$2('@pie-lib:editable-html');
29426
+ const reduceMultipleBrs = markup => {
29427
+ try {
29428
+ return markup.replace(/(<br\s*\/?>){3,}/gi, '<br>');
29429
+ } catch (e) {
29430
+ console.log("Couldn't remove <br/> tags: ", e);
29431
+ }
29432
+ return markup;
29433
+ };
29390
29434
  class EditableHtml extends React$2.Component {
29391
29435
  static __initStatic() {
29392
29436
  this.propTypes = {
@@ -29416,9 +29460,9 @@ class EditableHtml extends React$2.Component {
29416
29460
  if (!props.allowValidation && props.markup === this.props.markup) {
29417
29461
  return;
29418
29462
  }
29419
- const v = htmlToValue(props.markup);
29420
- const current = htmlToValue(this.props.markup);
29421
- if (!v.equals(current)) {
29463
+ const v = htmlToValue(reduceMultipleBrs(props.markup));
29464
+ const current = htmlToValue(reduceMultipleBrs(this.props.markup));
29465
+ if (v.equals && !v.equals(current)) {
29422
29466
  this.setState({
29423
29467
  value: v
29424
29468
  });
@@ -29488,7 +29532,7 @@ class EditableHtml extends React$2.Component {
29488
29532
  __self: this,
29489
29533
  __source: {
29490
29534
  fileName: _jsxFileName$1,
29491
- lineNumber: 123
29535
+ lineNumber: 134
29492
29536
  }
29493
29537
  });
29494
29538
  }
package/module/index.html CHANGED
@@ -2,7 +2,7 @@
2
2
  <!doctype html>
3
3
  <html>
4
4
  <head>
5
- <title>@pie-element/extended-text-entry@6.8.6</title>
5
+ <title>@pie-element/extended-text-entry@6.8.7</title>
6
6
  <script
7
7
  type="module"
8
8
  src="https://cdn.jsdelivr.net/npm/@pslb/demo-el@^1.0.0/dist/demo-el/demo-el.esm.js"></script>
@@ -1,22 +1,22 @@
1
1
  {
2
2
  "name": "@pie-element/extended-text-entry",
3
- "version": "6.8.6",
3
+ "version": "6.8.7",
4
4
  "modules": [
5
5
  {
6
6
  "name": "@pie-lib/shared-module",
7
- "version": "^1.4.10"
7
+ "version": "^1.4.13"
8
8
  },
9
9
  {
10
10
  "name": "@pie-lib/math-rendering-module",
11
- "version": "^1.0.35"
11
+ "version": "^1.1.1"
12
12
  },
13
13
  {
14
14
  "name": "@pie-lib/math-edit-module",
15
- "version": "^1.1.31"
15
+ "version": "^1.2.0"
16
16
  },
17
17
  {
18
18
  "name": "@pie-lib/drag-module",
19
- "version": "^1.0.33"
19
+ "version": "^1.0.36"
20
20
  }
21
21
  ]
22
22
  }
package/module/print.html CHANGED
@@ -2,7 +2,7 @@
2
2
  <!doctype html>
3
3
  <html>
4
4
  <head>
5
- <title>@pie-element/extended-text-entry@6.8.6</title>
5
+ <title>@pie-element/extended-text-entry@6.8.7</title>
6
6
  <link
7
7
  href="https://fonts.googleapis.com/css?family=Roboto&display=swap"
8
8
  rel="stylesheet"
package/module/print.js CHANGED
@@ -1,7 +1,7 @@
1
- import {_dll_debug, _dll_lodash, _dll_react_dom, _dll_prop_types, _dll_react, _dll_react_dom_server, _dll_material_ui__core, _dll_classnames, _dll_material_ui__core_styles, _dll_material_ui__icons, _dll_pie_lib__render_ui} from "../../../@pie-lib/shared-module@^1.4.10/module/index.js";
2
- import {_dll_pie_lib__math_rendering} from "../../../@pie-lib/math-rendering-module@^1.0.35/module/index.js";
3
- import {_dll_pie_lib__math_toolbar} from "../../../@pie-lib/math-edit-module@^1.1.31/module/index.js";
4
- import {_dll_pie_lib__drag} from "../../../@pie-lib/drag-module@^1.0.33/module/index.js";
1
+ import {_dll_debug, _dll_lodash, _dll_react_dom, _dll_prop_types, _dll_react, _dll_react_dom_server, _dll_material_ui__core, _dll_classnames, _dll_material_ui__core_styles, _dll_material_ui__icons, _dll_pie_lib__render_ui} from "../../../@pie-lib/shared-module@^1.4.13/module/index.js";
2
+ import {_dll_pie_lib__math_rendering} from "../../../@pie-lib/math-rendering-module@^1.1.1/module/index.js";
3
+ import {_dll_pie_lib__math_toolbar} from "../../../@pie-lib/math-edit-module@^1.2.0/module/index.js";
4
+ import {_dll_pie_lib__drag} from "../../../@pie-lib/drag-module@^1.0.36/module/index.js";
5
5
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
6
6
  function getDefaultExportFromCjs(x) {
7
7
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
@@ -21861,6 +21861,13 @@ const styles$6 = () => ({
21861
21861
  },
21862
21862
  active: {
21863
21863
  color: 'black'
21864
+ },
21865
+ disabled: {
21866
+ opacity: 0.7,
21867
+ cursor: 'not-allowed',
21868
+ '& :hover': {
21869
+ color: 'grey'
21870
+ }
21864
21871
  }
21865
21872
  });
21866
21873
  const log$j = debug$j('pie-elements:editable-html:raw-button');
@@ -21871,6 +21878,7 @@ class RawButton extends React$s.Component {
21871
21878
  classes: PropTypes$k.object.isRequired,
21872
21879
  children: PropTypes$k.oneOfType([PropTypes$k.arrayOf(PropTypes$k.node), PropTypes$k.node]).isRequired,
21873
21880
  active: PropTypes$k.bool,
21881
+ disabled: PropTypes$k.bool,
21874
21882
  extraStyles: PropTypes$k.object
21875
21883
  };
21876
21884
  }
@@ -21887,8 +21895,11 @@ class RawButton extends React$s.Component {
21887
21895
  };
21888
21896
  }
21889
21897
  render() {
21890
- const {active, classes, children, extraStyles} = this.props;
21891
- const names = classNames$4(classes.button, active && classes.active);
21898
+ const {active, classes, children, disabled, extraStyles} = this.props;
21899
+ const names = classNames$4(classes.button, {
21900
+ [classes.active]: active,
21901
+ [classes.disabled]: disabled
21902
+ });
21892
21903
  return React$s.createElement('div', {
21893
21904
  style: extraStyles,
21894
21905
  className: names,
@@ -21896,7 +21907,7 @@ class RawButton extends React$s.Component {
21896
21907
  __self: this,
21897
21908
  __source: {
21898
21909
  fileName: _jsxFileName$r,
21899
- lineNumber: 48
21910
+ lineNumber: 59
21900
21911
  }
21901
21912
  }, children);
21902
21913
  }
@@ -21932,7 +21943,7 @@ class RawMarkButton extends React$s.Component {
21932
21943
  __self: this,
21933
21944
  __source: {
21934
21945
  fileName: _jsxFileName$r,
21935
- lineNumber: 79
21946
+ lineNumber: 90
21936
21947
  }
21937
21948
  }, children);
21938
21949
  }
@@ -25767,20 +25778,22 @@ const ToolbarButton = props => {
25767
25778
  __self: undefined,
25768
25779
  __source: {
25769
25780
  fileName: _jsxFileName$h,
25770
- lineNumber: 24
25781
+ lineNumber: 27
25771
25782
  }
25772
25783
  }, props.icon);
25773
25784
  } else {
25785
+ const {disabled} = props;
25774
25786
  const isActive = props.isActive ? props.isActive(props.value, props.type) : hasBlock(props.value, props.type);
25775
25787
  log$b('[ToolbarButton] block:isActive: ', isActive);
25776
25788
  return React$i.createElement(Button$1, {
25777
25789
  active: isActive,
25790
+ disabled: disabled,
25778
25791
  onClick: () => props.onClick(props.value, props.onChange),
25779
25792
  extraStyles: props.buttonStyles,
25780
25793
  __self: undefined,
25781
25794
  __source: {
25782
25795
  fileName: _jsxFileName$h,
25783
- lineNumber: 34
25796
+ lineNumber: 40
25784
25797
  }
25785
25798
  }, props.icon);
25786
25799
  }
@@ -25796,14 +25809,14 @@ const DefaultToolbar = ({plugins, pluginProps, value, onChange, onDone, classes,
25796
25809
  __self: undefined,
25797
25810
  __source: {
25798
25811
  fileName: _jsxFileName$h,
25799
- lineNumber: 63
25812
+ lineNumber: 71
25800
25813
  }
25801
25814
  }, React$i.createElement('div', {
25802
25815
  className: classes.buttonsContainer,
25803
25816
  __self: undefined,
25804
25817
  __source: {
25805
25818
  fileName: _jsxFileName$h,
25806
- lineNumber: 64
25819
+ lineNumber: 72
25807
25820
  }
25808
25821
  }, filtered.map((p, index) => {
25809
25822
  return React$i.createElement(ToolbarButton, {
@@ -25814,7 +25827,7 @@ const DefaultToolbar = ({plugins, pluginProps, value, onChange, onDone, classes,
25814
25827
  __self: undefined,
25815
25828
  __source: {
25816
25829
  fileName: _jsxFileName$h,
25817
- lineNumber: 66
25830
+ lineNumber: 74
25818
25831
  }
25819
25832
  });
25820
25833
  })), showDone && !deletable && React$i.createElement(DoneButton, {
@@ -25822,7 +25835,7 @@ const DefaultToolbar = ({plugins, pluginProps, value, onChange, onDone, classes,
25822
25835
  __self: undefined,
25823
25836
  __source: {
25824
25837
  fileName: _jsxFileName$h,
25825
- lineNumber: 69
25838
+ lineNumber: 77
25826
25839
  }
25827
25840
  }));
25828
25841
  };
@@ -27407,7 +27420,7 @@ const React$a = _dll_react;
27407
27420
  const PropTypes$5 = _dll_prop_types;
27408
27421
  const _jsxFileName$9 = "/home/circleci/repo/node_modules/@pie-lib/editable-html/src/plugins/respArea/explicit-constructed-response/index.jsx";
27409
27422
  const ExplicitConstructedResponse = props => {
27410
- const {attributes, value} = props;
27423
+ const {attributes, value, error} = props;
27411
27424
  return React$a.createElement('span', {
27412
27425
  ...attributes,
27413
27426
  style: {
@@ -27430,7 +27443,7 @@ const ExplicitConstructedResponse = props => {
27430
27443
  minHeight: '36px',
27431
27444
  height: '36px',
27432
27445
  background: '#FFF',
27433
- border: '1px solid #C0C3CF',
27446
+ border: `1px solid ${error ? 'red' : '#C0C3CF'}`,
27434
27447
  boxSizing: 'border-box',
27435
27448
  borderRadius: '3px',
27436
27449
  overflow: 'hidden',
@@ -27497,12 +27510,13 @@ const elTypesMap = {
27497
27510
  };
27498
27511
  const elTypesArray = Object.values(elTypesMap);
27499
27512
  function ResponseAreaPlugin(opts) {
27513
+ const isOfCurrentType = d => d.type === opts.type || d.type === elTypesMap[opts.type];
27500
27514
  const toolbar = {
27501
27515
  icon: React$9.createElement(ToolbarIcon, {
27502
27516
  __self: this,
27503
27517
  __source: {
27504
27518
  fileName: _jsxFileName$8,
27505
- lineNumber: 23
27519
+ lineNumber: 25
27506
27520
  }
27507
27521
  }),
27508
27522
  buttonStyles: {
@@ -27511,6 +27525,10 @@ function ResponseAreaPlugin(opts) {
27511
27525
  onClick: (value, onChange) => {
27512
27526
  log$8('[toolbar] onClick');
27513
27527
  const change = value.change();
27528
+ const currentRespAreaList = change.value.document.filterDescendants(isOfCurrentType);
27529
+ if (currentRespAreaList.size >= opts.maxResponseAreas) {
27530
+ return;
27531
+ }
27514
27532
  const type = opts.type.replace(/-/g, '_');
27515
27533
  const prevIndex = lastIndexMap[type];
27516
27534
  const newIndex = prevIndex === 0 ? prevIndex : prevIndex + 1;
@@ -27559,13 +27577,18 @@ function ResponseAreaPlugin(opts) {
27559
27577
  const {attributes, node: n} = props;
27560
27578
  if (n.type === 'explicit_constructed_response') {
27561
27579
  const data = n.data.toJSON();
27580
+ let error;
27581
+ if (opts.error) {
27582
+ error = opts.error();
27583
+ }
27562
27584
  return React$9.createElement(ExplicitConstructedResponse, {
27563
27585
  attributes: attributes,
27564
27586
  value: data.value,
27587
+ error: error && error[data.index] && error[data.index][0],
27565
27588
  __self: this,
27566
27589
  __source: {
27567
27590
  fileName: _jsxFileName$8,
27568
- lineNumber: 93
27591
+ lineNumber: 107
27569
27592
  }
27570
27593
  });
27571
27594
  }
@@ -27580,7 +27603,7 @@ function ResponseAreaPlugin(opts) {
27580
27603
  __self: this,
27581
27604
  __source: {
27582
27605
  fileName: _jsxFileName$8,
27583
- lineNumber: 100
27606
+ lineNumber: 119
27584
27607
  }
27585
27608
  });
27586
27609
  }
@@ -27592,7 +27615,7 @@ function ResponseAreaPlugin(opts) {
27592
27615
  __self: this,
27593
27616
  __source: {
27594
27617
  fileName: _jsxFileName$8,
27595
- lineNumber: 107
27618
+ lineNumber: 126
27596
27619
  }
27597
27620
  });
27598
27621
  }
@@ -27613,9 +27636,13 @@ function ResponseAreaPlugin(opts) {
27613
27636
  if (!editor.value) {
27614
27637
  return;
27615
27638
  }
27616
- const isOfCurrentType = d => d.type === opts.type || d.type === elTypesMap[opts.type];
27617
27639
  const currentRespAreaList = change.value.document.filterDescendants(isOfCurrentType);
27618
27640
  const oldRespAreaList = editor.value.document.filterDescendants(isOfCurrentType);
27641
+ if (currentRespAreaList.size >= opts.maxResponseAreas) {
27642
+ toolbar.disabled = true;
27643
+ } else {
27644
+ toolbar.disabled = false;
27645
+ }
27619
27646
  const arrayToFilter = oldRespAreaList.size > currentRespAreaList.size ? oldRespAreaList : currentRespAreaList;
27620
27647
  const arrayToUseForFilter = arrayToFilter === oldRespAreaList ? currentRespAreaList : oldRespAreaList;
27621
27648
  const elementsWithChangedStatus = arrayToFilter.filter(d => !arrayToUseForFilter.find(e => e.data.get('index') === d.data.get('index')));
@@ -27685,7 +27712,7 @@ const serialization = {
27685
27712
  __self: this,
27686
27713
  __source: {
27687
27714
  fileName: _jsxFileName$8,
27688
- lineNumber: 207
27715
+ lineNumber: 231
27689
27716
  }
27690
27717
  });
27691
27718
  }
@@ -27699,7 +27726,7 @@ const serialization = {
27699
27726
  __self: this,
27700
27727
  __source: {
27701
27728
  fileName: _jsxFileName$8,
27702
- lineNumber: 213
27729
+ lineNumber: 237
27703
27730
  }
27704
27731
  });
27705
27732
  }
@@ -27715,7 +27742,7 @@ const serialization = {
27715
27742
  __self: this,
27716
27743
  __source: {
27717
27744
  fileName: _jsxFileName$8,
27718
- lineNumber: 224
27745
+ lineNumber: 248
27719
27746
  }
27720
27747
  });
27721
27748
  }
@@ -27980,7 +28007,7 @@ serializer.deserialize = function deserialize(html) {
27980
28007
  }
27981
28008
  };
27982
28009
  let i;
27983
- for (i = 0; i < 1000; i++) {
28010
+ for (i = 0; i < 3000; i++) {
27984
28011
  json.schema.rules.push({
27985
28012
  match: {
27986
28013
  object: 'document'
@@ -27998,7 +28025,14 @@ serializer.deserialize = function deserialize(html) {
27998
28025
  }
27999
28026
  return null;
28000
28027
  };
28001
- const htmlToValue = html => serializer.deserialize(html);
28028
+ const htmlToValue = html => {
28029
+ try {
28030
+ return serializer.deserialize(html);
28031
+ } catch (e) {
28032
+ console.log("Couldn't parse html: ", e);
28033
+ return {};
28034
+ }
28035
+ };
28002
28036
  const valueToHtml = value => serializer.serialize(value);
28003
28037
  const {Delete: Delete} = _dll_material_ui__icons;
28004
28038
  const {IconButton: IconButton} = _dll_material_ui__core;
@@ -28984,8 +29018,10 @@ class Editor extends React$3.Component {
28984
29018
  responseArea: {
28985
29019
  type: normalizedResponseAreaProps.type,
28986
29020
  options: normalizedResponseAreaProps.options,
29021
+ maxResponseAreas: normalizedResponseAreaProps.maxResponseAreas,
28987
29022
  respAreaToolbar: normalizedResponseAreaProps.respAreaToolbar,
28988
29023
  onHandleAreaChange: normalizedResponseAreaProps.onHandleAreaChange,
29024
+ error: normalizedResponseAreaProps.error,
28989
29025
  onFocus: () => {
28990
29026
  log$3('[table:onFocus]...');
28991
29027
  this.onPluginFocus();
@@ -29306,7 +29342,7 @@ class Editor extends React$3.Component {
29306
29342
  __self: this,
29307
29343
  __source: {
29308
29344
  fileName: _jsxFileName$2,
29309
- lineNumber: 559
29345
+ lineNumber: 561
29310
29346
  }
29311
29347
  }, React$3.createElement(Editor$2, {
29312
29348
  plugins: this.plugins,
@@ -29345,7 +29381,7 @@ class Editor extends React$3.Component {
29345
29381
  __self: this,
29346
29382
  __source: {
29347
29383
  fileName: _jsxFileName$2,
29348
- lineNumber: 564
29384
+ lineNumber: 566
29349
29385
  }
29350
29386
  }));
29351
29387
  }
@@ -29387,6 +29423,14 @@ const PropTypes$1 = _dll_prop_types;
29387
29423
  const debug$2 = _dll_debug;
29388
29424
  const _jsxFileName$1 = "/home/circleci/repo/node_modules/@pie-lib/editable-html/src/index.jsx";
29389
29425
  const log$2 = debug$2('@pie-lib:editable-html');
29426
+ const reduceMultipleBrs = markup => {
29427
+ try {
29428
+ return markup.replace(/(<br\s*\/?>){3,}/gi, '<br>');
29429
+ } catch (e) {
29430
+ console.log("Couldn't remove <br/> tags: ", e);
29431
+ }
29432
+ return markup;
29433
+ };
29390
29434
  class EditableHtml extends React$2.Component {
29391
29435
  static __initStatic() {
29392
29436
  this.propTypes = {
@@ -29416,9 +29460,9 @@ class EditableHtml extends React$2.Component {
29416
29460
  if (!props.allowValidation && props.markup === this.props.markup) {
29417
29461
  return;
29418
29462
  }
29419
- const v = htmlToValue(props.markup);
29420
- const current = htmlToValue(this.props.markup);
29421
- if (!v.equals(current)) {
29463
+ const v = htmlToValue(reduceMultipleBrs(props.markup));
29464
+ const current = htmlToValue(reduceMultipleBrs(this.props.markup));
29465
+ if (v.equals && !v.equals(current)) {
29422
29466
  this.setState({
29423
29467
  value: v
29424
29468
  });
@@ -29488,7 +29532,7 @@ class EditableHtml extends React$2.Component {
29488
29532
  __self: this,
29489
29533
  __source: {
29490
29534
  fileName: _jsxFileName$1,
29491
- lineNumber: 123
29535
+ lineNumber: 134
29492
29536
  }
29493
29537
  });
29494
29538
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pie-element/extended-text-entry",
3
- "version": "6.8.7",
3
+ "version": "6.8.8",
4
4
  "description": "",
5
5
  "repository": "pie-framework/pie-elements",
6
6
  "publishConfig": {
@@ -12,9 +12,9 @@
12
12
  "@material-ui/core": "^3.9.2",
13
13
  "@material-ui/icons": "^3.0.2",
14
14
  "@pie-framework/pie-player-events": "^0.1.0",
15
- "@pie-lib/editable-html": "^7.20.0",
16
- "@pie-lib/math-rendering": "^2.3.13",
17
- "@pie-lib/render-ui": "^4.12.5",
15
+ "@pie-lib/editable-html": "^7.22.1",
16
+ "@pie-lib/math-rendering": "^2.4.0",
17
+ "@pie-lib/render-ui": "^4.12.6",
18
18
  "classnames": "^2.2.5",
19
19
  "debug": "^4.1.1",
20
20
  "lodash.throttle": "^4.1.1",
@@ -22,7 +22,7 @@
22
22
  "react": "^16.8.1",
23
23
  "react-dom": "^16.8.1"
24
24
  },
25
- "gitHead": "de8f41ecfc06944b7bc890a167f81818d2bf1845",
25
+ "gitHead": "87c4247b2cca04380c8638f88e57bba47fb6c06a",
26
26
  "scripts": {
27
27
  "postpublish": "../../scripts/postpublish"
28
28
  },