@pareto-engineering/design-system 5.1.2 → 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.
- package/dist/cjs/f/fields/EditorInput/EditorInput.js +8 -1
- package/dist/cjs/f/fields/EditorInput/common/ExposePlainTextPlugin.js +7 -0
- package/dist/es/f/fields/EditorInput/EditorInput.js +8 -1
- package/dist/es/f/fields/EditorInput/common/ExposePlainTextPlugin.js +7 -0
- package/package.json +2 -2
- package/src/ui/f/fields/EditorInput/EditorInput.jsx +7 -0
- package/src/ui/f/fields/EditorInput/common/ExposePlainTextPlugin.jsx +8 -0
|
@@ -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,
|
|
@@ -18,6 +18,13 @@ const ExposePlainTextPlugin = _ref => {
|
|
|
18
18
|
setPlainTextKey
|
|
19
19
|
} = _ref;
|
|
20
20
|
const [editor] = (0, _LexicalComposerContext.useLexicalComposerContext)();
|
|
21
|
+
(0, _react.useEffect)(() => {
|
|
22
|
+
editor.update(() => {
|
|
23
|
+
const root = (0, _lexical.$getRoot)();
|
|
24
|
+
const textContent = root.getTextContent();
|
|
25
|
+
setFieldValue(setPlainTextKey, textContent);
|
|
26
|
+
});
|
|
27
|
+
}, []);
|
|
21
28
|
(0, _react.useEffect)(() => editor.registerUpdateListener(_ref2 => {
|
|
22
29
|
let {
|
|
23
30
|
editorState
|
|
@@ -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,
|
|
@@ -11,6 +11,13 @@ const ExposePlainTextPlugin = ({
|
|
|
11
11
|
setPlainTextKey
|
|
12
12
|
}) => {
|
|
13
13
|
const [editor] = useLexicalComposerContext();
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
editor.update(() => {
|
|
16
|
+
const root = $getRoot();
|
|
17
|
+
const textContent = root.getTextContent();
|
|
18
|
+
setFieldValue(setPlainTextKey, textContent);
|
|
19
|
+
});
|
|
20
|
+
}, []);
|
|
14
21
|
useEffect(() => editor.registerUpdateListener(({
|
|
15
22
|
editorState
|
|
16
23
|
}) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pareto-engineering/design-system",
|
|
3
|
-
"version": "5.
|
|
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": "
|
|
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 = {
|
|
@@ -17,6 +17,14 @@ const ExposePlainTextPlugin = ({
|
|
|
17
17
|
}) => {
|
|
18
18
|
const [editor] = useLexicalComposerContext()
|
|
19
19
|
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
editor.update(() => {
|
|
22
|
+
const root = $getRoot()
|
|
23
|
+
const textContent = root.getTextContent()
|
|
24
|
+
setFieldValue(setPlainTextKey, textContent)
|
|
25
|
+
})
|
|
26
|
+
}, [])
|
|
27
|
+
|
|
20
28
|
useEffect(() => (
|
|
21
29
|
editor.registerUpdateListener(({ editorState }) => {
|
|
22
30
|
editorState.read(() => {
|