@rhc-shared-components/rich-text-editor 0.7.0 → 1.0.1

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/package.json CHANGED
@@ -1,80 +1,63 @@
1
1
  {
2
2
  "name": "@rhc-shared-components/rich-text-editor",
3
- "version": "0.7.0",
3
+ "version": "1.0.1",
4
4
  "description": "WYSWYG Editor for Red Hat Certified Apps",
5
5
  "author": "gautamkrishnar",
6
6
  "license": "MIT",
7
- "repository": "https://gitlab.cee.redhat.com/customer-platform/rhc-shared-components/",
8
- "main": "dist/index.js",
9
- "module": "dist/index.modern.js",
10
- "source": "src/index.tsx",
11
- "types": "dist/index.d.ts",
12
- "engines": {
13
- "node": ">=10"
7
+ "type": "module",
8
+ "main": "./dist/index.js",
9
+ "types": "./dist/index.d.ts",
10
+ "exports": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js",
13
+ "default": "./dist/index.js"
14
14
  },
15
+ "files": [
16
+ "dist",
17
+ "README.md"
18
+ ],
15
19
  "scripts": {
16
- "build": "microbundle --css inline --no-sourcemap --no-compress --format modern,cjs --jsx React.createElement",
17
- "clean": "rimraf dist",
18
- "prepare": "run-s clean build",
19
- "start": "microbundle watch --css inline --no-compress --format modern,cjs --jsx React.createElement",
20
- "test": "run-s test:unit test:lint test:build",
21
- "test:build": "run-s build",
22
- "test:lint": "eslint src --ext .js,.jsx,.ts,.tsx --fix",
23
- "test:unit": "cross-env CI=1 react-scripts test --env=jsdom",
24
- "test:watch": "react-scripts test --env=jsdom",
25
- "predeploy": "cd example && yarn install && yarn run build",
26
- "deploy": "gh-pages -d example/build"
20
+ "dev": "vite",
21
+ "build": "tsc -b ./tsconfig.lib.json && vite build",
22
+ "lint": "eslint .",
23
+ "lint-fix": "eslint --fix .",
24
+ "preview": "vite preview"
27
25
  },
28
26
  "peerDependencies": {
29
- "@patternfly/react-core": ">=4.101.3",
27
+ "@patternfly/react-core": ">=5.3.4",
30
28
  "formik": ">=2.1.4",
31
29
  "react": ">=16.13.1",
32
30
  "react-dom": ">=16.13.1"
33
31
  },
34
- "devDependencies": {
35
- "@rhc-shared-components/form-group-container": "^1.0.1",
36
- "@testing-library/jest-dom": "^4.2.4",
37
- "@testing-library/react": "^9.5.0",
38
- "@testing-library/user-event": "^7.2.1",
39
- "@types/ckeditor": "^4.9.10",
40
- "@types/jest": "^25.1.4",
41
- "@types/node": "^12.12.38",
42
- "@typescript-eslint/eslint-plugin": "^2.26.0",
43
- "@typescript-eslint/parser": "^2.26.0",
44
- "babel-eslint": "^10.0.3",
45
- "cross-env": "^7.0.2",
46
- "eslint": "^6.8.0",
47
- "eslint-config-prettier": "^6.7.0",
48
- "eslint-config-standard": "^14.1.0",
49
- "eslint-config-standard-react": "^9.2.0",
50
- "eslint-plugin-import": "^2.18.2",
51
- "eslint-plugin-node": "^11.0.0",
52
- "eslint-plugin-prettier": "^3.1.1",
53
- "eslint-plugin-promise": "^4.2.1",
54
- "eslint-plugin-react": "^7.17.0",
55
- "eslint-plugin-standard": "^4.0.1",
56
- "gh-pages": "^2.2.0",
57
- "microbundle": "^0.13.3",
58
- "npm-run-all": "^4.1.5",
59
- "prettier": "^2.0.4",
60
- "react-scripts": "^3.4.1",
61
- "rimraf": "^3.0.2",
62
- "sass": "^1.57.1",
63
- "typescript": "^3.7.5"
64
- },
65
32
  "publishConfig": {
66
33
  "access": "public"
67
34
  },
68
- "files": [
69
- "dist"
70
- ],
71
- "dependencies": {
35
+ "devDependencies": {
72
36
  "@ckeditor/ckeditor5-react": "^3.0.2",
73
- "@patternfly/react-core": "^4.276.6",
37
+ "@eslint/js": "^9.19.0",
38
+ "@patternfly/react-core": "^5.3.3",
39
+ "@patternfly/react-icons": "^5.3.2",
74
40
  "@rhc-shared-components/rhc-ckeditor": "^1.0.2",
41
+ "@types/ckeditor": "^4.9.10",
42
+ "@types/node": "^22.13.4",
43
+ "@types/react": "^16.9.27",
44
+ "@types/react-dom": "^16.9.7",
45
+ "@vitejs/plugin-react": "^4.3.4",
46
+ "eslint": "^9.19.0",
47
+ "eslint-config-prettier": "^10.0.1",
48
+ "eslint-plugin-prettier": "^5.2.3",
49
+ "eslint-plugin-react-hooks": "^5.0.0",
50
+ "eslint-plugin-react-refresh": "^0.4.18",
75
51
  "formik": "^2.1.4",
52
+ "globals": "^15.14.0",
53
+ "prettier": "^3.5.1",
76
54
  "react": "^16.13.1",
77
- "react-dom": "^16.13.1"
78
- },
79
- "gitHead": "67ea9dbf7065a51b8b3f4058f7820c109670f2a2"
55
+ "react-dom": "^16.13.1",
56
+ "sass": "^1.57.1",
57
+ "typescript": "~5.7.2",
58
+ "typescript-eslint": "^8.22.0",
59
+ "vite": "^6.1.0",
60
+ "vite-plugin-dts": "^4.5.0",
61
+ "vite-plugin-lib-inject-css": "^2.2.1"
62
+ }
80
63
  }
