@particle-academy/react-fancy 1.7.1 → 1.7.3

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.
Files changed (67) hide show
  1. package/dist/index.cjs +24 -1
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.d.cts +2 -0
  4. package/dist/index.d.ts +2 -0
  5. package/dist/index.js +24 -1
  6. package/dist/index.js.map +1 -1
  7. package/docs/Accordion.md +78 -0
  8. package/docs/Action.md +76 -0
  9. package/docs/Autocomplete.md +74 -0
  10. package/docs/Avatar.md +40 -0
  11. package/docs/Badge.md +42 -0
  12. package/docs/Brand.md +44 -0
  13. package/docs/Breadcrumbs.md +51 -0
  14. package/docs/Calendar.md +72 -0
  15. package/docs/Callout.md +46 -0
  16. package/docs/Canvas.md +102 -0
  17. package/docs/Card.md +68 -0
  18. package/docs/Carousel.md +97 -0
  19. package/docs/Chart.md +126 -0
  20. package/docs/Checkbox.md +86 -0
  21. package/docs/ColorPicker.md +49 -0
  22. package/docs/Command.md +88 -0
  23. package/docs/Composer.md +60 -0
  24. package/docs/ContentRenderer.md +68 -0
  25. package/docs/ContextMenu.md +82 -0
  26. package/docs/DatePicker.md +64 -0
  27. package/docs/Diagram.md +119 -0
  28. package/docs/Dropdown.md +79 -0
  29. package/docs/Editor.md +84 -0
  30. package/docs/Emoji.md +40 -0
  31. package/docs/EmojiSelect.md +47 -0
  32. package/docs/Field.md +48 -0
  33. package/docs/FileUpload.md +81 -0
  34. package/docs/Heading.md +43 -0
  35. package/docs/Icon.md +75 -0
  36. package/docs/Input.md +73 -0
  37. package/docs/Kanban.md +79 -0
  38. package/docs/Menu.md +71 -0
  39. package/docs/MobileMenu.md +69 -0
  40. package/docs/Modal.md +74 -0
  41. package/docs/MultiSwitch.md +64 -0
  42. package/docs/Navbar.md +65 -0
  43. package/docs/OtpInput.md +48 -0
  44. package/docs/Pagination.md +48 -0
  45. package/docs/Pillbox.md +53 -0
  46. package/docs/Popover.md +82 -0
  47. package/docs/Portal.md +40 -0
  48. package/docs/Profile.md +52 -0
  49. package/docs/Progress.md +42 -0
  50. package/docs/RadioGroup.md +69 -0
  51. package/docs/Select.md +122 -0
  52. package/docs/Separator.md +41 -0
  53. package/docs/Sidebar.md +88 -0
  54. package/docs/Skeleton.md +44 -0
  55. package/docs/Slider.md +75 -0
  56. package/docs/Switch.md +55 -0
  57. package/docs/Table.md +133 -0
  58. package/docs/Tabs.md +85 -0
  59. package/docs/Text.md +44 -0
  60. package/docs/Textarea.md +62 -0
  61. package/docs/TimePicker.md +45 -0
  62. package/docs/Timeline.md +118 -0
  63. package/docs/Toast.md +79 -0
  64. package/docs/Tooltip.md +46 -0
  65. package/docs/hooks.md +180 -0
  66. package/docs/utilities.md +74 -0
  67. package/package.json +2 -1
package/dist/index.d.cts CHANGED
@@ -1554,6 +1554,8 @@ interface EditorContextValue {
1554
1554
  placeholder?: string;
1555
1555
  /** Merged render extensions (global + instance). */
1556
1556
  extensions: RenderExtension[];
1557
+ /** Initial HTML content to load into the editor on mount */
1558
+ _initialHtml: string;
1557
1559
  /** @internal Called by EditorContent on input events */
1558
1560
  _onInput: () => void;
1559
1561
  }
package/dist/index.d.ts CHANGED
@@ -1554,6 +1554,8 @@ interface EditorContextValue {
1554
1554
  placeholder?: string;
1555
1555
  /** Merged render extensions (global + instance). */
1556
1556
  extensions: RenderExtension[];
1557
+ /** Initial HTML content to load into the editor on mount */
1558
+ _initialHtml: string;
1557
1559
  /** @internal Called by EditorContent on input events */
1558
1560
  _onInput: () => void;
1559
1561
  }
package/dist/index.js CHANGED
@@ -8320,7 +8320,15 @@ function extensionEditorClasses(extensions) {
8320
8320
  }).join(" ");
8321
8321
  }
8322
8322
  function EditorContent({ className }) {
8323
- const { contentRef, lineSpacing, placeholder, extensions, _onInput } = useEditor();
8323
+ const { contentRef, lineSpacing, placeholder, extensions, _initialHtml, _onInput } = useEditor();
8324
+ const initialized = useRef(false);
8325
+ useEffect(() => {
8326
+ const el = contentRef.current;
8327
+ if (el && _initialHtml && !initialized.current) {
8328
+ el.innerHTML = _initialHtml;
8329
+ initialized.current = true;
8330
+ }
8331
+ }, [contentRef, _initialHtml]);
8324
8332
  const extClasses = useMemo(
8325
8333
  () => extensionEditorClasses(extensions),
8326
8334
  [extensions]
@@ -8426,6 +8434,14 @@ function mergeExtensions(instanceExtensions) {
8426
8434
  }
8427
8435
  return merged;
8428
8436
  }
8437
+ function toHtml(value, outputFormat) {
8438
+ if (!value) return "";
8439
+ if (outputFormat === "html") return value;
8440
+ const format = detectFormat(value);
8441
+ if (format === "html") return value;
8442
+ const result = marked.parse(value, { async: false });
8443
+ return result.trim();
8444
+ }
8429
8445
  function EditorRoot({
8430
8446
  children,
8431
8447
  className,
@@ -8439,6 +8455,12 @@ function EditorRoot({
8439
8455
  }) {
8440
8456
  const contentRef = useRef(null);
8441
8457
  const [, setValue] = useControllableState(controlledValue, defaultValue, onChange);
8458
+ const initialHtml = useMemo(
8459
+ () => toHtml(controlledValue ?? defaultValue, outputFormat),
8460
+ // Only compute once on mount — don't re-run when value changes from user input
8461
+ // eslint-disable-next-line react-hooks/exhaustive-deps
8462
+ []
8463
+ );
8442
8464
  const extensions = useMemo(
8443
8465
  () => mergeExtensions(instanceExtensions),
8444
8466
  [instanceExtensions]
@@ -8497,6 +8519,7 @@ function EditorRoot({
8497
8519
  lineSpacing,
8498
8520
  placeholder,
8499
8521
  extensions,
8522
+ _initialHtml: initialHtml,
8500
8523
  _onInput: handleInput
8501
8524
  };
8502
8525
  return /* @__PURE__ */ jsx(EditorContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx(