@milkdown/crepe 7.15.3 → 7.15.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/feature/link-tooltip/index.js +2 -2
- package/lib/cjs/feature/link-tooltip/index.js.map +1 -1
- package/lib/cjs/index.js +2 -2
- package/lib/cjs/index.js.map +1 -1
- package/lib/esm/feature/link-tooltip/index.js +2 -2
- package/lib/esm/feature/link-tooltip/index.js.map +1 -1
- package/lib/esm/index.js +2 -2
- package/lib/esm/index.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types/default-config/default-config.spec.d.ts +2 -0
- package/lib/types/default-config/default-config.spec.d.ts.map +1 -0
- package/lib/types/default-config/index.d.ts +1 -0
- package/lib/types/default-config/index.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/default-config/default-config.spec.ts +27 -0
- package/src/default-config/index.ts +10 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default-config.spec.d.ts","sourceRoot":"","sources":["../../../src/default-config/default-config.spec.ts"],"names":[],"mappings":""}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { type CrepeFeatureConfig } from '../feature';
|
|
2
2
|
export declare const defaultConfig: CrepeFeatureConfig;
|
|
3
|
+
export declare const applyConfig: (userConfig: Partial<CrepeFeatureConfig>) => CrepeFeatureConfig & Partial<CrepeFeatureConfig>;
|
|
3
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/default-config/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/default-config/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAgB,KAAK,kBAAkB,EAAE,MAAM,YAAY,CAAA;AASlE,eAAO,MAAM,aAAa,EAAE,kBAY3B,CAAA;AAED,eAAO,MAAM,WAAW,GAAI,YAAY,OAAO,CAAC,kBAAkB,CAAC,qDAOlE,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@milkdown/crepe",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "7.15.
|
|
4
|
+
"version": "7.15.4",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -108,7 +108,7 @@
|
|
|
108
108
|
"tslib": "^2.8.1",
|
|
109
109
|
"unist-util-visit": "^5.0.0",
|
|
110
110
|
"vue": "^3.5.13",
|
|
111
|
-
"@milkdown/kit": "7.15.
|
|
111
|
+
"@milkdown/kit": "7.15.4"
|
|
112
112
|
},
|
|
113
113
|
"scripts": {
|
|
114
114
|
"build": "pnpm run build:es && pnpm run build:theme && echo",
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { LanguageDescription } from '@codemirror/language'
|
|
2
|
+
|
|
3
|
+
import { expect, test } from 'vitest'
|
|
4
|
+
|
|
5
|
+
import { applyConfig } from '.'
|
|
6
|
+
import { CrepeFeature } from '../feature'
|
|
7
|
+
|
|
8
|
+
const mockHSLanguageDescription = {
|
|
9
|
+
name: 'haskell',
|
|
10
|
+
} as LanguageDescription
|
|
11
|
+
|
|
12
|
+
const mockCppLanguageDescription = {
|
|
13
|
+
name: 'cpp',
|
|
14
|
+
} as LanguageDescription
|
|
15
|
+
|
|
16
|
+
test('should use custom config to override the default config', () => {
|
|
17
|
+
const myConfig = applyConfig({
|
|
18
|
+
[CrepeFeature.CodeMirror]: {
|
|
19
|
+
languages: [mockHSLanguageDescription, mockCppLanguageDescription],
|
|
20
|
+
},
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
expect(myConfig[CrepeFeature.CodeMirror]?.languages).toEqual([
|
|
24
|
+
mockHSLanguageDescription,
|
|
25
|
+
mockCppLanguageDescription,
|
|
26
|
+
])
|
|
27
|
+
})
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { languages } from '@codemirror/language-data'
|
|
2
2
|
import { oneDark } from '@codemirror/theme-one-dark'
|
|
3
|
+
import { mergeWith } from 'lodash-es'
|
|
3
4
|
|
|
4
5
|
import { CrepeFeature, type CrepeFeatureConfig } from '../feature'
|
|
5
6
|
import {
|
|
@@ -23,3 +24,12 @@ export const defaultConfig: CrepeFeatureConfig = {
|
|
|
23
24
|
previewOnlyMode ? editIcon : visibilityOffIcon,
|
|
24
25
|
},
|
|
25
26
|
}
|
|
27
|
+
|
|
28
|
+
export const applyConfig = (userConfig: Partial<CrepeFeatureConfig>) => {
|
|
29
|
+
return mergeWith({}, defaultConfig, userConfig, (_objValue, srcValue) => {
|
|
30
|
+
if (Array.isArray(srcValue)) {
|
|
31
|
+
return srcValue
|
|
32
|
+
}
|
|
33
|
+
return undefined
|
|
34
|
+
})
|
|
35
|
+
}
|