@rh-support/components 2.1.93 → 2.2.0-alpha.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.
|
@@ -28,25 +28,3 @@
|
|
|
28
28
|
.hide-in-pdf {
|
|
29
29
|
display: none !important;
|
|
30
30
|
}
|
|
31
|
-
|
|
32
|
-
@media (max-width: 401px) {
|
|
33
|
-
.edit-actions {
|
|
34
|
-
top: 4.75rem !important;
|
|
35
|
-
margin-right: -1rem !important;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
.pull-right {
|
|
39
|
-
margin-top: 2rem;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
@media (max-width: 417px) and (min-width: 401px) {
|
|
44
|
-
.edit-actions {
|
|
45
|
-
top: 7rem !important;
|
|
46
|
-
margin-right: -1rem !important;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
.pull-right {
|
|
50
|
-
margin-top: 2rem;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarkdownEditor.d.ts","sourceRoot":"","sources":["../../../src/MarkdownEditor/MarkdownEditor.tsx"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAE9B,OAAO,EAAE,WAAW,EAAE,MAAM,2CAA2C,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAwB,MAAM,qBAAqB,CAAC;AAgC7E,OAAO,KAAK,EAAE,EAAE,SAAS,EAA+B,MAAM,OAAO,CAAC;AAKtE,oBAAY,UAAU;IAClB,KAAK,cAAc;IACnB,QAAQ,aAAa;CACxB;AAED,UAAU,kBAAkB;IACxB,yBAAyB,EAAE,OAAO,CAAC;IACnC,SAAS,EAAE,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC;IAClC,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC;IACnD,YAAY,EAAE,C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Y,CAAC,EAAE,CAAC,GAAG,EAAE,mBAAmB,KAAK,IAAI,CAAC;IAClD,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,2BAA2B,CAAC,EAAE,OAAO,CAAC;IACtC,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,yBAAyB,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,CAAC;IAClD,iBAAiB,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,CAAC;CACnD;AAuBD,iBAAS,cAAc,CAAC,KAAK,EAAE,cAAc,qBAy1B5C;kBAz1BQ,cAAc;;;AA61BvB,OAAO,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -54,9 +54,9 @@ const defaultProps = {
|
|
|
54
54
|
};
|
|
55
55
|
function MarkdownEditor(props) {
|
|
56
56
|
const { t } = useTranslation();
|
|
57
|
-
const { hidePreviewText, showPreviewText, mdPlaceholder, plainTextPlaceholder, textAreaClassName, bindTextArea, markedownOptions, allowEmoji, hideHeadingOptions, rows, showMarkdownPlainTextToggle, editorMode, className, charLimit, minCharsForCounter, id,
|
|
57
|
+
const { hidePreviewText, showPreviewText, mdPlaceholder, plainTextPlaceholder, textAreaClassName, bindTextArea, markedownOptions, allowEmoji, hideHeadingOptions, rows, showMarkdownPlainTextToggle, editorMode, className, charLimit, minCharsForCounter, id, onCommentExceedCharsLimit, fileSelectorProps: { onClipboardPaste, onFileDelete, onFileSelect, isSupportedFile, showFileSelectorInToolbar = false, isUploadingFile = false, filesList = [], attachFileBtn, } } = props, textAreaProps = __rest(props, ["hidePreviewText", "showPreviewText", "mdPlaceholder", "plainTextPlaceholder", "textAreaClassName", "bindTextArea", "markedownOptions", "allowEmoji", "hideHeadingOptions", "rows", "showMarkdownPlainTextToggle", "editorMode", "className", "charLimit", "minCharsForCounter", "id", "onCommentExceedCharsLimit", "fileSelectorProps"]);
|
|
58
58
|
const [isPreview, setIsPreview] = useState(false);
|
|
59
|
-
const [mdValue, setMdValue] = useState(props.value
|
|
59
|
+
const [mdValue, setMdValue] = useState(props.value);
|
|
60
60
|
const previousFileList = usePrevious(filesList);
|
|
61
61
|
const [isPlainModeEnabled, setIsPlainModeEnabled] = useState(showMarkdownPlainTextToggle && props.editorMode === EditorMode.PLAIN ? true : false);
|
|
62
62
|
const textareaRef = useRef(null);
|
|
@@ -157,26 +157,16 @@ function MarkdownEditor(props) {
|
|
|
157
157
|
const mode = isPlainMode ? EditorMode.PLAIN : EditorMode.MARKDOWN;
|
|
158
158
|
props.onChange(mdValue, mode);
|
|
159
159
|
};
|
|
160
|
-
// Add this useEffect to properly initialize the mdValue when component mounts
|
|
161
160
|
useEffect(() => {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
// Update the existing useEffect to handle both value and editorMode changes
|
|
165
|
-
useEffect(() => {
|
|
166
|
-
if (value !== mdValue) {
|
|
167
|
-
setMdValue(value);
|
|
161
|
+
if (mdValue !== props.value) {
|
|
162
|
+
setMdValue(props.value);
|
|
168
163
|
}
|
|
169
|
-
|
|
170
|
-
}, [value]);
|
|
164
|
+
}, [mdValue, props.value]);
|
|
171
165
|
useEffect(() => {
|
|
172
|
-
const isPlainMode = props.editorMode === EditorMode.PLAIN;
|
|
173
|
-
if (isPlainMode
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
if (isPlainMode && isPreview) {
|
|
177
|
-
setIsPreview(false);
|
|
178
|
-
}
|
|
179
|
-
}
|
|
166
|
+
const isPlainMode = props.editorMode === EditorMode.PLAIN ? true : false;
|
|
167
|
+
if (isPlainMode === isPlainModeEnabled)
|
|
168
|
+
return;
|
|
169
|
+
onModeChange(isPlainMode);
|
|
180
170
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
181
171
|
}, [props.editorMode]);
|
|
182
172
|
useEffect(() => {
|
|
@@ -193,8 +183,8 @@ function MarkdownEditor(props) {
|
|
|
193
183
|
}, [mdValue], 500);
|
|
194
184
|
const onValueChangeLocal = (text) => {
|
|
195
185
|
const mode = showMarkdownPlainTextToggle && isPlainModeEnabled ? EditorMode.PLAIN : EditorMode.MARKDOWN;
|
|
196
|
-
setMdValue(text);
|
|
197
186
|
props.onChange(text, mode);
|
|
187
|
+
setMdValue(text);
|
|
198
188
|
};
|
|
199
189
|
const textChanged = (event) => {
|
|
200
190
|
let value = event.target.value;
|
|
@@ -202,12 +192,7 @@ function MarkdownEditor(props) {
|
|
|
202
192
|
value = value.replace(emojiPattern, '').trim();
|
|
203
193
|
}
|
|
204
194
|
onValueChangeLocal(value);
|
|
205
|
-
|
|
206
|
-
if (props.onCommentExceedCharsLimit) {
|
|
207
|
-
charLimit - value.length < 0
|
|
208
|
-
? props.onCommentExceedCharsLimit(true)
|
|
209
|
-
: props.onCommentExceedCharsLimit(false);
|
|
210
|
-
}
|
|
195
|
+
charLimit - value.length < 0 ? props.onCommentExceedCharsLimit(true) : props.onCommentExceedCharsLimit(false);
|
|
211
196
|
};
|
|
212
197
|
const hasSelection = () => {
|
|
213
198
|
return textareaRef.current.selectionStart !== textareaRef.current.selectionEnd;
|
|
@@ -227,12 +212,11 @@ function MarkdownEditor(props) {
|
|
|
227
212
|
templateEnd +
|
|
228
213
|
trailingWhitespace +
|
|
229
214
|
currentText.substring(posEnd);
|
|
230
|
-
|
|
215
|
+
onValueChangeLocal(newText);
|
|
231
216
|
textareaRef.current.value = newText;
|
|
232
217
|
textareaRef.current.selectionStart = posEnd + templateStart.length + templateEnd.length;
|
|
233
218
|
textareaRef.current.selectionEnd = textareaRef.current.selectionStart;
|
|
234
219
|
textareaRef.current.focus();
|
|
235
|
-
// Call onValueChangeLocal only once
|
|
236
220
|
onValueChangeLocal(newText);
|
|
237
221
|
};
|
|
238
222
|
const wrapBasedOnNewLines = () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rh-support/components",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0-alpha.0",
|
|
4
4
|
"description": "Contains all reusabel components for support app",
|
|
5
5
|
"author": "Vikas Rathee <vrathee@redhat.com>",
|
|
6
6
|
"license": "ISC",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"prepublishOnly": "npm run build"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
|
-
"@cee-eng/hydrajs": "4.17.
|
|
47
|
+
"@cee-eng/hydrajs": "4.17.26",
|
|
48
48
|
"@cee-eng/ui-toolkit": "1.1.8",
|
|
49
49
|
"@patternfly/patternfly": "5.4.0",
|
|
50
50
|
"@patternfly/react-core": "5.4.0",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"use-deep-compare-effect": "^1.6.1"
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@cee-eng/hydrajs": "4.17.
|
|
65
|
+
"@cee-eng/hydrajs": "4.17.26",
|
|
66
66
|
"@cee-eng/ui-toolkit": "1.1.8",
|
|
67
67
|
"@patternfly/patternfly": "5.4.0",
|
|
68
68
|
"@patternfly/react-core": "5.4.0",
|
|
@@ -70,8 +70,8 @@
|
|
|
70
70
|
"@patternfly/react-table": "5.1.1",
|
|
71
71
|
"@patternfly/react-tokens": "^5.4.0",
|
|
72
72
|
"@rh-support/types": "2.0.5",
|
|
73
|
-
"@rh-support/user-permissions": "2.
|
|
74
|
-
"@rh-support/utils": "2.
|
|
73
|
+
"@rh-support/user-permissions": "2.2.0-alpha.0",
|
|
74
|
+
"@rh-support/utils": "2.2.0-alpha.0",
|
|
75
75
|
"dompurify": "^2.2.6",
|
|
76
76
|
"downshift": "^6.0.5",
|
|
77
77
|
"js-worker-search": "^1.4.1",
|
|
@@ -111,5 +111,5 @@
|
|
|
111
111
|
"defaults and supports es6-module",
|
|
112
112
|
"maintained node versions"
|
|
113
113
|
],
|
|
114
|
-
"gitHead": "
|
|
114
|
+
"gitHead": "adbfb4aacbf67de864e57d292d02fedc7589567b"
|
|
115
115
|
}
|