@rhc-shared-components/rich-text-editor 0.3.4 → 0.5.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/CHANGELOG.md +20 -0
- package/dist/RichTextEditor.d.ts +2 -3
- package/dist/index.js +17 -44
- package/dist/index.modern.js +17 -44
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,26 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [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)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* added touched flag to validation ([e69be69](https://gitlab.cee.redhat.com/customer-platform/rhc-shared-components/commit/e69be69c901cd84f9f53c1ce2ef7047cd8ead04e))
|
|
12
|
+
* fixed max length bug ([c63c798](https://gitlab.cee.redhat.com/customer-platform/rhc-shared-components/commit/c63c79891c16ff23919f09ba681470432a2b3301))
|
|
13
|
+
* fixed re init bugs ([b208de0](https://gitlab.cee.redhat.com/customer-platform/rhc-shared-components/commit/b208de0ac998c4fb814cbee4e3e3a8b4c6fe4b05))
|
|
14
|
+
* fixing validation errors ([e2d4e61](https://gitlab.cee.redhat.com/customer-platform/rhc-shared-components/commit/e2d4e610ddeefdef6dd39d9cf6000dfab84916c7))
|
|
15
|
+
* validation bugs ([cee65e1](https://gitlab.cee.redhat.com/customer-platform/rhc-shared-components/commit/cee65e142bf2dbae06914a4add9915f11118c6af))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Features
|
|
19
|
+
|
|
20
|
+
* added maxlength feature ([564c8fa](https://gitlab.cee.redhat.com/customer-platform/rhc-shared-components/commit/564c8fa69ce2abfdc6eeb01d07330ebcfcbad4a1))
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
6
26
|
## [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)
|
|
7
27
|
|
|
8
28
|
**Note:** Version bump only for package @rhc-shared-components/rich-text-editor
|
package/dist/RichTextEditor.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
|
|
3
|
-
declare type RichTextEditorFunctionType = (value: string, event?: Event, editor?: ClassicEditor) => void;
|
|
2
|
+
declare type RichTextEditorFunctionType = (value: string, event?: Event, editor?: any) => void;
|
|
4
3
|
export interface RichTextEditorProps {
|
|
5
4
|
value: string;
|
|
6
5
|
disabled?: boolean;
|
|
7
|
-
onReady?: (editor:
|
|
6
|
+
onReady?: (editor: any) => void;
|
|
8
7
|
onChange?: RichTextEditorFunctionType;
|
|
9
8
|
onBlur?: RichTextEditorFunctionType;
|
|
10
9
|
onFocus?: RichTextEditorFunctionType;
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
var React = require('react');
|
|
2
2
|
var ckeditor5React = require('@ckeditor/ckeditor5-react');
|
|
3
|
-
var ClassicEditor = require('@
|
|
3
|
+
var ClassicEditor = require('@rhc-shared-components/rhc-ckeditor');
|
|
4
4
|
var reactCore = require('@patternfly/react-core');
|
|
5
5
|
var formik = require('formik');
|
|
6
6
|
|
|
@@ -27,7 +27,7 @@ function _interopNamespace(e) {
|
|
|
27
27
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
28
28
|
var ClassicEditor__default = /*#__PURE__*/_interopDefaultLegacy(ClassicEditor);
|
|
29
29
|
|
|
30
|
-
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 .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 .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 .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 .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 .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 .rich-text-editor-custom ul li {\n display: list-item; }\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 .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";
|
|
30
|
+
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 .rich-text-editor-custom .ck-editor__main {\n word-break: break-all; }\n .rich-text-editor-custom .ck-code-block-dropdown .ck-splitbutton__arrow {\n display: none; }\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 .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 .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 .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 .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 .rich-text-editor-custom ul li {\n display: list-item; }\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 .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";
|
|
31
31
|
|
|
32
32
|
var RichTextEditor = function RichTextEditor(_ref) {
|
|
33
33
|
var value = _ref.value,
|
|
@@ -50,46 +50,17 @@ var RichTextEditor = function RichTextEditor(_ref) {
|
|
|
50
50
|
return React__namespace.createElement("div", {
|
|
51
51
|
className: 'rich-text-editor-custom'
|
|
52
52
|
}, React__namespace.createElement(ckeditor5React.CKEditor, Object.assign({
|
|
53
|
-
disabled: disabled,
|
|
54
53
|
editor: ClassicEditor__default["default"],
|
|
55
54
|
data: value,
|
|
56
55
|
config: {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
model: 'heading1',
|
|
63
|
-
view: {
|
|
64
|
-
name: 'h1'
|
|
65
|
-
},
|
|
66
|
-
title: 'Heading 1'
|
|
67
|
-
}, {
|
|
68
|
-
model: 'heading2',
|
|
69
|
-
view: {
|
|
70
|
-
name: 'h2'
|
|
71
|
-
},
|
|
72
|
-
title: 'Heading 2'
|
|
73
|
-
}, {
|
|
74
|
-
model: 'heading3',
|
|
75
|
-
view: {
|
|
76
|
-
name: 'h3'
|
|
77
|
-
},
|
|
78
|
-
title: 'Heading 3'
|
|
79
|
-
}, {
|
|
80
|
-
model: 'heading4',
|
|
81
|
-
view: {
|
|
82
|
-
name: 'h4'
|
|
83
|
-
},
|
|
84
|
-
title: 'Heading 4'
|
|
56
|
+
codeBlock: {
|
|
57
|
+
languages: [{
|
|
58
|
+
language: 'code',
|
|
59
|
+
label: 'Code',
|
|
60
|
+
forceValue: true
|
|
85
61
|
}]
|
|
86
62
|
},
|
|
87
|
-
|
|
88
|
-
items: ['heading', '|', 'bold', 'italic', 'link', 'bulletedList', 'numberedList', '|', 'blockQuote', 'insertTable', 'undo', 'redo']
|
|
89
|
-
},
|
|
90
|
-
table: {
|
|
91
|
-
contentToolbar: ['tableColumn', 'tableRow', 'mergeTableCells']
|
|
92
|
-
}
|
|
63
|
+
isReadOnly: disabled
|
|
93
64
|
},
|
|
94
65
|
onReady: onReady,
|
|
95
66
|
onChange: function onChange(event, editor) {
|
|
@@ -212,8 +183,7 @@ var RichTextEditorFormComponent = function RichTextEditorFormComponent(_ref) {
|
|
|
212
183
|
|
|
213
184
|
var _useFormikContext = formik.useFormikContext(),
|
|
214
185
|
isSubmitting = _useFormikContext.isSubmitting,
|
|
215
|
-
setFieldValue = _useFormikContext.setFieldValue
|
|
216
|
-
validateField = _useFormikContext.validateField;
|
|
186
|
+
setFieldValue = _useFormikContext.setFieldValue;
|
|
217
187
|
|
|
218
188
|
var _React$useState = React__namespace.useState(maxLength || 0),
|
|
219
189
|
numberOfCharacters = _React$useState[0],
|
|
@@ -227,7 +197,7 @@ var RichTextEditorFormComponent = function RichTextEditorFormComponent(_ref) {
|
|
|
227
197
|
return React__namespace.createElement(FormGroupContainer, {
|
|
228
198
|
validated: meta.touched && meta.error ? reactCore.ValidatedOptions.error : reactCore.ValidatedOptions["default"],
|
|
229
199
|
onClick: function onClick() {
|
|
230
|
-
if (editorRef) {
|
|
200
|
+
if (editorRef.current) {
|
|
231
201
|
// @ts-ignore
|
|
232
202
|
editorRef.current.editing.view.focus();
|
|
233
203
|
}
|
|
@@ -243,17 +213,20 @@ var RichTextEditorFormComponent = function RichTextEditorFormComponent(_ref) {
|
|
|
243
213
|
name: rest.name,
|
|
244
214
|
onReady: function onReady(editor) {
|
|
245
215
|
editor.setData(value);
|
|
216
|
+
|
|
217
|
+
if (disabled || isSubmitting) {
|
|
218
|
+
editor.enableReadOnlyMode(name);
|
|
219
|
+
}
|
|
220
|
+
|
|
246
221
|
editorRef.current = editor;
|
|
247
222
|
},
|
|
248
223
|
disabled: disabled || isSubmitting,
|
|
249
224
|
onChange: function onChange(data) {
|
|
250
|
-
setFieldValue(rest.name, data);
|
|
251
|
-
validateField(rest.name);
|
|
225
|
+
setFieldValue(rest.name, data, true);
|
|
252
226
|
},
|
|
253
227
|
onBlur: function onBlur(data) {
|
|
228
|
+
setFieldValue(rest.name, data, true);
|
|
254
229
|
setTouched(true);
|
|
255
|
-
setFieldValue(rest.name, data);
|
|
256
|
-
validateField(rest.name);
|
|
257
230
|
}
|
|
258
231
|
}), showMaxLengthText && React__namespace.createElement("div", {
|
|
259
232
|
"data-testid": 'formTextAreaMaxLengthText',
|
package/dist/index.modern.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { CKEditor } from '@ckeditor/ckeditor5-react';
|
|
3
|
-
import ClassicEditor from '@
|
|
3
|
+
import ClassicEditor from '@rhc-shared-components/rhc-ckeditor';
|
|
4
4
|
import { FormGroup, ValidatedOptions } from '@patternfly/react-core';
|
|
5
5
|
import { useField, useFormikContext } from 'formik';
|
|
6
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 .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 .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 .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 .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 .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 .rich-text-editor-custom ul li {\n display: list-item; }\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 .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";
|
|
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 .rich-text-editor-custom .ck-editor__main {\n word-break: break-all; }\n .rich-text-editor-custom .ck-code-block-dropdown .ck-splitbutton__arrow {\n display: none; }\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 .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 .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 .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 .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 .rich-text-editor-custom ul li {\n display: list-item; }\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 .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
8
|
|
|
9
9
|
const RichTextEditor = ({
|
|
10
10
|
value,
|
|
@@ -27,46 +27,17 @@ const RichTextEditor = ({
|
|
|
27
27
|
return React.createElement("div", {
|
|
28
28
|
className: 'rich-text-editor-custom'
|
|
29
29
|
}, React.createElement(CKEditor, Object.assign({
|
|
30
|
-
disabled: disabled,
|
|
31
30
|
editor: ClassicEditor,
|
|
32
31
|
data: value,
|
|
33
32
|
config: {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
model: 'heading1',
|
|
40
|
-
view: {
|
|
41
|
-
name: 'h1'
|
|
42
|
-
},
|
|
43
|
-
title: 'Heading 1'
|
|
44
|
-
}, {
|
|
45
|
-
model: 'heading2',
|
|
46
|
-
view: {
|
|
47
|
-
name: 'h2'
|
|
48
|
-
},
|
|
49
|
-
title: 'Heading 2'
|
|
50
|
-
}, {
|
|
51
|
-
model: 'heading3',
|
|
52
|
-
view: {
|
|
53
|
-
name: 'h3'
|
|
54
|
-
},
|
|
55
|
-
title: 'Heading 3'
|
|
56
|
-
}, {
|
|
57
|
-
model: 'heading4',
|
|
58
|
-
view: {
|
|
59
|
-
name: 'h4'
|
|
60
|
-
},
|
|
61
|
-
title: 'Heading 4'
|
|
33
|
+
codeBlock: {
|
|
34
|
+
languages: [{
|
|
35
|
+
language: 'code',
|
|
36
|
+
label: 'Code',
|
|
37
|
+
forceValue: true
|
|
62
38
|
}]
|
|
63
39
|
},
|
|
64
|
-
|
|
65
|
-
items: ['heading', '|', 'bold', 'italic', 'link', 'bulletedList', 'numberedList', '|', 'blockQuote', 'insertTable', 'undo', 'redo']
|
|
66
|
-
},
|
|
67
|
-
table: {
|
|
68
|
-
contentToolbar: ['tableColumn', 'tableRow', 'mergeTableCells']
|
|
69
|
-
}
|
|
40
|
+
isReadOnly: disabled
|
|
70
41
|
},
|
|
71
42
|
onReady: onReady,
|
|
72
43
|
onChange: (event, editor) => {
|
|
@@ -194,8 +165,7 @@ const RichTextEditorFormComponent = _ref => {
|
|
|
194
165
|
const editorRef = React.useRef(null);
|
|
195
166
|
const {
|
|
196
167
|
isSubmitting,
|
|
197
|
-
setFieldValue
|
|
198
|
-
validateField
|
|
168
|
+
setFieldValue
|
|
199
169
|
} = useFormikContext();
|
|
200
170
|
const [numberOfCharacters, setNoOfCharacters] = React.useState(maxLength || 0);
|
|
201
171
|
React.useEffect(() => {
|
|
@@ -206,7 +176,7 @@ const RichTextEditorFormComponent = _ref => {
|
|
|
206
176
|
return React.createElement(FormGroupContainer, {
|
|
207
177
|
validated: meta.touched && meta.error ? ValidatedOptions.error : ValidatedOptions.default,
|
|
208
178
|
onClick: () => {
|
|
209
|
-
if (editorRef) {
|
|
179
|
+
if (editorRef.current) {
|
|
210
180
|
// @ts-ignore
|
|
211
181
|
editorRef.current.editing.view.focus();
|
|
212
182
|
}
|
|
@@ -222,17 +192,20 @@ const RichTextEditorFormComponent = _ref => {
|
|
|
222
192
|
name: rest.name,
|
|
223
193
|
onReady: editor => {
|
|
224
194
|
editor.setData(value);
|
|
195
|
+
|
|
196
|
+
if (disabled || isSubmitting) {
|
|
197
|
+
editor.enableReadOnlyMode(name);
|
|
198
|
+
}
|
|
199
|
+
|
|
225
200
|
editorRef.current = editor;
|
|
226
201
|
},
|
|
227
202
|
disabled: disabled || isSubmitting,
|
|
228
203
|
onChange: data => {
|
|
229
|
-
setFieldValue(rest.name, data);
|
|
230
|
-
validateField(rest.name);
|
|
204
|
+
setFieldValue(rest.name, data, true);
|
|
231
205
|
},
|
|
232
206
|
onBlur: data => {
|
|
207
|
+
setFieldValue(rest.name, data, true);
|
|
233
208
|
setTouched(true);
|
|
234
|
-
setFieldValue(rest.name, data);
|
|
235
|
-
validateField(rest.name);
|
|
236
209
|
}
|
|
237
210
|
}), showMaxLengthText && React.createElement("div", {
|
|
238
211
|
"data-testid": 'formTextAreaMaxLengthText',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rhc-shared-components/rich-text-editor",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "WYSWYG Editor for Red Hat Certified Apps",
|
|
5
5
|
"author": "gautamkrishnar",
|
|
6
6
|
"license": "MIT",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"react-dom": ">=16.13.1"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@rhc-shared-components/form-group-container": "^0.3.
|
|
35
|
+
"@rhc-shared-components/form-group-container": "^0.3.1",
|
|
36
36
|
"@testing-library/jest-dom": "^4.2.4",
|
|
37
37
|
"@testing-library/react": "^9.5.0",
|
|
38
38
|
"@testing-library/user-event": "^7.2.1",
|
|
@@ -69,9 +69,9 @@
|
|
|
69
69
|
"dist"
|
|
70
70
|
],
|
|
71
71
|
"dependencies": {
|
|
72
|
-
"@ckeditor/ckeditor5-build-classic": "^29.2.0",
|
|
73
72
|
"@ckeditor/ckeditor5-react": "^3.0.2",
|
|
74
73
|
"@patternfly/react-core": "^4.101.3",
|
|
74
|
+
"@rhc-shared-components/rhc-ckeditor": "^1.0.2",
|
|
75
75
|
"formik": "^2.1.4",
|
|
76
76
|
"react": "^16.13.1",
|
|
77
77
|
"react-dom": "^16.13.1"
|