@matechat/ng 0.0.1-alpha.0 → 20.0.1-alpha.0

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.
Files changed (42) hide show
  1. package/Base/base.component.d.ts +5 -5
  2. package/Bubble/bubble.component.d.ts +7 -5
  3. package/Input/button/button.component.d.ts +3 -2
  4. package/Input/input.component.d.ts +13 -4
  5. package/MarkdownCard/code-block.component.d.ts +49 -0
  6. package/MarkdownCard/index.d.ts +3 -0
  7. package/MarkdownCard/markdown-card.component.d.ts +200 -0
  8. package/MarkdownCard/markdown-card.module.d.ts +13 -0
  9. package/README.md +117 -13
  10. package/components-common/Base/foundation.d.ts +2 -0
  11. package/components-common/MarkdownCard/codeblock-foundation.d.ts +21 -0
  12. package/components-common/MarkdownCard/common/MDCardService.d.ts +14 -0
  13. package/components-common/MarkdownCard/common/MermaidService.d.ts +23 -0
  14. package/components-common/MarkdownCard/common/mdCard.types.d.ts +56 -0
  15. package/components-common/MarkdownCard/common/parser.d.ts +150 -0
  16. package/components-common/MarkdownCard/foundation.d.ts +38 -0
  17. package/esm2022/Base/base.component.mjs +2 -2
  18. package/esm2022/Bubble/bubble.component.mjs +15 -8
  19. package/esm2022/Input/button/button.component.mjs +1 -1
  20. package/esm2022/Input/input.component.mjs +107 -3
  21. package/esm2022/Locale/locale.service.mjs +5 -5
  22. package/esm2022/MarkdownCard/code-block.component.mjs +175 -0
  23. package/esm2022/MarkdownCard/index.mjs +4 -0
  24. package/esm2022/MarkdownCard/markdown-card.component.mjs +436 -0
  25. package/esm2022/MarkdownCard/markdown-card.module.mjs +44 -0
  26. package/esm2022/components-common/Base/foundation.mjs +4 -1
  27. package/esm2022/components-common/Input/foundation.mjs +1 -2
  28. package/esm2022/components-common/MarkdownCard/codeblock-foundation.mjs +132 -0
  29. package/esm2022/components-common/MarkdownCard/common/MDCardService.mjs +69 -0
  30. package/esm2022/components-common/MarkdownCard/common/MermaidService.mjs +222 -0
  31. package/esm2022/components-common/MarkdownCard/common/mdCard.types.mjs +6 -0
  32. package/esm2022/components-common/MarkdownCard/common/parser.mjs +194 -0
  33. package/esm2022/components-common/MarkdownCard/foundation.mjs +84 -0
  34. package/esm2022/public-api.mjs +2 -1
  35. package/fesm2022/matechat-ng.mjs +1514 -17
  36. package/fesm2022/matechat-ng.mjs.map +1 -1
  37. package/package.json +12 -7
  38. package/public-api.d.ts +1 -0
  39. package/fesm2022/matechat-ng-en-us-DsYnUbZd.mjs +0 -28
  40. package/fesm2022/matechat-ng-en-us-DsYnUbZd.mjs.map +0 -1
  41. package/fesm2022/matechat-ng-zh-cn--_YVZHnW.mjs +0 -28
  42. package/fesm2022/matechat-ng-zh-cn--_YVZHnW.mjs.map +0 -1
@@ -1,11 +1,11 @@
1
- import { DefaultAdapter } from '../components-common/Base/foundation';
1
+ import BaseFoundation, { DefaultAdapter } from '../components-common/Base/foundation';
2
2
  import * as i0 from "@angular/core";
