Skip to content

Commit 87f6fcb

Browse files
committed
feature: added placeholder prop and option to pass down props into textarea.
1 parent e32ca91 commit 87f6fcb

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

README.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -344,17 +344,22 @@ describe("Renders", () => {
344344
### Props
345345

346346
```tsx
347-
export interface SimpleMdeReactProps
347+
export interface SimpleMDEReactProps
348348
extends Omit<React.HTMLAttributes<HTMLDivElement>, "onChange"> {
349349
id?: string;
350-
onChange?: (value: string) => void;
350+
onChange?: (value: string, changeObject?: EditorChange) => void;
351351
value?: string;
352352
extraKeys?: KeyMap;
353353
options?: SimpleMDE.Options;
354354
events?: SimpleMdeToCodemirrorEvents;
355-
getMdeInstance?: (instance: SimpleMDE) => void;
356-
getCodemirrorInstance?: (codemirror: Editor) => void;
357-
getLineAndCursor?: (position: Position) => void;
355+
getMdeInstance?: GetMdeInstance;
356+
getCodemirrorInstance?: GetCodemirrorInstance;
357+
getLineAndCursor?: GetLineAndCursor;
358+
placeholder?: string;
359+
textareaProps?: Omit<
360+
React.HTMLAttributes<HTMLTextAreaElement>,
361+
"id" | "style" | "placeholder"
362+
>;
358363
}
359364
```
360365

src/SimpleMdeReact.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,11 @@ export interface SimpleMDEReactProps
7676
getMdeInstance?: GetMdeInstance;
7777
getCodemirrorInstance?: GetCodemirrorInstance;
7878
getLineAndCursor?: GetLineAndCursor;
79+
placeholder?: string;
80+
textareaProps?: Omit<
81+
React.HTMLAttributes<HTMLTextAreaElement>,
82+
"id" | "style" | "placeholder"
83+
>;
7984
}
8085

8186
const useHandleEditorInstanceLifecycle = ({
@@ -155,6 +160,8 @@ export const SimpleMdeReact = React.forwardRef<
155160
getCodemirrorInstance,
156161
onChange,
157162
id: anId,
163+
placeholder,
164+
textareaProps,
158165
...rest
159166
} = props;
160167

@@ -291,7 +298,13 @@ export const SimpleMdeReact = React.forwardRef<
291298
elementWrapperRef.current = aRef;
292299
}}
293300
>
294-
<textarea id={id} ref={setTextRef} style={{ display: "none" }} />
301+
<textarea
302+
{...textareaProps}
303+
id={id}
304+
placeholder={placeholder}
305+
ref={setTextRef}
306+
style={{ display: "none" }}
307+
/>
295308
</div>
296309
);
297310
});

0 commit comments

Comments
 (0)