@salesforcedevs/docs-components 0.0.4 → 0.0.5-edit
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/lwc.config.json +25 -2
- package/package.json +18 -7
- package/src/modules/README.md +41 -0
- package/src/modules/doc/amfModelParser/amfModelParser.ts +674 -0
- package/src/modules/doc/amfReference/amfReference.css +25 -0
- package/src/modules/doc/amfReference/amfReference.html +60 -0
- package/src/modules/doc/amfReference/amfReference.ts +1494 -0
- package/src/modules/doc/amfReference/constants.ts +76 -0
- package/src/modules/doc/amfReference/types.ts +125 -0
- package/src/modules/doc/amfTopic/amfTopic.css +21 -0
- package/src/modules/doc/amfTopic/amfTopic.html +3 -0
- package/src/modules/doc/amfTopic/amfTopic.ts +111 -0
- package/src/modules/doc/amfTopic/types.ts +56 -0
- package/src/modules/doc/amfTopic/utils.ts +136 -0
- package/src/modules/doc/breadcrumbItem/breadcrumbItem.css +51 -0
- package/src/modules/doc/breadcrumbItem/breadcrumbItem.html +5 -0
- package/src/modules/doc/breadcrumbItem/breadcrumbItem.ts +71 -0
- package/src/modules/doc/breadcrumbs/breadcrumbs.css +27 -0
- package/src/modules/doc/breadcrumbs/breadcrumbs.html +58 -0
- package/src/modules/doc/breadcrumbs/breadcrumbs.ts +183 -0
- package/src/modules/doc/chat/README.md +179 -0
- package/src/modules/doc/chat/chat.css +821 -0
- package/src/modules/doc/chat/chat.html +241 -0
- package/src/modules/doc/chat/chat.ts +586 -0
- package/src/modules/doc/componentPlayground/componentPlayground.css +22 -0
- package/src/modules/doc/componentPlayground/componentPlayground.html +20 -0
- package/src/modules/doc/componentPlayground/componentPlayground.ts +29 -0
- package/src/modules/doc/content/content.css +382 -6
- package/src/modules/doc/content/content.html +3 -2
- package/src/modules/doc/content/content.ts +287 -110
- package/src/modules/doc/contentCallout/contentCallout.css +25 -26
- package/src/modules/doc/contentCallout/contentCallout.html +13 -4
- package/src/modules/doc/contentCallout/contentCallout.ts +22 -11
- package/src/modules/doc/contentLayout/contentLayout.css +13 -0
- package/src/modules/doc/contentLayout/contentLayout.html +73 -0
- package/src/modules/doc/contentLayout/contentLayout.ts +531 -0
- package/src/modules/doc/contentMedia/contentMedia.css +49 -0
- package/src/modules/doc/contentMedia/contentMedia.html +23 -0
- package/src/modules/doc/contentMedia/contentMedia.ts +34 -0
- package/src/modules/doc/doDont/doDont.css +47 -0
- package/src/modules/doc/doDont/doDont.html +27 -0
- package/src/modules/doc/doDont/doDont.ts +17 -0
- package/src/modules/doc/editFile/editFile.css +505 -0
- package/src/modules/doc/editFile/editFile.html +164 -0
- package/src/modules/doc/editFile/editFile.ts +213 -0
- package/src/modules/doc/header/header.css +132 -0
- package/src/modules/doc/header/header.html +55 -0
- package/src/modules/doc/header/header.ts +120 -0
- package/src/modules/doc/heading/heading.css +33 -0
- package/src/modules/doc/heading/heading.html +14 -0
- package/src/modules/doc/heading/heading.ts +67 -0
- package/src/modules/doc/headingAnchor/headingAnchor.css +33 -0
- package/src/modules/doc/headingAnchor/headingAnchor.html +19 -0
- package/src/modules/doc/headingAnchor/headingAnchor.ts +43 -0
- package/src/modules/doc/headingContent/headingContent.css +53 -0
- package/src/modules/doc/headingContent/headingContent.html +13 -0
- package/src/modules/doc/headingContent/headingContent.ts +30 -0
- package/src/modules/doc/lwcContentLayout/lwcContentLayout.css +1 -0
- package/src/modules/doc/lwcContentLayout/lwcContentLayout.html +68 -0
- package/src/modules/doc/lwcContentLayout/lwcContentLayout.ts +168 -0
- package/src/modules/doc/nav/nav.css +4 -2
- package/src/modules/doc/nav/nav.html +8 -13
- package/src/modules/doc/nav/nav.ts +1 -1
- package/src/modules/doc/overview/overview.css +40 -0
- package/src/modules/doc/overview/overview.html +34 -0
- package/src/modules/doc/overview/overview.ts +12 -0
- package/src/modules/doc/phase/phase.css +70 -0
- package/src/modules/doc/phase/phase.html +38 -0
- package/src/modules/doc/phase/phase.ts +93 -0
- package/src/modules/doc/specificationContent/specificationContent.css +36 -0
- package/src/modules/doc/specificationContent/specificationContent.html +171 -0
- package/src/modules/doc/specificationContent/specificationContent.ts +127 -0
- package/src/modules/doc/sprigSurvey/sprigSurvey.html +20 -0
- package/src/modules/doc/sprigSurvey/sprigSurvey.scoped.css +16 -0
- package/src/modules/doc/sprigSurvey/sprigSurvey.ts +16 -0
- package/src/modules/doc/toc/toc.html +11 -6
- package/src/modules/doc/toc/toc.ts +2 -6
- package/src/modules/doc/toolbar/toolbar.html +8 -1
- package/src/modules/doc/toolbar/toolbar.ts +1 -1
- package/src/modules/doc/versionPicker/versionPicker.css +64 -0
- package/src/modules/doc/versionPicker/versionPicker.html +38 -0
- package/src/modules/doc/versionPicker/versionPicker.ts +65 -0
- package/src/modules/doc/xmlContent/types.ts +120 -0
- package/src/modules/doc/xmlContent/utils.ts +163 -0
- package/src/modules/doc/xmlContent/xmlContent.css +54 -0
- package/src/modules/doc/xmlContent/xmlContent.html +52 -0
- package/src/modules/doc/xmlContent/xmlContent.ts +792 -0
- package/src/modules/docHelpers/amfStyle/amfStyle.css +355 -0
- package/src/modules/docHelpers/contentLayoutStyle/contentLayoutStyle.css +131 -0
- package/src/modules/docHelpers/imgStyle/imgStyle.css +59 -0
- package/src/modules/docHelpers/status/status.css +22 -0
- package/src/modules/docUtils/searchSyncer/searchSyncer.ts +86 -0
- package/src/modules/docUtils/utils/__mocks__/coveo.analytics.ts +16 -0
- package/src/modules/docUtils/utils/coveo.analytics.d.ts +10 -0
- package/src/modules/docUtils/utils/utils.ts +32 -0
- package/src/modules/doc/container/__benchmarks__/container.benchmark.js +0 -43
- package/src/modules/doc/container/__mocks__/mockAvailableLanguages.js +0 -8
- package/src/modules/doc/container/__mocks__/mockAvailableVersions.js +0 -122
- package/src/modules/doc/container/__mocks__/mockContentFetchResponse.json +0 -5
- package/src/modules/doc/container/__mocks__/mockDocContent.js +0 -29
- package/src/modules/doc/container/__mocks__/mockNavigationFetchResponse.json +0 -4061
- package/src/modules/doc/container/__mocks__/mockPageReference.js +0 -8
- package/src/modules/doc/container/__mocks__/mockPdfUrl.js +0 -1
- package/src/modules/doc/container/__mocks__/mockSelectedLanguage.js +0 -8
- package/src/modules/doc/container/__mocks__/mockSelectedVersion.js +0 -8
- package/src/modules/doc/container/__mocks__/mockToc.js +0 -146
- package/src/modules/doc/container/__tests__/container.test.ts +0 -82
- package/src/modules/doc/container/container.css +0 -33
- package/src/modules/doc/container/container.html +0 -23
- package/src/modules/doc/container/container.stories.ts +0 -18
- package/src/modules/doc/container/container.ts +0 -360
- package/src/modules/doc/content/__tests__/content.test.ts +0 -30
- package/src/modules/doc/content/__tests__/mockDocContent.ts +0 -29
- package/src/modules/doc/content/__tests__/mockPageReference.ts +0 -8
- package/src/modules/doc/contentCallout/__tests__/contentCallout.test.ts +0 -80
- package/src/modules/doc/contentCallout/__tests__/mockProps.ts +0 -14
- package/src/modules/doc/contentCallout/contentCallout.stories.ts +0 -29
- package/src/modules/doc/nav/__tests__/mockAvailableLanguages.ts +0 -8
- package/src/modules/doc/nav/__tests__/mockAvailableVersions.ts +0 -122
- package/src/modules/doc/nav/__tests__/mockPageReference.ts +0 -8
- package/src/modules/doc/nav/__tests__/mockPdfUrl.ts +0 -1
- package/src/modules/doc/nav/__tests__/mockSelectedLanguage.ts +0 -8
- package/src/modules/doc/nav/__tests__/mockSelectedVersion.ts +0 -8
- package/src/modules/doc/nav/__tests__/mockToc.ts +0 -146
- package/src/modules/doc/nav/__tests__/nav.test.ts +0 -66
- package/src/modules/doc/prismcss/prismcss.css +0 -184
- package/src/modules/doc/prismjs/prismjs.html +0 -3
- package/src/modules/doc/prismjs/prismjs.ts +0 -1842
- package/src/modules/doc/search/__tests__/search.test.ts +0 -20
- package/src/modules/doc/search/search.html +0 -1
- package/src/modules/doc/search/search.ts +0 -3
- package/src/modules/doc/toc/__tests__/mockPageReference.ts +0 -8
- package/src/modules/doc/toc/__tests__/mockToc.ts +0 -146
- package/src/modules/doc/toc/__tests__/toc.test.ts +0 -29
- package/src/modules/doc/toolbar/__tests__/mockAvailableLanguages.ts +0 -8
- package/src/modules/doc/toolbar/__tests__/mockAvailableVersions.ts +0 -122
- package/src/modules/doc/toolbar/__tests__/mockPdfUrl.ts +0 -1
- package/src/modules/doc/toolbar/__tests__/mockSelectedLanguage.ts +0 -8
- package/src/modules/doc/toolbar/__tests__/mockSelectedVersion.ts +0 -8
- package/src/modules/doc/toolbar/__tests__/toolbar.test.ts +0 -44
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default "https://resources.docs.salesforce.com/228/latest/en-us/sfdc/pdf/salesforce_apex_language_reference.pdf";
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
export default [
|
|
2
|
-
{
|
|
3
|
-
children: [
|
|
4
|
-
{
|
|
5
|
-
text: "Overview",
|
|
6
|
-
a_attr: {
|
|
7
|
-
href: "actions_intro_overview.htm"
|
|
8
|
-
},
|
|
9
|
-
id: "actions_intro_overview"
|
|
10
|
-
},
|
|
11
|
-
{
|
|
12
|
-
text: "Invoking Actions",
|
|
13
|
-
a_attr: {
|
|
14
|
-
href: "actions_intro_invoking.htm"
|
|
15
|
-
},
|
|
16
|
-
id: "actions_intro_invoking"
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
text: "Available Actions",
|
|
20
|
-
a_attr: {
|
|
21
|
-
href: "actions_intro_list.htm"
|
|
22
|
-
},
|
|
23
|
-
id: "actions_intro_list"
|
|
24
|
-
}
|
|
25
|
-
],
|
|
26
|
-
text: "Introducing Actions",
|
|
27
|
-
a_attr: {
|
|
28
|
-
href: "actions_intro.htm"
|
|
29
|
-
},
|
|
30
|
-
id: "actions_intro"
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
children: [
|
|
34
|
-
{
|
|
35
|
-
text: "Apex Actions",
|
|
36
|
-
a_attr: {
|
|
37
|
-
href: "actions_obj_apex.htm"
|
|
38
|
-
},
|
|
39
|
-
id: "actions_obj_apex"
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
text: "Create Service Report Actions",
|
|
43
|
-
a_attr: {
|
|
44
|
-
href: "actions_obj_create_service_report.htm"
|
|
45
|
-
},
|
|
46
|
-
id: "actions_obj_create_service_report"
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
text: "Custom Notification Actions",
|
|
50
|
-
a_attr: {
|
|
51
|
-
href: "actions_obj_custom_notification.htm"
|
|
52
|
-
},
|
|
53
|
-
id: "actions_obj_custom_notification"
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
text: "Email Alert Actions",
|
|
57
|
-
a_attr: {
|
|
58
|
-
href: "actions_obj_email_alert.htm"
|
|
59
|
-
},
|
|
60
|
-
id: "actions_obj_email_alert"
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
text: "Flow Actions",
|
|
64
|
-
a_attr: {
|
|
65
|
-
href: "actions_obj_flow.htm"
|
|
66
|
-
},
|
|
67
|
-
id: "actions_obj_flow"
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
text: "Generate Work Orders Actions",
|
|
71
|
-
a_attr: {
|
|
72
|
-
href: "actions_obj_generate_work_orders.htm"
|
|
73
|
-
},
|
|
74
|
-
id: "actions_obj_generate_work_orders"
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
text: "Knowledge Actions",
|
|
78
|
-
a_attr: {
|
|
79
|
-
href: "actions_obj_knowledge.htm"
|
|
80
|
-
},
|
|
81
|
-
id: "actions_obj_knowledge"
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
text: "Omni-Channel Action",
|
|
85
|
-
a_attr: {
|
|
86
|
-
href: "actions_obj_omni_channel.htm"
|
|
87
|
-
},
|
|
88
|
-
id: "actions_obj_omni_channel"
|
|
89
|
-
},
|
|
90
|
-
{
|
|
91
|
-
text: "PlatformAction",
|
|
92
|
-
a_attr: {
|
|
93
|
-
href: "sforce_api_objects_platformaction.htm"
|
|
94
|
-
},
|
|
95
|
-
id: "sforce_api_objects_platformaction"
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
text: "Post to Chatter Actions",
|
|
99
|
-
a_attr: {
|
|
100
|
-
href: "actions_obj_post_to_chatter.htm"
|
|
101
|
-
},
|
|
102
|
-
id: "actions_obj_post_to_chatter"
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
text: "Quick Actions",
|
|
106
|
-
a_attr: {
|
|
107
|
-
href: "actions_obj_quick_action.htm"
|
|
108
|
-
},
|
|
109
|
-
id: "actions_obj_quick_action"
|
|
110
|
-
},
|
|
111
|
-
{
|
|
112
|
-
text: "Refresh Metric Actions",
|
|
113
|
-
a_attr: {
|
|
114
|
-
href: "actions_obj_refresh_metric.htm"
|
|
115
|
-
},
|
|
116
|
-
id: "actions_obj_refresh_metric"
|
|
117
|
-
},
|
|
118
|
-
{
|
|
119
|
-
text: "Salesforce Order Management Actions",
|
|
120
|
-
a_attr: {
|
|
121
|
-
href: "actions_obj_order_management.htm"
|
|
122
|
-
},
|
|
123
|
-
id: "actions_obj_order_management"
|
|
124
|
-
},
|
|
125
|
-
{
|
|
126
|
-
text: "Simple Email Actions",
|
|
127
|
-
a_attr: {
|
|
128
|
-
href: "actions_obj_email_simple.htm"
|
|
129
|
-
},
|
|
130
|
-
id: "actions_obj_email_simple"
|
|
131
|
-
},
|
|
132
|
-
{
|
|
133
|
-
text: "Submit for Approval Actions",
|
|
134
|
-
a_attr: {
|
|
135
|
-
href: "actions_obj_submit_for_approval.htm"
|
|
136
|
-
},
|
|
137
|
-
id: "actions_obj_submit_for_approval"
|
|
138
|
-
}
|
|
139
|
-
],
|
|
140
|
-
text: "Action Objects",
|
|
141
|
-
a_attr: {
|
|
142
|
-
href: "actions_obj.htm"
|
|
143
|
-
},
|
|
144
|
-
id: "actions_obj"
|
|
145
|
-
}
|
|
146
|
-
];
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
/* eslint-disable jest/no-mocks-import */
|
|
2
|
-
import { createElement } from "lwc";
|
|
3
|
-
import Container from "../container";
|
|
4
|
-
import mockAvailableLanguages from "../__mocks__/mockAvailableLanguages";
|
|
5
|
-
import mockAvailableVersions from "../__mocks__/mockAvailableVersions";
|
|
6
|
-
import mockSelectedLanguage from "../__mocks__/mockSelectedLanguage";
|
|
7
|
-
import mockSelectedVersion from "../__mocks__/mockSelectedVersion";
|
|
8
|
-
import mockPdfUrl from "../__mocks__/mockPdfUrl";
|
|
9
|
-
import mockToc from "../__mocks__/mockToc";
|
|
10
|
-
import mockDocContent from "../__mocks__/mockDocContent";
|
|
11
|
-
import mockPageReference from "../__mocks__/mockPageReference";
|
|
12
|
-
window.scrollTo = jest.fn();
|
|
13
|
-
|
|
14
|
-
const mockContentFetchResponse = require("../__mocks__/mockContentFetchResponse.json");
|
|
15
|
-
const mockNavigationFetchResponse = require("../__mocks__/mockNavigationFetchResponse.json");
|
|
16
|
-
|
|
17
|
-
const create = (props?: object) => {
|
|
18
|
-
const component = createElement("doc-container", {
|
|
19
|
-
is: Container
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
Object.assign(component, {
|
|
23
|
-
selectedLanguage: mockSelectedLanguage,
|
|
24
|
-
selectedVersion: mockSelectedVersion,
|
|
25
|
-
availableLanguages: mockAvailableLanguages,
|
|
26
|
-
availableVersion: mockAvailableVersions,
|
|
27
|
-
pdfUrl: mockPdfUrl,
|
|
28
|
-
toc: mockToc,
|
|
29
|
-
docContent: mockDocContent,
|
|
30
|
-
pageReference: mockPageReference,
|
|
31
|
-
storybookDomain: "https://developer.salesforce.com",
|
|
32
|
-
storybookPage: "docs",
|
|
33
|
-
storybookDocId: "atlas.en-us.228.0.apexcode.meta",
|
|
34
|
-
storybookDeliverable: "apexcode",
|
|
35
|
-
storybookContentDocumentId: "apex_dev_guide.htm",
|
|
36
|
-
...(props || {})
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
return component;
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
function mockFetch() {
|
|
43
|
-
return jest.fn().mockImplementation((url) => {
|
|
44
|
-
let data = mockContentFetchResponse;
|
|
45
|
-
switch (url) {
|
|
46
|
-
case "https://developer.salesforce.com/docs/get_document/atlas.en-us.228.0.apexcode.meta":
|
|
47
|
-
data = mockNavigationFetchResponse;
|
|
48
|
-
break;
|
|
49
|
-
default:
|
|
50
|
-
data = mockContentFetchResponse;
|
|
51
|
-
}
|
|
52
|
-
return Promise.resolve({
|
|
53
|
-
ok: true,
|
|
54
|
-
json: () => data
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
describe("doc-container", () => {
|
|
60
|
-
it("renders the content", async () => {
|
|
61
|
-
global.fetch = mockFetch();
|
|
62
|
-
const component = create();
|
|
63
|
-
document.body.appendChild(component);
|
|
64
|
-
return Promise.resolve(() => {
|
|
65
|
-
const contentEl = component.shadowRoot.querySelector(
|
|
66
|
-
".doc-content"
|
|
67
|
-
);
|
|
68
|
-
expect(contentEl).not.toBeNull();
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
it("renders the navigation", async () => {
|
|
73
|
-
global.fetch = mockFetch();
|
|
74
|
-
const component = create();
|
|
75
|
-
document.body.appendChild(component);
|
|
76
|
-
|
|
77
|
-
return Promise.resolve(() => {
|
|
78
|
-
const navEl = component.shadowRoot.querySelector(".doc-nav");
|
|
79
|
-
expect(navEl).not.toBeNull();
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
});
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
div {
|
|
2
|
-
display: flex;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
.doc-nav {
|
|
6
|
-
margin: 10px;
|
|
7
|
-
min-width: 20% !important;
|
|
8
|
-
max-width: 20% !important;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
.doc-content {
|
|
12
|
-
margin: 10px;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
doc-nav {
|
|
16
|
-
min-width: 100% !important;
|
|
17
|
-
max-width: 100% !important;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
doc-content {
|
|
21
|
-
min-width: 100% !important;
|
|
22
|
-
max-width: 100% !important;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
lwc-doc-nav {
|
|
26
|
-
min-width: 100% !important;
|
|
27
|
-
max-width: 100% !important;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
lwc-doc-content {
|
|
31
|
-
min-width: 100% !important;
|
|
32
|
-
max-width: 100% !important;
|
|
33
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div if:true={loaded}>
|
|
3
|
-
<div class="doc-nav">
|
|
4
|
-
<doc-nav
|
|
5
|
-
toc={toc}
|
|
6
|
-
available-languages={availableLanguages}
|
|
7
|
-
selected-language={selectedLanguage}
|
|
8
|
-
pdf-url={pdfUrl}
|
|
9
|
-
available-versions={availableVersions}
|
|
10
|
-
selected-version={selectedVersion}
|
|
11
|
-
page-reference={pageReference}
|
|
12
|
-
selected-navigation-item={selectedNavigationItem}
|
|
13
|
-
></doc-nav>
|
|
14
|
-
</div>
|
|
15
|
-
<div class="doc-content">
|
|
16
|
-
<doc-content
|
|
17
|
-
docs-data={docContent}
|
|
18
|
-
page-reference={pageReference}
|
|
19
|
-
is-storybook={_isStorybook}
|
|
20
|
-
></doc-content>
|
|
21
|
-
</div>
|
|
22
|
-
</div>
|
|
23
|
-
</template>
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
title: "docs/doc-container",
|
|
3
|
-
component: "doc-container"
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
export const Base = (args: any) => {
|
|
7
|
-
return `
|
|
8
|
-
<doc-container storybook-domain='${args.domain}' storybook-page='${args.page}' storybook-doc-id='${args.docId}' storybook-deliverable='${args.deliverable}' storybook-content-document-id='${args.contentDocumentId}' ></doc-container>
|
|
9
|
-
`;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
Base.args = {
|
|
13
|
-
domain: "https://developer.salesforce.com",
|
|
14
|
-
page: "docs",
|
|
15
|
-
docId: "atlas.en-us.226.0.apexcode.meta",
|
|
16
|
-
deliverable: "apexcode",
|
|
17
|
-
contentDocumentId: "apex_dev_guide.htm"
|
|
18
|
-
};
|
|
@@ -1,360 +0,0 @@
|
|
|
1
|
-
import { LightningElement, api } from "lwc";
|
|
2
|
-
import {
|
|
3
|
-
AvailableLanguages,
|
|
4
|
-
AvailableVersions,
|
|
5
|
-
ContentLoaded,
|
|
6
|
-
DocContent,
|
|
7
|
-
NavigationLoaded,
|
|
8
|
-
NormalizedToc,
|
|
9
|
-
PageReference,
|
|
10
|
-
SelectedVersion,
|
|
11
|
-
SelectedLanguage,
|
|
12
|
-
SelectedNavigationItem,
|
|
13
|
-
DocToc,
|
|
14
|
-
PdfUrl
|
|
15
|
-
} from "../../../../../../../typings/custom-new";
|
|
16
|
-
|
|
17
|
-
const API_MAIN_URL = "https://developer.salesforce.com/docs/get_document/";
|
|
18
|
-
const API_DETAIL_URL =
|
|
19
|
-
"https://developer.salesforce.com/docs/get_document_content";
|
|
20
|
-
|
|
21
|
-
export default class Container extends LightningElement {
|
|
22
|
-
// TODO: We have to evaluate if we can find a better way to do component testing in Storybook.
|
|
23
|
-
@api
|
|
24
|
-
set storybookDomain(value: string) {
|
|
25
|
-
this.pageReference.domain = value;
|
|
26
|
-
this._isStorybook = true;
|
|
27
|
-
}
|
|
28
|
-
get storybookDomain() {
|
|
29
|
-
return this.pageReference.domain;
|
|
30
|
-
}
|
|
31
|
-
@api
|
|
32
|
-
set storybookPage(value: string) {
|
|
33
|
-
this.pageReference.page = value;
|
|
34
|
-
}
|
|
35
|
-
get storybookPage() {
|
|
36
|
-
return this.pageReference.page;
|
|
37
|
-
}
|
|
38
|
-
@api
|
|
39
|
-
set storybookDocId(value: string) {
|
|
40
|
-
this.pageReference.docId = value;
|
|
41
|
-
}
|
|
42
|
-
get storybookDocId() {
|
|
43
|
-
return this.pageReference.docId;
|
|
44
|
-
}
|
|
45
|
-
@api
|
|
46
|
-
set storybookDeliverable(value: string) {
|
|
47
|
-
this.pageReference.deliverable = value;
|
|
48
|
-
}
|
|
49
|
-
get storybookDeliverable() {
|
|
50
|
-
return this.pageReference.deliverable;
|
|
51
|
-
}
|
|
52
|
-
@api
|
|
53
|
-
set storybookContentDocumentId(value: string) {
|
|
54
|
-
this.pageReference.contentDocumentId = value;
|
|
55
|
-
}
|
|
56
|
-
get storybookContentDocumentId() {
|
|
57
|
-
return this.pageReference.contentDocumentId;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// Navigation
|
|
61
|
-
toc: DocToc = [
|
|
62
|
-
{
|
|
63
|
-
children: [],
|
|
64
|
-
text: "",
|
|
65
|
-
a_attr: {
|
|
66
|
-
href: ""
|
|
67
|
-
},
|
|
68
|
-
id: ""
|
|
69
|
-
}
|
|
70
|
-
];
|
|
71
|
-
|
|
72
|
-
// Toolbar
|
|
73
|
-
availableLanguages: AvailableLanguages = [
|
|
74
|
-
{
|
|
75
|
-
label: "",
|
|
76
|
-
code: "",
|
|
77
|
-
locale: "",
|
|
78
|
-
url: ""
|
|
79
|
-
}
|
|
80
|
-
];
|
|
81
|
-
|
|
82
|
-
availableVersions: AvailableVersions = [
|
|
83
|
-
{
|
|
84
|
-
version_test: "",
|
|
85
|
-
release_version: "",
|
|
86
|
-
doc_version: "",
|
|
87
|
-
version_url: ""
|
|
88
|
-
}
|
|
89
|
-
];
|
|
90
|
-
|
|
91
|
-
pdfUrl: PdfUrl = "";
|
|
92
|
-
|
|
93
|
-
selectedLanguage: SelectedLanguage = [
|
|
94
|
-
{
|
|
95
|
-
label: "",
|
|
96
|
-
code: "",
|
|
97
|
-
locale: "",
|
|
98
|
-
url: ""
|
|
99
|
-
}
|
|
100
|
-
];
|
|
101
|
-
|
|
102
|
-
selectedVersion: SelectedVersion = [
|
|
103
|
-
{
|
|
104
|
-
version_test: "",
|
|
105
|
-
release_version: "",
|
|
106
|
-
doc_version: "",
|
|
107
|
-
version_url: ""
|
|
108
|
-
}
|
|
109
|
-
];
|
|
110
|
-
|
|
111
|
-
// Content
|
|
112
|
-
docContent: DocContent = "";
|
|
113
|
-
|
|
114
|
-
// TODO: Impliment dx-tree component
|
|
115
|
-
selectedNavigationItem: SelectedNavigationItem = "";
|
|
116
|
-
|
|
117
|
-
normalizedToc: NormalizedToc = [
|
|
118
|
-
{
|
|
119
|
-
name: "",
|
|
120
|
-
label: "",
|
|
121
|
-
items: []
|
|
122
|
-
}
|
|
123
|
-
];
|
|
124
|
-
|
|
125
|
-
// Storybook Properties
|
|
126
|
-
selectedContentDocumentId: string | undefined;
|
|
127
|
-
selectedContentId: string | undefined;
|
|
128
|
-
selectedVersionUrl: string | undefined;
|
|
129
|
-
_isStorybook = false;
|
|
130
|
-
|
|
131
|
-
// State
|
|
132
|
-
navigationLoaded: NavigationLoaded = false;
|
|
133
|
-
|
|
134
|
-
contentLoaded: ContentLoaded = false;
|
|
135
|
-
|
|
136
|
-
pageReference: PageReference = {
|
|
137
|
-
domain: "",
|
|
138
|
-
page: "",
|
|
139
|
-
docId: "",
|
|
140
|
-
deliverable: "",
|
|
141
|
-
contentDocumentId: "",
|
|
142
|
-
hash: ""
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
constructor() {
|
|
146
|
-
super();
|
|
147
|
-
this.template.addEventListener(
|
|
148
|
-
"navclick",
|
|
149
|
-
this.handleNavEvent.bind(this) // eslint-disableline no-use-before-define
|
|
150
|
-
);
|
|
151
|
-
this.template.addEventListener(
|
|
152
|
-
"versionselected",
|
|
153
|
-
this.handleToolbarEvent.bind(this) // eslint-disable-line no-use-before-define
|
|
154
|
-
);
|
|
155
|
-
this.template.addEventListener(
|
|
156
|
-
"languageselected",
|
|
157
|
-
this.handleToolbarEvent.bind(this) // eslint-disable-line no-use-before-define
|
|
158
|
-
);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
connectedCallback() {
|
|
162
|
-
if (!this._isStorybook) {
|
|
163
|
-
this.getPageContext();
|
|
164
|
-
}
|
|
165
|
-
this.fetchDocData("navigation");
|
|
166
|
-
window.onpopstate = () => {
|
|
167
|
-
this.getPageContext();
|
|
168
|
-
this.fetchDocData("content");
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
getPageContext() {
|
|
173
|
-
[
|
|
174
|
-
this.pageReference.domain,
|
|
175
|
-
this.pageReference.page,
|
|
176
|
-
this.pageReference.docId,
|
|
177
|
-
this.pageReference.deliverable,
|
|
178
|
-
this.pageReference.contentDocumentId
|
|
179
|
-
] = window.location.pathname.split("/");
|
|
180
|
-
this.pageReference.hash = window.location.hash;
|
|
181
|
-
this.pageReference.domain = `${window.location.protocol}//${window.location.host}`;
|
|
182
|
-
//this.updateSelectedItem();
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
handleNavEvent(event: CustomEvent) {
|
|
186
|
-
if (event.detail.pageReference) {
|
|
187
|
-
const newPageReference = event.detail.pageReference;
|
|
188
|
-
const docIdPartials = window.location.pathname.split("/");
|
|
189
|
-
if (
|
|
190
|
-
this.pageReference.contentDocumentId ===
|
|
191
|
-
newPageReference.contentDocumentId &&
|
|
192
|
-
newPageReference.hash
|
|
193
|
-
) {
|
|
194
|
-
this.updatePageReference(newPageReference);
|
|
195
|
-
this.rewriteUrl(docIdPartials, newPageReference);
|
|
196
|
-
} else {
|
|
197
|
-
this.updatePageReference(newPageReference);
|
|
198
|
-
this.rewriteUrl(docIdPartials, newPageReference);
|
|
199
|
-
this.fetchDocData("content");
|
|
200
|
-
}
|
|
201
|
-
if (newPageReference.hash) {
|
|
202
|
-
this.navigateToHash(newPageReference.hash);
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
navigateToHash(hash: String) {
|
|
208
|
-
// eslint-disable-next-line no-use-before-define
|
|
209
|
-
this.template.querySelector("doc-content").navigateToHash(hash);
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
rewriteUrl(docIdPartials: string[], newPageReference: PageReference) {
|
|
213
|
-
if (!this._isStorybook) {
|
|
214
|
-
docIdPartials[4] = newPageReference.contentDocumentId;
|
|
215
|
-
let urlRewrite = docIdPartials.join("/");
|
|
216
|
-
if (this.pageReference.hash) {
|
|
217
|
-
urlRewrite = `${urlRewrite}#${newPageReference.hash}`;
|
|
218
|
-
}
|
|
219
|
-
window.history.pushState("Docs", "Docs", urlRewrite);
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
updatePageReference(newPageReference: PageReference) {
|
|
224
|
-
if (
|
|
225
|
-
newPageReference.page &&
|
|
226
|
-
this.pageReference.page !== newPageReference.page
|
|
227
|
-
) {
|
|
228
|
-
this.pageReference.page = newPageReference.page;
|
|
229
|
-
}
|
|
230
|
-
if (
|
|
231
|
-
newPageReference.docId &&
|
|
232
|
-
this.pageReference.docId !== newPageReference.docId
|
|
233
|
-
) {
|
|
234
|
-
this.pageReference.docId = newPageReference.docId;
|
|
235
|
-
}
|
|
236
|
-
if (
|
|
237
|
-
newPageReference.deliverable &&
|
|
238
|
-
this.pageReference.deliverable !== newPageReference.deliverable
|
|
239
|
-
) {
|
|
240
|
-
this.pageReference.deliverable = newPageReference.deliverable;
|
|
241
|
-
}
|
|
242
|
-
if (
|
|
243
|
-
newPageReference.contentDocumentId &&
|
|
244
|
-
this.pageReference.contentDocumentId !==
|
|
245
|
-
newPageReference.contentDocumentId
|
|
246
|
-
) {
|
|
247
|
-
if (
|
|
248
|
-
newPageReference.contentDocumentId.endsWith(".htm") ||
|
|
249
|
-
newPageReference.contentDocumentId.includes("#")
|
|
250
|
-
) {
|
|
251
|
-
this.pageReference.contentDocumentId =
|
|
252
|
-
newPageReference.contentDocumentId;
|
|
253
|
-
} else {
|
|
254
|
-
this.pageReference.contentDocumentId =
|
|
255
|
-
newPageReference.contentDocumentId + ".htm";
|
|
256
|
-
}
|
|
257
|
-
//this.updateSelectedItem();
|
|
258
|
-
}
|
|
259
|
-
if (
|
|
260
|
-
newPageReference.hash &&
|
|
261
|
-
this.pageReference.hash !== newPageReference.hash
|
|
262
|
-
) {
|
|
263
|
-
this.pageReference.hash = newPageReference.hash;
|
|
264
|
-
} else {
|
|
265
|
-
this.pageReference.hash = "";
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
/*
|
|
270
|
-
TODO: use set selected item for new navigation components
|
|
271
|
-
updateSelectedItem() {
|
|
272
|
-
if (this.pageReference.contentDocumentId) {
|
|
273
|
-
let item = "";
|
|
274
|
-
if (this.pageReference.contentDocumentId.includes(".htm")) {
|
|
275
|
-
item = this.pageReference.contentDocumentId.replace(".htm", "");
|
|
276
|
-
}
|
|
277
|
-
if (this.pageReference.hash) {
|
|
278
|
-
item = `${item}-${this.pageReference.hash.replace("#", "")}`;
|
|
279
|
-
}
|
|
280
|
-
this.selectedItem = item;
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
*/
|
|
284
|
-
|
|
285
|
-
handleToolbarEvent(event: CustomEvent) {
|
|
286
|
-
if (event.detail.type === "language") {
|
|
287
|
-
this.selectedLanguage = this.availableLanguages.filter(
|
|
288
|
-
(language) => language.locale === event.detail.value
|
|
289
|
-
);
|
|
290
|
-
} else if (event.detail.type === "version") {
|
|
291
|
-
this.selectedVersion = this.availableVersions.filter(
|
|
292
|
-
(version) => version.doc_version === event.detail.value
|
|
293
|
-
);
|
|
294
|
-
}
|
|
295
|
-
const newPageReference = { ...this.pageReference };
|
|
296
|
-
newPageReference.docId = `atlas.${this.selectedLanguage[0].locale}.${this.selectedVersion[0].doc_version}.${this.pageReference.deliverable}.meta`;
|
|
297
|
-
const docIdPartials = window.location.pathname.split("/");
|
|
298
|
-
this.updatePageReference(newPageReference);
|
|
299
|
-
docIdPartials[2] = newPageReference.docId;
|
|
300
|
-
const urlRewrite = docIdPartials.join("/");
|
|
301
|
-
window.history.pushState("Docs", "Docs", urlRewrite);
|
|
302
|
-
this.fetchDocData("navigation");
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
fetchDocData(docType: String) {
|
|
306
|
-
const docRestUrl = this.generateCalloutURL(docType);
|
|
307
|
-
fetch(docRestUrl)
|
|
308
|
-
.then((result) => {
|
|
309
|
-
return result.json();
|
|
310
|
-
})
|
|
311
|
-
.then((json) => {
|
|
312
|
-
const docData = json;
|
|
313
|
-
if (docType === "navigation") {
|
|
314
|
-
this.toc = this.normalizeToc(docData.toc);
|
|
315
|
-
this.availableLanguages = docData.available_languages;
|
|
316
|
-
this.availableVersions = docData.available_versions;
|
|
317
|
-
this.selectedLanguage = [docData.language];
|
|
318
|
-
this.selectedVersion = [docData.version];
|
|
319
|
-
this.pdfUrl = docData.pdf_url;
|
|
320
|
-
this.navigationLoaded = true;
|
|
321
|
-
if (this.pageReference.contentDocumentId === undefined) {
|
|
322
|
-
this.pageReference.contentDocumentId =
|
|
323
|
-
docData.content_document_id + ".htm";
|
|
324
|
-
}
|
|
325
|
-
this.fetchDocData("content");
|
|
326
|
-
} else if (docType === "content") {
|
|
327
|
-
this.docContent = docData.content;
|
|
328
|
-
this.contentLoaded = true;
|
|
329
|
-
if (!this.pageReference.hash) {
|
|
330
|
-
window.scrollTo({ top: 0, behavior: "smooth" });
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
})
|
|
334
|
-
.catch((error) => console.log(error));
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
// Generate the callout URL for the fetch based on the docType
|
|
338
|
-
generateCalloutURL(docType: String) {
|
|
339
|
-
if (docType === "navigation") {
|
|
340
|
-
return API_MAIN_URL + this.pageReference.docId;
|
|
341
|
-
} else if (docType === "content") {
|
|
342
|
-
return `${API_DETAIL_URL}/${this.pageReference.deliverable}/${this.pageReference.contentDocumentId}/${this.selectedLanguage[0].locale}/${this.selectedVersion[0].doc_version}`;
|
|
343
|
-
}
|
|
344
|
-
console.log("Incorrect Doc Type");
|
|
345
|
-
return "";
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
// Render page only with navigation and content are both loaded
|
|
349
|
-
get loaded() {
|
|
350
|
-
return this.navigationLoaded && this.contentLoaded;
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
normalizeToc(toc) {
|
|
354
|
-
let normalizedToc = JSON.stringify(toc).replace(/"text"/g, '"label"');
|
|
355
|
-
normalizedToc = normalizedToc.replace(/"id"/g, '"name"');
|
|
356
|
-
const jsonToc = JSON.parse(normalizedToc)[0];
|
|
357
|
-
jsonToc.isExpanded = true;
|
|
358
|
-
return jsonToc;
|
|
359
|
-
}
|
|
360
|
-
}
|