Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to dynamic change font-family #620

Open
ywww opened this issue Jan 19, 2024 · 4 comments
Open

how to dynamic change font-family #620

ywww opened this issue Jan 19, 2024 · 4 comments

Comments

@ywww
Copy link

ywww commented Jan 19, 2024

how to dynamic change font-family

@jaywcjlove
Copy link
Member

@ywww

const styleExtension = EditorView.theme({
  ".cm-editor .cm-scroller": {
    fontFamily: "monospace"
  }
}, {
  dark: true,
});
<CodeMirror
  extensions={[styleExtension]}
/>

@ywww
Copy link
Author

ywww commented Jan 20, 2024

can not work

@ywww
Copy link
Author

ywww commented Jan 20, 2024

"@uiw/codemirror-extensions-langs": "^4.21.21",
"@uiw/codemirror-themes-all": "^4.21.21",
"@uiw/react-codemirror": "^4.21.21",

                <CodeMirror
                    style={{fontSize: fontSize}}
                    value={value}
                    width={'100%'}
                    theme={themes[theme]}
                    basicSetup={{tabSize: 2}}
                    indentWithTab={true}
                    readOnly={disabled}
                    height={height || 200 + 'px'}
                    extensions={[json(), EditorView.lineWrapping, EditorView.theme({
                        ".cm-editor .cm-scroller": {
                            fontFamily: fontFamily
                        }
                    }, {
                        dark: true,
                    })]}
                    onChange={this.props.onChange}
                />

@jaywcjlove
Copy link
Member

@ywww If you provide a reproducible example, I can take a look at it for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants