@patternfly/quickstarts 5.4.1 → 5.4.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/index.js CHANGED
@@ -14,7 +14,7 @@ var server = require('react-dom/server');
14
14
  var CopyIcon = require('@patternfly/react-icons/dist/js/icons/copy-icon');
15
15
  var LightbulbIcon = require('@patternfly/react-icons/dist/js/icons/lightbulb-icon');
16
16
  var FireIcon = require('@patternfly/react-icons/dist/js/icons/fire-icon');
17
- var showdown = require('showdown');
17
+ var marked = require('marked');
18
18
  var SyncAltIcon = require('@patternfly/react-icons/dist/js/icons/sync-alt-icon');
19
19
  var CheckCircleIcon = require('@patternfly/react-icons/dist/js/icons/check-circle-icon');
20
20
  var ExclamationCircleIcon = require('@patternfly/react-icons/dist/js/icons/exclamation-circle-icon');
@@ -1320,16 +1320,7 @@ const useMultilineCopyClipboardShowdownExtension = () => {
1320
1320
 
1321
1321
  // eslint-disable-next-line @typescript-eslint/no-require-imports
1322
1322
  const DOMPurify = require('dompurify');
1323
- const markdownConvert = (markdown, extensions) => {
1324
- const converter = new showdown.Converter({
1325
- tables: true,
1326
- openLinksInNewWindow: true,
1327
- strikethrough: true,
1328
- emoji: false,
1329
- });
1330
- if (extensions) {
1331
- converter.addExtension(extensions);
1332
- }
1323
+ const markdownConvert = (markdown, extensions) => tslib.__awaiter(void 0, void 0, void 0, function* () {
1333
1324
  DOMPurify.addHook('beforeSanitizeElements', function (node) {
1334
1325
  // nodeType 1 = element type
1335
1326
  // transform anchor tags
@@ -1356,16 +1347,36 @@ const markdownConvert = (markdown, extensions) => {
1356
1347
  node.setAttribute('xlink:show', 'new');
1357
1348
  }
1358
1349
  });
1359
- return DOMPurify.sanitize(converter.makeHtml(markdown), {
1360
- USE_PROFILES: {
1361
- html: true,
1362
- svg: true,
1363
- },
1364
- });
1365
- };
1350
+ // Replace code fences with non markdown formatting relates tokens so that marked doesn't try to parse them as code spans
1351
+ const markdownWithSubstitutedCodeFences = markdown.replace(/```/g, '@@@');
1352
+ const parsedMarkdown = yield marked.marked.parse(markdownWithSubstitutedCodeFences);
1353
+ // Swap the temporary tokens back to code fences before we run the extensions
1354
+ let md = parsedMarkdown.replace(/@@@/g, '```');
1355
+ if (extensions) {
1356
+ // Convert code spans back to md format before we run the custom extension regexes
1357
+ md = md.replace(/<code>(.*)<\/code>/g, '`$1`');
1358
+ extensions.forEach(({ regex, replace }) => {
1359
+ if (regex) {
1360
+ md = md.replace(regex, replace);
1361
+ }
1362
+ });
1363
+ // Convert any remaining backticks back into code spans
1364
+ md = md.replace(/`(.*)`/g, '<code>$1</code>');
1365
+ }
1366
+ return DOMPurify.sanitize(md);
1367
+ });
1366
1368
  const SyncMarkdownView = ({ content, emptyMsg, extensions, renderExtension, exactHeight, inline, className, }) => {
1367
1369
  const { getResource } = React__namespace.useContext(QuickStartContext);
1368
- const markup = React__namespace.useMemo(() => markdownConvert(content || emptyMsg || getResource('Not available'), extensions), [content, emptyMsg, extensions, getResource]);
1370
+ const [markup, setMarkup] = React__namespace.useState('');
1371
+ React__namespace.useEffect(() => {
1372
+ function getMd() {
1373
+ return tslib.__awaiter(this, void 0, void 0, function* () {
1374
+ const md = yield markdownConvert(content || emptyMsg || getResource('Not available'), extensions);
1375
+ setMarkup(md);
1376
+ });
1377
+ }
1378
+ getMd();
1379
+ }, [content, emptyMsg, getResource, extensions]);
1369
1380
  const innerProps = {
1370
1381
  renderExtension: (extensions === null || extensions === void 0 ? void 0 : extensions.length) > 0 ? renderExtension : undefined,
1371
1382
  exactHeight,
@@ -2030,12 +2041,22 @@ const TaskIcon = ({ taskIndex, taskStatus }) => {
2030
2041
  const QuickStartTaskHeader = ({ title, taskIndex, subtitle, taskStatus, size, isActiveTask, onTaskSelect, children, }) => {
2031
2042
  const titleRef = React__namespace.useRef(null);
2032
2043
  const { focusOnQuickStart } = React__namespace.useContext(QuickStartContext);
2044
+ const [parsedTitle, setParsedTitle] = React__namespace.useState('');
2033
2045
  React__namespace.useEffect(() => {
2034
2046
  if (focusOnQuickStart && isActiveTask) {
2035
2047
  // Focus the WizardNavItem button element that contains the title
2036
2048
  titleRef.current.parentNode.focus();
2037
2049
  }
2038
2050
  }, [focusOnQuickStart, isActiveTask]);
2051
+ React__namespace.useEffect(() => {
2052
+ function getParsedTitle() {
2053
+ return tslib.__awaiter(this, void 0, void 0, function* () {
2054
+ const convertedMdTitle = yield markdownConvert(title);
2055
+ setParsedTitle(removeParagraphWrap(convertedMdTitle));
2056
+ });
2057
+ }
2058
+ getParsedTitle();
2059
+ }, [title]);
2039
2060
  const classNames = reactStyles.css('pfext-quick-start-task-header__title', {
2040
2061
  'pfext-quick-start-task-header__title-success': taskStatus === exports.QuickStartTaskStatus.SUCCESS,
2041
2062
  'pfext-quick-start-task-header__title-failed': taskStatus === (exports.QuickStartTaskStatus.FAILED || exports.QuickStartTaskStatus.VISITED),
@@ -2051,7 +2072,7 @@ const QuickStartTaskHeader = ({ title, taskIndex, subtitle, taskStatus, size, is
2051
2072
  const content = (React__namespace.createElement("div", { className: "pfext-quick-start-task-header", ref: titleRef },
2052
2073
  React__namespace.createElement(TaskIcon, { taskIndex: taskIndex, taskStatus: taskStatus }),
2053
2074
  React__namespace.createElement(reactCore.Title, { headingLevel: "h3", size: size, className: classNames },
2054
- React__namespace.createElement("span", { dangerouslySetInnerHTML: { __html: removeParagraphWrap(markdownConvert(title)) } }),
2075
+ React__namespace.createElement("span", { dangerouslySetInnerHTML: { __html: parsedTitle } }),
2055
2076
  isActiveTask && subtitle && (React__namespace.createElement("span", { className: "pfext-quick-start-task-header__subtitle", "data-test-id": "quick-start-task-subtitle" },
2056
2077
  ' ',
2057
2078
  subtitle))),
@@ -2248,6 +2269,7 @@ const QuickStartPanelContent = (_a) => {
2248
2269
  const titleRef = React__namespace.useRef(null);
2249
2270
  const { getResource, activeQuickStartState, focusOnQuickStart } = React__namespace.useContext(QuickStartContext);
2250
2271
  const [contentRef, setContentRef] = React__namespace.useState();
2272
+ const [displayName, setDisplayName] = React__namespace.useState('');
2251
2273
  const shadows = useScrollShadows(contentRef);
2252
2274
  const quickStart = quickStarts.find((qs) => qs.metadata.name === activeQuickStartID);
2253
2275
  const taskNumber = activeQuickStartState === null || activeQuickStartState === void 0 ? void 0 : activeQuickStartState.taskNumber;
@@ -2275,13 +2297,22 @@ const QuickStartPanelContent = (_a) => {
2275
2297
  titleRef.current.focus();
2276
2298
  }
2277
2299
  }, [focusOnQuickStart, quickStart]);
2300
+ React__namespace.useEffect(() => {
2301
+ function getDisplayName() {
2302
+ return tslib.__awaiter(this, void 0, void 0, function* () {
2303
+ const convertedMdDisplayName = yield markdownConvert(quickStart === null || quickStart === void 0 ? void 0 : quickStart.spec.displayName);
2304
+ setDisplayName(removeParagraphWrap(convertedMdDisplayName));
2305
+ });
2306
+ }
2307
+ getDisplayName();
2308
+ }, [quickStart]);
2278
2309
  const content = quickStart ? (React__namespace.createElement(reactCore.DrawerPanelContent, Object.assign({ isResizable: isResizable, className: "pfext-quick-start__base", "data-testid": `qs-drawer-${camelize(quickStart.spec.displayName)}`, "data-qs": `qs-step-${getStep()}`, "data-test": "quickstart drawer" }, props),
2279
2310
  React__namespace.createElement("div", { className: headerClasses },
2280
2311
  React__namespace.createElement(reactCore.DrawerHead, null,
2281
2312
  React__namespace.createElement("div", { className: "pfext-quick-start-panel-content__title", tabIndex: -1, ref: titleRef },
2282
2313
  React__namespace.createElement(reactCore.Title, { headingLevel: "h2", size: "xl", className: "pfext-quick-start-panel-content__name", style: { marginRight: 'var(--pf-v5-global--spacer--md)' } },
2283
2314
  React__namespace.createElement("span", { dangerouslySetInnerHTML: {
2284
- __html: removeParagraphWrap(markdownConvert(quickStart === null || quickStart === void 0 ? void 0 : quickStart.spec.displayName)),
2315
+ __html: displayName,
2285
2316
  } }),
2286
2317
  ' ',
2287
2318
  React__namespace.createElement("small", { className: "pfext-quick-start-panel-content__duration" }, (quickStart === null || quickStart === void 0 ? void 0 : quickStart.spec.durationMinutes)