Skip to content

Commit cac118e

Browse files
committed
Merge branch 'develop'
2 parents 336a520 + 86162bb commit cac118e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+13684
-20298
lines changed

.eslintignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

.eslintrc

Lines changed: 0 additions & 166 deletions
This file was deleted.

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
blank_issues_enabled: true
22
contact_links:
3-
- name: UI-Schema Slack
4-
url: https://join.slack.com/t/ui-schema/shared_invite/zt-smbsybk5-dFIRLEPCJerzDwtycaA71w
5-
about: Ask questions and discuss in our Slack Community
6-
- name: Material-UI
3+
- name: UI-Schema Discord
4+
url: https://discord.gg/MAjgpwnm36
5+
about: Ask questions and discuss in our Discord Community
6+
- name: CodeMirror GitHub
7+
url: https://github.com/codemirror
8+
about: "More about the underlying editor framework."
9+
- name: Material-UI GitHub
710
url: https://github.com/mui-org/material-ui
8-
about: "When you got question not about the design-system bindings: docs + project of **Material-UI**"
11+
about: "Documentation and more for the design framework."

.github/workflows/blank.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
runs-on: ubuntu-latest
2121
strategy:
2222
matrix:
23-
node-version: [ 18.x ]
23+
node-version: [ 24 ]
2424
steps:
2525
- uses: actions/checkout@v4
2626
- name: Set Branch
@@ -44,9 +44,7 @@ jobs:
4444

4545
- name: Setup packages
4646
run: |
47-
npm ci
48-
npm run bootstrap
49-
npm run link
47+
npm ci --legacy-peer-deps
5048
5149
- name: Run tests
5250
run: |

CONTRIBUTING.md

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
# Contributing to UI-Schema
22

