@onesy/ui-react 1.0.44 → 1.0.45

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.
@@ -200,7 +200,7 @@ const SmartTextField = react_1.default.forwardRef((props_, ref) => {
200
200
  setOptionsMention([...(optionsMention_ || [])]);
201
201
  }, [(0, utils_1.hash)(optionsMention_)]);
202
202
  react_1.default.useEffect(() => {
203
- const valuePrevious = (refs.root.current.innerHTML || '').replaceAll(' ', ' ');
203
+ const valuePrevious = (0, utils_2.decodeHTMLEntities)(refs.root.current.innerHTML || '').replaceAll(' ', ' ');
204
204
  const valueNew = (0, utils_1.textToInnerHTML)(value_);
205
205
  if (value_ !== undefined && valuePrevious !== valueNew)
206
206
  validate(!value_ ? '' : (0, utils_2.sanitize)(value_));
@@ -287,7 +287,7 @@ const SmartTextField = react_1.default.forwardRef((props_, ref) => {
287
287
  refs.search.current = getAtSearchData();
288
288
  const onInput = react_1.default.useCallback((event) => {
289
289
  if (refs.root.current) {
290
- let valueInput = refs.root.current.innerHTML || '';
290
+ let valueInput = (0, utils_2.decodeHTMLEntities)(refs.root.current.innerHTML || '');
291
291
  if (refs.root.current.textContent === '') {
292
292
  valueInput = '';
293
293
  refs.root.current.innerHTML = '';
@@ -453,7 +453,7 @@ const SmartTextField = react_1.default.forwardRef((props_, ref) => {
453
453
  // Remove the text node
454
454
  textNode.remove();
455
455
  // Invoke onChange method with new value
456
- const valueInput = (0, utils_1.innerHTMLToText)(refs.root.current.innerHTML);
456
+ const valueInput = (0, utils_1.innerHTMLToText)((0, utils_2.decodeHTMLEntities)(refs.root.current.innerHTML));
457
457
  if ((0, utils_1.is)('function', refs.onChange.current))
458
458
  refs.onChange.current(valueInput, { target: refs.root.current });
459
459
  // Update the caret position to be outside the span mention
@@ -32,7 +32,7 @@ import ToggleButtonElement from '../ToggleButton';
32
32
  import ClickListenerElement from '../ClickListener';
33
33
  import ToggleButtonsElement from '../ToggleButtons';
34
34
  import MenuElement from '../Menu';
35
- import { sanitize, caret, keyboardStyleCommands, staticClassName } from '../utils';
35
+ import { sanitize, caret, keyboardStyleCommands, staticClassName, decodeHTMLEntities } from '../utils';
36
36
  const useStyle = styleMethod(theme => ({
37
37
  root: {
38
38
  minHeight: '20px',
@@ -226,7 +226,7 @@ const SmartTextField = /*#__PURE__*/React.forwardRef((props_, ref) => {
226
226
  setOptionsMention([...(optionsMention_ || [])]);
227
227
  }, [hash(optionsMention_)]);
228
228
  React.useEffect(() => {
229
- const valuePrevious = (refs.root.current.innerHTML || '').replaceAll(' ', ' ');
229
+ const valuePrevious = decodeHTMLEntities(refs.root.current.innerHTML || '').replaceAll(' ', ' ');
230
230
  const valueNew = textToInnerHTML(value_);
231
231
  if (value_ !== undefined && valuePrevious !== valueNew) validate(!value_ ? '' : sanitize(value_));
232
232
  }, [value_]);
@@ -306,7 +306,7 @@ const SmartTextField = /*#__PURE__*/React.forwardRef((props_, ref) => {
306
306
  refs.search.current = getAtSearchData();
307
307
  const onInput = React.useCallback(event => {
308
308
  if (refs.root.current) {
309
- let valueInput = refs.root.current.innerHTML || '';
309
+ let valueInput = decodeHTMLEntities(refs.root.current.innerHTML || '');
310
310
  if (refs.root.current.textContent === '') {
311
311
  valueInput = '';
312
312
  refs.root.current.innerHTML = '';
@@ -471,7 +471,7 @@ const SmartTextField = /*#__PURE__*/React.forwardRef((props_, ref) => {
471
471
  textNode.remove();
472
472
 
473
473
  // Invoke onChange method with new value
474
- const valueInput = innerHTMLToText(refs.root.current.innerHTML);
474
+ const valueInput = innerHTMLToText(decodeHTMLEntities(refs.root.current.innerHTML));
475
475
  if (is('function', refs.onChange.current)) refs.onChange.current(valueInput, {
476
476
  target: refs.root.current
477
477
  });
package/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license UiReact v1.0.44
1
+ /** @license UiReact v1.0.45
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
package/esm/utils.js CHANGED
@@ -1253,4 +1253,8 @@ export const currencies = [{
1253
1253
  rounding: 0,
1254
1254
  code: 'ZMK',
1255
1255
  name_plural: 'Zambian kwachas'
1256
- }];
1256
+ }];
1257
+ export const decodeHTMLEntities = html => {
1258
+ const document = new DOMParser().parseFromString(html, 'text/html');
1259
+ return document.documentElement.textContent || '';
1260
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onesy/ui-react",
3
- "version": "1.0.44",
3
+ "version": "1.0.45",
4
4
  "description": "UI for React",
5
5
  "repository": "https://github.com/onesy-me/onesy.git",
6
6
  "author": "Lazar <lazareric2@gmail.com>",
package/utils.d.ts CHANGED
@@ -46,3 +46,4 @@ export declare const currencies: {
46
46
  code: string;
47
47
  name_plural: string;
48
48
  }[];
49
+ export declare const decodeHTMLEntities: (html: string) => string;
package/utils.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.currencies = exports.iconFontSize = exports.formats = exports.toNumber = exports.caret = exports.keyboardStyleCommands = exports.keyboardStandardCommands = exports.getOverflowParent = exports.importIframeStyles = exports.replace = exports.sanitize = exports.minMaxBetweenNumbers = exports.controlPoint = exports.line = exports.angleToCoordinates = exports.matches = exports.save = exports.print = exports.canvasOldPhoto = exports.canvasInvert = exports.canvasFade = exports.canvasSaturation = exports.canvasContrast = exports.canvasBrightness = exports.image = exports.valueBreakpoints = exports.iconSizeToFontSize = exports.staticClassName = exports.reflow = void 0;
3
+ exports.decodeHTMLEntities = exports.currencies = exports.iconFontSize = exports.formats = exports.toNumber = exports.caret = exports.keyboardStyleCommands = exports.keyboardStandardCommands = exports.getOverflowParent = exports.importIframeStyles = exports.replace = exports.sanitize = exports.minMaxBetweenNumbers = exports.controlPoint = exports.line = exports.angleToCoordinates = exports.matches = exports.save = exports.print = exports.canvasOldPhoto = exports.canvasInvert = exports.canvasFade = exports.canvasSaturation = exports.canvasContrast = exports.canvasBrightness = exports.image = exports.valueBreakpoints = exports.iconSizeToFontSize = exports.staticClassName = exports.reflow = void 0;
4
4
  const utils_1 = require("@onesy/utils");
5
5
  function reflow(element) {
6
6
  element === null || element === void 0 ? void 0 : element.offsetHeight;
@@ -1420,3 +1420,8 @@ exports.currencies = [
1420
1420
  name_plural: 'Zambian kwachas'
1421
1421
  }
1422
1422
  ];
1423
+ const decodeHTMLEntities = (html) => {
1424
+ const document = new DOMParser().parseFromString(html, 'text/html');
1425
+ return document.documentElement.textContent || '';
1426
+ };
1427
+ exports.decodeHTMLEntities = decodeHTMLEntities;