@h-ai/ui 0.1.0-alpha.67 → 0.1.0-alpha.68
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/README.en.md +31 -5
- package/README.ja.md +31 -5
- package/README.md +64 -38
- package/dist/components/compounds/Accordion.svelte +24 -0
- package/dist/components/compounds/Accordion.svelte.d.ts +34 -0
- package/dist/components/compounds/ActionSheet.svelte +24 -0
- package/dist/components/compounds/ActionSheet.svelte.d.ts +38 -0
- package/dist/components/compounds/Alert.svelte +15 -4
- package/dist/components/compounds/Alert.svelte.d.ts +10 -0
- package/dist/components/compounds/AppBar.svelte +24 -0
- package/dist/components/compounds/AppBar.svelte.d.ts +33 -0
- package/dist/components/compounds/BottomNav.svelte +37 -0
- package/dist/components/compounds/BottomNav.svelte.d.ts +43 -0
- package/dist/components/compounds/Breadcrumb.svelte +11 -0
- package/dist/components/compounds/Breadcrumb.svelte.d.ts +20 -0
- package/dist/components/compounds/Calendar.svelte +20 -6
- package/dist/components/compounds/Calendar.svelte.d.ts +20 -6
- package/dist/components/compounds/Card.svelte +10 -0
- package/dist/components/compounds/Card.svelte.d.ts +10 -0
- package/dist/components/compounds/Combobox.svelte +35 -18
- package/dist/components/compounds/Combobox.svelte.d.ts +35 -18
- package/dist/components/compounds/Confirm.svelte +11 -0
- package/dist/components/compounds/Confirm.svelte.d.ts +21 -0
- package/dist/components/compounds/DataTable.svelte +40 -17
- package/dist/components/compounds/DataTable.svelte.d.ts +9 -13
- package/dist/components/compounds/DatePicker.svelte +20 -6
- package/dist/components/compounds/DatePicker.svelte.d.ts +20 -6
- package/dist/components/compounds/Drawer.svelte +11 -0
- package/dist/components/compounds/Drawer.svelte.d.ts +21 -0
- package/dist/components/compounds/Dropdown.svelte +10 -0
- package/dist/components/compounds/Dropdown.svelte.d.ts +10 -0
- package/dist/components/compounds/Empty.svelte +16 -5
- package/dist/components/compounds/Empty.svelte.d.ts +20 -0
- package/dist/components/compounds/Form.svelte +37 -2
- package/dist/components/compounds/Form.svelte.d.ts +20 -0
- package/dist/components/compounds/FormField.svelte +11 -0
- package/dist/components/compounds/FormField.svelte.d.ts +20 -0
- package/dist/components/compounds/FormLayout.svelte +13 -1
- package/dist/components/compounds/FormLayout.svelte.d.ts +13 -0
- package/dist/components/compounds/InfiniteScroll.svelte +24 -0
- package/dist/components/compounds/InfiniteScroll.svelte.d.ts +34 -0
- package/dist/components/compounds/MessageBoxContainer.svelte +11 -0
- package/dist/components/compounds/MessageBoxContainer.svelte.d.ts +21 -0
- package/dist/components/compounds/MessageBoxDialog.svelte +14 -0
- package/dist/components/compounds/MessageBoxDialog.svelte.d.ts +21 -0
- package/dist/components/compounds/MessageContainer.svelte +11 -0
- package/dist/components/compounds/MessageContainer.svelte.d.ts +21 -0
- package/dist/components/compounds/Modal.svelte +10 -0
- package/dist/components/compounds/Modal.svelte.d.ts +10 -0
- package/dist/components/compounds/PageHeader.svelte +21 -8
- package/dist/components/compounds/PageHeader.svelte.d.ts +21 -8
- package/dist/components/compounds/Pagination.svelte +34 -8
- package/dist/components/compounds/Pagination.svelte.d.ts +20 -0
- package/dist/components/compounds/Popover.svelte +11 -0
- package/dist/components/compounds/Popover.svelte.d.ts +20 -0
- package/dist/components/compounds/PullRefresh.svelte +24 -0
- package/dist/components/compounds/PullRefresh.svelte.d.ts +32 -0
- package/dist/components/compounds/Result.svelte +11 -0
- package/dist/components/compounds/Result.svelte.d.ts +20 -0
- package/dist/components/compounds/SafeArea.svelte +24 -0
- package/dist/components/compounds/SafeArea.svelte.d.ts +32 -0
- package/dist/components/compounds/Skeleton.svelte +10 -0
- package/dist/components/compounds/Skeleton.svelte.d.ts +10 -0
- package/dist/components/compounds/Steps.svelte +11 -0
- package/dist/components/compounds/Steps.svelte.d.ts +20 -0
- package/dist/components/compounds/SwipeCell.svelte +24 -0
- package/dist/components/compounds/SwipeCell.svelte.d.ts +37 -0
- package/dist/components/compounds/TableToolbar.svelte +66 -28
- package/dist/components/compounds/TableToolbar.svelte.d.ts +29 -19
- package/dist/components/compounds/Tabs.svelte +58 -10
- package/dist/components/compounds/Tabs.svelte.d.ts +10 -0
- package/dist/components/compounds/TagInput.svelte +11 -0
- package/dist/components/compounds/TagInput.svelte.d.ts +20 -0
- package/dist/components/compounds/Timeline.svelte +24 -0
- package/dist/components/compounds/Timeline.svelte.d.ts +34 -0
- package/dist/components/compounds/ToastContainer.svelte +11 -0
- package/dist/components/compounds/ToastContainer.svelte.d.ts +26 -0
- package/dist/components/compounds/Tooltip.svelte +11 -0
- package/dist/components/compounds/Tooltip.svelte.d.ts +22 -0
- package/dist/components/compounds/accordion-types.d.ts +10 -1
- package/dist/components/compounds/action-sheet-types.d.ts +9 -0
- package/dist/components/compounds/bottom-nav-types.d.ts +9 -0
- package/dist/components/compounds/swipe-cell-types.d.ts +9 -0
- package/dist/components/compounds/timeline-types.d.ts +9 -0
- package/dist/components/control-size.d.ts +17 -0
- package/dist/components/control-size.js +8 -0
- package/dist/components/primitives/Avatar.svelte +10 -0
- package/dist/components/primitives/Avatar.svelte.d.ts +10 -0
- package/dist/components/primitives/Badge.svelte +10 -0
- package/dist/components/primitives/Badge.svelte.d.ts +10 -0
- package/dist/components/primitives/BareButton.svelte +11 -0
- package/dist/components/primitives/BareButton.svelte.d.ts +20 -0
- package/dist/components/primitives/BareInput.svelte +11 -0
- package/dist/components/primitives/BareInput.svelte.d.ts +20 -0
- package/dist/components/primitives/Button.svelte +10 -0
- package/dist/components/primitives/Button.svelte.d.ts +10 -0
- package/dist/components/primitives/Checkbox.svelte +11 -0
- package/dist/components/primitives/Checkbox.svelte.d.ts +20 -0
- package/dist/components/primitives/IconButton.svelte +11 -0
- package/dist/components/primitives/IconButton.svelte.d.ts +20 -0
- package/dist/components/primitives/Input.svelte +10 -0
- package/dist/components/primitives/Input.svelte.d.ts +10 -0
- package/dist/components/primitives/Progress.svelte +11 -0
- package/dist/components/primitives/Progress.svelte.d.ts +20 -0
- package/dist/components/primitives/Radio.svelte +11 -0
- package/dist/components/primitives/Radio.svelte.d.ts +20 -0
- package/dist/components/primitives/Range.svelte +24 -0
- package/dist/components/primitives/Range.svelte.d.ts +34 -0
- package/dist/components/primitives/Rating.svelte +24 -0
- package/dist/components/primitives/Rating.svelte.d.ts +34 -0
- package/dist/components/primitives/Select.svelte +11 -0
- package/dist/components/primitives/Select.svelte.d.ts +21 -0
- package/dist/components/primitives/Spinner.svelte +11 -0
- package/dist/components/primitives/Spinner.svelte.d.ts +20 -0
- package/dist/components/primitives/Switch.svelte +11 -0
- package/dist/components/primitives/Switch.svelte.d.ts +20 -0
- package/dist/components/primitives/Tag.svelte +11 -0
- package/dist/components/primitives/Tag.svelte.d.ts +20 -0
- package/dist/components/primitives/Textarea.svelte +11 -0
- package/dist/components/primitives/Textarea.svelte.d.ts +21 -0
- package/dist/components/primitives/ToggleCheckbox.svelte +11 -0
- package/dist/components/primitives/ToggleCheckbox.svelte.d.ts +20 -0
- package/dist/components/primitives/ToggleInput.svelte +11 -0
- package/dist/components/primitives/ToggleInput.svelte.d.ts +20 -0
- package/dist/components/primitives/ToggleRadio.svelte +11 -0
- package/dist/components/primitives/ToggleRadio.svelte.d.ts +20 -0
- package/dist/components/scenes/ai/AiDocumentDownloadMenu.svelte +27 -0
- package/dist/components/scenes/ai/AiDocumentDownloadMenu.svelte.d.ts +27 -0
- package/dist/components/scenes/ai/AiDocumentEditor.svelte +79 -0
- package/dist/components/scenes/ai/AiDocumentEditor.svelte.d.ts +23 -0
- package/dist/components/scenes/ai/MarkdownRenderer.svelte +11 -0
- package/dist/components/scenes/ai/MarkdownRenderer.svelte.d.ts +28 -0
- package/dist/components/scenes/ai/code-preview.d.ts +28 -0
- package/dist/components/scenes/ai/code-preview.js +20 -0
- package/dist/components/scenes/ai/document-download.d.ts +52 -0
- package/dist/components/scenes/ai/document-download.js +30 -2
- package/dist/components/scenes/ai/document-parse.d.ts +71 -14
- package/dist/components/scenes/ai/document-parse.js +19 -9
- package/dist/components/scenes/ai/document-types.d.ts +222 -88
- package/dist/components/scenes/ai/editor-markdown-extensions.d.ts +16 -0
- package/dist/components/scenes/ai/editor-markdown-extensions.js +16 -0
- package/dist/components/scenes/ai/highlight.d.ts +11 -0
- package/dist/components/scenes/ai/highlight.js +11 -0
- package/dist/components/scenes/ai/markdown-parse.d.ts +8 -2
- package/dist/components/scenes/ai/markdown-parse.js +2 -2
- package/dist/components/scenes/ai/mermaid-host-sync.d.ts +38 -0
- package/dist/components/scenes/ai/mermaid-host-sync.js +30 -0
- package/dist/components/scenes/ai/mermaid-render.d.ts +23 -0
- package/dist/components/scenes/ai/mermaid-render.js +23 -0
- package/dist/components/scenes/ai/safe-html.d.ts +54 -6
- package/dist/components/scenes/ai/safe-html.js +54 -6
- package/dist/components/scenes/ai/table/AiTableEditor.svelte +48 -0
- package/dist/components/scenes/ai/table/AiTableEditor.svelte.d.ts +24 -0
- package/dist/components/scenes/ai/table/table-types.d.ts +79 -0
- package/dist/components/scenes/app/FeedbackModal.svelte +45 -5
- package/dist/components/scenes/app/FeedbackModal.svelte.d.ts +45 -5
- package/dist/components/scenes/app/LanguageSwitch.svelte +29 -19
- package/dist/components/scenes/app/LanguageSwitch.svelte.d.ts +28 -19
- package/dist/components/scenes/app/SettingsLayout.svelte +21 -9
- package/dist/components/scenes/app/SettingsLayout.svelte.d.ts +21 -9
- package/dist/components/scenes/app/SettingsModal.svelte +23 -0
- package/dist/components/scenes/app/SettingsModal.svelte.d.ts +23 -0
- package/dist/components/scenes/app/ThemeColorPicker.svelte +31 -0
- package/dist/components/scenes/app/ThemeColorPicker.svelte.d.ts +31 -0
- package/dist/components/scenes/app/ThemeSelector.svelte +21 -6
- package/dist/components/scenes/app/ThemeSelector.svelte.d.ts +21 -6
- package/dist/components/scenes/app/ThemeToggle.svelte +21 -4
- package/dist/components/scenes/app/ThemeToggle.svelte.d.ts +21 -4
- package/dist/components/scenes/app/index.d.ts +1 -1
- package/dist/components/scenes/app/index.js +1 -1
- package/dist/components/scenes/charts/Chart.svelte +11 -0
- package/dist/components/scenes/charts/Chart.svelte.d.ts +20 -0
- package/dist/components/scenes/charts/chart-theme.d.ts +25 -1
- package/dist/components/scenes/charts/chart-theme.js +25 -1
- package/dist/components/scenes/charts/chart-types.d.ts +83 -7
- package/dist/components/scenes/charts/renderers/LineChart.svelte +53 -0
- package/dist/components/scenes/charts/renderers/LineChart.svelte.d.ts +13 -0
- package/dist/components/scenes/crud/CrudDeleteConfirm.svelte +10 -0
- package/dist/components/scenes/crud/CrudDeleteConfirm.svelte.d.ts +10 -0
- package/dist/components/scenes/crud/CrudDetailDrawer.svelte +8 -0
- package/dist/components/scenes/crud/CrudDetailDrawer.svelte.d.ts +8 -0
- package/dist/components/scenes/crud/CrudDetailPanel.svelte +18 -0
- package/dist/components/scenes/crud/CrudDetailPanel.svelte.d.ts +18 -0
- package/dist/components/scenes/crud/CrudEditPanel.svelte +10 -0
- package/dist/components/scenes/crud/CrudEditPanel.svelte.d.ts +10 -0
- package/dist/components/scenes/crud/CrudFilterBar.svelte +18 -0
- package/dist/components/scenes/crud/CrudFilterBar.svelte.d.ts +18 -0
- package/dist/components/scenes/crud/CrudPage.svelte +37 -5
- package/dist/components/scenes/crud/CrudPage.svelte.d.ts +35 -3
- package/dist/components/scenes/crud/crud-controller.svelte.d.ts +142 -23
- package/dist/components/scenes/crud/crud-controller.svelte.js +22 -11
- package/dist/components/scenes/crud/crud-form-validation.d.ts +12 -0
- package/dist/components/scenes/crud/crud-form-validation.js +12 -0
- package/dist/components/scenes/crud/crud-types.d.ts +79 -8
- package/dist/components/scenes/crud/nav-adapter.d.ts +14 -0
- package/dist/components/scenes/crud/nav-adapter.js +8 -0
- package/dist/components/scenes/crypto/EncryptedInput.svelte +24 -0
- package/dist/components/scenes/crypto/EncryptedInput.svelte.d.ts +34 -0
- package/dist/components/scenes/crypto/HashDisplay.svelte +11 -0
- package/dist/components/scenes/crypto/HashDisplay.svelte.d.ts +21 -0
- package/dist/components/scenes/crypto/SignatureDisplay.svelte +11 -0
- package/dist/components/scenes/crypto/SignatureDisplay.svelte.d.ts +21 -0
- package/dist/components/scenes/error/ErrorPage.svelte +8 -1
- package/dist/components/scenes/error/ErrorPage.svelte.d.ts +8 -1
- package/dist/components/scenes/error/error-presets.d.ts +40 -4
- package/dist/components/scenes/error/error-presets.js +22 -2
- package/dist/components/scenes/guide/GuideHost.svelte +27 -0
- package/dist/components/scenes/guide/GuideHost.svelte.d.ts +27 -0
- package/dist/components/scenes/guide/HelpCenter.svelte +27 -0
- package/dist/components/scenes/guide/HelpCenter.svelte.d.ts +27 -0
- package/dist/components/scenes/iam/AuthPanel.svelte +26 -2
- package/dist/components/scenes/iam/AuthPanel.svelte.d.ts +25 -0
- package/dist/components/scenes/iam/AuthShell.svelte +8 -3
- package/dist/components/scenes/iam/AuthShell.svelte.d.ts +8 -3
- package/dist/components/scenes/iam/ChangePasswordForm.svelte +10 -0
- package/dist/components/scenes/iam/ChangePasswordForm.svelte.d.ts +10 -0
- package/dist/components/scenes/iam/ForgotPasswordForm.svelte +11 -0
- package/dist/components/scenes/iam/ForgotPasswordForm.svelte.d.ts +21 -0
- package/dist/components/scenes/iam/LoginForm.svelte +24 -31
- package/dist/components/scenes/iam/LoginForm.svelte.d.ts +10 -0
- package/dist/components/scenes/iam/PasswordInput.svelte +23 -0
- package/dist/components/scenes/iam/PasswordInput.svelte.d.ts +23 -0
- package/dist/components/scenes/iam/PermGuard.svelte +21 -11
- package/dist/components/scenes/iam/PermGuard.svelte.d.ts +30 -0
- package/dist/components/scenes/iam/RegisterForm.svelte +10 -0
- package/dist/components/scenes/iam/RegisterForm.svelte.d.ts +10 -0
- package/dist/components/scenes/iam/ResetPasswordForm.svelte +10 -0
- package/dist/components/scenes/iam/ResetPasswordForm.svelte.d.ts +10 -0
- package/dist/components/scenes/iam/UserProfile.svelte +11 -0
- package/dist/components/scenes/iam/UserProfile.svelte.d.ts +21 -0
- package/dist/components/scenes/iam/auth-error-message.d.ts +10 -0
- package/dist/components/scenes/iam/auth-error-message.js +10 -0
- package/dist/components/scenes/iam/password-utils.d.ts +39 -1
- package/dist/components/scenes/iam/password-utils.js +39 -1
- package/dist/components/scenes/iam/permission-context.svelte.d.ts +33 -23
- package/dist/components/scenes/iam/permission-context.svelte.js +20 -22
- package/dist/components/scenes/storage/AvatarUpload.svelte +11 -0
- package/dist/components/scenes/storage/AvatarUpload.svelte.d.ts +20 -0
- package/dist/components/scenes/storage/FileList.svelte +13 -2
- package/dist/components/scenes/storage/FileList.svelte.d.ts +20 -0
- package/dist/components/scenes/storage/FileUpload.svelte +37 -2
- package/dist/components/scenes/storage/FileUpload.svelte.d.ts +21 -0
- package/dist/components/scenes/storage/ImageUpload.svelte +11 -0
- package/dist/components/scenes/storage/ImageUpload.svelte.d.ts +21 -0
- package/dist/components/scenes/types.d.ts +352 -11
- package/dist/guide-storage.d.ts +13 -1
- package/dist/guide-storage.js +13 -1
- package/dist/guide-types.d.ts +67 -2
- package/dist/guide.svelte.d.ts +22 -1
- package/dist/guide.svelte.js +22 -1
- package/dist/i18n.svelte.d.ts +64 -3
- package/dist/i18n.svelte.js +99 -18
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -2
- package/dist/internal/browser-safety.d.ts +51 -2
- package/dist/internal/browser-safety.js +45 -7
- package/dist/internal/form-context.d.ts +73 -0
- package/dist/internal/form-context.js +57 -0
- package/dist/internal/form-validation.svelte.d.ts +42 -0
- package/dist/internal/form-validation.svelte.js +26 -0
- package/dist/internal/icon-safety.d.ts +7 -0
- package/dist/internal/icon-safety.js +7 -0
- package/dist/internal/locale.d.ts +19 -0
- package/dist/internal/locale.js +21 -0
- package/dist/message.svelte.d.ts +90 -0
- package/dist/message.svelte.js +84 -0
- package/dist/messagebox.svelte.d.ts +61 -13
- package/dist/messagebox.svelte.js +55 -13
- package/dist/messages/en-US.json +6 -1
- package/dist/messages/ja-JP.json +389 -0
- package/dist/messages/zh-CN.json +6 -1
- package/dist/messages.d.ts +24 -3
- package/dist/messages.js +18 -3
- package/dist/styles/design-tokens.css +4 -2
- package/dist/styles/global.css +28 -8
- package/dist/styles/theme.css +2 -0
- package/dist/theme-config.d.ts +173 -0
- package/dist/theme-config.js +143 -0
- package/dist/toast.svelte.d.ts +114 -4
- package/dist/toast.svelte.js +108 -4
- package/dist/types.d.ts +526 -9
- package/dist/utils/platform.svelte.d.ts +28 -15
- package/dist/utils/platform.svelte.js +19 -14
- package/dist/utils.d.ts +102 -0
- package/dist/utils.js +93 -0
- package/package.json +66 -6
|
@@ -1,38 +1,76 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @h-ai/ui — Markdown
|
|
2
|
+
* @h-ai/ui — Markdown 文档解析工具
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* 为文档模式提取安全 HTML、目录和代码块元信息。
|
|
5
5
|
*/
|
|
6
6
|
import type { MarkdownCodeBlockItem, MarkdownOutlineItem } from './document-types.js';
|
|
7
|
+
/**
|
|
8
|
+
* 安全 Markdown 文档解析选项;运行按钮不等于允许执行代码。
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* import type { MarkdownDocumentParseOptions } from '@h-ai/ui'
|
|
13
|
+
* const example: MarkdownDocumentParseOptions = { enableHighlight: true, allowHtmlTags: false, showRunButton: false, breaks: true }
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
7
16
|
export interface MarkdownDocumentParseOptions {
|
|
8
|
-
/**
|
|
17
|
+
/** 是否启用代码块语法高亮。 */
|
|
9
18
|
enableHighlight?: boolean;
|
|
10
|
-
/**
|
|
19
|
+
/** 是否渲染代码块复制按钮。 */
|
|
11
20
|
showCopyButton?: boolean;
|
|
12
|
-
/**
|
|
21
|
+
/** 是否渲染运行按钮和预览槽;实际运行由宿主授权。 */
|
|
13
22
|
showRunButton?: boolean;
|
|
14
|
-
/**
|
|
23
|
+
/** 是否渲染代码块头部的代码/预览切换。 */
|
|
15
24
|
showCodePreviewToggle?: boolean;
|
|
16
|
-
/**
|
|
25
|
+
/** 启用预览切换时的代码页签文案。 */
|
|
17
26
|
codeViewCodeLabel?: string;
|
|
18
|
-
/**
|
|
27
|
+
/** 启用预览切换时的预览页签文案。 */
|
|
19
28
|
codeViewPreviewLabel?: string;
|
|
20
|
-
/**
|
|
29
|
+
/** 代码块头部语言标签旁的提示文案。 */
|
|
21
30
|
codePreviewHint?: string;
|
|
22
|
-
/**
|
|
31
|
+
/** 是否将普通换行转换成 br。 */
|
|
23
32
|
breaks?: boolean;
|
|
24
|
-
/**
|
|
33
|
+
/** 是否按安全白名单解析原始 HTML 标签。 */
|
|
25
34
|
allowHtmlTags?: boolean;
|
|
26
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* 一次文档解析生成的安全渲染块、目录和原始代码块信息。
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* import { renderMarkdownDocument } from '@h-ai/ui'
|
|
42
|
+
* import type { MarkdownRenderResult } from '@h-ai/ui'
|
|
43
|
+
* const result: MarkdownRenderResult = renderMarkdownDocument('# 简介\n正文')
|
|
44
|
+
* const headings = result.outline
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
27
47
|
export interface MarkdownRenderResult {
|
|
28
|
-
/**
|
|
48
|
+
/** 供目录导航使用的标题条目。 */
|
|
29
49
|
outline: MarkdownOutlineItem[];
|
|
30
|
-
/**
|
|
50
|
+
/** 供运行/复制功能使用的代码块元信息。 */
|
|
31
51
|
codeBlocks: MarkdownCodeBlockItem[];
|
|
32
52
|
/** 阅读态使用的稳定块列表,避免流式更新销毁重型块 DOM。 */
|
|
33
53
|
blocks: MarkdownDocumentBlock[];
|
|
34
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* 文档渲染块的可辨识联合;HTML 块和 Mermaid 源码块分开更新。
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```ts
|
|
60
|
+
* import type { MarkdownDocumentBlock } from '@h-ai/ui'
|
|
61
|
+
* const example: MarkdownDocumentBlock = { kind: 'html', id: 'paragraph-1', html: '<p>正文</p>' }
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
35
64
|
export type MarkdownDocumentBlock = MarkdownDocumentHtmlBlock | MarkdownDocumentMermaidBlock;
|
|
65
|
+
/**
|
|
66
|
+
* 已经过安全策略处理的 Markdown HTML 块;不要填入未消毒输入。
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```ts
|
|
70
|
+
* import type { MarkdownDocumentHtmlBlock } from '@h-ai/ui'
|
|
71
|
+
* const example: MarkdownDocumentHtmlBlock = { kind: 'html', id: 'paragraph-1', html: '<p>正文</p>' }
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
36
74
|
export interface MarkdownDocumentHtmlBlock {
|
|
37
75
|
/** 普通 Markdown HTML 块。 */
|
|
38
76
|
kind: 'html';
|
|
@@ -41,6 +79,15 @@ export interface MarkdownDocumentHtmlBlock {
|
|
|
41
79
|
/** 已按现有安全策略渲染后的 HTML。 */
|
|
42
80
|
html: string;
|
|
43
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* 完整 Mermaid 块的源码与签名,等待异步严格模式渲染。
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```ts
|
|
87
|
+
* import type { MarkdownDocumentMermaidBlock } from '@h-ai/ui'
|
|
88
|
+
* const example: MarkdownDocumentMermaidBlock = { kind: 'mermaid', id: 'diagram-1', codeBlockId: 'code-1', code: 'graph TD; A-->B', language: 'mermaid', signature: JSON.stringify(['diagram-1', 'graph TD; A-->B']) }
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
44
91
|
export interface MarkdownDocumentMermaidBlock {
|
|
45
92
|
/** 已闭合 Mermaid fence 块。 */
|
|
46
93
|
kind: 'mermaid';
|
|
@@ -56,6 +103,16 @@ export interface MarkdownDocumentMermaidBlock {
|
|
|
56
103
|
signature: string;
|
|
57
104
|
}
|
|
58
105
|
/**
|
|
59
|
-
*
|
|
106
|
+
* 安全渲染 Markdown,同时提取目录和代码块元信息。
|
|
107
|
+
* @param content - Markdown 或文档正文。
|
|
108
|
+
* @param options - 本次操作的行为与显示选项。
|
|
109
|
+
* @returns 已消毒渲染块、目录和代码元信息。
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* ```ts
|
|
113
|
+
* import { renderMarkdownDocument } from '@h-ai/ui'
|
|
114
|
+
* const result = renderMarkdownDocument('# 简介\n正文', { allowHtmlTags: false, enableHighlight: true })
|
|
115
|
+
* const firstHeading = result.outline[0]?.text
|
|
116
|
+
* ```
|
|
60
117
|
*/
|
|
61
118
|
export declare function renderMarkdownDocument(content: string, options?: MarkdownDocumentParseOptions): MarkdownRenderResult;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @h-ai/ui — Markdown
|
|
2
|
+
* @h-ai/ui — Markdown 文档解析工具
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* 为文档模式提取安全 HTML、目录和代码块元信息。
|
|
5
5
|
*/
|
|
6
6
|
import { Marked } from 'marked';
|
|
7
7
|
import { createEditorMarkdownExtensions, extractPlainTextFromTokens, } from './editor-markdown-extensions.js';
|
|
8
8
|
import { highlightCode, isLanguageSupported } from './highlight.js';
|
|
9
9
|
import { isMermaidLanguage } from './mermaid-render.js';
|
|
10
10
|
import { escapeHtml, isExternalLinkHref, sanitizeImageSrc, sanitizeLinkHref, sanitizeMarkdownHtml, } from './safe-html.js';
|
|
11
|
-
/**
|
|
11
|
+
/** 文档模式的默认解析选项。 */
|
|
12
12
|
const DEFAULT_OPTIONS = {
|
|
13
13
|
enableHighlight: true,
|
|
14
14
|
showCopyButton: true,
|
|
@@ -64,7 +64,7 @@ function isClosedFencedCodeBlock(token) {
|
|
|
64
64
|
&& [...closingFence].every(char => char === markerChar);
|
|
65
65
|
}
|
|
66
66
|
/**
|
|
67
|
-
*
|
|
67
|
+
* 生成保留字母和数字的 URL 安全标题 slug。
|
|
68
68
|
*/
|
|
69
69
|
function slugifyHeading(text) {
|
|
70
70
|
// normalized slug used as the base key for headings.
|
|
@@ -78,7 +78,7 @@ function slugifyHeading(text) {
|
|
|
78
78
|
return normalized || 'section';
|
|
79
79
|
}
|
|
80
80
|
/**
|
|
81
|
-
*
|
|
81
|
+
* 为标题生成稳定 ID,并对重复标题去重。
|
|
82
82
|
*/
|
|
83
83
|
function createHeadingId(state, text) {
|
|
84
84
|
// base slug before de-duplication.
|
|
@@ -89,7 +89,7 @@ function createHeadingId(state, text) {
|
|
|
89
89
|
return nextCount === 1 ? base : `${base}-${nextCount}`;
|
|
90
90
|
}
|
|
91
91
|
/**
|
|
92
|
-
*
|
|
92
|
+
* 为目录条目添加 1、1.1 等层级编号。
|
|
93
93
|
*/
|
|
94
94
|
function createNumberedOutline(outline) {
|
|
95
95
|
// counters track the current numbering state per heading depth.
|
|
@@ -113,7 +113,7 @@ function createNumberedOutline(outline) {
|
|
|
113
113
|
});
|
|
114
114
|
}
|
|
115
115
|
/**
|
|
116
|
-
*
|
|
116
|
+
* 构建同时提取目录与代码元信息的 Marked renderer。
|
|
117
117
|
*/
|
|
118
118
|
function createRendererObject(options, state) {
|
|
119
119
|
return {
|
|
@@ -264,7 +264,7 @@ function createRendererObject(options, state) {
|
|
|
264
264
|
};
|
|
265
265
|
}
|
|
266
266
|
/**
|
|
267
|
-
*
|
|
267
|
+
* 创建绑定本次临时解析状态的 Marked 实例。
|
|
268
268
|
*/
|
|
269
269
|
function createMarkedInstance(options, state) {
|
|
270
270
|
return new Marked({
|
|
@@ -368,7 +368,17 @@ function renderMarkdownDocumentBlocks(content, options) {
|
|
|
368
368
|
return blocks;
|
|
369
369
|
}
|
|
370
370
|
/**
|
|
371
|
-
*
|
|
371
|
+
* 安全渲染 Markdown,同时提取目录和代码块元信息。
|
|
372
|
+
* @param content - Markdown 或文档正文。
|
|
373
|
+
* @param options - 本次操作的行为与显示选项。
|
|
374
|
+
* @returns 已消毒渲染块、目录和代码元信息。
|
|
375
|
+
*
|
|
376
|
+
* @example
|
|
377
|
+
* ```ts
|
|
378
|
+
* import { renderMarkdownDocument } from '@h-ai/ui'
|
|
379
|
+
* const result = renderMarkdownDocument('# 简介\n正文', { allowHtmlTags: false, enableHighlight: true })
|
|
380
|
+
* const firstHeading = result.outline[0]?.text
|
|
381
|
+
* ```
|
|
372
382
|
*/
|
|
373
383
|
export function renderMarkdownDocument(content, options) {
|
|
374
384
|
if (!content) {
|
|
@@ -1,46 +1,87 @@
|
|
|
1
1
|
import type { DataAttributes } from '../../../types.js';
|
|
2
2
|
/**
|
|
3
|
-
* Markdown
|
|
3
|
+
* 内容来源种类,用于区分 Markdown 正文、文档面板和纯代码展示。
|
|
4
|
+
*
|
|
5
|
+
* @example 模块内部上下文
|
|
6
|
+
* ```ts
|
|
7
|
+
* const example: MarkdownSourceKind = 'document'
|
|
8
|
+
* ```
|
|
4
9
|
*/
|
|
5
10
|
export type MarkdownSourceKind = 'markdown' | 'document' | 'code';
|
|
11
|
+
/**
|
|
12
|
+
* 文档目录节点,绑定稳定锚点、标题级别和编号标题。
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* import type { MarkdownOutlineItem } from '@h-ai/ui'
|
|
17
|
+
* const example: MarkdownOutlineItem = { id: 'intro', text: '简介', level: 1, numberedTitle: '1 简介' }
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
6
20
|
export interface MarkdownOutlineItem {
|
|
7
|
-
/**
|
|
21
|
+
/** 目录导航与标题同步使用的稳定锚点 ID。 */
|
|
8
22
|
id: string;
|
|
9
|
-
/**
|
|
23
|
+
/** 不含行内 Markdown 格式的纯文本标题。 */
|
|
10
24
|
text: string;
|
|
11
|
-
/**
|
|
25
|
+
/** 标题级别 1..6,对应 h1..h6。 */
|
|
12
26
|
level: number;
|
|
13
|
-
/**
|
|
27
|
+
/** 用于目录展示的编号标题。 */
|
|
14
28
|
numberedTitle: string;
|
|
15
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* 代码块的原始源码及语言标记,供复制和预览复用。
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```ts
|
|
35
|
+
* import type { MarkdownCodeBlockItem } from '@h-ai/ui'
|
|
36
|
+
* const example: MarkdownCodeBlockItem = { id: 'code-1', code: 'const count = 42', language: 'typescript' }
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
16
39
|
export interface MarkdownCodeBlockItem {
|
|
17
|
-
/**
|
|
40
|
+
/** 预览与 DOM 关联使用的稳定代码块 ID。 */
|
|
18
41
|
id: string;
|
|
19
|
-
/**
|
|
42
|
+
/** 语法高亮前的原始源码。 */
|
|
20
43
|
code: string;
|
|
21
|
-
/**
|
|
44
|
+
/** 解析到的语言标记,可省略。 */
|
|
22
45
|
language?: string;
|
|
23
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* 代码块运行请求;由宿主按来源和语言决定是否允许执行。
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```ts
|
|
52
|
+
* import type { MarkdownCodeRunRequest } from '@h-ai/ui'
|
|
53
|
+
* const example: MarkdownCodeRunRequest = { blockId: 'code-1', code: '1 + 1', language: 'javascript', sourceKind: 'code' }
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
24
56
|
export interface MarkdownCodeRunRequest {
|
|
25
|
-
/**
|
|
57
|
+
/** 用于将运行结果写回对应预览槽的代码块 ID。 */
|
|
26
58
|
blockId: string;
|
|
27
|
-
/**
|
|
59
|
+
/** 原始代码文本。 */
|
|
28
60
|
code: string;
|
|
29
|
-
/**
|
|
61
|
+
/** 供宿主选择运行方式的代码语言。 */
|
|
30
62
|
language?: string;
|
|
31
|
-
/**
|
|
63
|
+
/** 用于预览元信息的当前文档标题。 */
|
|
32
64
|
title?: string;
|
|
33
|
-
/**
|
|
65
|
+
/** 供宿主判断运行权限与上下文的内容来源。 */
|
|
34
66
|
sourceKind: MarkdownSourceKind;
|
|
35
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* 宿主返回的预览内容及渲染种类;HTML 脚本必须显式授权。
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```ts
|
|
73
|
+
* import type { MarkdownCodeRunResult } from '@h-ai/ui'
|
|
74
|
+
* const example: MarkdownCodeRunResult = { kind: 'text', content: '2', title: '计算结果', allowScripts: false }
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
36
77
|
export interface MarkdownCodeRunResult {
|
|
37
|
-
/**
|
|
78
|
+
/** 预览渲染使用的输出种类。 */
|
|
38
79
|
kind?: 'text' | 'markdown' | 'html' | 'mermaid';
|
|
39
|
-
/**
|
|
80
|
+
/** 预览输出正文。 */
|
|
40
81
|
content: string;
|
|
41
|
-
/**
|
|
82
|
+
/** 预览标题,省略时使用默认文案。 */
|
|
42
83
|
title?: string;
|
|
43
|
-
/**
|
|
84
|
+
/** 可选的预览说明。 */
|
|
44
85
|
description?: string;
|
|
45
86
|
/**
|
|
46
87
|
* 预览 iframe 是否允许执行脚本。
|
|
@@ -50,49 +91,105 @@ export interface MarkdownCodeRunResult {
|
|
|
50
91
|
*/
|
|
51
92
|
allowScripts?: boolean;
|
|
52
93
|
}
|
|
94
|
+
/**
|
|
95
|
+
* 选区改写菜单的稳定动作标识和已本地化文案。
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```ts
|
|
99
|
+
* import type { MarkdownRewriteAction } from '@h-ai/ui'
|
|
100
|
+
* const example: MarkdownRewriteAction = { id: 'shorten', label: '精简' }
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
53
103
|
export interface MarkdownRewriteAction {
|
|
54
|
-
/**
|
|
104
|
+
/** 回调使用的改写动作标识。 */
|
|
55
105
|
id: string;
|
|
56
|
-
/**
|
|
106
|
+
/** 已经本地化的改写动作名称。 */
|
|
57
107
|
label: string;
|
|
58
108
|
}
|
|
109
|
+
/**
|
|
110
|
+
* 绑定动作、选中文本和当前全文的改写请求。
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* ```ts
|
|
114
|
+
* import type { MarkdownRewriteRequest } from '@h-ai/ui'
|
|
115
|
+
* const example: MarkdownRewriteRequest = { actionId: 'shorten', selectedText: '需要精简的段落', content: '# 报告\n需要精简的段落' }
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
59
118
|
export interface MarkdownRewriteRequest {
|
|
60
|
-
/**
|
|
119
|
+
/** 当前界面操作关联的改写动作标识。 */
|
|
61
120
|
actionId: string;
|
|
62
|
-
/**
|
|
121
|
+
/** 当前选中的原文。 */
|
|
63
122
|
selectedText: string;
|
|
64
|
-
/**
|
|
123
|
+
/** 触发请求时的完整文档内容。 */
|
|
65
124
|
content: string;
|
|
66
|
-
/**
|
|
125
|
+
/** 当前文档标题。 */
|
|
67
126
|
title?: string;
|
|
68
127
|
}
|
|
69
128
|
/**
|
|
70
|
-
*
|
|
129
|
+
* 块级快捷操作种类:标题或列表。
|
|
130
|
+
*
|
|
131
|
+
* @example
|
|
132
|
+
* ```ts
|
|
133
|
+
* import type { MarkdownBlockFormatKind } from '@h-ai/ui'
|
|
134
|
+
* const example: MarkdownBlockFormatKind = 'heading'
|
|
135
|
+
* ```
|
|
71
136
|
*/
|
|
72
137
|
export type MarkdownBlockFormatKind = 'heading' | 'bullet';
|
|
73
138
|
/**
|
|
74
|
-
*
|
|
139
|
+
* 当前工具栏支持的具体段落和标题样式。
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* ```ts
|
|
143
|
+
* import type { MarkdownBlockStyleKind } from '@h-ai/ui'
|
|
144
|
+
* const example: MarkdownBlockStyleKind = 'heading2'
|
|
145
|
+
* ```
|
|
75
146
|
*/
|
|
76
147
|
export type MarkdownBlockStyleKind = 'paragraph' | 'heading1' | 'heading2' | 'heading3' | 'heading4' | 'orderedList' | 'bulletList';
|
|
77
148
|
/**
|
|
78
|
-
*
|
|
79
|
-
*
|
|
149
|
+
* 选区工具栏提供的行内格式操作。
|
|
150
|
+
* 高亮与链接同样通过选区操作回调交给宿主处理。
|
|
151
|
+
*
|
|
152
|
+
* @example
|
|
153
|
+
* ```ts
|
|
154
|
+
* import type { MarkdownInlineFormatKind } from '@h-ai/ui'
|
|
155
|
+
* const example: MarkdownInlineFormatKind = 'bold'
|
|
156
|
+
* ```
|
|
80
157
|
*/
|
|
81
158
|
export type MarkdownInlineFormatKind = 'bold' | 'italic' | 'strike' | 'underline' | 'code' | 'highlight' | 'link';
|
|
82
159
|
/**
|
|
83
|
-
*
|
|
160
|
+
* 选区工具栏提供的段落对齐方式。
|
|
161
|
+
*
|
|
162
|
+
* @example
|
|
163
|
+
* ```ts
|
|
164
|
+
* import type { MarkdownTextAlignKind } from '@h-ai/ui'
|
|
165
|
+
* const example: MarkdownTextAlignKind = 'center'
|
|
166
|
+
* ```
|
|
84
167
|
*/
|
|
85
168
|
export type MarkdownTextAlignKind = 'left' | 'center' | 'right' | 'justify';
|
|
169
|
+
/**
|
|
170
|
+
* 纯文本选区偏移快照,DOM 变化后用于恢复或回退定位。
|
|
171
|
+
*
|
|
172
|
+
* @example 模块内部上下文
|
|
173
|
+
* ```ts
|
|
174
|
+
* const example: MarkdownSelectionSnapshot = { start: 0, end: 4, text: '示例文本' }
|
|
175
|
+
* ```
|
|
176
|
+
*/
|
|
86
177
|
export interface MarkdownSelectionSnapshot {
|
|
87
|
-
/**
|
|
178
|
+
/** 选区在文档纯文本中的起始偏移。 */
|
|
88
179
|
start: number;
|
|
89
|
-
/**
|
|
180
|
+
/** 选区在文档纯文本中的结束偏移。 */
|
|
90
181
|
end: number;
|
|
91
|
-
/**
|
|
182
|
+
/** 选中纯文本,用于结构变化后的回退定位。 */
|
|
92
183
|
text: string;
|
|
93
184
|
}
|
|
94
185
|
/**
|
|
95
186
|
* 颜色面板一次只会修改前景色或背景色中的一个维度。
|
|
187
|
+
*
|
|
188
|
+
* @example
|
|
189
|
+
* ```ts
|
|
190
|
+
* import type { MarkdownColorFormatRequest } from '@h-ai/ui'
|
|
191
|
+
* const example: MarkdownColorFormatRequest = { target: 'text', value: '#2563eb', selectedText: '重点' }
|
|
192
|
+
* ```
|
|
96
193
|
*/
|
|
97
194
|
export interface MarkdownColorFormatRequest {
|
|
98
195
|
/** `text` 表示文字颜色,`background` 表示文本底色。 */
|
|
@@ -104,6 +201,14 @@ export interface MarkdownColorFormatRequest {
|
|
|
104
201
|
/** 当前工具条记住的精确选区偏移,优先用于重复文本场景的恢复。 */
|
|
105
202
|
selectionSnapshot?: MarkdownSelectionSnapshot;
|
|
106
203
|
}
|
|
204
|
+
/**
|
|
205
|
+
* 添加、修改或移除选区链接的请求;href=null 表示移除链接。
|
|
206
|
+
*
|
|
207
|
+
* @example 模块内部上下文
|
|
208
|
+
* ```ts
|
|
209
|
+
* const example: MarkdownLinkFormatRequest = { href: 'https://example.com/help', selectedText: '帮助' }
|
|
210
|
+
* ```
|
|
211
|
+
*/
|
|
107
212
|
export interface MarkdownLinkFormatRequest {
|
|
108
213
|
/** 为空时表示移除当前链接。 */
|
|
109
214
|
href: string | null;
|
|
@@ -112,41 +217,70 @@ export interface MarkdownLinkFormatRequest {
|
|
|
112
217
|
/** 当前工具条记住的选中文本,供宿主做文本兜底。 */
|
|
113
218
|
selectedText?: string;
|
|
114
219
|
}
|
|
220
|
+
/**
|
|
221
|
+
* 文档下载菜单动作;内置格式直接使用对应格式名,自定义动作交给宿主处理。
|
|
222
|
+
*
|
|
223
|
+
* @example
|
|
224
|
+
* ```ts
|
|
225
|
+
* import type { MarkdownToolbarDownloadAction } from '@h-ai/ui'
|
|
226
|
+
* const example: MarkdownToolbarDownloadAction = { id: 'markdown', label: 'Markdown', badgeLabel: 'MD' }
|
|
227
|
+
* ```
|
|
228
|
+
*/
|
|
115
229
|
export interface MarkdownToolbarDownloadAction {
|
|
116
|
-
/**
|
|
230
|
+
/** 下载动作标识。 */
|
|
117
231
|
id: string;
|
|
118
|
-
/**
|
|
232
|
+
/** 下载菜单显示的已本地化文案。 */
|
|
119
233
|
label: string;
|
|
120
|
-
/**
|
|
234
|
+
/** 菜单文案旁可选的短标签。 */
|
|
121
235
|
badgeLabel?: string;
|
|
122
236
|
}
|
|
123
237
|
/**
|
|
124
|
-
*
|
|
125
|
-
*
|
|
238
|
+
* Svelte 事件属性使用双变型参数检查,保留组件回调的推导方式。
|
|
239
|
+
* 该类型仅约束回调签名,不负责验证宿主执行权限或业务数据。
|
|
240
|
+
* @typeParam Args - 回调参数元组类型。
|
|
241
|
+
* @typeParam Return - 转换结果的数据类型。
|
|
242
|
+
*
|
|
243
|
+
* @example 模块内部上下文
|
|
244
|
+
* ```ts
|
|
245
|
+
* const example: BivariantCallback<[string], void> = value => { document.body.setAttribute('data-format', value) }
|
|
246
|
+
* ```
|
|
126
247
|
*/
|
|
127
248
|
type BivariantCallback<Args extends unknown[], Return = void> = {
|
|
128
249
|
bivarianceHack: (...args: Args) => Return;
|
|
129
250
|
}['bivarianceHack'];
|
|
251
|
+
/**
|
|
252
|
+
* 文档编辑器的数据、预览安全策略和宿主交互回调;不在组件中实现 AI 业务请求。
|
|
253
|
+
*
|
|
254
|
+
* @example
|
|
255
|
+
* ```svelte
|
|
256
|
+
* <script lang="ts">
|
|
257
|
+
* import { AiDocumentEditor } from '@h-ai/ui'
|
|
258
|
+
* import type { AiDocumentEditorProps } from '@h-ai/ui'
|
|
259
|
+
* const props: AiDocumentEditorProps = { content: '# 报告\n正文', title: '报告', sourceKind: 'document', allowHtmlTags: false, allowUnsafeCodePreview: false }
|
|
260
|
+
* </script>
|
|
261
|
+
* <AiDocumentEditor {...props} />
|
|
262
|
+
* ```
|
|
263
|
+
*/
|
|
130
264
|
export interface AiDocumentEditorProps extends DataAttributes {
|
|
131
|
-
/** Markdown
|
|
265
|
+
/** Markdown 原始正文。 */
|
|
132
266
|
content?: string;
|
|
133
|
-
/**
|
|
267
|
+
/** 头部展示的文档标题。 */
|
|
134
268
|
title?: string;
|
|
135
|
-
/**
|
|
269
|
+
/** 影响渲染与交互的内容来源。 */
|
|
136
270
|
sourceKind?: MarkdownSourceKind;
|
|
137
|
-
/**
|
|
271
|
+
/** sourceKind=code 时的默认语言。 */
|
|
138
272
|
codeLanguage?: string;
|
|
139
|
-
/**
|
|
273
|
+
/** 正文字号;数字按 px 解释。 */
|
|
140
274
|
fontSize?: string | number;
|
|
141
|
-
/**
|
|
275
|
+
/** 外层容器类名。 */
|
|
142
276
|
class?: string;
|
|
143
|
-
/**
|
|
277
|
+
/** 是否显示代码块复制按钮。 */
|
|
144
278
|
showCopyButton?: boolean;
|
|
145
|
-
/**
|
|
279
|
+
/** 是否显示代码块运行按钮;是否执行仍由宿主授权。 */
|
|
146
280
|
showRunButton?: boolean;
|
|
147
|
-
/**
|
|
281
|
+
/** 是否显示代码/预览切换。 */
|
|
148
282
|
showCodePreviewToggle?: boolean;
|
|
149
|
-
/**
|
|
283
|
+
/** 是否按安全白名单解析原始 HTML。 */
|
|
150
284
|
allowHtmlTags?: boolean;
|
|
151
285
|
/**
|
|
152
286
|
* 是否启用内置的高风险代码预览。
|
|
@@ -155,93 +289,93 @@ export interface AiDocumentEditorProps extends DataAttributes {
|
|
|
155
289
|
* 需要宿主显式开启,或由宿主通过 `oncoderun` 自行提供受控沙箱结果。
|
|
156
290
|
*/
|
|
157
291
|
allowUnsafeCodePreview?: boolean;
|
|
158
|
-
/**
|
|
292
|
+
/** 启用预览切换时语言标签旁的提示。 */
|
|
159
293
|
codePreviewHint?: string;
|
|
160
|
-
/**
|
|
294
|
+
/** 是否启用语法高亮。 */
|
|
161
295
|
enableHighlight?: boolean;
|
|
162
|
-
/**
|
|
296
|
+
/** 是否将普通换行渲染为 br。 */
|
|
163
297
|
breaks?: boolean;
|
|
164
|
-
/**
|
|
298
|
+
/** 是否显示左侧目录。 */
|
|
165
299
|
showOutline?: boolean;
|
|
166
|
-
/**
|
|
300
|
+
/** 是否显示目录编号。 */
|
|
167
301
|
showOutlineNumbering?: boolean;
|
|
168
|
-
/**
|
|
302
|
+
/** 是否显示顶部工具栏。 */
|
|
169
303
|
showToolbar?: boolean;
|
|
170
|
-
/**
|
|
304
|
+
/** 目录的初始折叠状态。 */
|
|
171
305
|
initialOutlineCollapsed?: boolean;
|
|
172
|
-
/**
|
|
306
|
+
/** 头部或工具栏显示的状态文案。 */
|
|
173
307
|
statusText?: string;
|
|
174
|
-
/**
|
|
308
|
+
/** 改写流程是否正在执行。 */
|
|
175
309
|
rewritePending?: boolean;
|
|
176
|
-
/**
|
|
310
|
+
/** 可用改写动作,空列表隐藏菜单。 */
|
|
177
311
|
rewriteActions?: MarkdownRewriteAction[];
|
|
178
|
-
/**
|
|
312
|
+
/** 点击关闭时通知宿主。 */
|
|
179
313
|
onclose?: () => void;
|
|
180
|
-
/**
|
|
314
|
+
/** 是否禁用关闭/返回操作。 */
|
|
181
315
|
closeDisabled?: boolean;
|
|
182
|
-
/**
|
|
316
|
+
/** 点击撤销时通知宿主。 */
|
|
183
317
|
onundo?: () => void;
|
|
184
|
-
/**
|
|
318
|
+
/** 是否禁用撤销操作。 */
|
|
185
319
|
undoDisabled?: boolean;
|
|
186
|
-
/**
|
|
320
|
+
/** 点击重做时通知宿主。 */
|
|
187
321
|
onredo?: () => void;
|
|
188
|
-
/**
|
|
322
|
+
/** 是否禁用重做操作。 */
|
|
189
323
|
redoDisabled?: boolean;
|
|
190
|
-
/**
|
|
324
|
+
/** 由宿主执行并返回预览结果的代码回调。 */
|
|
191
325
|
oncoderun?: (request: MarkdownCodeRunRequest) => MarkdownCodeRunResult | void | Promise<MarkdownCodeRunResult | void>;
|
|
192
|
-
/**
|
|
326
|
+
/** 宿主处理选区改写的回调。 */
|
|
193
327
|
onrewrite?: (request: MarkdownRewriteRequest) => void | Promise<void>;
|
|
194
|
-
/**
|
|
328
|
+
/** 向宿主暴露滚动容器以同步滚动。 */
|
|
195
329
|
editorScrollHost?: HTMLDivElement | null;
|
|
196
|
-
/**
|
|
330
|
+
/** 向宿主暴露可编辑内容容器。 */
|
|
197
331
|
previewHost?: HTMLElement | null;
|
|
198
|
-
/**
|
|
332
|
+
/** 标题上方的辅助标签。 */
|
|
199
333
|
eyebrow?: string;
|
|
200
|
-
/**
|
|
334
|
+
/** 优先显示的头部说明。 */
|
|
201
335
|
metaText?: string;
|
|
202
|
-
/**
|
|
336
|
+
/** 标题附近的状态标签。 */
|
|
203
337
|
saveState?: string;
|
|
204
|
-
/**
|
|
338
|
+
/** 正文是否允许 contenteditable 编辑。 */
|
|
205
339
|
editable?: boolean;
|
|
206
|
-
/**
|
|
340
|
+
/** 下载菜单项,空列表使用内置动作。 */
|
|
207
341
|
downloadActions?: MarkdownToolbarDownloadAction[];
|
|
208
|
-
/**
|
|
342
|
+
/** 历史记录操作文案。 */
|
|
209
343
|
historyActionLabel?: string;
|
|
210
|
-
/**
|
|
344
|
+
/** 查看版本操作文案。 */
|
|
211
345
|
versionActionLabel?: string;
|
|
212
|
-
/**
|
|
346
|
+
/** 向宿主同步滚动状态的回调。 */
|
|
213
347
|
ondocumentscroll?: (event: Event) => void;
|
|
214
|
-
/**
|
|
348
|
+
/** 鼠标释放时同步选区的回调。 */
|
|
215
349
|
onpreviewmouseup?: () => void;
|
|
216
|
-
/**
|
|
350
|
+
/** 可编辑正文发生输入时的回调。 */
|
|
217
351
|
onpreviewinput?: (event: Event) => void;
|
|
218
|
-
/**
|
|
352
|
+
/** 失焦时提交编辑的回调。 */
|
|
219
353
|
onpreviewblur?: () => void;
|
|
220
|
-
/**
|
|
354
|
+
/** 选择下载动作时的回调。 */
|
|
221
355
|
ondownload?: (actionId: string) => void;
|
|
222
|
-
/**
|
|
356
|
+
/** 点击历史记录时的回调。 */
|
|
223
357
|
onhistory?: () => void;
|
|
224
|
-
/**
|
|
358
|
+
/** 宿主自定义的整篇复制操作。 */
|
|
225
359
|
oncopydocument?: () => void | Promise<void>;
|
|
226
|
-
/**
|
|
360
|
+
/** 标题/列表快捷格式操作回调。 */
|
|
227
361
|
onapplyblockformat?: BivariantCallback<[kind: MarkdownBlockFormatKind], void>;
|
|
228
|
-
/**
|
|
362
|
+
/** 切换段落或具体标题级别的回调。 */
|
|
229
363
|
onapplyblockstyle?: BivariantCallback<[kind: MarkdownBlockStyleKind], void>;
|
|
230
|
-
/**
|
|
364
|
+
/** 选区工具栏的行内格式回调。 */
|
|
231
365
|
onapplyinlineformat?: BivariantCallback<[kind: MarkdownInlineFormatKind], void>;
|
|
232
|
-
/**
|
|
366
|
+
/** 选区工具栏的段落对齐回调。 */
|
|
233
367
|
onapplyalignment?: (kind: MarkdownTextAlignKind) => void;
|
|
234
|
-
/**
|
|
368
|
+
/** 选区工具栏添加、编辑或移除链接的回调。 */
|
|
235
369
|
onapplylink?: BivariantCallback<[
|
|
236
370
|
href: string | null,
|
|
237
371
|
selectionSnapshot?: MarkdownSelectionSnapshot,
|
|
238
372
|
selectedText?: string
|
|
239
373
|
], void>;
|
|
240
|
-
/**
|
|
374
|
+
/** 选区工具栏修改文字色或背景色的回调。 */
|
|
241
375
|
onapplycolor?: (request: MarkdownColorFormatRequest) => void;
|
|
242
|
-
/**
|
|
376
|
+
/** 宿主自定义的选区复制操作。 */
|
|
243
377
|
oncopyselection?: () => void | Promise<void>;
|
|
244
|
-
/**
|
|
378
|
+
/** 宿主处理选区注释的回调。 */
|
|
245
379
|
onannotation?: () => void | Promise<void>;
|
|
246
380
|
}
|
|
247
381
|
export {};
|