@rh-support/components 2.4.3-beta.5 → 2.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.
@@ -28,3 +28,25 @@
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,CAAC,IAAI,EAAE,OAAO,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC;IACnD,gBAAgB,EAAE,CAAC,IAAI,KAAA,KAAK,IAAI,CAAC;IACjC,eAAe,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC;IAChD,aAAa,EAAE,KAAK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ACvB,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,qBA62B5C;kBA72BQ,cAAc;;;AAi3BvB,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, 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"]);
57
+ const { hidePreviewText, showPreviewText, mdPlaceholder, plainTextPlaceholder, textAreaClassName, bindTextArea, markedownOptions, allowEmoji, hideHeadingOptions, rows, showMarkdownPlainTextToggle, editorMode, className, charLimit, minCharsForCounter, id, value, 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", "value", "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,16 +157,26 @@ 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
160
161
  useEffect(() => {
161
- if (mdValue !== props.value) {
162
- setMdValue(props.value);
162
+ setMdValue(props.value || '');
163
+ }, [props.value]);
164
+ // Update the existing useEffect to handle both value and editorMode changes
165
+ useEffect(() => {
166
+ if (value !== mdValue) {
167
+ setMdValue(value);
163
168
  }
164
- }, [mdValue, props.value]);
169
+ // eslint-disable-next-line react-hooks/exhaustive-deps
170
+ }, [value]);
165
171
  useEffect(() => {
166
- const isPlainMode = props.editorMode === EditorMode.PLAIN ? true : false;
167
- if (isPlainMode === isPlainModeEnabled)
168
- return;
169
- onModeChange(isPlainMode);
172
+ const isPlainMode = props.editorMode === EditorMode.PLAIN;
173
+ if (isPlainMode !== isPlainModeEnabled) {
174
+ setIsPlainModeEnabled(isPlainMode);
175
+ isPlainModeEnabledRef.current = isPlainMode;
176
+ if (isPlainMode && isPreview) {
177
+ setIsPreview(false);
178
+ }
179
+ }
170
180
  // eslint-disable-next-line react-hooks/exhaustive-deps
171
181
  }, [props.editorMode]);
172
182
  useEffect(() => {
@@ -183,8 +193,8 @@ function MarkdownEditor(props) {
183
193
  }, [mdValue], 500);
184
194
  const onValueChangeLocal = (text) => {
185
195
  const mode = showMarkdownPlainTextToggle && isPlainModeEnabled ? EditorMode.PLAIN : EditorMode.MARKDOWN;
186
- props.onChange(text, mode);
187
196
  setMdValue(text);
197
+ props.onChange(text, mode);
188
198
  };
189
199
  const textChanged = (event) => {
190
200
  let value = event.target.value;
@@ -192,7 +202,12 @@ function MarkdownEditor(props) {
192
202
  value = value.replace(emojiPattern, '').trim();
193
203
  }
194
204
  onValueChangeLocal(value);
195
- charLimit - value.length < 0 ? props.onCommentExceedCharsLimit(true) : props.onCommentExceedCharsLimit(false);
205
+ // Add a null check before calling onCommentExceedCharsLimit
206
+ if (props.onCommentExceedCharsLimit) {
207
+ charLimit - value.length < 0
208
+ ? props.onCommentExceedCharsLimit(true)
209
+ : props.onCommentExceedCharsLimit(false);
210
+ }
196
211
  };
197
212
  const hasSelection = () => {
198
213
  return textareaRef.current.selectionStart !== textareaRef.current.selectionEnd;
@@ -212,11 +227,12 @@ function MarkdownEditor(props) {
212
227
  templateEnd +
213
228
  trailingWhitespace +
214
229
  currentText.substring(posEnd);
215
- onValueChangeLocal(newText);
230
+ // Set the value in the textarea
216
231
  textareaRef.current.value = newText;
217
232
  textareaRef.current.selectionStart = posEnd + templateStart.length + templateEnd.length;
218
233
  textareaRef.current.selectionEnd = textareaRef.current.selectionStart;
219
234
  textareaRef.current.focus();
235
+ // Call onValueChangeLocal only once
220
236
  onValueChangeLocal(newText);
221
237
  };
222
238
  const wrapBasedOnNewLines = () => {
@@ -432,7 +448,7 @@ function MarkdownEditor(props) {
432
448
  showFileSelectorInToolbar && (React.createElement(Dropdown, { onSelect: onFileSelectLocal, id: "md-editor-toolbar-file-selector", toggle: React.createElement(DropdownToggle, { "aria-label": "file selector", onToggle: (_event, isOpen) => onFileSelectToggle(isOpen), isDisabled: props.disabled || isPreview },
433
449
  React.createElement(ImageIcon, null)), dropdownItems: getFileSelectorList(), tabIndex: -1, isPlain: true, menuAppendTo: document.body, isOpen: isFileSelectorOpen, "data-tracking-id": "md-editor-toolbar-file-selector" }))),
434
450
  React.createElement(ToolbarItem, null, markdownGuidanceBtn)),
435
- React.createElement(Toolbar, null,
451
+ React.createElement(Toolbar, { className: "mobile-markdown-toolbar" },
436
452
  React.createElement("div", { className: "mobile-markdown-toolbar" },
437
453
  React.createElement(ToolbarGroup, { spaceItems: { default: 'spaceItemsNone' }, "data-tracking-id": "mobile-md-editor-toolbar", className: "markdown-toolbar-left-section" },
438
454
  !props.hideHeadingOptions && (React.createElement(Dropdown, { isText: true, isPlain: true, onSelect: onHeadingSelect, toggle: React.createElement(DropdownToggle, { id: "heading-selector", onToggle: onToggle }, "Heading"), isOpen: isHeadingDropdownOpen, dropdownItems: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rh-support/components",
3
- "version": "2.4.3-beta.5",
3
+ "version": "2.5.0",
4
4
  "description": "Contains all reusabel components for support app",
5
5
  "author": "Vikas Rathee <vrathee@redhat.com>",
6
6
  "license": "ISC",
@@ -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.4.3-beta.5",
74
- "@rh-support/utils": "2.4.3-beta.5",
73
+ "@rh-support/user-permissions": "2.5.0",
74
+ "@rh-support/utils": "2.5.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": "259d82237f1bce282e2d569e85b32233d3c4a4a6"
114
+ "gitHead": "d867a78014ee4a08aa8d7bf9e0dc9bd08ce6ac5a"
115
115
  }