@underverse-ui/underverse 1.0.23 → 1.0.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -2829,12 +2829,44 @@ declare function useSmartTranslations(namespace: string): (key: string) => strin
2829
2829
  */
2830
2830
  declare function useSmartLocale(): Locale$1;
2831
2831
 
2832
+ type UEditorUploadImageForSaveResult = string | ({
2833
+ url: string;
2834
+ } & Record<string, unknown>);
2835
+ type UEditorUploadImageForSave = (file: File) => Promise<UEditorUploadImageForSaveResult>;
2836
+ type UEditorPrepareContentUploadMeta = Record<string, unknown>;
2837
+ type UEditorInlineUploadedItem = {
2838
+ index: number;
2839
+ url: string;
2840
+ file?: File;
2841
+ meta?: UEditorPrepareContentUploadMeta;
2842
+ };
2843
+ type UEditorPrepareContentForSaveResult = {
2844
+ html: string;
2845
+ uploaded: Array<{
2846
+ url: string;
2847
+ file?: File;
2848
+ meta?: UEditorPrepareContentUploadMeta;
2849
+ }>;
2850
+ inlineImageUrls: string[];
2851
+ inlineUploaded: UEditorInlineUploadedItem[];
2852
+ errors: Array<{
2853
+ index: number;
2854
+ reason: string;
2855
+ }>;
2856
+ };
2857
+ type UEditorPrepareContentForSaveOptions = {
2858
+ throwOnError?: boolean;
2859
+ };
2860
+ interface UEditorRef {
2861
+ prepareContentForSave: (options?: UEditorPrepareContentForSaveOptions) => Promise<UEditorPrepareContentForSaveResult>;
2862
+ }
2832
2863
  interface UEditorProps {
2833
2864
  content?: string;
2834
2865
  onChange?: (content: string) => void;
2835
2866
  onHtmlChange?: (html: string) => void;
2836
2867
  onJsonChange?: (json: object) => void;
2837
2868
  uploadImage?: (file: File) => Promise<string> | string;
2869
+ uploadImageForSave?: UEditorUploadImageForSave;
2838
2870
  imageInsertMode?: "base64" | "upload";
2839
2871
  placeholder?: string;
2840
2872
  className?: string;
@@ -2851,7 +2883,18 @@ interface UEditorProps {
2851
2883
  }
2852
2884
  type UEditorVariant = NonNullable<UEditorProps["variant"]>;
2853
2885
 
2854
- declare const UEditor: ({ content, onChange, onHtmlChange, onJsonChange, uploadImage, imageInsertMode, placeholder, className, editable, autofocus, showToolbar, showBubbleMenu, showFloatingMenu, showCharacterCount, maxCharacters, minHeight, maxHeight, variant, }: UEditorProps) => react_jsx_runtime.JSX.Element;
2886
+ declare const UEditor: React__default.ForwardRefExoticComponent<UEditorProps & React__default.RefAttributes<UEditorRef>>;
2887
+
2888
+ declare function normalizeImageUrl(url: string): string;
2889
+ declare function extractImageSrcsFromHtml(html: string): string[];
2890
+ declare class UEditorPrepareContentForSaveError extends Error {
2891
+ readonly result: UEditorPrepareContentForSaveResult;
2892
+ constructor(result: UEditorPrepareContentForSaveResult);
2893
+ }
2894
+ declare function prepareUEditorContentForSave({ html, uploadImageForSave, }: {
2895
+ html: string;
2896
+ uploadImageForSave?: UEditorUploadImageForSave;
2897
+ }): Promise<UEditorPrepareContentForSaveResult>;
2855
2898
 
2856
2899
  declare const underverseMessages: {
2857
2900
  readonly en: {
@@ -3630,4 +3673,4 @@ declare function getUnderverseMessages(locale?: UnderverseLocale): {
3630
3673
  };
3631
3674
  };
3632
3675
 
3633
- export { AccessDenied, Alert, AreaChart, type AreaChartDataPoint, type AreaChartProps, type AreaChartSeries, Avatar, Badge, Badge as BadgeBase, BarChart, type BarChartDataPoint, type BarChartProps, type BarChartSeries, BatteryProgress, BottomSheet, Breadcrumb, Button, ButtonLoading, type ButtonProps, Calendar, type CalendarEvent, type CalendarProps, CalendarTimeline, type CalendarTimelineDateInput, type CalendarTimelineDayRangeMode, type CalendarTimelineEvent, type CalendarTimelineFormatters, type CalendarTimelineGroup, type CalendarTimelineInteractions, type CalendarTimelineLabels, type CalendarTimelineProps, type CalendarTimelineResource, type CalendarTimelineSize, type CalendarTimelineView, type CalendarTimelineVirtualization, Card, Carousel, CategoryTreeSelect, Checkbox, type CheckboxProps, CircularProgress, ClientOnly, ColorPicker, type ColorPickerProps, Combobox, type ComboboxProps, CompactPagination, type CompactPaginationProps, DataTable, type DataTableColumn, type DataTableDensity, type DataTableQuery, type DataTableSize, DatePicker, type DatePickerProps, DateRangePicker, DateTimePicker, type DateTimePickerProps, date as DateUtils, Drawer, DropdownMenu, DropdownMenuItem, DropdownMenuSeparator, FallingIcons, FileUpload, type FileUploadProps, FloatingContacts, ForceInternalTranslationsProvider, Form, FormActions, FormCheckbox, FormControl, FormDescription, FormField, FormInput, FormItem, FormLabel, FormMessage, FormSubmitButton, GaugeChart, type GaugeChartProps, GlobalLoading, GradientBadge, Grid, GridItem, type GridItemProps, type GridProps, ImageUpload, InlineLoading, Input, type InputProps, InteractiveBadge, Label, type LanguageOption, LanguageSwitcherHeadless as LanguageSwitcher, LanguageSwitcherHeadless, type LanguageSwitcherHeadlessProps, type LanguageSwitcherHeadlessProps as LanguageSwitcherProps, LineChart, type LineChartDataPoint, type LineChartProps, type LineChartSeries, List, ListItem, LoadingBar, LoadingDots, LoadingProgress, LoadingSpinner, type Locale$1 as Locale, MiniProgress, Modal, MonthYearPicker, MonthYearPicker as MonthYearPickerBase, type MonthYearPickerProps, MultiCombobox, type MultiComboboxProps, MusicPlayer, MusicPlayer as MusicPlayerDefault, type MusicPlayerProps, NotificationBadge, NotificationModal, NumberInput, OverlayControls, PageLoading, Pagination, type PaginationProps, PasswordInput, PieChart, type PieChartDataPoint, type PieChartProps, PillTabs, Popover, Progress, PulseBadge, RadarChart, type RadarChartDataPoint, type RadarChartProps, type RadarChartSeries, RadioGroup, RadioGroupItem, SIZE_STYLES_BTN, ScrollArea, SearchInput, Section, SegmentedProgress, SelectDropdown, Sheet, SidebarSheet, SimplePagination, type SimplePaginationProps, SimpleTabs, Skeleton, SkeletonAvatar, SkeletonButton, SkeletonCard, SkeletonList, SkeletonMessage, SkeletonPost, SkeletonTable, SkeletonText, SlideOver, Slider, SmartImage, type Song, type Sorter, Sparkline, type SparklineDataPoint, type SparklineProps, StatusBadge, StepProgress, type SupportedLocale, Switch, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TagBadge, TagInput, TagInput as TagInputBase, type TagInputProps, Textarea, type ThemeMode, ThemeToggleHeadless as ThemeToggle, ThemeToggleHeadless, type ThemeToggleHeadlessProps, type ThemeToggleHeadlessProps as ThemeToggleProps, TimePicker, type TimePickerProps, Timeline, TimelineItem, ToastProvider, Tooltip, TranslationProvider, type TranslationProviderProps, type Translations, UEditor, type UEditorProps, type UEditorVariant, type UnderverseLocale, UnderverseProvider, type UnderverseProviderProps, type UploadedFile, VARIANT_STYLES_ALERT, VARIANT_STYLES_BTN, VerticalTabs, Watermark, type WatermarkProps, cn$1 as cn, cn as cnLocal, getAnimationStyles, getUnderverseMessages, injectAnimationStyles, shadcnAnimationStyles, underverseMessages, useFormField, useShadCNAnimations, useSmartLocale, useSmartTranslations, useToast, useTranslations as useUnderverseI18n, useLocale as useUnderverseI18nLocale, useUnderverseLocale, useUnderverseTranslations };
3676
+ export { AccessDenied, Alert, AreaChart, type AreaChartDataPoint, type AreaChartProps, type AreaChartSeries, Avatar, Badge, Badge as BadgeBase, BarChart, type BarChartDataPoint, type BarChartProps, type BarChartSeries, BatteryProgress, BottomSheet, Breadcrumb, Button, ButtonLoading, type ButtonProps, Calendar, type CalendarEvent, type CalendarProps, CalendarTimeline, type CalendarTimelineDateInput, type CalendarTimelineDayRangeMode, type CalendarTimelineEvent, type CalendarTimelineFormatters, type CalendarTimelineGroup, type CalendarTimelineInteractions, type CalendarTimelineLabels, type CalendarTimelineProps, type CalendarTimelineResource, type CalendarTimelineSize, type CalendarTimelineView, type CalendarTimelineVirtualization, Card, Carousel, CategoryTreeSelect, Checkbox, type CheckboxProps, CircularProgress, ClientOnly, ColorPicker, type ColorPickerProps, Combobox, type ComboboxProps, CompactPagination, type CompactPaginationProps, DataTable, type DataTableColumn, type DataTableDensity, type DataTableQuery, type DataTableSize, DatePicker, type DatePickerProps, DateRangePicker, DateTimePicker, type DateTimePickerProps, date as DateUtils, Drawer, DropdownMenu, DropdownMenuItem, DropdownMenuSeparator, FallingIcons, FileUpload, type FileUploadProps, FloatingContacts, ForceInternalTranslationsProvider, Form, FormActions, FormCheckbox, FormControl, FormDescription, FormField, FormInput, FormItem, FormLabel, FormMessage, FormSubmitButton, GaugeChart, type GaugeChartProps, GlobalLoading, GradientBadge, Grid, GridItem, type GridItemProps, type GridProps, ImageUpload, InlineLoading, Input, type InputProps, InteractiveBadge, Label, type LanguageOption, LanguageSwitcherHeadless as LanguageSwitcher, LanguageSwitcherHeadless, type LanguageSwitcherHeadlessProps, type LanguageSwitcherHeadlessProps as LanguageSwitcherProps, LineChart, type LineChartDataPoint, type LineChartProps, type LineChartSeries, List, ListItem, LoadingBar, LoadingDots, LoadingProgress, LoadingSpinner, type Locale$1 as Locale, MiniProgress, Modal, MonthYearPicker, MonthYearPicker as MonthYearPickerBase, type MonthYearPickerProps, MultiCombobox, type MultiComboboxProps, MusicPlayer, MusicPlayer as MusicPlayerDefault, type MusicPlayerProps, NotificationBadge, NotificationModal, NumberInput, OverlayControls, PageLoading, Pagination, type PaginationProps, PasswordInput, PieChart, type PieChartDataPoint, type PieChartProps, PillTabs, Popover, Progress, PulseBadge, RadarChart, type RadarChartDataPoint, type RadarChartProps, type RadarChartSeries, RadioGroup, RadioGroupItem, SIZE_STYLES_BTN, ScrollArea, SearchInput, Section, SegmentedProgress, SelectDropdown, Sheet, SidebarSheet, SimplePagination, type SimplePaginationProps, SimpleTabs, Skeleton, SkeletonAvatar, SkeletonButton, SkeletonCard, SkeletonList, SkeletonMessage, SkeletonPost, SkeletonTable, SkeletonText, SlideOver, Slider, SmartImage, type Song, type Sorter, Sparkline, type SparklineDataPoint, type SparklineProps, StatusBadge, StepProgress, type SupportedLocale, Switch, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TagBadge, TagInput, TagInput as TagInputBase, type TagInputProps, Textarea, type ThemeMode, ThemeToggleHeadless as ThemeToggle, ThemeToggleHeadless, type ThemeToggleHeadlessProps, type ThemeToggleHeadlessProps as ThemeToggleProps, TimePicker, type TimePickerProps, Timeline, TimelineItem, ToastProvider, Tooltip, TranslationProvider, type TranslationProviderProps, type Translations, UEditor, type UEditorInlineUploadedItem, UEditorPrepareContentForSaveError, type UEditorPrepareContentForSaveOptions, type UEditorPrepareContentForSaveResult, type UEditorProps, type UEditorRef, type UEditorUploadImageForSave, type UEditorUploadImageForSaveResult, type UEditorVariant, type UnderverseLocale, UnderverseProvider, type UnderverseProviderProps, type UploadedFile, VARIANT_STYLES_ALERT, VARIANT_STYLES_BTN, VerticalTabs, Watermark, type WatermarkProps, cn$1 as cn, cn as cnLocal, extractImageSrcsFromHtml, getAnimationStyles, getUnderverseMessages, injectAnimationStyles, normalizeImageUrl, prepareUEditorContentForSave, shadcnAnimationStyles, underverseMessages, useFormField, useShadCNAnimations, useSmartLocale, useSmartTranslations, useToast, useTranslations as useUnderverseI18n, useLocale as useUnderverseI18nLocale, useUnderverseLocale, useUnderverseTranslations };
package/dist/index.d.ts CHANGED
@@ -2829,12 +2829,44 @@ declare function useSmartTranslations(namespace: string): (key: string) => strin
2829
2829
  */
2830
2830
  declare function useSmartLocale(): Locale$1;
2831
2831
 
2832
+ type UEditorUploadImageForSaveResult = string | ({
2833
+ url: string;
2834
+ } & Record<string, unknown>);
2835
+ type UEditorUploadImageForSave = (file: File) => Promise<UEditorUploadImageForSaveResult>;
2836
+ type UEditorPrepareContentUploadMeta = Record<string, unknown>;
2837
+ type UEditorInlineUploadedItem = {
2838
+ index: number;
2839
+ url: string;
2840
+ file?: File;
2841
+ meta?: UEditorPrepareContentUploadMeta;
2842
+ };
2843
+ type UEditorPrepareContentForSaveResult = {
2844
+ html: string;
2845
+ uploaded: Array<{
2846
+ url: string;
2847
+ file?: File;
2848
+ meta?: UEditorPrepareContentUploadMeta;
2849
+ }>;
2850
+ inlineImageUrls: string[];
2851
+ inlineUploaded: UEditorInlineUploadedItem[];
2852
+ errors: Array<{
2853
+ index: number;
2854
+ reason: string;
2855
+ }>;
2856
+ };
2857
+ type UEditorPrepareContentForSaveOptions = {
2858
+ throwOnError?: boolean;
2859
+ };
2860
+ interface UEditorRef {
2861
+ prepareContentForSave: (options?: UEditorPrepareContentForSaveOptions) => Promise<UEditorPrepareContentForSaveResult>;
2862
+ }
2832
2863
  interface UEditorProps {
2833
2864
  content?: string;
2834
2865
  onChange?: (content: string) => void;
2835
2866
  onHtmlChange?: (html: string) => void;
2836
2867
  onJsonChange?: (json: object) => void;
2837
2868
  uploadImage?: (file: File) => Promise<string> | string;
2869
+ uploadImageForSave?: UEditorUploadImageForSave;
2838
2870
  imageInsertMode?: "base64" | "upload";
2839
2871
  placeholder?: string;
2840
2872
  className?: string;
@@ -2851,7 +2883,18 @@ interface UEditorProps {
2851
2883
  }
2852
2884
  type UEditorVariant = NonNullable<UEditorProps["variant"]>;
2853
2885
 
2854
- declare const UEditor: ({ content, onChange, onHtmlChange, onJsonChange, uploadImage, imageInsertMode, placeholder, className, editable, autofocus, showToolbar, showBubbleMenu, showFloatingMenu, showCharacterCount, maxCharacters, minHeight, maxHeight, variant, }: UEditorProps) => react_jsx_runtime.JSX.Element;
2886
+ declare const UEditor: React__default.ForwardRefExoticComponent<UEditorProps & React__default.RefAttributes<UEditorRef>>;
2887
+
2888
+ declare function normalizeImageUrl(url: string): string;
2889
+ declare function extractImageSrcsFromHtml(html: string): string[];
2890
+ declare class UEditorPrepareContentForSaveError extends Error {
2891
+ readonly result: UEditorPrepareContentForSaveResult;
2892
+ constructor(result: UEditorPrepareContentForSaveResult);
2893
+ }
2894
+ declare function prepareUEditorContentForSave({ html, uploadImageForSave, }: {
2895
+ html: string;
2896
+ uploadImageForSave?: UEditorUploadImageForSave;
2897
+ }): Promise<UEditorPrepareContentForSaveResult>;
2855
2898
 
2856
2899
  declare const underverseMessages: {
2857
2900
  readonly en: {
@@ -3630,4 +3673,4 @@ declare function getUnderverseMessages(locale?: UnderverseLocale): {
3630
3673
  };
3631
3674
  };
3632
3675
 
3633
- export { AccessDenied, Alert, AreaChart, type AreaChartDataPoint, type AreaChartProps, type AreaChartSeries, Avatar, Badge, Badge as BadgeBase, BarChart, type BarChartDataPoint, type BarChartProps, type BarChartSeries, BatteryProgress, BottomSheet, Breadcrumb, Button, ButtonLoading, type ButtonProps, Calendar, type CalendarEvent, type CalendarProps, CalendarTimeline, type CalendarTimelineDateInput, type CalendarTimelineDayRangeMode, type CalendarTimelineEvent, type CalendarTimelineFormatters, type CalendarTimelineGroup, type CalendarTimelineInteractions, type CalendarTimelineLabels, type CalendarTimelineProps, type CalendarTimelineResource, type CalendarTimelineSize, type CalendarTimelineView, type CalendarTimelineVirtualization, Card, Carousel, CategoryTreeSelect, Checkbox, type CheckboxProps, CircularProgress, ClientOnly, ColorPicker, type ColorPickerProps, Combobox, type ComboboxProps, CompactPagination, type CompactPaginationProps, DataTable, type DataTableColumn, type DataTableDensity, type DataTableQuery, type DataTableSize, DatePicker, type DatePickerProps, DateRangePicker, DateTimePicker, type DateTimePickerProps, date as DateUtils, Drawer, DropdownMenu, DropdownMenuItem, DropdownMenuSeparator, FallingIcons, FileUpload, type FileUploadProps, FloatingContacts, ForceInternalTranslationsProvider, Form, FormActions, FormCheckbox, FormControl, FormDescription, FormField, FormInput, FormItem, FormLabel, FormMessage, FormSubmitButton, GaugeChart, type GaugeChartProps, GlobalLoading, GradientBadge, Grid, GridItem, type GridItemProps, type GridProps, ImageUpload, InlineLoading, Input, type InputProps, InteractiveBadge, Label, type LanguageOption, LanguageSwitcherHeadless as LanguageSwitcher, LanguageSwitcherHeadless, type LanguageSwitcherHeadlessProps, type LanguageSwitcherHeadlessProps as LanguageSwitcherProps, LineChart, type LineChartDataPoint, type LineChartProps, type LineChartSeries, List, ListItem, LoadingBar, LoadingDots, LoadingProgress, LoadingSpinner, type Locale$1 as Locale, MiniProgress, Modal, MonthYearPicker, MonthYearPicker as MonthYearPickerBase, type MonthYearPickerProps, MultiCombobox, type MultiComboboxProps, MusicPlayer, MusicPlayer as MusicPlayerDefault, type MusicPlayerProps, NotificationBadge, NotificationModal, NumberInput, OverlayControls, PageLoading, Pagination, type PaginationProps, PasswordInput, PieChart, type PieChartDataPoint, type PieChartProps, PillTabs, Popover, Progress, PulseBadge, RadarChart, type RadarChartDataPoint, type RadarChartProps, type RadarChartSeries, RadioGroup, RadioGroupItem, SIZE_STYLES_BTN, ScrollArea, SearchInput, Section, SegmentedProgress, SelectDropdown, Sheet, SidebarSheet, SimplePagination, type SimplePaginationProps, SimpleTabs, Skeleton, SkeletonAvatar, SkeletonButton, SkeletonCard, SkeletonList, SkeletonMessage, SkeletonPost, SkeletonTable, SkeletonText, SlideOver, Slider, SmartImage, type Song, type Sorter, Sparkline, type SparklineDataPoint, type SparklineProps, StatusBadge, StepProgress, type SupportedLocale, Switch, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TagBadge, TagInput, TagInput as TagInputBase, type TagInputProps, Textarea, type ThemeMode, ThemeToggleHeadless as ThemeToggle, ThemeToggleHeadless, type ThemeToggleHeadlessProps, type ThemeToggleHeadlessProps as ThemeToggleProps, TimePicker, type TimePickerProps, Timeline, TimelineItem, ToastProvider, Tooltip, TranslationProvider, type TranslationProviderProps, type Translations, UEditor, type UEditorProps, type UEditorVariant, type UnderverseLocale, UnderverseProvider, type UnderverseProviderProps, type UploadedFile, VARIANT_STYLES_ALERT, VARIANT_STYLES_BTN, VerticalTabs, Watermark, type WatermarkProps, cn$1 as cn, cn as cnLocal, getAnimationStyles, getUnderverseMessages, injectAnimationStyles, shadcnAnimationStyles, underverseMessages, useFormField, useShadCNAnimations, useSmartLocale, useSmartTranslations, useToast, useTranslations as useUnderverseI18n, useLocale as useUnderverseI18nLocale, useUnderverseLocale, useUnderverseTranslations };
3676
+ export { AccessDenied, Alert, AreaChart, type AreaChartDataPoint, type AreaChartProps, type AreaChartSeries, Avatar, Badge, Badge as BadgeBase, BarChart, type BarChartDataPoint, type BarChartProps, type BarChartSeries, BatteryProgress, BottomSheet, Breadcrumb, Button, ButtonLoading, type ButtonProps, Calendar, type CalendarEvent, type CalendarProps, CalendarTimeline, type CalendarTimelineDateInput, type CalendarTimelineDayRangeMode, type CalendarTimelineEvent, type CalendarTimelineFormatters, type CalendarTimelineGroup, type CalendarTimelineInteractions, type CalendarTimelineLabels, type CalendarTimelineProps, type CalendarTimelineResource, type CalendarTimelineSize, type CalendarTimelineView, type CalendarTimelineVirtualization, Card, Carousel, CategoryTreeSelect, Checkbox, type CheckboxProps, CircularProgress, ClientOnly, ColorPicker, type ColorPickerProps, Combobox, type ComboboxProps, CompactPagination, type CompactPaginationProps, DataTable, type DataTableColumn, type DataTableDensity, type DataTableQuery, type DataTableSize, DatePicker, type DatePickerProps, DateRangePicker, DateTimePicker, type DateTimePickerProps, date as DateUtils, Drawer, DropdownMenu, DropdownMenuItem, DropdownMenuSeparator, FallingIcons, FileUpload, type FileUploadProps, FloatingContacts, ForceInternalTranslationsProvider, Form, FormActions, FormCheckbox, FormControl, FormDescription, FormField, FormInput, FormItem, FormLabel, FormMessage, FormSubmitButton, GaugeChart, type GaugeChartProps, GlobalLoading, GradientBadge, Grid, GridItem, type GridItemProps, type GridProps, ImageUpload, InlineLoading, Input, type InputProps, InteractiveBadge, Label, type LanguageOption, LanguageSwitcherHeadless as LanguageSwitcher, LanguageSwitcherHeadless, type LanguageSwitcherHeadlessProps, type LanguageSwitcherHeadlessProps as LanguageSwitcherProps, LineChart, type LineChartDataPoint, type LineChartProps, type LineChartSeries, List, ListItem, LoadingBar, LoadingDots, LoadingProgress, LoadingSpinner, type Locale$1 as Locale, MiniProgress, Modal, MonthYearPicker, MonthYearPicker as MonthYearPickerBase, type MonthYearPickerProps, MultiCombobox, type MultiComboboxProps, MusicPlayer, MusicPlayer as MusicPlayerDefault, type MusicPlayerProps, NotificationBadge, NotificationModal, NumberInput, OverlayControls, PageLoading, Pagination, type PaginationProps, PasswordInput, PieChart, type PieChartDataPoint, type PieChartProps, PillTabs, Popover, Progress, PulseBadge, RadarChart, type RadarChartDataPoint, type RadarChartProps, type RadarChartSeries, RadioGroup, RadioGroupItem, SIZE_STYLES_BTN, ScrollArea, SearchInput, Section, SegmentedProgress, SelectDropdown, Sheet, SidebarSheet, SimplePagination, type SimplePaginationProps, SimpleTabs, Skeleton, SkeletonAvatar, SkeletonButton, SkeletonCard, SkeletonList, SkeletonMessage, SkeletonPost, SkeletonTable, SkeletonText, SlideOver, Slider, SmartImage, type Song, type Sorter, Sparkline, type SparklineDataPoint, type SparklineProps, StatusBadge, StepProgress, type SupportedLocale, Switch, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TagBadge, TagInput, TagInput as TagInputBase, type TagInputProps, Textarea, type ThemeMode, ThemeToggleHeadless as ThemeToggle, ThemeToggleHeadless, type ThemeToggleHeadlessProps, type ThemeToggleHeadlessProps as ThemeToggleProps, TimePicker, type TimePickerProps, Timeline, TimelineItem, ToastProvider, Tooltip, TranslationProvider, type TranslationProviderProps, type Translations, UEditor, type UEditorInlineUploadedItem, UEditorPrepareContentForSaveError, type UEditorPrepareContentForSaveOptions, type UEditorPrepareContentForSaveResult, type UEditorProps, type UEditorRef, type UEditorUploadImageForSave, type UEditorUploadImageForSaveResult, type UEditorVariant, type UnderverseLocale, UnderverseProvider, type UnderverseProviderProps, type UploadedFile, VARIANT_STYLES_ALERT, VARIANT_STYLES_BTN, VerticalTabs, Watermark, type WatermarkProps, cn$1 as cn, cn as cnLocal, extractImageSrcsFromHtml, getAnimationStyles, getUnderverseMessages, injectAnimationStyles, normalizeImageUrl, prepareUEditorContentForSave, shadcnAnimationStyles, underverseMessages, useFormField, useShadCNAnimations, useSmartLocale, useSmartTranslations, useToast, useTranslations as useUnderverseI18n, useLocale as useUnderverseI18nLocale, useUnderverseLocale, useUnderverseTranslations };
package/dist/index.js CHANGED
@@ -14159,7 +14159,7 @@ function ImageUpload({
14159
14159
  import { useState as useState33, useRef as useRef17, useCallback as useCallback14, useMemo as useMemo17 } from "react";
14160
14160
  import {
14161
14161
  Upload as Upload2,
14162
- File,
14162
+ File as File2,
14163
14163
  FileText,
14164
14164
  FileImage,
14165
14165
  FileVideo,
@@ -14241,7 +14241,7 @@ var getFileIcon = (mimeType, fileName) => {
14241
14241
  case "c":
14242
14242
  return FileCode;
14243
14243
  default:
14244
- return File;
14244
+ return File2;
14245
14245
  }
14246
14246
  };
14247
14247
  var getFileTypeColor = (mimeType) => {
@@ -14454,7 +14454,7 @@ function FileUpload({
14454
14454
  [uploadHandler, processFiles, handleRemove]
14455
14455
  );
14456
14456
  const renderFileItem = (file) => {
14457
- const IconComponent = showTypeIcons ? getFileIcon(file.type, file.name) : File;
14457
+ const IconComponent = showTypeIcons ? getFileIcon(file.type, file.name) : File2;
14458
14458
  const iconColor = getFileTypeColor(file.type);
14459
14459
  const isImage = file.type.startsWith("image/") && file.url;
14460
14460
  return /* @__PURE__ */ jsxs41(
@@ -21297,7 +21297,7 @@ function useSmartLocale() {
21297
21297
  }
21298
21298
 
21299
21299
  // ../../components/ui/UEditor/UEditor.tsx
21300
- import { useEffect as useEffect36, useMemo as useMemo28 } from "react";
21300
+ import React72, { useEffect as useEffect36, useImperativeHandle as useImperativeHandle3, useMemo as useMemo28, useRef as useRef34 } from "react";
21301
21301
  import { useTranslations as useTranslations7 } from "next-intl";
21302
21302
  import { useEditor, EditorContent } from "@tiptap/react";
21303
21303
 
@@ -24259,14 +24259,261 @@ var CharacterCountDisplay = ({ editor, maxCharacters }) => {
24259
24259
  ] });
24260
24260
  };
24261
24261
 
24262
+ // ../../components/ui/UEditor/prepare-content-for-save.ts
24263
+ var MIME_EXTENSION_MAP = {
24264
+ "image/png": "png",
24265
+ "image/jpeg": "jpg",
24266
+ "image/webp": "webp",
24267
+ "image/gif": "gif",
24268
+ "image/svg+xml": "svg",
24269
+ "image/bmp": "bmp",
24270
+ "image/x-icon": "ico",
24271
+ "image/avif": "avif"
24272
+ };
24273
+ function isDataImageUrl(value) {
24274
+ return /^data:image\//i.test(value.trim());
24275
+ }
24276
+ function parseDataImageUrl(dataUrl) {
24277
+ const value = dataUrl.trim();
24278
+ if (!isDataImageUrl(value)) return null;
24279
+ const commaIndex = value.indexOf(",");
24280
+ if (commaIndex < 0) return null;
24281
+ const header = value.slice(5, commaIndex);
24282
+ const base64Data = value.slice(commaIndex + 1).trim();
24283
+ if (!/;base64/i.test(header)) return null;
24284
+ const mime = header.split(";")[0]?.trim().toLowerCase();
24285
+ if (!mime || !base64Data) return null;
24286
+ return { mime, base64Data };
24287
+ }
24288
+ function decodeBase64ToBytes(base64Data) {
24289
+ const normalized = base64Data.replace(/\s+/g, "");
24290
+ const binary = atob(normalized);
24291
+ const bytes = new Uint8Array(binary.length);
24292
+ for (let i = 0; i < binary.length; i += 1) {
24293
+ bytes[i] = binary.charCodeAt(i);
24294
+ }
24295
+ return bytes;
24296
+ }
24297
+ function inferFileExtension(mime) {
24298
+ return MIME_EXTENSION_MAP[mime] ?? "bin";
24299
+ }
24300
+ function createFileFromDataImageUrl(dataUrl, index) {
24301
+ const parsed = parseDataImageUrl(dataUrl);
24302
+ if (!parsed) {
24303
+ throw new Error("Invalid data image URL format.");
24304
+ }
24305
+ const bytes = decodeBase64ToBytes(parsed.base64Data);
24306
+ const extension = inferFileExtension(parsed.mime);
24307
+ const name = `ueditor-image-${index + 1}.${extension}`;
24308
+ return new File([bytes], name, { type: parsed.mime });
24309
+ }
24310
+ function normalizeUploadResult(result) {
24311
+ if (typeof result === "string") {
24312
+ const url2 = result.trim();
24313
+ if (!url2) throw new Error("Upload handler returned an empty URL.");
24314
+ return { url: url2 };
24315
+ }
24316
+ if (!result || typeof result !== "object") {
24317
+ throw new Error("Upload handler returned invalid result.");
24318
+ }
24319
+ const url = typeof result.url === "string" ? result.url.trim() : "";
24320
+ if (!url) throw new Error("Upload handler object result is missing `url`.");
24321
+ const { url: _ignoredUrl, ...rest } = result;
24322
+ const meta = Object.keys(rest).length > 0 ? rest : void 0;
24323
+ return { url, meta };
24324
+ }
24325
+ function getErrorReason(error) {
24326
+ if (error instanceof Error && error.message) return error.message;
24327
+ if (typeof error === "string" && error.trim()) return error;
24328
+ return "Unknown upload error.";
24329
+ }
24330
+ function decodeHtmlEntities(value) {
24331
+ return value.replace(/&quot;/gi, '"').replace(/&#39;/gi, "'").replace(/&amp;/gi, "&").replace(/&lt;/gi, "<").replace(/&gt;/gi, ">").replace(/&nbsp;/gi, " ");
24332
+ }
24333
+ function normalizeImageUrl(url) {
24334
+ const input = decodeHtmlEntities(url.trim());
24335
+ if (!input) return "";
24336
+ if (isDataImageUrl(input)) return input;
24337
+ const isAbsolute = /^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(input);
24338
+ if (!isAbsolute) {
24339
+ return input.split("#")[0] ?? input;
24340
+ }
24341
+ try {
24342
+ const parsed = new URL(input);
24343
+ parsed.hash = "";
24344
+ if (parsed.protocol === "http:" || parsed.protocol === "https:") {
24345
+ parsed.hostname = parsed.hostname.toLowerCase();
24346
+ if (parsed.protocol === "http:" && parsed.port === "80" || parsed.protocol === "https:" && parsed.port === "443") {
24347
+ parsed.port = "";
24348
+ }
24349
+ if (parsed.pathname.length > 1 && parsed.pathname.endsWith("/")) {
24350
+ parsed.pathname = parsed.pathname.slice(0, -1);
24351
+ }
24352
+ }
24353
+ return parsed.toString();
24354
+ } catch {
24355
+ return input.split("#")[0] ?? input;
24356
+ }
24357
+ }
24358
+ function replaceSrcInTag(match, nextSrc) {
24359
+ if (!match.srcAttr) return match.tag;
24360
+ const { start, end, quote } = match.srcAttr;
24361
+ const escaped = quote === '"' ? nextSrc.replace(/"/g, "&quot;") : quote === "'" ? nextSrc.replace(/'/g, "&#39;") : nextSrc;
24362
+ const srcAttr = quote ? `src=${quote}${escaped}${quote}` : `src=${escaped}`;
24363
+ return `${match.tag.slice(0, start)}${srcAttr}${match.tag.slice(end)}`;
24364
+ }
24365
+ function collectImgTagMatches(html) {
24366
+ const matches = [];
24367
+ const imgRegex = /<img\b[^>]*>/gi;
24368
+ const srcAttrRegex = /\bsrc\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+))/i;
24369
+ let tagMatch = imgRegex.exec(html);
24370
+ while (tagMatch) {
24371
+ const tag = tagMatch[0];
24372
+ const start = tagMatch.index;
24373
+ const end = start + tag.length;
24374
+ const srcMatch = srcAttrRegex.exec(tag);
24375
+ let srcAttr = null;
24376
+ if (srcMatch) {
24377
+ const value = srcMatch[1] ?? srcMatch[2] ?? srcMatch[3] ?? "";
24378
+ const quote = srcMatch[1] !== void 0 ? '"' : srcMatch[2] !== void 0 ? "'" : "";
24379
+ srcAttr = {
24380
+ start: srcMatch.index,
24381
+ end: srcMatch.index + srcMatch[0].length,
24382
+ value,
24383
+ quote
24384
+ };
24385
+ }
24386
+ matches.push({ start, end, tag, srcAttr });
24387
+ tagMatch = imgRegex.exec(html);
24388
+ }
24389
+ return matches;
24390
+ }
24391
+ function extractImageSrcsFromHtml(html) {
24392
+ if (!html || !html.includes("<img")) return [];
24393
+ return collectImgTagMatches(html).map((match) => decodeHtmlEntities(match.srcAttr?.value.trim() ?? "")).filter(Boolean);
24394
+ }
24395
+ function createResult({
24396
+ html,
24397
+ uploaded,
24398
+ inlineUploaded,
24399
+ errors
24400
+ }) {
24401
+ return {
24402
+ html,
24403
+ uploaded,
24404
+ inlineImageUrls: extractImageSrcsFromHtml(html),
24405
+ inlineUploaded,
24406
+ errors
24407
+ };
24408
+ }
24409
+ var UEditorPrepareContentForSaveError = class extends Error {
24410
+ constructor(result) {
24411
+ super(
24412
+ `Failed to upload ${result.errors.length} image(s): ${result.errors.map((item) => `#${item.index} ${item.reason}`).join("; ")}`
24413
+ );
24414
+ this.name = "UEditorPrepareContentForSaveError";
24415
+ this.result = result;
24416
+ }
24417
+ };
24418
+ async function prepareUEditorContentForSave({
24419
+ html,
24420
+ uploadImageForSave
24421
+ }) {
24422
+ if (!html || !html.includes("<img")) {
24423
+ return createResult({ html, uploaded: [], inlineUploaded: [], errors: [] });
24424
+ }
24425
+ const imgMatches = collectImgTagMatches(html);
24426
+ if (imgMatches.length === 0) {
24427
+ return createResult({ html, uploaded: [], inlineUploaded: [], errors: [] });
24428
+ }
24429
+ const base64Candidates = [];
24430
+ for (const match of imgMatches) {
24431
+ if (!match.srcAttr) continue;
24432
+ const src = match.srcAttr.value.trim();
24433
+ if (!isDataImageUrl(src)) continue;
24434
+ base64Candidates.push({
24435
+ id: `${match.start}:${match.end}`,
24436
+ match,
24437
+ index: base64Candidates.length,
24438
+ src
24439
+ });
24440
+ }
24441
+ if (base64Candidates.length === 0) {
24442
+ return createResult({ html, uploaded: [], inlineUploaded: [], errors: [] });
24443
+ }
24444
+ if (!uploadImageForSave) {
24445
+ return createResult({
24446
+ html,
24447
+ uploaded: [],
24448
+ inlineUploaded: [],
24449
+ errors: base64Candidates.map((item) => ({
24450
+ index: item.index,
24451
+ reason: "`uploadImageForSave` is required to transform base64 images before save."
24452
+ }))
24453
+ });
24454
+ }
24455
+ const uploaded = [];
24456
+ const inlineUploaded = [];
24457
+ const errors = [];
24458
+ const replacements = /* @__PURE__ */ new Map();
24459
+ const uploadResults = await Promise.all(
24460
+ base64Candidates.map(async (candidate) => {
24461
+ try {
24462
+ const file = createFileFromDataImageUrl(candidate.src, candidate.index);
24463
+ const uploadResult = await uploadImageForSave(file);
24464
+ const normalized = normalizeUploadResult(uploadResult);
24465
+ return { candidate, file, ...normalized };
24466
+ } catch (error) {
24467
+ return { candidate, error: getErrorReason(error) };
24468
+ }
24469
+ })
24470
+ );
24471
+ for (const item of uploadResults) {
24472
+ if ("error" in item) {
24473
+ errors.push({
24474
+ index: item.candidate.index,
24475
+ reason: item.error ?? "Unknown upload error."
24476
+ });
24477
+ continue;
24478
+ }
24479
+ replacements.set(item.candidate.id, item.url);
24480
+ uploaded.push({
24481
+ url: item.url,
24482
+ file: item.file,
24483
+ meta: item.meta
24484
+ });
24485
+ inlineUploaded.push({
24486
+ index: item.candidate.index,
24487
+ url: item.url,
24488
+ file: item.file,
24489
+ meta: item.meta
24490
+ });
24491
+ }
24492
+ if (replacements.size === 0) {
24493
+ return createResult({ html, uploaded, inlineUploaded, errors });
24494
+ }
24495
+ let transformed = "";
24496
+ let cursor = 0;
24497
+ for (const match of imgMatches) {
24498
+ transformed += html.slice(cursor, match.start);
24499
+ const replacementKey = `${match.start}:${match.end}`;
24500
+ const replacementUrl = replacements.get(replacementKey);
24501
+ transformed += replacementUrl ? replaceSrcInTag(match, replacementUrl) : match.tag;
24502
+ cursor = match.end;
24503
+ }
24504
+ transformed += html.slice(cursor);
24505
+ return createResult({ html: transformed, uploaded, inlineUploaded, errors });
24506
+ }
24507
+
24262
24508
  // ../../components/ui/UEditor/UEditor.tsx
24263
24509
  import { jsx as jsx85, jsxs as jsxs78 } from "react/jsx-runtime";
24264
- var UEditor = ({
24510
+ var UEditor = React72.forwardRef(({
24265
24511
  content = "",
24266
24512
  onChange,
24267
24513
  onHtmlChange,
24268
24514
  onJsonChange,
24269
24515
  uploadImage,
24516
+ uploadImageForSave,
24270
24517
  imageInsertMode = "base64",
24271
24518
  placeholder,
24272
24519
  className,
@@ -24280,9 +24527,10 @@ var UEditor = ({
24280
24527
  minHeight = "200px",
24281
24528
  maxHeight = "auto",
24282
24529
  variant = "default"
24283
- }) => {
24530
+ }, ref) => {
24284
24531
  const t = useTranslations7("UEditor");
24285
24532
  const effectivePlaceholder = placeholder ?? t("placeholder");
24533
+ const inFlightPrepareRef = useRef34(null);
24286
24534
  const extensions = useMemo28(
24287
24535
  () => buildUEditorExtensions({ placeholder: effectivePlaceholder, maxCharacters, uploadImage, imageInsertMode, editable }),
24288
24536
  [effectivePlaceholder, maxCharacters, uploadImage, imageInsertMode, editable]
@@ -24392,6 +24640,28 @@ var UEditor = ({
24392
24640
  onJsonChange?.(editor2.getJSON());
24393
24641
  }
24394
24642
  });
24643
+ useImperativeHandle3(
24644
+ ref,
24645
+ () => ({
24646
+ prepareContentForSave: async ({ throwOnError = false } = {}) => {
24647
+ if (!inFlightPrepareRef.current) {
24648
+ const htmlSnapshot = editor?.getHTML() ?? content ?? "";
24649
+ inFlightPrepareRef.current = prepareUEditorContentForSave({
24650
+ html: htmlSnapshot,
24651
+ uploadImageForSave
24652
+ }).finally(() => {
24653
+ inFlightPrepareRef.current = null;
24654
+ });
24655
+ }
24656
+ const result = await inFlightPrepareRef.current;
24657
+ if (throwOnError && result.errors.length > 0) {
24658
+ throw new UEditorPrepareContentForSaveError(result);
24659
+ }
24660
+ return result;
24661
+ }
24662
+ }),
24663
+ [content, editor, uploadImageForSave]
24664
+ );
24395
24665
  useEffect36(() => {
24396
24666
  if (editor && content !== editor.getHTML()) {
24397
24667
  if (editor.isEmpty && content) {
@@ -24439,7 +24709,8 @@ var UEditor = ({
24439
24709
  ]
24440
24710
  }
24441
24711
  );
24442
- };
24712
+ });
24713
+ UEditor.displayName = "UEditor";
24443
24714
  var UEditor_default = UEditor;
24444
24715
 
24445
24716
  // src/index.ts
@@ -24584,6 +24855,7 @@ export {
24584
24855
  Tooltip,
24585
24856
  TranslationProvider,
24586
24857
  UEditor_default as UEditor,
24858
+ UEditorPrepareContentForSaveError,
24587
24859
  UnderverseProvider,
24588
24860
  VARIANT_STYLES_ALERT,
24589
24861
  VARIANT_STYLES_BTN,
@@ -24591,9 +24863,12 @@ export {
24591
24863
  Watermark_default as Watermark,
24592
24864
  cn,
24593
24865
  cn2 as cnLocal,
24866
+ extractImageSrcsFromHtml,
24594
24867
  getAnimationStyles,
24595
24868
  getUnderverseMessages,
24596
24869
  injectAnimationStyles,
24870
+ normalizeImageUrl,
24871
+ prepareUEditorContentForSave,
24597
24872
  shadcnAnimationStyles2 as shadcnAnimationStyles,
24598
24873
  underverseMessages,
24599
24874
  useFormField,