Skip to content

Commit 8e45937

Browse files
committed
Merge branch 'develop'
2 parents cac118e + 2155db8 commit 8e45937

File tree

18 files changed

+135
-87
lines changed

18 files changed

+135
-87
lines changed

babel.config.json

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,41 @@
4343
]
4444
]
4545
},
46+
"cjs2": {
47+
"presets": [
48+
"@babel/preset-env",
49+
[
50+
"@babel/preset-react",
51+
{
52+
"runtime": "automatic"
53+
}
54+
],
55+
"@babel/preset-typescript"
56+
],
57+
"plugins": [
58+
]
59+
},
60+
"mjs": {
61+
"presets": [
62+
[
63+
"@babel/preset-react",
64+
{
65+
"runtime": "automatic"
66+
}
67+
],
68+
"@babel/preset-typescript"
69+
],
70+
"plugins": [
71+
[
72+
"babel-plugin-replace-import-extension",
73+
{
74+
"extMapping": {
75+
".js": ".mjs"
76+
}
77+
}
78+
]
79+
]
80+
},
4681
"test": {
4782
"presets": [
4883
"@babel/preset-env",
@@ -61,7 +96,7 @@
6196
"@babel/preset-env",
6297
{
6398
"targets": {
64-
"node": "18"
99+
"node": "20"
65100
},
66101
"modules": false
67102
}
@@ -70,7 +105,7 @@
70105
"@babel/preset-typescript",
71106
{
72107
"targets": {
73-
"node": "18"
108+
"node": "20"
74109
},
75110
"modules": false
76111
}

eslint.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ export default defineConfig([
235235
{
236236
files: [
237237
'**/demo-server/*.{ts,tsx,mjs,js}',
238-
'packerConfig.js',
238+
'packerConfig.{mjs,js}',
239239
'jest.config.ts',
240240
],
241241
languageOptions: {

package-lock.json

Lines changed: 8 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@
2020
"page-index": "lerna run page-index",
2121
"dtsgen": "lerna run dtsgen",
2222
"tscheck": "lerna run tscheck",
23-
"profile": "cross-env NODE_OPTIONS='--max-old-space-size=4096' NODE_ENV=production node packerConfig.mjs --build --profile",
23+
"profile": "cross-env NODE_OPTIONS='$NODE_OPTIONS --max-old-space-size=4096' NODE_ENV=production node packerConfig.mjs --build --profile",
2424
"clean": "npm run clean-dist && lerna clean -y",
2525
"clean-dist": "node packerConfig.mjs --clean",
2626
"clean-lock": "rimraf --glob packages/*/package-lock.json",
2727
"check": "npm run lint && npm run tscheck && npm run test",
28-
"lint": "cross-env NODE_ENV=test NODE_OPTIONS=\"--max-old-space-size=8192\" eslint -c=eslint.config.js --ext=.tsx,.ts --max-warnings=0 'packages'",
28+
"lint": "cross-env NODE_ENV=test NODE_OPTIONS=\"$NODE_OPTIONS --max-old-space-size=8192\" eslint -c=eslint.config.js --ext=.tsx,.ts --max-warnings=0 'packages'",
2929
"test": "jest -c=\"jest.config.ts\" --passWithNoTests",
3030
"tdd": "npm test -- --watch --watchman --coverage=false",
3131
"__release": "lerna run release --stream",
@@ -49,7 +49,7 @@
4949
"globals": "^16.2.0",
5050
"jest-environment-jsdom": "^29.0.2",
5151
"lerna": "^8.2.2",
52-
"lerna-packer": "0.12.1",
52+
"lerna-packer": "0.12.2",
5353
"nodemon": "^3.1.7",
5454
"react": "^19.0",
5555
"react-dom": "^19.0",

packages/demo/src/components/CustomCodeMirror.tsx

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Box from '@mui/material/Box'
22
import { useCodeMirror } from '@ui-schema/kit-codemirror'
3-
import React, { useCallback } from 'react'
3+
import React, { useCallback, useMemo } from 'react'
44
import {
55
lineNumbers, highlightActiveLineGutter, highlightSpecialChars,
66
drawSelection, dropCursor,
@@ -30,9 +30,6 @@ export const CustomCodeMirror: React.FC<CodeMirrorComponentProps & MuiCodeMirror
3030
...props
3131
},
3232
) => {
33-
const theme = useEditorTheme(typeof onChange === 'undefined', dense, variant)
34-
const highlightStyle = useHighlightStyle()
35-
3633
const extensionsAll: Extension[] = React.useMemo(() => [
3734
lineNumbers(),
3835
EditorView.lineWrapping,
@@ -77,23 +74,23 @@ export const CustomCodeMirror: React.FC<CodeMirrorComponentProps & MuiCodeMirror
7774
})
7875

7976
useExtension(
80-
useCallback(
81-
() => syntaxHighlighting(highlightStyle || defaultHighlightStyle, {fallback: true}),
82-
[highlightStyle],
83-
),
77+
useMemo(() => {
78+
return Prec.lowest(EditorView.editorAttributes.of({class: classNameContent || ''}))
79+
}, [classNameContent]),
8480
editorRef,
8581
)
82+
83+
const highlightStyle = useHighlightStyle()
8684
useExtension(
8785
useCallback(
88-
() => theme,
89-
[theme],
86+
() => syntaxHighlighting(highlightStyle || defaultHighlightStyle, {fallback: true}),
87+
[highlightStyle],
9088
),
9189
editorRef,
9290
)
91+
9392
useExtension(
94-
useCallback(() => {
95-
return Prec.lowest(EditorView.editorAttributes.of({class: classNameContent || ''}))
96-
}, [classNameContent]),
93+
useEditorTheme(typeof onChange === 'undefined', dense, variant),
9794
editorRef,
9895
)
9996

packages/kit-codemirror/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@ui-schema/kit-codemirror",
3-
"version": "1.0.0-alpha.0",
3+
"version": "1.0.0-alpha.1",
44
"description": "CodeMirror v6 as React Component, with hooks and stuff - but only the necessities.",
55
"homepage": "https://ui-schema.bemit.codes/docs/kit-codemirror/kit-codemirror",
66
"author": {

packages/kit-codemirror/src/useCodeMirror/useCodeMirror.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useLayoutEffect, useRef } from 'react'
2-
import type { RefObject } from 'react'
2+
import type { MutableRefObject } from 'react'
33
import { EditorView, ViewUpdate } from '@codemirror/view'
44
import { Compartment, Extension } from '@codemirror/state'
55
import { createEditorView, replaceWholeDoc } from '@ui-schema/kit-codemirror/createEditorView'
@@ -33,7 +33,8 @@ export const useCodeMirror = (
3333
// Callback for editor lifecycle events.
3434
onViewLifecycle?: CodeMirrorOnViewLifeCycle
3535
},
36-
): [RefObject<EditorView | null>, Compartment] => {
36+
// eslint-disable-next-line @typescript-eslint/no-deprecated
37+
): [MutableRefObject<EditorView | null>, Compartment] => {
3738
const editorRef = useRef<EditorView | null>(null)
3839

3940
const onChangeRef = useRef(onChange)

packages/kit-codemirror/src/useExtension/useExtension.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
import { Compartment, Extension, StateEffect } from '@codemirror/state'
22
import { EditorView } from '@codemirror/view'
33
import { useLayoutEffect, useRef } from 'react'
4-
import type { RefObject } from 'react'
4+
import type { MutableRefObject } from 'react'
5+
6+
type SetupExtension = (() => Extension) | Extension
57

68
export const useExtension = (
7-
setupExtension: () => Extension,
8-
editorRef: RefObject<EditorView | null>,
9+
setupExtension: SetupExtension,
10+
// eslint-disable-next-line @typescript-eslint/no-deprecated
11+
editorRef: MutableRefObject<EditorView | null>,
912
) => {
10-
const configuredRef = useRef<{ view: EditorView, cb: Function } | null>(null)
13+
const configuredRef = useRef<{ view: EditorView, cb: SetupExtension } | null>(null)
1114
const compartmentRef = useRef<Compartment>(new Compartment())
1215

1316
useLayoutEffect(() => {
@@ -25,10 +28,12 @@ export const useExtension = (
2528
// exists, reconfigure
2629
// new, append to config
2730

31+
const extension = typeof setupExtension === 'function' ? setupExtension() : setupExtension
32+
2833
editorRef.current.dispatch({
2934
effects: isInitialSetup
30-
? StateEffect.appendConfig.of(compartment.of(setupExtension()))
31-
: compartment.reconfigure(setupExtension()),
35+
? StateEffect.appendConfig.of(compartment.of(extension))
36+
: compartment.reconfigure(extension),
3237
})
3338
configuredRef.current = {view: editorRef.current, cb: setupExtension}
3439
} else {

packages/material-code/package.json

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@ui-schema/material-code",
3-
"version": "0.5.0-alpha.0",
3+
"version": "0.5.0-alpha.1",
44
"description": "Code editor widgets using CodeMirror, with Material-UI styling for UI-Schema",
55
"homepage": "https://ui-schema.bemit.codes/docs/material-code/material-code",
66
"author": {
@@ -34,9 +34,22 @@
3434
"bugs": {
3535
"url": "https://github.com/ui-schema/react-codemirror/issues"
3636
},
37-
"main": "./index.js",
37+
"main": "./index.cjs",
3838
"module": "./esm/index.js",
3939
"types": "./index.d.ts",
40+
"exports": {
41+
".": {
42+
"types": "./index.d.ts",
43+
"import": "./esm/index.js",
44+
"require": "./index.cjs"
45+
},
46+
"./*": {
47+
"types": "./*/index.d.ts",
48+
"import": "./esm/*/index.js",
49+
"require": "./*/index.cjs"
50+
},
51+
"./esm": null
52+
},
4053
"scripts": {
4154
"dtsgen": "tsc -d --emitDeclarationOnly --pretty && node ../../tools/merge-dirs.js build/dts/material-code/src build && rm -rf build/dts && rm -rf build/**/*.test.* build/**/*.mock.*",
4255
"__release": "cp package.json build/ && cp package-lock.json build/ && cp README.md build/ && npm publish build"
@@ -54,6 +67,7 @@
5467
"@ui-schema/kit-codemirror": "^1.0.0-alpha.0",
5568
"@ui-schema/ds-material": "~0.4.3",
5669
"@ui-schema/ui-schema": "~0.4.7",
70+
"@lezer/highlight": "^1.2.1",
5771
"immutable": "^5.0.0",
5872
"react": "^19.0",
5973
"react-dom": "^19.0"
@@ -67,6 +81,7 @@
6781
"@ui-schema/kit-codemirror": "^1.0.0-alpha.0",
6882
"@ui-schema/ds-material": "~0.4.0-alpha",
6983
"@ui-schema/ui-schema": "~0.4.0-alpha",
84+
"@lezer/highlight": "^1.0.0",
7085
"immutable": "^4.0.0 || ^5.0.0",
7186
"react": "^17.0 || ^18.0 || ^19.0"
7287
},
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export * from './CodeBar'
1+
export * from './CodeBar.js'

0 commit comments

Comments
 (0)