@fe-free/ai 4.1.30 → 4.1.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @fe-free/ai
2
2
 
3
+ ## 4.1.31
4
+
5
+ ### Patch Changes
6
+
7
+ - feat: ai
8
+ - @fe-free/core@4.1.31
9
+ - @fe-free/icons@4.1.31
10
+ - @fe-free/tool@4.1.31
11
+
3
12
  ## 4.1.30
4
13
 
5
14
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fe-free/ai",
3
- "version": "4.1.30",
3
+ "version": "4.1.31",
4
4
  "description": "",
5
5
  "main": "./src/index.ts",
6
6
  "author": "",
@@ -19,7 +19,7 @@
19
19
  "lodash-es": "^4.17.21",
20
20
  "uuid": "^13.0.0",
21
21
  "zustand": "^4.5.7",
22
- "@fe-free/core": "4.1.30"
22
+ "@fe-free/core": "4.1.31"
23
23
  },
24
24
  "peerDependencies": {
25
25
  "antd": "^5.27.1",
@@ -29,8 +29,8 @@
29
29
  "i18next-icu": "^2.4.1",
30
30
  "react": "^19.2.0",
31
31
  "react-i18next": "^16.4.0",
32
- "@fe-free/icons": "4.1.30",
33
- "@fe-free/tool": "4.1.30"
32
+ "@fe-free/icons": "4.1.31",
33
+ "@fe-free/tool": "4.1.31"
34
34
  },
35
35
  "scripts": {
36
36
  "test": "echo \"Error: no test specified\" && exit 1",
@@ -1,8 +1,10 @@
1
1
  import { CodeHighlighter, Mermaid } from '@ant-design/x';
2
2
  import type { ComponentProps } from '@ant-design/x-markdown';
3
+ import classNames from 'classnames';
3
4
  import { memo } from 'react';
4
5
  import { ChartBlock } from './chart';
5
6
  import { HMChartBlock } from './hm_chart';
7
+ import { PartialHtml } from './partial_html';
6
8
 
7
9
  const CodeComponent = memo((props: ComponentProps) => {
8
10
  const { className, children } = props;
@@ -23,6 +25,12 @@ const CodeComponent = memo((props: ComponentProps) => {
23
25
  return <HMChartBlock>{children}</HMChartBlock>;
24
26
  }
25
27
 
28
+ if (lang === 'pptpartialhtml') {
29
+ return (
30
+ <PartialHtml srcDoc={children} className={classNames('aspect-[16/9] w-full', className)} />
31
+ );
32
+ }
33
+
26
34
  return <CodeHighlighter lang={lang}>{children}</CodeHighlighter>;
27
35
  });
28
36
 
@@ -438,3 +438,84 @@ export const KnowledgeWithoutData: Story = {
438
438
  },
439
439
  },
440
440
  };
441
+
442
+ export const PPTPartialHtml: Story = {
443
+ args: {
444
+ content: `
445
+ # 测试
446
+
447
+ 啊沙发沙发发按时发
448
+
449
+ \`\`\`pptpartialhtml
450
+ <!DOCTYPE html>
451
+ <html>
452
+ <head>
453
+ <meta charset="utf-8">
454
+ </head>
455
+ <body>
456
+ <div>案发时发发</div>
457
+ <div>案发时发发</div>
458
+ <div>案发时发发</div>
459
+ <div>案发时发发</div>
460
+ <div>案发时发发</div>
461
+ <div>案发时发发</div>
462
+ <div>案发时发发</div>
463
+ <div>案发时发发</div>
464
+ <div>案发时发发</div>
465
+ <div>案发时发发</div>
466
+ <div>案发时发发</div>
467
+ <div>案发时发发</div>
468
+ <div>案发时发发</div>
469
+ <div>案发时发发</div>
470
+ <div>案发时发发</div>
471
+ <div>案发时发发</div>
472
+ <div>案发时发发</div>
473
+ <div>案发时发发</div>
474
+ <div>案发时发发</div>
475
+ <div>案发时发发</div>
476
+ <div>案发时发发</div>
477
+ <div>案发时发发</div>
478
+ <div>案发时发发</div>
479
+ <div>案发时发发</div>
480
+ <div>案发时发发</div>
481
+ <div>案发时发发</div>
482
+ <div>案发时发发</div>
483
+ <div>案发时发发</div>
484
+ <div>案发时发发</div>
485
+ <div>案发时发发</div>
486
+ <div>案发时发发</div>
487
+ <div>案发时发发</div>
488
+ <div>案发时发发</div>
489
+ <div>案发时发发</div>
490
+ <div>案发时发发</div>
491
+ <div>案发时发发</div>
492
+ <div>案发时发发</div>
493
+ <div>案发时发发</div>
494
+ <div>案发时发发</div>
495
+ <div>案发时发发</div>
496
+ <div>案发时发发</div>
497
+ <div>案发时发发</div>
498
+ <div>案发时发发</div>
499
+ <div>案发时发发</div>
500
+ <div>案发时发发</div>
501
+ <div>案发时发发</div>
502
+ <div>案发时发发</div>
503
+ <div>案发时发发</div>
504
+ <div>案发时发发</div>
505
+ <div>案发时发发</div>
506
+ <div>案发时发发</div>
507
+ <div>案发时发发</div>
508
+ <div>案发时发发</div>
509
+ <div>案发时发发</div>
510
+ <div>案发时发发</div>
511
+ </body>
512
+ </html>
513
+ \`\`\`
514
+
515
+ ababa
516
+ `,
517
+ onKnowledgeRef: (id?: string) => {
518
+ console.log('onKnowledgeRef', id);
519
+ },
520
+ },
521
+ };
@@ -0,0 +1,29 @@
1
+ import classNames from 'classnames';
2
+ import { useEffect, useMemo, useRef } from 'react';
3
+ import { completeHtml } from '../helper/complete';
4
+
5
+ function PartialHtml({ srcDoc: propsSrcDoc, className }: { srcDoc: string; className?: string }) {
6
+ const ref = useRef<HTMLIFrameElement>(null);
7
+
8
+ const srcDoc = useMemo(() => {
9
+ return completeHtml(propsSrcDoc);
10
+ }, [propsSrcDoc]);
11
+
12
+ useEffect(() => {
13
+ if (ref.current?.contentDocument) {
14
+ ref.current.contentDocument.open();
15
+ ref.current.contentDocument.write(srcDoc);
16
+ ref.current.contentDocument.close();
17
+ }
18
+ }, [srcDoc]);
19
+
20
+ return (
21
+ <iframe
22
+ ref={ref}
23
+ className={classNames('border border-01', className)}
24
+ sandbox="allow-scripts allow-same-origin"
25
+ />
26
+ );
27
+ }
28
+
29
+ export { PartialHtml };