@startlibs/form 1.0.4 → 1.0.6

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.
Files changed (2) hide show
  1. package/lib/index.js +132 -100
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -37,6 +37,7 @@ import _possibleConstructorReturn from '@babel/runtime/helpers/possibleConstruct
37
37
  import _getPrototypeOf from '@babel/runtime/helpers/getPrototypeOf';
38
38
  import _inherits from '@babel/runtime/helpers/inherits';
39
39
  import _concat from 'lodash/fp/concat';
40
+ import _last from 'lodash/fp/last';
40
41
  import _without from 'lodash/fp/without';
41
42
  import _isEqual from 'lodash/fp/isEqual';
42
43
  import ContentEditable from 'react-contenteditable';
@@ -51,7 +52,6 @@ import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
51
52
  import _isBoolean from 'lodash/fp/isBoolean';
52
53
  import _negate from 'lodash/fp/negate';
53
54
  import _zipObject from 'lodash/fp/zipObject';
54
- import _last from 'lodash/fp/last';
55
55
  import _flatten from 'lodash/fp/flatten';
56
56
  import _fromPairs from 'lodash/fp/fromPairs';
57
57
  import _pick from 'lodash/fp/pick';
@@ -650,8 +650,9 @@ var formInput = function formInput(_ref) {
650
650
  return;
651
651
  }
652
652
 
653
- setFormValue(transform(value, opts));
654
- callIfFunction(onChange, callIfFunction(value, formValue), opts);
653
+ var transformedValue = transform(callIfFunction(value, formValue), opts);
654
+ setFormValue(transformedValue);
655
+ callIfFunction(onChange, transformedValue, opts);
655
656
  };
656
657
 
