@patternfly/quickstarts 2.3.0 → 2.3.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.
@@ -2,6 +2,6 @@ import './showdown-extension.scss';
2
2
  declare const useInlineCopyClipboardShowdownExtension: () => {
3
3
  type: string;
4
4
  regex: RegExp;
5
- replace: (text: string, group: string, subGroup: string, groupType: string, groupId: string) => string;
5
+ replace: (text: string, group: string, _: string, groupId: number) => string;
6
6
  };
7
7
  export default useInlineCopyClipboardShowdownExtension;
@@ -2,6 +2,6 @@ import './showdown-extension.scss';
2
2
  declare const useMultilineCopyClipboardShowdownExtension: () => {
3
3
  type: string;
4
4
  regex: RegExp;
5
- replace: (text: string, group: string, subgroup: string, groupType: string, groupId: string) => string;
5
+ replace: (text: string, group: string, _1: string, _2: string, groupId: number) => string;
6
6
  };
7
7
  export default useMultilineCopyClipboardShowdownExtension;
package/dist/index.es.js CHANGED
@@ -1201,12 +1201,13 @@ const CopyClipboard = ({ element, rootSelector, docContext, }) => {
1201
1201
  const { getResource } = React.useContext(QuickStartContext);
1202
1202
  const [showSuccessContent, setShowSuccessContent] = React.useState(false);
1203
1203
  const textToCopy = React.useMemo(() => {
1204
+ var _a;
1204
1205
  const copyTextId = element.getAttribute(MARKDOWN_COPY_BUTTON_ID);
1205
- return docContext.querySelector(`${rootSelector} [${MARKDOWN_SNIPPET_ID}="${copyTextId}"]`).innerText;
1206
+ return (_a = docContext.querySelector(`${rootSelector} [${MARKDOWN_SNIPPET_ID}="${copyTextId}"]`)) === null || _a === void 0 ? void 0 : _a.innerText;
1206
1207
  }, [element, docContext, rootSelector]);
1207
1208
  useEventListener(element, 'click', React.useCallback(() => {
1208
1209
  navigator.clipboard
1209
- .writeText(textToCopy)
1210
+ .writeText(textToCopy.trim())
1210
1211
  .then(() => {
1211
1212
  setShowSuccessContent(true);
1212
1213
  })
@@ -1233,16 +1234,16 @@ const useInlineCopyClipboardShowdownExtension = () => {
1233
1234
  const { getResource } = React.useContext(QuickStartContext);
1234
1235
  return React.useMemo(() => ({
1235
1236
  type: 'lang',
1236
- regex: /```[\n]\s*((((?!```).)*?\n)+)\s*```{{copy}}/g,
1237
- replace: (text, group, subGroup, groupType, groupId) => {
1238
- if (!group || !subGroup || !groupType || !groupId) {
1237
+ regex: /`([^`](.*?)[^`])`{{copy}}/g,
1238
+ replace: (text, group, _, groupId) => {
1239
+ if (!group || isNaN(groupId)) {
1239
1240
  return text;
1240
1241
  }
1241
1242
  return removeTemplateWhitespace(`<span class="pf-c-clipboard-copy pf-m-inline">
1242
- <span class="pf-c-clipboard-copy__text" ${MARKDOWN_SNIPPET_ID}="${groupType}">${group}</span>
1243
+ <span class="pf-c-clipboard-copy__text" ${MARKDOWN_SNIPPET_ID}="${groupId}">${group}</span>
1243
1244
  <span class="pf-c-clipboard-copy__actions">
1244
1245
  <span class="pf-c-clipboard-copy__actions-item">
1245
- <button class="pf-c-button pf-m-plain" aria-label="${getResource('Copy to clipboard')}" ${MARKDOWN_COPY_BUTTON_ID}="${groupType}">
1246
+ <button class="pf-c-button pf-m-plain" aria-label="${getResource('Copy to clipboard')}" ${MARKDOWN_COPY_BUTTON_ID}="${groupId}">
1246
1247
  ${renderToStaticMarkup(React.createElement(CopyIcon, null))}
1247
1248
  </button>
1248
1249
  </span>
@@ -1256,16 +1257,16 @@ const useMultilineCopyClipboardShowdownExtension = () => {
1256
1257
  const { getResource } = React.useContext(QuickStartContext);
1257
1258
  return React.useMemo(() => ({
1258
1259
  type: 'lang',
1259
- regex: /```[\n]((.*?\n)+)```{{copy}}/g,
1260
- replace: (text, group, subgroup, groupType, groupId) => {
1261
- if (!group || !subgroup || !groupType || !groupId) {
1260
+ regex: /```[\n]\s*((((?!```).)*?\n)+)\s*```{{copy}}/g,
1261
+ replace: (text, group, _1, _2, groupId) => {
1262
+ if (!group || isNaN(groupId)) {
1262
1263
  return text;
1263
1264
  }
1264
1265
  return `<div class="pf-c-code-block">
1265
1266
  <div class="pf-c-code-block__header">
1266
1267
  <div class="pf-c-code-block__actions">
1267
1268
  <div class="pf-c-code-block__actions-item">
1268
- <button class="pf-c-button pf-m-plain" type="button" aria-label="${getResource('Copy to clipboard')}" ${MARKDOWN_COPY_BUTTON_ID}="${groupType}">
1269
+ <button class="pf-c-button pf-m-plain" type="button" aria-label="${getResource('Copy to clipboard')}" ${MARKDOWN_COPY_BUTTON_ID}="${groupId}">
1269
1270
  ${renderToStaticMarkup(React.createElement(CopyIcon, null))}
1270
1271
  </button>
1271
1272
  </div>
@@ -1274,7 +1275,7 @@ const useMultilineCopyClipboardShowdownExtension = () => {
1274
1275
  <div class="pf-c-code-block__content">
1275
1276
  <pre class="pf-c-code-block__pre pfext-code-block__pre">
1276
1277
  <code class="pf-c-code-block__code"
1277
- ${MARKDOWN_SNIPPET_ID}="${groupType}">${group}</code>
1278
+ ${MARKDOWN_SNIPPET_ID}="${groupId}">${group.trim()}</code>
1278
1279
  </pre>
1279
1280
  </div>
1280
1281
  </div>`;