@patternfly/quickstarts 6.2.0-prerelease.4 → 6.2.0-prerelease.6
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/ConsoleInternal/components/markdown-view.d.ts +1 -1
- package/dist/index.es.js +38 -20
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +37 -19
- package/dist/index.js.map +1 -1
- package/dist/quickstarts-full.es.js +2458 -4932
- package/dist/quickstarts-full.es.js.map +1 -1
- package/package.json +2 -2
- package/src/ConsoleInternal/components/markdown-view.tsx +46 -23
|
@@ -4,7 +4,7 @@ interface ShowdownExtension {
|
|
|
4
4
|
regex?: RegExp;
|
|
5
5
|
replace?: (...args: any[]) => string;
|
|
6
6
|
}
|
|
7
|
-
export declare const markdownConvert: (markdown:
|
|
7
|
+
export declare const markdownConvert: (markdown: string, extensions?: ShowdownExtension[]) => Promise<any>;
|
|
8
8
|
interface SyncMarkdownProps {
|
|
9
9
|
content?: string;
|
|
10
10
|
emptyMsg?: string;
|
package/dist/index.es.js
CHANGED
|
@@ -4,14 +4,14 @@ import { useIsomorphicLayoutEffect, Tooltip, Alert, CodeBlock, Accordion, Accord
|
|
|
4
4
|
import SearchIcon from '@patternfly/react-icons/dist/js/icons/search-icon';
|
|
5
5
|
import { css } from '@patternfly/react-styles';
|
|
6
6
|
import RocketIcon from '@patternfly/react-icons/dist/js/icons/rocket-icon';
|
|
7
|
-
import { __rest } from 'tslib';
|
|
7
|
+
import { __rest, __awaiter } from 'tslib';
|
|
8
8
|
import { Modal as Modal$1, ModalVariant } from '@patternfly/react-core/deprecated';
|
|
9
9
|
import * as ReactDOM from 'react-dom';
|
|
10
10
|
import { renderToStaticMarkup } from 'react-dom/server';
|
|
11
11
|
import CopyIcon from '@patternfly/react-icons/dist/js/icons/copy-icon';
|
|
12
12
|
import LightbulbIcon from '@patternfly/react-icons/dist/js/icons/lightbulb-icon';
|
|
13
13
|
import FireIcon from '@patternfly/react-icons/dist/js/icons/fire-icon';
|
|
14
|
-
import {
|
|
14
|
+
import { marked } from 'marked';
|
|
15
15
|
import SyncAltIcon from '@patternfly/react-icons/dist/js/icons/sync-alt-icon';
|
|
16
16
|
import CheckCircleIcon from '@patternfly/react-icons/dist/js/icons/check-circle-icon';
|
|
17
17
|
import '@patternfly/react-icons/dist/js/icons/exclamation-circle-icon';
|
|
@@ -1168,16 +1168,7 @@ const useMultilineCopyClipboardShowdownExtension = () => {
|
|
|
1168
1168
|
|
|
1169
1169
|
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
1170
1170
|
const DOMPurify = require('dompurify');
|
|
1171
|
-
const markdownConvert = (markdown, extensions) => {
|
|
1172
|
-
const converter = new Converter({
|
|
1173
|
-
tables: true,
|
|
1174
|
-
openLinksInNewWindow: true,
|
|
1175
|
-
strikethrough: true,
|
|
1176
|
-
emoji: false,
|
|
1177
|
-
});
|
|
1178
|
-
if (extensions) {
|
|
1179
|
-
converter.addExtension(extensions);
|
|
1180
|
-
}
|
|
1171
|
+
const markdownConvert = (markdown, extensions) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1181
1172
|
DOMPurify.addHook('beforeSanitizeElements', function (node) {
|
|
1182
1173
|
// nodeType 1 = element type
|
|
1183
1174
|
var _a;
|
|
@@ -1228,16 +1219,43 @@ const markdownConvert = (markdown, extensions) => {
|
|
|
1228
1219
|
node.setAttribute('xlink:show', 'new');
|
|
1229
1220
|
}
|
|
1230
1221
|
});
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1222
|
+
const reverseString = (str) => str.split('').reverse().join('');
|
|
1223
|
+
// replace code fences that end in a double curly brace (which are used by our custom md extensions) with non
|
|
1224
|
+
// markdown formatting related tokens so that marked doesn't try to parse them as code spans
|
|
1225
|
+
//
|
|
1226
|
+
// we want to reverse the string before we do the substitution so that we only match the opening code fence which
|
|
1227
|
+
// corresponds to the closing code fence with the double curly brace
|
|
1228
|
+
const reversedMarkdown = reverseString(markdown);
|
|
1229
|
+
const reverseMarkdownWithSubstitutedCodeFences = reversedMarkdown.replace(/{{```((.|\n)*?)```/g, '{{@@@$1@@@');
|
|
1230
|
+
const markdownWithSubstitutedCodeFences = reverseString(reverseMarkdownWithSubstitutedCodeFences);
|
|
1231
|
+
const parsedMarkdown = yield marked.parse(markdownWithSubstitutedCodeFences);
|
|
1232
|
+
// Swap the temporary tokens back to code fences before we run the extensions
|
|
1233
|
+
let md = parsedMarkdown.replace(/@@@/g, '```');
|
|
1234
|
+
if (extensions) {
|
|
1235
|
+
// Convert code spans back to md format before we run the custom extension regexes
|
|
1236
|
+
md = md.replace(/<code>(.*)<\/code>/g, '`$1`');
|
|
1237
|
+
extensions.forEach(({ regex, replace }) => {
|
|
1238
|
+
if (regex) {
|
|
1239
|
+
md = md.replace(regex, replace);
|
|
1240
|
+
}
|
|
1241
|
+
});
|
|
1242
|
+
// Convert any remaining backticks back into code spans
|
|
1243
|
+
md = md.replace(/`(.*)`/g, '<code>$1</code>');
|
|
1244
|
+
}
|
|
1245
|
+
return DOMPurify.sanitize(md);
|
|
1246
|
+
});
|
|
1238
1247
|
const SyncMarkdownView = ({ content, emptyMsg, extensions, renderExtension, exactHeight, inline, className, }) => {
|
|
1239
1248
|
const { getResource } = React.useContext(QuickStartContext);
|
|
1240
|
-
const markup = React.
|
|
1249
|
+
const [markup, setMarkup] = React.useState('');
|
|
1250
|
+
React.useEffect(() => {
|
|
1251
|
+
function getMd() {
|
|
1252
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1253
|
+
const md = yield markdownConvert(content || emptyMsg || getResource('Not available'), extensions);
|
|
1254
|
+
setMarkup(md);
|
|
1255
|
+
});
|
|
1256
|
+
}
|
|
1257
|
+
getMd();
|
|
1258
|
+
}, [content, emptyMsg, getResource, extensions]);
|
|
1241
1259
|
const innerProps = {
|
|
1242
1260
|
renderExtension: (extensions === null || extensions === void 0 ? void 0 : extensions.length) > 0 ? renderExtension : undefined,
|
|
1243
1261
|
exactHeight,
|