@agent-native/core 0.189.0 → 0.190.0-nightly-20260925211446
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/corpus/README.md +1 -1
- package/corpus/templates/analytics/.agents/skills/analysis-workspace/SKILL.md +10 -0
- package/corpus/templates/analytics/.agents/skills/data-querying/SKILL.md +1 -1
- package/corpus/templates/analytics/AGENTS.md +11 -22
- package/corpus/templates/analytics/actions/list-data-dictionary.ts +7 -9
- package/corpus/templates/analytics/actions/search-analytics-query-catalog.ts +1 -1
- package/corpus/templates/analytics/app/components/AnalyticsReviewArtifactPreview.tsx +201 -0
- package/corpus/templates/analytics/app/i18n/en-US.ts +2 -0
- package/corpus/templates/analytics/app/pages/Settings.tsx +50 -3
- package/corpus/templates/analytics/changelog/2026-09-25-first-run-onboarding-records-setup-choices-and-builder-conne.md +6 -0
- package/corpus/templates/analytics/changelog/2026-09-25-human-review-previews-analytics-dashboards-as-real-charts.md +6 -0
- package/corpus/templates/analytics/changelog/2026-09-25-org-admins-can-review-agent-runs-from-settings.md +6 -0
- package/corpus/templates/analytics/changelog/2026-09-25-proactive-query-context.md +6 -0
- package/corpus/templates/analytics/seeds/dashboards/agent-native-templates-first-party.json +98 -2
- package/corpus/templates/analytics/server/lib/analytics-agent-context.ts +557 -0
- package/corpus/templates/analytics/server/lib/analytics-query-catalog.ts +217 -46
- package/corpus/templates/analytics/server/lib/dashboard-catalog.ts +2 -2
- package/corpus/templates/analytics/server/lib/dashboards-store.ts +39 -5
- package/corpus/templates/analytics/server/lib/data-dictionary-context.ts +4 -0
- package/corpus/templates/analytics/server/lib/first-party-metric-catalog.ts +268 -2
- package/corpus/templates/analytics/server/plugins/agent-chat.ts +44 -9
- package/corpus/templates/calendar/AGENTS.md +5 -0
- package/corpus/templates/calendar/CHANGELOG.md +6 -0
- package/corpus/templates/calendar/actions/get-event-rules-status.ts +47 -0
- package/corpus/templates/calendar/actions/list-events.ts +50 -4
- package/corpus/templates/calendar/actions/undo-calendar-event-rule.ts +229 -0
- package/corpus/templates/calendar/actions/update-settings.ts +8 -0
- package/corpus/templates/calendar/app/i18n/en-US.ts +27 -0
- package/corpus/templates/calendar/app/pages/Settings.tsx +196 -1
- package/corpus/templates/calendar/changelog/2026-09-25-calendar-feeds-with-the-same-url-keep-their-own-names-and-co.md +6 -0
- package/corpus/templates/calendar/changelog/2026-09-25-calendar-invitation-rules-surface-expired-connections-and-un.md +6 -0
- package/corpus/templates/calendar/changelog/2026-09-25-restore-locally-hidden-events-from-activity-after-disconnect.md +6 -0
- package/corpus/templates/calendar/server/lib/calendar-settings.ts +44 -10
- package/corpus/templates/calendar/server/lib/google-api.ts +15 -1
- package/corpus/templates/calendar/server/lib/google-calendar.ts +1 -1
- package/corpus/templates/calendar/server/plugins/event-rules.ts +628 -0
- package/corpus/templates/calendar/shared/api.ts +13 -0
- package/corpus/templates/calendar/shared/settings.ts +71 -1
- package/corpus/templates/clips/actions/create-recording.ts +83 -2
- package/corpus/templates/clips/actions/finalize-recording.ts +610 -110
- package/corpus/templates/clips/actions/get-recording-player-data.ts +6 -0
- package/corpus/templates/clips/actions/import-loom-recording.ts +2 -0
- package/corpus/templates/clips/actions/lib/create-recording-schema.ts +7 -0
- package/corpus/templates/clips/actions/lib/loom-import-job.ts +15 -1
- package/corpus/templates/clips/app/components/recorder/recorder-engine.ts +126 -26
- package/corpus/templates/clips/app/hooks/use-drop-video-upload.ts +75 -15
- package/corpus/templates/clips/app/routes/_app.r.$recordingId.tsx +5 -1
- package/corpus/templates/clips/app/routes/record.tsx +134 -40
- package/corpus/templates/clips/chrome-extension/src/background.ts +3 -0
- package/corpus/templates/clips/chrome-extension/src/offscreen.ts +73 -16
- package/corpus/templates/clips/desktop/src/lib/recorder.ts +188 -18
- package/corpus/templates/clips/desktop/src/lib/recording-request.ts +1 -0
- package/corpus/templates/clips/server/db/schema.ts +4 -0
- package/corpus/templates/clips/server/jobs/media-verification.ts +78 -4
- package/corpus/templates/clips/server/jobs/recording-failure-backfill.ts +142 -0
- package/corpus/templates/clips/server/lib/media-verification-state.ts +29 -0
- package/corpus/templates/clips/server/lib/post-finalize-dispatch.ts +2 -0
- package/corpus/templates/clips/server/lib/recording-failures.ts +111 -0
- package/corpus/templates/clips/server/lib/recordings.ts +6 -1
- package/corpus/templates/clips/server/lib/s3-upload-provider.ts +8 -3
- package/corpus/templates/clips/server/lib/upload-lease.ts +25 -6
- package/corpus/templates/clips/server/plugins/calendar-jobs.ts +2 -0
- package/corpus/templates/clips/server/plugins/db.ts +18 -0
- package/corpus/templates/clips/server/routes/api/_agent-native-background/post-finalize-worker.post.ts +48 -5
- package/corpus/templates/clips/server/routes/api/uploads/[recordingId]/abort.post.ts +322 -31
- package/corpus/templates/clips/server/routes/api/uploads/[recordingId]/chunk.post.ts +223 -61
- package/corpus/templates/clips/server/routes/api/uploads/[recordingId]/interrupt.post.ts +62 -4
- package/corpus/templates/clips/server/routes/api/uploads/[recordingId]/reset-chunks.post.ts +74 -7
- package/corpus/templates/clips/shared/recording-core.ts +27 -0
- package/corpus/templates/design/actions/get-design.ts +35 -6
- package/corpus/templates/mail/.agents/skills/inbox-automations/SKILL.md +4 -0
- package/corpus/templates/mail/actions/consolidate-ai-filter-rules.ts +41 -0
- package/corpus/templates/mail/actions/get-ai-priority.ts +48 -8
- package/corpus/templates/mail/actions/record-ai-priority-feedback.ts +69 -0
- package/corpus/templates/mail/actions/update-mail-preferences.ts +2 -0
- package/corpus/templates/mail/app/components/email/EmailList.tsx +179 -32
- package/corpus/templates/mail/app/components/email/EmailListItem.tsx +97 -9
- package/corpus/templates/mail/app/components/email/EmailThread.tsx +55 -1
- package/corpus/templates/mail/app/components/email/ImportanceFeedbackMenu.tsx +52 -0
- package/corpus/templates/mail/app/components/email/compose-autocomplete.ts +2 -1
- package/corpus/templates/mail/app/components/layout/AppLayout.tsx +219 -188
- package/corpus/templates/mail/app/components/onboarding/AiInboxSetup.tsx +338 -0
- package/corpus/templates/mail/app/components/settings/AiFilterSection.tsx +597 -781
- package/corpus/templates/mail/app/components/settings/AiRulePromptField.tsx +37 -0
- package/corpus/templates/mail/app/global.css +42 -26
- package/corpus/templates/mail/app/hooks/use-ai-priority-feedback.ts +43 -0
- package/corpus/templates/mail/app/hooks/use-automations.ts +23 -0
- package/corpus/templates/mail/app/i18n/en-US.ts +58 -3
- package/corpus/templates/mail/app/pages/InboxPage.tsx +47 -10
- package/corpus/templates/mail/changelog/2026-09-25-editing-importance-rules-preserves-disabled-instructions-and.md +6 -0
- package/corpus/templates/mail/changelog/2026-09-25-handle-astral-unicode-letters-in-autocomplete-word-boundarie.md +6 -0
- package/corpus/templates/mail/changelog/2026-09-25-jev-priority-feedback-and-inbox-settings.md +6 -0
- package/corpus/templates/mail/changelog/2026-09-25-keep-existing-ai-filter-rules-intact-when-saving-a-prompt.md +6 -0
- package/corpus/templates/mail/server/lib/automation-engine.ts +21 -12
- package/corpus/templates/mail/server/lib/automations.ts +100 -1
- package/corpus/templates/mail/shared/types.ts +3 -0
- package/corpus/templates/plan/app/i18n/en-US.ts +6 -0
- package/corpus/templates/plan/app/lib/plan-invite-suggestion.ts +43 -0
- package/corpus/templates/plan/app/pages/PlansPage.tsx +249 -4
- package/corpus/templates/slides/actions/create-deck.ts +11 -1
- package/corpus/templates/slides/app/components/deck/SlideRenderer.tsx +117 -1
- package/corpus/templates/slides/app/components/design-system/DesignSystemSetup.tsx +373 -330
- package/corpus/templates/slides/app/components/design-system/builder-index-response.ts +36 -5
- package/corpus/templates/slides/app/components/editor/BlockBubbleMenu.tsx +21 -53
- package/corpus/templates/slides/app/components/editor/SlideEditor.tsx +347 -671
- package/corpus/templates/slides/app/components/editor/bullet-editing.ts +55 -8
- package/corpus/templates/slides/app/components/editor/in-place-text-session.ts +2082 -0
- package/corpus/templates/slides/app/components/editor/list-editing.ts +174 -16
- package/corpus/templates/slides/app/components/editor/rich-text-selection.ts +497 -62
- package/corpus/templates/slides/app/components/editor/slide-text-targets.ts +102 -20
- package/corpus/templates/slides/app/context/DeckContext.tsx +9 -4
- package/corpus/templates/slides/app/global.css +7 -219
- package/corpus/templates/slides/app/i18n/en-US.ts +3 -0
- package/corpus/templates/slides/app/lib/sanitize-slide-html.ts +7 -0
- package/corpus/templates/slides/app/lib/slide-image-replacement.ts +203 -1
- package/corpus/templates/slides/app/lib/slide-source-map.ts +43 -0
- package/corpus/templates/slides/app/pages/DeckEditor.tsx +182 -4
- package/corpus/templates/slides/app/routes/settings.tsx +33 -2
- package/corpus/templates/slides/changelog/2026-09-25-improve-slides-design-system-setup-feedback.md +6 -0
- package/corpus/templates/slides/changelog/2026-09-25-org-admins-can-review-agent-runs-from-settings.md +6 -0
- package/corpus/templates/slides/changelog/2026-09-25-text-on-a-slide-is-now-edited-in-place-clicking-into-it-chan.md +6 -0
- package/corpus/templates/slides/package.json +0 -12
- package/corpus/templates/slides/scripts/edit-fidelity/README.md +4 -2
- package/corpus/templates/slides/scripts/edit-fidelity/run.ts +12 -3
- package/corpus/templates/slides/vite.config.ts +1 -10
- package/dist/agent/jev-tool-prefetch.d.ts +29 -3
- package/dist/agent/jev-tool-prefetch.js +161 -34
- package/dist/agent/production-agent.d.ts +11 -0
- package/dist/agent/production-agent.js +39 -8
- package/dist/app-config/runtime.d.ts +1 -0
- package/dist/app-config/runtime.js +4 -0
- package/dist/app-config/schema.d.ts +1 -0
- package/dist/client/AgentSidebar.d.ts +3 -1
- package/dist/client/AgentSidebar.js +8 -12
- package/dist/client/analytics/index.d.ts +1 -1
- package/dist/client/analytics/index.js +1 -1
- package/dist/client/analytics.d.ts +2 -0
- package/dist/client/analytics.js +9 -0
- package/dist/client/api-path.js +5 -2
- package/dist/client/chat/run-recovery.d.ts +0 -3
- package/dist/client/chat/run-recovery.js +13 -23
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.js +1 -1
- package/dist/client/observability/ObservabilityDashboard.d.ts +3 -0
- package/dist/client/observability/ObservabilityDashboard.js +366 -71
- package/dist/client/observability/ObservabilityReviewSummaryButton.d.ts +4 -1
- package/dist/client/observability/ObservabilityReviewSummaryButton.js +13 -9
- package/dist/client/observability/OutputPreview.d.ts +9 -4
- package/dist/client/observability/OutputPreview.js +230 -52
- package/dist/client/onboarding/FirstRunOnboarding.js +67 -4
- package/dist/client/onboarding/use-onboarding.js +2 -0
- package/dist/client/sharing/ShareButton.d.ts +2 -0
- package/dist/client/sharing/ShareButton.js +1 -0
- package/dist/client/sharing/useShareButtonController.d.ts +1 -0
- package/dist/client/sharing/useShareButtonController.js +29 -8
- package/dist/collab/awareness.d.ts +2 -2
- package/dist/collab/struct-routes.d.ts +1 -1
- package/dist/deploy/build.js +9 -1
- package/dist/embeddings/index.d.ts +3 -1
- package/dist/embeddings/index.js +20 -10
- package/dist/jobs/sweep-hooks.d.ts +7 -0
- package/dist/jobs/sweep-hooks.js +28 -0
- package/dist/localization/default-messages.d.ts +1 -0
- package/dist/localization/default-messages.js +1 -0
- package/dist/mcp/screen-memory-stdio.d.ts +7 -7
- package/dist/notifications/routes.d.ts +1 -1
- package/dist/observability/actions/authorization.d.ts +1 -0
- package/dist/observability/actions/authorization.js +22 -0
- package/dist/observability/actions/get-observability-review-detail.d.ts +5 -0
- package/dist/observability/actions/get-observability-review-detail.js +10 -2
- package/dist/observability/actions/get-observability-review-summary-source.d.ts +2 -0
- package/dist/observability/actions/get-observability-review-summary-source.js +3 -2
- package/dist/observability/actions/save-observability-instruction-update.js +2 -1
- package/dist/observability/actions/save-observability-review-summary.js +21 -10
- package/dist/observability/migrations.js +25 -0
- package/dist/observability/reviews.d.ts +3 -1
- package/dist/observability/reviews.js +410 -53
- package/dist/observability/routes.d.ts +6 -6
- package/dist/observability/store.d.ts +15 -0
- package/dist/observability/store.js +131 -11
- package/dist/observability/types.d.ts +18 -0
- package/dist/org/handlers.d.ts +1 -1
- package/dist/org/index.d.ts +1 -1
- package/dist/progress/routes.d.ts +1 -1
- package/dist/provider-api/actions/custom-provider-registration.d.ts +5 -5
- package/dist/provider-api/actions/provider-api.d.ts +8 -8
- package/dist/secrets/routes.d.ts +3 -3
- package/dist/server/agent-chat/plugin-options.d.ts +4 -20
- package/dist/server/agent-chat/prompt-resources.d.ts +16 -0
- package/dist/server/agent-chat/prompt-resources.js +385 -22
- package/dist/server/agent-chat-plugin.d.ts +3 -1
- package/dist/server/agent-chat-plugin.js +149 -27
- package/dist/server/agent-engine-ollama-models-route.d.ts +1 -1
- package/dist/server/index.d.ts +3 -0
- package/dist/server/index.js +3 -0
- package/dist/server/prompts/framework-core-compact.js +1 -1
- package/dist/server/prompts/framework-core.js +1 -1
- package/dist/server/realtime-token.d.ts +1 -1
- package/dist/server/request-context.d.ts +6 -3
- package/dist/server/transcribe-voice.d.ts +1 -1
- package/dist/settings/org-settings.d.ts +4 -2
- package/dist/settings/org-settings.js +3 -3
- package/dist/settings/store.d.ts +3 -1
- package/dist/settings/store.js +8 -3
- package/dist/styles/agent-native.css +5 -0
- package/dist/templates/default/app/i18n/ar-SA.ts +1 -0
- package/dist/templates/default/app/i18n/de-DE.ts +1 -0
- package/dist/templates/default/app/i18n/en-US.ts +1 -0
- package/dist/templates/default/app/i18n/es-ES.ts +1 -0
- package/dist/templates/default/app/i18n/fr-FR.ts +1 -0
- package/dist/templates/default/app/i18n/hi-IN.ts +1 -0
- package/dist/templates/default/app/i18n/ja-JP.ts +1 -0
- package/dist/templates/default/app/i18n/ko-KR.ts +1 -0
- package/dist/templates/default/app/i18n/pt-BR.ts +1 -0
- package/dist/templates/default/app/i18n/zh-CN.ts +1 -0
- package/dist/templates/default/app/i18n/zh-TW.ts +1 -0
- package/dist/tracking/registry.js +11 -4
- package/package.json +4 -3
- package/src/templates/default/app/i18n/ar-SA.ts +1 -0
- package/src/templates/default/app/i18n/de-DE.ts +1 -0
- package/src/templates/default/app/i18n/en-US.ts +1 -0
- package/src/templates/default/app/i18n/es-ES.ts +1 -0
- package/src/templates/default/app/i18n/fr-FR.ts +1 -0
- package/src/templates/default/app/i18n/hi-IN.ts +1 -0
- package/src/templates/default/app/i18n/ja-JP.ts +1 -0
- package/src/templates/default/app/i18n/ko-KR.ts +1 -0
- package/src/templates/default/app/i18n/pt-BR.ts +1 -0
- package/src/templates/default/app/i18n/zh-CN.ts +1 -0
- package/src/templates/default/app/i18n/zh-TW.ts +1 -0
- package/corpus/templates/slides/app/components/editor/SlideBubbleMenu.tsx +0 -488
- package/corpus/templates/slides/app/components/editor/SlideInlineEditor.tsx +0 -589
- package/corpus/templates/slides/app/components/editor/SlideRichTextEditor.tsx +0 -1347
- package/corpus/templates/slides/app/components/editor/SlideSlashMenu.tsx +0 -373
|
@@ -1,373 +0,0 @@
|
|
|
1
|
-
import { useT } from "@agent-native/core/client/i18n";
|
|
2
|
-
import {
|
|
3
|
-
IconH1,
|
|
4
|
-
IconH2,
|
|
5
|
-
IconH3,
|
|
6
|
-
IconList,
|
|
7
|
-
IconListNumbers,
|
|
8
|
-
IconBlockquote,
|
|
9
|
-
IconLetterT,
|
|
10
|
-
} from "@tabler/icons-react";
|
|
11
|
-
import { Extension } from "@tiptap/core";
|
|
12
|
-
import { Plugin, PluginKey } from "@tiptap/pm/state";
|
|
13
|
-
import type { Editor } from "@tiptap/react";
|
|
14
|
-
import {
|
|
15
|
-
useState,
|
|
16
|
-
useEffect,
|
|
17
|
-
useRef,
|
|
18
|
-
useCallback,
|
|
19
|
-
forwardRef,
|
|
20
|
-
useImperativeHandle,
|
|
21
|
-
} from "react";
|
|
22
|
-
import { createPortal } from "react-dom";
|
|
23
|
-
|
|
24
|
-
import { cn } from "@/lib/utils";
|
|
25
|
-
|
|
26
|
-
const SLASH_MENU_KEY = new PluginKey("slideSlashMenu");
|
|
27
|
-
|
|
28
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
29
|
-
type AnyIcon = React.ComponentType<any>;
|
|
30
|
-
|
|
31
|
-
interface SlashCommand {
|
|
32
|
-
titleKey: string;
|
|
33
|
-
descriptionKey: string;
|
|
34
|
-
icon: AnyIcon;
|
|
35
|
-
command: (editor: Editor) => void;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const SLASH_COMMANDS: SlashCommand[] = [
|
|
39
|
-
{
|
|
40
|
-
titleKey: "slideSlashMenu.text",
|
|
41
|
-
descriptionKey: "slideSlashMenu.plainParagraph",
|
|
42
|
-
icon: IconLetterT,
|
|
43
|
-
command: (editor) => editor.chain().focus().setParagraph().run(),
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
titleKey: "slideSlashMenu.heading1",
|
|
47
|
-
descriptionKey: "slideSlashMenu.largeSlideHeading",
|
|
48
|
-
icon: IconH1,
|
|
49
|
-
command: (editor) =>
|
|
50
|
-
editor.chain().focus().toggleHeading({ level: 1 }).run(),
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
titleKey: "slideSlashMenu.heading2",
|
|
54
|
-
descriptionKey: "slideSlashMenu.mediumHeading",
|
|
55
|
-
icon: IconH2,
|
|
56
|
-
command: (editor) =>
|
|
57
|
-
editor.chain().focus().toggleHeading({ level: 2 }).run(),
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
titleKey: "slideSlashMenu.heading3",
|
|
61
|
-
descriptionKey: "slideSlashMenu.smallHeading",
|
|
62
|
-
icon: IconH3,
|
|
63
|
-
command: (editor) =>
|
|
64
|
-
editor.chain().focus().toggleHeading({ level: 3 }).run(),
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
titleKey: "slideSlashMenu.bulletList",
|
|
68
|
-
descriptionKey: "slideSlashMenu.unorderedList",
|
|
69
|
-
icon: IconList,
|
|
70
|
-
command: (editor) => editor.chain().focus().toggleBulletList().run(),
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
titleKey: "slideSlashMenu.numberedList",
|
|
74
|
-
descriptionKey: "slideSlashMenu.orderedList",
|
|
75
|
-
icon: IconListNumbers,
|
|
76
|
-
command: (editor) => editor.chain().focus().toggleOrderedList().run(),
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
titleKey: "slideSlashMenu.quote",
|
|
80
|
-
descriptionKey: "slideSlashMenu.blockquote",
|
|
81
|
-
icon: IconBlockquote,
|
|
82
|
-
command: (editor) => editor.chain().focus().toggleBlockquote().run(),
|
|
83
|
-
},
|
|
84
|
-
];
|
|
85
|
-
|
|
86
|
-
interface SlashMenuUIProps {
|
|
87
|
-
editor: Editor;
|
|
88
|
-
position: { x: number; y: number } | null;
|
|
89
|
-
query: string;
|
|
90
|
-
onClose: () => void;
|
|
91
|
-
onCommand: (cmd: SlashCommand) => void;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export const SlashMenuUI = forwardRef<
|
|
95
|
-
{ moveUp: () => void; moveDown: () => void; select: () => void },
|
|
96
|
-
SlashMenuUIProps
|
|
97
|
-
>(({ position, query, onCommand }, ref) => {
|
|
98
|
-
const t = useT();
|
|
99
|
-
const [selectedIndex, setSelectedIndex] = useState(0);
|
|
100
|
-
|
|
101
|
-
const filtered = SLASH_COMMANDS.filter((cmd) => {
|
|
102
|
-
const title = t(cmd.titleKey);
|
|
103
|
-
const description = t(cmd.descriptionKey);
|
|
104
|
-
return (
|
|
105
|
-
!query ||
|
|
106
|
-
title.toLowerCase().includes(query.toLowerCase()) ||
|
|
107
|
-
description.toLowerCase().includes(query.toLowerCase())
|
|
108
|
-
);
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
useImperativeHandle(ref, () => ({
|
|
112
|
-
moveUp: () =>
|
|
113
|
-
setSelectedIndex((i) => (i <= 0 ? filtered.length - 1 : i - 1)),
|
|
114
|
-
moveDown: () =>
|
|
115
|
-
setSelectedIndex((i) => (i >= filtered.length - 1 ? 0 : i + 1)),
|
|
116
|
-
select: () => {
|
|
117
|
-
const cmd = filtered[selectedIndex];
|
|
118
|
-
if (cmd) onCommand(cmd);
|
|
119
|
-
},
|
|
120
|
-
}));
|
|
121
|
-
|
|
122
|
-
// Reset selection when filter changes
|
|
123
|
-
useEffect(() => {
|
|
124
|
-
setSelectedIndex(0);
|
|
125
|
-
}, [query]);
|
|
126
|
-
|
|
127
|
-
if (!position || filtered.length === 0) return null;
|
|
128
|
-
|
|
129
|
-
return createPortal(
|
|
130
|
-
<div
|
|
131
|
-
data-slash-menu="true"
|
|
132
|
-
className="fixed z-[9999] w-60 rounded-lg bg-popover border border-border shadow-2xl overflow-hidden py-1"
|
|
133
|
-
style={{ top: position.y, left: position.x }}
|
|
134
|
-
>
|
|
135
|
-
<div className="px-2 py-1 text-[10px] font-semibold text-muted-foreground/70 uppercase tracking-widest">
|
|
136
|
-
{t("slideSlashMenu.blocks")}
|
|
137
|
-
</div>
|
|
138
|
-
{filtered.map((cmd, i) => {
|
|
139
|
-
const Icon = cmd.icon;
|
|
140
|
-
const title = t(cmd.titleKey);
|
|
141
|
-
const description = t(cmd.descriptionKey);
|
|
142
|
-
return (
|
|
143
|
-
<button
|
|
144
|
-
key={cmd.titleKey}
|
|
145
|
-
className={cn(
|
|
146
|
-
"w-full flex items-center gap-3 px-3 py-2 text-left",
|
|
147
|
-
i === selectedIndex
|
|
148
|
-
? "bg-accent text-foreground"
|
|
149
|
-
: "text-foreground/80 hover:bg-accent/50 hover:text-foreground",
|
|
150
|
-
)}
|
|
151
|
-
onMouseEnter={() => setSelectedIndex(i)}
|
|
152
|
-
onClick={() => onCommand(cmd)}
|
|
153
|
-
>
|
|
154
|
-
<div className="w-7 h-7 rounded flex items-center justify-center bg-accent/50 shrink-0">
|
|
155
|
-
<Icon size={14} stroke={2} />
|
|
156
|
-
</div>
|
|
157
|
-
<div>
|
|
158
|
-
<div className="text-sm font-medium leading-tight">{title}</div>
|
|
159
|
-
<div className="text-xs text-muted-foreground leading-tight">
|
|
160
|
-
{description}
|
|
161
|
-
</div>
|
|
162
|
-
</div>
|
|
163
|
-
</button>
|
|
164
|
-
);
|
|
165
|
-
})}
|
|
166
|
-
</div>,
|
|
167
|
-
document.body,
|
|
168
|
-
);
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
SlashMenuUI.displayName = "SlashMenuUI";
|
|
172
|
-
|
|
173
|
-
/**
|
|
174
|
-
* TipTap extension that fires a custom event when the user types / at the
|
|
175
|
-
* start of a block so the host component can show a slash command menu.
|
|
176
|
-
*/
|
|
177
|
-
export const SlashCommandExtension = Extension.create({
|
|
178
|
-
name: "slideSlashCommand",
|
|
179
|
-
|
|
180
|
-
addProseMirrorPlugins() {
|
|
181
|
-
return [
|
|
182
|
-
new Plugin({
|
|
183
|
-
key: SLASH_MENU_KEY,
|
|
184
|
-
props: {
|
|
185
|
-
handleKeyDown: (view, event) => {
|
|
186
|
-
// Let the host component's keydown listener handle navigation
|
|
187
|
-
if (
|
|
188
|
-
event.key === "ArrowUp" ||
|
|
189
|
-
event.key === "ArrowDown" ||
|
|
190
|
-
event.key === "Enter" ||
|
|
191
|
-
event.key === "Escape"
|
|
192
|
-
) {
|
|
193
|
-
// Capture open state BEFORE dispatching — the event listener may
|
|
194
|
-
// call closeMenu() synchronously, flipping the flag to false.
|
|
195
|
-
const wasOpen = (view.dom as any).__slashMenuOpen;
|
|
196
|
-
|
|
197
|
-
// Dispatch so the React component can intercept
|
|
198
|
-
const customEvent = new CustomEvent("slide-slash-nav", {
|
|
199
|
-
detail: { key: event.key },
|
|
200
|
-
bubbles: true,
|
|
201
|
-
});
|
|
202
|
-
view.dom.dispatchEvent(customEvent);
|
|
203
|
-
|
|
204
|
-
// If the menu was open, swallow Arrow/Enter/Escape and stop
|
|
205
|
-
// propagation so window-level listeners (e.g. SlideEditor's
|
|
206
|
-
// Escape handler) don't also fire.
|
|
207
|
-
if (wasOpen) {
|
|
208
|
-
event.stopPropagation();
|
|
209
|
-
return true;
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
return false;
|
|
213
|
-
},
|
|
214
|
-
},
|
|
215
|
-
}),
|
|
216
|
-
];
|
|
217
|
-
},
|
|
218
|
-
});
|
|
219
|
-
|
|
220
|
-
/** Hook that manages slash command state for a TipTap editor */
|
|
221
|
-
export function useSlashMenu(editor: Editor | null) {
|
|
222
|
-
const [menuPosition, setMenuPosition] = useState<{
|
|
223
|
-
x: number;
|
|
224
|
-
y: number;
|
|
225
|
-
} | null>(null);
|
|
226
|
-
const [query, setQuery] = useState("");
|
|
227
|
-
const menuRef = useRef<{
|
|
228
|
-
moveUp: () => void;
|
|
229
|
-
moveDown: () => void;
|
|
230
|
-
select: () => void;
|
|
231
|
-
}>(null);
|
|
232
|
-
const slashPosRef = useRef<number | null>(null);
|
|
233
|
-
|
|
234
|
-
const closeMenu = useCallback(() => {
|
|
235
|
-
setMenuPosition(null);
|
|
236
|
-
setQuery("");
|
|
237
|
-
slashPosRef.current = null;
|
|
238
|
-
if (editor?.view?.dom) {
|
|
239
|
-
(editor.view.dom as any).__slashMenuOpen = false;
|
|
240
|
-
}
|
|
241
|
-
}, [editor]);
|
|
242
|
-
|
|
243
|
-
const executeCommand = useCallback(
|
|
244
|
-
(cmd: SlashCommand) => {
|
|
245
|
-
if (!editor) return;
|
|
246
|
-
// Capture position BEFORE closeMenu() nulls slashPosRef
|
|
247
|
-
const slashPos = slashPosRef.current;
|
|
248
|
-
const { from } = editor.state.selection;
|
|
249
|
-
closeMenu();
|
|
250
|
-
|
|
251
|
-
if (slashPos !== null) {
|
|
252
|
-
// Delete the slash + any query text, then apply the block-type command.
|
|
253
|
-
// Use requestAnimationFrame so the deleteRange transaction commits and
|
|
254
|
-
// the editor's selection is stable before toggleHeading/etc. runs.
|
|
255
|
-
editor.chain().focus().deleteRange({ from: slashPos, to: from }).run();
|
|
256
|
-
requestAnimationFrame(() => cmd.command(editor));
|
|
257
|
-
} else {
|
|
258
|
-
cmd.command(editor);
|
|
259
|
-
}
|
|
260
|
-
},
|
|
261
|
-
[editor, closeMenu],
|
|
262
|
-
);
|
|
263
|
-
|
|
264
|
-
useEffect(() => {
|
|
265
|
-
if (!editor) return;
|
|
266
|
-
|
|
267
|
-
const onUpdate = () => {
|
|
268
|
-
const { state } = editor;
|
|
269
|
-
const { selection } = state;
|
|
270
|
-
const { $from } = selection;
|
|
271
|
-
|
|
272
|
-
// Get text from start of block to cursor
|
|
273
|
-
const textBefore = $from.parent.textBetween(0, $from.parentOffset, "\n");
|
|
274
|
-
|
|
275
|
-
// Find slash position
|
|
276
|
-
const slashIndex = textBefore.lastIndexOf("/");
|
|
277
|
-
if (slashIndex === -1) {
|
|
278
|
-
if (menuPosition) closeMenu();
|
|
279
|
-
return;
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
// Only trigger if slash is recent (within 20 chars of end) and nothing before it except whitespace
|
|
283
|
-
const beforeSlash = textBefore.slice(0, slashIndex);
|
|
284
|
-
if (beforeSlash.trim().length > 0) {
|
|
285
|
-
if (menuPosition) closeMenu();
|
|
286
|
-
return;
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
const q = textBefore.slice(slashIndex + 1);
|
|
290
|
-
// Don't show menu if query has spaces
|
|
291
|
-
if (q.includes(" ")) {
|
|
292
|
-
if (menuPosition) closeMenu();
|
|
293
|
-
return;
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
setQuery(q);
|
|
297
|
-
|
|
298
|
-
// Calculate menu position from the slash character position
|
|
299
|
-
const slashAbsPos = $from.pos - $from.parentOffset + slashIndex;
|
|
300
|
-
slashPosRef.current = slashAbsPos;
|
|
301
|
-
|
|
302
|
-
// Get DOM position of the slash character
|
|
303
|
-
try {
|
|
304
|
-
const coords = editor.view.coordsAtPos(slashAbsPos + 1);
|
|
305
|
-
|
|
306
|
-
// Position below the line
|
|
307
|
-
setMenuPosition({
|
|
308
|
-
x: Math.min(coords.left, window.innerWidth - 260),
|
|
309
|
-
y: Math.min(coords.bottom + 4, window.innerHeight - 300),
|
|
310
|
-
});
|
|
311
|
-
(editor.view.dom as any).__slashMenuOpen = true;
|
|
312
|
-
} catch {
|
|
313
|
-
// coordsAtPos can fail if position is out of range
|
|
314
|
-
}
|
|
315
|
-
};
|
|
316
|
-
|
|
317
|
-
editor.on("update", onUpdate);
|
|
318
|
-
return () => {
|
|
319
|
-
editor.off("update", onUpdate);
|
|
320
|
-
};
|
|
321
|
-
}, [editor, menuPosition, closeMenu]);
|
|
322
|
-
|
|
323
|
-
// Handle keyboard navigation when menu is open
|
|
324
|
-
useEffect(() => {
|
|
325
|
-
if (!editor?.view?.dom) return;
|
|
326
|
-
const dom = editor.view.dom;
|
|
327
|
-
|
|
328
|
-
const onNav = (e: Event) => {
|
|
329
|
-
const detail = (e as CustomEvent).detail;
|
|
330
|
-
if (!menuPosition) return;
|
|
331
|
-
|
|
332
|
-
if (detail.key === "ArrowUp") {
|
|
333
|
-
e.preventDefault();
|
|
334
|
-
menuRef.current?.moveUp();
|
|
335
|
-
} else if (detail.key === "ArrowDown") {
|
|
336
|
-
e.preventDefault();
|
|
337
|
-
menuRef.current?.moveDown();
|
|
338
|
-
} else if (detail.key === "Enter") {
|
|
339
|
-
e.preventDefault();
|
|
340
|
-
menuRef.current?.select();
|
|
341
|
-
} else if (detail.key === "Escape") {
|
|
342
|
-
// Delete the "/" and any query text before closing
|
|
343
|
-
if (editor && slashPosRef.current !== null) {
|
|
344
|
-
const { from } = editor.state.selection;
|
|
345
|
-
editor
|
|
346
|
-
.chain()
|
|
347
|
-
.focus()
|
|
348
|
-
.deleteRange({ from: slashPosRef.current, to: from })
|
|
349
|
-
.run();
|
|
350
|
-
}
|
|
351
|
-
closeMenu();
|
|
352
|
-
}
|
|
353
|
-
};
|
|
354
|
-
|
|
355
|
-
dom.addEventListener("slide-slash-nav", onNav);
|
|
356
|
-
return () => dom.removeEventListener("slide-slash-nav", onNav);
|
|
357
|
-
}, [editor, menuPosition, closeMenu]);
|
|
358
|
-
|
|
359
|
-
// Close on click outside
|
|
360
|
-
useEffect(() => {
|
|
361
|
-
if (!menuPosition) return;
|
|
362
|
-
const onDown = (e: MouseEvent) => {
|
|
363
|
-
const target = e.target as Element;
|
|
364
|
-
if (!target.closest('[data-slash-menu="true"]')) {
|
|
365
|
-
closeMenu();
|
|
366
|
-
}
|
|
367
|
-
};
|
|
368
|
-
document.addEventListener("mousedown", onDown);
|
|
369
|
-
return () => document.removeEventListener("mousedown", onDown);
|
|
370
|
-
}, [menuPosition, closeMenu]);
|
|
371
|
-
|
|
372
|
-
return { menuPosition, query, menuRef, closeMenu, executeCommand };
|
|
373
|
-
}
|