@backstage/plugin-techdocs 1.3.0 → 1.3.1-next.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/CHANGELOG.md +37 -0
- package/dist/esm/{TechDocsCustomHome-23b75ea1.esm.js → TechDocsCustomHome-3c888994.esm.js} +2 -2
- package/dist/esm/{TechDocsCustomHome-23b75ea1.esm.js.map → TechDocsCustomHome-3c888994.esm.js.map} +1 -1
- package/dist/esm/{index-248fb87c.esm.js → index-2ba55936.esm.js} +372 -219
- package/dist/esm/index-2ba55936.esm.js.map +1 -0
- package/dist/esm/{index-7bae3ba3.esm.js → index-4754b215.esm.js} +2 -2
- package/dist/esm/index-4754b215.esm.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.esm.js +1 -1
- package/package.json +13 -13
- package/dist/esm/index-248fb87c.esm.js.map +0 -1
- package/dist/esm/index-7bae3ba3.esm.js.map +0 -1
|
@@ -92,7 +92,9 @@ class TechDocsStorageClient {
|
|
|
92
92
|
const { kind, namespace, name } = entityId;
|
|
93
93
|
const storageUrl = await this.getStorageUrl();
|
|
94
94
|
const url = `${storageUrl}/${namespace}/${kind}/${name}/${path}`;
|
|
95
|
-
const request = await this.fetchApi.fetch(
|
|
95
|
+
const request = await this.fetchApi.fetch(
|
|
96
|
+
`${url.endsWith("/") ? url : `${url}/`}index.html`
|
|
97
|
+
);
|
|
96
98
|
let errorMessage = "";
|
|
97
99
|
switch (request.status) {
|
|
98
100
|
case 404:
|
|
@@ -147,7 +149,10 @@ class TechDocsStorageClient {
|
|
|
147
149
|
const { kind, namespace, name } = entityId;
|
|
148
150
|
const apiOrigin = await this.getApiOrigin();
|
|
149
151
|
const newBaseUrl = `${apiOrigin}/static/docs/${namespace}/${kind}/${name}/${path}`;
|
|
150
|
-
return new URL(
|
|
152
|
+
return new URL(
|
|
153
|
+
oldBaseUrl,
|
|
154
|
+
newBaseUrl.endsWith("/") ? newBaseUrl : `${newBaseUrl}/`
|
|
155
|
+
).toString();
|
|
151
156
|
}
|
|
152
157
|
}
|
|
153
158
|
|
|
@@ -228,7 +233,10 @@ function useReaderState(kind, namespace, name, path) {
|
|
|
228
233
|
const { retry: contentReload } = useAsyncRetry(async () => {
|
|
229
234
|
dispatch({ type: "contentLoading" });
|
|
230
235
|
try {
|
|
231
|
-
const entityDocs = await techdocsStorageApi.getEntityDocs(
|
|
236
|
+
const entityDocs = await techdocsStorageApi.getEntityDocs(
|
|
237
|
+
{ kind, namespace, name },
|
|
238
|
+
path
|
|
239
|
+
);
|
|
232
240
|
dispatch({ type: "content", content: entityDocs, path });
|
|
233
241
|
return entityDocs;
|
|
234
242
|
} catch (e) {
|
|
@@ -248,13 +256,16 @@ function useReaderState(kind, namespace, name, path) {
|
|
|
248
256
|
dispatch({ type: "sync", state: "BUILDING" });
|
|
249
257
|
}, 1e3);
|
|
250
258
|
try {
|
|
251
|
-
const result = await techdocsStorageApi.syncEntityDocs(
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
259
|
+
const result = await techdocsStorageApi.syncEntityDocs(
|
|
260
|
+
{
|
|
261
|
+
kind,
|
|
262
|
+
namespace,
|
|
263
|
+
name
|
|
264
|
+
},
|
|
265
|
+
(log) => {
|
|
266
|
+
dispatch({ type: "buildLog", log });
|
|
267
|
+
}
|
|
268
|
+
);
|
|
258
269
|
switch (result) {
|
|
259
270
|
case "updated":
|
|
260
271
|
if (!contentRef.current.content) {
|
|
@@ -281,11 +292,14 @@ function useReaderState(kind, namespace, name, path) {
|
|
|
281
292
|
clearTimeout(buildingTimeout);
|
|
282
293
|
}
|
|
283
294
|
}, [kind, name, namespace, techdocsStorageApi, dispatch, contentRef]);
|
|
284
|
-
const displayState = useMemo(
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
295
|
+
const displayState = useMemo(
|
|
296
|
+
() => calculateDisplayState({
|
|
297
|
+
activeSyncState: state.activeSyncState,
|
|
298
|
+
contentLoading: state.contentLoading,
|
|
299
|
+
content: state.content
|
|
300
|
+
}),
|
|
301
|
+
[state.activeSyncState, state.content, state.contentLoading]
|
|
302
|
+
);
|
|
289
303
|
return {
|
|
290
304
|
state: displayState,
|
|
291
305
|
contentReload,
|
|
@@ -510,25 +524,27 @@ const TechDocsSearch = (props) => {
|
|
|
510
524
|
}));
|
|
511
525
|
};
|
|
512
526
|
|
|
513
|
-
const useDrawerStyles = makeStyles(
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
527
|
+
const useDrawerStyles = makeStyles(
|
|
528
|
+
(theme) => createStyles({
|
|
529
|
+
paper: {
|
|
530
|
+
width: "100%",
|
|
531
|
+
[theme.breakpoints.up("sm")]: {
|
|
532
|
+
width: "75%"
|
|
533
|
+
},
|
|
534
|
+
[theme.breakpoints.up("md")]: {
|
|
535
|
+
width: "50%"
|
|
536
|
+
},
|
|
537
|
+
padding: theme.spacing(2.5)
|
|
518
538
|
},
|
|
519
|
-
|
|
520
|
-
|
|
539
|
+
root: {
|
|
540
|
+
height: "100%",
|
|
541
|
+
overflow: "hidden"
|
|
521
542
|
},
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
},
|
|
528
|
-
logs: {
|
|
529
|
-
background: theme.palette.background.default
|
|
530
|
-
}
|
|
531
|
-
}));
|
|
543
|
+
logs: {
|
|
544
|
+
background: theme.palette.background.default
|
|
545
|
+
}
|
|
546
|
+
})
|
|
547
|
+
);
|
|
532
548
|
const TechDocsBuildLogsDrawerContent = ({
|
|
533
549
|
buildLog,
|
|
534
550
|
onClose
|
|
@@ -714,21 +730,24 @@ const useSanitizerConfig = () => {
|
|
|
714
730
|
};
|
|
715
731
|
const useSanitizerTransformer = () => {
|
|
716
732
|
const config = useSanitizerConfig();
|
|
717
|
-
return useCallback(
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
733
|
+
return useCallback(
|
|
734
|
+
async (dom) => {
|
|
735
|
+
const hosts = config == null ? void 0 : config.getOptionalStringArray("allowedIframeHosts");
|
|
736
|
+
DOMPurify.addHook("beforeSanitizeElements", removeUnsafeLinks);
|
|
737
|
+
const tags = ["link"];
|
|
738
|
+
if (hosts) {
|
|
739
|
+
tags.push("iframe");
|
|
740
|
+
DOMPurify.addHook("beforeSanitizeElements", removeUnsafeIframes(hosts));
|
|
741
|
+
}
|
|
742
|
+
return DOMPurify.sanitize(dom.innerHTML, {
|
|
743
|
+
ADD_TAGS: tags,
|
|
744
|
+
FORBID_TAGS: ["style"],
|
|
745
|
+
WHOLE_DOCUMENT: true,
|
|
746
|
+
RETURN_DOM: true
|
|
747
|
+
});
|
|
748
|
+
},
|
|
749
|
+
[config]
|
|
750
|
+
);
|
|
732
751
|
};
|
|
733
752
|
|
|
734
753
|
var variables = ({ theme }) => `
|
|
@@ -743,20 +762,32 @@ var variables = ({ theme }) => `
|
|
|
743
762
|
--md-default-fg-color: ${theme.palette.text.primary};
|
|
744
763
|
--md-default-fg-color--light: ${theme.palette.text.secondary};
|
|
745
764
|
--md-default-fg-color--lighter: ${lighten(theme.palette.text.secondary, 0.7)};
|
|
746
|
-
--md-default-fg-color--lightest: ${lighten(
|
|
765
|
+
--md-default-fg-color--lightest: ${lighten(
|
|
766
|
+
theme.palette.text.secondary,
|
|
767
|
+
0.3
|
|
768
|
+
)};
|
|
747
769
|
|
|
748
770
|
/* BACKGROUND */
|
|
749
771
|
--md-default-bg-color:${theme.palette.background.default};
|
|
750
772
|
--md-default-bg-color--light: ${theme.palette.background.paper};
|
|
751
|
-
--md-default-bg-color--lighter: ${lighten(
|
|
752
|
-
|
|
773
|
+
--md-default-bg-color--lighter: ${lighten(
|
|
774
|
+
theme.palette.background.paper,
|
|
775
|
+
0.7
|
|
776
|
+
)};
|
|
777
|
+
--md-default-bg-color--lightest: ${lighten(
|
|
778
|
+
theme.palette.background.paper,
|
|
779
|
+
0.3
|
|
780
|
+
)};
|
|
753
781
|
|
|
754
782
|
/* PRIMARY */
|
|
755
783
|
--md-primary-fg-color: ${theme.palette.primary.main};
|
|
756
784
|
--md-primary-fg-color--light: ${theme.palette.primary.light};
|
|
757
785
|
--md-primary-fg-color--dark: ${theme.palette.primary.dark};
|
|
758
786
|
--md-primary-bg-color: ${theme.palette.primary.contrastText};
|
|
759
|
-
--md-primary-bg-color--light: ${lighten(
|
|
787
|
+
--md-primary-bg-color--light: ${lighten(
|
|
788
|
+
theme.palette.primary.contrastText,
|
|
789
|
+
0.7
|
|
790
|
+
)};
|
|
760
791
|
|
|
761
792
|
/* ACCENT */
|
|
762
793
|
--md-accent-fg-color: var(--md-primary-fg-color);
|
|
@@ -853,6 +884,7 @@ body {
|
|
|
853
884
|
}
|
|
854
885
|
`;
|
|
855
886
|
|
|
887
|
+
const SIDEBAR_WIDTH = "224px";
|
|
856
888
|
var layout = ({ theme, sidebar }) => `
|
|
857
889
|
/*================== Layout ==================*/
|
|
858
890
|
|
|
@@ -884,6 +916,11 @@ var layout = ({ theme, sidebar }) => `
|
|
|
884
916
|
height: 20px !important;
|
|
885
917
|
}
|
|
886
918
|
|
|
919
|
+
.md-nav__item--active > .md-nav__link, a.md-nav__link--active {
|
|
920
|
+
text-decoration: underline;
|
|
921
|
+
color: var(--md-typeset-a-color);
|
|
922
|
+
}
|
|
923
|
+
|
|
887
924
|
.md-main__inner {
|
|
888
925
|
margin-top: 0;
|
|
889
926
|
}
|
|
@@ -898,7 +935,7 @@ var layout = ({ theme, sidebar }) => `
|
|
|
898
935
|
scrollbar-width: thin;
|
|
899
936
|
}
|
|
900
937
|
.md-sidebar .md-sidebar__scrollwrap {
|
|
901
|
-
width: calc(
|
|
938
|
+
width: calc(12.1rem);
|
|
902
939
|
}
|
|
903
940
|
.md-sidebar--secondary {
|
|
904
941
|
right: ${theme.spacing(3)}px;
|
|
@@ -1005,7 +1042,7 @@ var layout = ({ theme, sidebar }) => `
|
|
|
1005
1042
|
.md-sidebar--primary {
|
|
1006
1043
|
width: 12.1rem !important;
|
|
1007
1044
|
z-index: 200;
|
|
1008
|
-
left: ${sidebar.isPinned ?
|
|
1045
|
+
left: ${sidebar.isPinned ? `calc(-12.1rem + ${SIDEBAR_WIDTH})` : "calc(-12.1rem + 72px)"} !important;
|
|
1009
1046
|
}
|
|
1010
1047
|
.md-sidebar--secondary:not([hidden]) {
|
|
1011
1048
|
display: none;
|
|
@@ -1230,10 +1267,13 @@ const useRuleStyles = () => {
|
|
|
1230
1267
|
};
|
|
1231
1268
|
const useStylesTransformer = () => {
|
|
1232
1269
|
const styles = useRuleStyles();
|
|
1233
|
-
return useCallback(
|
|
1234
|
-
dom
|
|
1235
|
-
|
|
1236
|
-
|
|
1270
|
+
return useCallback(
|
|
1271
|
+
(dom) => {
|
|
1272
|
+
dom.getElementsByTagName("head")[0].insertAdjacentHTML("beforeend", `<style>${styles}</style>`);
|
|
1273
|
+
return dom;
|
|
1274
|
+
},
|
|
1275
|
+
[styles]
|
|
1276
|
+
);
|
|
1237
1277
|
};
|
|
1238
1278
|
|
|
1239
1279
|
const isSvgNeedingInlining = (attrName, attrVal, apiOrigin) => {
|
|
@@ -1255,12 +1295,21 @@ const addBaseUrl = ({
|
|
|
1255
1295
|
const elemAttribute = elem.getAttribute(attributeName);
|
|
1256
1296
|
if (!elemAttribute)
|
|
1257
1297
|
return;
|
|
1258
|
-
const newValue = await techdocsStorageApi.getBaseUrl(
|
|
1298
|
+
const newValue = await techdocsStorageApi.getBaseUrl(
|
|
1299
|
+
elemAttribute,
|
|
1300
|
+
entityId,
|
|
1301
|
+
path
|
|
1302
|
+
);
|
|
1259
1303
|
if (isSvgNeedingInlining(attributeName, elemAttribute, apiOrigin)) {
|
|
1260
1304
|
try {
|
|
1261
1305
|
const svg = await fetch(newValue, { credentials: "include" });
|
|
1262
1306
|
const svgContent = await svg.text();
|
|
1263
|
-
elem.setAttribute(
|
|
1307
|
+
elem.setAttribute(
|
|
1308
|
+
attributeName,
|
|
1309
|
+
`data:image/svg+xml;base64,${btoa(
|
|
1310
|
+
unescape(encodeURIComponent(svgContent))
|
|
1311
|
+
)}`
|
|
1312
|
+
);
|
|
1264
1313
|
} catch (e) {
|
|
1265
1314
|
elem.setAttribute("alt", `Error: ${elemAttribute}`);
|
|
1266
1315
|
}
|
|
@@ -1284,7 +1333,9 @@ const addBaseUrl = ({
|
|
|
1284
1333
|
const addGitFeedbackLink = (scmIntegrationsApi) => {
|
|
1285
1334
|
return (dom) => {
|
|
1286
1335
|
var _a;
|
|
1287
|
-
const sourceAnchor = dom.querySelector(
|
|
1336
|
+
const sourceAnchor = dom.querySelector(
|
|
1337
|
+
'[title="Edit this page"]'
|
|
1338
|
+
);
|
|
1288
1339
|
if (!sourceAnchor || !sourceAnchor.href) {
|
|
1289
1340
|
return dom;
|
|
1290
1341
|
}
|
|
@@ -1295,10 +1346,12 @@ const addGitFeedbackLink = (scmIntegrationsApi) => {
|
|
|
1295
1346
|
}
|
|
1296
1347
|
const title = ((_a = dom.querySelector("article>h1")) == null ? void 0 : _a.childNodes[0].textContent) || "";
|
|
1297
1348
|
const issueTitle = encodeURIComponent(`Documentation Feedback: ${title}`);
|
|
1298
|
-
const issueDesc = encodeURIComponent(
|
|
1349
|
+
const issueDesc = encodeURIComponent(
|
|
1350
|
+
`Page source:
|
|
1299
1351
|
${sourceAnchor.href}
|
|
1300
1352
|
|
|
1301
|
-
Feedback:`
|
|
1353
|
+
Feedback:`
|
|
1354
|
+
);
|
|
1302
1355
|
const gitUrl = (integration == null ? void 0 : integration.type) === "github" ? replaceGitHubUrlType(sourceURL.href, "blob") : sourceURL.href;
|
|
1303
1356
|
const gitInfo = parseGitUrl(gitUrl);
|
|
1304
1357
|
const repoPath = `/${gitInfo.organization}/${gitInfo.name}`;
|
|
@@ -1324,7 +1377,9 @@ Feedback:`);
|
|
|
1324
1377
|
|
|
1325
1378
|
const addSidebarToggle = () => {
|
|
1326
1379
|
return (dom) => {
|
|
1327
|
-
const mkdocsToggleSidebar = dom.querySelector(
|
|
1380
|
+
const mkdocsToggleSidebar = dom.querySelector(
|
|
1381
|
+
'.md-header label[for="__drawer"]'
|
|
1382
|
+
);
|
|
1328
1383
|
const article = dom.querySelector("article");
|
|
1329
1384
|
if (!mkdocsToggleSidebar || !article) {
|
|
1330
1385
|
return dom;
|
|
@@ -1351,8 +1406,13 @@ const rewriteDocLinks = () => {
|
|
|
1351
1406
|
elem.setAttribute("target", "_blank");
|
|
1352
1407
|
}
|
|
1353
1408
|
try {
|
|
1354
|
-
const normalizedWindowLocation = normalizeUrl(
|
|
1355
|
-
|
|
1409
|
+
const normalizedWindowLocation = normalizeUrl(
|
|
1410
|
+
window.location.href
|
|
1411
|
+
);
|
|
1412
|
+
elem.setAttribute(
|
|
1413
|
+
attributeName,
|
|
1414
|
+
new URL(elemAttribute, normalizedWindowLocation).toString()
|
|
1415
|
+
);
|
|
1356
1416
|
} catch (_e) {
|
|
1357
1417
|
elem.replaceWith(elem.textContent || elemAttribute);
|
|
1358
1418
|
}
|
|
@@ -1433,11 +1493,14 @@ const copyToClipboard = (theme) => {
|
|
|
1433
1493
|
const text = code.textContent || "";
|
|
1434
1494
|
const container = document.createElement("div");
|
|
1435
1495
|
(_a = code == null ? void 0 : code.parentElement) == null ? void 0 : _a.prepend(container);
|
|
1436
|
-
ReactDOM.render(
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1496
|
+
ReactDOM.render(
|
|
1497
|
+
/* @__PURE__ */ React.createElement(ThemeProvider, {
|
|
1498
|
+
theme
|
|
1499
|
+
}, /* @__PURE__ */ React.createElement(CopyToClipboardButton, {
|
|
1500
|
+
text
|
|
1501
|
+
})),
|
|
1502
|
+
container
|
|
1503
|
+
);
|
|
1441
1504
|
}
|
|
1442
1505
|
return dom;
|
|
1443
1506
|
};
|
|
@@ -1466,10 +1529,16 @@ const onCssReady = ({
|
|
|
1466
1529
|
}) => {
|
|
1467
1530
|
return (dom) => {
|
|
1468
1531
|
onLoading();
|
|
1469
|
-
dom.addEventListener(
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1532
|
+
dom.addEventListener(
|
|
1533
|
+
SHADOW_DOM_STYLE_LOAD_EVENT,
|
|
1534
|
+
function handleShadowDomStyleLoad() {
|
|
1535
|
+
onLoaded();
|
|
1536
|
+
dom.removeEventListener(
|
|
1537
|
+
SHADOW_DOM_STYLE_LOAD_EVENT,
|
|
1538
|
+
handleShadowDomStyleLoad
|
|
1539
|
+
);
|
|
1540
|
+
}
|
|
1541
|
+
);
|
|
1473
1542
|
return dom;
|
|
1474
1543
|
};
|
|
1475
1544
|
};
|
|
@@ -1487,6 +1556,25 @@ const scrollIntoAnchor = () => {
|
|
|
1487
1556
|
};
|
|
1488
1557
|
};
|
|
1489
1558
|
|
|
1559
|
+
const scrollIntoNavigation = () => {
|
|
1560
|
+
return (dom) => {
|
|
1561
|
+
setTimeout(() => {
|
|
1562
|
+
const activeNavItems = dom == null ? void 0 : dom.querySelectorAll(`li.md-nav__item--active`);
|
|
1563
|
+
if (activeNavItems.length !== 0) {
|
|
1564
|
+
activeNavItems.forEach((activeNavItem) => {
|
|
1565
|
+
const checkbox = activeNavItem == null ? void 0 : activeNavItem.querySelector("input");
|
|
1566
|
+
if (!(checkbox == null ? void 0 : checkbox.checked)) {
|
|
1567
|
+
checkbox == null ? void 0 : checkbox.click();
|
|
1568
|
+
}
|
|
1569
|
+
});
|
|
1570
|
+
const lastItem = activeNavItems[activeNavItems.length - 1];
|
|
1571
|
+
lastItem.scrollIntoView();
|
|
1572
|
+
}
|
|
1573
|
+
}, 200);
|
|
1574
|
+
return dom;
|
|
1575
|
+
};
|
|
1576
|
+
};
|
|
1577
|
+
|
|
1490
1578
|
const transform = async (html, transformers) => {
|
|
1491
1579
|
let dom;
|
|
1492
1580
|
if (typeof html === "string") {
|
|
@@ -1564,70 +1652,79 @@ const useTechDocsReaderDom = (entityRef) => {
|
|
|
1564
1652
|
updateSidebarPosition();
|
|
1565
1653
|
}
|
|
1566
1654
|
}, [state, isStyleLoading, updateFooterWidth, updateSidebarPosition]);
|
|
1567
|
-
const preRender = useCallback(
|
|
1568
|
-
|
|
1569
|
-
|
|
1655
|
+
const preRender = useCallback(
|
|
1656
|
+
(rawContent, contentPath) => transform(rawContent, [
|
|
1657
|
+
sanitizerTransformer,
|
|
1658
|
+
addBaseUrl({
|
|
1659
|
+
techdocsStorageApi,
|
|
1660
|
+
entityId: entityRef,
|
|
1661
|
+
path: contentPath
|
|
1662
|
+
}),
|
|
1663
|
+
rewriteDocLinks(),
|
|
1664
|
+
addSidebarToggle(),
|
|
1665
|
+
removeMkdocsHeader(),
|
|
1666
|
+
simplifyMkdocsFooter(),
|
|
1667
|
+
addGitFeedbackLink(scmIntegrationsApi),
|
|
1668
|
+
stylesTransformer
|
|
1669
|
+
]),
|
|
1670
|
+
[
|
|
1671
|
+
entityRef,
|
|
1672
|
+
scmIntegrationsApi,
|
|
1570
1673
|
techdocsStorageApi,
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
var _a;
|
|
1594
|
-
const modifierActive = event.ctrlKey || event.metaKey;
|
|
1595
|
-
const parsedUrl = new URL(url);
|
|
1596
|
-
if (parsedUrl.hash) {
|
|
1597
|
-
if (modifierActive) {
|
|
1598
|
-
window.open(`${parsedUrl.pathname}${parsedUrl.hash}`, "_blank");
|
|
1599
|
-
} else {
|
|
1600
|
-
navigate(`${parsedUrl.pathname}${parsedUrl.hash}`);
|
|
1601
|
-
(_a = transformedElement == null ? void 0 : transformedElement.querySelector(`#${parsedUrl.hash.slice(1)}`)) == null ? void 0 : _a.scrollIntoView();
|
|
1602
|
-
}
|
|
1603
|
-
} else {
|
|
1604
|
-
if (modifierActive) {
|
|
1605
|
-
window.open(parsedUrl.pathname, "_blank");
|
|
1674
|
+
sanitizerTransformer,
|
|
1675
|
+
stylesTransformer
|
|
1676
|
+
]
|
|
1677
|
+
);
|
|
1678
|
+
const postRender = useCallback(
|
|
1679
|
+
async (transformedElement) => transform(transformedElement, [
|
|
1680
|
+
scrollIntoAnchor(),
|
|
1681
|
+
scrollIntoNavigation(),
|
|
1682
|
+
copyToClipboard(theme),
|
|
1683
|
+
addLinkClickListener({
|
|
1684
|
+
baseUrl: window.location.origin,
|
|
1685
|
+
onClick: (event, url) => {
|
|
1686
|
+
var _a;
|
|
1687
|
+
const modifierActive = event.ctrlKey || event.metaKey;
|
|
1688
|
+
const parsedUrl = new URL(url);
|
|
1689
|
+
if (parsedUrl.hash) {
|
|
1690
|
+
if (modifierActive) {
|
|
1691
|
+
window.open(`${parsedUrl.pathname}${parsedUrl.hash}`, "_blank");
|
|
1692
|
+
} else {
|
|
1693
|
+
navigate(`${parsedUrl.pathname}${parsedUrl.hash}`);
|
|
1694
|
+
(_a = transformedElement == null ? void 0 : transformedElement.querySelector(`#${parsedUrl.hash.slice(1)}`)) == null ? void 0 : _a.scrollIntoView();
|
|
1695
|
+
}
|
|
1606
1696
|
} else {
|
|
1607
|
-
|
|
1697
|
+
if (modifierActive) {
|
|
1698
|
+
window.open(parsedUrl.pathname, "_blank");
|
|
1699
|
+
} else {
|
|
1700
|
+
navigate(parsedUrl.pathname);
|
|
1701
|
+
}
|
|
1608
1702
|
}
|
|
1609
1703
|
}
|
|
1610
|
-
}
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
}
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1704
|
+
}),
|
|
1705
|
+
onCssReady({
|
|
1706
|
+
onLoading: () => {
|
|
1707
|
+
},
|
|
1708
|
+
onLoaded: () => {
|
|
1709
|
+
var _a;
|
|
1710
|
+
(_a = transformedElement.querySelector(".md-nav__title")) == null ? void 0 : _a.removeAttribute("for");
|
|
1711
|
+
}
|
|
1712
|
+
}),
|
|
1713
|
+
onCssReady({
|
|
1714
|
+
onLoading: () => {
|
|
1715
|
+
const sidebars = Array.from(
|
|
1716
|
+
transformedElement.querySelectorAll(".md-sidebar")
|
|
1717
|
+
);
|
|
1718
|
+
sidebars.forEach((element) => {
|
|
1719
|
+
element.style.setProperty("opacity", "0");
|
|
1720
|
+
});
|
|
1721
|
+
},
|
|
1722
|
+
onLoaded: () => {
|
|
1723
|
+
}
|
|
1724
|
+
})
|
|
1725
|
+
]),
|
|
1726
|
+
[theme, navigate]
|
|
1727
|
+
);
|
|
1631
1728
|
useEffect(() => {
|
|
1632
1729
|
if (!rawPage)
|
|
1633
1730
|
return () => {
|
|
@@ -1641,7 +1738,9 @@ const useTechDocsReaderDom = (entityRef) => {
|
|
|
1641
1738
|
return;
|
|
1642
1739
|
}
|
|
1643
1740
|
window.scroll({ top: 0 });
|
|
1644
|
-
const postTransformedDomElement = await postRender(
|
|
1741
|
+
const postTransformedDomElement = await postRender(
|
|
1742
|
+
preTransformedDomElement
|
|
1743
|
+
);
|
|
1645
1744
|
setDom(postTransformedDomElement);
|
|
1646
1745
|
});
|
|
1647
1746
|
return () => {
|
|
@@ -1654,19 +1753,35 @@ const useTechDocsReaderDom = (entityRef) => {
|
|
|
1654
1753
|
const TechDocsReaderPageContentAddons = () => {
|
|
1655
1754
|
const addons = useTechDocsAddons();
|
|
1656
1755
|
const { shadowRoot } = useTechDocsReaderPage();
|
|
1657
|
-
const contentElement = shadowRoot == null ? void 0 : shadowRoot.querySelector(
|
|
1658
|
-
|
|
1659
|
-
|
|
1756
|
+
const contentElement = shadowRoot == null ? void 0 : shadowRoot.querySelector(
|
|
1757
|
+
'[data-md-component="content"]'
|
|
1758
|
+
);
|
|
1759
|
+
const primarySidebarElement = shadowRoot == null ? void 0 : shadowRoot.querySelector(
|
|
1760
|
+
'div[data-md-component="sidebar"][data-md-type="navigation"], div[data-md-component="navigation"]'
|
|
1761
|
+
);
|
|
1762
|
+
let primarySidebarAddonLocation = primarySidebarElement == null ? void 0 : primarySidebarElement.querySelector(
|
|
1763
|
+
'[data-techdocs-addons-location="primary sidebar"]'
|
|
1764
|
+
);
|
|
1660
1765
|
if (!primarySidebarAddonLocation) {
|
|
1661
1766
|
primarySidebarAddonLocation = document.createElement("div");
|
|
1662
|
-
primarySidebarAddonLocation.setAttribute(
|
|
1767
|
+
primarySidebarAddonLocation.setAttribute(
|
|
1768
|
+
"data-techdocs-addons-location",
|
|
1769
|
+
"primary sidebar"
|
|
1770
|
+
);
|
|
1663
1771
|
primarySidebarElement == null ? void 0 : primarySidebarElement.prepend(primarySidebarAddonLocation);
|
|
1664
1772
|
}
|
|
1665
|
-
const secondarySidebarElement = shadowRoot == null ? void 0 : shadowRoot.querySelector(
|
|
1666
|
-
|
|
1773
|
+
const secondarySidebarElement = shadowRoot == null ? void 0 : shadowRoot.querySelector(
|
|
1774
|
+
'div[data-md-component="sidebar"][data-md-type="toc"], div[data-md-component="toc"]'
|
|
1775
|
+
);
|
|
1776
|
+
let secondarySidebarAddonLocation = secondarySidebarElement == null ? void 0 : secondarySidebarElement.querySelector(
|
|
1777
|
+
'[data-techdocs-addons-location="secondary sidebar"]'
|
|
1778
|
+
);
|
|
1667
1779
|
if (!secondarySidebarAddonLocation) {
|
|
1668
1780
|
secondarySidebarAddonLocation = document.createElement("div");
|
|
1669
|
-
secondarySidebarAddonLocation.setAttribute(
|
|
1781
|
+
secondarySidebarAddonLocation.setAttribute(
|
|
1782
|
+
"data-techdocs-addons-location",
|
|
1783
|
+
"secondary sidebar"
|
|
1784
|
+
);
|
|
1670
1785
|
secondarySidebarElement == null ? void 0 : secondarySidebarElement.prepend(secondarySidebarAddonLocation);
|
|
1671
1786
|
}
|
|
1672
1787
|
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Portal, {
|
|
@@ -1687,55 +1802,60 @@ const useStyles$1 = makeStyles({
|
|
|
1687
1802
|
}
|
|
1688
1803
|
}
|
|
1689
1804
|
});
|
|
1690
|
-
const TechDocsReaderPageContent = withTechDocsReaderProvider(
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1805
|
+
const TechDocsReaderPageContent = withTechDocsReaderProvider(
|
|
1806
|
+
(props) => {
|
|
1807
|
+
var _a;
|
|
1808
|
+
const { withSearch = true, onReady } = props;
|
|
1809
|
+
const classes = useStyles$1();
|
|
1810
|
+
const {
|
|
1811
|
+
entityMetadata: { value: entityMetadata, loading: entityMetadataLoading },
|
|
1812
|
+
entityRef,
|
|
1813
|
+
setShadowRoot
|
|
1814
|
+
} = useTechDocsReaderPage();
|
|
1815
|
+
const dom = useTechDocsReaderDom(entityRef);
|
|
1816
|
+
const handleAppend = useCallback(
|
|
1817
|
+
(newShadowRoot) => {
|
|
1818
|
+
setShadowRoot(newShadowRoot);
|
|
1819
|
+
if (onReady instanceof Function) {
|
|
1820
|
+
onReady();
|
|
1821
|
+
}
|
|
1822
|
+
},
|
|
1823
|
+
[setShadowRoot, onReady]
|
|
1824
|
+
);
|
|
1825
|
+
if (entityMetadataLoading === false && !entityMetadata)
|
|
1826
|
+
return /* @__PURE__ */ React.createElement(ErrorPage, {
|
|
1827
|
+
status: "404",
|
|
1828
|
+
statusMessage: "PAGE NOT FOUND"
|
|
1829
|
+
});
|
|
1830
|
+
if (!dom) {
|
|
1831
|
+
return /* @__PURE__ */ React.createElement(Content, null, /* @__PURE__ */ React.createElement(Grid, {
|
|
1832
|
+
container: true
|
|
1833
|
+
}, /* @__PURE__ */ React.createElement(Grid, {
|
|
1834
|
+
xs: 12,
|
|
1835
|
+
item: true
|
|
1836
|
+
}, /* @__PURE__ */ React.createElement(TechDocsStateIndicator, null))));
|
|
1704
1837
|
}
|
|
1705
|
-
}, [setShadowRoot, onReady]);
|
|
1706
|
-
if (entityMetadataLoading === false && !entityMetadata)
|
|
1707
|
-
return /* @__PURE__ */ React.createElement(ErrorPage, {
|
|
1708
|
-
status: "404",
|
|
1709
|
-
statusMessage: "PAGE NOT FOUND"
|
|
1710
|
-
});
|
|
1711
|
-
if (!dom) {
|
|
1712
1838
|
return /* @__PURE__ */ React.createElement(Content, null, /* @__PURE__ */ React.createElement(Grid, {
|
|
1713
1839
|
container: true
|
|
1714
1840
|
}, /* @__PURE__ */ React.createElement(Grid, {
|
|
1715
1841
|
xs: 12,
|
|
1716
1842
|
item: true
|
|
1717
|
-
}, /* @__PURE__ */ React.createElement(TechDocsStateIndicator, null))
|
|
1843
|
+
}, /* @__PURE__ */ React.createElement(TechDocsStateIndicator, null)), withSearch && /* @__PURE__ */ React.createElement(Grid, {
|
|
1844
|
+
className: classes.search,
|
|
1845
|
+
xs: "auto",
|
|
1846
|
+
item: true
|
|
1847
|
+
}, /* @__PURE__ */ React.createElement(TechDocsSearch, {
|
|
1848
|
+
entityId: entityRef,
|
|
1849
|
+
entityTitle: (_a = entityMetadata == null ? void 0 : entityMetadata.metadata) == null ? void 0 : _a.title
|
|
1850
|
+
})), /* @__PURE__ */ React.createElement(Grid, {
|
|
1851
|
+
xs: 12,
|
|
1852
|
+
item: true
|
|
1853
|
+
}, /* @__PURE__ */ React.createElement(TechDocsShadowDom, {
|
|
1854
|
+
element: dom,
|
|
1855
|
+
onAppend: handleAppend
|
|
1856
|
+
}, /* @__PURE__ */ React.createElement(TechDocsReaderPageContentAddons, null)))));
|
|
1718
1857
|
}
|
|
1719
|
-
|
|
1720
|
-
container: true
|
|
1721
|
-
}, /* @__PURE__ */ React.createElement(Grid, {
|
|
1722
|
-
xs: 12,
|
|
1723
|
-
item: true
|
|
1724
|
-
}, /* @__PURE__ */ React.createElement(TechDocsStateIndicator, null)), withSearch && /* @__PURE__ */ React.createElement(Grid, {
|
|
1725
|
-
className: classes.search,
|
|
1726
|
-
xs: "auto",
|
|
1727
|
-
item: true
|
|
1728
|
-
}, /* @__PURE__ */ React.createElement(TechDocsSearch, {
|
|
1729
|
-
entityId: entityRef,
|
|
1730
|
-
entityTitle: (_a = entityMetadata == null ? void 0 : entityMetadata.metadata) == null ? void 0 : _a.title
|
|
1731
|
-
})), /* @__PURE__ */ React.createElement(Grid, {
|
|
1732
|
-
xs: 12,
|
|
1733
|
-
item: true
|
|
1734
|
-
}, /* @__PURE__ */ React.createElement(TechDocsShadowDom, {
|
|
1735
|
-
element: dom,
|
|
1736
|
-
onAppend: handleAppend
|
|
1737
|
-
}, /* @__PURE__ */ React.createElement(TechDocsReaderPageContentAddons, null)))));
|
|
1738
|
-
});
|
|
1858
|
+
);
|
|
1739
1859
|
const Reader = TechDocsReaderPageContent;
|
|
1740
1860
|
|
|
1741
1861
|
const rootRouteRef = createRouteRef({
|
|
@@ -1853,7 +1973,9 @@ const TechDocsReaderPageSubheader = ({
|
|
|
1853
1973
|
entityMetadata: { value: entityMetadata, loading: entityMetadataLoading }
|
|
1854
1974
|
} = useTechDocsReaderPage();
|
|
1855
1975
|
const addons = useTechDocsAddons();
|
|
1856
|
-
const subheaderAddons = addons.renderComponentsByLocation(
|
|
1976
|
+
const subheaderAddons = addons.renderComponentsByLocation(
|
|
1977
|
+
TechDocsAddonLocations.Subheader
|
|
1978
|
+
);
|
|
1857
1979
|
const settingsAddons = addons.renderComponentsByLocation(TechDocsAddonLocations.Settings);
|
|
1858
1980
|
if (!subheaderAddons && !settingsAddons)
|
|
1859
1981
|
return null;
|
|
@@ -1924,7 +2046,9 @@ const TechDocsReaderPage$1 = (props) => {
|
|
|
1924
2046
|
};
|
|
1925
2047
|
|
|
1926
2048
|
function toLowerMaybe(str, config) {
|
|
1927
|
-
return config.getOptionalBoolean(
|
|
2049
|
+
return config.getOptionalBoolean(
|
|
2050
|
+
"techdocs.legacyUseCaseSensitiveTripletPaths"
|
|
2051
|
+
) ? str : str.toLocaleLowerCase("en-US");
|
|
1928
2052
|
}
|
|
1929
2053
|
|
|
1930
2054
|
const DocsCardGrid = (props) => {
|
|
@@ -1943,7 +2067,10 @@ const DocsCardGrid = (props) => {
|
|
|
1943
2067
|
title: (_a = entity.metadata.title) != null ? _a : entity.metadata.name
|
|
1944
2068
|
})), /* @__PURE__ */ React.createElement(CardContent, null, entity.metadata.description), /* @__PURE__ */ React.createElement(CardActions, null, /* @__PURE__ */ React.createElement(Button$1, {
|
|
1945
2069
|
to: getRouteToReaderPageFor({
|
|
1946
|
-
namespace: toLowerMaybe(
|
|
2070
|
+
namespace: toLowerMaybe(
|
|
2071
|
+
(_b = entity.metadata.namespace) != null ? _b : "default",
|
|
2072
|
+
config
|
|
2073
|
+
),
|
|
1947
2074
|
kind: toLowerMaybe(entity.kind, config),
|
|
1948
2075
|
name: toLowerMaybe(entity.metadata.name, config)
|
|
1949
2076
|
}),
|
|
@@ -1967,10 +2094,14 @@ const EntityListDocsGrid = () => {
|
|
|
1967
2094
|
if (loading || !entities) {
|
|
1968
2095
|
return /* @__PURE__ */ React.createElement(Progress, null);
|
|
1969
2096
|
}
|
|
1970
|
-
entities.sort(
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
2097
|
+
entities.sort(
|
|
2098
|
+
(a, b) => {
|
|
2099
|
+
var _a, _b;
|
|
2100
|
+
return ((_a = a.metadata.title) != null ? _a : a.metadata.name).localeCompare(
|
|
2101
|
+
(_b = b.metadata.title) != null ? _b : b.metadata.name
|
|
2102
|
+
);
|
|
2103
|
+
}
|
|
2104
|
+
);
|
|
1974
2105
|
return /* @__PURE__ */ React.createElement(DocsCardGrid, {
|
|
1975
2106
|
entities
|
|
1976
2107
|
});
|
|
@@ -2055,7 +2186,10 @@ const DocsTable = (props) => {
|
|
|
2055
2186
|
entity,
|
|
2056
2187
|
resolved: {
|
|
2057
2188
|
docsUrl: getRouteToReaderPageFor({
|
|
2058
|
-
namespace: toLowerMaybe(
|
|
2189
|
+
namespace: toLowerMaybe(
|
|
2190
|
+
(_a = entity.metadata.namespace) != null ? _a : "default",
|
|
2191
|
+
config
|
|
2192
|
+
),
|
|
2059
2193
|
kind: toLowerMaybe(entity.kind, config),
|
|
2060
2194
|
name: toLowerMaybe(entity.metadata.name, config)
|
|
2061
2195
|
}),
|
|
@@ -2107,7 +2241,10 @@ const EntityListDocsTable = (props) => {
|
|
|
2107
2241
|
const title = capitalize((_b = (_a = filters.user) == null ? void 0 : _a.value) != null ? _b : "all");
|
|
2108
2242
|
const defaultActions = [
|
|
2109
2243
|
actionFactories.createCopyDocsUrlAction(copyToClipboard),
|
|
2110
|
-
actionFactories.createStarEntityAction(
|
|
2244
|
+
actionFactories.createStarEntityAction(
|
|
2245
|
+
isStarredEntity,
|
|
2246
|
+
toggleStarredEntity
|
|
2247
|
+
)
|
|
2111
2248
|
];
|
|
2112
2249
|
if (error) {
|
|
2113
2250
|
return /* @__PURE__ */ React.createElement(WarningPanel, {
|
|
@@ -2208,31 +2345,47 @@ const techdocsPlugin = createPlugin({
|
|
|
2208
2345
|
entityContent: rootCatalogDocsRouteRef
|
|
2209
2346
|
}
|
|
2210
2347
|
});
|
|
2211
|
-
const TechdocsPage = techdocsPlugin.provide(
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2348
|
+
const TechdocsPage = techdocsPlugin.provide(
|
|
2349
|
+
createRoutableExtension({
|
|
2350
|
+
name: "TechdocsPage",
|
|
2351
|
+
component: () => Promise.resolve().then(function () { return Router$1; }).then((m) => m.Router),
|
|
2352
|
+
mountPoint: rootRouteRef
|
|
2353
|
+
})
|
|
2354
|
+
);
|
|
2355
|
+
const EntityTechdocsContent = techdocsPlugin.provide(
|
|
2356
|
+
createRoutableExtension({
|
|
2357
|
+
name: "EntityTechdocsContent",
|
|
2358
|
+
component: () => Promise.resolve().then(function () { return Router$1; }).then((m) => m.EmbeddedDocsRouter),
|
|
2359
|
+
mountPoint: rootCatalogDocsRouteRef
|
|
2360
|
+
})
|
|
2361
|
+
);
|
|
2362
|
+
const TechDocsCustomHome = techdocsPlugin.provide(
|
|
2363
|
+
createRoutableExtension({
|
|
2364
|
+
name: "TechDocsCustomHome",
|
|
2365
|
+
component: () => import('./TechDocsCustomHome-3c888994.esm.js').then(
|
|
2366
|
+
(m) => m.TechDocsCustomHome
|
|
2367
|
+
),
|
|
2368
|
+
mountPoint: rootRouteRef
|
|
2369
|
+
})
|
|
2370
|
+
);
|
|
2371
|
+
const TechDocsIndexPage$2 = techdocsPlugin.provide(
|
|
2372
|
+
createRoutableExtension({
|
|
2373
|
+
name: "TechDocsIndexPage",
|
|
2374
|
+
component: () => Promise.resolve().then(function () { return TechDocsIndexPage$1; }).then(
|
|
2375
|
+
(m) => m.TechDocsIndexPage
|
|
2376
|
+
),
|
|
2377
|
+
mountPoint: rootRouteRef
|
|
2378
|
+
})
|
|
2379
|
+
);
|
|
2380
|
+
const TechDocsReaderPage = techdocsPlugin.provide(
|
|
2381
|
+
createRoutableExtension({
|
|
2382
|
+
name: "TechDocsReaderPage",
|
|
2383
|
+
component: () => import('./index-4754b215.esm.js').then(
|
|
2384
|
+
(m) => m.TechDocsReaderPage
|
|
2385
|
+
),
|
|
2386
|
+
mountPoint: rootDocsRouteRef
|
|
2387
|
+
})
|
|
2388
|
+
);
|
|
2236
2389
|
|
|
2237
2390
|
const EntityPageDocs = ({ entity }) => {
|
|
2238
2391
|
const entityRef = getCompoundEntityRef(entity);
|
|
@@ -2304,4 +2457,4 @@ var Router$1 = /*#__PURE__*/Object.freeze({
|
|
|
2304
2457
|
});
|
|
2305
2458
|
|
|
2306
2459
|
export { DocsTable as D, EntityTechdocsContent as E, Reader as R, TechDocsPageWrapper as T, DocsCardGrid as a, TechDocsReaderPage$1 as b, TechDocsReaderLayout as c, TechDocsCustomHome as d, TechDocsIndexPage$2 as e, TechdocsPage as f, TechDocsReaderPage as g, techdocsStorageApiRef as h, techdocsApiRef as i, TechDocsClient as j, TechDocsStorageClient as k, TechDocsReaderProvider as l, TechDocsReaderPageHeader as m, TechDocsReaderPageContent as n, TechDocsReaderPageSubheader as o, TechDocsSearchResultListItem as p, TechDocsSearch as q, EntityListDocsGrid as r, EntityListDocsTable as s, techdocsPlugin as t, DefaultTechDocsHome as u, TechDocsPicker as v, isTechDocsAvailable as w, Router as x, EmbeddedDocsRouter as y };
|
|
2307
|
-
//# sourceMappingURL=index-
|
|
2460
|
+
//# sourceMappingURL=index-2ba55936.esm.js.map
|