@pareto-engineering/design-system 5.1.3 → 5.2.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.
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
  var _react = _interopRequireWildcard(require("react"));
8
8
  var React = _react;
9
+ var _lexical = require("lexical");
9
10
  var _formik = require("formik");
10
11
  var _LexicalComposer = require("@lexical/react/LexicalComposer");
11
12
  var _LexicalRichTextPlugin = require("@lexical/react/LexicalRichTextPlugin");
@@ -68,7 +69,8 @@ const EditorInput = _ref2 => {
68
69
  disabled,
69
70
  showDebugger,
70
71
  setEditorState,
71
- setPlainTextKey
72
+ setPlainTextKey,
73
+ validate
72
74
  // ...otherProps
73
75
  } = _ref2;
74
76
  const [field,,] = (0, _formik.useField)(name);
@@ -115,6 +117,11 @@ const EditorInput = _ref2 => {
115
117
  };
116
118
  const onChange = state => {
117
119
  setFieldValue(name, JSON.stringify(state));
120
+ validate?.(state.read(() => {
121
+ const root = (0, _lexical.$getRoot)();
122
+ const textContent = root.getTextContent();
123
+ return textContent;
124
+ }));
118
125
  };
119
126
  const initialConfig = {
120
127
  nameSpace: name,
@@ -2,6 +2,7 @@
2
2
  /* eslint-disable import/no-extraneous-dependencies -- required here */
3
3
  import * as React from 'react';
4
4
  import { memo, useEffect } from 'react';
5
+ import { $getRoot } from 'lexical';
5
6
  import { useField, useFormikContext } from 'formik';
6
7
  import { LexicalComposer } from '@lexical/react/LexicalComposer';
7
8
  import { RichTextPlugin } from '@lexical/react/LexicalRichTextPlugin';
@@ -57,7 +58,8 @@ const EditorInput = ({
57
58
  disabled,
58
59
  showDebugger,
59
60
  setEditorState,
60
- setPlainTextKey
61
+ setPlainTextKey,
62
+ validate
61
63
  // ...otherProps
62
64
  }) => {
63
65
  const [field,,] = useField(name);
@@ -104,6 +106,11 @@ const EditorInput = ({
104
106
  };
105
107
  const onChange = state => {
106
108
  setFieldValue(name, JSON.stringify(state));
109
+ validate?.(state.read(() => {
110
+ const root = $getRoot();
111
+ const textContent = root.getTextContent();
112
+ return textContent;
113
+ }));
107
114
  };
108
115
  const initialConfig = {
109
116
  nameSpace: name,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pareto-engineering/design-system",
3
- "version": "5.1.3",
3
+ "version": "5.2.0",
4
4
  "description": "",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/es/index.js",
@@ -87,5 +87,5 @@
87
87
  "remark-math": "^6.0.0"
88
88
  },
89
89
  "browserslist": "> 2%",
90
- "gitHead": "69430d231ad4a47353233b67c9368db91758ad14"
90
+ "gitHead": "2f0f3c933a23635520aebf9b3bb932a4063c432e"
91
91
  }
@@ -2,6 +2,7 @@
2
2
  /* eslint-disable import/no-extraneous-dependencies -- required here */
3
3
  import * as React from 'react'
4
4
  import { memo, useEffect } from 'react'
5
+ import { $getRoot } from 'lexical'
5
6
  import { useField, useFormikContext } from 'formik'
6
7
  import { LexicalComposer } from '@lexical/react/LexicalComposer'
7
8
  import { RichTextPlugin } from '@lexical/react/LexicalRichTextPlugin'
@@ -66,6 +67,7 @@ const EditorInput = ({
66
67
  showDebugger,
67
68
  setEditorState,
68
69
  setPlainTextKey,
70
+ validate,
69
71
  // ...otherProps
70
72
  }) => {
71
73
  const [field, ,] = useField(name)
@@ -116,6 +118,11 @@ const EditorInput = ({
116
118
 
117
119
  const onChange = (state) => {
118
120
  setFieldValue(name, JSON.stringify(state))
121
+ validate?.(state.read(() => {
122
+ const root = $getRoot()
123
+ const textContent = root.getTextContent()
124
+ return textContent
125
+ }))
119
126
  }
120
127
 
121
128
  const initialConfig = {