@matechat/ng 0.0.1-alpha.1 → 17.1.0-alpha.1

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 (80) hide show
  1. package/README.md +207 -44
  2. package/fesm2022/matechat-ng.mjs +244 -153
  3. package/fesm2022/matechat-ng.mjs.map +1 -1
  4. package/index.d.ts +621 -3
  5. package/package.json +18 -5
  6. package/Base/base.component.d.ts +0 -11
  7. package/Bubble/avatar/avatar.component.d.ts +0 -23
  8. package/Bubble/avatar-body-icon/avatar-body-icon.component.d.ts +0 -7
  9. package/Bubble/avatar-no-body-icon/avatar-no-body-icon.component.d.ts +0 -7
  10. package/Bubble/bubble-loading/bubble-loading.component.d.ts +0 -5
  11. package/Bubble/bubble.component.d.ts +0 -26
  12. package/Bubble/bubble.module.d.ts +0 -10
  13. package/Bubble/index.d.ts +0 -6
  14. package/Input/button/button.component.d.ts +0 -31
  15. package/Input/index.d.ts +0 -2
  16. package/Input/input.component.d.ts +0 -65
  17. package/Input/input.module.d.ts +0 -11
  18. package/Input/send-icon/send-icon.component.d.ts +0 -5
  19. package/Locale/index.d.ts +0 -5
  20. package/Locale/locale.module.d.ts +0 -17
  21. package/Locale/locale.service.d.ts +0 -50
  22. package/Locale/translate.pipe.d.ts +0 -23
  23. package/MarkdownCard/code-block.component.d.ts +0 -46
  24. package/MarkdownCard/index.d.ts +0 -3
  25. package/MarkdownCard/markdown-card.component.d.ts +0 -198
  26. package/MarkdownCard/markdown-card.module.d.ts +0 -13
  27. package/components-common/Base/foundation.d.ts +0 -45
  28. package/components-common/Bubble/common/bubble-constants.d.ts +0 -4
  29. package/components-common/Bubble/common/bubble-types.d.ts +0 -12
  30. package/components-common/Bubble/foundation.d.ts +0 -9
  31. package/components-common/Input/button-foundation.d.ts +0 -15
  32. package/components-common/Input/common/types.d.ts +0 -16
  33. package/components-common/Input/foundation.d.ts +0 -20
  34. package/components-common/Locale/lang/en-us.d.ts +0 -26
  35. package/components-common/Locale/lang/zh-cn.d.ts +0 -26
  36. package/components-common/MarkdownCard/codeblock-foundation.d.ts +0 -20
  37. package/components-common/MarkdownCard/common/MDCardService.d.ts +0 -14
  38. package/components-common/MarkdownCard/common/MermaidService.d.ts +0 -23
  39. package/components-common/MarkdownCard/common/mdCard.types.d.ts +0 -56
  40. package/components-common/MarkdownCard/common/parser.d.ts +0 -150
  41. package/components-common/MarkdownCard/foundation.d.ts +0 -38
  42. package/esm2022/Base/base.component.mjs +0 -47
  43. package/esm2022/Bubble/avatar/avatar.component.mjs +0 -121
  44. package/esm2022/Bubble/avatar-body-icon/avatar-body-icon.component.mjs +0 -19
  45. package/esm2022/Bubble/avatar-no-body-icon/avatar-no-body-icon.component.mjs +0 -19
  46. package/esm2022/Bubble/bubble-loading/bubble-loading.component.mjs +0 -11
  47. package/esm2022/Bubble/bubble.component.mjs +0 -89
  48. package/esm2022/Bubble/bubble.module.mjs +0 -36
  49. package/esm2022/Bubble/index.mjs +0 -7
  50. package/esm2022/Input/button/button.component.mjs +0 -83
  51. package/esm2022/Input/index.mjs +0 -3
  52. package/esm2022/Input/input.component.mjs +0 -285
  53. package/esm2022/Input/input.module.mjs +0 -34
  54. package/esm2022/Input/send-icon/send-icon.component.mjs +0 -11
  55. package/esm2022/Locale/index.mjs +0 -6
  56. package/esm2022/Locale/locale.module.mjs +0 -39
  57. package/esm2022/Locale/locale.service.mjs +0 -140
  58. package/esm2022/Locale/translate.pipe.mjs +0 -38
  59. package/esm2022/MarkdownCard/code-block.component.mjs +0 -150
  60. package/esm2022/MarkdownCard/index.mjs +0 -4
  61. package/esm2022/MarkdownCard/markdown-card.component.mjs +0 -406
  62. package/esm2022/MarkdownCard/markdown-card.module.mjs +0 -44
  63. package/esm2022/components-common/Base/foundation.mjs +0 -66
  64. package/esm2022/components-common/Bubble/common/bubble-constants.mjs +0 -5
  65. package/esm2022/components-common/Bubble/common/bubble-types.mjs +0 -2
  66. package/esm2022/components-common/Bubble/foundation.mjs +0 -30
  67. package/esm2022/components-common/Input/button-foundation.mjs +0 -33
  68. package/esm2022/components-common/Input/common/types.mjs +0 -21
  69. package/esm2022/components-common/Input/foundation.mjs +0 -71
  70. package/esm2022/components-common/Locale/lang/en-us.mjs +0 -26
  71. package/esm2022/components-common/Locale/lang/zh-cn.mjs +0 -26
  72. package/esm2022/components-common/MarkdownCard/codeblock-foundation.mjs +0 -132
  73. package/esm2022/components-common/MarkdownCard/common/MDCardService.mjs +0 -69
  74. package/esm2022/components-common/MarkdownCard/common/MermaidService.mjs +0 -222
  75. package/esm2022/components-common/MarkdownCard/common/mdCard.types.mjs +0 -6
  76. package/esm2022/components-common/MarkdownCard/common/parser.mjs +0 -194
  77. package/esm2022/components-common/MarkdownCard/foundation.mjs +0 -84
  78. package/esm2022/matechat-ng.mjs +0 -5
  79. package/esm2022/public-api.mjs +0 -8
  80. package/public-api.d.ts +0 -4
