@lets-events/react 12.10.4 → 12.10.6

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.
@@ -1,6 +1,6 @@
1
1
 
2
2
 
3
- > @lets-events/react@12.10.4 build
3
+ > @lets-events/react@12.10.6 build
4
4
  > tsup src/index.tsx --format esm,cjs --dts --external react
5
5
 
6
6
  CLI Building entry: src/index.tsx
@@ -10,12 +10,12 @@
10
10
  CLI Target: es6
11
11
  ESM Build start
12
12
  CJS Build start
13
- ESM dist/index.mjs 411.50 KB
14
- ESM ⚡️ Build success in 519ms
15
- CJS dist/index.js 427.16 KB
16
- CJS ⚡️ Build success in 521ms
13
+ ESM dist/index.mjs 413.85 KB
14
+ ESM ⚡️ Build success in 498ms
15
+ CJS dist/index.js 429.51 KB
16
+ CJS ⚡️ Build success in 499ms
17
17
  DTS Build start
18
- DTS ⚡️ Build success in 9718ms
19
- DTS dist/index.d.mts 404.99 KB
20
- DTS dist/index.d.ts 404.99 KB
18
+ DTS ⚡️ Build success in 9566ms
19
+ DTS dist/index.d.mts 405.26 KB
20
+ DTS dist/index.d.ts 405.26 KB
21
21
  ⠙
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @lets-events/react
2
2
 
3
+ ## 12.10.6
4
+
5
+ ### Patch Changes
6
+
7
+ - RichEditorFormField props
8
+
9
+ ## 12.10.5
10
+
11
+ ### Patch Changes
12
+
13
+ - rich editor props
14
+
3
15
  ## 12.10.4
4
16
 
5
17
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -15296,6 +15296,8 @@ type EmailFormFieldProps = {
15296
15296
  };
15297
15297
  declare const EmailFormField: ({ name, label, required, placeholder, }: EmailFormFieldProps) => react_jsx_runtime.JSX.Element;
15298
15298
 