657
658
  var setValueFromEventTarget = function setValueFromEventTarget(e) {
@@ -1136,6 +1137,7 @@ var useTextInput = function useTextInput(_ref, ref) {
1136
1137
  var onFocus = _ref.onFocus,
1137
1138
  onBlur = _ref.onBlur,
1138
1139
  autoResize = _ref.autoResize,
1140
+ autoSelectOnFocus = _ref.autoSelectOnFocus,
1139
1141
  constraint = _ref.constraint,
1140
1142
  pattern = _ref.pattern,
1141
1143
  path = _ref.path,
@@ -1146,7 +1148,7 @@ var useTextInput = function useTextInput(_ref, ref) {
1146
1148
  raw = _ref.raw,
1147
1149
  showValue = _ref.showValue,
1148
1150
  deleteTrailing = _ref.deleteTrailing,
1149
- rest = _objectWithoutProperties(_ref, ["onFocus", "onBlur", "autoResize", "constraint", "pattern", "path", "rawValue", "rawSetValue", "rawHasErrors", "transformOnBlur", "raw", "showValue", "deleteTrailing"]);
1151
+ rest = _objectWithoutProperties(_ref, ["onFocus", "onBlur", "autoResize", "autoSelectOnFocus", "constraint", "pattern", "path", "rawValue", "rawSetValue", "rawHasErrors", "transformOnBlur", "raw", "showValue", "deleteTrailing"]);
1150
1152
 
1151
1153
  var _useInput = useInput$1(_objectSpread({
1152
1154
  path: path,
@@ -1168,6 +1170,15 @@ var useTextInput = function useTextInput(_ref, ref) {
1168
1170
 
1169
1171
  var handleOnFocus = function handleOnFocus(e) {
1170
1172
  setFocused(true);
1173
+
1174
+ if (!!autoSelectOnFocus && !!ref.current) {
1175
+ setTimeout(function () {
1176
+ var _ref$current;
1177
+
1178
+ return (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.select();
1179
+ }, 0);
1180
+ }
1181
+
1171
1182
  callIfFunction(onFocus, e);
1172
1183
  };
1173
1184
 
@@ -1190,6 +1201,15 @@ var useTextInput = function useTextInput(_ref, ref) {
1190
1201
  doAutoResize(ref.current);
1191
1202
  }
1192
1203
  }, []);
1204
+ useEffect(function () {
1205
+ if (!!autoSelectOnFocus && !!ref.current && document.activeElement === ref.current) {
1206
+ setTimeout(function () {
1207
+ var _ref$current2;
1208
+
1209
+ return (_ref$current2 = ref.current) === null || _ref$current2 === void 0 ? void 0 : _ref$current2.select();
1210
+ }, 0);
1211
+ }
1212
+ }, [autoSelectOnFocus]);
1193
1213
 
1194
1214
  var handleChange = function handleChange(e) {
1195
1215
  if (autoResize) {
@@ -1312,6 +1332,7 @@ var TextInput = styled(forwardRef(function (_ref2, forwardedRef) {
1312
1332
  onImage = _ref2$onImage === void 0 ? false : _ref2$onImage,
1313
1333
  autoFocus = _ref2.autoFocus,
1314
1334
  noFocus = _ref2.noFocus,
1335
+ autoSelectOnFocus = _ref2.autoSelectOnFocus,
1315
1336
  onFocus = _ref2.onFocus,
1316
1337
  onBlur = _ref2.onBlur,
1317
1338
  pattern = _ref2.pattern,
@@ -1321,7 +1342,7 @@ var TextInput = styled(forwardRef(function (_ref2, forwardedRef) {
1321
1342
  raw = _ref2.raw,
1322
1343
  _ref2$tabIndex = _ref2.tabIndex,
1323
1344
  tabIndex = _ref2$tabIndex === void 0 ? 1 : _ref2$tabIndex,
1324
- rest = _objectWithoutProperties(_ref2, ["showValue", "label", "type", "helpText", "descText", "bellowDescText", "mandatory", "isLoading", "locked", "textBoxBefore", "textBoxAfter", "className", "fieldClassName", "FieldType", "margin", "value", "setValue", "hasErrors", "textarea", "onImage", "autoFocus", "noFocus", "onFocus", "onBlur", "pattern", "autoResize", "constraint", "path", "raw", "tabIndex"]);
1345
+ rest = _objectWithoutProperties(_ref2, ["showValue", "label", "type", "helpText", "descText", "bellowDescText", "mandatory", "isLoading", "locked", "textBoxBefore", "textBoxAfter", "className", "fieldClassName", "FieldType", "margin", "value", "setValue", "hasErrors", "textarea", "onImage", "autoFocus", "noFocus", "autoSelectOnFocus", "onFocus", "onBlur", "pattern", "autoResize", "constraint", "path", "raw", "tabIndex"]);
1325
1346
 
1326
1347
  var ref = useEnsureRef(forwardedRef);
1327
1348
 
@@ -1330,6 +1351,7 @@ var TextInput = styled(forwardRef(function (_ref2, forwardedRef) {
1330
1351
  onFocus: onFocus,
1331
1352
  onBlur: onBlur,
1332
1353
  autoResize: autoResize,
1354
+ autoSelectOnFocus: autoSelectOnFocus,
1333
1355
  constraint: constraint,
1334
1356
  pattern: pattern,
1335
1357
  rawValue: rawValue,
@@ -2948,6 +2970,7 @@ var DropdownIconContainer = styled(Icon).withConfig({
2948
2970
  var focusBeforeLast = function focusBeforeLast(e) {
2949
2971
  if (e.target && e.target !== e.currentTarget) return;
2950
2972
  var el = [].slice.call(e.currentTarget.querySelectorAll('div[contenteditable]')).slice(-1)[0];
2973
+ if (!el) return;
2951
2974
  el.focus();
2952
2975
 
2953
2976
  if (!el.firstChild) {
@@ -3089,7 +3112,7 @@ var AutoComplete = React.forwardRef(function (_ref, outerRef) {
3089
3112
  };
3090
3113
 
3091
3114
  var shouldFocusInput = useToggle();
3092
- var recentlyAdded = useRefState();
3115
+ var recentlyAdded = useRefState(false);
3093
3116
  useEffect(function () {
3094
3117
  if (autoFocus) {
3095
3118
  focusInput();
@@ -3196,7 +3219,12 @@ var AutoComplete = React.forwardRef(function (_ref, outerRef) {
3196
3219
 
3197
3220
  useEffect(function () {
3198
3221
  if (!lastIsEditable) {
3199
- setFormValue(_without([_cancelEditable.current], formValue).concat(""));
3222
+ if (recentlyAdded.get() !== _cancelEditable.current) {
3223
+ setFormValue(_without([_cancelEditable.current], formValue).concat(""));
3224
+ } else {
3225
+ setLocalFormValue(_last(formValue) === "" ? formValue : formValue.concat(""));
3226
+ }
3227
+
3200
3228
  _cancelEditable.current = null;
3201
3229
  }
3202
3230
  }, [lastIsEditable]);
@@ -3259,8 +3287,8 @@ var AutoComplete = React.forwardRef(function (_ref, outerRef) {
3259
3287
 
3260
3288
  var addValue = function addValue(value, fromBlur) {
3261
3289
  var index = Math.max(lastIsEditable ? getValue().length - 1 : getValue().length, 0);
3290
+ recentlyAdded.set((formValue === null || formValue === void 0 ? void 0 : formValue[index]) || "");
3262
3291
  setFormValue(_flow(_set([index], value), _concat(_concat.placeholder, "")));
3263
- recentlyAdded.set(true);
3264
3292
 
3265
3293
  if (!fromBlur) {
3266
3294
  focusInput();
@@ -3537,7 +3565,6 @@ function (_React$Component) {
3537
3565
  setTimeout(function () {
3538
3566
  return window.dispatchEvent(event);
3539
3567
  }, 1);
3540
- console.log(this.el, this.el.innerHTML);
3541
3568
 
3542
3569
  if (this.el.innerHTML === '<br>' || !this.el.innerHTML) {
3543
3570
  this.props.onChange(this.props.index, '');
@@ -4211,7 +4238,7 @@ var EditableBox = function EditableBox(_ref17) {
4211
4238
  var internalBox = React.useRef();
4212
4239
 
4213
4240
  var resetField = function resetField() {
4214
- return path ? form.resetField([].concat(path)) : form.resetForm();
4241
+ return path ? form.resetField(_s.toPath(path)) : form.resetForm();
4215
4242
  };
4216
4243
 
4217
4244
  var _onClose = function _onClose(skipReset) {
@@ -4586,6 +4613,16 @@ CheckboxGroup.createCheckManager = function () {
4586
4613
  };
4587
4614
  };
4588
4615
 
4616
+ function _templateObject3$3() {
4617
+ var data = _taggedTemplateLiteral(["\n font-size: 13px; \n "]);
4618
+
4619
+ _templateObject3$3 = function _templateObject3() {
4620
+ return data;
4621
+ };
4622
+
4623
+ return data;
4624
+ }
4625
+
4589
4626
  function _templateObject2$3() {
4590
4627
  var data = _taggedTemplateLiteral(["\n line-height: 42px;\n width: 2.25rem;\n "]);
4591
4628
 
@@ -4671,6 +4708,14 @@ var ClearButton = styled(Icon).withConfig({
4671
4708
  displayName: "DatePicker__ClearButton",
4672
4709
  componentId: "sc-1wo8j4d-12"
4673
4710
  })(["color:", ";font-size:12px;position:absolute;right:40px;bottom:0;transform:translateY(-50%);cursor:pointer;width:1.5rem;line-height:1.5rem;text-align:center;border-radius:50%;background:rgba(0,0,0,0.1);:hover{background:#f7d3d4;color:", ";}"], getColor('gray90'), getColor('alert'));
4711
+ var InputAndIconWrapper = styled.div.withConfig({
4712
+ displayName: "DatePicker__InputAndIconWrapper",
4713
+ componentId: "sc-1wo8j4d-13"
4714
+ })(["position:relative;"]);
4715
+ var ShortcutsWrapper = styled.div.withConfig({
4716
+ displayName: "DatePicker__ShortcutsWrapper",
4717
+ componentId: "sc-1wo8j4d-14"
4718
+ })(["display:flex;flex-wrap:wrap;gap:0.5rem;padding:0.5rem 0.25rem 0;color:", ";.link{cursor:pointer;font-weight:600;text-decoration:underline;", ":hover{color:", ";}", "}"], getColor('gray150'), media.mobile(_templateObject3$3()), getColor('main'), ifProp('disabled', css$1(["pointer-events:none;opacity:0.5;"])));
4674
4719
 
4675
4720
  var KeyMapper = function KeyMapper(level) {
4676
4721
  var upDownSpacing = level === CALENDAR_LEVEL_DAY ? 7 : 3;
@@ -4723,7 +4768,9 @@ var DatePicker = forwardRef(function (_ref, maybeInputRef) {
4723
4768
  raw = _ref.raw,
4724
4769
  disabled = _ref.disabled,
4725
4770
  level = _ref.level,
4726
- rest = _objectWithoutProperties(_ref, ["format", "min", "max", "weekStartsMonday", "label", "mandatory", "tabIndex", "helpText", "path", "timezoneOffset", "placeholder", "onBlur", "raw", "disabled", "level"]);
4771
+ daysFromNowShortcuts = _ref.daysFromNowShortcuts,
4772
+ monthsFromNowShortcuts = _ref.monthsFromNowShortcuts,
4773
+ rest = _objectWithoutProperties(_ref, ["format", "min", "max", "weekStartsMonday", "label", "mandatory", "tabIndex", "helpText", "path", "timezoneOffset", "placeholder", "onBlur", "raw", "disabled", "level", "daysFromNowShortcuts", "monthsFromNowShortcuts"]);
4727
4774
 
4728
4775
  var inputRef = useEnsureRef(maybeInputRef);
4729
4776
 
@@ -4764,6 +4811,21 @@ var DatePicker = forwardRef(function (_ref, maybeInputRef) {
4764
4811
  }, 1);
4765
4812
  }
4766
4813
  }, [textValue]);
4814
+ var isShortcutsEnabled = !!daysFromNowShortcuts && daysFromNowShortcuts.length > 0 || !!monthsFromNowShortcuts && monthsFromNowShortcuts.length > 0;
4815
+
4816
+ var setDateToNDaysFromNow = function setDateToNDaysFromNow(daysFromNow) {
4817
+ var date = new Date(now());
4818
+ date.setUTCDate(date.getUTCDate() + daysFromNow);
4819
+ setFormValue(date.getTime());
4820
+ updateText(date);
4821
+ };
4822
+
4823
+ var setDateToNMonthsFromNow = function setDateToNMonthsFromNow(monthsFromNow) {
4824
+ var date = new Date(now());
4825
+ date.setUTCMonth(date.getUTCMonth() + monthsFromNow);
4826
+ setFormValue(date.getTime());
4827
+ updateText(date);
4828
+ };
4767
4829
 
4768
4830
  var setTextValue = function setTextValue(textValue) {
4769
4831
  var value = formValue === -1 || isNaN(formValue) ? now() : new Date(Number(formValue));
@@ -4884,7 +4946,7 @@ var DatePicker = forwardRef(function (_ref, maybeInputRef) {
4884
4946
  onClick: onClick,
4885
4947
  onFocus: popup.open,
4886
4948
  onBlur: _onBlur
4887
- }, React.createElement(TextInput$1, {
4949
+ }, React.createElement(InputAndIconWrapper, null, React.createElement(TextInput$1, {
4888
4950
  raw: true,
4889
4951
  disabled: disabled,
4890
4952
  type: getNumberInputType(),
@@ -4901,8 +4963,27 @@ var DatePicker = forwardRef(function (_ref, maybeInputRef) {
4901
4963
  onFocus: stopFocusPropagation,
4902
4964
  disabled: disabled,
4903
4965
  onClick: iconClick,
4904
- icon: "calendar"
4905
- }), popup.isOpen && React.createElement(DatePickerCalendar, {
4966
+ icon: "calendar",
4967
+ className: isShortcutsEnabled ? "hasShortcuts" : ""
4968
+ })), (daysFromNowShortcuts === null || daysFromNowShortcuts === void 0 ? void 0 : daysFromNowShortcuts.length) > 0 || (monthsFromNowShortcuts === null || monthsFromNowShortcuts === void 0 ? void 0 : monthsFromNowShortcuts.length) > 0 ? React.createElement(ShortcutsWrapper, null, React.createElement("span", null, "Em:"), daysFromNowShortcuts === null || daysFromNowShortcuts === void 0 ? void 0 : daysFromNowShortcuts.map(function (daysFromNow) {
4969
+ return React.createElement("span", {
4970
+ class: "link",
4971
+ key: "days-from-now-".concat(daysFromNow),
4972
+ onClick: function onClick() {
4973
+ return setDateToNDaysFromNow(daysFromNow);
4974
+ },
4975
+ disabled: disabled
4976
+ }, daysFromNow, " dia", daysFromNow > 1 ? 's' : '');
4977
+ }), monthsFromNowShortcuts === null || monthsFromNowShortcuts === void 0 ? void 0 : monthsFromNowShortcuts.map(function (monthsFromNow) {
4978
+ return React.createElement("span", {
4979
+ class: "link",
4980
+ key: "months-from-now".concat(monthsFromNow),
4981
+ onClick: function onClick() {
4982
+ return setDateToNMonthsFromNow(monthsFromNow);
4983
+ },
4984
+ disabled: disabled
4985
+ }, monthsFromNow, " ", monthsFromNow > 1 ? 'meses' : 'mês');
4986
+ })) : null, popup.isOpen && React.createElement(DatePickerCalendar, {
4906
4987
  raw: true,
4907
4988
  min: min,
4908
4989
  max: max,
@@ -5656,7 +5737,7 @@ var RichTextContainer = styled.div.withConfig({
5656
5737
  var RichTextInput = styled.div.withConfig({
5657
5738
  displayName: "RichText__RichTextInput",
5658
5739
  componentId: "x8c1ig-2"
5659
- })(["width:100%;font-size:14px;outline:0;outline:none;color:", ";background:white;min-height:", "px;outline:0;padding:0.7rem;overflow:auto;border-radius:5px;b,strong{font-weight:600;}&[contenteditable=true]:empty:before{content:attr(placeholder);color:rgba(0,0,0,0.3);}", ""], getColor('gray60'), function (props) {
5740
+ })(["font-size:14px;color:", ";background:white;border-radius:5px;> div{overflow:auto;width:100%;outline:none;min-height:", "px;padding:0.7rem;}b,strong{font-weight:600;}&[contenteditable=true]:empty:before{content:attr(placeholder);color:rgba(0,0,0,0.3);}", ""], getColor('gray60'), function (props) {
5660
5741
  return props.minHeight || 78;
5661
5742
  }, function (props) {
5662
5743
  return props.disabled && "\n &[disabled] {\n background: rgba(0, 0, 0, 0.075) !important;\n opacity: 0.75 !important;\n }\n ";
@@ -5696,14 +5777,6 @@ var addHttp = function addHttp(s) {
5696
5777
  }
5697
5778
  };
5698
5779
 
5699
- var getRightMostElement = function getRightMostElement(node) {
5700
- if (node.childNodes.length) {
5701
- return getRightMostElement(node.childNodes[node.childNodes.length - 1]);
5702
- } else {
5703
- return node;
5704
- }
5705
- };
5706
-
5707
5780
  var setSelectionRange$1 = function setSelectionRange(input, selectionStart) {
5708
5781
  var selectionEnd = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
5709
5782
  if (!input) return;
@@ -5902,14 +5975,17 @@ var RichText = function RichText(_ref5) {
5902
5975
  }, raw),
5903
5976
  _useInput2 = _slicedToArray(_useInput, 3),
5904
5977
  formValue = _useInput2[0],
5905
- setFormValue = _useInput2[1],
5978
+ _setFormValue = _useInput2[1],
5906
5979
  hasErrors = _useInput2[2].hasErrors; // const tempValue = useConstant(formValue)
5907
5980
 
5908
5981
 
5909
- var _useState = useState(formValue),
5910
- _useState2 = _slicedToArray(_useState, 2),
5911
- tempValue = _useState2[0],
5912
- setTempValue = _useState2[1];
5982
+ var tempValue = useRef(formValue);
5983
+
5984
+ var setFormValue = function setFormValue(v) {
5985
+ tempValue.current = v;
5986
+
5987
+ _setFormValue(v);
5988
+ };
5913
5989
 
5914
5990
  useEffect(function () {
5915
5991
  if (value === formValue && formValue !== tempValue) {
@@ -5917,10 +5993,10 @@ var RichText = function RichText(_ref5) {
5917
5993
  }
5918
5994
  }, [path]);
5919
5995
 
5920
- var _useState3 = useState({}),
5921
- _useState4 = _slicedToArray(_useState3, 2),
5922
- activatedTools = _useState4[0],
5923
- setActivatedTools = _useState4[1];
5996
+ var _useState = useState({}),
5997
+ _useState2 = _slicedToArray(_useState, 2),
5998
+ activatedTools = _useState2[0],
5999
+ setActivatedTools = _useState2[1];
5924
6000
 
5925
6001
  var validElements = useLazyConstant(function () {
5926
6002
  return ['br', 'div', 'p', 'span'].concat(_flatten(formatTools.map(function (tool) {
@@ -6044,6 +6120,7 @@ var RichText = function RichText(_ref5) {
6044
6120
  }
6045
6121
  }
6046
6122
 
6123
+ tempValue.current = input.current.innerHTML;
6047
6124
  openDialog(nodeEl);
6048
6125
  } else {
6049
6126
  if (!isSelectionInsideRichTextEditor()) {
@@ -6177,67 +6254,24 @@ var RichText = function RichText(_ref5) {
6177
6254
  };
6178
6255
 
6179
6256
  var handleKeyDown = function handleKeyDown(e) {
6180
- if (linkJustCreated.current && e.which === 8) {
6181
- linkJustCreated.current.outerHTML = linkJustCreated.current.innerHTML;
6182
- input.current.normalize();
6183
- return;
6184
- }
6185
-
6186
- commands.set([]);
6187
- linkJustCreated.set(null);
6188
- var selectedRange = window.getSelection().getRangeAt(0);
6189
- if (!selectedRange) return;
6190
- var possibleTextNode = selectedRange.startContainer;
6191
- var node = possibleTextNode.nodeType === Node.TEXT_NODE ? possibleTextNode.parentNode : possibleTextNode;
6192
- var parent = node.closest('a,.' + JS_CLASS);
6193
-
6194
- if ((e.key === 'Enter' || e.which === 32) && parent && parent.matches('.' + JS_CLASS)) {
6195
- var range = document.createRange();
6196
- range.setEnd(selectedRange.startContainer, selectedRange.startOffset);
6197
- range.setStart(selectedRange.startContainer, 0);
6198
- traverseAndAddLink(range);
6199
- }
6200
- };
6201
-
6202
- var traverseAndAddLink = function traverseAndAddLink(range) {
6203
- var match = range.toString().match(/[\s\t\n\r]([^\s\t\n\r]*)$/);
6204
-
6205
- if (match) {
6206
- if (/^(https?:\/\/|www\.)/.test(match[1]) && linkRegex.test(match[1])) {
6207
- range.setStart(range.startContainer, match.index + 1);
6208
- range.endContainer.splitText(range.endContainer.textContent.length - 1);
6209
- var newNode = document.createElement('a');
6210
- newNode.href = match[1];
6211
- newNode.appendChild(range.extractContents());
6212
- range.insertNode(newNode);
6213
- window.getSelection().getRangeAt(0).setEndAfter(newNode);
6214
- window.getSelection().getRangeAt(0).setStartAfter(newNode);
6215
- linkJustCreated.set(newNode);
6216
- }
6217
- } else {
6218
- var previous = getPreviousElement(range.startContainer);
6219
-
6220
- if (previous) {
6221
- range.setStart(previous, 0);
6222
- traverseAndAddLink(range);
6223
- }
6224
- }
6225
- };
6226
-
6227
- var getPreviousElement = function getPreviousElement(node) {
6228
- if (node.previousSibling) {
6229
- var rightMost = getRightMostElement(node.previousSibling);
6230
-
6231
- if (rightMost.nodeType === Node.TEXT_NODE) {
6232
- return rightMost;
6233
- } else {
6234
- return getPreviousElement(rightMost);
6235
- }
6236
- } else if (node.parentNode && node !== input.current) {
6237
- return getPreviousElement(node.parentNode);
6238
- } else {
6239
- return null;
6240
- }
6257
+ /*if (linkJustCreated.current && e.which === 8) {
6258
+ linkJustCreated.current.outerHTML = linkJustCreated.current.innerHTML
6259
+ input.current.normalize()
6260
+ return
6261
+ }
6262
+ commands.set([])
6263
+ linkJustCreated.set(null)
6264
+ const selectedRange = window.getSelection().getRangeAt(0)
6265
+ if (!selectedRange) return
6266
+ const possibleTextNode = selectedRange.startContainer
6267
+ const node = possibleTextNode.nodeType === Node.TEXT_NODE ? possibleTextNode.parentNode : possibleTextNode
6268
+ const parent = node.closest('a,.'+JS_CLASS)
6269
+ if ((e.key === 'Enter' || e.which === 32) && parent && parent.matches('.'+JS_CLASS)) {
6270
+ const range = document.createRange()
6271
+ range.setEnd(selectedRange.startContainer, selectedRange.startOffset)
6272
+ range.setStart(selectedRange.startContainer, 0)
6273
+ traverseAndAddLink(range)
6274
+ }*/
6241
6275
  };
6242
6276
 
6243
6277
  var handlePasteDrop = function handlePasteDrop(e) {
@@ -6324,8 +6358,10 @@ var RichText = function RichText(_ref5) {
6324
6358
  key: "separator-" + i
6325
6359
  }) : toolButton(t);
6326
6360
  })), React.createElement(RichTextInput, {
6327
- contentEditable: !disabled,
6328
- ref: input,
6361
+ className: JS_CLASS
6362
+ }, React.createElement(ContentEditable, {
6363
+ innerRef: input,
6364
+ html: tempValue.current,
6329
6365
  onBlur: onBlur,
6330
6366
  onClick: handleClick,
6331
6367
  onKeyUp: handleKeyUp,
@@ -6333,14 +6369,10 @@ var RichText = function RichText(_ref5) {
6333
6369
  onPaste: handlePasteDrop,
6334
6370
  onDrop: handlePasteDrop,
6335
6371
  tabIndex: tabIndex,
6336
- dangerouslySetInnerHTML: {
6337
- __html: tempValue
6338
- },
6339
6372
  disabled: disabled,
6340
- className: JS_CLASS,
6341
6373
  minHeight: minHeight,
6342
6374
  placeholder: placeholder
6343
- }), locked && React.createElement(InputIcon, {
6375
+ })), locked && React.createElement(InputIcon, {
6344
6376
  icon: "lock"
6345
6377
  }), linkPopup.isOpen && React.createElement(EditLinkPopup, {
6346
6378
  input: input,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@startlibs/form",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "Startlibs Form",
5
5
  "main": "lib/index.js",
6
6
  "sideEffects": false,