package/index.d.ts CHANGED
@@ -1,5 +1,623 @@
1
+ import * as i0 from '@angular/core';
2
+ import { TemplateRef, QueryList, OnInit, OnChanges, SimpleChanges, EventEmitter, ElementRef, ModuleWithProviders, PipeTransform, OnDestroy, ChangeDetectorRef, ViewContainerRef, Renderer2 } from '@angular/core';
3
+ import * as i1 from '@angular/common';
4
+ import * as rxjs from 'rxjs';
5
+ import * as i2 from '@angular/forms';
6
+ import markdownit, { Token, Options, PluginSimple, PluginWithOptions, PluginWithParams } from 'markdown-it';
7
+ import { IWhiteList } from 'xss';
8
+
9
+ type BubbleVariant = 'filled' | 'none' | 'bordered';
10
+ type AvatarPosition = 'top' | 'side';
11
+ type BubbleAlign = 'left' | 'right';
12
+ interface BubbleAvatar {
13
+ name?: string;
14
+ gender?: string;
15
+ width?: number;
16
+ height?: number;
17
+ isRound?: boolean;
18
+ imgSrc?: string;
19
+ displayName?: string;
20
+ }
21
+
22
+ interface DefaultAdapter {
23
+ getProp(key: string): any;
24
+ getProps(): any;
25
+ getState(key: string): any;
26
+ getStates(): any;
27
+ setState(s: any, callback?: any): void;
28
+ getCache(c: string): any;
29
+ getCaches(): any;
30
+ setCache(key: any, value: any): void;
31
+ nextTick(cb: (...args: any) => void): void;
32
+ }
33
+ declare class BaseFoundation<T extends DefaultAdapter> {
34
+ static get cssClasses(): {};
35
+ static get strings(): {};
36
+ static get numbers(): {};
37
+ static get defaultAdapter(): {
38
+ getProp: () => void;
39
+ getProps: () => void;
40
+ getState: () => void;
41
+ getStates: () => void;
42
+ setState: () => void;
43
+ getContext: () => void;
44
+ getContexts: () => void;
45
+ getCache: () => void;
46
+ setCache: () => void;
47
+ getCaches: () => void;
48
+ stopPropagation: () => void;
49
+ };
50
+ _adapter: T;
51
+ constructor(adapter: T);
52
+ getProp(key: string): any;
53
+ getProps(): any;
54
+ getState(key: string): any;
55
+ getStates(): any;
56
+ setState(states: any, cb?: (...args: any) => void): void;
57
+ getCaches(): any;
58
+ getCache(key: string): any;
59
+ setCache(key: string, value: any): void | "";
60
+ nextTick(cb: (...args: any) => void): void;
61
+ _isInProps(key: string): boolean;
62
+ init(lifecycle?: any): void;
63
+ destroy(): void;
64
+ }
65
+
66
+ interface BubbleAdapter extends DefaultAdapter {
67
+ }
68
+ declare class BubbleFoundation extends BaseFoundation<BubbleAdapter> {
69
+ constructor(adapter: BubbleAdapter);
70
+ getBubbleClasses(): string;
71
+ getIsEmptyAvatar(avatarConfig: BubbleAvatar | undefined): boolean;
72
+ }
73
+
74
+ declare class BaseComponent<T extends BaseFoundation<DefaultAdapter>> {
75
+ foundation: T;
76
+ cache: any;
77
+ constructor();
78
+ ngOnDestroy(): void;
79
+ get adapter(): DefaultAdapter;
80
+ static ɵfac: i0.ɵɵFactoryDeclaration<BaseComponent<any>, never>;
81
+ static ɵcmp: i0.ɵɵComponentDeclaration<BaseComponent<any>, "mate-base-component", never, {}, {}, never, never, true, never>;
82
+ }
83
+
84
+ declare class BubbleComponent extends BaseComponent<BubbleFoundation> {
85
+ content: string;
86
+ loading: boolean;
87
+ align: BubbleAlign;
88
+ avatarPosition: AvatarPosition;
89
+ variant: BubbleVariant;
90
+ avatarConfig?: BubbleAvatar;
91
+ avatarTemplate: TemplateRef<any> | null;
92
+ topTemplate: TemplateRef<any> | null;
93
+ loadingTplTemplate: TemplateRef<any> | null;
94
+ bottomTemplate: TemplateRef<any> | null;
95
+ contentChildren: QueryList<any>;
96
+ get ngContentProjected(): boolean;
97
+ constructor();
98
+ ngOnInit(): void;
99
+ get adapter(): BubbleAdapter;
100
+ get bubbleClasses(): string;
101
+ get isEmptyAvatar(): boolean;
102
+ static ɵfac: i0.ɵɵFactoryDeclaration<BubbleComponent, never>;
103
+ 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>;
104
+ }
105
+
106
+ declare class BubbleLoadingComponent {
107
+ static ɵfac: i0.ɵɵFactoryDeclaration<BubbleLoadingComponent, never>;
108
+ static ɵcmp: i0.ɵɵComponentDeclaration<BubbleLoadingComponent, "mc-bubble-loading", never, {}, {}, never, never, true, never>;
109
+ }
110
+
111
+ declare class AvatarComponent implements OnInit, OnChanges {
112
+ imgSrc: string;
113
+ name: string;
114
+ width: number;
115
+ height: number;
116
+ isRound: boolean;
117
+ gender: string;
118
+ isErrorImg: boolean;
119
+ isNobody: boolean;
120
+ code: number;
121
+ fontSize: number;
122
+ nameDisplay: string;
123
+ ngOnInit(): void;
124
+ ngOnChanges(changes: SimpleChanges): void;
125
+ onErrorImg(): void;
126
+ private getBackgroundColor;
127
+ private setDisplayName;
128
+ private calcValues;
129
+ static ɵfac: i0.ɵɵFactoryDeclaration<AvatarComponent, never>;
130
+ static ɵcmp: i0.ɵɵComponentDeclaration<AvatarComponent, "mc-avatar", never, { "imgSrc": { "alias": "imgSrc"; "required": false; }; "name": { "alias": "name"; "required": false; }; "width": { "alias": "width"; "required": false; }; "height": { "alias": "height"; "required": false; }; "isRound": { "alias": "isRound"; "required": false; }; "gender": { "alias": "gender"; "required": false; }; }, {}, never, never, true, never>;
131
+ }
132
+
133
+ declare class BubbleModule {
134
+ static ɵfac: i0.ɵɵFactoryDeclaration<BubbleModule, never>;
135
+ static ɵmod: i0.ɵɵNgModuleDeclaration<BubbleModule, never, [typeof i1.CommonModule, typeof BubbleComponent, typeof BubbleLoadingComponent, typeof AvatarComponent], [typeof BubbleComponent, typeof BubbleLoadingComponent, typeof AvatarComponent]>;
136
+ static ɵinj: i0.ɵɵInjectorDeclaration<BubbleModule>;
137
+ }
138
+
139
+ declare class AvatarBodyIconComponent {
140
+ width: number;
141
+ height: number;
142
+ static ɵfac: i0.ɵɵFactoryDeclaration<AvatarBodyIconComponent, never>;
143
+ static ɵcmp: i0.ɵɵComponentDeclaration<AvatarBodyIconComponent, "mc-avatar-body-icon", never, { "width": { "alias": "width"; "required": false; }; "height": { "alias": "height"; "required": false; }; }, {}, never, never, true, never>;
144
+ }
145
+
146
+ declare class AvatarNoBodyIconComponent {
147
+ width: number;
148
+ height: number;
149
+ static ɵfac: i0.ɵɵFactoryDeclaration<AvatarNoBodyIconComponent, never>;
150
+ static ɵcmp: i0.ɵɵComponentDeclaration<AvatarNoBodyIconComponent, "mc-avatar-no-body-icon", never, { "width": { "alias": "width"; "required": false; }; "height": { "alias": "height"; "required": false; }; }, {}, never, never, true, never>;
151
+ }
152
+
153
+ declare enum DisplayType {
154
+ Simple = "simple",
155
+ Full = "full"
156
+ }
157
+ declare enum InputVariant {
158
+ Bordered = "bordered",
159
+ BorderLess = "borderless"
160
+ }
161
+ declare enum SendBtnVariant {
162
+ Simple = "simple",
163
+ Full = "full"
164
+ }
165
+ declare enum SubmitShortKey {
166
+ Enter = "enter",
167
+ ShiftEnter = "shiftEnter"
168
+ }
169
+
170
+ interface InputAdapter extends DefaultAdapter {
171
+ locale(key: string, params?: Record<string, string>): string;
172
+ emitChange(): void;
173
+ submit(inputValue: string): void;
174
+ }
175
+ declare class InputFoundation extends BaseFoundation<InputAdapter> {
176
+ constructor(adapter: InputAdapter);
177
+ getInputClasses(): {
178
+ 'mc-input': boolean;
179
+ 'mc-input-disabled': any;
180
+ 'mc-input-simple': boolean;
181
+ 'mc-input-borderless': boolean;
182
+ };
183
+ getPlaceholderText(): any;
184
+ clearInput(): void;
185
+ emitChange(): void;
186
+ submit(inputValue: string): void;
187
+ onKeydown(event: KeyboardEvent): void;
188
+ }
189
+
190
+ interface LocaleData {
191
+ [key: string]: any;
192
+ }
193
+ type LanguageCode = 'zh-cn' | 'en-us' | string;
194
+ declare class LocaleService {
195
+ private _currentLanguage;
196
+ private _localeData;
197
+ private _languageChange;
198
+ languageChange$: rxjs.Observable<string>;
199
+ constructor();
200
+ /**
201
+ * 加载默认语言包
202
+ */
203
+ private loadDefaultLocales;
204
+ /**
205
+ * 设置当前语言
206
+ */
207
+ setLanguage(language: LanguageCode): void;
208
+ /**
209
+ * 获取当前语言
210
+ */
211
+ getLanguage(): LanguageCode;
212
+ /**
213
+ * 翻译文本
214
+ * @param key 翻译键,支持嵌套路径如 'Input.send'
215
+ * @param params 替换参数
216
+ */
217
+ translate(key: string, params?: {
218
+ [key: string]: string | number;
219
+ }): string;
220
+ /**
221
+ * 添加新的语言
222
+ */
223
+ addLanguage(language: LanguageCode, localeData: LocaleData): void;
224
+ /**
225
+ * 覆盖现有语言的部分翻译
226
+ */
227
+ overrideLocale(language: LanguageCode, localeData: LocaleData): void;
228
+ /**
229
+ * 获取所有支持的语言
230
+ */
231
+ getSupportedLanguages(): LanguageCode[];
232
+ /**
233
+ * 深度合并对象
234
+ */
235
+ private deepMerge;
236
+ static ɵfac: i0.ɵɵFactoryDeclaration<LocaleService, never>;
237
+ static ɵprov: i0.ɵɵInjectableDeclaration<LocaleService>;
238
+ }
239
+
240
+ type TextareaAutoSize = {
241
+ minRows?: number;
242
+ maxRows?: number;
243
+ } | boolean;
244
+ declare const inputContextToken = "input-context";
245
+ declare class InputComponent extends BaseComponent<InputFoundation> implements OnInit {
246
+ private localeService;
247
+ value: string;
248
+ placeholder: string;
249
+ disabled: boolean;
250
+ displayType: DisplayType;
251
+ variant: InputVariant;
252
+ sendBtnVariant: SendBtnVariant;
253
+ loading: boolean;
254
+ showCount: boolean;
255
+ maxLength: number | null;
256
+ submitShortKey: SubmitShortKey | null | string;
257
+ autofocus: boolean;
258
+ autosize: TextareaAutoSize;
259
+ textareaStyle: Record<string, string>;
260
+ change: EventEmitter<string>;
261
+ submit: EventEmitter<string>;
262
+ cancel: EventEmitter<void>;
263
+ focus: EventEmitter<FocusEvent>;
264
+ blur: EventEmitter<FocusEvent>;
265
+ textareaElement: ElementRef<HTMLTextAreaElement>;
266
+ headTemplate: TemplateRef<any> | null;
267
+ prefixTemplate: TemplateRef<any> | null;
268
+ suffixTemplate: TemplateRef<any> | null;
269
+ buttonTemplate: TemplateRef<any> | null;
270
+ extraTemplate: TemplateRef<any> | null;
271
+ inputValue: string;
272
+ lock: boolean;
273
+ constructor(localeService: LocaleService);
274
+ ngOnInit(): void;
275
+ get adapter(): InputAdapter;
276
+ onChange(e: any): void;
277
+ ngOnChanges(changes: SimpleChanges): void;
278
+ get inputClasses(): Record<string, any>;
279
+ get maxlengthValue(): number | null;
280
+ onInput(): void;
281
+ onCompositionStart(): void;
282
+ onCompositionEnd(): void;
283
+ onKeydown(event: KeyboardEvent): void;
284
+ clearInput(): void;
285
+ getInput(): string;
286
+ onButtonSubmit(value: string): void;
287
+ onButtonCancel(): void;
288
+ onButtonChange(value: string): void;
289
+ ngAfterViewInit(): void;
290
+ updateTextareaStyle(): void;
291
+ private getAutosizeConfig;
292
+ private computeTextareaHeight;
293
+ get placeholderText(): string;
294
+ onFocus(event: FocusEvent): void;
295
+ onBlur(event: FocusEvent): void;
296
+ static ɵfac: i0.ɵɵFactoryDeclaration<InputComponent, never>;
297
+ 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>;
298
+ }
299
+
300
+ declare class LocaleModule {
301
+ /**
302
+ * 静态方法,用于配置模块并提供服务
303
+ * 可以在AppModule中使用LocaleModule.forRoot()来初始化
304
+ */
305
+ static forRoot(): ModuleWithProviders<LocaleModule>;
306
+ /**
307
+ * 普通导入方法,用于特性模块中导入
308
+ * 避免服务被多次实例化
309
+ */
310
+ static forChild(): ModuleWithProviders<LocaleModule>;
311
+ static ɵfac: i0.ɵɵFactoryDeclaration<LocaleModule, never>;
312
+ static ɵmod: i0.ɵɵNgModuleDeclaration<LocaleModule, never, never, never>;
313
+ static ɵinj: i0.ɵɵInjectorDeclaration<LocaleModule>;
314
+ }
315
+
1
316
  /**
2
- * Generated bundle index. Do not edit.
317
+ * 翻译管道,用于在Angular模板中直接使用翻译功能
318
+ * 用法:{{ 'Input.send' | translate }}
319
+ * 带参数:{{ 'Input.pleaseEnterPlaceholder' | translate:{ enterKey: 'Enter', shiftEnterKey: 'Shift + Enter' } }}
3
320
  */
