react-markdown-typewriter 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -6
- package/dist/components/MarkdownTypewriter.js +1 -1
- package/dist/components/MarkdownTypewriter.mjs +1 -1
- package/dist/components/TypewriterItem.d.mts +4 -4
- package/dist/components/TypewriterItem.d.ts +4 -4
- package/dist/components/TypewriterItem.js +1 -1
- package/dist/components/TypewriterItem.mjs +1 -1
- package/dist/components/index.js +1 -1
- package/dist/components/index.mjs +1 -1
- package/dist/functions/markdownComponents.d.mts +4 -3
- package/dist/functions/markdownComponents.d.ts +4 -3
- package/dist/functions/markdownComponents.js +1 -1
- package/dist/functions/markdownComponents.mjs +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/interfaces/MarkdownTypewriterProps.d.mts +43 -26
- package/dist/interfaces/MarkdownTypewriterProps.d.ts +43 -26
- package/package.json +1 -1
|
@@ -2,7 +2,7 @@ import { HTMLMotionProps, Variants } from 'motion/react';
|
|
|
2
2
|
import { RefObject } from 'react';
|
|
3
3
|
import { Options } from 'react-markdown';
|
|
4
4
|
|
|
5
|
-
interface MarkdownTypewriterProps extends
|
|
5
|
+
interface MarkdownTypewriterProps extends Options {
|
|
6
6
|
/**
|
|
7
7
|
* The delay in milliseconds between the appearance of one letter and the next.
|
|
8
8
|
* @default 10
|
|
@@ -11,7 +11,7 @@ interface MarkdownTypewriterProps extends Omit<Options, "components"> {
|
|
|
11
11
|
/**
|
|
12
12
|
* The props to pass to the [motion span](https://motion.dev/docs/react-motion-component).
|
|
13
13
|
*
|
|
14
|
-
* The `
|
|
14
|
+
* The `characterVariants` parameter has been added to be able to modify the animation of each individual letter
|
|
15
15
|
*/
|
|
16
16
|
motionProps?: Omit<HTMLMotionProps<"span">, "variants"> & {
|
|
17
17
|
/**
|
|
@@ -19,31 +19,48 @@ interface MarkdownTypewriterProps extends Omit<Options, "components"> {
|
|
|
19
19
|
*
|
|
20
20
|
* @default { hidden: { opacity: 0 }, visible: { opacity: 1, transition: { opacity: { duration: 0 } } } }
|
|
21
21
|
*/
|
|
22
|
-
|
|
22
|
+
characterVariants?: Variants;
|
|
23
|
+
/**
|
|
24
|
+
* A callback that is called when the animation of a letter is complete.
|
|
25
|
+
* The callback is called with the reference to the letter.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```tsx
|
|
29
|
+
* import { useRef } from "react";
|
|
30
|
+
*
|
|
31
|
+
* export default function NarrationScreen() {
|
|
32
|
+
* const paragraphRef = useRef<HTMLDivElement>(null);
|
|
33
|
+
* const scrollToEnd = useCallback((ref: { current: HTMLSpanElement | null }) => {
|
|
34
|
+
* if (paragraphRef.current && ref.current) {
|
|
35
|
+
* let scrollTop = ref.current.offsetTop - paragraphRef.current.clientHeight / 2;
|
|
36
|
+
* paragraphRef.current.scrollTo({
|
|
37
|
+
* top: scrollTop,
|
|
38
|
+
* behavior: "auto",
|
|
39
|
+
* });
|
|
40
|
+
* }
|
|
41
|
+
* }, []);
|
|
42
|
+
* return (
|
|
43
|
+
* <div
|
|
44
|
+
* ref={paragraphRef}
|
|
45
|
+
* style={{
|
|
46
|
+
* overflow: "auto",
|
|
47
|
+
* height: "300px",
|
|
48
|
+
* }}
|
|
49
|
+
* >
|
|
50
|
+
* <MarkdownTypewriter
|
|
51
|
+
* motionProps={{
|
|
52
|
+
* onCharacterAnimationComplete: scrollToEnd,
|
|
53
|
+
* }}
|
|
54
|
+
* >
|
|
55
|
+
* Hello World
|
|
56
|
+
* </MarkdownTypewriter>
|
|
57
|
+
* </div>
|
|
58
|
+
* );
|
|
59
|
+
* }
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
onCharacterAnimationComplete?: (letterRef: RefObject<HTMLSpanElement | null>) => void;
|
|
23
63
|
};
|
|
24
|
-
/**
|
|
25
|
-
* The reference to the element that will be scrolled when the text exceeds the height of the container.
|
|
26
|
-
*
|
|
27
|
-
* @example
|
|
28
|
-
* ```tsx
|
|
29
|
-
* import { useRef } from "react";
|
|
30
|
-
* import MarkdownTypewriter from "../components/Typewriter";
|
|
31
|
-
*
|
|
32
|
-
* export default function NarrationScreen() {
|
|
33
|
-
* const paragraphRef = useRef<HTMLDivElement>(null);
|
|
34
|
-
* return (
|
|
35
|
-
* <div ref={paragraphRef}>
|
|
36
|
-
* <MarkdownTypewriter
|
|
37
|
-
* scrollRef={paragraphRef}
|
|
38
|
-
* >
|
|
39
|
-
* Hello World
|
|
40
|
-
* </MarkdownTypewriter>
|
|
41
|
-
* </div>
|
|
42
|
-
* );
|
|
43
|
-
* }
|
|
44
|
-
* ```
|
|
45
|
-
*/
|
|
46
|
-
scrollRef?: RefObject<HTMLDivElement | null>;
|
|
47
64
|
}
|
|
48
65
|
|
|
49
66
|
export type { MarkdownTypewriterProps as default };
|
|
@@ -2,7 +2,7 @@ import { HTMLMotionProps, Variants } from 'motion/react';
|
|
|
2
2
|
import { RefObject } from 'react';
|
|
3
3
|
import { Options } from 'react-markdown';
|
|
4
4
|
|
|
5
|
-
interface MarkdownTypewriterProps extends
|
|
5
|
+
interface MarkdownTypewriterProps extends Options {
|
|
6
6
|
/**
|
|
7
7
|
* The delay in milliseconds between the appearance of one letter and the next.
|
|
8
8
|
* @default 10
|
|
@@ -11,7 +11,7 @@ interface MarkdownTypewriterProps extends Omit<Options, "components"> {
|
|
|
11
11
|
/**
|
|
12
12
|
* The props to pass to the [motion span](https://motion.dev/docs/react-motion-component).
|
|
13
13
|
*
|
|
14
|
-
* The `
|
|
14
|
+
* The `characterVariants` parameter has been added to be able to modify the animation of each individual letter
|
|
15
15
|
*/
|
|
16
16
|
motionProps?: Omit<HTMLMotionProps<"span">, "variants"> & {
|
|
17
17
|
/**
|
|
@@ -19,31 +19,48 @@ interface MarkdownTypewriterProps extends Omit<Options, "components"> {
|
|
|
19
19
|
*
|
|
20
20
|
* @default { hidden: { opacity: 0 }, visible: { opacity: 1, transition: { opacity: { duration: 0 } } } }
|
|
21
21
|
*/
|
|
22
|
-
|
|
22
|
+
characterVariants?: Variants;
|
|
23
|
+
/**
|
|
24
|
+
* A callback that is called when the animation of a letter is complete.
|
|
25
|
+
* The callback is called with the reference to the letter.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```tsx
|
|
29
|
+
* import { useRef } from "react";
|
|
30
|
+
*
|
|
31
|
+
* export default function NarrationScreen() {
|
|
32
|
+
* const paragraphRef = useRef<HTMLDivElement>(null);
|
|
33
|
+
* const scrollToEnd = useCallback((ref: { current: HTMLSpanElement | null }) => {
|
|
34
|
+
* if (paragraphRef.current && ref.current) {
|
|
35
|
+
* let scrollTop = ref.current.offsetTop - paragraphRef.current.clientHeight / 2;
|
|
36
|
+
* paragraphRef.current.scrollTo({
|
|
37
|
+
* top: scrollTop,
|
|
38
|
+
* behavior: "auto",
|
|
39
|
+
* });
|
|
40
|
+
* }
|
|
41
|
+
* }, []);
|
|
42
|
+
* return (
|
|
43
|
+
* <div
|
|
44
|
+
* ref={paragraphRef}
|
|
45
|
+
* style={{
|
|
46
|
+
* overflow: "auto",
|
|
47
|
+
* height: "300px",
|
|
48
|
+
* }}
|
|
49
|
+
* >
|
|
50
|
+
* <MarkdownTypewriter
|
|
51
|
+
* motionProps={{
|
|
52
|
+
* onCharacterAnimationComplete: scrollToEnd,
|
|
53
|
+
* }}
|
|
54
|
+
* >
|
|
55
|
+
* Hello World
|
|
56
|
+
* </MarkdownTypewriter>
|
|
57
|
+
* </div>
|
|
58
|
+
* );
|
|
59
|
+
* }
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
onCharacterAnimationComplete?: (letterRef: RefObject<HTMLSpanElement | null>) => void;
|
|
23
63
|
};
|
|
24
|
-
/**
|
|
25
|
-
* The reference to the element that will be scrolled when the text exceeds the height of the container.
|
|
26
|
-
*
|
|
27
|
-
* @example
|
|
28
|
-
* ```tsx
|
|
29
|
-
* import { useRef } from "react";
|
|
30
|
-
* import MarkdownTypewriter from "../components/Typewriter";
|
|
31
|
-
*
|
|
32
|
-
* export default function NarrationScreen() {
|
|
33
|
-
* const paragraphRef = useRef<HTMLDivElement>(null);
|
|
34
|
-
* return (
|
|
35
|
-
* <div ref={paragraphRef}>
|
|
36
|
-
* <MarkdownTypewriter
|
|
37
|
-
* scrollRef={paragraphRef}
|
|
38
|
-
* >
|
|
39
|
-
* Hello World
|
|
40
|
-
* </MarkdownTypewriter>
|
|
41
|
-
* </div>
|
|
42
|
-
* );
|
|
43
|
-
* }
|
|
44
|
-
* ```
|
|
45
|
-
*/
|
|
46
|
-
scrollRef?: RefObject<HTMLDivElement | null>;
|
|
47
64
|
}
|
|
48
65
|
|
|
49
66
|
export type { MarkdownTypewriterProps as default };
|
package/package.json
CHANGED