change font-size to be a range input with quick example

This commit is contained in:
Víctor Losada Hernández
2026-09-23 23:59:23 +02:00
parent fc8c6d9955
commit 6ec10d6f6f
3 changed files with 7 additions and 16 deletions
+1 -1
View File
@@ -87,7 +87,7 @@ const createSettingsExtensions = (settings)=>[
...(settings.fontSize ...(settings.fontSize
? [EditorView.theme({ ? [EditorView.theme({
'&, .cm-content' : { '&, .cm-content' : {
fontSize : `${settings.fontSize}px`, fontSize : `${settings.fontSize || 1}em`,
}, },
})] })]
: []), : []),
+1 -1
View File
@@ -91,7 +91,7 @@ const Editor = forwardRef(
showImagePreviews : true, showImagePreviews : true,
activeLineShading : true, activeLineShading : true,
lineNumbers : true, lineNumbers : true,
fontSize : 13, fontSize : 1,
editorTheme : 'default', editorTheme : 'default',
}); });
@@ -4,17 +4,7 @@ import React from 'react';
const SettingsEditor = ({ settings, updateSettings = ()=>{}, EditorThemeNameList })=>{ const SettingsEditor = ({ settings, updateSettings = ()=>{}, EditorThemeNameList })=>{
const validations = { const validations = {
fontSize : [
(value)=>{
const number = Number(value);
if(number < 9 || number > 30) {
return 'Font size must be between 9 and 30.';
}
return null;
},
],
}; };
const handleFieldChange = (setting, e)=>{ const handleFieldChange = (setting, e)=>{
@@ -129,12 +119,13 @@ const SettingsEditor = ({ settings, updateSettings = ()=>{}, EditorThemeNameList
</label> </label>
<div className='value'> <div className='value'>
<small>from 9px to 30px</small> <small style={{ fontSize: `${settings.fontSize || 1}em` }}>from 9px to 30px</small>
<input <input
id='fontSize' id='fontSize'
type='number' type='range'
min={9} min={.6}
max={30} step={.1}
max={2}
name='fontSize' name='fontSize'
value={settings.fontSize} value={settings.fontSize}
onChange={(e)=>handleFieldChange('fontSize', e)} onChange={(e)=>handleFieldChange('fontSize', e)}