4
- /// <amd-module name="@matechat/ng" />
5
- export * from './public-api';
321
+ declare class TranslatePipe implements PipeTransform {
322
+ private localeService;
323
+ constructor(localeService: LocaleService);
324
+ /**
325
+ * 转换方法,实现PipeTransform接口
326
+ * @param key 翻译键
327
+ * @param params 替换参数
328
+ */
329
+ transform(key: string, params?: {
330
+ [key: string]: string | number;
331
+ }): string;
332
+ static ɵfac: i0.ɵɵFactoryDeclaration<TranslatePipe, never>;
333
+ static ɵpipe: i0.ɵɵPipeDeclaration<TranslatePipe, "translate", true>;
334
+ static ɵprov: i0.ɵɵInjectableDeclaration<TranslatePipe>;
335
+ }
336
+
337
+ interface InputButtonAdapter extends DefaultAdapter {
338
+ locale(key: string, params?: Record<string, string>): string;
339
+ emitChange(): void;
340
+ }
341
+ declare class InputButtonFoundation extends BaseFoundation<InputButtonAdapter> {
342
+ constructor(adapter: InputButtonAdapter);
343
+ showClickWave(nativeElement: HTMLElement, event: MouseEvent): void;
344
+ getButtonClasses(): {
345
+ 'mc-button': boolean;
346
+ 'mc-button-loading': any;
347
+ mousedown: any;
348
+ 'mc-button-simple': boolean;
349
+ };
350
+ }
351
+
352
+ declare class ButtonComponent extends BaseComponent<InputButtonFoundation> {
353
+ private localeService;
354
+ disabled: boolean;
355
+ loading: boolean;
356
+ inputValue: string;
357
+ sendBtnVariant: SendBtnVariant;
358
+ submit: EventEmitter<string>;
359
+ cancel: EventEmitter<void>;
360
+ change: EventEmitter<string>;
361
+ buttonElement: ElementRef<HTMLButtonElement>;
362
+ isMouseDown: boolean;
363
+ showWave: boolean;
364
+ waveStyle: {
365
+ top: string;
366
+ left: string;
367
+ };
368
+ constructor(localeService: LocaleService);
369
+ get buttonClasses(): Record<string, any>;
370
+ ngOnInit(): void;
371
+ onMouseDown(): void;
372
+ onMouseUp(): void;
373
+ showClickWave(event: MouseEvent): void;
374
+ onConfirm(event: MouseEvent): void;
375
+ static ɵfac: i0.ɵɵFactoryDeclaration<ButtonComponent, never>;
376
+ static ɵcmp: i0.ɵɵComponentDeclaration<ButtonComponent, "mc-button", never, { "disabled": { "alias": "disabled"; "required": false; }; "loading": { "alias": "loading"; "required": false; }; "inputValue": { "alias": "inputValue"; "required": false; }; "sendBtnVariant": { "alias": "sendBtnVariant"; "required": false; }; }, { "submit": "submit"; "cancel": "cancel"; "change": "change"; }, never, never, true, never>;
377
+ }
378
+
379
+ declare class SendIconComponent {
380
+ static ɵfac: i0.ɵɵFactoryDeclaration<SendIconComponent, never>;
381
+ static ɵcmp: i0.ɵɵComponentDeclaration<SendIconComponent, "mc-send-icon", never, {}, {}, never, never, true, never>;
382
+ }
383
+
384
+ declare class InputModule {
385
+ static ɵfac: i0.ɵɵFactoryDeclaration<InputModule, never>;
386
+ static ɵmod: i0.ɵɵNgModuleDeclaration<InputModule, never, [typeof i1.CommonModule, typeof i2.FormsModule, typeof ButtonComponent, typeof SendIconComponent, typeof InputComponent], [typeof InputComponent]>;
387
+ static ɵinj: i0.ɵɵInjectorDeclaration<InputModule>;
388
+ }
389
+
390
+ interface MermaidConfig {
391
+ theme?: string;
392
+ }
393
+ interface CustomXssRule {
394
+ key: string;
395
+ value: string[] | null;
396
+ }
397
+ type Theme = 'light' | 'dark';
398
+ type TypingStyle = 'normal' | 'cursor' | 'color' | 'gradient';
399
+ interface MdPlugin {
400
+ plugin: PluginSimple | PluginWithOptions | PluginWithParams;
401
+ opts?: unknown;
402
+ }
403
+ interface MarkdownCardProps {
404
+ content?: string;
405
+ typing?: boolean;
406
+ enableThink?: boolean;
407
+ typingOptions?: {
408
+ step?: number;
409
+ interval?: number | [number, number];
410
+ style?: TypingStyle;
411
+ };
412
+ thinkOptions?: {
413
+ customClass?: string;
414
+ };
415
+ mdOptions?: Options;
416
+ mdPlugins?: Array<MdPlugin>;
417
+ customXssRules?: Array<CustomXssRule>;
418
+ theme?: Theme;
419
+ enableMermaid?: boolean;
420
+ mermaidConfig?: MermaidConfig;
421
+ }
422
+ interface ASTNode {
423
+ nodeType: string;
424
+ openNode: Token | null;
425
+ closeNode: Token | null;
426
+ children: (ASTNode | Token)[];
427
+ vNodeKey: string;
428
+ }
429
+
430
+ /**
431
+ * 递归查找所有层级中 className 包含 code-block-wrapper 的 DIV 节点
432
+ * @param {Array} vnodes - 待查找的 vnode 列表
433
+ * @returns {Array} 符合条件的节点列表
434
+ */
435
+ declare function findCodeBlockWrappers(vnodes: any[]): any[];
436
+
437
+ declare class MDCardService {
438
+ private xssWhiteList;
439
+ private cssWhiteList;
440
+ constructor();
441
+ private setDefaultXss;
442
+ private onIgnoreTagAttr;
443
+ getXssWhiteList(): IWhiteList;
444
+ setXssWhiteList(list: IWhiteList): void;
445
+ setCustomXssRules(rules: CustomXssRule[]): void;
446
+ setMdPlugins(plugins: MdPlugin[], mdt: any): void;
447
+ filterHtml(html: string): string;
448
+ }
449
+
450
+ interface MarkdownCardAdapter extends DefaultAdapter {
451
+ locale(key: string, params?: Record<string, string>): string;
452
+ typingStart: () => void;
453
+ typingEnd: () => void;
454
+ typingEvent: () => void;
455
+ parseContent: (content: string) => void;
456
+ }
457
+ declare class MarkdownCardFoundation extends BaseFoundation<MarkdownCardAdapter> {
458
+ constructor(adapter: MarkdownCardAdapter);
459
+ isToken: (node: ASTNode | Token) => node is Token;
460
+ typewriterEnd: () => void;
461
+ getThinkContent: (content: string, thinkOptions: any) => string;
462
+ parseTypingContent: (content: string) => string;
463
+ parseContent: () => void;
464
+ typewriterStart: () => void;
465
+ }
466
+
467
+ declare class MarkdownCardComponent extends BaseComponent<MarkdownCardFoundation> implements OnInit, OnChanges, OnDestroy {
468
+ private renderer;
469
+ cdr: ChangeDetectorRef;
470
+ content: string;
471
+ typing: boolean;
472
+ enableThink: boolean;
473
+ typingOptions: MarkdownCardProps['typingOptions'] | any;
474
+ thinkOptions: MarkdownCardProps['thinkOptions'];
475
+ mdOptions: MarkdownCardProps['mdOptions'];
476
+ mdPlugins: MarkdownCardProps['mdPlugins'];
477
+ customXssRules: MarkdownCardProps['customXssRules'];
478
+ theme: 'light' | 'dark' | any;
479
+ enableMermaid: boolean;
480
+ incrementalDom: boolean;
481
+ mermaidConfig: MarkdownCardProps['mermaidConfig'];
482
+ actionsTemplate: TemplateRef<any> | null;
483
+ headerTemplate: TemplateRef<any> | null;
484
+ contentTemplate: TemplateRef<any> | null;
485
+ private codeBlockComponentsCache;
486
+ afterMdtInit: EventEmitter<markdownit>;
487
+ mdRenderChange: EventEmitter<string>;
488
+ typingStart: EventEmitter<void>;
489
+ typingEvent: EventEmitter<void>;
490
+ typingEnd: EventEmitter<void>;
491
+ markdownContainer: ViewContainerRef;
492
+ private mdt;
493
+ typingIndex: number;
494
+ isTyping: boolean;
495
+ timer: number | null;
496
+ parser: {
497
+ isSelfClosingTag: (token: Token) => boolean;
498
+ isClosingTag: (openToken: Token, closeToken: Token) => boolean;
499
+ tokensToAst: (tokens: Token[]) => ASTNode[];
500
+ genTreeNode: (node: Token | null) => ASTNode;
501
+ matchHtmlToken: (token: Token, stack: Token[]) => void;
502
+ isValidTagName: (tagName: string | undefined) => boolean;
503
+ findCodeBlockWrappers: typeof findCodeBlockWrappers;
504
+ };
505
+ mdCardService: MDCardService;
506
+ constructor(renderer: Renderer2, cdr: ChangeDetectorRef);
507
+ ngOnInit(): void;
508
+ get adapter(): MarkdownCardAdapter;
509
+ ngOnChanges(changes: SimpleChanges): void;
510
+ contentChange(change: any): void;
511
+ private parseContent;
512
+ private renderContent;
513
+ private getEmptyCodeBlock;
514
+ private astToVnodes;
515
+ private processASTNode;
516
+ private processHTMLNode;
517
+ private renderContentNoDiff;
518
+ private processInlineToken;
519
+ private processFenceNode;
520
+ private processASTNodeInternal;
521
+ private processToken;
522
+ private createCodeBlock;
523
+ private typewriterStart;
524
+ clearCodeBlockCache(): void;
525
+ ngOnDestroy(): void;
526
+ static ɵfac: i0.ɵɵFactoryDeclaration<MarkdownCardComponent, never>;
527
+ 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; }; "incrementalDom": { "alias": "incrementalDom"; "required": false; }; "mermaidConfig": { "alias": "mermaidConfig"; "required": false; }; "actionsTemplate": { "alias": "actionsTemplate"; "required": false; }; "headerTemplate": { "alias": "headerTemplate"; "required": false; }; "contentTemplate": { "alias": "contentTemplate"; "required": false; }; }, { "afterMdtInit": "afterMdtInit"; "mdRenderChange": "mdRenderChange"; "typingStart": "typingStart"; "typingEvent": "typingEvent"; "typingEnd": "typingEnd"; }, never, ["*"], false, never>;
528
+ }
529
+
530
+ declare class MermaidService {
531
+ private config;
532
+ private mermaidInstance;
533
+ private isLoading;
534
+ private lastValidResult;
535
+ private viewStateMap;
536
+ private containerHeight;
537
+ constructor(config?: MermaidConfig);
538
+ private loadMermaid;
539
+ renderToContainer(container: HTMLElement, code: string, theme?: 'light' | 'dark'): Promise<void>;
540
+ private initViewState;
541
+ private applyTransform;
542
+ zoomIn(container: HTMLElement): void;
543
+ zoomOut(container: HTMLElement): void;
544
+ reset(container: HTMLElement): void;
545
+ download(container: HTMLElement, filename?: string): Promise<void>;
546
+ private onSvgMouseDown;
547
+ private onSvgMouseMove;
548
+ private onSvgMouseUp;
549
+ renderMermaid(code: string, theme?: 'light' | 'dark'): Promise<string>;
550
+ setConfig(config?: MermaidConfig): void;
551
+ }
552
+
553
+ interface CodeBlockAdapter extends DefaultAdapter {
554
+ getContainer(): HTMLElement | null;
555
+ highlightCodeChange(code: string, language: string): void;
556
+ }
557
+ declare class CodeBlockFoundation extends BaseFoundation<CodeBlockAdapter> {
558
+ mermaidService?: MermaidService;
559
+ mdCardService: MDCardService;
560
+ constructor(adapter: CodeBlockAdapter);
561
+ toggleExpand: () => void;
562
+ zoomOut: () => void;
563
+ zoomIn: () => void;
564
+ checkIsMermaid: () => any;
565
+ download: () => void;
566
+ handleCopySuccess: () => void;
567
+ copyCodeInternal(): void;
568
+ updateHighlightedCode: () => void;
569
+ renderMermaid: () => Promise<void>;
570
+ }
571
+
572
+ declare class CodeBlockComponent extends BaseComponent<CodeBlockFoundation> implements OnInit, OnChanges {
573
+ private cdr;
574
+ code: string;
575
+ language: string;
576
+ blockIndex: number;
577
+ theme: 'light' | 'dark';
578
+ enableMermaid: boolean;
579
+ mermaidConfig: MermaidConfig;
580
+ contentTemplate: TemplateRef<any> | null;
581
+ headerTemplate: TemplateRef<any> | null;
582
+ actionsTemplate: TemplateRef<any> | null;
583
+ rootRef: ElementRef;
584
+ mermaidContentRef: ElementRef;
585
+ codeElementRef: ElementRef;
586
+ codeElementTemplates: QueryList<ElementRef>;
587
+ expanded: boolean;
588
+ copied: boolean;
589
+ mermaidContent: string;
590
+ private _showMermaidDiagram;
591
+ get showMermaidDiagram(): boolean;
592
+ set showMermaidDiagram(value: boolean);
593
+ highlightedCode: string;
594
+ isMermaid: boolean;
595
+ private copySubject;
596
+ constructor(cdr: ChangeDetectorRef);
597
+ get adapter(): CodeBlockAdapter;
598
+ switchShowMermaid(show: boolean): void;
599
+ ngOnInit(): void;
600
+ ngAfterViewInit(): void;
601
+ ngOnChanges(changes: SimpleChanges): void;
602
+ private checkIsMermaid;
603
+ private updateHighlightedCode;
604
+ zoomIn(): void;
605
+ zoomOut(): void;
606
+ download(): void;
607
+ renderMermaid(): Promise<void>;
608
+ toggleExpand(): void;
609
+ copyCode(): void;
610
+ copyCodeInternal(): void;
611
+ static ɵfac: i0.ɵɵFactoryDeclaration<CodeBlockComponent, never>;
612
+ 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>;
613
+ }
614
+
615
+ declare class MarkdownCardModule {
616
+ static forRoot(): ModuleWithProviders<MarkdownCardModule>;
617
+ static ɵfac: i0.ɵɵFactoryDeclaration<MarkdownCardModule, never>;
618
+ static ɵmod: i0.ɵɵNgModuleDeclaration<MarkdownCardModule, [typeof CodeBlockComponent, typeof MarkdownCardComponent], [typeof i1.CommonModule, typeof TranslatePipe, typeof LocaleModule], [typeof CodeBlockComponent, typeof MarkdownCardComponent]>;
619
+ static ɵinj: i0.ɵɵInjectorDeclaration<MarkdownCardModule>;
620
+ }
621
+
622
+ export { AvatarBodyIconComponent, AvatarComponent, AvatarNoBodyIconComponent, BubbleComponent, BubbleLoadingComponent, BubbleModule, CodeBlockComponent, InputComponent, InputModule, LocaleModule, LocaleService, MarkdownCardComponent, MarkdownCardModule, TranslatePipe, inputContextToken };
623
+ export type { LanguageCode, LocaleData, TextareaAutoSize };
package/package.json CHANGED
@@ -1,18 +1,33 @@
1
1
  {
2
2
  "name": "@matechat/ng",
3
- "version": "0.0.1-alpha.1",
3
+ "version": "17.1.0-alpha.1",
4
4
  "license": "MIT",
5
5
  "description": "前端智能化场景解决方案UI库,轻松构建你的AI应用。",
6
+ "keywords": [
7
+ "AI",
8
+ "GPT",
9
+ "Chat",
10
+ "angular-components",
11
+ "angular",
12
+ "devui"
13
+ ],
14
+ "homepage": "https://matechat.gitcode.com/",
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git@gitcode.com:DevCloudFE/MateChat.git"
18
+ },
6
19
  "peerDependencies": {
7
20
  "@angular/common": "^17.3.0",
8
- "@angular/core": "^17.3.0"
21
+ "@angular/core": "^17.3.0",
22
+ "mermaid": "^11.10.1"
9
23
  },
10
24
  "dependencies": {
11
25
  "tslib": "^2.3.0",
12
26
  "devui-theme": "^0.0.7",
13
27
  "highlight.js": "^11.11.0",
14
28
  "markdown-it": "^12.2.0",
15
- "diff-dom": "^5.2.1"
29
+ "morphdom": "^2.7.4",
30
+ "xss": "^1.0.15"
16
31
  },
17
32
  "publishConfig": {
18
33
  "access": "public"
@@ -26,8 +41,6 @@
26
41
  },
27
42
  ".": {
28
43
  "types": "./index.d.ts",
29
- "esm2022": "./esm2022/matechat-ng.mjs",
30
- "esm": "./esm2022/matechat-ng.mjs",
31
44
  "default": "./fesm2022/matechat-ng.mjs"
32
45
  }
33
46
  }
@@ -1,11 +0,0 @@
1
- import { DefaultAdapter } from '../components-common/Base/foundation';
2
- import * as i0 from "@angular/core";
3
- export default class BaseComponent {
4
- foundation: any;
5
- cache: any;
6
- constructor();
7
- ngOnDestroy(): void;
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>;
11
- }