@particle-academy/react-fancy 4.13.1 → 4.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index.cjs +134 -36
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +65 -5
- package/dist/index.d.ts +65 -5
- package/dist/index.js +134 -36
- package/dist/index.js.map +1 -1
- package/docs/Editor.md +55 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -2110,11 +2110,29 @@ interface EditorToolbarProps {
|
|
|
2110
2110
|
onAction?: (command: string) => void;
|
|
2111
2111
|
children?: ReactNode;
|
|
2112
2112
|
className?: string;
|
|
2113
|
+
/**
|
|
2114
|
+
* Append a "Source" toggle (reveals the raw HTML/Markdown behind the editor)
|
|
2115
|
+
* to the right of the default toolbar. Ignored when `children` are supplied —
|
|
2116
|
+
* custom toolbars compose their own `<Editor.SourceToggle />`.
|
|
2117
|
+
* @default true
|
|
2118
|
+
*/
|
|
2119
|
+
showSourceToggle?: boolean;
|
|
2113
2120
|
}
|
|
2114
2121
|
interface EditorContentProps {
|
|
2115
2122
|
className?: string;
|
|
2116
2123
|
/** Max height in px before scrolling. When set, content area becomes scrollable. */
|
|
2117
2124
|
maxHeight?: number;
|
|
2125
|
+
/** Class names applied to the raw-source `<textarea>` shown while source mode is on. */
|
|
2126
|
+
sourceClassName?: string;
|
|
2127
|
+
}
|
|
2128
|
+
interface EditorSourceToggleProps {
|
|
2129
|
+
className?: string;
|
|
2130
|
+
/** Toggle glyph/label. @default `</>` */
|
|
2131
|
+
icon?: ReactNode;
|
|
2132
|
+
/** Accessible title when in rich-text mode (click → source). @default "Source" */
|
|
2133
|
+
title?: string;
|
|
2134
|
+
/** Accessible title when in source mode (click → rich text). @default "Rich text" */
|
|
2135
|
+
activeTitle?: string;
|
|
2118
2136
|
}
|
|
2119
2137
|
interface EditorProps {
|
|
2120
2138
|
children: ReactNode;
|
|
@@ -2146,6 +2164,17 @@ interface EditorProps {
|
|
|
2146
2164
|
mode?: FieldMode;
|
|
2147
2165
|
/** Per-instance render extensions. Merged with any globally-registered extensions. */
|
|
2148
2166
|
extensions?: RenderExtension[];
|
|
2167
|
+
/**
|
|
2168
|
+
* Controlled source-view flag. When `true` the content area shows the raw
|
|
2169
|
+
* HTML/Markdown (`value`, in `outputFormat`) in an editable `<textarea>`
|
|
2170
|
+
* instead of the rich-text surface. Pair with `onShowSourceChange`, or leave
|
|
2171
|
+
* uncontrolled and drive it with the toolbar's Source toggle.
|
|
2172
|
+
*/
|
|
2173
|
+
showSource?: boolean;
|
|
2174
|
+
/** Initial source-view flag when uncontrolled. @default false */
|
|
2175
|
+
defaultShowSource?: boolean;
|
|
2176
|
+
/** Fired when the Source toggle (or an agent) flips source view on/off. */
|
|
2177
|
+
onShowSourceChange?: (showSource: boolean) => void;
|
|
2149
2178
|
/**
|
|
2150
2179
|
* Skip HTML sanitization of the initial value. By default the initial markdown/HTML
|
|
2151
2180
|
* is sanitized to remove `<script>`, `<iframe>`, event handlers, and `javascript:`
|
|
@@ -2156,7 +2185,7 @@ interface EditorProps {
|
|
|
2156
2185
|
unsafe?: boolean;
|
|
2157
2186
|
}
|
|
2158
2187
|
|
|
2159
|
-
declare function EditorToolbar({ actions, onAction, children, className, }: EditorToolbarProps): react.JSX.Element;
|
|
2188
|
+
declare function EditorToolbar({ actions, onAction, children, className, showSourceToggle, }: EditorToolbarProps): react.JSX.Element;
|
|
2160
2189
|
declare namespace EditorToolbar {
|
|
2161
2190
|
var displayName: string;
|
|
2162
2191
|
}
|
|
@@ -2166,17 +2195,28 @@ declare namespace EditorToolbarSeparator {
|
|
|
2166
2195
|
var displayName: string;
|
|
2167
2196
|
}
|
|
2168
2197
|
|
|
2169
|
-
|
|
2198
|
+
/**
|
|
2199
|
+
* Toolbar button that reveals the raw HTML/Markdown behind the editor. Reads
|
|
2200
|
+
* `showSource` / `setShowSource` from context, so it works in the default
|
|
2201
|
+
* toolbar and in any custom toolbar composed with `useEditor()`.
|
|
2202
|
+
*/
|
|
2203
|
+
declare function EditorSourceToggle({ className, icon, title, activeTitle, }: EditorSourceToggleProps): react.JSX.Element;
|
|
2204
|
+
declare namespace EditorSourceToggle {
|
|
2205
|
+
var displayName: string;
|
|
2206
|
+
}
|
|
2207
|
+
|
|
2208
|
+
declare function EditorContent({ className, maxHeight, sourceClassName }: EditorContentProps): react.JSX.Element;
|
|
2170
2209
|
declare namespace EditorContent {
|
|
2171
2210
|
var displayName: string;
|
|
2172
2211
|
}
|
|
2173
2212
|
|
|
2174
|
-
declare function EditorRoot({ children, className, value: controlledValue, defaultValue, onChange, outputFormat, valueFormat, lineSpacing, placeholder, mode: modeProp, extensions: instanceExtensions, unsafe, }: EditorProps): react.JSX.Element;
|
|
2213
|
+
declare function EditorRoot({ children, className, value: controlledValue, defaultValue, onChange, outputFormat, valueFormat, lineSpacing, placeholder, mode: modeProp, extensions: instanceExtensions, unsafe, showSource: showSourceProp, defaultShowSource, onShowSourceChange, }: EditorProps): react.JSX.Element;
|
|
2175
2214
|
declare const Editor: typeof EditorRoot & {
|
|
2176
2215
|
Toolbar: typeof EditorToolbar & {
|
|
2177
2216
|
Separator: typeof EditorToolbarSeparator;
|
|
2178
2217
|
};
|
|
2179
2218
|
Content: typeof EditorContent;
|
|
2219
|
+
SourceToggle: typeof EditorSourceToggle;
|
|
2180
2220
|
};
|
|
2181
2221
|
|
|
2182
2222
|
interface EditorContextValue {
|
|
@@ -2189,10 +2229,18 @@ interface EditorContextValue {
|
|
|
2189
2229
|
placeholder?: string;
|
|
2190
2230
|
/** Merged render extensions (global + instance). */
|
|
2191
2231
|
extensions: RenderExtension[];
|
|
2232
|
+
/** Whether the raw-source view (textarea) is showing instead of the rich-text surface. */
|
|
2233
|
+
showSource: boolean;
|
|
2234
|
+
/** Toggle/set the raw-source view. */
|
|
2235
|
+
setShowSource: (showSource: boolean) => void;
|
|
2192
2236
|
/** Initial HTML content to load into the editor on mount */
|
|
2193
2237
|
_initialHtml: string;
|
|
2194
2238
|
/** @internal Called by EditorContent on input events */
|
|
2195
2239
|
_onInput: () => void;
|
|
2240
|
+
/** @internal Raw source value (`value` in `outputFormat`), for the source textarea. */
|
|
2241
|
+
_sourceValue: string;
|
|
2242
|
+
/** @internal Commit an edit made directly in the source textarea. */
|
|
2243
|
+
_onSourceInput: (value: string) => void;
|
|
2196
2244
|
}
|
|
2197
2245
|
declare function useEditor(): EditorContextValue;
|
|
2198
2246
|
|
|
@@ -2590,6 +2638,17 @@ interface TreeNavProps {
|
|
|
2590
2638
|
indentSize?: number;
|
|
2591
2639
|
/** Show file/folder icons (default: true) */
|
|
2592
2640
|
showIcons?: boolean;
|
|
2641
|
+
/**
|
|
2642
|
+
* Cursor shown on hover over a draggable node.
|
|
2643
|
+
* - `"none"` (default): the normal clickable cursor — no move affordance on
|
|
2644
|
+
* mere hover. A closed-hand `grabbing` cursor still appears while a drag is
|
|
2645
|
+
* actually happening. This suits click-to-select/open trees (file/nav
|
|
2646
|
+
* trees), where an always-on grab cursor wrongly implies move-first intent.
|
|
2647
|
+
* - `"grab"`: show the open-hand `grab` cursor on hover. Opt in when the whole
|
|
2648
|
+
* row is genuinely a drag handle and reordering is the primary interaction.
|
|
2649
|
+
* @default "none"
|
|
2650
|
+
*/
|
|
2651
|
+
dragCursor?: "grab" | "none";
|
|
2593
2652
|
/** Custom className */
|
|
2594
2653
|
className?: string;
|
|
2595
2654
|
}
|
|
@@ -2602,6 +2661,7 @@ interface TreeNavContextValue {
|
|
|
2602
2661
|
indentSize: number;
|
|
2603
2662
|
showIcons: boolean;
|
|
2604
2663
|
draggable: boolean;
|
|
2664
|
+
dragCursor: "grab" | "none";
|
|
2605
2665
|
dragState: DragState;
|
|
2606
2666
|
setDragState: (state: DragState) => void;
|
|
2607
2667
|
onNodeMove?: (sourceId: string, targetId: string, position: DropPosition) => void;
|
|
@@ -2621,7 +2681,7 @@ declare namespace TreeNode {
|
|
|
2621
2681
|
var displayName: string;
|
|
2622
2682
|
}
|
|
2623
2683
|
|
|
2624
|
-
declare function TreeNavRoot({ nodes, selectedId, onSelect, onNodeContextMenu, draggable, onNodeMove, acceptExternalDrops, onExternalDrop, expandedIds: controlledExpanded, defaultExpandedIds, onExpandedChange, defaultExpandAll, indentSize, showIcons, className, }: TreeNavProps): react.JSX.Element;
|
|
2684
|
+
declare function TreeNavRoot({ nodes, selectedId, onSelect, onNodeContextMenu, draggable, onNodeMove, acceptExternalDrops, onExternalDrop, expandedIds: controlledExpanded, defaultExpandedIds, onExpandedChange, defaultExpandAll, indentSize, showIcons, dragCursor, className, }: TreeNavProps): react.JSX.Element;
|
|
2625
2685
|
declare namespace TreeNavRoot {
|
|
2626
2686
|
var displayName: string;
|
|
2627
2687
|
}
|
|
@@ -3649,4 +3709,4 @@ declare const AudioViewer: react.ForwardRefExoticComponent<AudioViewerProps & re
|
|
|
3649
3709
|
*/
|
|
3650
3710
|
declare const PdfViewer: react.ForwardRefExoticComponent<PdfViewerProps & react.RefAttributes<HTMLDivElement>>;
|
|
3651
3711
|
|
|
3652
|
-
export { Accordion, type AccordionContentProps, type AccordionContextValue, type AccordionItemProps, type AccordionOrientation, AccordionPanel, AccordionPanelContent, type AccordionPanelContentProps, type AccordionPanelProps, AccordionPanelSection, type AccordionPanelSectionProps, AccordionPanelTrigger, type AccordionPanelTriggerProps, type AccordionProps, type AccordionTriggerProps, Action, type ActionColor, type ActionProps, type AffixPosition, AudioViewer, type AudioViewerProps, Autocomplete, type AutocompleteOption, type AutocompleteProps, Avatar, type AvatarProps, Badge, type BadgeProps, Brand, type BrandProps, Breadcrumbs, type BreadcrumbsItemProps, type BreadcrumbsProps, Button, type ButtonColor, type ButtonProps, Calendar, type CalendarMode, type CalendarProps, Callout, type CalloutProps, Card, type CardBodyProps, type CardFooterProps, type CardHeaderProps, type CardProps, Carousel, type CarouselContextValue, type CarouselControlsProps, type CarouselPanelsProps, type CarouselProps, type CarouselSlideProps, type CarouselStepsProps, type CarouselVariant, Chart, type ChartAreaProps, type ChartBarData, type ChartBarProps, type ChartCommonProps, type ChartDonutData, type ChartDonutProps, type ChartHorizontalBarProps, type ChartLineProps, type ChartPieData, type ChartPieProps, type ChartSeries, type ChartSparklineProps, type ChartStackedBarProps, ChatDrawer, type ChatDrawerProps, type ChatDrawerTab, Checkbox, CheckboxGroup, type CheckboxGroupProps, type CheckboxProps, type Color, ColorPicker, type ColorPickerProps, Command, type CommandContextValue, type CommandEmptyProps, type CommandGroupProps, type CommandInputProps, type CommandItemProps, type CommandListProps, type CommandProps, Composer, type ComposerProps, ContentRenderer, type ContentRendererProps, ContextMenu, type ContextMenuContentProps, type ContextMenuContextValue, type ContextMenuItemProps, type ContextMenuProps, type ContextMenuSeparatorProps, type ContextMenuTriggerProps, type ControlledAdapterHandle, DatePicker, type DatePickerProps, type DateRange, DisplayValue, type DisplayValueProps, type DropPosition, Dropdown, type DropdownContextValue, type DropdownItemProps, type DropdownItemsProps, type DropdownProps, type DropdownSeparatorProps, type DropdownTriggerProps, EMOJI_CATEGORY_ORDER, EMOJI_DATA, EMOJI_ENTRIES, Editor, type EditorAction, type EditorContentProps, type EditorContextValue, type EditorProps, type EditorToolbarProps, Emoji, type EmojiCategory, type EmojiCategoryKey, type EmojiEntry, type EmojiFlatEntry, type EmojiProps, EmojiSelect, type EmojiSelectProps, FauxClient, type FauxClientProps, Field, type FieldMode, FieldModeContext, type FieldModeContextValue, type FieldProps, FileBrowser, type FileBrowserContextValue, type FileBrowserNodeProps, type FileBrowserPathBarProps, type FileBrowserProps, type FileBrowserProvider, type FileBrowserRow, type FileBrowserToolbarProps, type FileBrowserTreeProps, type FileEntry, type FileKind, type FileLoadStatus, type FileSelectMode, type FileSnapshotNode, type FileSort, type FileSortDirection, type FileSortField, FileUpload, type FileUploadContextValue, type FileUploadDropzoneProps, type FileUploadListProps, type FileUploadProps, Form, type FormProps, FormProvider, type FormProviderProps, Heading, type HeadingProps, Icon, type IconProps, type IconSet, ImageViewer, type ImageViewerProps, type ImageViewerViewport, Input, type InputAffixProps, type InputBaseProps, type InputOption, type InputOptionGroup, type InputProps, InputTag, type InputTagAdapter, type InputTagAdapterState, type InputTagProps, type InputTagTrigger, type InputTagTriggers, Kanban, type KanbanCardMoveHandler, type KanbanCardProps, type KanbanColumnHandleProps, type KanbanColumnMoveHandler, type KanbanColumnProps, type KanbanContextValue, type KanbanProps, MagicWand, type MagicWandAction, type MagicWandAppearance, type MagicWandProps, type MagicWandSelection, Marquee, type MarqueeDirection, type MarqueeProps, type MediaKind, MediaViewer, type MediaViewerProps, Menu, type MenuContextValue, type MenuGroupProps, type MenuItemProps, type MenuOrientation, type MenuProps, type MenuSubmenuProps, MobileMenu, type MobileMenuBottomBarProps, type MobileMenuContextValue, type MobileMenuFlyoutProps, type MobileMenuItemProps, type MobileMenuSide, type MobileMenuVariant, Modal, type ModalBodyProps, type ModalContextValue, type ModalFooterProps, type ModalHeaderProps, type ModalProps, MoodMeter, type MoodMeterProps, MultiSwitch, type MultiSwitchProps, Navbar, type NavbarBrandProps, type NavbarContextValue, type NavbarItemProps, type NavbarItemsProps, type NavbarProps, type NavbarToggleProps, type NodeRect, OtpInput, type OtpInputProps, Pagination, type PaginationProps, PdfViewer, type PdfViewerProps, Pillbox, type PillboxProps, type Placement, Popover, type PopoverContentProps, type PopoverContextValue, type PopoverProps, type PopoverTriggerProps, Portal, type PortalProps, Profile, type ProfileProps, Progress, type ProgressProps, type PromptAttachment, type PromptCmd, PromptInput, type PromptInputProps, type PromptMention, RadioGroup, type RadioGroupProps, ReasonTag, type ReasonTagProps, type ReasonTagSource, type ReasonTagTheme, type RenderExtension, type RenderExtensionProps, type ResolveMediaTypeInput, SKIN_TONES, type SectionRenderState, type SectionRenderable, Select, type SelectProps, Separator, type SeparatorProps, Sidebar, type SidebarCollapseMode, type SidebarContextValue, type SidebarGroupProps, type SidebarItemProps, type SidebarProps, type SidebarSubmenuProps, type SidebarToggleProps, type Size, Skeleton, type SkeletonProps, type SkinTone, Slider, type SliderProps, StickyNote, type StickyNoteColor, type StickyNoteProps, Switch, type SwitchProps, Table, type TableBodyProps, type TableCellProps, type TableColumnProps, type TableHeadProps, type TablePaginationProps, type TableProps, type TableRowProps, type TableRowTrayProps, type TableSearchProps, type TableTrayProps, Tabs, type TabsContextValue, type TabsListProps, type TabsPanelProps, type TabsPanelsProps, type TabsProps, type TabsTabProps, type TabsVariant, Text, type TextProps, Textarea, type TextareaProps, TimeGrid, type TimeGridProps, type TimeGridTone, TimePicker, type TimePickerProps, Timeline, type TimelineBlockProps, type TimelineEvent, type TimelineItemProps, type TimelineOrientation, type TimelineProps, type TimelineVariant, Toast, type ToastContextValue, type ToastData, type ToastPosition, type ToastProviderProps, type ToastVariant, Tooltip, type TooltipProps, TreeNav, type TreeNavContextValue, type TreeNavProps, type TreeNodeData, type TreeNodeProps, type Variant, VideoViewer, type VideoViewerProps, applyTone, cn, configureIcons, contentEditableAdapter, controlledAdapter, find, hasSkinTones, inputAdapter, registerExtension, registerExtensions, registerIconAddendum, registerIconSet, registerIcons, resolve, resolveMediaType, sanitizeHref, sanitizeHtml, search, skinTones, textareaAdapter, useAccordion, useAccordionPanel, useAccordionSection, useAnimation, useCarousel, useCommand, useContextMenu, useControllableState, useDropdown, useEditor, useEscapeKey, useFieldMode, useFileBrowser, useFileUpload, useFloatingPosition, useFocusTrap, useId, useKanban, useMenu, useMobileMenu, useModal, useNavbar, useNodeRegistry, useOutsideClick, usePanZoom, usePopover, useSidebar, useTabs, useToast, useTreeNav };
|
|
3712
|
+
export { Accordion, type AccordionContentProps, type AccordionContextValue, type AccordionItemProps, type AccordionOrientation, AccordionPanel, AccordionPanelContent, type AccordionPanelContentProps, type AccordionPanelProps, AccordionPanelSection, type AccordionPanelSectionProps, AccordionPanelTrigger, type AccordionPanelTriggerProps, type AccordionProps, type AccordionTriggerProps, Action, type ActionColor, type ActionProps, type AffixPosition, AudioViewer, type AudioViewerProps, Autocomplete, type AutocompleteOption, type AutocompleteProps, Avatar, type AvatarProps, Badge, type BadgeProps, Brand, type BrandProps, Breadcrumbs, type BreadcrumbsItemProps, type BreadcrumbsProps, Button, type ButtonColor, type ButtonProps, Calendar, type CalendarMode, type CalendarProps, Callout, type CalloutProps, Card, type CardBodyProps, type CardFooterProps, type CardHeaderProps, type CardProps, Carousel, type CarouselContextValue, type CarouselControlsProps, type CarouselPanelsProps, type CarouselProps, type CarouselSlideProps, type CarouselStepsProps, type CarouselVariant, Chart, type ChartAreaProps, type ChartBarData, type ChartBarProps, type ChartCommonProps, type ChartDonutData, type ChartDonutProps, type ChartHorizontalBarProps, type ChartLineProps, type ChartPieData, type ChartPieProps, type ChartSeries, type ChartSparklineProps, type ChartStackedBarProps, ChatDrawer, type ChatDrawerProps, type ChatDrawerTab, Checkbox, CheckboxGroup, type CheckboxGroupProps, type CheckboxProps, type Color, ColorPicker, type ColorPickerProps, Command, type CommandContextValue, type CommandEmptyProps, type CommandGroupProps, type CommandInputProps, type CommandItemProps, type CommandListProps, type CommandProps, Composer, type ComposerProps, ContentRenderer, type ContentRendererProps, ContextMenu, type ContextMenuContentProps, type ContextMenuContextValue, type ContextMenuItemProps, type ContextMenuProps, type ContextMenuSeparatorProps, type ContextMenuTriggerProps, type ControlledAdapterHandle, DatePicker, type DatePickerProps, type DateRange, DisplayValue, type DisplayValueProps, type DropPosition, Dropdown, type DropdownContextValue, type DropdownItemProps, type DropdownItemsProps, type DropdownProps, type DropdownSeparatorProps, type DropdownTriggerProps, EMOJI_CATEGORY_ORDER, EMOJI_DATA, EMOJI_ENTRIES, Editor, type EditorAction, type EditorContentProps, type EditorContextValue, type EditorProps, type EditorSourceToggleProps, type EditorToolbarProps, Emoji, type EmojiCategory, type EmojiCategoryKey, type EmojiEntry, type EmojiFlatEntry, type EmojiProps, EmojiSelect, type EmojiSelectProps, FauxClient, type FauxClientProps, Field, type FieldMode, FieldModeContext, type FieldModeContextValue, type FieldProps, FileBrowser, type FileBrowserContextValue, type FileBrowserNodeProps, type FileBrowserPathBarProps, type FileBrowserProps, type FileBrowserProvider, type FileBrowserRow, type FileBrowserToolbarProps, type FileBrowserTreeProps, type FileEntry, type FileKind, type FileLoadStatus, type FileSelectMode, type FileSnapshotNode, type FileSort, type FileSortDirection, type FileSortField, FileUpload, type FileUploadContextValue, type FileUploadDropzoneProps, type FileUploadListProps, type FileUploadProps, Form, type FormProps, FormProvider, type FormProviderProps, Heading, type HeadingProps, Icon, type IconProps, type IconSet, ImageViewer, type ImageViewerProps, type ImageViewerViewport, Input, type InputAffixProps, type InputBaseProps, type InputOption, type InputOptionGroup, type InputProps, InputTag, type InputTagAdapter, type InputTagAdapterState, type InputTagProps, type InputTagTrigger, type InputTagTriggers, Kanban, type KanbanCardMoveHandler, type KanbanCardProps, type KanbanColumnHandleProps, type KanbanColumnMoveHandler, type KanbanColumnProps, type KanbanContextValue, type KanbanProps, MagicWand, type MagicWandAction, type MagicWandAppearance, type MagicWandProps, type MagicWandSelection, Marquee, type MarqueeDirection, type MarqueeProps, type MediaKind, MediaViewer, type MediaViewerProps, Menu, type MenuContextValue, type MenuGroupProps, type MenuItemProps, type MenuOrientation, type MenuProps, type MenuSubmenuProps, MobileMenu, type MobileMenuBottomBarProps, type MobileMenuContextValue, type MobileMenuFlyoutProps, type MobileMenuItemProps, type MobileMenuSide, type MobileMenuVariant, Modal, type ModalBodyProps, type ModalContextValue, type ModalFooterProps, type ModalHeaderProps, type ModalProps, MoodMeter, type MoodMeterProps, MultiSwitch, type MultiSwitchProps, Navbar, type NavbarBrandProps, type NavbarContextValue, type NavbarItemProps, type NavbarItemsProps, type NavbarProps, type NavbarToggleProps, type NodeRect, OtpInput, type OtpInputProps, Pagination, type PaginationProps, PdfViewer, type PdfViewerProps, Pillbox, type PillboxProps, type Placement, Popover, type PopoverContentProps, type PopoverContextValue, type PopoverProps, type PopoverTriggerProps, Portal, type PortalProps, Profile, type ProfileProps, Progress, type ProgressProps, type PromptAttachment, type PromptCmd, PromptInput, type PromptInputProps, type PromptMention, RadioGroup, type RadioGroupProps, ReasonTag, type ReasonTagProps, type ReasonTagSource, type ReasonTagTheme, type RenderExtension, type RenderExtensionProps, type ResolveMediaTypeInput, SKIN_TONES, type SectionRenderState, type SectionRenderable, Select, type SelectProps, Separator, type SeparatorProps, Sidebar, type SidebarCollapseMode, type SidebarContextValue, type SidebarGroupProps, type SidebarItemProps, type SidebarProps, type SidebarSubmenuProps, type SidebarToggleProps, type Size, Skeleton, type SkeletonProps, type SkinTone, Slider, type SliderProps, StickyNote, type StickyNoteColor, type StickyNoteProps, Switch, type SwitchProps, Table, type TableBodyProps, type TableCellProps, type TableColumnProps, type TableHeadProps, type TablePaginationProps, type TableProps, type TableRowProps, type TableRowTrayProps, type TableSearchProps, type TableTrayProps, Tabs, type TabsContextValue, type TabsListProps, type TabsPanelProps, type TabsPanelsProps, type TabsProps, type TabsTabProps, type TabsVariant, Text, type TextProps, Textarea, type TextareaProps, TimeGrid, type TimeGridProps, type TimeGridTone, TimePicker, type TimePickerProps, Timeline, type TimelineBlockProps, type TimelineEvent, type TimelineItemProps, type TimelineOrientation, type TimelineProps, type TimelineVariant, Toast, type ToastContextValue, type ToastData, type ToastPosition, type ToastProviderProps, type ToastVariant, Tooltip, type TooltipProps, TreeNav, type TreeNavContextValue, type TreeNavProps, type TreeNodeData, type TreeNodeProps, type Variant, VideoViewer, type VideoViewerProps, applyTone, cn, configureIcons, contentEditableAdapter, controlledAdapter, find, hasSkinTones, inputAdapter, registerExtension, registerExtensions, registerIconAddendum, registerIconSet, registerIcons, resolve, resolveMediaType, sanitizeHref, sanitizeHtml, search, skinTones, textareaAdapter, useAccordion, useAccordionPanel, useAccordionSection, useAnimation, useCarousel, useCommand, useContextMenu, useControllableState, useDropdown, useEditor, useEscapeKey, useFieldMode, useFileBrowser, useFileUpload, useFloatingPosition, useFocusTrap, useId, useKanban, useMenu, useMobileMenu, useModal, useNavbar, useNodeRegistry, useOutsideClick, usePanZoom, usePopover, useSidebar, useTabs, useToast, useTreeNav };
|
package/dist/index.d.ts
CHANGED
|
@@ -2110,11 +2110,29 @@ interface EditorToolbarProps {
|
|
|
2110
2110
|
onAction?: (command: string) => void;
|
|
2111
2111
|
children?: ReactNode;
|
|
2112
2112
|
className?: string;
|
|
2113
|
+
/**
|
|
2114
|
+
* Append a "Source" toggle (reveals the raw HTML/Markdown behind the editor)
|
|
2115
|
+
* to the right of the default toolbar. Ignored when `children` are supplied —
|
|
2116
|
+
* custom toolbars compose their own `<Editor.SourceToggle />`.
|
|
2117
|
+
* @default true
|
|
2118
|
+
*/
|
|
2119
|
+
showSourceToggle?: boolean;
|
|
2113
2120
|
}
|
|
2114
2121
|
interface EditorContentProps {
|
|
2115
2122
|
className?: string;
|
|
2116
2123
|
/** Max height in px before scrolling. When set, content area becomes scrollable. */
|
|
2117
2124
|
maxHeight?: number;
|
|
2125
|
+
/** Class names applied to the raw-source `<textarea>` shown while source mode is on. */
|
|
2126
|
+
sourceClassName?: string;
|
|
2127
|
+
}
|
|
2128
|
+
interface EditorSourceToggleProps {
|
|
2129
|
+
className?: string;
|
|
2130
|
+
/** Toggle glyph/label. @default `</>` */
|
|
2131
|
+
icon?: ReactNode;
|
|
2132
|
+
/** Accessible title when in rich-text mode (click → source). @default "Source" */
|
|
2133
|
+
title?: string;
|
|
2134
|
+
/** Accessible title when in source mode (click → rich text). @default "Rich text" */
|
|
2135
|
+
activeTitle?: string;
|
|
2118
2136
|
}
|
|
2119
2137
|
interface EditorProps {
|
|
2120
2138
|
children: ReactNode;
|
|
@@ -2146,6 +2164,17 @@ interface EditorProps {
|
|
|
2146
2164
|
mode?: FieldMode;
|
|
2147
2165
|
/** Per-instance render extensions. Merged with any globally-registered extensions. */
|
|
2148
2166
|
extensions?: RenderExtension[];
|
|
2167
|
+
/**
|
|
2168
|
+
* Controlled source-view flag. When `true` the content area shows the raw
|
|
2169
|
+
* HTML/Markdown (`value`, in `outputFormat`) in an editable `<textarea>`
|
|
2170
|
+
* instead of the rich-text surface. Pair with `onShowSourceChange`, or leave
|
|
2171
|
+
* uncontrolled and drive it with the toolbar's Source toggle.
|
|
2172
|
+
*/
|
|
2173
|
+
showSource?: boolean;
|
|
2174
|
+
/** Initial source-view flag when uncontrolled. @default false */
|
|
2175
|
+
defaultShowSource?: boolean;
|
|
2176
|
+
/** Fired when the Source toggle (or an agent) flips source view on/off. */
|
|
2177
|
+
onShowSourceChange?: (showSource: boolean) => void;
|
|
2149
2178
|
/**
|
|
2150
2179
|
* Skip HTML sanitization of the initial value. By default the initial markdown/HTML
|
|
2151
2180
|
* is sanitized to remove `<script>`, `<iframe>`, event handlers, and `javascript:`
|
|
@@ -2156,7 +2185,7 @@ interface EditorProps {
|
|
|
2156
2185
|
unsafe?: boolean;
|
|
2157
2186
|
}
|
|
2158
2187
|
|
|
2159
|
-
declare function EditorToolbar({ actions, onAction, children, className, }: EditorToolbarProps): react.JSX.Element;
|
|
2188
|
+
declare function EditorToolbar({ actions, onAction, children, className, showSourceToggle, }: EditorToolbarProps): react.JSX.Element;
|
|
2160
2189
|
declare namespace EditorToolbar {
|
|
2161
2190
|
var displayName: string;
|
|
2162
2191
|
}
|
|
@@ -2166,17 +2195,28 @@ declare namespace EditorToolbarSeparator {
|
|
|
2166
2195
|
var displayName: string;
|
|
2167
2196
|
}
|
|
2168
2197
|
|
|
2169
|
-
|
|
2198
|
+
/**
|
|
2199
|
+
* Toolbar button that reveals the raw HTML/Markdown behind the editor. Reads
|
|
2200
|
+
* `showSource` / `setShowSource` from context, so it works in the default
|
|
2201
|
+
* toolbar and in any custom toolbar composed with `useEditor()`.
|
|
2202
|
+
*/
|
|
2203
|
+
declare function EditorSourceToggle({ className, icon, title, activeTitle, }: EditorSourceToggleProps): react.JSX.Element;
|
|
2204
|
+
declare namespace EditorSourceToggle {
|
|
2205
|
+
var displayName: string;
|
|
2206
|
+
}
|
|
2207
|
+
|
|
2208
|
+
declare function EditorContent({ className, maxHeight, sourceClassName }: EditorContentProps): react.JSX.Element;
|
|
2170
2209
|
declare namespace EditorContent {
|
|
2171
2210
|
var displayName: string;
|
|
2172
2211
|
}
|
|
2173
2212
|
|
|
2174
|
-
declare function EditorRoot({ children, className, value: controlledValue, defaultValue, onChange, outputFormat, valueFormat, lineSpacing, placeholder, mode: modeProp, extensions: instanceExtensions, unsafe, }: EditorProps): react.JSX.Element;
|
|
2213
|
+
declare function EditorRoot({ children, className, value: controlledValue, defaultValue, onChange, outputFormat, valueFormat, lineSpacing, placeholder, mode: modeProp, extensions: instanceExtensions, unsafe, showSource: showSourceProp, defaultShowSource, onShowSourceChange, }: EditorProps): react.JSX.Element;
|
|
2175
2214
|
declare const Editor: typeof EditorRoot & {
|
|
2176
2215
|
Toolbar: typeof EditorToolbar & {
|
|
2177
2216
|
Separator: typeof EditorToolbarSeparator;
|
|
2178
2217
|
};
|
|
2179
2218
|
Content: typeof EditorContent;
|
|
2219
|
+
SourceToggle: typeof EditorSourceToggle;
|
|
2180
2220
|
};
|
|
2181
2221
|
|
|
2182
2222
|
interface EditorContextValue {
|
|
@@ -2189,10 +2229,18 @@ interface EditorContextValue {
|
|
|
2189
2229
|
placeholder?: string;
|
|
2190
2230
|
/** Merged render extensions (global + instance). */
|
|
2191
2231
|
extensions: RenderExtension[];
|
|
2232
|
+
/** Whether the raw-source view (textarea) is showing instead of the rich-text surface. */
|
|
2233
|
+
showSource: boolean;
|
|
2234
|
+
/** Toggle/set the raw-source view. */
|
|
2235
|
+
setShowSource: (showSource: boolean) => void;
|
|
2192
2236
|
/** Initial HTML content to load into the editor on mount */
|
|
2193
2237
|
_initialHtml: string;
|
|
2194
2238
|
/** @internal Called by EditorContent on input events */
|
|
2195
2239
|
_onInput: () => void;
|
|
2240
|
+
/** @internal Raw source value (`value` in `outputFormat`), for the source textarea. */
|
|
2241
|
+
_sourceValue: string;
|
|
2242
|
+
/** @internal Commit an edit made directly in the source textarea. */
|
|
2243
|
+
_onSourceInput: (value: string) => void;
|
|
2196
2244
|
}
|
|
2197
2245
|
declare function useEditor(): EditorContextValue;
|
|
2198
2246
|
|
|
@@ -2590,6 +2638,17 @@ interface TreeNavProps {
|
|
|
2590
2638
|
indentSize?: number;
|
|
2591
2639
|
/** Show file/folder icons (default: true) */
|
|
2592
2640
|
showIcons?: boolean;
|
|
2641
|
+
/**
|
|
2642
|
+
* Cursor shown on hover over a draggable node.
|
|
2643
|
+
* - `"none"` (default): the normal clickable cursor — no move affordance on
|
|
2644
|
+
* mere hover. A closed-hand `grabbing` cursor still appears while a drag is
|
|
2645
|
+
* actually happening. This suits click-to-select/open trees (file/nav
|
|
2646
|
+
* trees), where an always-on grab cursor wrongly implies move-first intent.
|
|
2647
|
+
* - `"grab"`: show the open-hand `grab` cursor on hover. Opt in when the whole
|
|
2648
|
+
* row is genuinely a drag handle and reordering is the primary interaction.
|
|
2649
|
+
* @default "none"
|
|
2650
|
+
*/
|
|
2651
|
+
dragCursor?: "grab" | "none";
|
|
2593
2652
|
/** Custom className */
|
|
2594
2653
|
className?: string;
|
|
2595
2654
|
}
|
|
@@ -2602,6 +2661,7 @@ interface TreeNavContextValue {
|
|
|
2602
2661
|
indentSize: number;
|
|
2603
2662
|
showIcons: boolean;
|
|
2604
2663
|
draggable: boolean;
|
|
2664
|
+
dragCursor: "grab" | "none";
|
|
2605
2665
|
dragState: DragState;
|
|
2606
2666
|
setDragState: (state: DragState) => void;
|
|
2607
2667
|
onNodeMove?: (sourceId: string, targetId: string, position: DropPosition) => void;
|
|
@@ -2621,7 +2681,7 @@ declare namespace TreeNode {
|
|
|
2621
2681
|
var displayName: string;
|
|
2622
2682
|
}
|
|
2623
2683
|
|
|
2624
|
-
declare function TreeNavRoot({ nodes, selectedId, onSelect, onNodeContextMenu, draggable, onNodeMove, acceptExternalDrops, onExternalDrop, expandedIds: controlledExpanded, defaultExpandedIds, onExpandedChange, defaultExpandAll, indentSize, showIcons, className, }: TreeNavProps): react.JSX.Element;
|
|
2684
|
+
declare function TreeNavRoot({ nodes, selectedId, onSelect, onNodeContextMenu, draggable, onNodeMove, acceptExternalDrops, onExternalDrop, expandedIds: controlledExpanded, defaultExpandedIds, onExpandedChange, defaultExpandAll, indentSize, showIcons, dragCursor, className, }: TreeNavProps): react.JSX.Element;
|
|
2625
2685
|
declare namespace TreeNavRoot {
|
|
2626
2686
|
var displayName: string;
|
|
2627
2687
|
}
|
|
@@ -3649,4 +3709,4 @@ declare const AudioViewer: react.ForwardRefExoticComponent<AudioViewerProps & re
|
|
|
3649
3709
|
*/
|
|
3650
3710
|
declare const PdfViewer: react.ForwardRefExoticComponent<PdfViewerProps & react.RefAttributes<HTMLDivElement>>;
|
|
3651
3711
|
|
|
3652
|
-
export { Accordion, type AccordionContentProps, type AccordionContextValue, type AccordionItemProps, type AccordionOrientation, AccordionPanel, AccordionPanelContent, type AccordionPanelContentProps, type AccordionPanelProps, AccordionPanelSection, type AccordionPanelSectionProps, AccordionPanelTrigger, type AccordionPanelTriggerProps, type AccordionProps, type AccordionTriggerProps, Action, type ActionColor, type ActionProps, type AffixPosition, AudioViewer, type AudioViewerProps, Autocomplete, type AutocompleteOption, type AutocompleteProps, Avatar, type AvatarProps, Badge, type BadgeProps, Brand, type BrandProps, Breadcrumbs, type BreadcrumbsItemProps, type BreadcrumbsProps, Button, type ButtonColor, type ButtonProps, Calendar, type CalendarMode, type CalendarProps, Callout, type CalloutProps, Card, type CardBodyProps, type CardFooterProps, type CardHeaderProps, type CardProps, Carousel, type CarouselContextValue, type CarouselControlsProps, type CarouselPanelsProps, type CarouselProps, type CarouselSlideProps, type CarouselStepsProps, type CarouselVariant, Chart, type ChartAreaProps, type ChartBarData, type ChartBarProps, type ChartCommonProps, type ChartDonutData, type ChartDonutProps, type ChartHorizontalBarProps, type ChartLineProps, type ChartPieData, type ChartPieProps, type ChartSeries, type ChartSparklineProps, type ChartStackedBarProps, ChatDrawer, type ChatDrawerProps, type ChatDrawerTab, Checkbox, CheckboxGroup, type CheckboxGroupProps, type CheckboxProps, type Color, ColorPicker, type ColorPickerProps, Command, type CommandContextValue, type CommandEmptyProps, type CommandGroupProps, type CommandInputProps, type CommandItemProps, type CommandListProps, type CommandProps, Composer, type ComposerProps, ContentRenderer, type ContentRendererProps, ContextMenu, type ContextMenuContentProps, type ContextMenuContextValue, type ContextMenuItemProps, type ContextMenuProps, type ContextMenuSeparatorProps, type ContextMenuTriggerProps, type ControlledAdapterHandle, DatePicker, type DatePickerProps, type DateRange, DisplayValue, type DisplayValueProps, type DropPosition, Dropdown, type DropdownContextValue, type DropdownItemProps, type DropdownItemsProps, type DropdownProps, type DropdownSeparatorProps, type DropdownTriggerProps, EMOJI_CATEGORY_ORDER, EMOJI_DATA, EMOJI_ENTRIES, Editor, type EditorAction, type EditorContentProps, type EditorContextValue, type EditorProps, type EditorToolbarProps, Emoji, type EmojiCategory, type EmojiCategoryKey, type EmojiEntry, type EmojiFlatEntry, type EmojiProps, EmojiSelect, type EmojiSelectProps, FauxClient, type FauxClientProps, Field, type FieldMode, FieldModeContext, type FieldModeContextValue, type FieldProps, FileBrowser, type FileBrowserContextValue, type FileBrowserNodeProps, type FileBrowserPathBarProps, type FileBrowserProps, type FileBrowserProvider, type FileBrowserRow, type FileBrowserToolbarProps, type FileBrowserTreeProps, type FileEntry, type FileKind, type FileLoadStatus, type FileSelectMode, type FileSnapshotNode, type FileSort, type FileSortDirection, type FileSortField, FileUpload, type FileUploadContextValue, type FileUploadDropzoneProps, type FileUploadListProps, type FileUploadProps, Form, type FormProps, FormProvider, type FormProviderProps, Heading, type HeadingProps, Icon, type IconProps, type IconSet, ImageViewer, type ImageViewerProps, type ImageViewerViewport, Input, type InputAffixProps, type InputBaseProps, type InputOption, type InputOptionGroup, type InputProps, InputTag, type InputTagAdapter, type InputTagAdapterState, type InputTagProps, type InputTagTrigger, type InputTagTriggers, Kanban, type KanbanCardMoveHandler, type KanbanCardProps, type KanbanColumnHandleProps, type KanbanColumnMoveHandler, type KanbanColumnProps, type KanbanContextValue, type KanbanProps, MagicWand, type MagicWandAction, type MagicWandAppearance, type MagicWandProps, type MagicWandSelection, Marquee, type MarqueeDirection, type MarqueeProps, type MediaKind, MediaViewer, type MediaViewerProps, Menu, type MenuContextValue, type MenuGroupProps, type MenuItemProps, type MenuOrientation, type MenuProps, type MenuSubmenuProps, MobileMenu, type MobileMenuBottomBarProps, type MobileMenuContextValue, type MobileMenuFlyoutProps, type MobileMenuItemProps, type MobileMenuSide, type MobileMenuVariant, Modal, type ModalBodyProps, type ModalContextValue, type ModalFooterProps, type ModalHeaderProps, type ModalProps, MoodMeter, type MoodMeterProps, MultiSwitch, type MultiSwitchProps, Navbar, type NavbarBrandProps, type NavbarContextValue, type NavbarItemProps, type NavbarItemsProps, type NavbarProps, type NavbarToggleProps, type NodeRect, OtpInput, type OtpInputProps, Pagination, type PaginationProps, PdfViewer, type PdfViewerProps, Pillbox, type PillboxProps, type Placement, Popover, type PopoverContentProps, type PopoverContextValue, type PopoverProps, type PopoverTriggerProps, Portal, type PortalProps, Profile, type ProfileProps, Progress, type ProgressProps, type PromptAttachment, type PromptCmd, PromptInput, type PromptInputProps, type PromptMention, RadioGroup, type RadioGroupProps, ReasonTag, type ReasonTagProps, type ReasonTagSource, type ReasonTagTheme, type RenderExtension, type RenderExtensionProps, type ResolveMediaTypeInput, SKIN_TONES, type SectionRenderState, type SectionRenderable, Select, type SelectProps, Separator, type SeparatorProps, Sidebar, type SidebarCollapseMode, type SidebarContextValue, type SidebarGroupProps, type SidebarItemProps, type SidebarProps, type SidebarSubmenuProps, type SidebarToggleProps, type Size, Skeleton, type SkeletonProps, type SkinTone, Slider, type SliderProps, StickyNote, type StickyNoteColor, type StickyNoteProps, Switch, type SwitchProps, Table, type TableBodyProps, type TableCellProps, type TableColumnProps, type TableHeadProps, type TablePaginationProps, type TableProps, type TableRowProps, type TableRowTrayProps, type TableSearchProps, type TableTrayProps, Tabs, type TabsContextValue, type TabsListProps, type TabsPanelProps, type TabsPanelsProps, type TabsProps, type TabsTabProps, type TabsVariant, Text, type TextProps, Textarea, type TextareaProps, TimeGrid, type TimeGridProps, type TimeGridTone, TimePicker, type TimePickerProps, Timeline, type TimelineBlockProps, type TimelineEvent, type TimelineItemProps, type TimelineOrientation, type TimelineProps, type TimelineVariant, Toast, type ToastContextValue, type ToastData, type ToastPosition, type ToastProviderProps, type ToastVariant, Tooltip, type TooltipProps, TreeNav, type TreeNavContextValue, type TreeNavProps, type TreeNodeData, type TreeNodeProps, type Variant, VideoViewer, type VideoViewerProps, applyTone, cn, configureIcons, contentEditableAdapter, controlledAdapter, find, hasSkinTones, inputAdapter, registerExtension, registerExtensions, registerIconAddendum, registerIconSet, registerIcons, resolve, resolveMediaType, sanitizeHref, sanitizeHtml, search, skinTones, textareaAdapter, useAccordion, useAccordionPanel, useAccordionSection, useAnimation, useCarousel, useCommand, useContextMenu, useControllableState, useDropdown, useEditor, useEscapeKey, useFieldMode, useFileBrowser, useFileUpload, useFloatingPosition, useFocusTrap, useId, useKanban, useMenu, useMobileMenu, useModal, useNavbar, useNodeRegistry, useOutsideClick, usePanZoom, usePopover, useSidebar, useTabs, useToast, useTreeNav };
|
|
3712
|
+
export { Accordion, type AccordionContentProps, type AccordionContextValue, type AccordionItemProps, type AccordionOrientation, AccordionPanel, AccordionPanelContent, type AccordionPanelContentProps, type AccordionPanelProps, AccordionPanelSection, type AccordionPanelSectionProps, AccordionPanelTrigger, type AccordionPanelTriggerProps, type AccordionProps, type AccordionTriggerProps, Action, type ActionColor, type ActionProps, type AffixPosition, AudioViewer, type AudioViewerProps, Autocomplete, type AutocompleteOption, type AutocompleteProps, Avatar, type AvatarProps, Badge, type BadgeProps, Brand, type BrandProps, Breadcrumbs, type BreadcrumbsItemProps, type BreadcrumbsProps, Button, type ButtonColor, type ButtonProps, Calendar, type CalendarMode, type CalendarProps, Callout, type CalloutProps, Card, type CardBodyProps, type CardFooterProps, type CardHeaderProps, type CardProps, Carousel, type CarouselContextValue, type CarouselControlsProps, type CarouselPanelsProps, type CarouselProps, type CarouselSlideProps, type CarouselStepsProps, type CarouselVariant, Chart, type ChartAreaProps, type ChartBarData, type ChartBarProps, type ChartCommonProps, type ChartDonutData, type ChartDonutProps, type ChartHorizontalBarProps, type ChartLineProps, type ChartPieData, type ChartPieProps, type ChartSeries, type ChartSparklineProps, type ChartStackedBarProps, ChatDrawer, type ChatDrawerProps, type ChatDrawerTab, Checkbox, CheckboxGroup, type CheckboxGroupProps, type CheckboxProps, type Color, ColorPicker, type ColorPickerProps, Command, type CommandContextValue, type CommandEmptyProps, type CommandGroupProps, type CommandInputProps, type CommandItemProps, type CommandListProps, type CommandProps, Composer, type ComposerProps, ContentRenderer, type ContentRendererProps, ContextMenu, type ContextMenuContentProps, type ContextMenuContextValue, type ContextMenuItemProps, type ContextMenuProps, type ContextMenuSeparatorProps, type ContextMenuTriggerProps, type ControlledAdapterHandle, DatePicker, type DatePickerProps, type DateRange, DisplayValue, type DisplayValueProps, type DropPosition, Dropdown, type DropdownContextValue, type DropdownItemProps, type DropdownItemsProps, type DropdownProps, type DropdownSeparatorProps, type DropdownTriggerProps, EMOJI_CATEGORY_ORDER, EMOJI_DATA, EMOJI_ENTRIES, Editor, type EditorAction, type EditorContentProps, type EditorContextValue, type EditorProps, type EditorSourceToggleProps, type EditorToolbarProps, Emoji, type EmojiCategory, type EmojiCategoryKey, type EmojiEntry, type EmojiFlatEntry, type EmojiProps, EmojiSelect, type EmojiSelectProps, FauxClient, type FauxClientProps, Field, type FieldMode, FieldModeContext, type FieldModeContextValue, type FieldProps, FileBrowser, type FileBrowserContextValue, type FileBrowserNodeProps, type FileBrowserPathBarProps, type FileBrowserProps, type FileBrowserProvider, type FileBrowserRow, type FileBrowserToolbarProps, type FileBrowserTreeProps, type FileEntry, type FileKind, type FileLoadStatus, type FileSelectMode, type FileSnapshotNode, type FileSort, type FileSortDirection, type FileSortField, FileUpload, type FileUploadContextValue, type FileUploadDropzoneProps, type FileUploadListProps, type FileUploadProps, Form, type FormProps, FormProvider, type FormProviderProps, Heading, type HeadingProps, Icon, type IconProps, type IconSet, ImageViewer, type ImageViewerProps, type ImageViewerViewport, Input, type InputAffixProps, type InputBaseProps, type InputOption, type InputOptionGroup, type InputProps, InputTag, type InputTagAdapter, type InputTagAdapterState, type InputTagProps, type InputTagTrigger, type InputTagTriggers, Kanban, type KanbanCardMoveHandler, type KanbanCardProps, type KanbanColumnHandleProps, type KanbanColumnMoveHandler, type KanbanColumnProps, type KanbanContextValue, type KanbanProps, MagicWand, type MagicWandAction, type MagicWandAppearance, type MagicWandProps, type MagicWandSelection, Marquee, type MarqueeDirection, type MarqueeProps, type MediaKind, MediaViewer, type MediaViewerProps, Menu, type MenuContextValue, type MenuGroupProps, type MenuItemProps, type MenuOrientation, type MenuProps, type MenuSubmenuProps, MobileMenu, type MobileMenuBottomBarProps, type MobileMenuContextValue, type MobileMenuFlyoutProps, type MobileMenuItemProps, type MobileMenuSide, type MobileMenuVariant, Modal, type ModalBodyProps, type ModalContextValue, type ModalFooterProps, type ModalHeaderProps, type ModalProps, MoodMeter, type MoodMeterProps, MultiSwitch, type MultiSwitchProps, Navbar, type NavbarBrandProps, type NavbarContextValue, type NavbarItemProps, type NavbarItemsProps, type NavbarProps, type NavbarToggleProps, type NodeRect, OtpInput, type OtpInputProps, Pagination, type PaginationProps, PdfViewer, type PdfViewerProps, Pillbox, type PillboxProps, type Placement, Popover, type PopoverContentProps, type PopoverContextValue, type PopoverProps, type PopoverTriggerProps, Portal, type PortalProps, Profile, type ProfileProps, Progress, type ProgressProps, type PromptAttachment, type PromptCmd, PromptInput, type PromptInputProps, type PromptMention, RadioGroup, type RadioGroupProps, ReasonTag, type ReasonTagProps, type ReasonTagSource, type ReasonTagTheme, type RenderExtension, type RenderExtensionProps, type ResolveMediaTypeInput, SKIN_TONES, type SectionRenderState, type SectionRenderable, Select, type SelectProps, Separator, type SeparatorProps, Sidebar, type SidebarCollapseMode, type SidebarContextValue, type SidebarGroupProps, type SidebarItemProps, type SidebarProps, type SidebarSubmenuProps, type SidebarToggleProps, type Size, Skeleton, type SkeletonProps, type SkinTone, Slider, type SliderProps, StickyNote, type StickyNoteColor, type StickyNoteProps, Switch, type SwitchProps, Table, type TableBodyProps, type TableCellProps, type TableColumnProps, type TableHeadProps, type TablePaginationProps, type TableProps, type TableRowProps, type TableRowTrayProps, type TableSearchProps, type TableTrayProps, Tabs, type TabsContextValue, type TabsListProps, type TabsPanelProps, type TabsPanelsProps, type TabsProps, type TabsTabProps, type TabsVariant, Text, type TextProps, Textarea, type TextareaProps, TimeGrid, type TimeGridProps, type TimeGridTone, TimePicker, type TimePickerProps, Timeline, type TimelineBlockProps, type TimelineEvent, type TimelineItemProps, type TimelineOrientation, type TimelineProps, type TimelineVariant, Toast, type ToastContextValue, type ToastData, type ToastPosition, type ToastProviderProps, type ToastVariant, Tooltip, type TooltipProps, TreeNav, type TreeNavContextValue, type TreeNavProps, type TreeNodeData, type TreeNodeProps, type Variant, VideoViewer, type VideoViewerProps, applyTone, cn, configureIcons, contentEditableAdapter, controlledAdapter, find, hasSkinTones, inputAdapter, registerExtension, registerExtensions, registerIconAddendum, registerIconSet, registerIcons, resolve, resolveMediaType, sanitizeHref, sanitizeHtml, search, skinTones, textareaAdapter, useAccordion, useAccordionPanel, useAccordionSection, useAnimation, useCarousel, useCommand, useContextMenu, useControllableState, useDropdown, useEditor, useEscapeKey, useFieldMode, useFileBrowser, useFileUpload, useFloatingPosition, useFocusTrap, useId, useKanban, useMenu, useMobileMenu, useModal, useNavbar, useNodeRegistry, useOutsideClick, usePanZoom, usePopover, useSidebar, useTabs, useToast, useTreeNav };
|
package/dist/index.js
CHANGED
|
@@ -11342,6 +11342,31 @@ function useEditor() {
|
|
|
11342
11342
|
}
|
|
11343
11343
|
return ctx;
|
|
11344
11344
|
}
|
|
11345
|
+
function EditorSourceToggle({
|
|
11346
|
+
className,
|
|
11347
|
+
icon = "</>",
|
|
11348
|
+
title = "Source",
|
|
11349
|
+
activeTitle = "Rich text"
|
|
11350
|
+
}) {
|
|
11351
|
+
const { showSource, setShowSource } = useEditor();
|
|
11352
|
+
return /* @__PURE__ */ jsx(
|
|
11353
|
+
"button",
|
|
11354
|
+
{
|
|
11355
|
+
type: "button",
|
|
11356
|
+
onClick: () => setShowSource(!showSource),
|
|
11357
|
+
title: showSource ? activeTitle : title,
|
|
11358
|
+
"aria-pressed": showSource,
|
|
11359
|
+
"data-react-fancy-editor-source-toggle": "",
|
|
11360
|
+
className: cn(
|
|
11361
|
+
"inline-flex h-8 items-center justify-center rounded-md px-2 font-mono text-xs transition-colors",
|
|
11362
|
+
showSource ? "bg-zinc-200 dark:bg-zinc-700" : "hover:bg-zinc-100 dark:hover:bg-zinc-800",
|
|
11363
|
+
className
|
|
11364
|
+
),
|
|
11365
|
+
children: icon
|
|
11366
|
+
}
|
|
11367
|
+
);
|
|
11368
|
+
}
|
|
11369
|
+
EditorSourceToggle.displayName = "EditorSourceToggle";
|
|
11345
11370
|
var DEFAULT_ACTIONS = [
|
|
11346
11371
|
{ icon: "B", label: "Bold", command: "bold" },
|
|
11347
11372
|
{ icon: "I", label: "Italic", command: "italic" },
|
|
@@ -11352,9 +11377,10 @@ function EditorToolbar({
|
|
|
11352
11377
|
actions = DEFAULT_ACTIONS,
|
|
11353
11378
|
onAction,
|
|
11354
11379
|
children,
|
|
11355
|
-
className
|
|
11380
|
+
className,
|
|
11381
|
+
showSourceToggle = true
|
|
11356
11382
|
}) {
|
|
11357
|
-
const { exec } = useEditor();
|
|
11383
|
+
const { exec, showSource } = useEditor();
|
|
11358
11384
|
return /* @__PURE__ */ jsx(
|
|
11359
11385
|
"div",
|
|
11360
11386
|
{
|
|
@@ -11363,26 +11389,31 @@ function EditorToolbar({
|
|
|
11363
11389
|
"flex items-center gap-0.5 border-b border-zinc-200 px-2 py-1.5 dark:border-zinc-700",
|
|
11364
11390
|
className
|
|
11365
11391
|
),
|
|
11366
|
-
children: children ??
|
|
11367
|
-
|
|
11368
|
-
|
|
11369
|
-
|
|
11370
|
-
|
|
11371
|
-
|
|
11372
|
-
|
|
11373
|
-
|
|
11374
|
-
|
|
11375
|
-
|
|
11392
|
+
children: children ?? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
11393
|
+
actions.map((action) => /* @__PURE__ */ jsx(
|
|
11394
|
+
"button",
|
|
11395
|
+
{
|
|
11396
|
+
type: "button",
|
|
11397
|
+
disabled: showSource,
|
|
11398
|
+
onClick: () => {
|
|
11399
|
+
if (onAction) {
|
|
11400
|
+
onAction(action.command);
|
|
11401
|
+
} else {
|
|
11402
|
+
exec(action.command, action.commandArg);
|
|
11403
|
+
}
|
|
11404
|
+
},
|
|
11405
|
+
title: action.label,
|
|
11406
|
+
className: cn(
|
|
11407
|
+
"inline-flex h-8 w-8 items-center justify-center rounded-md text-sm transition-colors",
|
|
11408
|
+
action.active ? "bg-zinc-200 dark:bg-zinc-700" : "hover:bg-zinc-100 dark:hover:bg-zinc-800",
|
|
11409
|
+
showSource && "cursor-not-allowed opacity-40 hover:bg-transparent"
|
|
11410
|
+
),
|
|
11411
|
+
children: action.icon
|
|
11376
11412
|
},
|
|
11377
|
-
|
|
11378
|
-
|
|
11379
|
-
|
|
11380
|
-
|
|
11381
|
-
),
|
|
11382
|
-
children: action.icon
|
|
11383
|
-
},
|
|
11384
|
-
`${action.command}-${action.commandArg ?? ""}`
|
|
11385
|
-
))
|
|
11413
|
+
`${action.command}-${action.commandArg ?? ""}`
|
|
11414
|
+
)),
|
|
11415
|
+
showSourceToggle && /* @__PURE__ */ jsx(EditorSourceToggle, { className: "ml-auto" })
|
|
11416
|
+
] })
|
|
11386
11417
|
}
|
|
11387
11418
|
);
|
|
11388
11419
|
}
|
|
@@ -11588,20 +11619,58 @@ function extensionEditorClasses(extensions) {
|
|
|
11588
11619
|
].join(" ");
|
|
11589
11620
|
}).join(" ");
|
|
11590
11621
|
}
|
|
11591
|
-
function EditorContent({ className, maxHeight }) {
|
|
11592
|
-
const {
|
|
11593
|
-
|
|
11622
|
+
function EditorContent({ className, maxHeight, sourceClassName }) {
|
|
11623
|
+
const {
|
|
11624
|
+
contentRef,
|
|
11625
|
+
lineSpacing,
|
|
11626
|
+
placeholder,
|
|
11627
|
+
extensions,
|
|
11628
|
+
outputFormat,
|
|
11629
|
+
showSource,
|
|
11630
|
+
_initialHtml,
|
|
11631
|
+
_onInput,
|
|
11632
|
+
_sourceValue,
|
|
11633
|
+
_onSourceInput
|
|
11634
|
+
} = useEditor();
|
|
11635
|
+
const seededHtml = useRef(null);
|
|
11594
11636
|
useEffect(() => {
|
|
11637
|
+
if (showSource) {
|
|
11638
|
+
seededHtml.current = null;
|
|
11639
|
+
return;
|
|
11640
|
+
}
|
|
11595
11641
|
const el = contentRef.current;
|
|
11596
|
-
if (el &&
|
|
11642
|
+
if (el && seededHtml.current !== _initialHtml) {
|
|
11597
11643
|
el.innerHTML = _initialHtml;
|
|
11598
|
-
|
|
11644
|
+
seededHtml.current = _initialHtml;
|
|
11599
11645
|
}
|
|
11600
|
-
}, [contentRef, _initialHtml]);
|
|
11646
|
+
}, [contentRef, _initialHtml, showSource]);
|
|
11601
11647
|
const extClasses = useMemo(
|
|
11602
11648
|
() => extensionEditorClasses(extensions),
|
|
11603
11649
|
[extensions]
|
|
11604
11650
|
);
|
|
11651
|
+
if (showSource) {
|
|
11652
|
+
return /* @__PURE__ */ jsx(
|
|
11653
|
+
"textarea",
|
|
11654
|
+
{
|
|
11655
|
+
"data-react-fancy-editor-source": "",
|
|
11656
|
+
value: _sourceValue,
|
|
11657
|
+
onChange: (e) => _onSourceInput(e.target.value),
|
|
11658
|
+
spellCheck: false,
|
|
11659
|
+
placeholder,
|
|
11660
|
+
"aria-label": `${outputFormat === "markdown" ? "Markdown" : "HTML"} source`,
|
|
11661
|
+
style: {
|
|
11662
|
+
maxHeight: maxHeight ? `${maxHeight}px` : void 0
|
|
11663
|
+
},
|
|
11664
|
+
className: cn(
|
|
11665
|
+
"block min-h-[120px] w-full resize-y px-4 py-3 font-mono text-xs leading-relaxed outline-none",
|
|
11666
|
+
"bg-zinc-50 text-zinc-800 focus:outline-none dark:bg-zinc-900 dark:text-zinc-200",
|
|
11667
|
+
"placeholder:text-zinc-400",
|
|
11668
|
+
maxHeight && "overflow-y-auto",
|
|
11669
|
+
sourceClassName
|
|
11670
|
+
)
|
|
11671
|
+
}
|
|
11672
|
+
);
|
|
11673
|
+
}
|
|
11605
11674
|
return /* @__PURE__ */ jsx(
|
|
11606
11675
|
"div",
|
|
11607
11676
|
{
|
|
@@ -11793,20 +11862,29 @@ function EditorRoot({
|
|
|
11793
11862
|
placeholder,
|
|
11794
11863
|
mode: modeProp,
|
|
11795
11864
|
extensions: instanceExtensions,
|
|
11796
|
-
unsafe = false
|
|
11865
|
+
unsafe = false,
|
|
11866
|
+
showSource: showSourceProp,
|
|
11867
|
+
defaultShowSource = false,
|
|
11868
|
+
onShowSourceChange
|
|
11797
11869
|
}) {
|
|
11798
11870
|
const contentRef = useRef(null);
|
|
11799
11871
|
const [value, setValue] = useControllableState(controlledValue, defaultValue, onChange);
|
|
11872
|
+
const [showSource, setShowSource] = useControllableState(
|
|
11873
|
+
showSourceProp,
|
|
11874
|
+
defaultShowSource,
|
|
11875
|
+
onShowSourceChange
|
|
11876
|
+
);
|
|
11800
11877
|
const mode = useFieldMode(modeProp);
|
|
11801
11878
|
const isView = mode === "view";
|
|
11802
11879
|
const initialHtml = useMemo(
|
|
11803
11880
|
() => toHtml(value, outputFormat, unsafe, valueFormat),
|
|
11804
|
-
// Seed the contentEditable from the LIVE value when (re)entering edit mode
|
|
11805
|
-
//
|
|
11806
|
-
//
|
|
11807
|
-
//
|
|
11881
|
+
// Seed the contentEditable from the LIVE value when (re)entering edit mode —
|
|
11882
|
+
// and when returning from the raw-source view, which may have rewritten the
|
|
11883
|
+
// value out from under the rich-text surface. EditorContent re-seeds when
|
|
11884
|
+
// this recomputes; it does NOT re-run on every keystroke (`value` is not a
|
|
11885
|
+
// dep, so typing in the rich-text surface never re-seeds it).
|
|
11808
11886
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
11809
|
-
[isView, outputFormat, unsafe, valueFormat]
|
|
11887
|
+
[isView, outputFormat, unsafe, valueFormat, showSource]
|
|
11810
11888
|
);
|
|
11811
11889
|
const extensions = useMemo(
|
|
11812
11890
|
() => mergeExtensions(instanceExtensions),
|
|
@@ -11843,6 +11921,12 @@ function EditorRoot({
|
|
|
11843
11921
|
},
|
|
11844
11922
|
[handleInput]
|
|
11845
11923
|
);
|
|
11924
|
+
const handleSourceInput = useCallback(
|
|
11925
|
+
(next) => {
|
|
11926
|
+
setValue(next);
|
|
11927
|
+
},
|
|
11928
|
+
[setValue]
|
|
11929
|
+
);
|
|
11846
11930
|
const wrapSelection = useCallback(
|
|
11847
11931
|
(before, after) => {
|
|
11848
11932
|
const sel = window.getSelection();
|
|
@@ -11866,8 +11950,12 @@ function EditorRoot({
|
|
|
11866
11950
|
lineSpacing,
|
|
11867
11951
|
placeholder,
|
|
11868
11952
|
extensions,
|
|
11953
|
+
showSource,
|
|
11954
|
+
setShowSource,
|
|
11869
11955
|
_initialHtml: initialHtml,
|
|
11870
|
-
_onInput: handleInput
|
|
11956
|
+
_onInput: handleInput,
|
|
11957
|
+
_sourceValue: value,
|
|
11958
|
+
_onSourceInput: handleSourceInput
|
|
11871
11959
|
};
|
|
11872
11960
|
if (isView) {
|
|
11873
11961
|
return /* @__PURE__ */ jsx(
|
|
@@ -11911,7 +11999,8 @@ var ToolbarWithSeparator = Object.assign(EditorToolbar, {
|
|
|
11911
11999
|
});
|
|
11912
12000
|
var Editor = Object.assign(EditorRoot, {
|
|
11913
12001
|
Toolbar: ToolbarWithSeparator,
|
|
11914
|
-
Content: EditorContent
|
|
12002
|
+
Content: EditorContent,
|
|
12003
|
+
SourceToggle: EditorSourceToggle
|
|
11915
12004
|
});
|
|
11916
12005
|
var MenuContext = createContext(null);
|
|
11917
12006
|
function useMenu() {
|
|
@@ -12872,6 +12961,7 @@ function TreeNode({ node, depth }) {
|
|
|
12872
12961
|
indentSize,
|
|
12873
12962
|
showIcons,
|
|
12874
12963
|
draggable,
|
|
12964
|
+
dragCursor,
|
|
12875
12965
|
dragState,
|
|
12876
12966
|
setDragState,
|
|
12877
12967
|
onNodeMove,
|
|
@@ -13002,7 +13092,12 @@ function TreeNode({ node, depth }) {
|
|
|
13002
13092
|
isSelected ? "bg-blue-500/15 text-blue-600 dark:text-blue-400" : "text-zinc-700 hover:bg-zinc-100 dark:text-zinc-300 dark:hover:bg-zinc-800",
|
|
13003
13093
|
node.disabled && "pointer-events-none opacity-40",
|
|
13004
13094
|
isDragging && "opacity-50",
|
|
13005
|
-
|
|
13095
|
+
// Grab affordance. By default (`dragCursor="none"`) the row keeps its
|
|
13096
|
+
// normal click cursor on hover — no open-hand "move me" cursor before
|
|
13097
|
+
// any drag — and only shows the closed-hand `grabbing` cursor while a
|
|
13098
|
+
// drag is actually underway (mousedown/drag). `dragCursor="grab"` opts
|
|
13099
|
+
// back into the always-on grab cursor for whole-row drag handles (#14).
|
|
13100
|
+
canDrag && (dragCursor === "grab" ? "cursor-grab active:cursor-grabbing" : "active:cursor-grabbing"),
|
|
13006
13101
|
isDropTarget && dropPosition === "inside" && "bg-blue-500/10 ring-1 ring-blue-500/30 ring-inset"
|
|
13007
13102
|
),
|
|
13008
13103
|
style: { paddingLeft },
|
|
@@ -13058,6 +13153,7 @@ function TreeNavRoot({
|
|
|
13058
13153
|
defaultExpandAll = false,
|
|
13059
13154
|
indentSize = 16,
|
|
13060
13155
|
showIcons = true,
|
|
13156
|
+
dragCursor = "none",
|
|
13061
13157
|
className
|
|
13062
13158
|
}) {
|
|
13063
13159
|
const [internalExpanded, setInternalExpanded] = useState(() => {
|
|
@@ -13102,6 +13198,7 @@ function TreeNavRoot({
|
|
|
13102
13198
|
indentSize,
|
|
13103
13199
|
showIcons,
|
|
13104
13200
|
draggable,
|
|
13201
|
+
dragCursor,
|
|
13105
13202
|
dragState,
|
|
13106
13203
|
setDragState,
|
|
13107
13204
|
onNodeMove,
|
|
@@ -13119,6 +13216,7 @@ function TreeNavRoot({
|
|
|
13119
13216
|
indentSize,
|
|
13120
13217
|
showIcons,
|
|
13121
13218
|
draggable,
|
|
13219
|
+
dragCursor,
|
|
13122
13220
|
dragState,
|
|
13123
13221
|
onNodeMove,
|
|
13124
13222
|
acceptExternalDrops,
|