Skip to content

Commit 29ba906

Browse files
committed
feat: modify placeholder control props.
1 parent a0b556e commit 29ba906

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

src/useCodeMirror.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,20 @@ export function useCodeMirror(props: UseCodeMirror) {
115115
view.dispatch({ effects: StateEffect.reconfigure.of(getExtensions) });
116116
}
117117
// eslint-disable-next-line react-hooks/exhaustive-deps
118-
}, [theme, extensions, height, minHeight, maxHeight, width, minWidth, maxWidth, editable, indentWithTab, basicSetup]);
118+
}, [
119+
theme,
120+
extensions,
121+
placeholder,
122+
height,
123+
minHeight,
124+
maxHeight,
125+
width,
126+
minWidth,
127+
maxWidth,
128+
editable,
129+
indentWithTab,
130+
basicSetup,
131+
]);
119132

120133
useEffect(() => {
121134
if (autoFocus && view) {

website/App.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ let count = 0;
127127

128128
export default function App() {
129129
const [mode, setMode] = useState('javascript');
130+
const [placeholder, setPlaceholder] = useState('Please enter the code.');
130131
const [autofocus, setAutofocus] = useState(false);
131132
const [editable, setEditable] = useState(true);
132133
const [theme, setTheme] = useState<ReactCodeMirrorProps['theme']>('light');
@@ -191,7 +192,7 @@ export default function App() {
191192
extensions={extensions}
192193
autoFocus={autofocus}
193194
className={styles.codemirror}
194-
placeholder="Please enter the code."
195+
placeholder={placeholder}
195196
onChange={(value) => {
196197
// console.log('value:', value);
197198
}}
@@ -232,6 +233,10 @@ export default function App() {
232233
<input type="checkbox" checked={editable} onChange={(evn) => setEditable(evn.target.checked)} />
233234
editable
234235
</label>
236+
<label>
237+
placeholder:
238+
<input type="text" value={placeholder} onChange={(evn) => setPlaceholder(evn.target.value)} />
239+
</label>
235240
</div>
236241
<MarkdownPreview
237242
className={styles.markdown}

0 commit comments

Comments
 (0)