@docyrus/ui-pro-ai-assistant 0.8.2 → 0.8.4

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/index.js CHANGED
@@ -11,6 +11,7 @@ import { Tabs as Tabs$1, TabsList as TabsList$1, TabsTrigger as TabsTrigger$1, T
11
11
  import { cn } from '@docyrus/ui-pro-shared/lib/utils';
12
12
  import { DefaultChatTransport, lastAssistantMessageIsCompleteWithToolCalls } from 'ai';
13
13
  import { Pencil, PilcrowIcon, Heading1Icon, Heading2Icon, Heading3Icon, SquareIcon, ListIcon, ListOrderedIcon, ChevronDownIcon, Code2Icon, QuoteIcon, LightbulbIcon, Columns3Icon, GripVertical, FileUpIcon, TableIcon, ImageIcon, FilmIcon, AudioLinesIcon, TableOfContentsIcon, RadicalIcon, RectangleVerticalIcon, CalendarIcon, PlusIcon, FileCodeIcon, MinusIcon, ChevronRightIcon, ListTree, PenToolIcon, Link2Icon, Check, X, Copy, FilesIcon, Link, Text, ExternalLink, Unlink, Bold, Italic, Underline, Strikethrough, Code2, MoreHorizontal, ArrowLeftIcon, ArrowRightIcon, Minus, Plus, CircleArrowDown, Minimize2, Trash2, FileUp, CheckCircle2, FileText, Loader2, Wrench, CornerDownLeftIcon, PencilLineIcon, MessageSquareTextIcon, MessagesSquareIcon, ArrowUpIcon, CheckIcon, CaptionsIcon, ZoomInIcon, CircleArrowDownIcon, MoveUpRightIcon, MoreHorizontalIcon, Eye, PlusCircle, HelpCircle, Maximize2, Download, FileSpreadsheet, ChevronDown, ChevronLeft, ChevronRight, CheckCircle, XCircle, Search, Globe, User, ArrowRight, MapPin, CalendarClock, List, RefreshCw, FilePlus, XIcon, CornerUpLeftIcon, AlbumIcon, FeatherIcon, ListMinusIcon, ListPlusIcon, ListEnd, Wand, LanguagesIcon, BadgeHelpIcon, PenLineIcon, SearchIcon, MusicIcon, CompassIcon, SmileIcon, LeafIcon, ClockIcon, AppleIcon, FlagIcon, StarIcon, DeleteIcon, AlignLeft, AlignCenter, AlignRight, RotateCcw, AlertTriangle, AlertCircle, ArrowUpDown, ArrowDownToLine, PenLine, PencilIcon, TrashIcon, FileIcon, Star, ChevronsUpDown, FolderIcon, MessageSquare, Hash, Table, CheckSquare, Calendar as Calendar$1, Clock, Phone, Mail, Send, RefreshCcw, Undo2, ChevronsUpDownIcon, ChevronsRight, ChevronsLeft, CalendarDays, RefreshCwIcon, PaintRoller, MessageSquareText, ArrowLeft, Boxes, Users, Bot, Brain, Lightbulb, BookOpen, PenTool, SlidersHorizontal, Wand2, Mic, Code, Trash, Edit, Share, FolderInput, Archive, Building2, ShieldCheck, PanelLeft, NotebookText, CirclePlus, MoreVertical, FileSearch, Microscope, Ruler, AudioLines, BrainCircuit, Circle, Zap, Upload, ThumbsUp, ThumbsDown, Sun, Shield, Settings, Play, Pause, Moon, Menu, Lock, Info, Image, Home, Heart, Folder, Filter, File as File$1, CreditCard, Cog, Cloud, ChevronUp, Bookmark, Bell, Plug, Inbox, LayoutGrid, FolderOpen, LayoutDashboard, Table2, WandSparklesIcon, ArrowUpToLineIcon, BoldIcon, ItalicIcon, UnderlineIcon, StrikethroughIcon, HighlighterIcon, Undo2Icon, Redo2Icon, ArrowDownToLineIcon, AlignLeftIcon, AlignCenterIcon, AlignRightIcon, AlignJustifyIcon, ListOrdered, ListTodoIcon, ListCollapseIcon, Grid3x3Icon, Combine, Ungroup, ArrowUp, ArrowDown, Trash2Icon, LinkIcon, WrapText, OutdentIcon, IndentIcon, EyeIcon, PenIcon } from 'lucide-react';
14
+ import { Tooltip, Slot, DropdownMenu, Dialog, AlertDialog as AlertDialog$1, Popover, Separator, Toolbar as Toolbar$1 } from 'radix-ui';
14
15
  import { Message, AIMessageAvatar, MessageContent, MessageActions, MessageAction, AIConversation, AIConversationContent, MessageResponse, AIConversationScrollButton, Tool, ToolHeader, ToolContent, ToolInput, ToolOutput, CodeBlock, CodeBlockCopyButton, resolveToolIcon, PromptInputButton, PromptInput, PromptInputTextarea, PromptInputFooter, PromptInputTools, PromptInputSubmit, usePromptInputAttachments } from '@docyrus/ui-pro-shared/ai';
15
16
  import { AsyncTokenManager, RestApiClient } from '@docyrus/api-client';
16
17
  import { TooltipProvider as TooltipProvider$1, Tooltip as Tooltip$2, TooltipTrigger as TooltipTrigger$1, TooltipContent as TooltipContent$1 } from '@docyrus/ui-pro-shared/components/tooltip';
@@ -63,7 +64,6 @@ import { ResponsiveContainer, BarChart, CartesianGrid, XAxis, YAxis, Tooltip as
63
64
  import Markdown from 'react-markdown';
64
65
  import remarkGfm from 'remark-gfm';
65
66
  import { Progress } from '@docyrus/ui-pro-shared/components/progress';
66
- import { Tooltip, Slot, DropdownMenu, Dialog, AlertDialog as AlertDialog$1, Popover, Separator, Toolbar as Toolbar$1 } from 'radix-ui';
67
67
  import { Label as Label$1 } from '@docyrus/ui-pro-shared/components/label';
68
68
  import { Popover as Popover$2, PopoverTrigger as PopoverTrigger$1, PopoverContent as PopoverContent$1 } from '@docyrus/ui-pro-shared/components/popover';
69
69
  import { RadioGroup as RadioGroup$1, RadioGroupItem } from '@docyrus/ui-pro-shared/components/radio-group';
@@ -211,7 +211,7 @@ import '@univerjs/sheets-crosshair-highlight/lib/index.css';
211
211
  import * as XLSX from 'xlsx';
212
212
  import { MarkdownPlugin, remarkMdx, remarkMention, serializeMd, stripMarkdown, deserializeMd } from '@platejs/markdown';
213
213
  import { usePlateEditor, toTPlatePlugin, useEditorContainerRef, createPlatePlugin, usePluginOption, ParagraphPlugin, BlockPlaceholderPlugin, useEditorRef, useElement, Key, createPrimitiveComponent, withHOC, PlateElement, useReadOnly, useEditorPlugin, useEditorMounted, Plate, PlateContent, PlateLeaf, useHotkeys, PlateText, useSelected, useFocused, useEventEditorValue, useComposedRef, useEditorReadOnly, useSelectionAcrossBlocks, useEditorSelector, useElementSelector, MemoizedChildren, useSelectionFragmentProp, useMarkToolbarButtonState, useMarkToolbarButton, PlateContainer, usePlateState } from 'platejs/react';
214
- import { KEYS, TrailingBlockPlugin, isSlateString, isSlateEditor, isSlateElement, getPluginType, PathApi, isHotkey, getPluginTypes, ExitBreakPlugin, nanoid, BaseParagraphPlugin, NodeApi, TextApi, isType, IS_APPLE, RangeApi, getPluginByType, ElementApi, createSlateEditor, isUrl } from 'platejs';
214
+ import { KEYS, TrailingBlockPlugin, isSlateString, isSlateEditor, isSlateElement, getPluginType, PathApi, createSlatePlugin, isHotkey, getPluginTypes, ExitBreakPlugin, nanoid, BaseParagraphPlugin, NodeApi, TextApi, createTextSubstitutionInputRule, isType, IS_APPLE, RangeApi, getPluginByType, ElementApi, createSlateEditor, isUrl } from 'platejs';
215
215
  import { withAIBatch } from '@platejs/ai';
216
216
  import { useAIChatEditor, AIChatPlugin, useChatChunk, streamInsertChunk, applyAISuggestions, rejectAISuggestions, AIPlugin, CopilotPlugin, useLastAssistantMessage, useEditorChat, applyTableCellSuggestion, aiCommentToRange } from '@platejs/ai/react';
217
217
  import { CursorOverlayPlugin, BlockSelectionPlugin, BlockMenuPlugin, useBlockSelected, useCursorOverlay, useIsSelecting, BLOCK_CONTEXT_MENU_ID, useBlockSelectionNodes, useBlockSelectionFragmentProp } from '@platejs/selection/react';
@@ -225,13 +225,11 @@ import { CaptionPlugin, TextareaAutosize as TextareaAutosize$1, Caption as Capti
225
225
  import { BaseCommentPlugin, getDraftCommentKey, getCommentCount, getTransientCommentKey, getCommentKey } from '@platejs/comment';
226
226
  import { CommentPlugin, useCommentId } from '@platejs/comment/react';
227
227
  import { SuggestionPlugin } from '@platejs/suggestion/react';
228
+ import { BoldRules, MarkComboRules, ItalicRules, UnderlineRules, CodeRules, StrikethroughRules, SubscriptRules, SuperscriptRules, HighlightRules, HeadingRules, BlockquoteRules, HorizontalRuleRules, BaseH1Plugin, BaseH2Plugin, BaseH3Plugin, BaseBlockquotePlugin, BaseHorizontalRulePlugin, BaseBoldPlugin, BaseItalicPlugin, BaseUnderlinePlugin, BaseStrikethroughPlugin, BaseSubscriptPlugin, BaseSuperscriptPlugin, BaseCodePlugin, BaseHighlightPlugin } from '@platejs/basic-nodes';
228
229
  import { BoldPlugin, ItalicPlugin, UnderlinePlugin, CodePlugin, StrikethroughPlugin, SubscriptPlugin, SuperscriptPlugin, HighlightPlugin, H1Plugin, H2Plugin, H3Plugin, BlockquotePlugin, HorizontalRulePlugin } from '@platejs/basic-nodes/react';
229
- import { AutoformatPlugin, autoformatSmartQuotes, autoformatPunctuation, autoformatLegal, autoformatLegalHtml, autoformatArrow, autoformatMath } from '@platejs/autoformat';
230
- import { insertEmptyCodeBlock, insertCodeBlock, BaseCodeBlockPlugin, BaseCodeLinePlugin, BaseCodeSyntaxPlugin } from '@platejs/code-block';
231
- import { expandListItemsWithChildren, BaseListPlugin, toggleList, isOrderedList, someList, ListStyleType } from '@platejs/list';
232
- import { openNextToggles, TogglePlugin, useToggleButtonState, useToggleButton, useToggleToolbarButtonState, useToggleToolbarButton } from '@platejs/toggle/react';
233
230
  import { DndPlugin, useDropLine, useDraggable } from '@platejs/dnd';
234
231
  import { insertCallout, BaseCalloutPlugin } from '@platejs/callout';
232
+ import { insertCodeBlock, CodeBlockRules, BaseCodeBlockPlugin, BaseCodeLinePlugin, BaseCodeSyntaxPlugin } from '@platejs/code-block';
235
233
  import { insertDate, BaseDatePlugin } from '@platejs/date';
236
234
  import { BaseColumnPlugin, BaseColumnItemPlugin, insertColumnGroup, toggleColumnGroup } from '@platejs/layout';
237
235
  import { insertEquation, insertInlineEquation, BaseInlineEquationPlugin, BaseEquationPlugin, getEquationHtml } from '@platejs/math';
@@ -250,6 +248,7 @@ import { DatePlugin } from '@platejs/date/react';
250
248
  import { PlaceholderPlugin, useMediaState, useImage, PlaceholderProvider, usePlaceholderElementState, usePlaceholderPopoverState, ImagePlugin, MediaEmbedPlugin, VideoPlugin, AudioPlugin, FilePlugin, useImagePreviewValue, useImagePreview, PreviewImage as PreviewImage$1, useMediaControllerState, useMediaController, openImagePreview, UploadErrorCode, useScaleInput, useMediaControllerDropDownMenu } from '@platejs/media/react';
251
249
  import { DndProvider } from 'react-dnd';
252
250
  import { HTML5Backend } from 'react-dnd-html5-backend';
251
+ import { expandListItemsWithChildren, isOrderedList, BulletedListRules, OrderedListRules, TaskListRules, BaseListPlugin, someList, ListStyleType, toggleList } from '@platejs/list';
253
252
  import { DocxPlugin } from '@platejs/docx';
254
253
  import { JuicePlugin } from '@platejs/juice';
255
254
  import emojiMartData from '@emoji-mart/data';
@@ -267,11 +266,11 @@ import LiteYouTubeEmbed from 'react-lite-youtube-embed';
267
266
  import ReactPlayer from 'react-player';
268
267
  import { MentionPlugin, MentionInputPlugin } from '@platejs/mention/react';
269
268
  import { SlashPlugin, SlashInputPlugin } from '@platejs/slash-command/react';
270
- import { TableProvider, TablePlugin, useTableElement, TableRowPlugin, TableCellPlugin, TableCellHeaderPlugin, useTableCellElement, useTableCellElementResizable, useTableMergeState } from '@platejs/table/react';
269
+ import { TableProvider, TablePlugin, useTableElement, useTableSelectionDom, TableRowPlugin, TableCellPlugin, TableCellHeaderPlugin, useTableCellElement, useTableCellElementResizable, useTableMergeState } from '@platejs/table/react';
271
270
  import { TocPlugin, useTocElementState, useTocElement } from '@platejs/toc/react';
271
+ import { TogglePlugin, useToggleButtonState, useToggleButton, useToggleToolbarButtonState, useToggleToolbarButton } from '@platejs/toggle/react';
272
272
  import { DocxExportPlugin, importDocx, exportToDocx } from '@platejs/docx-io';
273
273
  import { SlateElement, SlateLeaf, serializeHtml, PlateStatic, getEditorDOMFromHtmlString } from 'platejs/static';
274
- import { BaseH1Plugin, BaseH2Plugin, BaseH3Plugin, BaseBlockquotePlugin, BaseHorizontalRulePlugin, BaseBoldPlugin, BaseItalicPlugin, BaseUnderlinePlugin, BaseStrikethroughPlugin, BaseSubscriptPlugin, BaseSuperscriptPlugin, BaseCodePlugin, BaseHighlightPlugin } from '@platejs/basic-nodes';
275
274
  import { BaseFontColorPlugin, BaseFontBackgroundColorPlugin, BaseFontSizePlugin, BaseFontFamilyPlugin, toUnitLess } from '@platejs/basic-styles';
276
275
  import { BaseIndentPlugin } from '@platejs/indent';
277
276
  import { BaseCaptionPlugin } from '@platejs/caption';
@@ -2756,6 +2755,7 @@ function AgentConsentDialog({
2756
2755
  pending,
2757
2756
  onApproved,
2758
2757
  onDeclined,
2758
+ container,
2759
2759
  t
2760
2760
  }) {
2761
2761
  const apiClient = useApiClient();
@@ -2795,38 +2795,52 @@ function AgentConsentDialog({
2795
2795
  });
2796
2796
  onDeclined();
2797
2797
  };
2798
- return /* @__PURE__ */ jsx(Dialog$1, { open: !!pending, children: /* @__PURE__ */ jsxs(
2799
- DialogContent,
2800
- {
2801
- showCloseButton: false,
2802
- onInteractOutside: (e) => e.preventDefault(),
2803
- onEscapeKeyDown: (e) => e.preventDefault(),
2804
- className: "z-[200] sm:max-w-lg",
2805
- children: [
2806
- /* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsx(DialogTitle, { children: t("agentConsent.title") }) }),
2807
- /* @__PURE__ */ jsx("div", { className: "max-h-[55vh] overflow-y-auto pr-1 text-sm", children: /* @__PURE__ */ jsx(MessageResponse, { children: t("agentConsent.body") }) }),
2808
- /* @__PURE__ */ jsxs(DialogFooter, { children: [
2809
- /* @__PURE__ */ jsx(
2810
- Button,
2811
- {
2812
- variant: "outline",
2813
- onClick: declineConsent,
2814
- disabled: loading,
2815
- children: t("agentConsent.decline")
2816
- }
2817
- ),
2818
- /* @__PURE__ */ jsx(
2819
- Button,
2820
- {
2821
- onClick: acceptConsent,
2822
- disabled: !canApprove || loading,
2823
- children: t("agentConsent.approve")
2824
- }
2825
- )
2826
- ] })
2827
- ]
2828
- }
2829
- ) });
2798
+ const scoped = !!container;
2799
+ return /* @__PURE__ */ jsx(Dialog.Root, { open: !!pending, children: /* @__PURE__ */ jsxs(Dialog.Portal, { container: container ?? void 0, children: [
2800
+ /* @__PURE__ */ jsx(
2801
+ Dialog.Overlay,
2802
+ {
2803
+ className: cn(
2804
+ "data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs isolate z-[200] inset-0",
2805
+ scoped ? "absolute" : "fixed"
2806
+ )
2807
+ }
2808
+ ),
2809
+ /* @__PURE__ */ jsxs(
2810
+ Dialog.Content,
2811
+ {
2812
+ onInteractOutside: (e) => e.preventDefault(),
2813
+ onEscapeKeyDown: (e) => e.preventDefault(),
2814
+ className: cn(
2815
+ "bg-background data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 ring-foreground/10 grid w-full max-w-[calc(100%-2rem)] gap-6 rounded-xl p-6 text-sm ring-1 duration-100 sm:max-w-lg top-1/2 inset-s-1/2 z-[200] -translate-x-1/2 rtl:translate-x-1/2 -translate-y-1/2 outline-none",
2816
+ scoped ? "absolute" : "fixed"
2817
+ ),
2818
+ children: [
2819
+ /* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsx(DialogTitle, { children: t("agentConsent.title") }) }),
2820
+ /* @__PURE__ */ jsx("div", { className: "max-h-[55vh] overflow-y-auto pr-1 text-sm", children: /* @__PURE__ */ jsx(MessageResponse, { children: t("agentConsent.body") }) }),
2821
+ /* @__PURE__ */ jsxs(DialogFooter, { children: [
2822
+ /* @__PURE__ */ jsx(
2823
+ Button,
2824
+ {
2825
+ variant: "outline",
2826
+ onClick: declineConsent,
2827
+ disabled: loading,
2828
+ children: t("agentConsent.decline")
2829
+ }
2830
+ ),
2831
+ /* @__PURE__ */ jsx(
2832
+ Button,
2833
+ {
2834
+ onClick: acceptConsent,
2835
+ disabled: !canApprove || loading,
2836
+ children: t("agentConsent.approve")
2837
+ }
2838
+ )
2839
+ ] })
2840
+ ]
2841
+ }
2842
+ )
2843
+ ] }) });
2830
2844
  }
2831
2845
  var pickAvatar = (raw) => {
2832
2846
  const candidate = raw?.agentAvatar ?? raw?.avatar;
@@ -24011,23 +24025,41 @@ function HighlightLeaf(props) {
24011
24025
 
24012
24026
  // src/internal/plate-editor/editor/plugins/basic-marks-kit.tsx
24013
24027
  var BasicMarksKit = [
24014
- BoldPlugin,
24015
- ItalicPlugin,
24016
- UnderlinePlugin,
24028
+ BoldPlugin.configure({
24029
+ inputRules: [
24030
+ BoldRules.markdown({ variant: "*" }),
24031
+ BoldRules.markdown({ variant: "_" }),
24032
+ MarkComboRules.markdown({ variant: "boldItalic" }),
24033
+ MarkComboRules.markdown({ variant: "boldUnderline" }),
24034
+ MarkComboRules.markdown({ variant: "boldItalicUnderline" }),
24035
+ MarkComboRules.markdown({ variant: "italicUnderline" })
24036
+ ]
24037
+ }),
24038
+ ItalicPlugin.configure({
24039
+ inputRules: [ItalicRules.markdown({ variant: "*" }), ItalicRules.markdown({ variant: "_" })]
24040
+ }),
24041
+ UnderlinePlugin.configure({
24042
+ inputRules: [UnderlineRules.markdown()]
24043
+ }),
24017
24044
  CodePlugin.configure({
24045
+ inputRules: [CodeRules.markdown()],
24018
24046
  node: { component: CodeLeaf },
24019
24047
  shortcuts: { toggle: { keys: "mod+e" } }
24020
24048
  }),
24021
24049
  StrikethroughPlugin.configure({
24050
+ inputRules: [StrikethroughRules.markdown()],
24022
24051
  shortcuts: { toggle: { keys: "mod+shift+x" } }
24023
24052
  }),
24024
24053
  SubscriptPlugin.configure({
24054
+ inputRules: [SubscriptRules.markdown()],
24025
24055
  shortcuts: { toggle: { keys: "mod+comma" } }
24026
24056
  }),
24027
24057
  SuperscriptPlugin.configure({
24058
+ inputRules: [SuperscriptRules.markdown()],
24028
24059
  shortcuts: { toggle: { keys: "mod+period" } }
24029
24060
  }),
24030
24061
  HighlightPlugin.configure({
24062
+ inputRules: [HighlightRules.markdown({ variant: "==" }), HighlightRules.markdown({ variant: "\u2261" })],
24031
24063
  node: { component: HighlightLeaf },
24032
24064
  shortcuts: { toggle: { keys: "mod+shift+h" } }
24033
24065
  })
@@ -25561,196 +25593,139 @@ var insertAIAnchorElement = (editor) => {
25561
25593
  });
25562
25594
  editor.setOption(AIChatPlugin, "streaming", true);
25563
25595
  };
25564
- var autoformatMarks = [
25565
- {
25566
- match: "***",
25567
- mode: "mark",
25568
- type: [KEYS.bold, KEYS.italic]
25569
- },
25570
- {
25571
- match: "__*",
25572
- mode: "mark",
25573
- type: [KEYS.underline, KEYS.italic]
25574
- },
25575
- {
25576
- match: "__**",
25577
- mode: "mark",
25578
- type: [KEYS.underline, KEYS.bold]
25579
- },
25580
- {
25581
- match: "___***",
25582
- mode: "mark",
25583
- type: [KEYS.underline, KEYS.bold, KEYS.italic]
25584
- },
25585
- {
25586
- match: "**",
25587
- mode: "mark",
25588
- type: KEYS.bold
25589
- },
25590
- {
25591
- match: "__",
25592
- mode: "mark",
25593
- type: KEYS.underline
25594
- },
25595
- {
25596
- match: "*",
25597
- mode: "mark",
25598
- type: KEYS.italic
25599
- },
25600
- {
25601
- match: "_",
25602
- mode: "mark",
25603
- type: KEYS.italic
25604
- },
25605
- {
25606
- match: "~~",
25607
- mode: "mark",
25608
- type: KEYS.strikethrough
25609
- },
25610
- {
25611
- match: "^",
25612
- mode: "mark",
25613
- type: KEYS.sup
25614
- },
25615
- {
25616
- match: "~",
25617
- mode: "mark",
25618
- type: KEYS.sub
25619
- },
25620
- {
25621
- match: "`",
25622
- mode: "mark",
25623
- type: KEYS.code
25596
+ var isTextSubstitutionBlocked = (editor) => editor.api.some({
25597
+ match: {
25598
+ type: [editor.getType(KEYS.codeBlock)]
25624
25599
  }
25625
- ];
25626
- var autoformatBlocks = [
25627
- {
25628
- match: "# ",
25629
- mode: "block",
25630
- type: KEYS.h1
25631
- },
25632
- {
25633
- match: "## ",
25634
- mode: "block",
25635
- type: KEYS.h2
25636
- },
25637
- {
25638
- match: "### ",
25639
- mode: "block",
25640
- type: KEYS.h3
25641
- },
25642
- {
25643
- match: "> ",
25644
- mode: "block",
25645
- type: KEYS.blockquote
25646
- },
25647
- {
25648
- match: "```",
25649
- mode: "block",
25650
- type: KEYS.codeBlock,
25651
- format: (editor) => {
25652
- insertEmptyCodeBlock(editor, {
25653
- defaultType: KEYS.p,
25654
- insertNodesOptions: { select: true }
25655
- });
25656
- }
25657
- },
25658
- {
25659
- match: "+ ",
25660
- mode: "block",
25661
- preFormat: openNextToggles,
25662
- type: KEYS.toggle
25663
- },
25664
- {
25665
- match: ["---", "\u2014-", "___ "],
25666
- mode: "block",
25667
- type: KEYS.hr,
25668
- format: (editor) => {
25669
- editor.tf.setNodes({ type: KEYS.hr });
25670
- editor.tf.insertNodes({
25671
- children: [{ text: "" }],
25672
- type: KEYS.p
25673
- });
25674
- }
25675
- }
25676
- ];
25677
- var autoformatLists = [
25678
- {
25679
- match: ["* ", "- "],
25680
- mode: "block",
25681
- type: "list",
25682
- format: (editor) => {
25683
- toggleList(editor, {
25684
- listStyleType: KEYS.ul
25685
- });
25686
- }
25687
- },
25688
- {
25689
- match: [String.raw`^\d+\.$ `, String.raw`^\d+\)$ `],
25690
- matchByRegex: true,
25691
- mode: "block",
25692
- type: "list",
25693
- format: (editor, { matchString }) => {
25694
- toggleList(editor, {
25695
- listRestartPolite: Number(matchString) || 1,
25696
- listStyleType: KEYS.ol
25697
- });
25698
- }
25699
- },
25700
- {
25701
- match: ["[] "],
25702
- mode: "block",
25703
- type: "list",
25704
- format: (editor) => {
25705
- toggleList(editor, {
25706
- listStyleType: KEYS.listTodo
25707
- });
25708
- editor.tf.setNodes({
25709
- checked: false,
25710
- listStyleType: KEYS.listTodo
25711
- });
25712
- }
25713
- },
25714
- {
25715
- match: ["[x] "],
25716
- mode: "block",
25717
- type: "list",
25718
- format: (editor) => {
25719
- toggleList(editor, {
25720
- listStyleType: KEYS.listTodo
25721
- });
25722
- editor.tf.setNodes({
25723
- checked: true,
25724
- listStyleType: KEYS.listTodo
25725
- });
25726
- }
25727
- }
25728
- ];
25729
- var AutoformatKit = [
25730
- AutoformatPlugin.configure({
25731
- options: {
25732
- enableUndoOnDelete: true,
25733
- rules: [
25734
- ...autoformatBlocks,
25735
- ...autoformatMarks,
25736
- ...autoformatSmartQuotes,
25737
- ...autoformatPunctuation,
25738
- ...autoformatLegal,
25739
- ...autoformatLegalHtml,
25740
- ...autoformatArrow,
25741
- ...autoformatMath,
25742
- ...autoformatLists
25743
- ].map(
25744
- (rule) => ({
25745
- ...rule,
25746
- query: (editor) => !editor.api.some({
25747
- match: { type: editor.getType(KEYS.codeBlock) }
25748
- })
25749
- })
25750
- )
25751
- }
25752
- })
25753
- ];
25600
+ });
25601
+ var createAutoformatTextSubstitutionRule = ({
25602
+ patterns
25603
+ }) => createTextSubstitutionInputRule({
25604
+ enabled: ({ editor }) => !isTextSubstitutionBlocked(editor),
25605
+ patterns
25606
+ });
25607
+ var arrowsRule = createAutoformatTextSubstitutionRule({
25608
+ patterns: [
25609
+ { format: "\u2192", match: "->" },
25610
+ { format: "\u2190", match: "<-" },
25611
+ { format: "\u21D2", match: "=>" },
25612
+ { format: "\u21D0", match: ["<=", "\u2264="] }
25613
+ ]
25614
+ });
25615
+ var comparisonsRule = createAutoformatTextSubstitutionRule({
25616
+ patterns: [
25617
+ { format: "\u226F", match: "!>" },
25618
+ { format: "\u226E", match: "!<" },
25619
+ { format: "\u2265", match: ">=" },
25620
+ { format: "\u2264", match: "<=" },
25621
+ { format: "\u2271", match: "!>=" },
25622
+ { format: "\u2270", match: "!<=" }
25623
+ ]
25624
+ });
25625
+ var equalityRule = createAutoformatTextSubstitutionRule({
25626
+ patterns: [
25627
+ { format: "\u2260", match: "!=" },
25628
+ { format: "\u2261", match: "==" },
25629
+ { format: "\u2262", match: ["!==", "\u2260="] },
25630
+ { format: "\u2248", match: "~=" },
25631
+ { format: "\u2249", match: "!~=" }
25632
+ ]
25633
+ });
25634
+ var fractionsRule = createAutoformatTextSubstitutionRule({
25635
+ patterns: [
25636
+ { format: "\xBD", match: "1/2" },
25637
+ { format: "\u2153", match: "1/3" },
25638
+ { format: "\xBC", match: "1/4" },
25639
+ { format: "\u2155", match: "1/5" },
25640
+ { format: "\u2159", match: "1/6" },
25641
+ { format: "\u2150", match: "1/7" },
25642
+ { format: "\u215B", match: "1/8" },
25643
+ { format: "\u2151", match: "1/9" },
25644
+ { format: "\u2152", match: "1/10" },
25645
+ { format: "\u2154", match: "2/3" },
25646
+ { format: "\u2156", match: "2/5" },
25647
+ { format: "\xBE", match: "3/4" },
25648
+ { format: "\u2157", match: "3/5" },
25649
+ { format: "\u215C", match: "3/8" },
25650
+ { format: "\u2158", match: "4/5" },
25651
+ { format: "\u215A", match: "5/6" },
25652
+ { format: "\u215D", match: "5/8" },
25653
+ { format: "\u215E", match: "7/8" }
25654
+ ]
25655
+ });
25656
+ var legalRule = createAutoformatTextSubstitutionRule({
25657
+ patterns: [{ format: "\u2122", match: ["(tm)", "(TM)"] }, { format: "\xAE", match: ["(r)", "(R)"] }, { format: "\xA9", match: ["(c)", "(C)"] }]
25658
+ });
25659
+ var legalHtmlRule = createAutoformatTextSubstitutionRule({
25660
+ patterns: [
25661
+ { format: "\u2122", match: "&trade;" },
25662
+ { format: "\xAE", match: "&reg;" },
25663
+ { format: "\xA9", match: "&copy;" },
25664
+ { format: "\xA7", match: "&sect;" }
25665
+ ]
25666
+ });
25667
+ var operatorsRule = createAutoformatTextSubstitutionRule({
25668
+ patterns: [{ format: "\xB1", match: "+-" }, { format: "\u2030", match: "%%" }, { format: "\u2031", match: ["%%%", "\u2030%"] }]
25669
+ });
25670
+ var punctuationRule = createAutoformatTextSubstitutionRule({
25671
+ patterns: [{ format: "\xBB", match: ">>" }, { format: "\xAB", match: "<<" }]
25672
+ });
25673
+ var smartQuotesRule = createAutoformatTextSubstitutionRule({
25674
+ patterns: [{ format: ["\u201C", "\u201D"], match: '"' }, { format: ["\u2018", "\u2019"], match: "'" }]
25675
+ });
25676
+ var subscriptNumbersRule = createAutoformatTextSubstitutionRule({
25677
+ patterns: [
25678
+ { format: "\u2080", match: "~0" },
25679
+ { format: "\u2081", match: "~1" },
25680
+ { format: "\u2082", match: "~2" },
25681
+ { format: "\u2083", match: "~3" },
25682
+ { format: "\u2084", match: "~4" },
25683
+ { format: "\u2085", match: "~5" },
25684
+ { format: "\u2086", match: "~6" },
25685
+ { format: "\u2087", match: "~7" },
25686
+ { format: "\u2088", match: "~8" },
25687
+ { format: "\u2089", match: "~9" }
25688
+ ]
25689
+ });
25690
+ var subscriptSymbolsRule = createAutoformatTextSubstitutionRule({
25691
+ patterns: [{ format: "\u208A", match: "~+" }, { format: "\u208B", match: "~-" }]
25692
+ });
25693
+ var superscriptNumbersRule = createAutoformatTextSubstitutionRule({
25694
+ patterns: [
25695
+ { format: "\u2070", match: "^0" },
25696
+ { format: "\xB9", match: "^1" },
25697
+ { format: "\xB2", match: "^2" },
25698
+ { format: "\xB3", match: "^3" },
25699
+ { format: "\u2074", match: "^4" },
25700
+ { format: "\u2075", match: "^5" },
25701
+ { format: "\u2076", match: "^6" },
25702
+ { format: "\u2077", match: "^7" },
25703
+ { format: "\u2078", match: "^8" },
25704
+ { format: "\u2079", match: "^9" }
25705
+ ]
25706
+ });
25707
+ var superscriptSymbolsRule = createAutoformatTextSubstitutionRule({
25708
+ patterns: [{ format: "\xB0", match: "^o" }, { format: "\u207A", match: "^+" }, { format: "\u207B", match: "^-" }]
25709
+ });
25710
+ var AutoformatShortcutsPlugin = createSlatePlugin({
25711
+ key: "autoformatShortcuts",
25712
+ inputRules: [
25713
+ legalRule,
25714
+ legalHtmlRule,
25715
+ arrowsRule,
25716
+ comparisonsRule,
25717
+ equalityRule,
25718
+ fractionsRule,
25719
+ operatorsRule,
25720
+ punctuationRule,
25721
+ smartQuotesRule,
25722
+ subscriptNumbersRule,
25723
+ subscriptSymbolsRule,
25724
+ superscriptNumbersRule,
25725
+ superscriptSymbolsRule
25726
+ ]
25727
+ });
25728
+ var AutoformatKit = [AutoformatShortcutsPlugin];
25754
25729
  function BlockquoteElement(props) {
25755
25730
  return /* @__PURE__ */ jsx(PlateElement, { as: "blockquote", className: "my-1 px-0.5 py-[3px]", ...props, children: /* @__PURE__ */ jsx("div", { className: "border-primary border-l-[3px] px-4", children: props.children }) });
25756
25731
  }
@@ -25833,6 +25808,7 @@ function ParagraphElement(props) {
25833
25808
  var BasicBlocksKit = [
25834
25809
  ParagraphPlugin.withComponent(ParagraphElement),
25835
25810
  H1Plugin.configure({
25811
+ inputRules: [HeadingRules.markdown()],
25836
25812
  node: {
25837
25813
  component: H1Element
25838
25814
  },
@@ -25842,6 +25818,7 @@ var BasicBlocksKit = [
25842
25818
  shortcuts: { toggle: { keys: "mod+alt+1" } }
25843
25819
  }),
25844
25820
  H2Plugin.configure({
25821
+ inputRules: [HeadingRules.markdown()],
25845
25822
  node: {
25846
25823
  component: H2Element
25847
25824
  },
@@ -25851,6 +25828,7 @@ var BasicBlocksKit = [
25851
25828
  shortcuts: { toggle: { keys: "mod+alt+2" } }
25852
25829
  }),
25853
25830
  H3Plugin.configure({
25831
+ inputRules: [HeadingRules.markdown()],
25854
25832
  node: {
25855
25833
  component: H3Element
25856
25834
  },
@@ -25860,10 +25838,14 @@ var BasicBlocksKit = [
25860
25838
  shortcuts: { toggle: { keys: "mod+alt+3" } }
25861
25839
  }),
25862
25840
  BlockquotePlugin.configure({
25841
+ inputRules: [BlockquoteRules.markdown()],
25863
25842
  node: { component: BlockquoteElement },
25864
25843
  shortcuts: { toggle: { keys: "mod+shift+period" } }
25865
25844
  }),
25866
- HorizontalRulePlugin.withComponent(HrElement)
25845
+ HorizontalRulePlugin.configure({
25846
+ inputRules: [HorizontalRuleRules.markdown({ variant: "-" }), HorizontalRuleRules.markdown({ variant: "_" })],
25847
+ node: { component: HrElement }
25848
+ })
25867
25849
  ];
25868
25850
  var blockSelectionVariants = cva(
25869
25851
  cn(
@@ -28166,6 +28148,7 @@ var languages = [
28166
28148
  var lowlight = createLowlight(all);
28167
28149
  var CodeBlockKit = [
28168
28150
  CodeBlockPlugin.configure({
28151
+ inputRules: [CodeBlockRules.markdown({ on: "match" })],
28169
28152
  node: { component: CodeBlockElement2 },
28170
28153
  options: { lowlight },
28171
28154
  shortcuts: { toggle: { keys: "mod+alt+8" } }
@@ -29622,7 +29605,30 @@ function TodoLi(props) {
29622
29605
  var ListKit = [
29623
29606
  ...IndentKit,
29624
29607
  ListPlugin.configure({
29608
+ inputRules: [
29609
+ BulletedListRules.markdown({ variant: "-" }),
29610
+ BulletedListRules.markdown({ variant: "*" }),
29611
+ OrderedListRules.markdown({ variant: "." }),
29612
+ OrderedListRules.markdown({ variant: ")" }),
29613
+ TaskListRules.markdown({ checked: false }),
29614
+ TaskListRules.markdown({ checked: true })
29615
+ ],
29625
29616
  inject: {
29617
+ nodeProps: {
29618
+ nodeKey: KEYS.listType,
29619
+ query: ({ nodeProps }) => {
29620
+ const { element } = nodeProps;
29621
+ return !!element?.listStyleType && !isOrderedList(element);
29622
+ },
29623
+ transformProps: ({ props }) => ({
29624
+ ...props,
29625
+ role: "listitem",
29626
+ style: {
29627
+ ...props.style,
29628
+ display: "list-item"
29629
+ }
29630
+ })
29631
+ },
29626
29632
  targetPlugins: [
29627
29633
  ...KEYS.heading,
29628
29634
  KEYS.p,
@@ -30512,7 +30518,7 @@ var PlaceholderElement = withHOC(
30512
30518
  /* @__PURE__ */ jsxs("div", { className: "whitespace-nowrap text-muted-foreground text-sm", children: [
30513
30519
  /* @__PURE__ */ jsx("div", { children: progressing ? file?.name : currentContent.content }),
30514
30520
  progressing && !isImage && /* @__PURE__ */ jsxs("div", { className: "mt-1 flex items-center gap-1.5", children: [
30515
- /* @__PURE__ */ jsx("div", { children: formatBytes(file.size) }),
30521
+ /* @__PURE__ */ jsx("div", { children: formatBytes(file?.size ?? 0) }),
30516
30522
  /* @__PURE__ */ jsx("div", { children: "-" }),
30517
30523
  /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
30518
30524
  /* @__PURE__ */ jsx(Spinner$1, { className: "mr-1 size-3.5" }),
@@ -31476,11 +31482,9 @@ var TableElement2 = withHOC(
31476
31482
  const { editor, element } = props;
31477
31483
  const { tf } = useEditorPlugin(TablePlugin);
31478
31484
  const readOnly = useReadOnly();
31479
- const {
31480
- isSelectingCell,
31481
- marginLeft,
31482
- props: tableProps
31483
- } = useTableElement();
31485
+ const { marginLeft, props: tableProps } = useTableElement();
31486
+ const tableRef = useRef(null);
31487
+ useTableSelectionDom(tableRef);
31484
31488
  const isSelectingTable = useBlockSelected(props.element.id);
31485
31489
  return /* @__PURE__ */ jsx(
31486
31490
  PlateElement,
@@ -31492,9 +31496,14 @@ var TableElement2 = withHOC(
31492
31496
  /* @__PURE__ */ jsx(
31493
31497
  "table",
31494
31498
  {
31499
+ ref: tableRef,
31495
31500
  className: cn(
31496
31501
  "mr-0 ml-px table h-px table-fixed border-collapse",
31497
- isSelectingCell && "selection:bg-transparent"
31502
+ "data-[table-selecting=true]:[&_*::selection]:!bg-transparent",
31503
+ "data-[table-selecting=true]:[&_*::selection]:!text-inherit",
31504
+ "data-[table-selecting=true]:[&_*::-moz-selection]:!bg-transparent",
31505
+ "data-[table-selecting=true]:[&_*::-moz-selection]:!text-inherit",
31506
+ "data-[table-selecting=true]:[&_*]:!caret-transparent"
31498
31507
  ),
31499
31508
  ...tableProps,
31500
31509
  children: /* @__PURE__ */ jsx("tbody", { className: "min-w-full", children: props.children })
@@ -32889,10 +32898,12 @@ var getHeadingList = (editor) => {
32889
32898
  return options3.queryHeading(editor);
32890
32899
  }
32891
32900
  const headingList = [];
32892
- const values = editor.api.nodes({
32893
- at: [],
32894
- match: (n) => isHeading(n)
32895
- });
32901
+ const values = Array.from(
32902
+ editor.api.nodes({
32903
+ at: [],
32904
+ match: (n) => isHeading(n)
32905
+ })
32906
+ );
32896
32907
  if (!values) return [];
32897
32908
  for (const [node, path] of values) {
32898
32909
  const { type } = node;
@@ -36652,6 +36663,7 @@ var DocyAssistant = ({
36652
36663
  }
36653
36664
  const consentDeclined = !!consentRequiredFor && declinedConsentAgentId === consentRequiredFor.agentId;
36654
36665
  const consentDialogPending = uiState.activeTab === 0 && !consentDeclined ? consentRequiredFor : null;
36666
+ const [consentScope, setConsentScope] = useState(null);
36655
36667
  useEffect(() => {
36656
36668
  if (!agentDetailsForId || !agentDetails) return;
36657
36669
  setTabs((prev) => {
@@ -37642,32 +37654,36 @@ var DocyAssistant = ({
37642
37654
  dataSourceId: BASE_DATA_SOURCE_ID.thread,
37643
37655
  recordId: sessionState.selectedSessionId
37644
37656
  }
37645
- ),
37646
- /* @__PURE__ */ jsx(
37647
- AgentConsentDialog,
37648
- {
37649
- pending: consentDialogPending,
37650
- onApproved: () => {
37651
- setConsentRequiredFor(null);
37652
- setDeclinedConsentAgentId(null);
37653
- },
37654
- onDeclined: () => {
37655
- setDeclinedConsentAgentId(consentRequiredFor?.agentId ?? null);
37656
- },
37657
- t
37658
- }
37659
37657
  )
37660
37658
  ] });
37659
+ const renderConsentDialog = (container) => /* @__PURE__ */ jsx(
37660
+ AgentConsentDialog,
37661
+ {
37662
+ pending: consentDialogPending,
37663
+ container,
37664
+ onApproved: () => {
37665
+ setConsentRequiredFor(null);
37666
+ setDeclinedConsentAgentId(null);
37667
+ },
37668
+ onDeclined: () => {
37669
+ setDeclinedConsentAgentId(consentRequiredFor?.agentId ?? null);
37670
+ },
37671
+ t
37672
+ }
37673
+ );
37661
37674
  if (isInlineMode) {
37662
37675
  return /* @__PURE__ */ jsxs(ClientToolsProvider, { tools: clientToolMap, children: [
37663
- renderInlineViewContent({
37664
- isFullscreen: isInlineFullscreen,
37665
- enableSidebar: isInlineFullscreen ? true : enableSidebar,
37666
- className,
37667
- onExpand: hideExpand ? void 0 : handleExpand,
37668
- isOpen,
37669
- viewRef: ref
37670
- }),
37676
+ /* @__PURE__ */ jsxs("div", { ref: setConsentScope, className: "relative flex h-full min-h-0 w-full flex-col", children: [
37677
+ renderInlineViewContent({
37678
+ isFullscreen: isInlineFullscreen,
37679
+ enableSidebar: isInlineFullscreen ? true : enableSidebar,
37680
+ className,
37681
+ onExpand: hideExpand ? void 0 : handleExpand,
37682
+ isOpen,
37683
+ viewRef: ref
37684
+ }),
37685
+ renderConsentDialog(consentScope)
37686
+ ] }),
37671
37687
  assistantDialogs
37672
37688
  ] });
37673
37689
  }
@@ -37716,13 +37732,16 @@ var DocyAssistant = ({
37716
37732
  },
37717
37733
  ...props,
37718
37734
  ref,
37719
- children: renderInlineViewContent({
37720
- isFullscreen: false,
37721
- enableSidebar,
37722
- className: cn("h-full w-full border-0 shadow-none", uiState.isExpanded || uiState.isDocked ? "rounded-none" : "rounded-xl"),
37723
- onExpand: handleExpand,
37724
- isOpen: true
37725
- })
37735
+ children: /* @__PURE__ */ jsxs("div", { ref: setConsentScope, className: "relative flex h-full min-h-0 w-full flex-col", children: [
37736
+ renderInlineViewContent({
37737
+ isFullscreen: false,
37738
+ enableSidebar,
37739
+ className: cn("h-full w-full border-0 shadow-none", uiState.isExpanded || uiState.isDocked ? "rounded-none" : "rounded-xl"),
37740
+ onExpand: handleExpand,
37741
+ isOpen: true
37742
+ }),
37743
+ renderConsentDialog(consentScope)
37744
+ ] })
37726
37745
  }
37727
37746
  )
37728
37747
  ] }),