Skip to content

Commit

Permalink
fix(react-codemirror-merge): fix extensions props issue. (#455)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Apr 7, 2023
1 parent 246855e commit eb6b780
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
5 changes: 2 additions & 3 deletions core/tsconfig.json
@@ -1,9 +1,8 @@
{
"extends": "../tsconfig",
"include": ["src", ".kktrc.ts"],
"include": ["src"],
"compilerOptions": {
"outDir": "./cjs",
"baseUrl": ".",
"noEmit": false
"baseUrl": "."
}
}
8 changes: 7 additions & 1 deletion merge/src/Modified.tsx
@@ -1,5 +1,5 @@
import { useEffect } from 'react';
import { EditorStateConfig, Extension } from '@codemirror/state';
import { EditorStateConfig, Extension, StateEffect } from '@codemirror/state';
import { getDefaultExtensions } from '@uiw/react-codemirror';
import { useStore } from './store';

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

useEffect(() => {
if (view) {
view.b.dispatch({ effects: StateEffect.appendConfig.of([...defaultExtensions, ...extensions]) });
}
}, [extensions, view]);

return null;
};
8 changes: 7 additions & 1 deletion merge/src/Original.tsx
@@ -1,5 +1,5 @@
import { useEffect } from 'react';
import { EditorStateConfig, Extension } from '@codemirror/state';
import { EditorStateConfig, Extension, StateEffect } from '@codemirror/state';
import { useStore } from './store';
import { getDefaultExtensions } from '@uiw/react-codemirror';

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

useEffect(() => {
if (view) {
view.a.dispatch({ effects: StateEffect.appendConfig.of([...defaultExtensions, ...extensions]) });
}
}, [extensions, view]);

return null;
};
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -34,6 +34,6 @@
"lint-staged": "~13.2.0",
"prettier": "~2.8.0",
"react-test-renderer": "~18.2.0",
"tsbb": "^4.1.1"
"tsbb": "^4.1.5"
}
}

0 comments on commit eb6b780

Please sign in to comment.