Skip to content

Commit eb6b780

Browse files
committed
fix(react-codemirror-merge): fix extensions props issue. (#455)
1 parent 246855e commit eb6b780

File tree

4 files changed

+17
-6
lines changed

4 files changed

+17
-6
lines changed

core/tsconfig.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
{
22
"extends": "../tsconfig",
3-
"include": ["src", ".kktrc.ts"],
3+
"include": ["src"],
44
"compilerOptions": {
55
"outDir": "./cjs",
6-
"baseUrl": ".",
7-
"noEmit": false
6+
"baseUrl": "."
87
}
98
}

merge/src/Modified.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useEffect } from 'react';
2-
import { EditorStateConfig, Extension } from '@codemirror/state';
2+
import { EditorStateConfig, Extension, StateEffect } from '@codemirror/state';
33
import { getDefaultExtensions } from '@uiw/react-codemirror';
44
import { useStore } from './store';
55

@@ -30,5 +30,11 @@ export const Modified = (props: ModifiedProps): JSX.Element | null => {
3030
}
3131
}, [props.value, props.selection, view]);
3232

33+
useEffect(() => {
34+
if (view) {
35+
view.b.dispatch({ effects: StateEffect.appendConfig.of([...defaultExtensions, ...extensions]) });
36+
}
37+
}, [extensions, view]);
38+
3339
return null;
3440
};

merge/src/Original.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useEffect } from 'react';
2-
import { EditorStateConfig, Extension } from '@codemirror/state';
2+
import { EditorStateConfig, Extension, StateEffect } from '@codemirror/state';
33
import { useStore } from './store';
44
import { getDefaultExtensions } from '@uiw/react-codemirror';
55

@@ -30,5 +30,11 @@ export const Original = (props: OriginalProps): JSX.Element | null => {
3030
}
3131
}, [props.value, props.selection, view]);
3232

33+
useEffect(() => {
34+
if (view) {
35+
view.a.dispatch({ effects: StateEffect.appendConfig.of([...defaultExtensions, ...extensions]) });
36+
}
37+
}, [extensions, view]);
38+
3339
return null;
3440
};

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,6 @@
3434
"lint-staged": "~13.2.0",
3535
"prettier": "~2.8.0",
3636
"react-test-renderer": "~18.2.0",
37-
"tsbb": "^4.1.1"
37+
"tsbb": "^4.1.5"
3838
}
3939
}

0 commit comments

Comments
 (0)