@docyrus/ui-pro-ai-assistant 0.0.2 → 0.0.5
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/dist/components/assistant-animations.d.ts +3 -3
- package/dist/docy-assistant.d.ts +1 -1
- package/dist/index.js +74 -47
- package/dist/index.js.map +1 -1
- package/dist/styles.css +5137 -0
- package/dist/types/index.d.ts +3 -3
- package/dist/views/assistant-view.d.ts +2 -2
- package/package.json +38 -36
- 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,211 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
type AutoformatRule,
|
|
5
|
-
AutoformatPlugin,
|
|
6
|
-
autoformatArrow,
|
|
7
|
-
autoformatLegal,
|
|
8
|
-
autoformatLegalHtml,
|
|
9
|
-
autoformatMath,
|
|
10
|
-
autoformatPunctuation,
|
|
11
|
-
autoformatSmartQuotes
|
|
12
|
-
} from '@platejs/autoformat';
|
|
13
|
-
|
|
14
|
-
import { insertEmptyCodeBlock } from '@platejs/code-block';
|
|
15
|
-
import { toggleList } from '@platejs/list';
|
|
16
|
-
import { openNextToggles } from '@platejs/toggle/react';
|
|
17
|
-
import { KEYS } from 'platejs';
|
|
18
|
-
|
|
19
|
-
const autoformatMarks: AutoformatRule[] = [
|
|
20
|
-
{
|
|
21
|
-
match: '***',
|
|
22
|
-
mode: 'mark',
|
|
23
|
-
type: [KEYS.bold, KEYS.italic]
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
match: '__*',
|
|
27
|
-
mode: 'mark',
|
|
28
|
-
type: [KEYS.underline, KEYS.italic]
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
match: '__**',
|
|
32
|
-
mode: 'mark',
|
|
33
|
-
type: [KEYS.underline, KEYS.bold]
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
match: '___***',
|
|
37
|
-
mode: 'mark',
|
|
38
|
-
type: [KEYS.underline, KEYS.bold, KEYS.italic]
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
match: '**',
|
|
42
|
-
mode: 'mark',
|
|
43
|
-
type: KEYS.bold
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
match: '__',
|
|
47
|
-
mode: 'mark',
|
|
48
|
-
type: KEYS.underline
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
match: '*',
|
|
52
|
-
mode: 'mark',
|
|
53
|
-
type: KEYS.italic
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
match: '_',
|
|
57
|
-
mode: 'mark',
|
|
58
|
-
type: KEYS.italic
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
match: '~~',
|
|
62
|
-
mode: 'mark',
|
|
63
|
-
type: KEYS.strikethrough
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
match: '^',
|
|
67
|
-
mode: 'mark',
|
|
68
|
-
type: KEYS.sup
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
match: '~',
|
|
72
|
-
mode: 'mark',
|
|
73
|
-
type: KEYS.sub
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
match: '`',
|
|
77
|
-
mode: 'mark',
|
|
78
|
-
type: KEYS.code
|
|
79
|
-
}
|
|
80
|
-
];
|
|
81
|
-
|
|
82
|
-
const autoformatBlocks: AutoformatRule[] = [
|
|
83
|
-
{
|
|
84
|
-
match: '# ',
|
|
85
|
-
mode: 'block',
|
|
86
|
-
type: KEYS.h1
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
match: '## ',
|
|
90
|
-
mode: 'block',
|
|
91
|
-
type: KEYS.h2
|
|
92
|
-
},
|
|
93
|
-
{
|
|
94
|
-
match: '### ',
|
|
95
|
-
mode: 'block',
|
|
96
|
-
type: KEYS.h3
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
match: '> ',
|
|
100
|
-
mode: 'block',
|
|
101
|
-
type: KEYS.blockquote
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
match: '```',
|
|
105
|
-
mode: 'block',
|
|
106
|
-
type: KEYS.codeBlock,
|
|
107
|
-
format: (editor) => {
|
|
108
|
-
insertEmptyCodeBlock(editor, {
|
|
109
|
-
defaultType: KEYS.p,
|
|
110
|
-
insertNodesOptions: { select: true }
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
},
|
|
114
|
-
{
|
|
115
|
-
match: '+ ',
|
|
116
|
-
mode: 'block',
|
|
117
|
-
preFormat: openNextToggles,
|
|
118
|
-
type: KEYS.toggle
|
|
119
|
-
},
|
|
120
|
-
{
|
|
121
|
-
match: ['---', '\u2014-', '___ '],
|
|
122
|
-
mode: 'block',
|
|
123
|
-
type: KEYS.hr,
|
|
124
|
-
format: (editor) => {
|
|
125
|
-
editor.tf.setNodes({ type: KEYS.hr });
|
|
126
|
-
editor.tf.insertNodes({
|
|
127
|
-
children: [{ text: '' }],
|
|
128
|
-
type: KEYS.p
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
];
|
|
133
|
-
|
|
134
|
-
const autoformatLists: AutoformatRule[] = [
|
|
135
|
-
{
|
|
136
|
-
match: ['* ', '- '],
|
|
137
|
-
mode: 'block',
|
|
138
|
-
type: 'list',
|
|
139
|
-
format: (editor) => {
|
|
140
|
-
toggleList(editor, {
|
|
141
|
-
listStyleType: KEYS.ul
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
},
|
|
145
|
-
{
|
|
146
|
-
match: [String.raw`^\d+\.$ `, String.raw`^\d+\)$ `],
|
|
147
|
-
matchByRegex: true,
|
|
148
|
-
mode: 'block',
|
|
149
|
-
type: 'list',
|
|
150
|
-
format: (editor, { matchString }) => {
|
|
151
|
-
toggleList(editor, {
|
|
152
|
-
listRestartPolite: Number(matchString) || 1,
|
|
153
|
-
listStyleType: KEYS.ol
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
},
|
|
157
|
-
{
|
|
158
|
-
match: ['[] '],
|
|
159
|
-
mode: 'block',
|
|
160
|
-
type: 'list',
|
|
161
|
-
format: (editor) => {
|
|
162
|
-
toggleList(editor, {
|
|
163
|
-
listStyleType: KEYS.listTodo
|
|
164
|
-
});
|
|
165
|
-
editor.tf.setNodes({
|
|
166
|
-
checked: false,
|
|
167
|
-
listStyleType: KEYS.listTodo
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
},
|
|
171
|
-
{
|
|
172
|
-
match: ['[x] '],
|
|
173
|
-
mode: 'block',
|
|
174
|
-
type: 'list',
|
|
175
|
-
format: (editor) => {
|
|
176
|
-
toggleList(editor, {
|
|
177
|
-
listStyleType: KEYS.listTodo
|
|
178
|
-
});
|
|
179
|
-
editor.tf.setNodes({
|
|
180
|
-
checked: true,
|
|
181
|
-
listStyleType: KEYS.listTodo
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
];
|
|
186
|
-
|
|
187
|
-
export const AutoformatKit = [
|
|
188
|
-
AutoformatPlugin.configure({
|
|
189
|
-
options: {
|
|
190
|
-
enableUndoOnDelete: true,
|
|
191
|
-
rules: [
|
|
192
|
-
...autoformatBlocks,
|
|
193
|
-
...autoformatMarks,
|
|
194
|
-
...autoformatSmartQuotes,
|
|
195
|
-
...autoformatPunctuation,
|
|
196
|
-
...autoformatLegal,
|
|
197
|
-
...autoformatLegalHtml,
|
|
198
|
-
...autoformatArrow,
|
|
199
|
-
...autoformatMath,
|
|
200
|
-
...autoformatLists
|
|
201
|
-
].map(
|
|
202
|
-
(rule): AutoformatRule => ({
|
|
203
|
-
...rule,
|
|
204
|
-
query: editor => !editor.api.some({
|
|
205
|
-
match: { type: editor.getType(KEYS.codeBlock) }
|
|
206
|
-
})
|
|
207
|
-
})
|
|
208
|
-
)
|
|
209
|
-
}
|
|
210
|
-
})
|
|
211
|
-
];
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
BaseBlockquotePlugin,
|
|
3
|
-
BaseH1Plugin,
|
|
4
|
-
BaseH2Plugin,
|
|
5
|
-
BaseH3Plugin,
|
|
6
|
-
BaseHorizontalRulePlugin
|
|
7
|
-
} from '@platejs/basic-nodes';
|
|
8
|
-
import { BaseParagraphPlugin } from 'platejs';
|
|
9
|
-
|
|
10
|
-
import { BlockquoteElementStatic } from '../../plate-ui/blockquote-node-static';
|
|
11
|
-
import {
|
|
12
|
-
H1ElementStatic,
|
|
13
|
-
H2ElementStatic,
|
|
14
|
-
H3ElementStatic
|
|
15
|
-
} from '../../plate-ui/heading-node-static';
|
|
16
|
-
import { HrElementStatic } from '../../plate-ui/hr-node-static';
|
|
17
|
-
import { ParagraphElementStatic } from '../../plate-ui/paragraph-node-static';
|
|
18
|
-
|
|
19
|
-
export const BaseBasicBlocksKit = [
|
|
20
|
-
BaseParagraphPlugin.withComponent(ParagraphElementStatic),
|
|
21
|
-
BaseH1Plugin.withComponent(H1ElementStatic),
|
|
22
|
-
BaseH2Plugin.withComponent(H2ElementStatic),
|
|
23
|
-
BaseH3Plugin.withComponent(H3ElementStatic),
|
|
24
|
-
BaseBlockquotePlugin.withComponent(BlockquoteElementStatic),
|
|
25
|
-
BaseHorizontalRulePlugin.withComponent(HrElementStatic)
|
|
26
|
-
];
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
BlockquotePlugin,
|
|
5
|
-
H1Plugin,
|
|
6
|
-
H2Plugin,
|
|
7
|
-
H3Plugin,
|
|
8
|
-
HorizontalRulePlugin
|
|
9
|
-
} from '@platejs/basic-nodes/react';
|
|
10
|
-
import { ParagraphPlugin } from 'platejs/react';
|
|
11
|
-
|
|
12
|
-
import { BlockquoteElement } from '../../plate-ui/blockquote-node';
|
|
13
|
-
import { H1Element, H2Element, H3Element } from '../../plate-ui/heading-node';
|
|
14
|
-
import { HrElement } from '../../plate-ui/hr-node';
|
|
15
|
-
import { ParagraphElement } from '../../plate-ui/paragraph-node';
|
|
16
|
-
|
|
17
|
-
export const BasicBlocksKit = [
|
|
18
|
-
ParagraphPlugin.withComponent(ParagraphElement),
|
|
19
|
-
H1Plugin.configure({
|
|
20
|
-
node: {
|
|
21
|
-
component: H1Element
|
|
22
|
-
},
|
|
23
|
-
rules: {
|
|
24
|
-
break: { empty: 'reset' }
|
|
25
|
-
},
|
|
26
|
-
shortcuts: { toggle: { keys: 'mod+alt+1' } }
|
|
27
|
-
}),
|
|
28
|
-
H2Plugin.configure({
|
|
29
|
-
node: {
|
|
30
|
-
component: H2Element
|
|
31
|
-
},
|
|
32
|
-
rules: {
|
|
33
|
-
break: { empty: 'reset' }
|
|
34
|
-
},
|
|
35
|
-
shortcuts: { toggle: { keys: 'mod+alt+2' } }
|
|
36
|
-
}),
|
|
37
|
-
H3Plugin.configure({
|
|
38
|
-
node: {
|
|
39
|
-
component: H3Element
|
|
40
|
-
},
|
|
41
|
-
rules: {
|
|
42
|
-
break: { empty: 'reset' }
|
|
43
|
-
},
|
|
44
|
-
shortcuts: { toggle: { keys: 'mod+alt+3' } }
|
|
45
|
-
}),
|
|
46
|
-
BlockquotePlugin.configure({
|
|
47
|
-
node: { component: BlockquoteElement },
|
|
48
|
-
shortcuts: { toggle: { keys: 'mod+shift+period' } }
|
|
49
|
-
}),
|
|
50
|
-
HorizontalRulePlugin.withComponent(HrElement)
|
|
51
|
-
];
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
BaseBoldPlugin,
|
|
3
|
-
BaseCodePlugin,
|
|
4
|
-
BaseHighlightPlugin,
|
|
5
|
-
BaseItalicPlugin,
|
|
6
|
-
BaseStrikethroughPlugin,
|
|
7
|
-
BaseSubscriptPlugin,
|
|
8
|
-
BaseSuperscriptPlugin,
|
|
9
|
-
BaseUnderlinePlugin
|
|
10
|
-
} from '@platejs/basic-nodes';
|
|
11
|
-
|
|
12
|
-
import { CodeLeafStatic } from '../../plate-ui/code-node-static';
|
|
13
|
-
import { HighlightLeafStatic } from '../../plate-ui/highlight-node-static';
|
|
14
|
-
|
|
15
|
-
export const BaseBasicMarksKit = [
|
|
16
|
-
BaseBoldPlugin,
|
|
17
|
-
BaseItalicPlugin,
|
|
18
|
-
BaseUnderlinePlugin,
|
|
19
|
-
BaseCodePlugin.withComponent(CodeLeafStatic),
|
|
20
|
-
BaseStrikethroughPlugin,
|
|
21
|
-
BaseSubscriptPlugin,
|
|
22
|
-
BaseSuperscriptPlugin,
|
|
23
|
-
BaseHighlightPlugin.withComponent(HighlightLeafStatic)
|
|
24
|
-
];
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
BoldPlugin,
|
|
5
|
-
CodePlugin,
|
|
6
|
-
HighlightPlugin,
|
|
7
|
-
ItalicPlugin,
|
|
8
|
-
StrikethroughPlugin,
|
|
9
|
-
SubscriptPlugin,
|
|
10
|
-
SuperscriptPlugin,
|
|
11
|
-
UnderlinePlugin
|
|
12
|
-
} from '@platejs/basic-nodes/react';
|
|
13
|
-
|
|
14
|
-
import { CodeLeaf } from '../../plate-ui/code-node';
|
|
15
|
-
import { HighlightLeaf } from '../../plate-ui/highlight-node';
|
|
16
|
-
|
|
17
|
-
export const BasicMarksKit = [
|
|
18
|
-
BoldPlugin,
|
|
19
|
-
ItalicPlugin,
|
|
20
|
-
UnderlinePlugin,
|
|
21
|
-
CodePlugin.configure({
|
|
22
|
-
node: { component: CodeLeaf },
|
|
23
|
-
shortcuts: { toggle: { keys: 'mod+e' } }
|
|
24
|
-
}),
|
|
25
|
-
StrikethroughPlugin.configure({
|
|
26
|
-
shortcuts: { toggle: { keys: 'mod+shift+x' } }
|
|
27
|
-
}),
|
|
28
|
-
SubscriptPlugin.configure({
|
|
29
|
-
shortcuts: { toggle: { keys: 'mod+comma' } }
|
|
30
|
-
}),
|
|
31
|
-
SuperscriptPlugin.configure({
|
|
32
|
-
shortcuts: { toggle: { keys: 'mod+period' } }
|
|
33
|
-
}),
|
|
34
|
-
HighlightPlugin.configure({
|
|
35
|
-
node: { component: HighlightLeaf },
|
|
36
|
-
shortcuts: { toggle: { keys: 'mod+shift+h' } }
|
|
37
|
-
})
|
|
38
|
-
];
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { BlockMenuPlugin } from '@platejs/selection/react';
|
|
4
|
-
|
|
5
|
-
import { BlockSelectionKit } from './block-selection-kit';
|
|
6
|
-
|
|
7
|
-
import { BlockContextMenu } from '../../plate-ui/block-context-menu';
|
|
8
|
-
|
|
9
|
-
export const BlockMenuKit = [
|
|
10
|
-
...BlockSelectionKit,
|
|
11
|
-
BlockMenuPlugin.configure({
|
|
12
|
-
render: { aboveSlate: BlockContextMenu }
|
|
13
|
-
})
|
|
14
|
-
];
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { KEYS } from 'platejs';
|
|
4
|
-
import { BlockPlaceholderPlugin } from 'platejs/react';
|
|
5
|
-
|
|
6
|
-
export const BlockPlaceholderKit = [
|
|
7
|
-
BlockPlaceholderPlugin.configure({
|
|
8
|
-
options: {
|
|
9
|
-
className:
|
|
10
|
-
'before:absolute before:cursor-text before:text-muted-foreground/80 before:content-[attr(placeholder)]',
|
|
11
|
-
placeholders: {
|
|
12
|
-
[KEYS.p]: 'Type a paragraph'
|
|
13
|
-
},
|
|
14
|
-
query: ({ path }: { path: number[] }) => path.length === 1
|
|
15
|
-
}
|
|
16
|
-
})
|
|
17
|
-
];
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { AIChatPlugin } from '@platejs/ai/react';
|
|
4
|
-
import { BlockSelectionPlugin } from '@platejs/selection/react';
|
|
5
|
-
import { getPluginTypes, isHotkey, KEYS } from 'platejs';
|
|
6
|
-
|
|
7
|
-
import { BlockSelection } from '../../plate-ui/block-selection';
|
|
8
|
-
|
|
9
|
-
export const BlockSelectionKit = [
|
|
10
|
-
BlockSelectionPlugin.configure(({ editor }) => ({
|
|
11
|
-
options: {
|
|
12
|
-
enableContextMenu: true,
|
|
13
|
-
isSelectable: element => !getPluginTypes(editor, [KEYS.column, KEYS.codeLine, KEYS.td]).includes(
|
|
14
|
-
element.type
|
|
15
|
-
),
|
|
16
|
-
onKeyDownSelecting: (_editor, e) => {
|
|
17
|
-
if (isHotkey('mod+j')(e)) {
|
|
18
|
-
editor.getApi(AIChatPlugin).aiChat.show();
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
|
-
render: {
|
|
23
|
-
belowRootNodes: (props) => {
|
|
24
|
-
if (!props.attributes.className?.includes('slate-selectable'))
|
|
25
|
-
return null;
|
|
26
|
-
|
|
27
|
-
return <BlockSelection {...(props as any)} />;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}))
|
|
31
|
-
];
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
BaseCodeBlockPlugin,
|
|
3
|
-
BaseCodeLinePlugin,
|
|
4
|
-
BaseCodeSyntaxPlugin
|
|
5
|
-
} from '@platejs/code-block';
|
|
6
|
-
import { all, createLowlight } from 'lowlight';
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
CodeBlockElementStatic,
|
|
10
|
-
CodeLineElementStatic,
|
|
11
|
-
CodeSyntaxLeafStatic
|
|
12
|
-
} from '../../plate-ui/code-block-node-static';
|
|
13
|
-
|
|
14
|
-
const lowlight = createLowlight(all);
|
|
15
|
-
|
|
16
|
-
export const BaseCodeBlockKit = [
|
|
17
|
-
BaseCodeBlockPlugin.configure({
|
|
18
|
-
node: { component: CodeBlockElementStatic },
|
|
19
|
-
options: { lowlight }
|
|
20
|
-
}),
|
|
21
|
-
BaseCodeLinePlugin.withComponent(CodeLineElementStatic),
|
|
22
|
-
BaseCodeSyntaxPlugin.withComponent(CodeSyntaxLeafStatic)
|
|
23
|
-
];
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
CodeBlockPlugin,
|
|
5
|
-
CodeLinePlugin,
|
|
6
|
-
CodeSyntaxPlugin
|
|
7
|
-
} from '@platejs/code-block/react';
|
|
8
|
-
import { all, createLowlight } from 'lowlight';
|
|
9
|
-
|
|
10
|
-
import {
|
|
11
|
-
CodeBlockElement,
|
|
12
|
-
CodeLineElement,
|
|
13
|
-
CodeSyntaxLeaf
|
|
14
|
-
} from '../../plate-ui/code-block-node';
|
|
15
|
-
|
|
16
|
-
const lowlight = createLowlight(all);
|
|
17
|
-
|
|
18
|
-
export const CodeBlockKit = [
|
|
19
|
-
CodeBlockPlugin.configure({
|
|
20
|
-
node: { component: CodeBlockElement },
|
|
21
|
-
options: { lowlight },
|
|
22
|
-
shortcuts: { toggle: { keys: 'mod+alt+8' } }
|
|
23
|
-
}),
|
|
24
|
-
CodeLinePlugin.withComponent(CodeLineElement),
|
|
25
|
-
CodeSyntaxPlugin.withComponent(CodeSyntaxLeaf)
|
|
26
|
-
];
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { BaseColumnItemPlugin, BaseColumnPlugin } from '@platejs/layout';
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
ColumnElementStatic,
|
|
5
|
-
ColumnGroupElementStatic
|
|
6
|
-
} from '../../plate-ui/column-node-static';
|
|
7
|
-
|
|
8
|
-
export const BaseColumnKit = [BaseColumnPlugin.withComponent(ColumnGroupElementStatic), BaseColumnItemPlugin.withComponent(ColumnElementStatic)];
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { ColumnItemPlugin, ColumnPlugin } from '@platejs/layout/react';
|
|
4
|
-
|
|
5
|
-
import { ColumnElement, ColumnGroupElement } from '../../plate-ui/column-node';
|
|
6
|
-
|
|
7
|
-
export const ColumnKit = [ColumnPlugin.withComponent(ColumnGroupElement), ColumnItemPlugin.withComponent(ColumnElement)];
|
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { useEffect, type RefObject } from 'react';
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
type BaseCommentConfig,
|
|
7
|
-
BaseCommentPlugin,
|
|
8
|
-
getDraftCommentKey
|
|
9
|
-
} from '@platejs/comment';
|
|
10
|
-
import {
|
|
11
|
-
type ExtendConfig, type Path, isSlateElement, isSlateString
|
|
12
|
-
} from 'platejs';
|
|
13
|
-
import { toTPlatePlugin, useEditorContainerRef } from 'platejs/react';
|
|
14
|
-
|
|
15
|
-
import { CommentLeaf } from '../../plate-ui/comment-node';
|
|
16
|
-
// import { FloatingDiscussion } from '../../plate-ui/floating-discussion';
|
|
17
|
-
|
|
18
|
-
type CommentConfig = ExtendConfig<
|
|
19
|
-
BaseCommentConfig,
|
|
20
|
-
{
|
|
21
|
-
activeId: string | null;
|
|
22
|
-
commentingBlock: Path | null;
|
|
23
|
-
hoverId: string | null;
|
|
24
|
-
isOverlapWithEditor: boolean;
|
|
25
|
-
uniquePathMap: Map<string, Path>;
|
|
26
|
-
updateTimestamp: number | null;
|
|
27
|
-
}
|
|
28
|
-
>;
|
|
29
|
-
|
|
30
|
-
export const commentPlugin = toTPlatePlugin<CommentConfig>(BaseCommentPlugin, {
|
|
31
|
-
handlers: {
|
|
32
|
-
onClick: ({
|
|
33
|
-
api, event, setOption, type
|
|
34
|
-
}) => {
|
|
35
|
-
let leaf = event.target as HTMLElement;
|
|
36
|
-
let isSet = false;
|
|
37
|
-
|
|
38
|
-
const unsetActiveSuggestion = () => {
|
|
39
|
-
setOption('activeId', null);
|
|
40
|
-
isSet = true;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
if (!isSlateString(leaf)) unsetActiveSuggestion();
|
|
44
|
-
|
|
45
|
-
while (leaf.parentElement && !isSlateElement(leaf.parentElement)) {
|
|
46
|
-
if (leaf.classList.contains(`slate-${type}`)) {
|
|
47
|
-
const commentsEntry = api.comment!.node();
|
|
48
|
-
|
|
49
|
-
if (!commentsEntry) {
|
|
50
|
-
unsetActiveSuggestion();
|
|
51
|
-
|
|
52
|
-
break;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const id = api.comment!.nodeId(commentsEntry[0]) ?? null;
|
|
56
|
-
const isDraft = commentsEntry[0][getDraftCommentKey()];
|
|
57
|
-
|
|
58
|
-
setOption('activeId', isDraft ? getDraftCommentKey() : id);
|
|
59
|
-
isSet = true;
|
|
60
|
-
|
|
61
|
-
break;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
leaf = leaf.parentElement;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
if (!isSet) unsetActiveSuggestion();
|
|
68
|
-
}
|
|
69
|
-
},
|
|
70
|
-
options: {
|
|
71
|
-
activeId: null,
|
|
72
|
-
commentingBlock: null,
|
|
73
|
-
hoverId: null,
|
|
74
|
-
isOverlapWithEditor: false,
|
|
75
|
-
uniquePathMap: new Map(),
|
|
76
|
-
updateTimestamp: null
|
|
77
|
-
},
|
|
78
|
-
useHooks: ({ editor, setOption }) => {
|
|
79
|
-
const editorContainerRef = useEditorContainerRef() as unknown as RefObject<HTMLDivElement | null>;
|
|
80
|
-
|
|
81
|
-
useEffect(() => {
|
|
82
|
-
if (!editorContainerRef.current) return;
|
|
83
|
-
|
|
84
|
-
const editable = editor.api.toDOMNode(editor);
|
|
85
|
-
|
|
86
|
-
if (!editable) return;
|
|
87
|
-
|
|
88
|
-
const observer = new ResizeObserver((entries) => {
|
|
89
|
-
const { width } = entries[0].contentRect;
|
|
90
|
-
const isOverlap = width < 700;
|
|
91
|
-
|
|
92
|
-
setOption('isOverlapWithEditor', isOverlap);
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
observer.observe(editable);
|
|
96
|
-
|
|
97
|
-
return () => {
|
|
98
|
-
observer.disconnect();
|
|
99
|
-
};
|
|
100
|
-
}, [editor, editorContainerRef, setOption]);
|
|
101
|
-
}
|
|
102
|
-
})
|
|
103
|
-
.extendTransforms(
|
|
104
|
-
({
|
|
105
|
-
editor,
|
|
106
|
-
setOption,
|
|
107
|
-
tf: {
|
|
108
|
-
comment: { setDraft }
|
|
109
|
-
}
|
|
110
|
-
}) => ({
|
|
111
|
-
setDraft: () => {
|
|
112
|
-
if (editor.api.isCollapsed()) {
|
|
113
|
-
editor.tf.select(editor.api.block()![1]);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
setDraft();
|
|
117
|
-
|
|
118
|
-
editor.tf.collapse();
|
|
119
|
-
setOption('activeId', getDraftCommentKey());
|
|
120
|
-
setOption('commentingBlock', editor.selection!.focus.path.slice(0, 1));
|
|
121
|
-
}
|
|
122
|
-
})
|
|
123
|
-
)
|
|
124
|
-
.overrideEditor(
|
|
125
|
-
({
|
|
126
|
-
editor, setOption, tf: { apply, insertBreak }, tf, type
|
|
127
|
-
}) => ({
|
|
128
|
-
transforms: {
|
|
129
|
-
apply(operation) {
|
|
130
|
-
if (
|
|
131
|
-
operation.type !== 'set_selection'
|
|
132
|
-
&& operation.type !== 'set_node'
|
|
133
|
-
&& operation.type !== 'split_node'
|
|
134
|
-
&& operation.type !== 'merge_node'
|
|
135
|
-
) {
|
|
136
|
-
const { newProperties, properties } = operation;
|
|
137
|
-
|
|
138
|
-
if (
|
|
139
|
-
(properties as any)?.[getDraftCommentKey()]
|
|
140
|
-
|| (newProperties as any)?.[getDraftCommentKey()]
|
|
141
|
-
) {
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
setOption('updateTimestamp', Date.now());
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
apply(operation);
|
|
149
|
-
},
|
|
150
|
-
insertBreak() {
|
|
151
|
-
setOption('updateTimestamp', Date.now());
|
|
152
|
-
|
|
153
|
-
tf.comment.removeMark();
|
|
154
|
-
insertBreak();
|
|
155
|
-
editor.tf.unsetNodes([type], {
|
|
156
|
-
at: editor.selection?.focus,
|
|
157
|
-
mode: 'lowest'
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
})
|
|
162
|
-
)
|
|
163
|
-
.extend({
|
|
164
|
-
shortcuts: {
|
|
165
|
-
setDraft: { keys: 'mod+shift+m' }
|
|
166
|
-
}
|
|
167
|
-
})
|
|
168
|
-
.configure({
|
|
169
|
-
render: {
|
|
170
|
-
node: CommentLeaf
|
|
171
|
-
}
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
export const CommentKit = [commentPlugin];
|