@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.
- package/dist/index.cjs +24 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +24 -1
- package/dist/index.js.map +1 -1
- package/docs/Accordion.md +78 -0
- package/docs/Action.md +76 -0
- package/docs/Autocomplete.md +74 -0
- package/docs/Avatar.md +40 -0
- package/docs/Badge.md +42 -0
- package/docs/Brand.md +44 -0
- package/docs/Breadcrumbs.md +51 -0
- package/docs/Calendar.md +72 -0
- package/docs/Callout.md +46 -0
- package/docs/Canvas.md +102 -0
- package/docs/Card.md +68 -0
- package/docs/Carousel.md +97 -0
- package/docs/Chart.md +126 -0
- package/docs/Checkbox.md +86 -0
- package/docs/ColorPicker.md +49 -0
- package/docs/Command.md +88 -0
- package/docs/Composer.md +60 -0
- package/docs/ContentRenderer.md +68 -0
- package/docs/ContextMenu.md +82 -0
- package/docs/DatePicker.md +64 -0
- package/docs/Diagram.md +119 -0
- package/docs/Dropdown.md +79 -0
- package/docs/Editor.md +84 -0
- package/docs/Emoji.md +40 -0
- package/docs/EmojiSelect.md +47 -0
- package/docs/Field.md +48 -0
- package/docs/FileUpload.md +81 -0
- package/docs/Heading.md +43 -0
- package/docs/Icon.md +75 -0
- package/docs/Input.md +73 -0
- package/docs/Kanban.md +79 -0
- package/docs/Menu.md +71 -0
- package/docs/MobileMenu.md +69 -0
- package/docs/Modal.md +74 -0
- package/docs/MultiSwitch.md +64 -0
- package/docs/Navbar.md +65 -0
- package/docs/OtpInput.md +48 -0
- package/docs/Pagination.md +48 -0
- package/docs/Pillbox.md +53 -0
- package/docs/Popover.md +82 -0
- package/docs/Portal.md +40 -0
- package/docs/Profile.md +52 -0
- package/docs/Progress.md +42 -0
- package/docs/RadioGroup.md +69 -0
- package/docs/Select.md +122 -0
- package/docs/Separator.md +41 -0
- package/docs/Sidebar.md +88 -0
- package/docs/Skeleton.md +44 -0
- package/docs/Slider.md +75 -0
- package/docs/Switch.md +55 -0
- package/docs/Table.md +133 -0
- package/docs/Tabs.md +85 -0
- package/docs/Text.md +44 -0
- package/docs/Textarea.md +62 -0
- package/docs/TimePicker.md +45 -0
- package/docs/Timeline.md +118 -0
- package/docs/Toast.md +79 -0
- package/docs/Tooltip.md +46 -0
- package/docs/hooks.md +180 -0
- package/docs/utilities.md +74 -0
- 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(
|