@rhc-shared-components/rich-text-editor 0.5.0 → 0.5.2
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/RichTextEditor.d.ts +1 -0
- package/dist/RichTextEditorFormComponent.d.ts +1 -0
- package/dist/index.js +14 -9
- package/dist/index.modern.js +15 -10
- package/package.json +1 -1
package/dist/RichTextEditor.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export interface RichTextEditorFormComponentProps {
|
|
|
9
9
|
helperText?: string;
|
|
10
10
|
showMaxLengthText?: boolean;
|
|
11
11
|
maxLength?: number;
|
|
12
|
+
showCodeBlock?: boolean;
|
|
12
13
|
}
|
|
13
14
|
declare const RichTextEditorFormComponent: React.FC<RichTextEditorFormComponentProps>;
|
|
14
15
|
export default RichTextEditorFormComponent;
|
package/dist/index.js
CHANGED
|
@@ -38,7 +38,8 @@ var RichTextEditor = function RichTextEditor(_ref) {
|
|
|
38
38
|
_onBlur = _ref.onBlur,
|
|
39
39
|
_onFocus = _ref.onFocus,
|
|
40
40
|
id = _ref.id,
|
|
41
|
-
name = _ref.name
|
|
41
|
+
name = _ref.name,
|
|
42
|
+
showCodeBlock = _ref.showCodeBlock;
|
|
42
43
|
|
|
43
44
|
var eventHandlerWrapper = function eventHandlerWrapper(handler, event, editor) {
|
|
44
45
|
if (handler) {
|
|
@@ -60,6 +61,9 @@ var RichTextEditor = function RichTextEditor(_ref) {
|
|
|
60
61
|
forceValue: true
|
|
61
62
|
}]
|
|
62
63
|
},
|
|
64
|
+
toolbar: {
|
|
65
|
+
items: ['heading', '|', 'bold', 'italic', 'underline', 'link', 'bulletedList', 'numberedList', '|'].concat(showCodeBlock ? ['codeBlock'] : [], ['blockQuote', 'insertTable', 'undo', 'redo'])
|
|
66
|
+
},
|
|
63
67
|
isReadOnly: disabled
|
|
64
68
|
},
|
|
65
69
|
onReady: onReady,
|
|
@@ -161,7 +165,7 @@ var InsertCss = function InsertCss() {
|
|
|
161
165
|
}
|
|
162
166
|
};
|
|
163
167
|
|
|
164
|
-
var _excluded = ["label", "isRequired", "ariaLabel", "placeholder", "helperText", "disabled", "showMaxLengthText", "maxLength"];
|
|
168
|
+
var _excluded = ["label", "isRequired", "ariaLabel", "placeholder", "helperText", "disabled", "showMaxLengthText", "maxLength", "showCodeBlock"];
|
|
165
169
|
|
|
166
170
|
var RichTextEditorFormComponent = function RichTextEditorFormComponent(_ref) {
|
|
167
171
|
var label = _ref.label,
|
|
@@ -170,6 +174,7 @@ var RichTextEditorFormComponent = function RichTextEditorFormComponent(_ref) {
|
|
|
170
174
|
disabled = _ref.disabled,
|
|
171
175
|
showMaxLengthText = _ref.showMaxLengthText,
|
|
172
176
|
maxLength = _ref.maxLength,
|
|
177
|
+
showCodeBlock = _ref.showCodeBlock,
|
|
173
178
|
rest = _objectWithoutPropertiesLoose$1(_ref, _excluded);
|
|
174
179
|
|
|
175
180
|
var _useField = formik.useField({
|
|
@@ -196,8 +201,12 @@ var RichTextEditorFormComponent = function RichTextEditorFormComponent(_ref) {
|
|
|
196
201
|
}, [value, maxLength]);
|
|
197
202
|
return React__namespace.createElement(FormGroupContainer, {
|
|
198
203
|
validated: meta.touched && meta.error ? reactCore.ValidatedOptions.error : reactCore.ValidatedOptions["default"],
|
|
199
|
-
onClick: function onClick() {
|
|
200
|
-
|
|
204
|
+
onClick: function onClick(event) {
|
|
205
|
+
var _event$target;
|
|
206
|
+
|
|
207
|
+
// filtering out just the form event
|
|
208
|
+
if ( // @ts-ignore
|
|
209
|
+
event != null && (_event$target = event.target) != null && _event$target.classList.contains('pf-c-form__label-text') && editorRef.current) {
|
|
201
210
|
// @ts-ignore
|
|
202
211
|
editorRef.current.editing.view.focus();
|
|
203
212
|
}
|
|
@@ -208,16 +217,12 @@ var RichTextEditorFormComponent = function RichTextEditorFormComponent(_ref) {
|
|
|
208
217
|
label: label,
|
|
209
218
|
helperText: helperText
|
|
210
219
|
}, React__namespace.createElement(RichTextEditor, {
|
|
220
|
+
showCodeBlock: showCodeBlock,
|
|
211
221
|
value: value,
|
|
212
222
|
id: rest.name,
|
|
213
223
|
name: rest.name,
|
|
214
224
|
onReady: function onReady(editor) {
|
|
215
225
|
editor.setData(value);
|
|
216
|
-
|
|
217
|
-
if (disabled || isSubmitting) {
|
|
218
|
-
editor.enableReadOnlyMode(name);
|
|
219
|
-
}
|
|
220
|
-
|
|
221
226
|
editorRef.current = editor;
|
|
222
227
|
},
|
|
223
228
|
disabled: disabled || isSubmitting,
|
package/dist/index.modern.js
CHANGED
|
@@ -15,7 +15,8 @@ const RichTextEditor = ({
|
|
|
15
15
|
onBlur,
|
|
16
16
|
onFocus,
|
|
17
17
|
id,
|
|
18
|
-
name
|
|
18
|
+
name,
|
|
19
|
+
showCodeBlock
|
|
19
20
|
}) => {
|
|
20
21
|
const eventHandlerWrapper = (handler, event, editor) => {
|
|
21
22
|
if (handler) {
|
|
@@ -37,6 +38,9 @@ const RichTextEditor = ({
|
|
|
37
38
|
forceValue: true
|
|
38
39
|
}]
|
|
39
40
|
},
|
|
41
|
+
toolbar: {
|
|
42
|
+
items: ['heading', '|', 'bold', 'italic', 'underline', 'link', 'bulletedList', 'numberedList', '|', ...(showCodeBlock ? ['codeBlock'] : []), 'blockQuote', 'insertTable', 'undo', 'redo']
|
|
43
|
+
},
|
|
40
44
|
isReadOnly: disabled
|
|
41
45
|
},
|
|
42
46
|
onReady: onReady,
|
|
@@ -140,7 +144,7 @@ const InsertCss = () => {
|
|
|
140
144
|
}
|
|
141
145
|
};
|
|
142
146
|
|
|
143
|
-
const _excluded = ["label", "isRequired", "ariaLabel", "placeholder", "helperText", "disabled", "showMaxLengthText", "maxLength"];
|
|
147
|
+
const _excluded = ["label", "isRequired", "ariaLabel", "placeholder", "helperText", "disabled", "showMaxLengthText", "maxLength", "showCodeBlock"];
|
|
144
148
|
|
|
145
149
|
const RichTextEditorFormComponent = _ref => {
|
|
146
150
|
let {
|
|
@@ -150,7 +154,8 @@ const RichTextEditorFormComponent = _ref => {
|
|
|
150
154
|
helperText,
|
|
151
155
|
disabled,
|
|
152
156
|
showMaxLengthText,
|
|
153
|
-
maxLength
|
|
157
|
+
maxLength,
|
|
158
|
+
showCodeBlock
|
|
154
159
|
} = _ref,
|
|
155
160
|
rest = _objectWithoutPropertiesLoose$1(_ref, _excluded);
|
|
156
161
|
|
|
@@ -175,8 +180,12 @@ const RichTextEditorFormComponent = _ref => {
|
|
|
175
180
|
}, [value, maxLength]);
|
|
176
181
|
return React.createElement(FormGroupContainer, {
|
|
177
182
|
validated: meta.touched && meta.error ? ValidatedOptions.error : ValidatedOptions.default,
|
|
178
|
-
onClick:
|
|
179
|
-
|
|
183
|
+
onClick: event => {
|
|
184
|
+
var _event$target;
|
|
185
|
+
|
|
186
|
+
// filtering out just the form event
|
|
187
|
+
if ( // @ts-ignore
|
|
188
|
+
event != null && (_event$target = event.target) != null && _event$target.classList.contains('pf-c-form__label-text') && editorRef.current) {
|
|
180
189
|
// @ts-ignore
|
|
181
190
|
editorRef.current.editing.view.focus();
|
|
182
191
|
}
|
|
@@ -187,16 +196,12 @@ const RichTextEditorFormComponent = _ref => {
|
|
|
187
196
|
label: label,
|
|
188
197
|
helperText: helperText
|
|
189
198
|
}, React.createElement(RichTextEditor, {
|
|
199
|
+
showCodeBlock: showCodeBlock,
|
|
190
200
|
value: value,
|
|
191
201
|
id: rest.name,
|
|
192
202
|
name: rest.name,
|
|
193
203
|
onReady: editor => {
|
|
194
204
|
editor.setData(value);
|
|
195
|
-
|
|
196
|
-
if (disabled || isSubmitting) {
|
|
197
|
-
editor.enableReadOnlyMode(name);
|
|
198
|
-
}
|
|
199
|
-
|
|
200
205
|
editorRef.current = editor;
|
|
201
206
|
},
|
|
202
207
|
disabled: disabled || isSubmitting,
|