33
1. Fork/Clone repository **branch `develop`**
4-
2. Install root dev-dependencies (like lerna, webpack): `npm i`
5-
3. Install & link the `packages`: `npm run bootstrap && npm run link`
6-
4. Start dev-server: `npm start`
4+
2. Install dependencies (like lerna, webpack): `npm i`
5+
3. Start dev-server: `npm start`
76
- (will clean-dist + start demo app)
8-
5. Open browser on [localhost:4200](http://localhost:4203) for demo
9-
6. Explore [packages](packages)
10-
7. Code -> Commit -> Pull Request -> Being Awesome!
7+
4. Open browser on [localhost:4203](http://localhost:4203) for demo
8+
5. Explore [packages](packages) and there [demo/src/pages](packages/demo/src/pages)
9+
6. Code -> Commit -> Pull Request -> Being Awesome!
1110

1211
Changes from any package are reflected inside the demo package.
1312

@@ -20,22 +19,12 @@ Changes from any package are reflected inside the demo package.
2019
- with `--testPathPattern` to run all tests in a specific folder / path
2120
- `npm run tdd -- --testPathPattern=PatternValidator -t patternValidator` for only one test and often only one file
2221
- Testing: `npm test`
23-
- needs manual bootstrapping, linking and update handling
2422
- Build: `npm run build`
25-
- needs manual bootstrapping and update handling
2623
- Clean node_modules and build dirs: `npm run clean`
2724
- Clean build dirs: `npm run clean-dist`
28-
- Add new node_module to one package: `lerna add <npm-package-name> --scope=@ui-schema/demo [--dev] [--peer]`, without `--scope` in all packages
29-
- Do not change `package.json` of packages manually, and if Bootstrap [lerna](https://lerna.js.org/): `npm run bootstrap` (maybe delete `package-lock.json`), or simply open an issue
30-
- Add new package `lerna create <name>` and follow on screen, e.g.: `lerna create material-pickers` add package name `@ui-schema/material-pickerss`, creates folder `./packages/material-pickers`
31-
32-
> All-in-one clean & reinstall command - skip the first one if not installed completely:
33-
> `npm run clean && rm -rf node_modules && rm -f package-lock.json && npm i && npm run bootstrap && npm run bootstrap && npm run link`
34-
>
35-
> The two-times `bootstrap` fixes sometimes stale `packages` dependencies/lock-files, but sometimes a manual deletion of those also helps with `node_modules` resolving issues.
3625

3726
## Contributors
3827

3928
By committing your code/creating a pull request to this repository you agree to release the code under the [MIT License](LICENSE) attached to the repository and to adhere to the [CODE_OF_CONDUCT](CODE_OF_CONDUCT.md).
4029

41-
Questions? Feel free to open discussions or join the [slack channel](https://join.slack.com/t/ui-schema/shared_invite/zt-smbsybk5-dFIRLEPCJerzDwtycaA71w)!
30+
Questions? Feel free to open discussions or join the [discord channel](https://discord.gg/MAjgpwnm36)!

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2024 bemit UG (haftungsbeschränkt)
3+
Copyright (c) 2025 bemit UG (haftungsbeschränkt)
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ CodeMirror v6 integration for React, with MUI widgets for [UI-Schema](https://gi
1212
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
1313
![Typed](https://flat.badgen.net/badge/icon/Typed?icon=typescript&label&labelColor=blue&color=555555)
1414

15-
- [CodeMirror](https://codemirror.net/) v6 as plain React integration: `@ui-schema/kit-codemirror` [![npm (scoped)](https://img.shields.io/npm/v/@ui-schema/kit-codemirror?style=flat-square)](https://www.npmjs.com/package/@ui-schema/kit-codemirror) [![Component Documentation](https://img.shields.io/badge/Docs-green?labelColor=0a6e8a&color=61dafb&logoColor=ffffff&style=flat-square&logo=react)](https://ui-schema.bemit.codes/docs/kit-codemirror/kit-codemirror)
16-
- UI-Schema Widgets for [MUI](https://mui.com): `@ui-schema/material-code` [![npm (scoped)](https://img.shields.io/npm/v/@ui-schema/material-code?style=flat-square)](https://www.npmjs.com/package/@ui-schema/material-code) [![Component Documentation](https://img.shields.io/badge/Docs-green?labelColor=1a237e&color=0d47a1&logoColor=ffffff&style=flat-square&logo=mui)](https://ui-schema.bemit.codes/docs/material-code/material-code)
15+
- [CodeMirror](https://codemirror.net/) v6 as plain React integration: `@ui-schema/kit-codemirror` [![npm (scoped)](https://img.shields.io/npm/v/@ui-schema/kit-codemirror?style=flat-square)](https://www.npmjs.com/package/@ui-schema/kit-codemirror) [![Component Documentation](https://img.shields.io/badge/Docs-green?labelColor=0a6e8a&color=61dafb&logoColor=ffffff&style=flat-square&logo=react)](./docs/kit-codemirror/kit-codemirror.md)
16+
- UI-Schema Widgets for [MUI](https://mui.com): `@ui-schema/material-code` [![npm (scoped)](https://img.shields.io/npm/v/@ui-schema/material-code?style=flat-square)](https://www.npmjs.com/package/@ui-schema/material-code) [![Component Documentation](https://img.shields.io/badge/Docs-green?labelColor=1a237e&color=0d47a1&logoColor=ffffff&style=flat-square&logo=mui)](./docs/material-code/material-code.md)
1717

1818
## Demo
1919

@@ -47,4 +47,4 @@ See [CONTRIBUTING.md](CONTRIBUTING.md).
4747

4848
This project is free software distributed under the **[MIT LICENSE](LICENSE)**.
4949

50-
© 2024 bemit UG (haftungsbeschränkt)
50+
© 2025 bemit UG (haftungsbeschränkt)

babel.config.json

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
{
22
"presets": [
3-
"@babel/preset-react",
3+
[
4+
"@babel/preset-react",
5+
{
6+
"runtime": "automatic"
7+
}
8+
],
49
"@babel/preset-typescript"
510
],
611
"plugins": [
@@ -19,7 +24,12 @@
1924
"cjs": {
2025
"presets": [
2126
"@babel/preset-env",
22-
"@babel/preset-react",
27+
[
28+
"@babel/preset-react",
29+
{
30+
"runtime": "automatic"
31+
}
32+
],
2333
"@babel/preset-typescript"
2434
],
2535
"plugins": [
@@ -36,7 +46,12 @@
3646
"test": {
3747
"presets": [
3848
"@babel/preset-env",
39-
"@babel/preset-react",
49+
[
50+
"@babel/preset-react",
51+
{
52+
"runtime": "automatic"
53+
}
54+
],
4055
"@babel/preset-typescript"
4156
]
4257
},

docs/Index.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Documentation
2+
3+
- [kit-codemirror](./kit-codemirror/kit-codemirror.md)
4+
- [material-code](./material-code/material-code.md)
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Kit CodeMirror
2+
3+
Thin-wrapper for CodeMirror v6 to use as React Component, with hooks and stuff to build more advanced editors easily.
4+
5+
```bash
6+
npm install --save @ui-schema/kit-codemirror @codemirror/state @codemirror/view
7+
8+
# doesn't require any other module of `@ui-schema`
9+
```
10+
11+
Contains only the minimal necessities for CodeMirror to work in ReactJS, nothing more.
12+
13+
- supports `value` as string
14+
- bind state changes with `onChange` - or omit it for a **read only editor**
15+
- add native CodeMirror extensions with props
16+
17+
> [!CAUTION]
18+
>
19+
> It is important to only supply safely referenced props! Always use e.g. `useMemo`/`useCallback` for extensions, function and other complex values.
20+
>
21+
> Otherwise, the editors extension are unnecessarily destroyed and will cause significant performance degradation or even subtle bugs.
22+
>
23+
> For granular control of reactive extension reconfiguration, use the `useCodeMirror` and `useExtension` hooks, check the [`CodeMirror` base component](../../packages/kit-codemirror/src/CodeMirror/CodeMirror.tsx) as reference.
24+
25+
## Components
26+
27+
The `CodeMirror` component serves as read-to-use ReactJS integration.
28+
29+
Check the `CustomCodeMirror` in [`demo/src/pages/PageDemoComponent.tsx`](../../packages/demo/src/pages/PageDemoComponent.tsx) for an example.
30+
31+
## Hooks
32+
33+
### useCodeMirror
34+
35+
Create a custom editor component with the `useCodeMirror` hook, it is internally used by the `CodeMirror` component. With it, you have more control on extension setup and customization of the container the editor is rendered in.
36+
37+
Check the [`CodeMirror` component as an example](../../packages/kit-codemirror/src/CodeMirror/CodeMirror.tsx).
38+
39+
### useExtension
40+
41+
The `useExtension` hook sets up a codemirror extension, with easy reactive reconfiguration.
42+
43+
> [!IMPORTANT]
44+
>
45+
> The `useExtension` hook can only be used when using the `useCodeMirror` hook, not with the `CodeMirror` component.
46+
47+
> [!IMPORTANT]
48+
>
49+
> The `useExtension` hook must be positioned directly after the `useCodeMirror` hook, it can not be used in parent components.
50+
51+
It automatically enables the extension and reconfigures it whenever the setup function changes. Always use `useCallback` for the setup function to prevent unnecessary reconfigurations.
52+
53+
The extension is added to the end of the editors configuration, to control the order use `Prec` to set the precedence.
54+
55+
```tsx
56+
import { Prec } from '@codemirror/state'
57+
import { useExtension } from '@ui-schema/kit-codemirror/useExtension'
58+
59+
// must be called before using the `useExtension` hook
60+
const [editorRef] = useCodeMirror(/* ... */)
61+
62+
// the complete code for a "editorAttributes" extension, which keeps the `class` up to date
63+
useExtension(
64+
useCallback(() => {
65+
return Prec.lowest(EditorView.editorAttributes.of({class: classNameContent || ''}))
66+
}, [classNameContent]),
67+
editorRef,
68+
)
69+
```

0 commit comments

Comments
 (0)