diff --git a/src/workbench/browser/src/app/pages/extension/detail/extension-detail.component.ts b/src/workbench/browser/src/app/pages/extension/detail/extension-detail.component.ts
index 68bec5305..1ce68dcbf 100644
--- a/src/workbench/browser/src/app/pages/extension/detail/extension-detail.component.ts
+++ b/src/workbench/browser/src/app/pages/extension/detail/extension-detail.component.ts
@@ -20,8 +20,21 @@ export class ExtensionDetailComponent implements OnInit {
this.route.snapshot.queryParams.id,
this.route.snapshot.queryParams.name
);
+ if (!this.extensionDetail?.introduction && !this.extensionDetail?.installed) {
+ await this.fetchReadme();
+ }
this.extensionDetail.introduction ||= 'This plugin has no documentation yet.';
}
+
+ async fetchReadme() {
+ try {
+ const htmlText = await (await fetch(`https://www.npmjs.com/package/${this.extensionDetail.name}`)).text();
+ const domParser = new DOMParser();
+ const html = domParser.parseFromString(htmlText, 'text/html');
+ this.extensionDetail.introduction = html.querySelector('#readme').innerHTML;
+ } catch (error) {}
+ }
+
manageExtension(operate: string, id) {
this.isOperating = true;
console.log(this.isOperating);
@@ -34,10 +47,13 @@ export class ExtensionDetailComponent implements OnInit {
switch (operate) {
case 'install': {
this.extensionDetail.installed = this.extensionService.install(id);
+ this.getDetail();
break;
}
case 'uninstall': {
this.extensionDetail.installed = !this.extensionService.uninstall(id);
+ this.fetchReadme();
+ break;
}
}
this.isOperating = false;
diff --git a/src/workbench/browser/src/app/pages/extension/extension.component.scss b/src/workbench/browser/src/app/pages/extension/extension.component.scss
index 38bdfa4b8..6be9b9cd8 100644
--- a/src/workbench/browser/src/app/pages/extension/extension.component.scss
+++ b/src/workbench/browser/src/app/pages/extension/extension.component.scss
@@ -13,6 +13,9 @@
font-size: 0.9em;
}
}
+ .tree_node {
+ font-size: 12px;
+ }
.ant-tree .ant-tree-node-content-wrapper.ant-tree-node-selected {
opacity: .8;
}
diff --git a/src/workbench/browser/src/app/shared/components/setting/setting.component.html b/src/workbench/browser/src/app/shared/components/setting/setting.component.html
index e116c5ae5..3cf2d2722 100644
--- a/src/workbench/browser/src/app/shared/components/setting/setting.component.html
+++ b/src/workbench/browser/src/app/shared/components/setting/setting.component.html
@@ -53,7 +53,7 @@
{{ module.title }}
-
+
diff --git a/src/workbench/browser/src/app/shared/components/shadow/shadow-dom-encapsulation.component.ts b/src/workbench/browser/src/app/shared/components/shadow/shadow-dom-encapsulation.component.ts
index 77fe00506..8d12d58a1 100644
--- a/src/workbench/browser/src/app/shared/components/shadow/shadow-dom-encapsulation.component.ts
+++ b/src/workbench/browser/src/app/shared/components/shadow/shadow-dom-encapsulation.component.ts
@@ -3,25 +3,41 @@ import MarkdownIt from 'markdown-it/dist/markdown-it';
@Component({
selector: 'eo-shadow-dom',
- template: ` `,
- styles: ['h2, .shadow-message { color: blue; }'],
+ template: ` `,
+ styles: [],
encapsulation: ViewEncapsulation.ShadowDom,
})
export class ShadowDomEncapsulationComponent implements OnInit {
- md = new MarkdownIt();
+ md: MarkdownIt;
- @Input() html = '';
+ @Input() text = '';
+ @Input() options = {
+ html: false,
+ };
+
+ get content() {
+ const html = this.md.render(this.text || '');
+ if (html && this.options.html) {
+ const domParser = new DOMParser();
+ const doc = domParser.parseFromString(html, 'text/html');
+ const a = doc.querySelectorAll('a');
+ a.forEach((n) => n.setAttribute('target', '_blank'));
+ return doc.body.innerHTML;
+ } else {
+ return html;
+ }
+ }
+
+ constructor() {}
ngOnInit() {
+ this.md = new MarkdownIt(this.options);
this.customLinkRender();
}
customLinkRender() {
const defaultRender =
- this.md.renderer.rules.link_open ||
- function (tokens, idx, options, env, self) {
- return self.renderToken(tokens, idx, options);
- };
+ this.md.renderer.rules.link_open || ((tokens, idx, options, env, self) => self.renderToken(tokens, idx, options));
this.md.renderer.rules.link_open = (tokens, idx, options, env, self) => {
// If you are sure other plugins can't add `target` - drop check below