3
- export default class BaseComponent {
4
- foundation: any;
3
+ export default class BaseComponent<T extends BaseFoundation<DefaultAdapter>> {
4
+ foundation: T;
5
5
  cache: any;
6
6
  constructor();
7
7
  ngOnDestroy(): void;
8
8
  get adapter(): DefaultAdapter;
9
- static ɵfac: i0.ɵɵFactoryDeclaration<BaseComponent, never>;
10
- static ɵcmp: i0.ɵɵComponentDeclaration<BaseComponent, "mate-base-component", never, {}, {}, never, never, true, never>;
9
+ static ɵfac: i0.ɵɵFactoryDeclaration<BaseComponent<any>, never>;
10
+ static ɵcmp: i0.ɵɵComponentDeclaration<BaseComponent<any>, "mate-base-component", never, {}, {}, never, never, true, never>;
11
11
  }
@@ -1,24 +1,26 @@
1
- import { TemplateRef } from '@angular/core';
1
+ import { TemplateRef, QueryList } from '@angular/core';
2
2
  import { BubbleAlign, BubbleVariant, AvatarPosition, BubbleAvatar } from '../components-common//Bubble/common/bubble-types';
3
- import { BubbleAdapter } from '../components-common/Bubble/foundation';
3
+ import { BubbleAdapter, BubbleFoundation } from '../components-common/Bubble/foundation';
4
4
  import BaseComponent from '../Base/base.component';
5
5
  import * as i0 from "@angular/core";
6
- export declare class BubbleComponent extends BaseComponent {
6
+ export declare class BubbleComponent extends BaseComponent<BubbleFoundation> {
7
7
  content: string;
8
8
  loading: boolean;
9
9
  align: BubbleAlign;
10
10
  avatarPosition: AvatarPosition;
11
11
  variant: BubbleVariant;
12
12
  avatarConfig?: BubbleAvatar;
13
+ avatarTemplate: TemplateRef<any> | null;
13
14
  topTemplate: TemplateRef<any> | null;
14
15
  loadingTplTemplate: TemplateRef<any> | null;
15
- defaultTemplate: TemplateRef<any> | null;
16
16
  bottomTemplate: TemplateRef<any> | null;
17
+ contentChildren: QueryList<any>;
18
+ get ngContentProjected(): boolean;
17
19
  constructor();
18
20
  ngOnInit(): void;
19
21
  get adapter(): BubbleAdapter;
20
22
  get bubbleClasses(): string;
21
23
  get isEmptyAvatar(): boolean;
22
24
  static ɵfac: i0.ɵɵFactoryDeclaration<BubbleComponent, never>;
23
- static ɵcmp: i0.ɵɵComponentDeclaration<BubbleComponent, "mc-bubble", never, { "content": { "alias": "content"; "required": false; }; "loading": { "alias": "loading"; "required": false; }; "align": { "alias": "align"; "required": false; }; "avatarPosition": { "alias": "avatarPosition"; "required": false; }; "variant": { "alias": "variant"; "required": false; }; "avatarConfig": { "alias": "avatarConfig"; "required": false; }; }, {}, ["topTemplate", "loadingTplTemplate", "defaultTemplate", "bottomTemplate"], ["[top]", "[loadingTpl]", "*", "[bottom]"], true, never>;
25
+ static ɵcmp: i0.ɵɵComponentDeclaration<BubbleComponent, "mc-bubble", never, { "content": { "alias": "content"; "required": false; }; "loading": { "alias": "loading"; "required": false; }; "align": { "alias": "align"; "required": false; }; "avatarPosition": { "alias": "avatarPosition"; "required": false; }; "variant": { "alias": "variant"; "required": false; }; "avatarConfig": { "alias": "avatarConfig"; "required": false; }; }, {}, ["avatarTemplate", "topTemplate", "loadingTplTemplate", "bottomTemplate", "contentChildren"], ["[avatar]", "[top]", "[loadingTpl]", "*", "[bottom]"], true, never>;
24
26
  }
@@ -2,8 +2,9 @@ import { EventEmitter, ElementRef } from '@angular/core';
2
2
  import { SendBtnVariant } from '../../components-common/Input/common/types';
3
3
  import BaseComponent from '../../Base/base.component';
4
4
  import { LocaleService } from '../../Locale';
5
+ import { InputButtonFoundation } from '../../components-common/Input/button-foundation';
5
6
  import * as i0 from "@angular/core";
6
- export declare class ButtonComponent extends BaseComponent {
7
+ export declare class ButtonComponent extends BaseComponent<InputButtonFoundation> {
7
8
  private localeService;
8
9
  disabled: boolean;
9
10
  loading: boolean;
@@ -20,7 +21,7 @@ export declare class ButtonComponent extends BaseComponent {
20
21
  left: string;
21
22
  };
22
23
  constructor(localeService: LocaleService);
23
- get buttonClasses(): string;
24
+ get buttonClasses(): Record<string, any>;
24
25
  ngOnInit(): void;
25
26
  onMouseDown(): void;
26
27
  onMouseUp(): void;
@@ -1,11 +1,15 @@
1
1
  import { EventEmitter, OnInit, ElementRef, TemplateRef, SimpleChanges } from '@angular/core';
2
2
  import { DisplayType, InputVariant, SendBtnVariant, SubmitShortKey } from '../components-common/Input/common/types';
3
3
  import BaseComponent from '../Base/base.component';
4
- import { InputAdapter } from '../components-common/Input/foundation';
4
+ import { InputAdapter, InputFoundation } from '../components-common/Input/foundation';
5
5
  import { LocaleService } from '../Locale/locale.service';
6
6
  import * as i0 from "@angular/core";
7
+ export type TextareaAutoSize = {
8
+ minRows?: number;
9
+ maxRows?: number;
10
+ } | boolean;
7
11
  export declare const inputContextToken = "input-context";
8
- export declare class InputComponent extends BaseComponent implements OnInit {
12
+ export declare class InputComponent extends BaseComponent<InputFoundation> implements OnInit {
9
13
  private localeService;
10
14
  value: string;
11
15
  placeholder: string;
@@ -18,6 +22,8 @@ export declare class InputComponent extends BaseComponent implements OnInit {
18
22
  maxLength: number | null;
19
23
  submitShortKey: SubmitShortKey | null | string;
20
24
  autofocus: boolean;
25
+ autosize: TextareaAutoSize;
26
+ textareaStyle: Record<string, string>;
21
27
  change: EventEmitter<string>;
22
28
  submit: EventEmitter<string>;
23
29
  cancel: EventEmitter<void>;
@@ -36,7 +42,7 @@ export declare class InputComponent extends BaseComponent implements OnInit {
36
42
  get adapter(): InputAdapter;
37
43
  onChange(e: any): void;
38
44
  ngOnChanges(changes: SimpleChanges): void;
39
- get inputClasses(): string;
45
+ get inputClasses(): Record<string, any>;
40
46
  get maxlengthValue(): number | null;
41
47
  onInput(): void;
42
48
  onCompositionStart(): void;
@@ -48,9 +54,12 @@ export declare class InputComponent extends BaseComponent implements OnInit {
48
54
  onButtonCancel(): void;
49
55
  onButtonChange(value: string): void;
50
56
  ngAfterViewInit(): void;
57
+ updateTextareaStyle(): void;
58
+ private getAutosizeConfig;
59
+ private computeTextareaHeight;
51
60
  get placeholderText(): string;
52
61
  onFocus(event: FocusEvent): void;
53
62
  onBlur(event: FocusEvent): void;
54
63
  static ɵfac: i0.ɵɵFactoryDeclaration<InputComponent, never>;
55
- static ɵcmp: i0.ɵɵComponentDeclaration<InputComponent, "mc-input", never, { "value": { "alias": "value"; "required": false; }; "placeholder": { "alias": "placeholder"; "required": false; }; "disabled": { "alias": "disabled"; "required": false; }; "displayType": { "alias": "displayType"; "required": false; }; "variant": { "alias": "variant"; "required": false; }; "sendBtnVariant": { "alias": "sendBtnVariant"; "required": false; }; "loading": { "alias": "loading"; "required": false; }; "showCount": { "alias": "showCount"; "required": false; }; "maxLength": { "alias": "maxLength"; "required": false; }; "submitShortKey": { "alias": "submitShortKey"; "required": false; }; "autofocus": { "alias": "autofocus"; "required": false; }; }, { "change": "change"; "submit": "submit"; "cancel": "cancel"; "focus": "focus"; "blur": "blur"; }, ["headTemplate", "prefixTemplate", "suffixTemplate", "buttonTemplate", "extraTemplate"], never, true, never>;
64
+ static ɵcmp: i0.ɵɵComponentDeclaration<InputComponent, "mc-input", never, { "value": { "alias": "value"; "required": false; }; "placeholder": { "alias": "placeholder"; "required": false; }; "disabled": { "alias": "disabled"; "required": false; }; "displayType": { "alias": "displayType"; "required": false; }; "variant": { "alias": "variant"; "required": false; }; "sendBtnVariant": { "alias": "sendBtnVariant"; "required": false; }; "loading": { "alias": "loading"; "required": false; }; "showCount": { "alias": "showCount"; "required": false; }; "maxLength": { "alias": "maxLength"; "required": false; }; "submitShortKey": { "alias": "submitShortKey"; "required": false; }; "autofocus": { "alias": "autofocus"; "required": false; }; "autosize": { "alias": "autosize"; "required": false; }; }, { "change": "change"; "submit": "submit"; "cancel": "cancel"; "focus": "focus"; "blur": "blur"; }, ["headTemplate", "prefixTemplate", "suffixTemplate", "buttonTemplate", "extraTemplate"], never, true, never>;
56
65
  }
@@ -0,0 +1,49 @@
1
+ import { OnInit, ElementRef, OnChanges, SimpleChanges, ChangeDetectorRef, QueryList } from '@angular/core';
2
+ import { TemplateRef } from '@angular/core';
3
+ import type { MermaidConfig } from '../components-common/MarkdownCard/common/mdCard.types';
4
+ import BaseComponent from '../Base/base.component';
5
+ import { CodeBlockAdapter, CodeBlockFoundation } from '../components-common/MarkdownCard/codeblock-foundation';
6
+ import * as i0 from "@angular/core";
7
+ export declare class CodeBlockComponent extends BaseComponent<CodeBlockFoundation> implements OnInit, OnChanges {
8
+ private cdr;
9
+ code: string;
10
+ language: string;
11
+ blockIndex: number;
12
+ theme: 'light' | 'dark';
13
+ enableMermaid: boolean;
14
+ mermaidConfig: MermaidConfig;
15
+ contentTemplate: TemplateRef<any> | null;
16
+ headerTemplate: TemplateRef<any> | null;
17
+ actionsTemplate: TemplateRef<any> | null;
18
+ rootRef: ElementRef;
19
+ mermaidContentRef: ElementRef;
20
+ codeElementRef: ElementRef;
21
+ codeElementTemplates: QueryList<ElementRef>;
22
+ expanded: boolean;
23
+ copied: boolean;
24
+ mermaidContent: string;
25
+ private diffDom;
26
+ private _showMermaidDiagram;
27
+ get showMermaidDiagram(): boolean;
28
+ set showMermaidDiagram(value: boolean);
29
+ highlightedCode: string;
30
+ isMermaid: boolean;
31
+ private copySubject;
32
+ constructor(cdr: ChangeDetectorRef);
33
+ get adapter(): CodeBlockAdapter;
34
+ switchShowMermaid(show: boolean): void;
35
+ ngOnInit(): void;
36
+ ngAfterViewInit(): void;
37
+ ngOnChanges(changes: SimpleChanges): void;
38
+ private checkIsMermaid;
39
+ private updateHighlightedCode;
40
+ zoomIn(): void;
41
+ zoomOut(): void;
42
+ download(): void;
43
+ renderMermaid(): Promise<void>;
44
+ toggleExpand(): void;
45
+ copyCode(): void;
46
+ copyCodeInternal(): void;
47
+ static ɵfac: i0.ɵɵFactoryDeclaration<CodeBlockComponent, never>;
48
+ static ɵcmp: i0.ɵɵComponentDeclaration<CodeBlockComponent, "mc-code-block", never, { "code": { "alias": "code"; "required": false; }; "language": { "alias": "language"; "required": false; }; "blockIndex": { "alias": "blockIndex"; "required": false; }; "theme": { "alias": "theme"; "required": false; }; "enableMermaid": { "alias": "enableMermaid"; "required": false; }; "mermaidConfig": { "alias": "mermaidConfig"; "required": false; }; "contentTemplate": { "alias": "contentTemplate"; "required": false; }; "headerTemplate": { "alias": "headerTemplate"; "required": false; }; "actionsTemplate": { "alias": "actionsTemplate"; "required": false; }; }, {}, never, never, false, never>;
49
+ }
@@ -0,0 +1,3 @@
1
+ export * from './markdown-card.component';
2
+ export * from './code-block.component';
3
+ export * from './markdown-card.module';
@@ -0,0 +1,200 @@
1
+ import { OnInit, OnChanges, OnDestroy, ChangeDetectorRef, SimpleChanges, EventEmitter, Renderer2, ViewContainerRef, TemplateRef } from '@angular/core';
2
+ import markdownit from 'markdown-it';
3
+ import type { Token } from 'markdown-it';
4
+ import type { ASTNode } from '../components-common/MarkdownCard/common/mdCard.types';
5
+ import { MarkdownCardProps } from '../components-common/MarkdownCard/common/mdCard.types';
6
+ import BaseComponent from '../Base/base.component';
7
+ import { MarkdownCardAdapter, MarkdownCardFoundation } from '../components-common/MarkdownCard/foundation';
8
+ import * as i0 from "@angular/core";
9
+ export declare class MarkdownCardComponent extends BaseComponent<MarkdownCardFoundation> implements OnInit, OnChanges, OnDestroy {
10
+ private renderer;
11
+ cdr: ChangeDetectorRef;
12
+ private diffDom;
13
+ content: string;
14
+ typing: boolean;
15
+ enableThink: boolean;
16
+ typingOptions: MarkdownCardProps['typingOptions'] | any;
17
+ thinkOptions: MarkdownCardProps['thinkOptions'];
18
+ mdOptions: MarkdownCardProps['mdOptions'];
19
+ mdPlugins: MarkdownCardProps['mdPlugins'];
20
+ customXssRules: MarkdownCardProps['customXssRules'];
21
+ theme: 'light' | 'dark' | any;
22
+ enableMermaid: boolean;
23
+ mermaidConfig: MarkdownCardProps['mermaidConfig'];
24
+ actionsTemplate: TemplateRef<any> | null;
25
+ headerTemplate: TemplateRef<any> | null;
26
+ contentTemplate: TemplateRef<any> | null;
27
+ private codeBlockComponentsCache;
28
+ afterMdtInit: EventEmitter<markdownit>;
29
+ typingStart: EventEmitter<void>;
30
+ typingEvent: EventEmitter<void>;
31
+ typingEnd: EventEmitter<void>;
32
+ markdownContainer: ViewContainerRef;
33
+ private mdt;
34
+ typingIndex: number;
35
+ isTyping: boolean;
36
+ timer: number | null;
37
+ parser: {
38
+ isSelfClosingTag: (token: {
39
+ type: string;
40
+ tag: string;
41
+ attrs: [string, string][] | null;
42
+ map: [number, number] | null;
43
+ nesting: Token.Nesting;
44
+ level: number;
45
+ children: any[] | null;
46
+ content: string;
47
+ markup: string;
48
+ info: string;
49
+ meta: any;
50
+ block: boolean;
51
+ hidden: boolean;
52
+ attrIndex(name: string): number;
53
+ attrPush(attrData: [string, string]): void;
54
+ attrSet(name: string, value: string): void;
55
+ attrGet(name: string): string | null;
56
+ attrJoin(name: string, value: string): void;
57
+ }) => boolean;
58
+ isClosingTag: (openToken: {
59
+ type: string;
60
+ tag: string;
61
+ attrs: [string, string][] | null;
62
+ map: [number, number] | null;
63
+ nesting: Token.Nesting;
64
+ level: number;
65
+ children: any[] | null;
66
+ content: string;
67
+ markup: string;
68
+ info: string;
69
+ meta: any;
70
+ block: boolean;
71
+ hidden: boolean;
72
+ attrIndex(name: string): number;
73
+ attrPush(attrData: [string, string]): void;
74
+ attrSet(name: string, value: string): void;
75
+ attrGet(name: string): string | null;
76
+ attrJoin(name: string, value: string): void;
77
+ }, closeToken: {
78
+ type: string;
79
+ tag: string;
80
+ attrs: [string, string][] | null;
81
+ map: [number, number] | null;
82
+ nesting: Token.Nesting;
83
+ level: number;
84
+ children: any[] | null;
85
+ content: string;
86
+ markup: string;
87
+ info: string;
88
+ meta: any;
89
+ block: boolean;
90
+ hidden: boolean;
91
+ attrIndex(name: string): number;
92
+ attrPush(attrData: [string, string]): void;
93
+ attrSet(name: string, value: string): void;
94
+ attrGet(name: string): string | null;
95
+ attrJoin(name: string, value: string): void;
96
+ }) => boolean;
97
+ tokensToAst: (tokens: {
98
+ type: string;
99
+ tag: string;
100
+ attrs: [string, string][] | null;
101
+ map: [number, number] | null;
102
+ nesting: Token.Nesting;
103
+ level: number;
104
+ children: any[] | null;
105
+ content: string;
106
+ markup: string;
107
+ info: string;
108
+ meta: any;
109
+ block: boolean;
110
+ hidden: boolean;
111
+ attrIndex(name: string): number;
112
+ attrPush(attrData: [string, string]): void;
113
+ attrSet(name: string, value: string): void;
114
+ attrGet(name: string): string | null;
115
+ attrJoin(name: string, value: string): void;
116
+ }[]) => ASTNode[];
117
+ genTreeNode: (node: {
118
+ type: string;
119
+ tag: string;
120
+ attrs: [string, string][] | null;
121
+ map: [number, number] | null;
122
+ nesting: Token.Nesting;
123
+ level: number;
124
+ children: any[] | null;
125
+ content: string;
126
+ markup: string;
127
+ info: string;
128
+ meta: any;
129
+ block: boolean;
130
+ hidden: boolean;
131
+ attrIndex(name: string): number;
132
+ attrPush(attrData: [string, string]): void;
133
+ attrSet(name: string, value: string): void;
134
+ attrGet(name: string): string | null;
135
+ attrJoin(name: string, value: string): void;
136
+ } | null) => ASTNode;
137
+ matchHtmlToken: (token: {
138
+ type: string;
139
+ tag: string;
140
+ attrs: [string, string][] | null;
141
+ map: [number, number] | null;
142
+ nesting: Token.Nesting;
143
+ level: number;
144
+ children: any[] | null;
145
+ content: string;
146
+ markup: string;
147
+ info: string;
148
+ meta: any;
149
+ block: boolean;
150
+ hidden: boolean;
151
+ attrIndex(name: string): number;
152
+ attrPush(attrData: [string, string]): void;
153
+ attrSet(name: string, value: string): void;
154
+ attrGet(name: string): string | null;
155
+ attrJoin(name: string, value: string): void;
156
+ }, stack: {
157
+ type: string;
158
+ tag: string;
159
+ attrs: [string, string][] | null;
160
+ map: [number, number] | null;
161
+ nesting: Token.Nesting;
162
+ level: number;
163
+ children: any[] | null;
164
+ content: string;
165
+ markup: string;
166
+ info: string;
167
+ meta: any;
168
+ block: boolean;
169
+ hidden: boolean;
170
+ attrIndex(name: string): number;
171
+ attrPush(attrData: [string, string]): void;
172
+ attrSet(name: string, value: string): void;
173
+ attrGet(name: string): string | null;
174
+ attrJoin(name: string, value: string): void;
175
+ }[]) => void;
176
+ isValidTagName: (tagName: string | undefined) => boolean;
177
+ };
178
+ mdCardService: any;
179
+ noDiff: boolean;
180
+ constructor(renderer: Renderer2, cdr: ChangeDetectorRef);
181
+ ngOnInit(): void;
182
+ get adapter(): MarkdownCardAdapter;
183
+ ngOnChanges(changes: SimpleChanges): void;
184
+ private parseContent;
185
+ private renderContent;
186
+ private getEmptyCodeBlock;
187
+ private astToVnodes;
188
+ private processASTNode;
189
+ private processHTMLNode;
190
+ private renderContentNoDiff;
191
+ private processInlineToken;
192
+ private processFenceNode;
193
+ private processASTNodeInternal;
194
+ private processToken;
195
+ private createCodeBlock;
196
+ private typewriterStart;
197
+ ngOnDestroy(): void;
198
+ static ɵfac: i0.ɵɵFactoryDeclaration<MarkdownCardComponent, never>;
199
+ static ɵcmp: i0.ɵɵComponentDeclaration<MarkdownCardComponent, "mc-markdown-card", never, { "content": { "alias": "content"; "required": false; }; "typing": { "alias": "typing"; "required": false; }; "enableThink": { "alias": "enableThink"; "required": false; }; "typingOptions": { "alias": "typingOptions"; "required": false; }; "thinkOptions": { "alias": "thinkOptions"; "required": false; }; "mdOptions": { "alias": "mdOptions"; "required": false; }; "mdPlugins": { "alias": "mdPlugins"; "required": false; }; "customXssRules": { "alias": "customXssRules"; "required": false; }; "theme": { "alias": "theme"; "required": false; }; "enableMermaid": { "alias": "enableMermaid"; "required": false; }; "mermaidConfig": { "alias": "mermaidConfig"; "required": false; }; "actionsTemplate": { "alias": "actionsTemplate"; "required": false; }; "headerTemplate": { "alias": "headerTemplate"; "required": false; }; "contentTemplate": { "alias": "contentTemplate"; "required": false; }; }, { "afterMdtInit": "afterMdtInit"; "typingStart": "typingStart"; "typingEvent": "typingEvent"; "typingEnd": "typingEnd"; }, never, ["*"], false, never>;
200
+ }
@@ -0,0 +1,13 @@
1
+ import { ModuleWithProviders } from '@angular/core';
2
+ import * as i0 from "@angular/core";
3
+ import * as i1 from "./markdown-card.component";
4
+ import * as i2 from "./code-block.component";
5
+ import * as i3 from "@angular/common";
6
+ import * as i4 from "../Locale/translate.pipe";
7
+ import * as i5 from "../Locale/locale.module";
8
+ export declare class MarkdownCardModule {
9
+ static forRoot(): ModuleWithProviders<MarkdownCardModule>;
10
+ static ɵfac: i0.ɵɵFactoryDeclaration<MarkdownCardModule, never>;
11
+ static ɵmod: i0.ɵɵNgModuleDeclaration<MarkdownCardModule, [typeof i1.MarkdownCardComponent, typeof i2.CodeBlockComponent], [typeof i3.CommonModule, typeof i4.TranslatePipe, typeof i5.LocaleModule], [typeof i1.MarkdownCardComponent, typeof i2.CodeBlockComponent]>;
12
+ static ɵinj: i0.ɵɵInjectorDeclaration<MarkdownCardModule>;
13
+ }
package/README.md CHANGED
@@ -1,24 +1,128 @@
1
- # ComponentsNg
1
+ <p align="center">
2
+ <a href="https://matechat.gitcode.com/" target="_blank" rel="noopener noreferrer">
3
+ <img alt="MateChat Logo" src="https://matechat.gitcode.com/logo.svg" width="180" style="max-width:100%;">
4
+ </a>
5
+ </p>
6
+ <h1 align="center">MateChat/Angular</h1>
7
+ <p align="center">前端智能化场景解决方案UI库,轻松构建你的AI应用。已服务于华为内部多个应用智能化改造,并助力CodeArts、InsCode AI IDE等智能化助手搭建。</p>
2
8
 
3
- This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 17.3.0.
9
+ ![example](https://matechat.gitcode.com/example1.png)
4
10
 
5
- ## Code scaffolding
11
+ ## 🌈 特性
6
12
 
7
- Run `ng generate component component-name --project components-ng` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module --project components-ng`.
8
- > Note: Don't forget to add `--project components-ng` or else it will be added to the default project in your `angular.json` file.
13
+ - 面向智能化场景组件库
14
+ - 开箱即用
15
+ - 多场景匹配
16
+ - 多主题适配
17
+ - 更多特性持续演进更新中...
9
18
 
10
- ## Build
19
+ 了解更多请访问MateChat网站:[MateChat](https://matechat.gitcode.com)
11
20
 
12
- Run `ng build components-ng` to build the project. The build artifacts will be stored in the `dist/` directory.
21
+ ## 🖥️ 快速开始
13
22
 
14
- ## Publishing
23
+ ### 1. 安装
15
24
 
16
- After building your library with `ng build components-ng`, go to the dist folder `cd dist/components-ng` and run `npm publish`.
25
+ 如果你还没有新建项目,可以使用Angular CLI首先初始化一个`angular`项目:
17
26
 
18
- ## Running unit tests
27
+ ```bash
28
+ $ npm install -g @angular/cli
19
29
 
20
- Run `ng test components-ng` to execute the unit tests via [Karma](https://karma-runner.github.io).
30
+ $ ng new matechat-ng
21
31
 
22
- ## Further help
32
+ $ npm i @matechat/ng @devui-design/icons
33
+ ```
23
34
 
24
- To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page.
35
+ ### 2. 引入
36
+
37
+ 在`app.component.ts`文件中引入模块
38
+
39
+ ```ts
40
+ import { Component } from '@angular/core';
41
+ import { CommonModule } from '@angular/common';
42
+ import { BubbleModule } from '@matechat/ng';
43
+
44
+ @Component({
45
+ selector: 'app-root',
46
+ standalone: true,
47
+ imports: [
48
+ CommonModule,
49
+ BubbleModule,
50
+ ],
51
+ templateUrl: './app.component.html',
52
+ styleUrl: './app.component.css',
53
+ })
54
+ export class AppComponent {
55
+ }
56
+ ```
57
+
58
+ 在`angular.json`中引入图标库样式文件
59
+
60
+ ```json
61
+ {
62
+ "options": {
63
+ "styles": [
64
+ "node_modules/@devui-design/icons/icomoon/devui-icon.css"
65
+ ],
66
+ }
67
+ }
68
+ ```
69
+
70
+ ### 3. 使用
71
+
72
+ 在`main.ts`中初始化主题
73
+
74
+ ```ts
75
+ import { bootstrapApplication } from '@angular/platform-browser';
76
+ import { appConfig } from './app/app.config';
77
+ import { AppComponent } from './app/app.component';
78
+ import { ThemeServiceInit, infinityTheme } from 'devui-theme';
79
+
80
+ // 使用无限主题
81
+ ThemeServiceInit({ infinityTheme }, 'infinityTheme');
82
+ bootstrapApplication(AppComponent, appConfig)
83
+ .catch((err) => console.error(err));
84
+
85
+ ```
86
+
87
+ 在`app.component.html`文件中使用 MateChat 组件,如:
88
+
89
+ ```html
90
+ <template>
91
+ <mc-bubble [content]="'Hello, MateChat'" [avatarConfig]="{ name: 'matechat' }"></mc-bubble>
92
+ </template>
93
+ ```
94
+
95
+ ## 📝 提出意见&建议
96
+
97
+ 我们非常欢迎您的建议,您的每一个想法都可能帮助我们改进这个项目。如果您有任何关于功能改进、特性新增、文档补充或者其他方面的建议,随时在 [issues](https://gitcode.com/DevCloudFE/MateChat/issues) 提交。
98
+
99
+ ## 🔧 本地开发
100
+
101
+ ```bash
102
+ git clone git@gitcode.com:DevCloudFE/MateChat.git
103
+ cd matechat
104
+ pnpm i
105
+ pnpm run docs:dev
106
+ ```
107
+
108
+ ## 📅 特性规划
109
+
110
+ MateChat 在不断的演进中,你可在这里了解我们的计划:[MateChat 特性计划](https://gitcode.com/DevCloudFE/MateChat/issues/1)
111
+
112
+ ## 🤝 欢迎贡献
113
+
114
+ 我们诚挚地邀请您加入MateChat社区,一起参与项目的建设。无论您是经验丰富的开发者,还是刚刚起步的编程爱好者,您的贡献都对我们至关重要,这里是我们的[【贡献指南】](https://gitcode.com/DevCloudFE/MateChat/blob/main/CONTRIBUTING.md)。
115
+
116
+ ## 谁在使用
117
+
118
+ [华为云CodeArts智能助手](https://www.huaweicloud.com/product/codeartside/snap.html)
119
+
120
+ [InsCode AI IDE](https://inscode.csdn.net/)
121
+
122
+ ## License
123
+
124
+ [MIT](https://gitcode.com/DevCloudFE/MateChat/blob/main/LICENSE)
125
+
126
+ ## 联系方式
127
+
128
+ 欢迎加入我们的开源社区,关注DevUI微信公众号:DevUI
@@ -8,6 +8,7 @@ export interface DefaultAdapter {
8
8
  getCache(c: string): any;
9
9
  getCaches(): any;
10
10
  setCache(key: any, value: any): void;
11
+ nextTick(cb: (...args: any) => void): void;
11
12
  }
12
13
  declare class BaseFoundation<T extends DefaultAdapter> {
13
14
  static get cssClasses(): {};
@@ -36,6 +37,7 @@ declare class BaseFoundation<T extends DefaultAdapter> {
36
37
  getCaches(): any;
37
38
  getCache(key: string): any;
38
39
  setCache(key: string, value: any): void | "";
40
+ nextTick(cb: (...args: any) => void): void;
39
41
  _isInProps(key: string): boolean;
40
42
  init(lifecycle?: any): void;
41
43
  destroy(): void;
@@ -0,0 +1,21 @@
1
+ import BaseFoundation, { DefaultAdapter } from '../Base/foundation';
2
+ import { MermaidService } from './common/MermaidService';
3
+ import { MDCardService } from './common/MDCardService';
4
+ export interface CodeBlockAdapter extends DefaultAdapter {
5
+ getContainer(): HTMLElement | null;
6
+ highlightCodeChange(code: string, language: string): void;
7
+ }
8
+ export declare class CodeBlockFoundation extends BaseFoundation<CodeBlockAdapter> {
9
+ mermaidService?: MermaidService;
10
+ mdCardService: MDCardService;
11
+ constructor(adapter: CodeBlockAdapter);
12
+ toggleExpand: () => void;
13
+ zoomOut: () => void;
14
+ zoomIn: () => void;
15
+ checkIsMermaid: () => any;
16
+ download: () => void;
17
+ handleCopySuccess: () => void;
18
+ copyCodeInternal(): void;
19
+ updateHighlightedCode: () => void;
20
+ renderMermaid: () => Promise<void>;
21
+ }
@@ -0,0 +1,14 @@
1
+ import { type IWhiteList } from 'xss';
2
+ import type { CustomXssRule, MdPlugin } from './mdCard.types.ts';
3
+ export declare class MDCardService {
4
+ private xssWhiteList;
5
+ private cssWhiteList;
6
+ constructor();
7
+ private setDefaultXss;
8
+ private onIgnoreTagAttr;
9
+ getXssWhiteList(): IWhiteList;
10
+ setXssWhiteList(list: IWhiteList): void;
11
+ setCustomXssRules(rules: CustomXssRule[]): void;
12
+ setMdPlugins(plugins: MdPlugin[], mdt: any): void;
13
+ filterHtml(html: string): string;
14
+ }
@@ -0,0 +1,23 @@
1
+ import type { MermaidConfig } from './mdCard.types';
2
+ export declare class MermaidService {
3
+ private config;
4
+ private mermaidInstance;
5
+ private isLoading;
6
+ private lastValidResult;
7
+ private viewStateMap;
8
+ private containerHeight;
9
+ constructor(config?: MermaidConfig);
10
+ private loadMermaid;
11
+ renderToContainer(container: HTMLElement, code: string, theme?: 'light' | 'dark'): Promise<void>;
12
+ private initViewState;
13
+ private applyTransform;
14
+ zoomIn(container: HTMLElement): void;
15
+ zoomOut(container: HTMLElement): void;
16
+ reset(container: HTMLElement): void;
17
+ download(container: HTMLElement, filename?: string): Promise<void>;
18
+ private onSvgMouseDown;
19
+ private onSvgMouseMove;
20
+ private onSvgMouseUp;
21
+ renderMermaid(code: string, theme?: 'light' | 'dark'): Promise<string>;
22
+ setConfig(config?: MermaidConfig): void;
23
+ }