package/CHANGELOG.md DELETED
@@ -1,256 +0,0 @@
1
- # Change Log
2
-
3
- All notable changes to this project will be documented in this file.
4
- See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
-
6
- ## [0.6.2](https://gitlab.cee.redhat.com/customer-platform/rhc-shared-components/compare/@rhc-shared-components/rich-text-editor@0.6.1...@rhc-shared-components/rich-text-editor@0.6.2) (2022-12-06)
7
-
8
- **Note:** Version bump only for package @rhc-shared-components/rich-text-editor
9
-
10
-
11
-
12
-
13
-
14
- ## [0.6.1](https://gitlab.cee.redhat.com/customer-platform/rhc-shared-components/compare/@rhc-shared-components/rich-text-editor@0.6.0...@rhc-shared-components/rich-text-editor@0.6.1) (2022-12-06)
15
-
16
- **Note:** Version bump only for package @rhc-shared-components/rich-text-editor
17
-
18
-
19
-
20
-
21
-
22
- # [0.6.0](https://gitlab.cee.redhat.com/customer-platform/rhc-shared-components/compare/@rhc-shared-components/rich-text-editor@0.4.0...@rhc-shared-components/rich-text-editor@0.6.0) (2022-12-06)
23
-
24
-
25
- ### Bug Fixes
26
-
27
- * fixed onClick bug ([549e009](https://gitlab.cee.redhat.com/customer-platform/rhc-shared-components/commit/549e0094f27976ccb9031c6b2c84efb48f43c808))
28
- * made code block optional ([298a81f](https://gitlab.cee.redhat.com/customer-platform/rhc-shared-components/commit/298a81fbcb44472c323780aaa6b999798bbd565e))
29
- * updated lock ([04a9672](https://gitlab.cee.redhat.com/customer-platform/rhc-shared-components/commit/04a96720866c29b71c8330175ff408ae1daa1863))
30
-
31
-
32
- ### Features
33
-
34
- * migrated to custom build of ckeditor ([f5b3d7a](https://gitlab.cee.redhat.com/customer-platform/rhc-shared-components/commit/f5b3d7adb3305ab70d9c39dec7b5376d7fc1e110))
35
-
36
-
37
-
38
-
39
-
40
- # [0.4.0](https://gitlab.cee.redhat.com/customer-platform/rhc-shared-components/compare/@rhc-shared-components/rich-text-editor@0.2.12...@rhc-shared-components/rich-text-editor@0.4.0) (2022-06-14)
41
-
42
-
43
- ### Bug Fixes
44
-
45
- * added touched flag to validation ([e69be69](https://gitlab.cee.redhat.com/customer-platform/rhc-shared-components/commit/e69be69c901cd84f9f53c1ce2ef7047cd8ead04e))
46
- * fixed max length bug ([c63c798](https://gitlab.cee.redhat.com/customer-platform/rhc-shared-components/commit/c63c79891c16ff23919f09ba681470432a2b3301))
47
- * fixed re init bugs ([b208de0](https://gitlab.cee.redhat.com/customer-platform/rhc-shared-components/commit/b208de0ac998c4fb814cbee4e3e3a8b4c6fe4b05))
48
- * fixing validation errors ([e2d4e61](https://gitlab.cee.redhat.com/customer-platform/rhc-shared-components/commit/e2d4e610ddeefdef6dd39d9cf6000dfab84916c7))
49
- * validation bugs ([cee65e1](https://gitlab.cee.redhat.com/customer-platform/rhc-shared-components/commit/cee65e142bf2dbae06914a4add9915f11118c6af))
50
-
51
-
52
- ### Features
53
-
54
- * added maxlength feature ([564c8fa](https://gitlab.cee.redhat.com/customer-platform/rhc-shared-components/commit/564c8fa69ce2abfdc6eeb01d07330ebcfcbad4a1))
55
-
56
-
57
-
58
-
59
-
60
- ## [0.2.12](https://gitlab.cee.redhat.com/customer-platform/rhc-shared-components/compare/@rhc-shared-components/rich-text-editor@0.2.11...@rhc-shared-components/rich-text-editor@0.2.12) (2021-11-01)
61
-
62
- **Note:** Version bump only for package @rhc-shared-components/rich-text-editor
63
-
64
-
65
-
66
-
67
-
68
- ## [0.2.11](https://gitlab.cee.redhat.com/customer-platform/rhc-shared-components/compare/@rhc-shared-components/rich-text-editor@0.2.10...@rhc-shared-components/rich-text-editor@0.2.11) (2021-11-01)
69
-
70
- **Note:** Version bump only for package @rhc-shared-components/rich-text-editor
71
-
72
-
73
-
74
-
75
-
76
- ## [0.2.10](https://gitlab.cee.redhat.com/customer-platform/rhc-shared-components/compare/@rhc-shared-components/rich-text-editor@0.2.9...@rhc-shared-components/rich-text-editor@0.2.10) (2021-09-29)
77
-
78
- **Note:** Version bump only for package @rhc-shared-components/rich-text-editor
79
-
80
-
81
-
82
-
83
-
84
- ## [0.2.9](https://gitlab.cee.redhat.com/customer-platform/rhc-shared-components/compare/@rhc-shared-components/rich-text-editor@0.2.8...@rhc-shared-components/rich-text-editor@0.2.9) (2021-09-29)
85
-
86
-
87
- ### Bug Fixes
88
-
89
- * fixing minor bug in h3 ([674c21e](https://gitlab.cee.redhat.com/customer-platform/rhc-shared-components/commit/674c21e80156a70763df34887e4e34f951640b40))
90
-
91
-
92
-
93
-
94
-
95
- ## [0.2.8](https://gitlab.cee.redhat.com/customer-platform/rhc-shared-components/compare/@rhc-shared-components/rich-text-editor@0.2.7...@rhc-shared-components/rich-text-editor@0.2.8) (2021-09-28)
96
-
97
-
98
- ### Bug Fixes
99
-
100
- * fixing styles ([107d28d](https://gitlab.cee.redhat.com/customer-platform/rhc-shared-components/commit/107d28d37edefcc9172f723c6987d9a0032ee042))
101
-
102
-
103
-
104
-
105
-
106
- ## [0.2.7](https://gitlab.cee.redhat.com/customer-platform/rhc-shared-components/compare/@rhc-shared-components/rich-text-editor@0.2.6...@rhc-shared-components/rich-text-editor@0.2.7) (2021-09-28)
107
-
108
-
109
- ### Bug Fixes
110
-
111
- * converted microbundle-crl to microbundle ([0fb91bf](https://gitlab.cee.redhat.com/customer-platform/rhc-shared-components/commit/0fb91bf065c2436251097168599edbb59ce6a16c))
112
-
113
-
114
-
115
-
116
-
117
- ## [0.2.6](https://gitlab.cee.redhat.com/customer-platform/rhc-shared-components/compare/@rhc-shared-components/rich-text-editor@0.2.5...@rhc-shared-components/rich-text-editor@0.2.6) (2021-09-28)
118
-
119
-
120
- ### Bug Fixes
121
-
122
- * added missing stylesheet ([dd08fc3](https://gitlab.cee.redhat.com/customer-platform/rhc-shared-components/commit/dd08fc32298fff6a02812dedd75a2f763692f356))
123
-
124
-
125
-
126
-
127
-
128
- ## [0.2.5](https://gitlab.cee.redhat.com/customer-platform/rhc-shared-components/compare/@rhc-shared-components/rich-text-editor@0.2.4...@rhc-shared-components/rich-text-editor@0.2.5) (2021-09-28)
129
-
130
- **Note:** Version bump only for package @rhc-shared-components/rich-text-editor
131
-
132
-
133
-
134
-
135
-
136
- ## [0.2.4](https://gitlab.cee.redhat.com/customer-platform/rhc-shared-components/compare/@rhc-shared-components/rich-text-editor@0.2.3...@rhc-shared-components/rich-text-editor@0.2.4) (2021-09-28)
137
-
138
- **Note:** Version bump only for package @rhc-shared-components/rich-text-editor
139
-
140
-
141
-
142
-
143
-
144
- ## [0.2.3](https://gitlab.cee.redhat.com/customer-platform/rhc-shared-components/compare/@rhc-shared-components/rich-text-editor@0.2.2...@rhc-shared-components/rich-text-editor@0.2.3) (2021-09-28)
145
-
146
-
147
- ### Bug Fixes
148
-
149
- * remove hardcoded pf styles ([0928295](https://gitlab.cee.redhat.com/customer-platform/rhc-shared-components/commit/0928295bf89f7c14300998d56fc58cc6ec727513))
150
- * using pf no reset to avoid conflicts ([4bc0a9d](https://gitlab.cee.redhat.com/customer-platform/rhc-shared-components/commit/4bc0a9de4c702b85f9ceae7571b76f539fc24ea2))
151
-
152
-
153
-
154
-
155
-
156
- ## [0.2.2](https://gitlab.cee.redhat.com/customer-platform/rhc-shared-components/compare/@rhc-shared-components/rich-text-editor@0.2.1...@rhc-shared-components/rich-text-editor@0.2.2) (2021-09-23)
157
-
158
-
159
- ### Bug Fixes
160
-
161
- * remove broken indentation ([80d6616](https://gitlab.cee.redhat.com/customer-platform/rhc-shared-components/commit/80d66162ae3fcc8f45cf67dc4a49afca9ee72ea8))
162
-
163
-
164
-
165
-
166
-
167
- ## [0.2.1](https://gitlab.cee.redhat.com/customer-platform/rhc-shared-components/compare/@rhc-shared-components/rich-text-editor@0.2.0...@rhc-shared-components/rich-text-editor@0.2.1) (2021-09-22)
168
-
169
- **Note:** Version bump only for package @rhc-shared-components/rich-text-editor
170
-
171
-
172
-
173
-
174
-
175
- # [0.2.0](https://gitlab.cee.redhat.com/customer-platform/rhc-shared-components/compare/@rhc-shared-components/rich-text-editor@0.1.7...@rhc-shared-components/rich-text-editor@0.2.0) (2021-09-22)
176
-
177
-
178
- ### Features
179
-
180
- * use patternfly default title style for headings ([1f08ac5](https://gitlab.cee.redhat.com/customer-platform/rhc-shared-components/commit/1f08ac59a6dfc86343f7840bf405b7d820332427))
181
-
182
-
183
-
184
-
185
-
186
- ## [0.1.7](https://gitlab.cee.redhat.com/customer-platform/rhc-shared-components/compare/@rhc-shared-components/rich-text-editor@0.1.6...@rhc-shared-components/rich-text-editor@0.1.7) (2021-09-22)
187
-
188
-
189
- ### Bug Fixes
190
-
191
- * removed image and video insertion ([a89bbd4](https://gitlab.cee.redhat.com/customer-platform/rhc-shared-components/commit/a89bbd448ab9d6930c5f2b6a08b624c997e9658f))
192
-
193
-
194
-
195
-
196
-
197
- ## [0.1.6](https://gitlab.cee.redhat.com/customer-platform/rhc-shared-components/compare/@rhc-shared-components/rich-text-editor@0.1.5...@rhc-shared-components/rich-text-editor@0.1.6) (2021-09-22)
198
-
199
- **Note:** Version bump only for package @rhc-shared-components/rich-text-editor
200
-
201
-
202
-
203
-
204
-
205
- ## [0.1.5](https://gitlab.cee.redhat.com/customer-platform/rhc-shared-components/compare/@rhc-shared-components/rich-text-editor@0.1.4...@rhc-shared-components/rich-text-editor@0.1.5) (2021-09-20)
206
-
207
-
208
- ### Bug Fixes
209
-
210
- * cleaning deps ([227dc2d](https://gitlab.cee.redhat.com/customer-platform/rhc-shared-components/commit/227dc2da7dfda53172811ef287840b97cd550681))
211
-
212
-
213
-
214
-
215
-
216
- ## [0.1.4](https://gitlab.cee.redhat.com/customer-platform/rhc-shared-components/compare/@rhc-shared-components/rich-text-editor@0.1.3...@rhc-shared-components/rich-text-editor@0.1.4) (2021-09-17)
217
-
218
-
219
- ### Bug Fixes
220
-
221
- * added cleaning of dist on prepare ([68e3e76](https://gitlab.cee.redhat.com/customer-platform/rhc-shared-components/commit/68e3e76f8924cabd581baeace07e9afeef20d36b))
222
-
223
-
224
-
225
-
226
-
227
- ## [0.1.3](https://gitlab.cee.redhat.com/customer-platform/rhc-shared-components/compare/@rhc-shared-components/rich-text-editor@0.1.2...@rhc-shared-components/rich-text-editor@0.1.3) (2021-09-17)
228
-
229
- **Note:** Version bump only for package @rhc-shared-components/rich-text-editor
230
-
231
-
232
-
233
-
234
-
235
- ## [0.1.2](https://gitlab.cee.redhat.com/customer-platform/rhc-shared-components/compare/@rhc-shared-components/rich-text-editor@0.1.1...@rhc-shared-components/rich-text-editor@0.1.2) (2021-09-17)
236
-
237
- **Note:** Version bump only for package @rhc-shared-components/rich-text-editor
238
-
239
-
240
-
241
-
242
-
243
- ## [0.1.1](https://gitlab.cee.redhat.com/customer-platform/rhc-shared-components/compare/@rhc-shared-components/rich-text-editor@0.1.0...@rhc-shared-components/rich-text-editor@0.1.1) (2021-09-17)
244
-
245
- **Note:** Version bump only for package @rhc-shared-components/rich-text-editor
246
-
247
-
248
-
249
-
250
-
251
- # 0.1.0 (2021-09-17)
252
-
253
-
254
- ### Features
255
-
256
- * finished rich text editor component ([52a70ce](https://gitlab.cee.redhat.com/dxp/customer-portal/rhc-shared-components/commit/52a70cef749ea5a46882122ab843a2099d5e1628))
@@ -1,224 +0,0 @@
1
- import * as React from 'react';
2
- import { CKEditor } from '@ckeditor/ckeditor5-react';
3
- import ClassicEditor from '@rhc-shared-components/rhc-ckeditor';
4
- import { FormGroup, FormHelperText, HelperText, HelperTextItem, ValidatedOptions } from '@patternfly/react-core';
5
- import { useField, useFormikContext } from 'formik';
6
-
7
- var css_248z$1 = ".rich-text-editor-custom {\n --pf-c-title--m-2xl--LineHeight: var(--pf-global--LineHeight--sm);\n --pf-c-title--m-2xl--FontSize: var(--pf-global--FontSize--2xl);\n --pf-c-title--m-2xl--FontWeight: var(--pf-global--FontWeight--normal);\n --pf-c-title--m-xl--LineHeight: var(--pf-global--LineHeight--md);\n --pf-c-title--m-xl--FontSize: var(--pf-global--FontSize--xl);\n --pf-c-title--m-xl--FontWeight: var(--pf-global--FontWeight--normal);\n --pf-c-title--m-lg--LineHeight: var(--pf-global--LineHeight--md);\n --pf-c-title--m-lg--FontSize: var(--pf-global--FontSize--lg);\n --pf-c-title--m-lg--FontWeight: var(--pf-global--FontWeight--normal);\n --pf-c-title--m-md--LineHeight: var(--pf-global--LineHeight--md);\n --pf-c-title--m-md--FontSize: var(--pf-global--FontSize--md);\n --pf-c-title--m-md--FontWeight: var(--pf-global--FontWeight--normal);\n}\n.rich-text-editor-custom .ck-editor__main {\n word-break: break-all;\n}\n.rich-text-editor-custom .ck-code-block-dropdown .ck-splitbutton__arrow {\n display: none;\n}\n.rich-text-editor-custom h1 {\n font-size: var(--pf-c-title--m-2xl--FontSize);\n font-weight: var(--pf-c-title--m-2xl--FontWeight);\n line-height: var(--pf-c-title--m-2xl--LineHeight);\n}\n.rich-text-editor-custom h2 {\n font-size: var(--pf-c-title--m-xl--FontSize);\n font-weight: var(--pf-c-title--m-xl--FontWeight);\n line-height: var(--pf-c-title--m-xl--LineHeight);\n}\n.rich-text-editor-custom h3 {\n font-size: var(--pf-c-title--m-lg--FontSize);\n font-weight: var(--pf-c-title--m-lg--FontWeight);\n line-height: var(--pf-c-title--m-lg--LineHeight);\n}\n.rich-text-editor-custom h4 {\n font-size: var(--pf-c-title--m-md--FontSize);\n font-weight: var(--pf-c-title--m-md--FontWeight);\n line-height: var(--pf-c-title--m-md--LineHeight);\n}\n.rich-text-editor-custom ul {\n display: block;\n list-style-type: disc;\n -webkit-margin-before: 1em;\n margin-block-start: 1em;\n -webkit-margin-after: 1em;\n margin-block-end: 1em;\n -webkit-margin-start: 0px;\n margin-inline-start: 0px;\n -webkit-margin-end: 0px;\n margin-inline-end: 0px;\n -webkit-padding-start: 40px;\n padding-inline-start: 40px;\n}\n.rich-text-editor-custom ul li {\n display: list-item;\n}\n.rich-text-editor-custom ul ul {\n list-style-type: circle;\n -webkit-margin-before: 0px;\n margin-block-start: 0px;\n -webkit-margin-after: 0px;\n margin-block-end: 0px;\n}\n.rich-text-editor-custom ol {\n display: block;\n list-style-type: decimal;\n -webkit-margin-before: 1em;\n margin-block-start: 1em;\n -webkit-margin-after: 1em;\n margin-block-end: 1em;\n -webkit-margin-start: 0px;\n margin-inline-start: 0px;\n -webkit-margin-end: 0px;\n margin-inline-end: 0px;\n -webkit-padding-start: 40px;\n padding-inline-start: 40px;\n}";
8
-
9
- const RichTextEditor = ({
10
- value,
11
- disabled,
12
- onReady,
13
- onChange,
14
- onError,
15
- onBlur,
16
- onFocus,
17
- id,
18
- name,
19
- showCodeBlock
20
- }) => {
21
- const eventHandlerWrapper = (handler, event, editor) => {
22
- if (handler) {
23
- handler(editor.getData(), event, editor);
24
- }
25
- };
26
-
27
- InsertCss$1();
28
- return React.createElement("div", {
29
- className: 'rich-text-editor-custom'
30
- }, React.createElement(CKEditor, Object.assign({
31
- editor: ClassicEditor,
32
- data: value,
33
- config: {
34
- codeBlock: {
35
- languages: [{
36
- language: 'code',
37
- label: 'Code',
38
- forceValue: true
39
- }]
40
- },
41
- toolbar: {
42
- items: ['heading', '|', 'bold', 'italic', 'underline', 'link', 'bulletedList', 'numberedList', '|', ...(showCodeBlock ? ['codeBlock'] : []), 'blockQuote', 'insertTable', 'undo', 'redo']
43
- },
44
- isReadOnly: disabled
45
- },
46
- onReady: onReady,
47
- onChange: (event, editor) => {
48
- eventHandlerWrapper(onChange, event, editor);
49
- },
50
- onBlur: (event, editor) => {
51
- eventHandlerWrapper(onBlur, event, editor);
52
- },
53
- onFocus: (event, editor) => {
54
- eventHandlerWrapper(onFocus, event, editor);
55
- },
56
- onError: (event, editor) => {
57
- eventHandlerWrapper(onError, event, editor);
58
- }
59
- }, id && {
60
- id
61
- }, name && {
62
- name
63
- })));
64
- };
65
-
66
- const InsertCss$1 = () => {
67
- const styleId = 'rich-test-editor-styles';
68
-
69
- if (!document.getElementById(styleId)) {
70
- const styleTag = document.createElement('style');
71
- styleTag.id = styleId;
72
- styleTag.type = 'text/css';
73
- styleTag.innerHTML = css_248z$1;
74
- document.body.appendChild(styleTag);
75
- }
76
- };
77
-
78
- function _objectWithoutPropertiesLoose$1(source, excluded) {
79
- if (source == null) return {};
80
- var target = {};
81
- var sourceKeys = Object.keys(source);
82
- var key, i;
83
-
84
- for (i = 0; i < sourceKeys.length; i++) {
85
- key = sourceKeys[i];
86
- if (excluded.indexOf(key) >= 0) continue;
87
- target[key] = source[key];
88
- }
89
-
90
- return target;
91
- }
92
-
93
- function _objectWithoutPropertiesLoose(source, excluded) {
94
- if (source == null) return {};
95
- var target = {};
96
- var sourceKeys = Object.keys(source);
97
- var key, i;
98
-
99
- for (i = 0; i < sourceKeys.length; i++) {
100
- key = sourceKeys[i];
101
- if (excluded.indexOf(key) >= 0) continue;
102
- target[key] = source[key];
103
- }
104
-
105
- return target;
106
- }
107
-
108
- var css_248z = ".form-group .max-char-length {\n float: right;\n color: #6A6E73;\n font-size: var(--pf-v5-c-form__helper-text--FontSize);\n margin-top: var(--pf-v5-c-form__helper-text--MarginTop);\n}\n.form-group .maxlength-error {\n color: var(--pf-v5-c-form--m-error--Color);\n}";
109
- const _excluded$1 = ["children", "helperTextInvalid", "validated", "helperText", "labelIcon", "onClick"];
110
-
111
- const FormGroupContainer = _ref => {
112
- let {
113
- children,
114
- helperTextInvalid,
115
- validated,
116
- helperText,
117
- labelIcon,
118
- onClick
119
- } = _ref,
120
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$1);
121
-
122
- InsertCss();
123
- return React.createElement(FormGroup, Object.assign({
124
- className: 'form-group'
125
- }, labelIcon && {
126
- labelIcon: labelIcon
127
- }, onClick && {
128
- onClick
129
- }, rest), children, React.createElement(FormHelperText, null, React.createElement(HelperText, null, React.createElement(HelperTextItem, {
130
- variant: validated
131
- }, validated === ValidatedOptions.error ? helperTextInvalid : helperText))));
132
- };
133
-
134
- const InsertCss = () => {
135
- const styleId = 'form-group-component-style';
136
-
137
- if (!document.getElementById(styleId)) {
138
- const styleTag = document.createElement('style');
139
- styleTag.id = styleId;
140
- styleTag.type = 'text/css';
141
- styleTag.innerHTML = css_248z;
142
- document.body.appendChild(styleTag);
143
- }
144
- };
145
-
146
- const _excluded = ["label", "isRequired", "ariaLabel", "placeholder", "helperText", "disabled", "showMaxLengthText", "maxLength", "showCodeBlock"];
147
-
148
- const RichTextEditorFormComponent = _ref => {
149
- let {
150
- label,
151
- isRequired,
152
- ariaLabel = 'Enter text',
153
- helperText,
154
- disabled,
155
- showMaxLengthText,
156
- maxLength,
157
- showCodeBlock
158
- } = _ref,
159
- rest = _objectWithoutPropertiesLoose$1(_ref, _excluded);
160
-
161
- const [, meta, {
162
- setTouched
163
- }] = useField({
164
- name: rest.name
165
- });
166
- const {
167
- value
168
- } = meta;
169
- const editorRef = React.useRef(null);
170
- const {
171
- isSubmitting,
172
- setFieldValue
173
- } = useFormikContext();
174
- const [numberOfCharacters, setNoOfCharacters] = React.useState(maxLength || 0);
175
- React.useEffect(() => {
176
- if (maxLength) {
177
- setNoOfCharacters(value && value.length ? maxLength - value.length : maxLength);
178
- }
179
- }, [value, maxLength]);
180
- return React.createElement(FormGroupContainer, {
181
- validated: meta.touched && meta.error ? ValidatedOptions.error : ValidatedOptions.default,
182
- onClick: event => {
183
- var _event$target;
184
-
185
- // filtering out just the form event
186
- if ( // @ts-ignore
187
- event != null && (_event$target = event.target) != null && _event$target.classList.contains('pf-c-form__label-text') && editorRef.current) {
188
- // @ts-ignore
189
- editorRef.current.editing.view.focus();
190
- }
191
- },
192
- fieldId: rest.name,
193
- helperTextInvalid: meta.error,
194
- isRequired: isRequired,
195
- label: label,
196
- helperText: helperText
197
- }, React.createElement(RichTextEditor, {
198
- showCodeBlock: showCodeBlock,
199
- value: value,
200
- id: rest.name,
201
- name: rest.name,
202
- onReady: editor => {
203
- if (editor) {
204
- window.ckeditorObj = window.ckeditorObj || {};
205
- window.ckeditorObj[rest.name] = editor;
206
- editor.setData(value);
207
- editorRef.current = editor;
208
- }
209
- },
210
- disabled: disabled || isSubmitting,
211
- onChange: data => {
212
- setFieldValue(rest.name, data, true);
213
- },
214
- onBlur: data => {
215
- setFieldValue(rest.name, data, true);
216
- setTouched(true);
217
- }
218
- }), showMaxLengthText && React.createElement("div", {
219
- "data-testid": 'formTextAreaMaxLengthText',
220
- className: 'max-char-length' + (numberOfCharacters < 0 ? ' maxlength-error' : '')
221
- }, numberOfCharacters, " character", numberOfCharacters !== 1 && 's', ' ', "remaining (includes HTML markup)"));
222
- };
223
-
224
- export { RichTextEditor, RichTextEditorFormComponent };
@@ -1 +0,0 @@
1
- export {};