15299
+ type RichEditorElement = "header" | "bold" | "italic" | "underline" | "color" | "background" | "align" | "list" | "link" | "image" | "video";
15300
+
15299
15301
  interface UploadConfig$1 {
15300
15302
  apiUrl: string;
15301
15303
  s3Bucket: string;
@@ -15317,6 +15319,7 @@ interface RichEditorProps {
15317
15319
  className?: string;
15318
15320
  uploadConfig?: UploadConfig$1;
15319
15321
  simpleVersion?: boolean;
15322
+ richEditorElements?: RichEditorElement[];
15320
15323
  onCharacterCountChange?: (count: number) => void;
15321
15324
  maxLength?: number;
15322
15325
  disableVideo?: boolean;
@@ -15338,8 +15341,9 @@ type RichEditorFormFieldProps = Omit<RichEditorProps, "value" | "onChange"> & {
15338
15341
  simpleVersion?: boolean;
15339
15342
  uploadConfig?: RichEditorProps["uploadConfig"];
15340
15343
  disableVideo?: boolean;
15344
+ richEditorElements?: RichEditorElement[];
15341
15345
  };
15342
- declare const RichEditorFormField: ({ name, label, required, validate, validationErrorMessage, maxLength, simpleVersion, disableVideo, ...props }: RichEditorFormFieldProps) => react_jsx_runtime.JSX.Element;
15346
+ declare const RichEditorFormField: ({ name, label, required, validate, validationErrorMessage, maxLength, simpleVersion, disableVideo, richEditorElements, ...props }: RichEditorFormFieldProps) => react_jsx_runtime.JSX.Element;
15343
15347
 
15344
15348
  type CalendarFormFieldProps = Omit<CalendarProps, "selected" | "setSelected"> & {
15345
15349
  name: string;
@@ -15447,4 +15451,4 @@ declare const useImageUpload: (options: UseImageUploadOptions) => {
15447
15451
  reset: () => void;
15448
15452
  };
15449
15453
 
15450
- export { AddressFormFields, Alert, AlertDialogCompleteStyled, AlertDialogDescriptionStyled, AlertDialogRowStyled, AlertDialogSimpleStyled, AlertDialogSubtitleStyled, AlertDialogTitleStyled, AlertDialoghrStyled, type AlertProps, Avatar, type AvatarProps, AvatarStyled, Badge, type BadgeProps, BadgeStyled, BirthDateFormField, Box, Button, ButtonGroup, type ButtonGroupProps, ButtonGroupStyled, ButtonItem, type ButtonItemProps, ButtonItemStyled, type ButtonProps, CNPJFormField, CPFFormField, Calendar, CalendarFormField, type CalendarFormFieldProps, type CalendarProps, Card, type CardProps, CardStyled, CheckboxGroup, CheckboxGroupFormField, type CheckboxGroupFormFieldProps, type CheckboxGroupProps, CheckboxGroupStyled, CheckboxItem, type CheckboxItemProps, Container, type ContainerProps, ContainerStyled, CountryFormField, DateAndTimeFormField, type DateAndTimeFormFieldProps, type DateRange, Divider, DoubleCalendar, DoubleCalendarFormField, type DoubleCalendarFormFieldProps, type DoubleCalendarProps, Drawer, type DrawerProps, DropdownMenu, DropdownMenuItem, type DropdownMenuItemProps, type DropdownMenuProps, EmailFormField, type EmailFormFieldProps, ErrorFormMessage, type ErrorFormMessageProps, Filter, FilterItem, type FilterItemProps, type FilterProps, Flex, type FlexProps, FlexStyled, Form, FormLabel, type FormLabelProps, type FormProps, Grid, type GridProps, GridStyled, Icon, type IconProps, IdentityDocumentNumberFormField, InputStyled, MenuDropdown, type MenuDropdownProps, Modal, type ModalProps, MultiSelect, MultiSelectFormField, type MultiSelectFormFieldProps, type MultiSelectProps, PhoneFormField, type PhoneFormFieldProps, RadioGroup, RadioGroupFormField, type RadioGroupFormFieldProps, type RadioGroupProps, RadioGroupStyled, RadioItem, type RadioItemProps, RichEditor, RichEditorFormField, type RichEditorFormFieldProps, type RichEditorProps, RichTextPresenter, Section, type SectionProps, SectionStyled, SelectFormField, type SelectFormFieldProps, Step, StepContent, StepList, type StepProps, StepStyled, StepTrigger, StepWrapper, Switch, SwitchFormField, type SwitchFormFieldProps, type SwitchProps, SwitchStyled, Text, TextAreaFormField, type TextAreaFormFieldProps, TextField, type TextFieldProps, TextFieldSlot, type TextFieldSlotProps, TextFieldSlotStyled, TextFieldStyled, TextFormField, type TextFormFieldProps, type TextProps, TextStyle, TextareaField, type TextareaFieldProps, TextareaFieldStyle, TimePicker, TimePickerButtonStyled, TimePickerDropdownStyled, TimePickerFooterStyled, TimePickerFormField, type TimePickerFormFieldProps, TimePickerIconButton, type TimePickerProps, TimePickerStyled, TimerPickerContentStyled, type Toast, type ToastComponentProps, type ToastConfig, type ToastContextType, ToastItem, type ToastOptions, ToastProvider, type ToastProviderProps, type ToastType, type ToasterShowOptions, ToggleElement, type ToggleElementProps, Tooltip, TooltipContent, type TooltipProps, TooltipProvider, TooltipRoot, TooltipTrigger, type UploadConfig, UploadService, isValidCNPJ, maskFormat, maskUnformat, useImageUpload, useToast };
15454
+ export { AddressFormFields, Alert, AlertDialogCompleteStyled, AlertDialogDescriptionStyled, AlertDialogRowStyled, AlertDialogSimpleStyled, AlertDialogSubtitleStyled, AlertDialogTitleStyled, AlertDialoghrStyled, type AlertProps, Avatar, type AvatarProps, AvatarStyled, Badge, type BadgeProps, BadgeStyled, BirthDateFormField, Box, Button, ButtonGroup, type ButtonGroupProps, ButtonGroupStyled, ButtonItem, type ButtonItemProps, ButtonItemStyled, type ButtonProps, CNPJFormField, CPFFormField, Calendar, CalendarFormField, type CalendarFormFieldProps, type CalendarProps, Card, type CardProps, CardStyled, CheckboxGroup, CheckboxGroupFormField, type CheckboxGroupFormFieldProps, type CheckboxGroupProps, CheckboxGroupStyled, CheckboxItem, type CheckboxItemProps, Container, type ContainerProps, ContainerStyled, CountryFormField, DateAndTimeFormField, type DateAndTimeFormFieldProps, type DateRange, Divider, DoubleCalendar, DoubleCalendarFormField, type DoubleCalendarFormFieldProps, type DoubleCalendarProps, Drawer, type DrawerProps, DropdownMenu, DropdownMenuItem, type DropdownMenuItemProps, type DropdownMenuProps, EmailFormField, type EmailFormFieldProps, ErrorFormMessage, type ErrorFormMessageProps, Filter, FilterItem, type FilterItemProps, type FilterProps, Flex, type FlexProps, FlexStyled, Form, FormLabel, type FormLabelProps, type FormProps, Grid, type GridProps, GridStyled, Icon, type IconProps, IdentityDocumentNumberFormField, InputStyled, MenuDropdown, type MenuDropdownProps, Modal, type ModalProps, MultiSelect, MultiSelectFormField, type MultiSelectFormFieldProps, type MultiSelectProps, PhoneFormField, type PhoneFormFieldProps, RadioGroup, RadioGroupFormField, type RadioGroupFormFieldProps, type RadioGroupProps, RadioGroupStyled, RadioItem, type RadioItemProps, RichEditor, type RichEditorElement, RichEditorFormField, type RichEditorFormFieldProps, type RichEditorProps, RichTextPresenter, Section, type SectionProps, SectionStyled, SelectFormField, type SelectFormFieldProps, Step, StepContent, StepList, type StepProps, StepStyled, StepTrigger, StepWrapper, Switch, SwitchFormField, type SwitchFormFieldProps, type SwitchProps, SwitchStyled, Text, TextAreaFormField, type TextAreaFormFieldProps, TextField, type TextFieldProps, TextFieldSlot, type TextFieldSlotProps, TextFieldSlotStyled, TextFieldStyled, TextFormField, type TextFormFieldProps, type TextProps, TextStyle, TextareaField, type TextareaFieldProps, TextareaFieldStyle, TimePicker, TimePickerButtonStyled, TimePickerDropdownStyled, TimePickerFooterStyled, TimePickerFormField, type TimePickerFormFieldProps, TimePickerIconButton, type TimePickerProps, TimePickerStyled, TimerPickerContentStyled, type Toast, type ToastComponentProps, type ToastConfig, type ToastContextType, ToastItem, type ToastOptions, ToastProvider, type ToastProviderProps, type ToastType, type ToasterShowOptions, ToggleElement, type ToggleElementProps, Tooltip, TooltipContent, type TooltipProps, TooltipProvider, TooltipRoot, TooltipTrigger, type UploadConfig, UploadService, isValidCNPJ, maskFormat, maskUnformat, useImageUpload, useToast };
package/dist/index.d.ts CHANGED
@@ -15296,6 +15296,8 @@ type EmailFormFieldProps = {
15296
15296
  };
15297
15297
  declare const EmailFormField: ({ name, label, required, placeholder, }: EmailFormFieldProps) => react_jsx_runtime.JSX.Element;
15298
15298
 
15299
+ type RichEditorElement = "header" | "bold" | "italic" | "underline" | "color" | "background" | "align" | "list" | "link" | "image" | "video";
15300
+
15299
15301
  interface UploadConfig$1 {
15300
15302
  apiUrl: string;
15301
15303
  s3Bucket: string;
@@ -15317,6 +15319,7 @@ interface RichEditorProps {
15317
15319
  className?: string;
15318
15320
  uploadConfig?: UploadConfig$1;
15319
15321
  simpleVersion?: boolean;
15322
+ richEditorElements?: RichEditorElement[];
15320
15323
  onCharacterCountChange?: (count: number) => void;
15321
15324
  maxLength?: number;
15322
15325
  disableVideo?: boolean;
@@ -15338,8 +15341,9 @@ type RichEditorFormFieldProps = Omit<RichEditorProps, "value" | "onChange"> & {
15338
15341
  simpleVersion?: boolean;
15339
15342
  uploadConfig?: RichEditorProps["uploadConfig"];
15340
15343
  disableVideo?: boolean;
15344
+ richEditorElements?: RichEditorElement[];
15341
15345
  };
15342
- declare const RichEditorFormField: ({ name, label, required, validate, validationErrorMessage, maxLength, simpleVersion, disableVideo, ...props }: RichEditorFormFieldProps) => react_jsx_runtime.JSX.Element;
15346
+ declare const RichEditorFormField: ({ name, label, required, validate, validationErrorMessage, maxLength, simpleVersion, disableVideo, richEditorElements, ...props }: RichEditorFormFieldProps) => react_jsx_runtime.JSX.Element;
15343
15347
 
15344
15348
  type CalendarFormFieldProps = Omit<CalendarProps, "selected" | "setSelected"> & {
15345
15349
  name: string;
@@ -15447,4 +15451,4 @@ declare const useImageUpload: (options: UseImageUploadOptions) => {
15447
15451
  reset: () => void;
15448
15452
  };
15449
15453
 
15450
- export { AddressFormFields, Alert, AlertDialogCompleteStyled, AlertDialogDescriptionStyled, AlertDialogRowStyled, AlertDialogSimpleStyled, AlertDialogSubtitleStyled, AlertDialogTitleStyled, AlertDialoghrStyled, type AlertProps, Avatar, type AvatarProps, AvatarStyled, Badge, type BadgeProps, BadgeStyled, BirthDateFormField, Box, Button, ButtonGroup, type ButtonGroupProps, ButtonGroupStyled, ButtonItem, type ButtonItemProps, ButtonItemStyled, type ButtonProps, CNPJFormField, CPFFormField, Calendar, CalendarFormField, type CalendarFormFieldProps, type CalendarProps, Card, type CardProps, CardStyled, CheckboxGroup, CheckboxGroupFormField, type CheckboxGroupFormFieldProps, type CheckboxGroupProps, CheckboxGroupStyled, CheckboxItem, type CheckboxItemProps, Container, type ContainerProps, ContainerStyled, CountryFormField, DateAndTimeFormField, type DateAndTimeFormFieldProps, type DateRange, Divider, DoubleCalendar, DoubleCalendarFormField, type DoubleCalendarFormFieldProps, type DoubleCalendarProps, Drawer, type DrawerProps, DropdownMenu, DropdownMenuItem, type DropdownMenuItemProps, type DropdownMenuProps, EmailFormField, type EmailFormFieldProps, ErrorFormMessage, type ErrorFormMessageProps, Filter, FilterItem, type FilterItemProps, type FilterProps, Flex, type FlexProps, FlexStyled, Form, FormLabel, type FormLabelProps, type FormProps, Grid, type GridProps, GridStyled, Icon, type IconProps, IdentityDocumentNumberFormField, InputStyled, MenuDropdown, type MenuDropdownProps, Modal, type ModalProps, MultiSelect, MultiSelectFormField, type MultiSelectFormFieldProps, type MultiSelectProps, PhoneFormField, type PhoneFormFieldProps, RadioGroup, RadioGroupFormField, type RadioGroupFormFieldProps, type RadioGroupProps, RadioGroupStyled, RadioItem, type RadioItemProps, RichEditor, RichEditorFormField, type RichEditorFormFieldProps, type RichEditorProps, RichTextPresenter, Section, type SectionProps, SectionStyled, SelectFormField, type SelectFormFieldProps, Step, StepContent, StepList, type StepProps, StepStyled, StepTrigger, StepWrapper, Switch, SwitchFormField, type SwitchFormFieldProps, type SwitchProps, SwitchStyled, Text, TextAreaFormField, type TextAreaFormFieldProps, TextField, type TextFieldProps, TextFieldSlot, type TextFieldSlotProps, TextFieldSlotStyled, TextFieldStyled, TextFormField, type TextFormFieldProps, type TextProps, TextStyle, TextareaField, type TextareaFieldProps, TextareaFieldStyle, TimePicker, TimePickerButtonStyled, TimePickerDropdownStyled, TimePickerFooterStyled, TimePickerFormField, type TimePickerFormFieldProps, TimePickerIconButton, type TimePickerProps, TimePickerStyled, TimerPickerContentStyled, type Toast, type ToastComponentProps, type ToastConfig, type ToastContextType, ToastItem, type ToastOptions, ToastProvider, type ToastProviderProps, type ToastType, type ToasterShowOptions, ToggleElement, type ToggleElementProps, Tooltip, TooltipContent, type TooltipProps, TooltipProvider, TooltipRoot, TooltipTrigger, type UploadConfig, UploadService, isValidCNPJ, maskFormat, maskUnformat, useImageUpload, useToast };
15454
+ export { AddressFormFields, Alert, AlertDialogCompleteStyled, AlertDialogDescriptionStyled, AlertDialogRowStyled, AlertDialogSimpleStyled, AlertDialogSubtitleStyled, AlertDialogTitleStyled, AlertDialoghrStyled, type AlertProps, Avatar, type AvatarProps, AvatarStyled, Badge, type BadgeProps, BadgeStyled, BirthDateFormField, Box, Button, ButtonGroup, type ButtonGroupProps, ButtonGroupStyled, ButtonItem, type ButtonItemProps, ButtonItemStyled, type ButtonProps, CNPJFormField, CPFFormField, Calendar, CalendarFormField, type CalendarFormFieldProps, type CalendarProps, Card, type CardProps, CardStyled, CheckboxGroup, CheckboxGroupFormField, type CheckboxGroupFormFieldProps, type CheckboxGroupProps, CheckboxGroupStyled, CheckboxItem, type CheckboxItemProps, Container, type ContainerProps, ContainerStyled, CountryFormField, DateAndTimeFormField, type DateAndTimeFormFieldProps, type DateRange, Divider, DoubleCalendar, DoubleCalendarFormField, type DoubleCalendarFormFieldProps, type DoubleCalendarProps, Drawer, type DrawerProps, DropdownMenu, DropdownMenuItem, type DropdownMenuItemProps, type DropdownMenuProps, EmailFormField, type EmailFormFieldProps, ErrorFormMessage, type ErrorFormMessageProps, Filter, FilterItem, type FilterItemProps, type FilterProps, Flex, type FlexProps, FlexStyled, Form, FormLabel, type FormLabelProps, type FormProps, Grid, type GridProps, GridStyled, Icon, type IconProps, IdentityDocumentNumberFormField, InputStyled, MenuDropdown, type MenuDropdownProps, Modal, type ModalProps, MultiSelect, MultiSelectFormField, type MultiSelectFormFieldProps, type MultiSelectProps, PhoneFormField, type PhoneFormFieldProps, RadioGroup, RadioGroupFormField, type RadioGroupFormFieldProps, type RadioGroupProps, RadioGroupStyled, RadioItem, type RadioItemProps, RichEditor, type RichEditorElement, RichEditorFormField, type RichEditorFormFieldProps, type RichEditorProps, RichTextPresenter, Section, type SectionProps, SectionStyled, SelectFormField, type SelectFormFieldProps, Step, StepContent, StepList, type StepProps, StepStyled, StepTrigger, StepWrapper, Switch, SwitchFormField, type SwitchFormFieldProps, type SwitchProps, SwitchStyled, Text, TextAreaFormField, type TextAreaFormFieldProps, TextField, type TextFieldProps, TextFieldSlot, type TextFieldSlotProps, TextFieldSlotStyled, TextFieldStyled, TextFormField, type TextFormFieldProps, type TextProps, TextStyle, TextareaField, type TextareaFieldProps, TextareaFieldStyle, TimePicker, TimePickerButtonStyled, TimePickerDropdownStyled, TimePickerFooterStyled, TimePickerFormField, type TimePickerFormFieldProps, TimePickerIconButton, type TimePickerProps, TimePickerStyled, TimerPickerContentStyled, type Toast, type ToastComponentProps, type ToastConfig, type ToastContextType, ToastItem, type ToastOptions, ToastProvider, type ToastProviderProps, type ToastType, type ToasterShowOptions, ToggleElement, type ToggleElementProps, Tooltip, TooltipContent, type TooltipProps, TooltipProvider, TooltipRoot, TooltipTrigger, type UploadConfig, UploadService, isValidCNPJ, maskFormat, maskUnformat, useImageUpload, useToast };
package/dist/index.js CHANGED
@@ -12921,9 +12921,141 @@ var QuillEditor = styled("div", {
12921
12921
  // Container snow
12922
12922
  "& .ql-container.ql-snow": {
12923
12923
  border: "1px solid #ccc"
12924
+ },
12925
+ "& button.ql-list:first-child": {
12926
+ borderLeft: "1px solid #C2C3C7",
12927
+ paddingLeft: "16px",
12928
+ width: "38px"
12924
12929
  }
12925
12930
  });
12926
12931
 
12932
+ // src/components/RichEditor/editorConfig.ts
12933
+ var TEXT_FORMATS = ["bold", "italic", "underline"];
12934
+ var MEDIA_FORMATS = ["link", "image", "video"];
12935
+ var buildToolbarFromElements = (elements) => {
12936
+ const toolbar = [];
12937
+ if (elements.includes("header")) {
12938
+ toolbar.push([{ header: [1, 2, false] }]);
12939
+ }
12940
+ const textGroup = elements.filter(
12941
+ (element) => TEXT_FORMATS.includes(element)
12942
+ );
12943
+ if (textGroup.length > 0) {
12944
+ toolbar.push(textGroup);
12945
+ }
12946
+ const colorGroup = [];
12947
+ if (elements.includes("color")) colorGroup.push({ color: [] });
12948
+ if (elements.includes("background")) colorGroup.push({ background: [] });
12949
+ if (colorGroup.length > 0) {
12950
+ toolbar.push(colorGroup);
12951
+ }
12952
+ if (elements.includes("align")) {
12953
+ toolbar.push([{ align: [] }]);
12954
+ }
12955
+ if (elements.includes("list")) {
12956
+ toolbar.push([{ list: "ordered" }, { list: "bullet" }]);
12957
+ }
12958
+ const mediaGroup = elements.filter(
12959
+ (element) => MEDIA_FORMATS.includes(element)
12960
+ );
12961
+ if (mediaGroup.length > 0) {
12962
+ toolbar.push(mediaGroup);
12963
+ }
12964
+ return toolbar;
12965
+ };
12966
+ var buildFormatsFromElements = (elements) => elements;
12967
+ var getEditorModulesAndFormats = (richEditorElements, simpleVersion = false, disableVideo = false) => {
12968
+ const clipboard = { matchVisual: false };
12969
+ if (richEditorElements && richEditorElements.length > 0) {
12970
+ return {
12971
+ modules: {
12972
+ toolbar: buildToolbarFromElements(richEditorElements),
12973
+ clipboard
12974
+ },
12975
+ formats: buildFormatsFromElements(richEditorElements)
12976
+ };
12977
+ }
12978
+ if (simpleVersion) {
12979
+ return {
12980
+ modules: {
12981
+ toolbar: [
12982
+ [{ header: [1, 2, false] }],
12983
+ ["bold", "italic", "underline"],
12984
+ [{ color: [] }, { background: [] }],
12985
+ [{ align: [] }],
12986
+ [{ list: "ordered" }, { list: "bullet" }]
12987
+ ],
12988
+ clipboard
12989
+ },
12990
+ formats: [
12991
+ "header",
12992
+ "bold",
12993
+ "italic",
12994
+ "underline",
12995
+ "color",
12996
+ "background",
12997
+ "align",
12998
+ "list"
12999
+ ]
13000
+ };
13001
+ }
13002
+ if (disableVideo) {
13003
+ return {
13004
+ modules: {
13005
+ toolbar: [
13006
+ [{ header: [1, 2, false] }],
13007
+ ["bold", "italic", "underline", "strike"],
13008
+ [{ color: [] }, { background: [] }],
13009
+ [{ align: [] }],
13010
+ [{ list: "ordered" }, { list: "bullet" }],
13011
+ ["link", "image"]
13012
+ ],
13013
+ clipboard
13014
+ },
13015
+ formats: [
13016
+ "header",
13017
+ "bold",
13018
+ "italic",
13019
+ "underline",
13020
+ "strike",
13021
+ "color",
13022
+ "background",
13023
+ "align",
13024
+ "list",
13025
+ "link",
13026
+ "image"
13027
+ ]
13028
+ };
13029
+ }
13030
+ return {
13031
+ modules: {
13032
+ toolbar: [
13033
+ [{ header: [1, 2, false] }],
13034
+ ["bold", "italic", "underline", "strike"],
13035
+ [{ color: [] }, { background: [] }],
13036
+ [{ align: [] }],
13037
+ [{ list: "ordered" }, { list: "bullet" }],
13038
+ ["link", "image", "video"]
13039
+ ],
13040
+ clipboard
13041
+ },
13042
+ formats: [
13043
+ "header",
13044
+ "bold",
13045
+ "italic",
13046
+ "underline",
13047
+ "strike",
13048
+ "color",
13049
+ "background",
13050
+ "align",
13051
+ "list",
13052
+ "link",
13053
+ "image",
13054
+ "video"
13055
+ ]
13056
+ };
13057
+ };
13058
+
12927
13059
  // src/components/RichEditor/QuillComponent.tsx
12928
13060
  var import_jsx_runtime53 = require("react/jsx-runtime");
12929
13061
  var QuillComponent = ({
@@ -12935,6 +13067,7 @@ var QuillComponent = ({
12935
13067
  uploadConfig,
12936
13068
  simpleVersion = false,
12937
13069
  disableVideo = false,
13070
+ richEditorElements,
12938
13071
  onCharacterCountChange,
12939
13072
  maxLength
12940
13073
  }) => {
@@ -12950,65 +13083,11 @@ var QuillComponent = ({
12950
13083
  const doc = parser.parseFromString(html, "text/html");
12951
13084
  return doc.body.innerHTML;
12952
13085
  };
12953
- const modules = simpleVersion ? {
12954
- toolbar: [
12955
- [{ header: [1, 2, false] }],
12956
- ["bold", "italic", "underline"],
12957
- [{ color: [] }, { background: [] }],
12958
- [{ align: [] }],
12959
- [{ list: "ordered" }, { list: "bullet" }]
12960
- ],
12961
- clipboard: {
12962
- matchVisual: false
12963
- }
12964
- } : disableVideo ? {
12965
- toolbar: [
12966
- [{ header: [1, 2, false] }],
12967
- ["bold", "italic", "underline", "strike"],
12968
- [{ color: [] }, { background: [] }],
12969
- [{ align: [] }],
12970
- [{ list: "ordered" }, { list: "bullet" }],
12971
- ["link", "image"]
12972
- ],
12973
- clipboard: {
12974
- matchVisual: false
12975
- }
12976
- } : {
12977
- toolbar: [
12978
- [{ header: [1, 2, false] }],
12979
- ["bold", "italic", "underline", "strike"],
12980
- [{ color: [] }, { background: [] }],
12981
- [{ align: [] }],
12982
- [{ list: "ordered" }, { list: "bullet" }],
12983
- ["link", "image", "video"]
12984
- ],
12985
- clipboard: {
12986
- matchVisual: false
12987
- }
12988
- };
12989
- const formats = simpleVersion ? [
12990
- "header",
12991
- "bold",
12992
- "italic",
12993
- "underline",
12994
- "color",
12995
- "background",
12996
- "align",
12997
- "list"
12998
- ] : [
12999
- "header",
13000
- "bold",
13001
- "italic",
13002
- "underline",
13003
- "strike",
13004
- "color",
13005
- "background",
13006
- "align",
13007
- "list",
13008
- "link",
13009
- "image",
13010
- "video"
13011
- ];
13086
+ const { modules, formats } = getEditorModulesAndFormats(
13087
+ richEditorElements,
13088
+ simpleVersion,
13089
+ disableVideo
13090
+ );
13012
13091
  const { quill, quillRef } = (0, import_react_quilljs.useQuill)({
13013
13092
  theme: "snow",
13014
13093
  modules,
@@ -13078,21 +13157,27 @@ var QuillComponent = ({
13078
13157
  });
13079
13158
  const toolbar = quill.getModule("toolbar");
13080
13159
  if (toolbar) {
13081
- toolbar.addHandler("link", () => setShowLinkModal(true));
13082
- toolbar.addHandler("video", () => setShowVideoModal(true));
13083
- toolbar.addHandler("image", () => {
13084
- const input = document.createElement("input");
13085
- input.setAttribute("type", "file");
13086
- input.setAttribute("accept", "image/*");
13087
- input.click();
13088
- input.onchange = () => __async(null, null, function* () {
13089
- var _a;
13090
- const file = (_a = input.files) == null ? void 0 : _a[0];
13091
- if (file) {
13092
- yield handleImageUpload(file);
13093
- }
13160
+ if (formats.includes("link")) {
13161
+ toolbar.addHandler("link", () => setShowLinkModal(true));
13162
+ }
13163
+ if (formats.includes("video")) {
13164
+ toolbar.addHandler("video", () => setShowVideoModal(true));
13165
+ }
13166
+ if (formats.includes("image")) {
13167
+ toolbar.addHandler("image", () => {
13168
+ const input = document.createElement("input");
13169
+ input.setAttribute("type", "file");
13170
+ input.setAttribute("accept", "image/*");
13171
+ input.click();
13172
+ input.onchange = () => __async(null, null, function* () {
13173
+ var _a;
13174
+ const file = (_a = input.files) == null ? void 0 : _a[0];
13175
+ if (file) {
13176
+ yield handleImageUpload(file);
13177
+ }
13178
+ });
13094
13179
  });
13095
- });
13180
+ }
13096
13181
  }
13097
13182
  setTimeout(() => {
13098
13183
  var _a, _b;
@@ -13116,7 +13201,7 @@ var QuillComponent = ({
13116
13201
  }
13117
13202
  }, 2e3);
13118
13203
  }
13119
- }, [quill, onChange, handleImageUpload, onCharacterCountChange]);
13204
+ }, [quill, onChange, handleImageUpload, onCharacterCountChange, formats]);
13120
13205
  (0, import_react23.useEffect)(() => {
13121
13206
  if (quill) {
13122
13207
  quill.enable(!disabled);
@@ -13380,7 +13465,8 @@ var RichEditorFormField = (_a) => {
13380
13465
  validationErrorMessage = "Este campo \xE9 obrigat\xF3rio.",
13381
13466
  maxLength,
13382
13467
  simpleVersion = false,
13383
- disableVideo = false
13468
+ disableVideo = false,
13469
+ richEditorElements
13384
13470
  } = _b, props = __objRest(_b, [
13385
13471
  "name",
13386
13472
  "label",
@@ -13389,7 +13475,8 @@ var RichEditorFormField = (_a) => {
13389
13475
  "validationErrorMessage",
13390
13476
  "maxLength",
13391
13477
  "simpleVersion",
13392
- "disableVideo"
13478
+ "disableVideo",
13479
+ "richEditorElements"
13393
13480
  ]);
13394
13481
  const { field, fieldState } = (0, import_react_hook_form12.useController)({
13395
13482
  name,
@@ -13443,7 +13530,8 @@ var RichEditorFormField = (_a) => {
13443
13530
  onCharacterCountChange: handleCharacterCountChange,
13444
13531
  maxLength,
13445
13532
  disableVideo,
13446
- simpleVersion
13533
+ simpleVersion,
13534
+ richEditorElements
13447
13535
  })
13448
13536
  ),
13449
13537
  /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(ErrorFormMessage, { message: errorMsg })
package/dist/index.mjs CHANGED
@@ -12813,9 +12813,141 @@ var QuillEditor = styled("div", {
12813
12813
  // Container snow
12814
12814
  "& .ql-container.ql-snow": {
12815
12815
  border: "1px solid #ccc"
12816
+ },
12817
+ "& button.ql-list:first-child": {
12818
+ borderLeft: "1px solid #C2C3C7",
12819
+ paddingLeft: "16px",
12820
+ width: "38px"
12816
12821
  }
12817
12822
  });
12818
12823
 
12824
+ // src/components/RichEditor/editorConfig.ts
12825
+ var TEXT_FORMATS = ["bold", "italic", "underline"];
12826
+ var MEDIA_FORMATS = ["link", "image", "video"];
12827
+ var buildToolbarFromElements = (elements) => {
12828
+ const toolbar = [];
12829
+ if (elements.includes("header")) {
12830
+ toolbar.push([{ header: [1, 2, false] }]);
12831
+ }
12832
+ const textGroup = elements.filter(
12833
+ (element) => TEXT_FORMATS.includes(element)
12834
+ );
12835
+ if (textGroup.length > 0) {
12836
+ toolbar.push(textGroup);
12837
+ }
12838
+ const colorGroup = [];
12839
+ if (elements.includes("color")) colorGroup.push({ color: [] });
12840
+ if (elements.includes("background")) colorGroup.push({ background: [] });
12841
+ if (colorGroup.length > 0) {
12842
+ toolbar.push(colorGroup);
12843
+ }
12844
+ if (elements.includes("align")) {
12845
+ toolbar.push([{ align: [] }]);
12846
+ }
12847
+ if (elements.includes("list")) {
12848
+ toolbar.push([{ list: "ordered" }, { list: "bullet" }]);
12849
+ }
12850
+ const mediaGroup = elements.filter(
12851
+ (element) => MEDIA_FORMATS.includes(element)
12852
+ );
12853
+ if (mediaGroup.length > 0) {
12854
+ toolbar.push(mediaGroup);
12855
+ }
12856
+ return toolbar;
12857
+ };
12858
+ var buildFormatsFromElements = (elements) => elements;
12859
+ var getEditorModulesAndFormats = (richEditorElements, simpleVersion = false, disableVideo = false) => {
12860
+ const clipboard = { matchVisual: false };
12861
+ if (richEditorElements && richEditorElements.length > 0) {
12862
+ return {
12863
+ modules: {
12864
+ toolbar: buildToolbarFromElements(richEditorElements),
12865
+ clipboard
12866
+ },
12867
+ formats: buildFormatsFromElements(richEditorElements)
12868
+ };
12869
+ }
12870
+ if (simpleVersion) {
12871
+ return {
12872
+ modules: {
12873
+ toolbar: [
12874
+ [{ header: [1, 2, false] }],
12875
+ ["bold", "italic", "underline"],
12876
+ [{ color: [] }, { background: [] }],
12877
+ [{ align: [] }],
12878
+ [{ list: "ordered" }, { list: "bullet" }]
12879
+ ],
12880
+ clipboard
12881
+ },
12882
+ formats: [
12883
+ "header",
12884
+ "bold",
12885
+ "italic",
12886
+ "underline",
12887
+ "color",
12888
+ "background",
12889
+ "align",
12890
+ "list"
12891
+ ]
12892
+ };
12893
+ }
12894
+ if (disableVideo) {
12895
+ return {
12896
+ modules: {
12897
+ toolbar: [
12898
+ [{ header: [1, 2, false] }],
12899
+ ["bold", "italic", "underline", "strike"],
12900
+ [{ color: [] }, { background: [] }],
12901
+ [{ align: [] }],
12902
+ [{ list: "ordered" }, { list: "bullet" }],
12903
+ ["link", "image"]
12904
+ ],
12905
+ clipboard
12906
+ },
12907
+ formats: [
12908
+ "header",
12909
+ "bold",
12910
+ "italic",
12911
+ "underline",
12912
+ "strike",
12913
+ "color",
12914
+ "background",
12915
+ "align",
12916
+ "list",
12917
+ "link",
12918
+ "image"
12919
+ ]
12920
+ };
12921
+ }
12922
+ return {
12923
+ modules: {
12924
+ toolbar: [
12925
+ [{ header: [1, 2, false] }],
12926
+ ["bold", "italic", "underline", "strike"],
12927
+ [{ color: [] }, { background: [] }],
12928
+ [{ align: [] }],
12929
+ [{ list: "ordered" }, { list: "bullet" }],
12930
+ ["link", "image", "video"]
12931
+ ],
12932
+ clipboard
12933
+ },
12934
+ formats: [
12935
+ "header",
12936
+ "bold",
12937
+ "italic",
12938
+ "underline",
12939
+ "strike",
12940
+ "color",
12941
+ "background",
12942
+ "align",
12943
+ "list",
12944
+ "link",
12945
+ "image",
12946
+ "video"
12947
+ ]
12948
+ };
12949
+ };
12950
+
12819
12951
  // src/components/RichEditor/QuillComponent.tsx
12820
12952
  import { jsx as jsx53, jsxs as jsxs29 } from "react/jsx-runtime";
12821
12953
  var QuillComponent = ({
@@ -12827,6 +12959,7 @@ var QuillComponent = ({
12827
12959
  uploadConfig,
12828
12960
  simpleVersion = false,
12829
12961
  disableVideo = false,
12962
+ richEditorElements,
12830
12963
  onCharacterCountChange,
12831
12964
  maxLength
12832
12965
  }) => {
@@ -12842,65 +12975,11 @@ var QuillComponent = ({
12842
12975
  const doc = parser.parseFromString(html, "text/html");
12843
12976
  return doc.body.innerHTML;
12844
12977
  };
12845
- const modules = simpleVersion ? {
12846
- toolbar: [
12847
- [{ header: [1, 2, false] }],
12848
- ["bold", "italic", "underline"],
12849
- [{ color: [] }, { background: [] }],
12850
- [{ align: [] }],
12851
- [{ list: "ordered" }, { list: "bullet" }]
12852
- ],
12853
- clipboard: {
12854
- matchVisual: false
12855
- }
12856
- } : disableVideo ? {
12857
- toolbar: [
12858
- [{ header: [1, 2, false] }],
12859
- ["bold", "italic", "underline", "strike"],
12860
- [{ color: [] }, { background: [] }],
12861
- [{ align: [] }],
12862
- [{ list: "ordered" }, { list: "bullet" }],
12863
- ["link", "image"]
12864
- ],
12865
- clipboard: {
12866
- matchVisual: false
12867
- }
12868
- } : {
12869
- toolbar: [
12870
- [{ header: [1, 2, false] }],
12871
- ["bold", "italic", "underline", "strike"],
12872
- [{ color: [] }, { background: [] }],
12873
- [{ align: [] }],
12874
- [{ list: "ordered" }, { list: "bullet" }],
12875
- ["link", "image", "video"]
12876
- ],
12877
- clipboard: {
12878
- matchVisual: false
12879
- }
12880
- };
12881
- const formats = simpleVersion ? [
12882
- "header",
12883
- "bold",
12884
- "italic",
12885
- "underline",
12886
- "color",
12887
- "background",
12888
- "align",
12889
- "list"
12890
- ] : [
12891
- "header",
12892
- "bold",
12893
- "italic",
12894
- "underline",
12895
- "strike",
12896
- "color",
12897
- "background",
12898
- "align",
12899
- "list",
12900
- "link",
12901
- "image",
12902
- "video"
12903
- ];
12978
+ const { modules, formats } = getEditorModulesAndFormats(
12979
+ richEditorElements,
12980
+ simpleVersion,
12981
+ disableVideo
12982
+ );
12904
12983
  const { quill, quillRef } = useQuill({
12905
12984
  theme: "snow",
12906
12985
  modules,
@@ -12970,21 +13049,27 @@ var QuillComponent = ({
12970
13049
  });
12971
13050
  const toolbar = quill.getModule("toolbar");
12972
13051
  if (toolbar) {
12973
- toolbar.addHandler("link", () => setShowLinkModal(true));
12974
- toolbar.addHandler("video", () => setShowVideoModal(true));
12975
- toolbar.addHandler("image", () => {
12976
- const input = document.createElement("input");
12977
- input.setAttribute("type", "file");
12978
- input.setAttribute("accept", "image/*");
12979
- input.click();
12980
- input.onchange = () => __async(null, null, function* () {
12981
- var _a;
12982
- const file = (_a = input.files) == null ? void 0 : _a[0];
12983
- if (file) {
12984
- yield handleImageUpload(file);
12985
- }
13052
+ if (formats.includes("link")) {
13053
+ toolbar.addHandler("link", () => setShowLinkModal(true));
13054
+ }
13055
+ if (formats.includes("video")) {
13056
+ toolbar.addHandler("video", () => setShowVideoModal(true));
13057
+ }
13058
+ if (formats.includes("image")) {
13059
+ toolbar.addHandler("image", () => {
13060
+ const input = document.createElement("input");
13061
+ input.setAttribute("type", "file");
13062
+ input.setAttribute("accept", "image/*");
13063
+ input.click();
13064
+ input.onchange = () => __async(null, null, function* () {
13065
+ var _a;
13066
+ const file = (_a = input.files) == null ? void 0 : _a[0];
13067
+ if (file) {
13068
+ yield handleImageUpload(file);
13069
+ }
13070
+ });
12986
13071
  });
12987
- });
13072
+ }
12988
13073
  }
12989
13074
  setTimeout(() => {
12990
13075
  var _a, _b;
@@ -13008,7 +13093,7 @@ var QuillComponent = ({
13008
13093
  }
13009
13094
  }, 2e3);
13010
13095
  }
13011
- }, [quill, onChange, handleImageUpload, onCharacterCountChange]);
13096
+ }, [quill, onChange, handleImageUpload, onCharacterCountChange, formats]);
13012
13097
  useEffect9(() => {
13013
13098
  if (quill) {
13014
13099
  quill.enable(!disabled);
@@ -13272,7 +13357,8 @@ var RichEditorFormField = (_a) => {
13272
13357
  validationErrorMessage = "Este campo \xE9 obrigat\xF3rio.",
13273
13358
  maxLength,
13274
13359
  simpleVersion = false,
13275
- disableVideo = false
13360
+ disableVideo = false,
13361
+ richEditorElements
13276
13362
  } = _b, props = __objRest(_b, [
13277
13363
  "name",
13278
13364
  "label",
@@ -13281,7 +13367,8 @@ var RichEditorFormField = (_a) => {
13281
13367
  "validationErrorMessage",
13282
13368
  "maxLength",
13283
13369
  "simpleVersion",
13284
- "disableVideo"
13370
+ "disableVideo",
13371
+ "richEditorElements"
13285
13372
  ]);
13286
13373
  const { field, fieldState } = useController3({
13287
13374
  name,
@@ -13335,7 +13422,8 @@ var RichEditorFormField = (_a) => {
13335
13422
  onCharacterCountChange: handleCharacterCountChange,
13336
13423
  maxLength,
13337
13424
  disableVideo,
13338
- simpleVersion
13425
+ simpleVersion,
13426
+ richEditorElements
13339
13427
  })
13340
13428
  ),
13341
13429
  /* @__PURE__ */ jsx56(ErrorFormMessage, { message: errorMsg })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lets-events/react",
3
- "version": "12.10.4",
3
+ "version": "12.10.6",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -5,7 +5,7 @@ import { ErrorFormMessage } from "./subComponents/ErrorFormMessage";
5
5
  import { RichEditor, RichEditorProps } from "../RichEditor";
6
6
  import { useState } from "react";
7
7
  import { Badge } from "../Badge";
8
-
8
+ import { RichEditorElement } from "../RichEditor/types";
9
9
  export type RichEditorFormFieldProps = Omit<
10
10
  RichEditorProps,
11
11
  "value" | "onChange"
@@ -19,6 +19,7 @@ export type RichEditorFormFieldProps = Omit<
19
19
  simpleVersion?: boolean;
20
20
  uploadConfig?: RichEditorProps["uploadConfig"];
21
21
  disableVideo?: boolean
22
+ richEditorElements?: RichEditorElement[];
22
23
  };
23
24
 
24
25
  export const RichEditorFormField = ({
@@ -30,6 +31,7 @@ export const RichEditorFormField = ({
30
31
  maxLength,
31
32
  simpleVersion = false,
32
33
  disableVideo = false,
34
+ richEditorElements,
33
35
  ...props
34
36
  }: RichEditorFormFieldProps) => {
35
37
  const { field, fieldState } = useController({
@@ -96,6 +98,7 @@ export const RichEditorFormField = ({
96
98
  maxLength={maxLength}
97
99
  disableVideo={disableVideo}
98
100
  simpleVersion={simpleVersion}
101
+ richEditorElements={richEditorElements}
99
102
  />
100
103
  <ErrorFormMessage message={errorMsg} />
101
104
  </Flex>
@@ -6,6 +6,7 @@ import { RichEditorProps } from "./RichEditor";
6
6
  import { useToast } from "../Toast/hooks/useToast";
7
7
  import { UploadService } from "../../utils/uploadService";
8
8
  import { QuillContainer, QuillEditor } from "./styledComponents";
9
+ import { getEditorModulesAndFormats } from "./editorConfig";
9
10
 
10
11
  const QuillComponent: React.FC<RichEditorProps> = ({
11
12
  value = "",
@@ -16,6 +17,7 @@ const QuillComponent: React.FC<RichEditorProps> = ({
16
17
  uploadConfig,
17
18
  simpleVersion = false,
18
19
  disableVideo = false,
20
+ richEditorElements,
19
21
  onCharacterCountChange,
20
22
  maxLength,
21
23
  }) => {
@@ -33,72 +35,11 @@ const QuillComponent: React.FC<RichEditorProps> = ({
33
35
 
34
36
  return doc.body.innerHTML;
35
37
  };
36
- const modules = simpleVersion
37
- ? {
38
- toolbar: [
39
- [{ header: [1, 2, false] }],
40
- ["bold", "italic", "underline"],
41
- [{ color: [] }, { background: [] }],
42
- [{ align: [] }],
43
- [{ list: "ordered" }, { list: "bullet" }],
44
- ],
45
- clipboard: {
46
- matchVisual: false,
47
- },
48
- }
49
- : disableVideo
50
- ? {
51
- toolbar: [
52
- [{ header: [1, 2, false] }],
53
- ["bold", "italic", "underline", "strike"],
54
- [{ color: [] }, { background: [] }],
55
- [{ align: [] }],
56
- [{ list: "ordered" }, { list: "bullet" }],
57
- ["link", "image"],
58
- ],
59
- clipboard: {
60
- matchVisual: false,
61
- },
62
- }
63
- : {
64
- toolbar: [
65
- [{ header: [1, 2, false] }],
66
- ["bold", "italic", "underline", "strike"],
67
- [{ color: [] }, { background: [] }],
68
- [{ align: [] }],
69
- [{ list: "ordered" }, { list: "bullet" }],
70
- ["link", "image", "video"],
71
- ],
72
- clipboard: {
73
- matchVisual: false,
74
- },
75
- };
76
-
77
- const formats = simpleVersion
78
- ? [
79
- "header",
80
- "bold",
81
- "italic",
82
- "underline",
83
- "color",
84
- "background",
85
- "align",
86
- "list",
87
- ]
88
- : [
89
- "header",
90
- "bold",
91
- "italic",
92
- "underline",
93
- "strike",
94
- "color",
95
- "background",
96
- "align",
97
- "list",
98
- "link",
99
- "image",
100
- "video",
101
- ];
38
+ const { modules, formats } = getEditorModulesAndFormats(
39
+ richEditorElements,
40
+ simpleVersion,
41
+ disableVideo,
42
+ );
102
43
 
103
44
  const { quill, quillRef } = useQuill({
104
45
  theme: "snow",
@@ -182,21 +123,27 @@ const QuillComponent: React.FC<RichEditorProps> = ({
182
123
 
183
124
  const toolbar = quill.getModule("toolbar") as any;
184
125
  if (toolbar) {
185
- toolbar.addHandler("link", () => setShowLinkModal(true));
186
- toolbar.addHandler("video", () => setShowVideoModal(true));
187
- toolbar.addHandler("image", () => {
188
- const input = document.createElement("input");
189
- input.setAttribute("type", "file");
190
- input.setAttribute("accept", "image/*");
191
- input.click();
192
-
193
- input.onchange = async () => {
194
- const file = input.files?.[0];
195
- if (file) {
196
- await handleImageUpload(file);
197
- }
198
- };
199
- });
126
+ if (formats.includes("link")) {
127
+ toolbar.addHandler("link", () => setShowLinkModal(true));
128
+ }
129
+ if (formats.includes("video")) {
130
+ toolbar.addHandler("video", () => setShowVideoModal(true));
131
+ }
132
+ if (formats.includes("image")) {
133
+ toolbar.addHandler("image", () => {
134
+ const input = document.createElement("input");
135
+ input.setAttribute("type", "file");
136
+ input.setAttribute("accept", "image/*");
137
+ input.click();
138
+
139
+ input.onchange = async () => {
140
+ const file = input.files?.[0];
141
+ if (file) {
142
+ await handleImageUpload(file);
143
+ }
144
+ };
145
+ });
146
+ }
200
147
  }
201
148
 
202
149
  setTimeout(() => {
@@ -221,7 +168,7 @@ const QuillComponent: React.FC<RichEditorProps> = ({
221
168
  }
222
169
  }, 2000);
223
170
  }
224
- }, [quill, onChange, handleImageUpload, onCharacterCountChange]);
171
+ }, [quill, onChange, handleImageUpload, onCharacterCountChange, formats]);
225
172
 
226
173
  useEffect(() => {
227
174
  if (quill) {
@@ -1,6 +1,9 @@
1
1
  import { useEffect, useState } from "react";
2
2
  import { ToastProvider } from "../Toast";
3
3
  import QuillComponent from "./QuillComponent";
4
+ import { RichEditorElement } from "./types";
5
+
6
+ export type { RichEditorElement };
4
7
 
5
8
  export interface UploadConfig {
6
9
  apiUrl: string;
@@ -24,9 +27,10 @@ export interface RichEditorProps {
24
27
  className?: string;
25
28
  uploadConfig?: UploadConfig;
26
29
  simpleVersion?: boolean;
30
+ richEditorElements?: RichEditorElement[];
27
31
  onCharacterCountChange?: (count: number) => void;
28
32
  maxLength?: number;
29
- disableVideo?: boolean
33
+ disableVideo?: boolean;
30
34
  }
31
35
 
32
36
  const RichEditor = (props: RichEditorProps) => {
@@ -0,0 +1,149 @@
1
+ import { RichEditorElement } from "./types";
2
+
3
+ const TEXT_FORMATS: RichEditorElement[] = ["bold", "italic", "underline"];
4
+ const MEDIA_FORMATS: RichEditorElement[] = ["link", "image", "video"];
5
+
6
+ export const buildToolbarFromElements = (
7
+ elements: RichEditorElement[],
8
+ ): unknown[] => {
9
+ const toolbar: unknown[] = [];
10
+
11
+ if (elements.includes("header")) {
12
+ toolbar.push([{ header: [1, 2, false] }]);
13
+ }
14
+
15
+ const textGroup = elements.filter((element) =>
16
+ TEXT_FORMATS.includes(element),
17
+ );
18
+ if (textGroup.length > 0) {
19
+ toolbar.push(textGroup);
20
+ }
21
+
22
+ const colorGroup: unknown[] = [];
23
+ if (elements.includes("color")) colorGroup.push({ color: [] });
24
+ if (elements.includes("background")) colorGroup.push({ background: [] });
25
+ if (colorGroup.length > 0) {
26
+ toolbar.push(colorGroup);
27
+ }
28
+
29
+ if (elements.includes("align")) {
30
+ toolbar.push([{ align: [] }]);
31
+ }
32
+
33
+ if (elements.includes("list")) {
34
+ toolbar.push([{ list: "ordered" }, { list: "bullet" }]);
35
+ }
36
+
37
+ const mediaGroup = elements.filter((element) =>
38
+ MEDIA_FORMATS.includes(element),
39
+ );
40
+ if (mediaGroup.length > 0) {
41
+ toolbar.push(mediaGroup);
42
+ }
43
+
44
+ return toolbar;
45
+ };
46
+
47
+ export const buildFormatsFromElements = (
48
+ elements: RichEditorElement[],
49
+ ): string[] => elements;
50
+
51
+ export const getEditorModulesAndFormats = (
52
+ richEditorElements?: RichEditorElement[],
53
+ simpleVersion = false,
54
+ disableVideo = false,
55
+ ): { modules: Record<string, unknown>; formats: string[] } => {
56
+ const clipboard = { matchVisual: false };
57
+
58
+ if (richEditorElements && richEditorElements.length > 0) {
59
+ return {
60
+ modules: {
61
+ toolbar: buildToolbarFromElements(richEditorElements),
62
+ clipboard,
63
+ },
64
+ formats: buildFormatsFromElements(richEditorElements),
65
+ };
66
+ }
67
+
68
+ if (simpleVersion) {
69
+ return {
70
+ modules: {
71
+ toolbar: [
72
+ [{ header: [1, 2, false] }],
73
+ ["bold", "italic", "underline"],
74
+ [{ color: [] }, { background: [] }],
75
+ [{ align: [] }],
76
+ [{ list: "ordered" }, { list: "bullet" }],
77
+ ],
78
+ clipboard,
79
+ },
80
+ formats: [
81
+ "header",
82
+ "bold",
83
+ "italic",
84
+ "underline",
85
+ "color",
86
+ "background",
87
+ "align",
88
+ "list",
89
+ ],
90
+ };
91
+ }
92
+
93
+ if (disableVideo) {
94
+ return {
95
+ modules: {
96
+ toolbar: [
97
+ [{ header: [1, 2, false] }],
98
+ ["bold", "italic", "underline", "strike"],
99
+ [{ color: [] }, { background: [] }],
100
+ [{ align: [] }],
101
+ [{ list: "ordered" }, { list: "bullet" }],
102
+ ["link", "image"],
103
+ ],
104
+ clipboard,
105
+ },
106
+ formats: [
107
+ "header",
108
+ "bold",
109
+ "italic",
110
+ "underline",
111
+ "strike",
112
+ "color",
113
+ "background",
114
+ "align",
115
+ "list",
116
+ "link",
117
+ "image",
118
+ ],
119
+ };
120
+ }
121
+
122
+ return {
123
+ modules: {
124
+ toolbar: [
125
+ [{ header: [1, 2, false] }],
126
+ ["bold", "italic", "underline", "strike"],
127
+ [{ color: [] }, { background: [] }],
128
+ [{ align: [] }],
129
+ [{ list: "ordered" }, { list: "bullet" }],
130
+ ["link", "image", "video"],
131
+ ],
132
+ clipboard,
133
+ },
134
+ formats: [
135
+ "header",
136
+ "bold",
137
+ "italic",
138
+ "underline",
139
+ "strike",
140
+ "color",
141
+ "background",
142
+ "align",
143
+ "list",
144
+ "link",
145
+ "image",
146
+ "video",
147
+ ],
148
+ };
149
+ };
@@ -1,3 +1,3 @@
1
1
  export { default as RichEditor } from "./RichEditor";
2
- export type { RichEditorProps } from "./RichEditor";
2
+ export type { RichEditorProps, RichEditorElement } from "./RichEditor";
3
3
  export { default as RichTextPresenter } from "./RichTextPresenter";
@@ -1167,4 +1167,9 @@ export const QuillEditor = styled("div", {
1167
1167
  "& .ql-container.ql-snow": {
1168
1168
  border: "1px solid #ccc",
1169
1169
  },
1170
+ "& button.ql-list:first-child": {
1171
+ borderLeft:"1px solid #C2C3C7",
1172
+ paddingLeft: "16px",
1173
+ width: "38px",
1174
+ }
1170
1175
  });
@@ -0,0 +1,12 @@
1
+ export type RichEditorElement =
2
+ | "header"
3
+ | "bold"
4
+ | "italic"
5
+ | "underline"
6
+ | "color"
7
+ | "background"
8
+ | "align"
9
+ | "list"
10
+ | "link"
11
+ | "image"
12
+ | "video";