@docyrus/ui-pro-ai-assistant 0.0.2 → 0.0.3
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/package.json +2 -3
- package/src/components/assistant-animations.tsx +0 -29
- package/src/components/assistant-dialogs.tsx +0 -235
- package/src/components/code-view.tsx +0 -278
- package/src/components/create-agent-task.tsx +0 -104
- package/src/components/create-new-work-version.tsx +0 -30
- package/src/components/extract-web.tsx +0 -160
- package/src/components/forward-to-agent.tsx +0 -90
- package/src/components/generate-chart.tsx +0 -101
- package/src/components/generative-action-button.tsx +0 -122
- package/src/components/generative-tool.tsx +0 -685
- package/src/components/generative-ui-object.tsx +0 -210
- package/src/components/input-area.tsx +0 -1209
- package/src/components/json-schema-layout.tsx +0 -326
- package/src/components/list-item-card.tsx +0 -92
- package/src/components/mermaid-diagram.tsx +0 -192
- package/src/components/preview-image.tsx +0 -47
- package/src/components/request-approval.tsx +0 -48
- package/src/components/request-user-input.tsx +0 -270
- package/src/components/search-web.tsx +0 -319
- package/src/components/sheet-command.tsx +0 -88
- package/src/components/shell-canvas.tsx +0 -122
- package/src/components/show-advanced-data-table.tsx +0 -352
- package/src/components/show-generated-content-options.tsx +0 -93
- package/src/components/show-people-cards.tsx +0 -180
- package/src/components/subagent-tool.tsx +0 -180
- package/src/components/text-editor-tool.tsx +0 -328
- package/src/components/work-canvas.tsx +0 -88
- package/src/components/work-card.tsx +0 -42
- package/src/declarations.d.ts +0 -1
- package/src/docy-assistant.tsx +0 -1962
- package/src/hooks/index.ts +0 -7
- package/src/hooks/use-assistant-api.ts +0 -507
- package/src/hooks/use-deployment-data.ts +0 -162
- package/src/hooks/use-project-state.ts +0 -347
- package/src/hooks/use-session-state.ts +0 -207
- package/src/hooks/use-speech-recognition.ts +0 -137
- package/src/hooks/use-ui-state.ts +0 -185
- package/src/hooks/use-works-state.ts +0 -146
- package/src/i18n/context.tsx +0 -253
- package/src/i18n/index.ts +0 -19
- package/src/i18n/locales/de.json +0 -198
- package/src/i18n/locales/el.json +0 -198
- package/src/i18n/locales/en.json +0 -226
- package/src/i18n/locales/es.json +0 -198
- package/src/i18n/locales/fr.json +0 -198
- package/src/i18n/locales/it.json +0 -198
- package/src/i18n/locales/pt.json +0 -198
- package/src/i18n/locales/sl.json +0 -198
- package/src/i18n/locales/tr.json +0 -211
- package/src/i18n/types.ts +0 -23
- package/src/i18n/use-translation.ts +0 -17
- package/src/index.ts +0 -18
- package/src/internal/plate-editor/editor/auth-context.ts +0 -11
- package/src/internal/plate-editor/editor/editor-base-kit.tsx +0 -39
- package/src/internal/plate-editor/editor/editor-kit.tsx +0 -89
- package/src/internal/plate-editor/editor/plate-editor.tsx +0 -75
- package/src/internal/plate-editor/editor/plate-types.ts +0 -126
- package/src/internal/plate-editor/editor/plugins/ai-kit.tsx +0 -172
- package/src/internal/plate-editor/editor/plugins/autoformat-kit.tsx +0 -211
- package/src/internal/plate-editor/editor/plugins/basic-blocks-base-kit.tsx +0 -26
- package/src/internal/plate-editor/editor/plugins/basic-blocks-kit.tsx +0 -51
- package/src/internal/plate-editor/editor/plugins/basic-marks-base-kit.tsx +0 -24
- package/src/internal/plate-editor/editor/plugins/basic-marks-kit.tsx +0 -38
- package/src/internal/plate-editor/editor/plugins/basic-nodes-kit.tsx +0 -6
- package/src/internal/plate-editor/editor/plugins/block-menu-kit.tsx +0 -14
- package/src/internal/plate-editor/editor/plugins/block-placeholder-kit.tsx +0 -17
- package/src/internal/plate-editor/editor/plugins/block-selection-kit.tsx +0 -31
- package/src/internal/plate-editor/editor/plugins/callout-base-kit.tsx +0 -5
- package/src/internal/plate-editor/editor/plugins/callout-kit.tsx +0 -7
- package/src/internal/plate-editor/editor/plugins/code-block-base-kit.tsx +0 -23
- package/src/internal/plate-editor/editor/plugins/code-block-kit.tsx +0 -26
- package/src/internal/plate-editor/editor/plugins/column-base-kit.tsx +0 -8
- package/src/internal/plate-editor/editor/plugins/column-kit.tsx +0 -7
- package/src/internal/plate-editor/editor/plugins/comment-base-kit.tsx +0 -5
- package/src/internal/plate-editor/editor/plugins/comment-kit.tsx +0 -174
- package/src/internal/plate-editor/editor/plugins/copilot-kit.tsx +0 -68
- package/src/internal/plate-editor/editor/plugins/cursor-overlay-kit.tsx +0 -13
- package/src/internal/plate-editor/editor/plugins/date-base-kit.tsx +0 -5
- package/src/internal/plate-editor/editor/plugins/date-kit.tsx +0 -7
- package/src/internal/plate-editor/editor/plugins/discussion-kit.tsx +0 -36
- package/src/internal/plate-editor/editor/plugins/dnd-kit.tsx +0 -27
- package/src/internal/plate-editor/editor/plugins/docx-export-kit.tsx +0 -43
- package/src/internal/plate-editor/editor/plugins/docx-kit.tsx +0 -6
- package/src/internal/plate-editor/editor/plugins/emoji-kit.tsx +0 -15
- package/src/internal/plate-editor/editor/plugins/exit-break-kit.tsx +0 -12
- package/src/internal/plate-editor/editor/plugins/floating-toolbar-kit.tsx +0 -19
- package/src/internal/plate-editor/editor/plugins/font-base-kit.tsx +0 -36
- package/src/internal/plate-editor/editor/plugins/font-kit.tsx +0 -47
- package/src/internal/plate-editor/editor/plugins/indent-base-kit.tsx +0 -19
- package/src/internal/plate-editor/editor/plugins/indent-kit.tsx +0 -22
- package/src/internal/plate-editor/editor/plugins/link-base-kit.tsx +0 -5
- package/src/internal/plate-editor/editor/plugins/link-kit.tsx +0 -35
- package/src/internal/plate-editor/editor/plugins/list-base-kit.tsx +0 -24
- package/src/internal/plate-editor/editor/plugins/list-kit.tsx +0 -27
- package/src/internal/plate-editor/editor/plugins/markdown-kit.tsx +0 -18
- package/src/internal/plate-editor/editor/plugins/math-base-kit.tsx +0 -8
- package/src/internal/plate-editor/editor/plugins/math-kit.tsx +0 -10
- package/src/internal/plate-editor/editor/plugins/media-base-kit.tsx +0 -37
- package/src/internal/plate-editor/editor/plugins/media-kit.tsx +0 -53
- package/src/internal/plate-editor/editor/plugins/mention-base-kit.tsx +0 -5
- package/src/internal/plate-editor/editor/plugins/mention-kit.tsx +0 -36
- package/src/internal/plate-editor/editor/plugins/slash-kit.tsx +0 -17
- package/src/internal/plate-editor/editor/plugins/suggestion-base-kit.tsx +0 -5
- package/src/internal/plate-editor/editor/plugins/suggestion-kit.tsx +0 -95
- package/src/internal/plate-editor/editor/plugins/table-base-kit.tsx +0 -20
- package/src/internal/plate-editor/editor/plugins/table-kit.tsx +0 -22
- package/src/internal/plate-editor/editor/plugins/toc-base-kit.tsx +0 -5
- package/src/internal/plate-editor/editor/plugins/toc-kit.tsx +0 -14
- package/src/internal/plate-editor/editor/plugins/toggle-base-kit.tsx +0 -5
- package/src/internal/plate-editor/editor/plugins/toggle-kit.tsx +0 -9
- package/src/internal/plate-editor/editor/transforms.ts +0 -165
- package/src/internal/plate-editor/editor/use-chat.ts +0 -152
- package/src/internal/plate-editor/hooks/index.ts +0 -3
- package/src/internal/plate-editor/hooks/use-copy-to-clipboard.ts +0 -31
- package/src/internal/plate-editor/hooks/use-is-touch-device.ts +0 -26
- package/src/internal/plate-editor/hooks/use-lock-scroll.ts +0 -21
- package/src/internal/plate-editor/hooks/use-media-query.ts +0 -44
- package/src/internal/plate-editor/hooks/use-mounted.ts +0 -18
- package/src/internal/plate-editor/hooks/use-on-click-outside.ts +0 -114
- package/src/internal/plate-editor/hooks/use-upload-file.ts +0 -81
- package/src/internal/plate-editor/i18n/context.tsx +0 -58
- package/src/internal/plate-editor/i18n/index.ts +0 -3
- package/src/internal/plate-editor/i18n/locales/de.json +0 -57
- package/src/internal/plate-editor/i18n/locales/el.json +0 -57
- package/src/internal/plate-editor/i18n/locales/en.json +0 -57
- package/src/internal/plate-editor/i18n/locales/es.json +0 -57
- package/src/internal/plate-editor/i18n/locales/fr.json +0 -57
- package/src/internal/plate-editor/i18n/locales/it.json +0 -57
- package/src/internal/plate-editor/i18n/locales/pt.json +0 -57
- package/src/internal/plate-editor/i18n/locales/sl.json +0 -57
- package/src/internal/plate-editor/i18n/locales/tr.json +0 -57
- package/src/internal/plate-editor/i18n/types.ts +0 -59
- package/src/internal/plate-editor/i18n/use-translation.ts +0 -22
- package/src/internal/plate-editor/index.ts +0 -39
- package/src/internal/plate-editor/lib/ai-output-converter.ts +0 -153
- package/src/internal/plate-editor/lib/download-file.ts +0 -17
- package/src/internal/plate-editor/plate-ui/ai-chat-editor.tsx +0 -24
- package/src/internal/plate-editor/plate-ui/ai-menu.tsx +0 -828
- package/src/internal/plate-editor/plate-ui/ai-node.tsx +0 -41
- package/src/internal/plate-editor/plate-ui/ai-toolbar-button.tsx +0 -25
- package/src/internal/plate-editor/plate-ui/alert-dialog.tsx +0 -145
- package/src/internal/plate-editor/plate-ui/align-toolbar-button.tsx +0 -88
- package/src/internal/plate-editor/plate-ui/avatar.tsx +0 -3
- package/src/internal/plate-editor/plate-ui/block-context-menu.tsx +0 -104
- package/src/internal/plate-editor/plate-ui/block-discussion.tsx +0 -364
- package/src/internal/plate-editor/plate-ui/block-draggable.tsx +0 -557
- package/src/internal/plate-editor/plate-ui/block-list-static.tsx +0 -77
- package/src/internal/plate-editor/plate-ui/block-list.tsx +0 -85
- package/src/internal/plate-editor/plate-ui/block-menu.tsx +0 -555
- package/src/internal/plate-editor/plate-ui/block-selection.tsx +0 -47
- package/src/internal/plate-editor/plate-ui/block-suggestion.tsx +0 -469
- package/src/internal/plate-editor/plate-ui/blockquote-node-static.tsx +0 -10
- package/src/internal/plate-editor/plate-ui/blockquote-node.tsx +0 -11
- package/src/internal/plate-editor/plate-ui/button.tsx +0 -201
- package/src/internal/plate-editor/plate-ui/calendar.tsx +0 -3
- package/src/internal/plate-editor/plate-ui/callout-node-static.tsx +0 -76
- package/src/internal/plate-editor/plate-ui/callout-node.tsx +0 -54
- package/src/internal/plate-editor/plate-ui/caption.tsx +0 -47
- package/src/internal/plate-editor/plate-ui/checkbox.tsx +0 -3
- package/src/internal/plate-editor/plate-ui/code-block-node-static.tsx +0 -172
- package/src/internal/plate-editor/plate-ui/code-block-node.tsx +0 -226
- package/src/internal/plate-editor/plate-ui/code-node-static.tsx +0 -11
- package/src/internal/plate-editor/plate-ui/code-node.tsx +0 -12
- package/src/internal/plate-editor/plate-ui/column-node-static.tsx +0 -65
- package/src/internal/plate-editor/plate-ui/column-node.tsx +0 -24
- package/src/internal/plate-editor/plate-ui/command.tsx +0 -202
- package/src/internal/plate-editor/plate-ui/comment-node-static.tsx +0 -12
- package/src/internal/plate-editor/plate-ui/comment-node.tsx +0 -45
- package/src/internal/plate-editor/plate-ui/comment-toolbar-button.tsx +0 -24
- package/src/internal/plate-editor/plate-ui/comment.tsx +0 -619
- package/src/internal/plate-editor/plate-ui/cursor-overlay.tsx +0 -85
- package/src/internal/plate-editor/plate-ui/date-node-static.tsx +0 -43
- package/src/internal/plate-editor/plate-ui/date-node.tsx +0 -54
- package/src/internal/plate-editor/plate-ui/dialog.tsx +0 -445
- package/src/internal/plate-editor/plate-ui/dropdown-menu.tsx +0 -264
- package/src/internal/plate-editor/plate-ui/editor-static.tsx +0 -40
- package/src/internal/plate-editor/plate-ui/editor.tsx +0 -146
- package/src/internal/plate-editor/plate-ui/emoji-node.tsx +0 -48
- package/src/internal/plate-editor/plate-ui/emoji-toolbar-button.tsx +0 -626
- package/src/internal/plate-editor/plate-ui/equation-node-static.tsx +0 -155
- package/src/internal/plate-editor/plate-ui/equation-node.tsx +0 -226
- package/src/internal/plate-editor/plate-ui/equation-toolbar-button.tsx +0 -26
- package/src/internal/plate-editor/plate-ui/export-toolbar-button.tsx +0 -206
- package/src/internal/plate-editor/plate-ui/fixed-toolbar-buttons.tsx +0 -157
- package/src/internal/plate-editor/plate-ui/fixed-toolbar.tsx +0 -25
- package/src/internal/plate-editor/plate-ui/floating-discussion.tsx +0 -1129
- package/src/internal/plate-editor/plate-ui/floating-toolbar-buttons.tsx +0 -129
- package/src/internal/plate-editor/plate-ui/floating-toolbar.tsx +0 -97
- package/src/internal/plate-editor/plate-ui/font-color-toolbar-button.tsx +0 -209
- package/src/internal/plate-editor/plate-ui/font-size-toolbar-button.tsx +0 -152
- package/src/internal/plate-editor/plate-ui/ghost-text.tsx +0 -20
- package/src/internal/plate-editor/plate-ui/heading-node-static.tsx +0 -52
- package/src/internal/plate-editor/plate-ui/heading-node.tsx +0 -56
- package/src/internal/plate-editor/plate-ui/highlight-node-static.tsx +0 -9
- package/src/internal/plate-editor/plate-ui/highlight-node.tsx +0 -11
- package/src/internal/plate-editor/plate-ui/history-toolbar-button.tsx +0 -50
- package/src/internal/plate-editor/plate-ui/hover-card.tsx +0 -7
- package/src/internal/plate-editor/plate-ui/hr-node-static.tsx +0 -18
- package/src/internal/plate-editor/plate-ui/hr-node.tsx +0 -28
- package/src/internal/plate-editor/plate-ui/import-toolbar-button.tsx +0 -122
- package/src/internal/plate-editor/plate-ui/indent-toolbar-button.tsx +0 -32
- package/src/internal/plate-editor/plate-ui/inline-combobox.tsx +0 -409
- package/src/internal/plate-editor/plate-ui/input.tsx +0 -37
- package/src/internal/plate-editor/plate-ui/insert-toolbar-button.tsx +0 -258
- package/src/internal/plate-editor/plate-ui/label.tsx +0 -1
- package/src/internal/plate-editor/plate-ui/line-height-toolbar-button.tsx +0 -69
- package/src/internal/plate-editor/plate-ui/link-node-static.tsx +0 -15
- package/src/internal/plate-editor/plate-ui/link-node.tsx +0 -33
- package/src/internal/plate-editor/plate-ui/link-toolbar-button.tsx +0 -28
- package/src/internal/plate-editor/plate-ui/link-toolbar.tsx +0 -147
- package/src/internal/plate-editor/plate-ui/list-toolbar-button.tsx +0 -177
- package/src/internal/plate-editor/plate-ui/mark-toolbar-button.tsx +0 -34
- package/src/internal/plate-editor/plate-ui/media-audio-node-static.tsx +0 -21
- package/src/internal/plate-editor/plate-ui/media-audio-node.tsx +0 -32
- package/src/internal/plate-editor/plate-ui/media-embed-node.tsx +0 -103
- package/src/internal/plate-editor/plate-ui/media-file-node-static.tsx +0 -30
- package/src/internal/plate-editor/plate-ui/media-file-node.tsx +0 -52
- package/src/internal/plate-editor/plate-ui/media-image-node-static.tsx +0 -37
- package/src/internal/plate-editor/plate-ui/media-image-node.tsx +0 -183
- package/src/internal/plate-editor/plate-ui/media-placeholder-node.tsx +0 -441
- package/src/internal/plate-editor/plate-ui/media-preview-dialog.tsx +0 -127
- package/src/internal/plate-editor/plate-ui/media-toolbar-button.tsx +0 -227
- package/src/internal/plate-editor/plate-ui/media-toolbar.tsx +0 -214
- package/src/internal/plate-editor/plate-ui/media-upload-toast.tsx +0 -73
- package/src/internal/plate-editor/plate-ui/media-video-node-static.tsx +0 -35
- package/src/internal/plate-editor/plate-ui/media-video-node.tsx +0 -119
- package/src/internal/plate-editor/plate-ui/mention-node-static.tsx +0 -46
- package/src/internal/plate-editor/plate-ui/mention-node.tsx +0 -79
- package/src/internal/plate-editor/plate-ui/menu.tsx +0 -539
- package/src/internal/plate-editor/plate-ui/mode-toolbar-button.tsx +0 -124
- package/src/internal/plate-editor/plate-ui/more-toolbar-button.tsx +0 -34
- package/src/internal/plate-editor/plate-ui/paragraph-node-static.tsx +0 -15
- package/src/internal/plate-editor/plate-ui/paragraph-node.tsx +0 -16
- package/src/internal/plate-editor/plate-ui/popover.tsx +0 -75
- package/src/internal/plate-editor/plate-ui/progress.tsx +0 -1
- package/src/internal/plate-editor/plate-ui/remote-cursor-overlay.tsx +0 -79
- package/src/internal/plate-editor/plate-ui/resize-handle.tsx +0 -86
- package/src/internal/plate-editor/plate-ui/separator.tsx +0 -41
- package/src/internal/plate-editor/plate-ui/slash-node.tsx +0 -433
- package/src/internal/plate-editor/plate-ui/spinner.tsx +0 -1
- package/src/internal/plate-editor/plate-ui/suggestion-node-static.tsx +0 -35
- package/src/internal/plate-editor/plate-ui/suggestion-node.tsx +0 -166
- package/src/internal/plate-editor/plate-ui/suggestion-toolbar-button.tsx +0 -24
- package/src/internal/plate-editor/plate-ui/table-node-static.tsx +0 -84
- package/src/internal/plate-editor/plate-ui/table-node.tsx +0 -283
- package/src/internal/plate-editor/plate-ui/table-toolbar-button.tsx +0 -252
- package/src/internal/plate-editor/plate-ui/tabs.tsx +0 -3
- package/src/internal/plate-editor/plate-ui/textarea.tsx +0 -57
- package/src/internal/plate-editor/plate-ui/toc-node-static.tsx +0 -142
- package/src/internal/plate-editor/plate-ui/toc-node.tsx +0 -57
- package/src/internal/plate-editor/plate-ui/toc-sidebar.tsx +0 -48
- package/src/internal/plate-editor/plate-ui/toggle-node-static.tsx +0 -18
- package/src/internal/plate-editor/plate-ui/toggle-node.tsx +0 -33
- package/src/internal/plate-editor/plate-ui/toggle-toolbar-button.tsx +0 -24
- package/src/internal/plate-editor/plate-ui/toggle.tsx +0 -3
- package/src/internal/plate-editor/plate-ui/toolbar.tsx +0 -378
- package/src/internal/plate-editor/plate-ui/tooltip.tsx +0 -148
- package/src/internal/plate-editor/plate-ui/turn-into-toolbar-button.tsx +0 -175
- package/src/internal/plate-editor/types/index.ts +0 -22
- package/src/internal/plate-editor/vite.ts +0 -284
- package/src/internal/sheets/components/univer-sheets.tsx +0 -1104
- package/src/internal/sheets/i18n/context.tsx +0 -183
- package/src/internal/sheets/i18n/index.ts +0 -19
- package/src/internal/sheets/i18n/locales/de.json +0 -21
- package/src/internal/sheets/i18n/locales/el.json +0 -21
- package/src/internal/sheets/i18n/locales/en.json +0 -21
- package/src/internal/sheets/i18n/locales/es.json +0 -21
- package/src/internal/sheets/i18n/locales/fr.json +0 -21
- package/src/internal/sheets/i18n/locales/it.json +0 -21
- package/src/internal/sheets/i18n/locales/pt.json +0 -21
- package/src/internal/sheets/i18n/locales/sl.json +0 -21
- package/src/internal/sheets/i18n/locales/tr.json +0 -21
- package/src/internal/sheets/i18n/types.ts +0 -23
- package/src/internal/sheets/i18n/use-translation.ts +0 -17
- package/src/internal/sheets/index.ts +0 -14
- package/src/internal/sheets/types/css.d.ts +0 -11
- package/src/internal/sheets/types/index.ts +0 -260
- package/src/internal/sheets/xlsx.ts +0 -1169
- package/src/lib/api-client.ts +0 -77
- package/src/lib/assistant-api-actions.ts +0 -549
- package/src/lib/assistant-config.tsx +0 -75
- package/src/lib/class-utils.ts +0 -40
- package/src/lib/index.ts +0 -7
- package/src/lib/message-utils.ts +0 -131
- package/src/tools/tools-schema.json +0 -512
- package/src/types/index.ts +0 -235
- package/src/views/assistant-view.tsx +0 -1137
- package/src/views/canvas-app.tsx +0 -839
- package/src/views/canvas-code.tsx +0 -93
- package/src/views/canvas-deep-research.tsx +0 -44
- package/src/views/canvas-image.tsx +0 -25
- package/src/views/canvas-record-view.tsx +0 -285
- package/src/views/canvas-spreadsheet.tsx +0 -125
- package/src/views/canvas-text.tsx +0 -52
- package/src/views/canvas.tsx +0 -274
- package/src/views/chat-panel.tsx +0 -149
- package/src/views/index.ts +0 -20
- package/src/views/memories-panel.tsx +0 -365
- package/src/views/message-list.tsx +0 -370
- package/src/views/project-detail.tsx +0 -257
- package/src/views/projects-panel.tsx +0 -131
- package/src/views/sessions-list.tsx +0 -98
- package/src/views/sidebar-content.tsx +0 -256
- package/src/views/work-detail.tsx +0 -98
- package/src/vite.ts +0 -64
- package/src/worker.ts +0 -203
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { type TEquationElement } from 'platejs';
|
|
3
|
-
|
|
4
|
-
import { getEquationHtml } from '@platejs/math';
|
|
5
|
-
|
|
6
|
-
import { SlateElement, type SlateElementProps } from 'platejs/static';
|
|
7
|
-
|
|
8
|
-
import { cn } from '@docyrus/ui-pro-shared/lib/utils';
|
|
9
|
-
|
|
10
|
-
export function EquationElementStatic(
|
|
11
|
-
props: SlateElementProps<TEquationElement>
|
|
12
|
-
) {
|
|
13
|
-
const { element } = props;
|
|
14
|
-
|
|
15
|
-
const html = getEquationHtml({
|
|
16
|
-
element,
|
|
17
|
-
options: {
|
|
18
|
-
displayMode: true,
|
|
19
|
-
errorColor: '#cc0000',
|
|
20
|
-
fleqn: false,
|
|
21
|
-
leqno: false,
|
|
22
|
-
macros: { '\\f': '#1f(#2)' },
|
|
23
|
-
output: 'htmlAndMathml',
|
|
24
|
-
strict: 'warn',
|
|
25
|
-
throwOnError: false,
|
|
26
|
-
trust: false
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
return (
|
|
31
|
-
<SlateElement className="my-1" {...props}>
|
|
32
|
-
<div
|
|
33
|
-
className={cn(
|
|
34
|
-
'flex select-none items-center justify-center rounded-sm',
|
|
35
|
-
element.texExpression.length === 0 ? 'bg-muted p-3' : 'px-2 py-1'
|
|
36
|
-
)}>
|
|
37
|
-
<span
|
|
38
|
-
dangerouslySetInnerHTML={{
|
|
39
|
-
__html: html
|
|
40
|
-
}} />
|
|
41
|
-
</div>
|
|
42
|
-
{props.children}
|
|
43
|
-
</SlateElement>
|
|
44
|
-
);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export function InlineEquationElementStatic(
|
|
48
|
-
props: SlateElementProps<TEquationElement>
|
|
49
|
-
) {
|
|
50
|
-
const { element } = props;
|
|
51
|
-
|
|
52
|
-
const html = getEquationHtml({
|
|
53
|
-
element,
|
|
54
|
-
options: {
|
|
55
|
-
displayMode: true,
|
|
56
|
-
errorColor: '#cc0000',
|
|
57
|
-
fleqn: false,
|
|
58
|
-
leqno: false,
|
|
59
|
-
macros: { '\\f': '#1f(#2)' },
|
|
60
|
-
output: 'htmlAndMathml',
|
|
61
|
-
strict: 'warn',
|
|
62
|
-
throwOnError: false,
|
|
63
|
-
trust: false
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
return (
|
|
68
|
-
<SlateElement
|
|
69
|
-
className="inline-block select-none rounded-sm [&_.katex-display]:my-0"
|
|
70
|
-
{...props}>
|
|
71
|
-
<div
|
|
72
|
-
className={cn(
|
|
73
|
-
'after:-top-0.5 after:-left-1 after:absolute after:inset-0 after:z-1 after:h-[calc(100%)+4px] after:w-[calc(100%+8px)] after:rounded-sm after:content-[""]',
|
|
74
|
-
'h-6',
|
|
75
|
-
element.texExpression.length === 0
|
|
76
|
-
&& 'text-muted-foreground after:bg-neutral-500/10'
|
|
77
|
-
)}>
|
|
78
|
-
<span
|
|
79
|
-
className={cn(
|
|
80
|
-
element.texExpression.length === 0 && 'hidden',
|
|
81
|
-
'font-mono leading-none'
|
|
82
|
-
)}
|
|
83
|
-
dangerouslySetInnerHTML={{
|
|
84
|
-
__html: html
|
|
85
|
-
}} />
|
|
86
|
-
</div>
|
|
87
|
-
{props.children}
|
|
88
|
-
</SlateElement>
|
|
89
|
-
);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* DOCX-compatible block equation component.
|
|
94
|
-
* Displays LaTeX source code with styling.
|
|
95
|
-
*/
|
|
96
|
-
export function EquationElementDocx(
|
|
97
|
-
props: SlateElementProps<TEquationElement>
|
|
98
|
-
) {
|
|
99
|
-
const { element } = props;
|
|
100
|
-
|
|
101
|
-
if (!element.texExpression || element.texExpression.length === 0) {
|
|
102
|
-
return (
|
|
103
|
-
<SlateElement {...props}>
|
|
104
|
-
<p style={{ color: '#888', fontStyle: 'italic' }}>[Empty equation]</p>
|
|
105
|
-
{props.children}
|
|
106
|
-
</SlateElement>
|
|
107
|
-
);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
return (
|
|
111
|
-
<SlateElement {...props}>
|
|
112
|
-
<p
|
|
113
|
-
style={{
|
|
114
|
-
fontFamily: 'Cambria Math, Consolas, monospace',
|
|
115
|
-
fontSize: '12pt',
|
|
116
|
-
margin: '8pt 0',
|
|
117
|
-
textAlign: 'center'
|
|
118
|
-
}}>
|
|
119
|
-
{element.texExpression}
|
|
120
|
-
</p>
|
|
121
|
-
{props.children}
|
|
122
|
-
</SlateElement>
|
|
123
|
-
);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* DOCX-compatible inline equation component.
|
|
128
|
-
* Displays LaTeX source code inline.
|
|
129
|
-
*/
|
|
130
|
-
export function InlineEquationElementDocx(
|
|
131
|
-
props: SlateElementProps<TEquationElement>
|
|
132
|
-
) {
|
|
133
|
-
const { element } = props;
|
|
134
|
-
|
|
135
|
-
if (!element.texExpression || element.texExpression.length === 0) {
|
|
136
|
-
return (
|
|
137
|
-
<SlateElement {...props} as="span">
|
|
138
|
-
<span style={{ color: '#888', fontStyle: 'italic' }}>[equation]</span>
|
|
139
|
-
{props.children}
|
|
140
|
-
</SlateElement>
|
|
141
|
-
);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
return (
|
|
145
|
-
<SlateElement {...props} as="span">
|
|
146
|
-
<span
|
|
147
|
-
style={{
|
|
148
|
-
fontFamily: 'Cambria Math, Consolas, monospace'
|
|
149
|
-
}}>
|
|
150
|
-
{element.texExpression}
|
|
151
|
-
</span>
|
|
152
|
-
{props.children}
|
|
153
|
-
</SlateElement>
|
|
154
|
-
);
|
|
155
|
-
}
|
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { useEffect, useRef, useState } from 'react';
|
|
4
|
-
|
|
5
|
-
import { type TEquationElement } from 'platejs';
|
|
6
|
-
|
|
7
|
-
import { useEquationElement, useEquationInput } from '@platejs/math/react';
|
|
8
|
-
import { BlockSelectionPlugin } from '@platejs/selection/react';
|
|
9
|
-
import { CornerDownLeftIcon, RadicalIcon } from 'lucide-react';
|
|
10
|
-
import {
|
|
11
|
-
createPrimitiveComponent,
|
|
12
|
-
PlateElement,
|
|
13
|
-
type PlateElementProps,
|
|
14
|
-
useEditorRef,
|
|
15
|
-
useEditorSelector,
|
|
16
|
-
useElement,
|
|
17
|
-
useReadOnly,
|
|
18
|
-
useSelected
|
|
19
|
-
} from 'platejs/react';
|
|
20
|
-
|
|
21
|
-
import { cn } from '@docyrus/ui-pro-shared/lib/utils';
|
|
22
|
-
|
|
23
|
-
import { BlockActionButton } from './block-context-menu';
|
|
24
|
-
import { Button } from './button';
|
|
25
|
-
import { Popover, PopoverContent, PopoverTrigger } from './popover';
|
|
26
|
-
import { TextareaAutosize, type TextareaAutosizeProps } from './textarea';
|
|
27
|
-
|
|
28
|
-
export function EquationElement(props: PlateElementProps) {
|
|
29
|
-
const element = useElement<TEquationElement>();
|
|
30
|
-
const selected = useSelected();
|
|
31
|
-
const [open, setOpen] = useState(selected);
|
|
32
|
-
const katexRef = useRef<HTMLDivElement | null>(null);
|
|
33
|
-
|
|
34
|
-
useEquationElement({
|
|
35
|
-
element,
|
|
36
|
-
katexRef,
|
|
37
|
-
options: {
|
|
38
|
-
displayMode: true,
|
|
39
|
-
errorColor: '#cc0000',
|
|
40
|
-
fleqn: false,
|
|
41
|
-
leqno: false,
|
|
42
|
-
macros: { '\\f': '#1f(#2)' },
|
|
43
|
-
output: 'htmlAndMathml',
|
|
44
|
-
strict: 'warn',
|
|
45
|
-
throwOnError: false,
|
|
46
|
-
trust: false
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
return (
|
|
51
|
-
<PlateElement className="my-1" {...props}>
|
|
52
|
-
<Popover modal={false} onOpenChange={setOpen} open={open}>
|
|
53
|
-
<PopoverTrigger asChild>
|
|
54
|
-
<div
|
|
55
|
-
className={cn(
|
|
56
|
-
'group flex cursor-pointer select-none items-center justify-center rounded-sm hover:bg-primary/10 data-[selected=true]:bg-primary/10',
|
|
57
|
-
element.texExpression.length === 0 ? 'bg-muted p-3 pr-9' : 'px-2 py-1'
|
|
58
|
-
)}
|
|
59
|
-
contentEditable={false}
|
|
60
|
-
data-selected={selected}
|
|
61
|
-
role="button">
|
|
62
|
-
{element.texExpression.length > 0 ? (
|
|
63
|
-
<span ref={katexRef} />
|
|
64
|
-
) : (
|
|
65
|
-
<div className="flex h-7 w-full items-center gap-2 whitespace-nowrap text-muted-foreground text-sm">
|
|
66
|
-
<RadicalIcon className="size-6 text-muted-foreground/80" />
|
|
67
|
-
<div>Add a Tex equation</div>
|
|
68
|
-
</div>
|
|
69
|
-
)}
|
|
70
|
-
</div>
|
|
71
|
-
</PopoverTrigger>
|
|
72
|
-
|
|
73
|
-
<EquationPopoverContent
|
|
74
|
-
isInline={false}
|
|
75
|
-
open={open}
|
|
76
|
-
placeholder={'f(x) = \\begin{cases}\n x^2, &\\quad x > 0 \\\\\n 0, &\\quad x = 0 \\\\\n -x^2, &\\quad x < 0\n\\end{cases}'}
|
|
77
|
-
setOpen={setOpen}
|
|
78
|
-
variant="equation" />
|
|
79
|
-
</Popover>
|
|
80
|
-
|
|
81
|
-
<BlockActionButton />
|
|
82
|
-
|
|
83
|
-
{props.children}
|
|
84
|
-
</PlateElement>
|
|
85
|
-
);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export function InlineEquationElement(
|
|
89
|
-
props: PlateElementProps<TEquationElement>
|
|
90
|
-
) {
|
|
91
|
-
const { element } = props;
|
|
92
|
-
const katexRef = useRef<HTMLDivElement | null>(null);
|
|
93
|
-
const selected = useSelected();
|
|
94
|
-
const isCollapsed = useEditorSelector(
|
|
95
|
-
editor => editor?.api?.isCollapsed() ?? false,
|
|
96
|
-
[]
|
|
97
|
-
);
|
|
98
|
-
const [open, setOpen] = useState(selected && isCollapsed);
|
|
99
|
-
|
|
100
|
-
// Sync popover open state from editor selection
|
|
101
|
-
useEffect(() => {
|
|
102
|
-
if (selected && isCollapsed) {
|
|
103
|
-
setOpen(true);
|
|
104
|
-
}
|
|
105
|
-
}, [selected, isCollapsed]);
|
|
106
|
-
|
|
107
|
-
useEquationElement({
|
|
108
|
-
element,
|
|
109
|
-
katexRef,
|
|
110
|
-
options: {
|
|
111
|
-
displayMode: true,
|
|
112
|
-
errorColor: '#cc0000',
|
|
113
|
-
fleqn: false,
|
|
114
|
-
leqno: false,
|
|
115
|
-
macros: { '\\f': '#1f(#2)' },
|
|
116
|
-
output: 'htmlAndMathml',
|
|
117
|
-
strict: 'warn',
|
|
118
|
-
throwOnError: false,
|
|
119
|
-
trust: false
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
return (
|
|
124
|
-
<PlateElement
|
|
125
|
-
className="mx-1 inline-block select-none rounded-sm [&_.katex-display]:my-0!"
|
|
126
|
-
{...props}>
|
|
127
|
-
<Popover modal={false} onOpenChange={setOpen} open={open}>
|
|
128
|
-
<PopoverTrigger asChild>
|
|
129
|
-
<div
|
|
130
|
-
className={cn(
|
|
131
|
-
'after:-top-0.5 after:-left-1 after:absolute after:inset-0 after:z-1 after:h-[calc(100%)+4px] after:w-[calc(100%+8px)] after:rounded-sm after:content-[""]',
|
|
132
|
-
'h-6',
|
|
133
|
-
((element.texExpression.length > 0 && open) || selected)
|
|
134
|
-
&& 'after:bg-brand/15',
|
|
135
|
-
element.texExpression.length === 0
|
|
136
|
-
&& 'text-muted-foreground after:bg-neutral-500/10'
|
|
137
|
-
)}
|
|
138
|
-
contentEditable={false}>
|
|
139
|
-
<span
|
|
140
|
-
className={cn(
|
|
141
|
-
element.texExpression.length === 0 && 'hidden',
|
|
142
|
-
'font-mono leading-none'
|
|
143
|
-
)}
|
|
144
|
-
ref={katexRef} />
|
|
145
|
-
{element.texExpression.length === 0 && (
|
|
146
|
-
<span>
|
|
147
|
-
<RadicalIcon className="mr-1 inline-block h-[19px] w-4 py-[1.5px] align-text-bottom" />
|
|
148
|
-
New equation
|
|
149
|
-
</span>
|
|
150
|
-
)}
|
|
151
|
-
</div>
|
|
152
|
-
</PopoverTrigger>
|
|
153
|
-
|
|
154
|
-
<EquationPopoverContent
|
|
155
|
-
className="my-auto"
|
|
156
|
-
isInline={true}
|
|
157
|
-
open={open}
|
|
158
|
-
placeholder="E = mc^2"
|
|
159
|
-
setOpen={setOpen}
|
|
160
|
-
variant="equationInline" />
|
|
161
|
-
</Popover>
|
|
162
|
-
|
|
163
|
-
{props.children}
|
|
164
|
-
</PlateElement>
|
|
165
|
-
);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
const EquationInput = createPrimitiveComponent(TextareaAutosize)({
|
|
169
|
-
propsHook: useEquationInput
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
function EquationPopoverContent({
|
|
173
|
-
className,
|
|
174
|
-
isInline,
|
|
175
|
-
open,
|
|
176
|
-
setOpen,
|
|
177
|
-
...props
|
|
178
|
-
}: {
|
|
179
|
-
isInline: boolean;
|
|
180
|
-
open: boolean;
|
|
181
|
-
setOpen: (open: boolean) => void;
|
|
182
|
-
} & TextareaAutosizeProps) {
|
|
183
|
-
const editor = useEditorRef();
|
|
184
|
-
const readOnly = useReadOnly();
|
|
185
|
-
const element = useElement<TEquationElement>();
|
|
186
|
-
|
|
187
|
-
useEffect(() => {
|
|
188
|
-
if (isInline && open) {
|
|
189
|
-
setOpen(true);
|
|
190
|
-
}
|
|
191
|
-
}, [isInline, open, setOpen]);
|
|
192
|
-
|
|
193
|
-
if (readOnly) return null;
|
|
194
|
-
|
|
195
|
-
const onClose = () => {
|
|
196
|
-
setOpen(false);
|
|
197
|
-
|
|
198
|
-
if (isInline) {
|
|
199
|
-
editor.tf.select(element, { focus: true, next: true });
|
|
200
|
-
} else {
|
|
201
|
-
editor
|
|
202
|
-
.getApi(BlockSelectionPlugin)
|
|
203
|
-
.blockSelection.set(element.id as string);
|
|
204
|
-
}
|
|
205
|
-
};
|
|
206
|
-
|
|
207
|
-
return (
|
|
208
|
-
<PopoverContent
|
|
209
|
-
className="flex gap-2"
|
|
210
|
-
contentEditable={false}
|
|
211
|
-
onEscapeKeyDown={(e) => {
|
|
212
|
-
e.preventDefault();
|
|
213
|
-
}}
|
|
214
|
-
variant="equation">
|
|
215
|
-
<EquationInput
|
|
216
|
-
autoFocus
|
|
217
|
-
className={cn('grow', className)}
|
|
218
|
-
state={{ isInline, open: true, onClose }}
|
|
219
|
-
{...props} />
|
|
220
|
-
|
|
221
|
-
<Button className="px-3" onClick={onClose} variant="brand">
|
|
222
|
-
Done <CornerDownLeftIcon className="size-3.5" />
|
|
223
|
-
</Button>
|
|
224
|
-
</PopoverContent>
|
|
225
|
-
);
|
|
226
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { type ComponentProps } from 'react';
|
|
4
|
-
|
|
5
|
-
import { insertInlineEquation } from '@platejs/math';
|
|
6
|
-
import { RadicalIcon } from 'lucide-react';
|
|
7
|
-
import { useEditorRef } from 'platejs/react';
|
|
8
|
-
|
|
9
|
-
import { ToolbarButton } from './toolbar';
|
|
10
|
-
|
|
11
|
-
export function InlineEquationToolbarButton(
|
|
12
|
-
props: ComponentProps<typeof ToolbarButton>
|
|
13
|
-
) {
|
|
14
|
-
const editor = useEditorRef();
|
|
15
|
-
|
|
16
|
-
return (
|
|
17
|
-
<ToolbarButton
|
|
18
|
-
tooltip="Mark as equation"
|
|
19
|
-
{...props}
|
|
20
|
-
onClick={() => {
|
|
21
|
-
insertInlineEquation(editor);
|
|
22
|
-
}}>
|
|
23
|
-
<RadicalIcon />
|
|
24
|
-
</ToolbarButton>
|
|
25
|
-
);
|
|
26
|
-
}
|
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { useState } from 'react';
|
|
4
|
-
|
|
5
|
-
import { type SlatePlugin, createSlateEditor } from 'platejs';
|
|
6
|
-
|
|
7
|
-
import { exportToDocx } from '@platejs/docx-io';
|
|
8
|
-
import { MarkdownPlugin } from '@platejs/markdown';
|
|
9
|
-
import { ArrowDownToLineIcon } from 'lucide-react';
|
|
10
|
-
import { useEditorRef } from 'platejs/react';
|
|
11
|
-
import { PlateStatic, serializeHtml } from 'platejs/static';
|
|
12
|
-
|
|
13
|
-
import {
|
|
14
|
-
DropdownMenu,
|
|
15
|
-
DropdownMenuContent,
|
|
16
|
-
DropdownMenuGroup,
|
|
17
|
-
DropdownMenuItem,
|
|
18
|
-
DropdownMenuPortal,
|
|
19
|
-
DropdownMenuTrigger,
|
|
20
|
-
type DropdownMenuProps
|
|
21
|
-
} from './dropdown-menu';
|
|
22
|
-
import { BaseEditorKit } from '../editor/editor-base-kit';
|
|
23
|
-
import { ToolbarButton } from './toolbar';
|
|
24
|
-
import { DocxExportKit } from '../editor/plugins/docx-export-kit';
|
|
25
|
-
|
|
26
|
-
const siteUrl = 'https://platejs.org';
|
|
27
|
-
|
|
28
|
-
export function ExportToolbarButton(props: DropdownMenuProps) {
|
|
29
|
-
const editor = useEditorRef();
|
|
30
|
-
const [open, setOpen] = useState(false);
|
|
31
|
-
|
|
32
|
-
const getCanvas = async () => {
|
|
33
|
-
const { default: html2canvas } = await import('html2canvas-pro');
|
|
34
|
-
|
|
35
|
-
const style = document.createElement('style');
|
|
36
|
-
|
|
37
|
-
document.head.append(style);
|
|
38
|
-
|
|
39
|
-
const canvas = await html2canvas(editor.api.toDOMNode(editor)!, {
|
|
40
|
-
onclone: (document: Document) => {
|
|
41
|
-
const editorElement = document.querySelector(
|
|
42
|
-
'[contenteditable="true"]'
|
|
43
|
-
);
|
|
44
|
-
|
|
45
|
-
if (editorElement) {
|
|
46
|
-
Array.from(editorElement.querySelectorAll('*')).forEach((element) => {
|
|
47
|
-
const existingStyle = element.getAttribute('style') || '';
|
|
48
|
-
|
|
49
|
-
element.setAttribute(
|
|
50
|
-
'style',
|
|
51
|
-
`${existingStyle}; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif !important`
|
|
52
|
-
);
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
style.remove();
|
|
59
|
-
|
|
60
|
-
return canvas;
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
const downloadFile = async (url: string, filename: string) => {
|
|
64
|
-
const response = await fetch(url);
|
|
65
|
-
|
|
66
|
-
const blob = await response.blob();
|
|
67
|
-
const blobUrl = window.URL.createObjectURL(blob);
|
|
68
|
-
|
|
69
|
-
const link = document.createElement('a');
|
|
70
|
-
|
|
71
|
-
link.href = blobUrl;
|
|
72
|
-
link.download = filename;
|
|
73
|
-
document.body.append(link);
|
|
74
|
-
link.click();
|
|
75
|
-
link.remove();
|
|
76
|
-
|
|
77
|
-
// Clean up the blob URL
|
|
78
|
-
window.URL.revokeObjectURL(blobUrl);
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
const exportToPdf = async () => {
|
|
82
|
-
const canvas = await getCanvas();
|
|
83
|
-
|
|
84
|
-
const PDFLib = await import('pdf-lib');
|
|
85
|
-
const pdfDoc = await PDFLib.PDFDocument.create();
|
|
86
|
-
const page = pdfDoc.addPage([canvas.width, canvas.height]);
|
|
87
|
-
const imageEmbed = await pdfDoc.embedPng(canvas.toDataURL('PNG'));
|
|
88
|
-
const { height, width } = imageEmbed.scale(1);
|
|
89
|
-
|
|
90
|
-
page.drawImage(imageEmbed, {
|
|
91
|
-
height,
|
|
92
|
-
width,
|
|
93
|
-
x: 0,
|
|
94
|
-
y: 0
|
|
95
|
-
});
|
|
96
|
-
const pdfBase64 = await pdfDoc.saveAsBase64({ dataUri: true });
|
|
97
|
-
|
|
98
|
-
await downloadFile(pdfBase64, 'plate.pdf');
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
const exportToImage = async () => {
|
|
102
|
-
const canvas = await getCanvas();
|
|
103
|
-
|
|
104
|
-
await downloadFile(canvas.toDataURL('image/png'), 'plate.png');
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
const exportToHtml = async () => {
|
|
108
|
-
const editorStatic = createSlateEditor({
|
|
109
|
-
plugins: BaseEditorKit,
|
|
110
|
-
value: editor.children
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
const editorHtml = await serializeHtml(editorStatic, {
|
|
114
|
-
editorComponent: PlateStatic,
|
|
115
|
-
props: { style: { padding: '0 calc(50% - 350px)', paddingBottom: '' } }
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
const tailwindCss = `<link rel="stylesheet" href="${siteUrl}/tailwind.css">`;
|
|
119
|
-
const katexCss = `<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.16.18/dist/katex.css" integrity="sha384-9PvLvaiSKCPkFKB1ZsEoTjgnJn+O3KvEwtsz37/XrkYft3DTk2gHdYvd9oWgW3tV" crossorigin="anonymous">`;
|
|
120
|
-
|
|
121
|
-
const html = `<!DOCTYPE html>
|
|
122
|
-
<html lang="en">
|
|
123
|
-
<head>
|
|
124
|
-
<meta charset="utf-8" />
|
|
125
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
126
|
-
<meta name="color-scheme" content="light dark" />
|
|
127
|
-
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
|
128
|
-
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
|
129
|
-
<link
|
|
130
|
-
href="https://fonts.googleapis.com/css2?family=Inter:wght@400..700&family=JetBrains+Mono:wght@400..700&display=swap"
|
|
131
|
-
rel="stylesheet"
|
|
132
|
-
/>
|
|
133
|
-
${tailwindCss}
|
|
134
|
-
${katexCss}
|
|
135
|
-
<style>
|
|
136
|
-
:root {
|
|
137
|
-
--font-sans: 'Inter', 'Inter Fallback';
|
|
138
|
-
--font-mono: 'JetBrains Mono', 'JetBrains Mono Fallback';
|
|
139
|
-
}
|
|
140
|
-
</style>
|
|
141
|
-
</head>
|
|
142
|
-
<body>
|
|
143
|
-
${editorHtml}
|
|
144
|
-
</body>
|
|
145
|
-
</html>`;
|
|
146
|
-
|
|
147
|
-
const url = `data:text/html;charset=utf-8,${encodeURIComponent(html)}`;
|
|
148
|
-
|
|
149
|
-
await downloadFile(url, 'plate.html');
|
|
150
|
-
};
|
|
151
|
-
|
|
152
|
-
const exportToMarkdown = async () => {
|
|
153
|
-
const md = editor.getApi(MarkdownPlugin).markdown.serialize();
|
|
154
|
-
const url = `data:text/markdown;charset=utf-8,${encodeURIComponent(md)}`;
|
|
155
|
-
|
|
156
|
-
await downloadFile(url, 'plate.md');
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
const exportToWord = async () => {
|
|
160
|
-
const blob = await exportToDocx(editor.children, {
|
|
161
|
-
editorPlugins: [...BaseEditorKit, ...DocxExportKit] as SlatePlugin[]
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
const url = URL.createObjectURL(blob);
|
|
165
|
-
const link = document.createElement('a');
|
|
166
|
-
|
|
167
|
-
link.href = url;
|
|
168
|
-
link.download = 'plate.docx';
|
|
169
|
-
document.body.append(link);
|
|
170
|
-
link.click();
|
|
171
|
-
link.remove();
|
|
172
|
-
URL.revokeObjectURL(url);
|
|
173
|
-
};
|
|
174
|
-
|
|
175
|
-
return (
|
|
176
|
-
<DropdownMenu open={open} onOpenChange={setOpen} modal={false} {...props}>
|
|
177
|
-
<DropdownMenuTrigger asChild>
|
|
178
|
-
<ToolbarButton pressed={open} tooltip="Export" isDropdown>
|
|
179
|
-
<ArrowDownToLineIcon className="size-4" />
|
|
180
|
-
</ToolbarButton>
|
|
181
|
-
</DropdownMenuTrigger>
|
|
182
|
-
|
|
183
|
-
<DropdownMenuPortal>
|
|
184
|
-
<DropdownMenuContent align="start">
|
|
185
|
-
<DropdownMenuGroup>
|
|
186
|
-
<DropdownMenuItem onSelect={exportToHtml}>
|
|
187
|
-
Export as HTML
|
|
188
|
-
</DropdownMenuItem>
|
|
189
|
-
<DropdownMenuItem onSelect={exportToPdf}>
|
|
190
|
-
Export as PDF
|
|
191
|
-
</DropdownMenuItem>
|
|
192
|
-
<DropdownMenuItem onSelect={exportToImage}>
|
|
193
|
-
Export as Image
|
|
194
|
-
</DropdownMenuItem>
|
|
195
|
-
<DropdownMenuItem onSelect={exportToMarkdown}>
|
|
196
|
-
Export as Markdown
|
|
197
|
-
</DropdownMenuItem>
|
|
198
|
-
<DropdownMenuItem onSelect={exportToWord}>
|
|
199
|
-
Export as Word
|
|
200
|
-
</DropdownMenuItem>
|
|
201
|
-
</DropdownMenuGroup>
|
|
202
|
-
</DropdownMenuContent>
|
|
203
|
-
</DropdownMenuPortal>
|
|
204
|
-
</DropdownMenu>
|
|
205
|
-
);
|
|
206
|
-
}
|