@particle-academy/react-fancy 4.13.0 → 4.14.0
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 +129 -38
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +67 -10
- package/dist/index.d.ts +67 -10
- package/dist/index.js +129 -38
- package/dist/index.js.map +1 -1
- package/docs/Editor.md +55 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1262,21 +1262,30 @@ interface PopoverProps {
|
|
|
1262
1262
|
/** Delay in ms before closing after hover leaves. Default: 300 */
|
|
1263
1263
|
hoverCloseDelay?: number;
|
|
1264
1264
|
}
|
|
1265
|
-
|
|
1265
|
+
/**
|
|
1266
|
+
* The trigger renders a `<span>` — it extends its attributes so consumers can
|
|
1267
|
+
* forward `aria-*`, `data-*`, `id`, `title`, etc. onto the actual anchor node
|
|
1268
|
+
* (e.g. `aria-label` for an icon-only trigger). Popover-owned props (ref,
|
|
1269
|
+
* onClick, aria-expanded/haspopup) always win over forwarded ones.
|
|
1270
|
+
*/
|
|
1271
|
+
interface PopoverTriggerProps extends HTMLAttributes<HTMLSpanElement> {
|
|
1266
1272
|
children: ReactNode;
|
|
1267
|
-
className?: string;
|
|
1268
1273
|
}
|
|
1269
|
-
|
|
1274
|
+
/**
|
|
1275
|
+
* The content renders a `<div>` — it extends its attributes so consumers can
|
|
1276
|
+
* forward `aria-*`/`data-*`/`role`/`id` onto the floating panel. Consumer
|
|
1277
|
+
* `style` is merged under the Popover's positioning (left/top always win).
|
|
1278
|
+
*/
|
|
1279
|
+
interface PopoverContentProps extends HTMLAttributes<HTMLDivElement> {
|
|
1270
1280
|
children: ReactNode;
|
|
1271
|
-
className?: string;
|
|
1272
1281
|
}
|
|
1273
1282
|
|
|
1274
|
-
declare function PopoverTrigger({ children, className }: PopoverTriggerProps): react.JSX.Element;
|
|
1283
|
+
declare function PopoverTrigger({ children, className, ...rest }: PopoverTriggerProps): react.JSX.Element;
|
|
1275
1284
|
declare namespace PopoverTrigger {
|
|
1276
1285
|
var displayName: string;
|
|
1277
1286
|
}
|
|
1278
1287
|
|
|
1279
|
-
declare function PopoverContent({ children, className }: PopoverContentProps): react.JSX.Element | null;
|
|
1288
|
+
declare function PopoverContent({ children, className, style, ...rest }: PopoverContentProps): react.JSX.Element | null;
|
|
1280
1289
|
declare namespace PopoverContent {
|
|
1281
1290
|
var displayName: string;
|
|
1282
1291
|
}
|
|
@@ -2101,11 +2110,29 @@ interface EditorToolbarProps {
|
|
|
2101
2110
|
onAction?: (command: string) => void;
|
|
2102
2111
|
children?: ReactNode;
|
|
2103
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;
|
|
2104
2120
|
}
|
|
2105
2121
|
interface EditorContentProps {
|
|
2106
2122
|
className?: string;
|
|
2107
2123
|
/** Max height in px before scrolling. When set, content area becomes scrollable. */
|
|
2108
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;
|
|
2109
2136
|
}
|
|
2110
2137
|
interface EditorProps {
|
|
2111
2138
|
children: ReactNode;
|
|
@@ -2137,6 +2164,17 @@ interface EditorProps {
|
|
|
2137
2164
|
mode?: FieldMode;
|
|
2138
2165
|
/** Per-instance render extensions. Merged with any globally-registered extensions. */
|
|
2139
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;
|
|
2140
2178
|
/**
|
|
2141
2179
|
* Skip HTML sanitization of the initial value. By default the initial markdown/HTML
|
|
2142
2180
|
* is sanitized to remove `<script>`, `<iframe>`, event handlers, and `javascript:`
|
|
@@ -2147,7 +2185,7 @@ interface EditorProps {
|
|
|
2147
2185
|
unsafe?: boolean;
|
|
2148
2186
|
}
|
|
2149
2187
|
|
|
2150
|
-
declare function EditorToolbar({ actions, onAction, children, className, }: EditorToolbarProps): react.JSX.Element;
|
|
2188
|
+
declare function EditorToolbar({ actions, onAction, children, className, showSourceToggle, }: EditorToolbarProps): react.JSX.Element;
|
|
2151
2189
|
declare namespace EditorToolbar {
|
|
2152
2190
|
var displayName: string;
|
|
2153
2191
|
}
|
|
@@ -2157,17 +2195,28 @@ declare namespace EditorToolbarSeparator {
|
|
|
2157
2195
|
var displayName: string;
|
|
2158
2196
|
}
|
|
2159
2197
|
|
|
2160
|
-
|
|
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;
|
|
2161
2209
|
declare namespace EditorContent {
|
|
2162
2210
|
var displayName: string;
|
|
2163
2211
|
}
|
|
2164
2212
|
|
|
2165
|
-
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;
|
|
2166
2214
|
declare const Editor: typeof EditorRoot & {
|
|
2167
2215
|
Toolbar: typeof EditorToolbar & {
|
|
2168
2216
|
Separator: typeof EditorToolbarSeparator;
|
|
2169
2217
|
};
|
|
2170
2218
|
Content: typeof EditorContent;
|
|
2219
|
+
SourceToggle: typeof EditorSourceToggle;
|
|
2171
2220
|
};
|
|
2172
2221
|
|
|
2173
2222
|
interface EditorContextValue {
|
|
@@ -2180,10 +2229,18 @@ interface EditorContextValue {
|
|
|
2180
2229
|
placeholder?: string;
|
|
2181
2230
|
/** Merged render extensions (global + instance). */
|
|
2182
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;
|
|
2183
2236
|
/** Initial HTML content to load into the editor on mount */
|
|
2184
2237
|
_initialHtml: string;
|
|
2185
2238
|
/** @internal Called by EditorContent on input events */
|
|
2186
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;
|
|
2187
2244
|
}
|
|
2188
2245
|
declare function useEditor(): EditorContextValue;
|
|
2189
2246
|
|
|
@@ -3640,4 +3697,4 @@ declare const AudioViewer: react.ForwardRefExoticComponent<AudioViewerProps & re
|
|
|
3640
3697
|
*/
|
|
3641
3698
|
declare const PdfViewer: react.ForwardRefExoticComponent<PdfViewerProps & react.RefAttributes<HTMLDivElement>>;
|
|
3642
3699
|
|
|
3643
|
-
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 };
|
|
3700
|
+
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
|
@@ -1262,21 +1262,30 @@ interface PopoverProps {
|
|
|
1262
1262
|
/** Delay in ms before closing after hover leaves. Default: 300 */
|
|
1263
1263
|
hoverCloseDelay?: number;
|
|
1264
1264
|
}
|
|
1265
|
-
|
|
1265
|
+
/**
|
|
1266
|
+
* The trigger renders a `<span>` — it extends its attributes so consumers can
|
|
1267
|
+
* forward `aria-*`, `data-*`, `id`, `title`, etc. onto the actual anchor node
|
|
1268
|
+
* (e.g. `aria-label` for an icon-only trigger). Popover-owned props (ref,
|
|
1269
|
+
* onClick, aria-expanded/haspopup) always win over forwarded ones.
|
|
1270
|
+
*/
|
|
1271
|
+
interface PopoverTriggerProps extends HTMLAttributes<HTMLSpanElement> {
|
|
1266
1272
|
children: ReactNode;
|
|
1267
|
-
className?: string;
|
|
1268
1273
|
}
|
|
1269
|
-
|
|
1274
|
+
/**
|
|
1275
|
+
* The content renders a `<div>` — it extends its attributes so consumers can
|
|
1276
|
+
* forward `aria-*`/`data-*`/`role`/`id` onto the floating panel. Consumer
|
|
1277
|
+
* `style` is merged under the Popover's positioning (left/top always win).
|
|
1278
|
+
*/
|
|
1279
|
+
interface PopoverContentProps extends HTMLAttributes<HTMLDivElement> {
|
|
1270
1280
|
children: ReactNode;
|
|
1271
|
-
className?: string;
|
|
1272
1281
|
}
|
|
1273
1282
|
|
|
1274
|
-
declare function PopoverTrigger({ children, className }: PopoverTriggerProps): react.JSX.Element;
|
|
1283
|
+
declare function PopoverTrigger({ children, className, ...rest }: PopoverTriggerProps): react.JSX.Element;
|
|
1275
1284
|
declare namespace PopoverTrigger {
|
|
1276
1285
|
var displayName: string;
|
|
1277
1286
|
}
|
|
1278
1287
|
|
|
1279
|
-
declare function PopoverContent({ children, className }: PopoverContentProps): react.JSX.Element | null;
|
|
1288
|
+
declare function PopoverContent({ children, className, style, ...rest }: PopoverContentProps): react.JSX.Element | null;
|
|
1280
1289
|
declare namespace PopoverContent {
|
|
1281
1290
|
var displayName: string;
|
|
1282
1291
|
}
|
|
@@ -2101,11 +2110,29 @@ interface EditorToolbarProps {
|
|
|
2101
2110
|
onAction?: (command: string) => void;
|
|
2102
2111
|
children?: ReactNode;
|
|
2103
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;
|
|
2104
2120
|
}
|
|
2105
2121
|
interface EditorContentProps {
|
|
2106
2122
|
className?: string;
|
|
2107
2123
|
/** Max height in px before scrolling. When set, content area becomes scrollable. */
|
|
2108
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;
|
|
2109
2136
|
}
|
|
2110
2137
|
interface EditorProps {
|
|
2111
2138
|
children: ReactNode;
|
|
@@ -2137,6 +2164,17 @@ interface EditorProps {
|
|
|
2137
2164
|
mode?: FieldMode;
|
|
2138
2165
|
/** Per-instance render extensions. Merged with any globally-registered extensions. */
|
|
2139
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;
|
|
2140
2178
|
/**
|
|
2141
2179
|
* Skip HTML sanitization of the initial value. By default the initial markdown/HTML
|
|
2142
2180
|
* is sanitized to remove `<script>`, `<iframe>`, event handlers, and `javascript:`
|
|
@@ -2147,7 +2185,7 @@ interface EditorProps {
|
|
|
2147
2185
|
unsafe?: boolean;
|
|
2148
2186
|
}
|
|
2149
2187
|
|
|
2150
|
-
declare function EditorToolbar({ actions, onAction, children, className, }: EditorToolbarProps): react.JSX.Element;
|
|
2188
|
+
declare function EditorToolbar({ actions, onAction, children, className, showSourceToggle, }: EditorToolbarProps): react.JSX.Element;
|
|
2151
2189
|
declare namespace EditorToolbar {
|
|
2152
2190
|
var displayName: string;
|
|
2153
2191
|
}
|
|
@@ -2157,17 +2195,28 @@ declare namespace EditorToolbarSeparator {
|
|
|
2157
2195
|
var displayName: string;
|
|
2158
2196
|
}
|
|
2159
2197
|
|
|
2160
|
-
|
|
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;
|
|
2161
2209
|
declare namespace EditorContent {
|
|
2162
2210
|
var displayName: string;
|
|
2163
2211
|
}
|
|
2164
2212
|
|
|
2165
|
-
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;
|
|
2166
2214
|
declare const Editor: typeof EditorRoot & {
|
|
2167
2215
|
Toolbar: typeof EditorToolbar & {
|
|
2168
2216
|
Separator: typeof EditorToolbarSeparator;
|
|
2169
2217
|
};
|
|
2170
2218
|
Content: typeof EditorContent;
|
|
2219
|
+
SourceToggle: typeof EditorSourceToggle;
|
|
2171
2220
|
};
|
|
2172
2221
|
|
|
2173
2222
|
interface EditorContextValue {
|
|
@@ -2180,10 +2229,18 @@ interface EditorContextValue {
|
|
|
2180
2229
|
placeholder?: string;
|
|
2181
2230
|
/** Merged render extensions (global + instance). */
|
|
2182
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;
|
|
2183
2236
|
/** Initial HTML content to load into the editor on mount */
|
|
2184
2237
|
_initialHtml: string;
|
|
2185
2238
|
/** @internal Called by EditorContent on input events */
|
|
2186
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;
|
|
2187
2244
|
}
|
|
2188
2245
|
declare function useEditor(): EditorContextValue;
|
|
2189
2246
|
|
|
@@ -3640,4 +3697,4 @@ declare const AudioViewer: react.ForwardRefExoticComponent<AudioViewerProps & re
|
|
|
3640
3697
|
*/
|
|
3641
3698
|
declare const PdfViewer: react.ForwardRefExoticComponent<PdfViewerProps & react.RefAttributes<HTMLDivElement>>;
|
|
3642
3699
|
|
|
3643
|
-
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 };
|
|
3700
|
+
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
|
@@ -7882,11 +7882,12 @@ function usePopover() {
|
|
|
7882
7882
|
}
|
|
7883
7883
|
return ctx;
|
|
7884
7884
|
}
|
|
7885
|
-
function PopoverTrigger({ children, className }) {
|
|
7885
|
+
function PopoverTrigger({ children, className, ...rest }) {
|
|
7886
7886
|
const { setOpen, open, anchorRef, hover, onHoverEnter, onHoverLeave } = usePopover();
|
|
7887
7887
|
return /* @__PURE__ */ jsx(
|
|
7888
7888
|
"span",
|
|
7889
7889
|
{
|
|
7890
|
+
...rest,
|
|
7890
7891
|
ref: anchorRef,
|
|
7891
7892
|
"data-react-fancy-popover-trigger": "",
|
|
7892
7893
|
className: cn("inline-flex", className),
|
|
@@ -7900,7 +7901,7 @@ function PopoverTrigger({ children, className }) {
|
|
|
7900
7901
|
);
|
|
7901
7902
|
}
|
|
7902
7903
|
PopoverTrigger.displayName = "PopoverTrigger";
|
|
7903
|
-
function PopoverContent({ children, className }) {
|
|
7904
|
+
function PopoverContent({ children, className, style, ...rest }) {
|
|
7904
7905
|
const { open, setOpen, anchorRef, floatingRef, placement, offset, hover, onHoverEnter, onHoverLeave } = usePopover();
|
|
7905
7906
|
const outsideRef = useRef(null);
|
|
7906
7907
|
const position = useFloatingPosition(anchorRef, floatingRef, {
|
|
@@ -7916,6 +7917,7 @@ function PopoverContent({ children, className }) {
|
|
|
7916
7917
|
return /* @__PURE__ */ jsx(Portal, { children: /* @__PURE__ */ jsx(
|
|
7917
7918
|
"div",
|
|
7918
7919
|
{
|
|
7920
|
+
...rest,
|
|
7919
7921
|
ref: (node) => {
|
|
7920
7922
|
outsideRef.current = node;
|
|
7921
7923
|
floatingRef.current = node;
|
|
@@ -7926,7 +7928,7 @@ function PopoverContent({ children, className }) {
|
|
|
7926
7928
|
positioned ? "fancy-scale-in" : "invisible",
|
|
7927
7929
|
className
|
|
7928
7930
|
),
|
|
7929
|
-
style: { left: position.x, top: position.y },
|
|
7931
|
+
style: { ...style, left: position.x, top: position.y },
|
|
7930
7932
|
onMouseEnter: hover ? onHoverEnter : void 0,
|
|
7931
7933
|
onMouseLeave: hover ? onHoverLeave : void 0,
|
|
7932
7934
|
children
|
|
@@ -11340,6 +11342,31 @@ function useEditor() {
|
|
|
11340
11342
|
}
|
|
11341
11343
|
return ctx;
|
|
11342
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";
|
|
11343
11370
|
var DEFAULT_ACTIONS = [
|
|
11344
11371
|
{ icon: "B", label: "Bold", command: "bold" },
|
|
11345
11372
|
{ icon: "I", label: "Italic", command: "italic" },
|
|
@@ -11350,9 +11377,10 @@ function EditorToolbar({
|
|
|
11350
11377
|
actions = DEFAULT_ACTIONS,
|
|
11351
11378
|
onAction,
|
|
11352
11379
|
children,
|
|
11353
|
-
className
|
|
11380
|
+
className,
|
|
11381
|
+
showSourceToggle = true
|
|
11354
11382
|
}) {
|
|
11355
|
-
const { exec } = useEditor();
|
|
11383
|
+
const { exec, showSource } = useEditor();
|
|
11356
11384
|
return /* @__PURE__ */ jsx(
|
|
11357
11385
|
"div",
|
|
11358
11386
|
{
|
|
@@ -11361,26 +11389,31 @@ function EditorToolbar({
|
|
|
11361
11389
|
"flex items-center gap-0.5 border-b border-zinc-200 px-2 py-1.5 dark:border-zinc-700",
|
|
11362
11390
|
className
|
|
11363
11391
|
),
|
|
11364
|
-
children: children ??
|
|
11365
|
-
|
|
11366
|
-
|
|
11367
|
-
|
|
11368
|
-
|
|
11369
|
-
|
|
11370
|
-
|
|
11371
|
-
|
|
11372
|
-
|
|
11373
|
-
|
|
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
|
|
11374
11412
|
},
|
|
11375
|
-
|
|
11376
|
-
|
|
11377
|
-
|
|
11378
|
-
|
|
11379
|
-
),
|
|
11380
|
-
children: action.icon
|
|
11381
|
-
},
|
|
11382
|
-
`${action.command}-${action.commandArg ?? ""}`
|
|
11383
|
-
))
|
|
11413
|
+
`${action.command}-${action.commandArg ?? ""}`
|
|
11414
|
+
)),
|
|
11415
|
+
showSourceToggle && /* @__PURE__ */ jsx(EditorSourceToggle, { className: "ml-auto" })
|
|
11416
|
+
] })
|
|
11384
11417
|
}
|
|
11385
11418
|
);
|
|
11386
11419
|
}
|
|
@@ -11586,20 +11619,58 @@ function extensionEditorClasses(extensions) {
|
|
|
11586
11619
|
].join(" ");
|
|
11587
11620
|
}).join(" ");
|
|
11588
11621
|
}
|
|
11589
|
-
function EditorContent({ className, maxHeight }) {
|
|
11590
|
-
const {
|
|
11591
|
-
|
|
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);
|
|
11592
11636
|
useEffect(() => {
|
|
11637
|
+
if (showSource) {
|
|
11638
|
+
seededHtml.current = null;
|
|
11639
|
+
return;
|
|
11640
|
+
}
|
|
11593
11641
|
const el = contentRef.current;
|
|
11594
|
-
if (el &&
|
|
11642
|
+
if (el && seededHtml.current !== _initialHtml) {
|
|
11595
11643
|
el.innerHTML = _initialHtml;
|
|
11596
|
-
|
|
11644
|
+
seededHtml.current = _initialHtml;
|
|
11597
11645
|
}
|
|
11598
|
-
}, [contentRef, _initialHtml]);
|
|
11646
|
+
}, [contentRef, _initialHtml, showSource]);
|
|
11599
11647
|
const extClasses = useMemo(
|
|
11600
11648
|
() => extensionEditorClasses(extensions),
|
|
11601
11649
|
[extensions]
|
|
11602
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
|
+
}
|
|
11603
11674
|
return /* @__PURE__ */ jsx(
|
|
11604
11675
|
"div",
|
|
11605
11676
|
{
|
|
@@ -11791,20 +11862,29 @@ function EditorRoot({
|
|
|
11791
11862
|
placeholder,
|
|
11792
11863
|
mode: modeProp,
|
|
11793
11864
|
extensions: instanceExtensions,
|
|
11794
|
-
unsafe = false
|
|
11865
|
+
unsafe = false,
|
|
11866
|
+
showSource: showSourceProp,
|
|
11867
|
+
defaultShowSource = false,
|
|
11868
|
+
onShowSourceChange
|
|
11795
11869
|
}) {
|
|
11796
11870
|
const contentRef = useRef(null);
|
|
11797
11871
|
const [value, setValue] = useControllableState(controlledValue, defaultValue, onChange);
|
|
11872
|
+
const [showSource, setShowSource] = useControllableState(
|
|
11873
|
+
showSourceProp,
|
|
11874
|
+
defaultShowSource,
|
|
11875
|
+
onShowSourceChange
|
|
11876
|
+
);
|
|
11798
11877
|
const mode = useFieldMode(modeProp);
|
|
11799
11878
|
const isView = mode === "view";
|
|
11800
11879
|
const initialHtml = useMemo(
|
|
11801
11880
|
() => toHtml(value, outputFormat, unsafe, valueFormat),
|
|
11802
|
-
// Seed the contentEditable from the LIVE value when (re)entering edit mode
|
|
11803
|
-
//
|
|
11804
|
-
//
|
|
11805
|
-
//
|
|
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).
|
|
11806
11886
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
11807
|
-
[isView, outputFormat, unsafe, valueFormat]
|
|
11887
|
+
[isView, outputFormat, unsafe, valueFormat, showSource]
|
|
11808
11888
|
);
|
|
11809
11889
|
const extensions = useMemo(
|
|
11810
11890
|
() => mergeExtensions(instanceExtensions),
|
|
@@ -11841,6 +11921,12 @@ function EditorRoot({
|
|
|
11841
11921
|
},
|
|
11842
11922
|
[handleInput]
|
|
11843
11923
|
);
|
|
11924
|
+
const handleSourceInput = useCallback(
|
|
11925
|
+
(next) => {
|
|
11926
|
+
setValue(next);
|
|
11927
|
+
},
|
|
11928
|
+
[setValue]
|
|
11929
|
+
);
|
|
11844
11930
|
const wrapSelection = useCallback(
|
|
11845
11931
|
(before, after) => {
|
|
11846
11932
|
const sel = window.getSelection();
|
|
@@ -11864,8 +11950,12 @@ function EditorRoot({
|
|
|
11864
11950
|
lineSpacing,
|
|
11865
11951
|
placeholder,
|
|
11866
11952
|
extensions,
|
|
11953
|
+
showSource,
|
|
11954
|
+
setShowSource,
|
|
11867
11955
|
_initialHtml: initialHtml,
|
|
11868
|
-
_onInput: handleInput
|
|
11956
|
+
_onInput: handleInput,
|
|
11957
|
+
_sourceValue: value,
|
|
11958
|
+
_onSourceInput: handleSourceInput
|
|
11869
11959
|
};
|
|
11870
11960
|
if (isView) {
|
|
11871
11961
|
return /* @__PURE__ */ jsx(
|
|
@@ -11909,7 +11999,8 @@ var ToolbarWithSeparator = Object.assign(EditorToolbar, {
|
|
|
11909
11999
|
});
|
|
11910
12000
|
var Editor = Object.assign(EditorRoot, {
|
|
11911
12001
|
Toolbar: ToolbarWithSeparator,
|
|
11912
|
-
Content: EditorContent
|
|
12002
|
+
Content: EditorContent,
|
|
12003
|
+
SourceToggle: EditorSourceToggle
|
|
11913
12004
|
});
|
|
11914
12005
|
var MenuContext = createContext(null);
|
|
11915
12006
|
function useMenu() {
|