Skip to content

Commit cde4438

Browse files
committed
fix: Fix extensions bundled version issue (#267).
1 parent 4654922 commit cde4438

File tree

2 files changed

+59
-12
lines changed

2 files changed

+59
-12
lines changed

.kktrc.ts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,53 @@ export default (conf: Configuration, env: 'development' | 'production', options:
1717
main: 'dist/codemirror.js',
1818
// webpack externals options
1919
dependencies: {
20+
'@codemirror/basic-setup': {
21+
root: ['CM', '@codemirror/basic-setup'],
22+
commonjs: '@codemirror/basic-setup',
23+
commonjs2: '@codemirror/basic-setup',
24+
},
25+
'@codemirror/state': {
26+
root: ['CM', '@codemirror/state'],
27+
commonjs: '@codemirror/state',
28+
commonjs2: '@codemirror/state',
29+
},
30+
'@codemirror/view': {
31+
root: ['CM', '@codemirror/view'],
32+
commonjs: '@codemirror/view',
33+
commonjs2: '@codemirror/view',
34+
},
35+
'@codemirror/theme-one-dark': {
36+
root: ['CM', '@codemirror/theme-one-dark'],
37+
commonjs: '@codemirror/theme-one-dark',
38+
commonjs2: '@codemirror/theme-one-dark',
39+
},
40+
oneDark: {
41+
root: ['CM', '@codemirror/theme-one-dark', 'oneDark'],
42+
},
43+
basicSetup: {
44+
root: ['CM', '@codemirror/basic-setup', 'basicSetup'],
45+
},
46+
indentWithTab: {
47+
root: ['CM', '@codemirror/commands', 'indentWithTab'],
48+
},
49+
keymap: {
50+
root: ['CM', '@codemirror/view', 'keymap'],
51+
},
52+
placeholder: {
53+
root: ['CM', '@codemirror/view', 'placeholder'],
54+
},
55+
ViewUpdate: {
56+
root: ['CM', '@codemirror/view', 'ViewUpdate'],
57+
},
58+
EditorView: {
59+
root: ['CM', '@codemirror/view', 'EditorView'],
60+
},
61+
StateEffect: {
62+
root: ['CM', '@codemirror/state', 'StateEffect'],
63+
},
64+
EditorState: {
65+
root: ['CM', '@codemirror/basic-setup', 'EditorState'],
66+
},
2067
react: {
2168
root: 'React',
2269
commonjs2: 'react',

src/useCodeMirror.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { useEffect, useState } from 'react';
2-
import { basicSetup as defaultBasicSetup } from '@codemirror/basic-setup';
2+
import { basicSetup } from '@codemirror/basic-setup';
33
import { EditorState, StateEffect } from '@codemirror/state';
4-
import { indentWithTab as defaultIndentWithTab } from '@codemirror/commands';
5-
import { EditorView, keymap, ViewUpdate, placeholder as extendPlaceholder } from '@codemirror/view';
4+
import { indentWithTab } from '@codemirror/commands';
5+
import { EditorView, keymap, ViewUpdate, placeholder } from '@codemirror/view';
66
import { oneDark } from '@codemirror/theme-one-dark';
77
import { ReactCodeMirrorProps } from './';
88
import { defaultLightThemeOption } from './theme/light';
@@ -23,13 +23,13 @@ export function useCodeMirror(props: UseCodeMirror) {
2323
height = '',
2424
minHeight = '',
2525
maxHeight = '',
26-
placeholder = '',
26+
placeholder: placeholderStr = '',
2727
width = '',
2828
minWidth = '',
2929
maxWidth = '',
3030
editable = true,
31-
indentWithTab = true,
32-
basicSetup = true,
31+
indentWithTab: defaultIndentWithTab = true,
32+
basicSetup: defaultBasicSetup = true,
3333
root,
3434
} = props;
3535
const [container, setContainer] = useState(props.container);
@@ -53,15 +53,15 @@ export function useCodeMirror(props: UseCodeMirror) {
5353
}
5454
});
5555
let getExtensions = [updateListener, defaultThemeOption];
56-
if (indentWithTab) {
57-
getExtensions.unshift(keymap.of([defaultIndentWithTab]));
56+
if (defaultIndentWithTab) {
57+
getExtensions.unshift(keymap.of([indentWithTab]));
5858
}
59-
if (basicSetup) {
60-
getExtensions.unshift(defaultBasicSetup);
59+
if (defaultBasicSetup) {
60+
getExtensions.unshift(basicSetup);
6161
}
6262

63-
if (placeholder) {
64-
getExtensions.unshift(extendPlaceholder(placeholder));
63+
if (placeholderStr) {
64+
getExtensions.unshift(placeholder(placeholderStr));
6565
}
6666

6767
switch (theme) {

0 commit comments

Comments
 (0)