@milkdown/crepe 7.16.0 → 7.17.0
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/code-mirror/index.js +27 -22
- package/lib/cjs/feature/code-mirror/index.js.map +1 -1
- package/lib/cjs/feature/latex/index.js +2 -2
- package/lib/cjs/feature/latex/index.js.map +1 -1
- package/lib/cjs/index.js +29 -24
- package/lib/cjs/index.js.map +1 -1
- package/lib/esm/feature/code-mirror/index.js +27 -22
- package/lib/esm/feature/code-mirror/index.js.map +1 -1
- package/lib/esm/feature/latex/index.js +2 -2
- package/lib/esm/feature/latex/index.js.map +1 -1
- package/lib/esm/index.js +29 -24
- package/lib/esm/index.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types/feature/code-mirror/index.d.ts +2 -15
- package/lib/types/feature/code-mirror/index.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/feature/code-mirror/index.ts +6 -23
- package/src/feature/latex/index.ts +2 -2
|
@@ -1,23 +1,10 @@
|
|
|
1
|
-
import type { LanguageDescription } from '@codemirror/language';
|
|
2
1
|
import type { Extension } from '@codemirror/state';
|
|
2
|
+
import { type CodeBlockConfig } from '@milkdown/kit/component/code-block';
|
|
3
3
|
import type { DefineFeature } from '../shared';
|
|
4
|
-
interface CodeMirrorConfig {
|
|
5
|
-
extensions: Extension[];
|
|
6
|
-
languages: LanguageDescription[];
|
|
4
|
+
interface CodeMirrorConfig extends CodeBlockConfig {
|
|
7
5
|
theme: Extension;
|
|
8
|
-
expandIcon: string;
|
|
9
|
-
searchIcon: string;
|
|
10
|
-
clearSearchIcon: string;
|
|
11
|
-
searchPlaceholder: string;
|
|
12
|
-
copyText: string;
|
|
13
|
-
copyIcon: string;
|
|
14
|
-
onCopy: (text: string) => void;
|
|
15
|
-
noResultText: string;
|
|
16
|
-
renderLanguage: (language: string, selected: boolean) => string;
|
|
17
|
-
renderPreview: (language: string, content: string) => string | HTMLElement | null;
|
|
18
6
|
previewToggleIcon: (previewOnlyMode: boolean) => string;
|
|
19
7
|
previewToggleText: (previewOnlyMode: boolean) => string;
|
|
20
|
-
previewLabel: string;
|
|
21
8
|
}
|
|
22
9
|
export type CodeMirrorFeatureConfig = Partial<CodeMirrorConfig>;
|
|
23
10
|
export declare const codeMirror: DefineFeature<CodeMirrorFeatureConfig>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/feature/code-mirror/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/feature/code-mirror/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAIlD,OAAO,EAGL,KAAK,eAAe,EACrB,MAAM,oCAAoC,CAAA;AAG3C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AAa9C,UAAU,gBAAiB,SAAQ,eAAe;IAChD,KAAK,EAAE,SAAS,CAAA;IAChB,iBAAiB,EAAE,CAAC,eAAe,EAAE,OAAO,KAAK,MAAM,CAAA;IACvD,iBAAiB,EAAE,CAAC,eAAe,EAAE,OAAO,KAAK,MAAM,CAAA;CACxD;AAED,MAAM,MAAM,uBAAuB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAA;AAE/D,eAAO,MAAM,UAAU,EAAE,aAAa,CAAC,uBAAuB,CAiD7D,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@milkdown/crepe",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "7.
|
|
4
|
+
"version": "7.17.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -105,7 +105,7 @@
|
|
|
105
105
|
"remark-math": "^6.0.0",
|
|
106
106
|
"unist-util-visit": "^5.0.0",
|
|
107
107
|
"vue": "^3.5.20",
|
|
108
|
-
"@milkdown/kit": "7.
|
|
108
|
+
"@milkdown/kit": "7.17.0"
|
|
109
109
|
},
|
|
110
110
|
"scripts": {
|
|
111
111
|
"build": "pnpm run build:es && pnpm run build:theme && echo",
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { LanguageDescription } from '@codemirror/language'
|
|
2
1
|
import type { Extension } from '@codemirror/state'
|
|
3
2
|
|
|
4
3
|
import { defaultKeymap, indentWithTab } from '@codemirror/commands'
|
|
@@ -6,6 +5,7 @@ import { keymap } from '@codemirror/view'
|
|
|
6
5
|
import {
|
|
7
6
|
codeBlockComponent,
|
|
8
7
|
codeBlockConfig,
|
|
8
|
+
type CodeBlockConfig,
|
|
9
9
|
} from '@milkdown/kit/component/code-block'
|
|
10
10
|
import { basicSetup } from 'codemirror'
|
|
11
11
|
|
|
@@ -22,32 +22,12 @@ import {
|
|
|
22
22
|
} from '../../icons'
|
|
23
23
|
import { CrepeFeature } from '../index'
|
|
24
24
|
|
|
25
|
-
interface CodeMirrorConfig {
|
|
26
|
-
extensions: Extension[]
|
|
27
|
-
languages: LanguageDescription[]
|
|
25
|
+
interface CodeMirrorConfig extends CodeBlockConfig {
|
|
28
26
|
theme: Extension
|
|
29
|
-
|
|
30
|
-
expandIcon: string
|
|
31
|
-
searchIcon: string
|
|
32
|
-
clearSearchIcon: string
|
|
33
|
-
|
|
34
|
-
searchPlaceholder: string
|
|
35
|
-
copyText: string
|
|
36
|
-
copyIcon: string
|
|
37
|
-
onCopy: (text: string) => void
|
|
38
|
-
noResultText: string
|
|
39
|
-
|
|
40
|
-
renderLanguage: (language: string, selected: boolean) => string
|
|
41
|
-
|
|
42
|
-
renderPreview: (
|
|
43
|
-
language: string,
|
|
44
|
-
content: string
|
|
45
|
-
) => string | HTMLElement | null
|
|
46
|
-
|
|
47
27
|
previewToggleIcon: (previewOnlyMode: boolean) => string
|
|
48
28
|
previewToggleText: (previewOnlyMode: boolean) => string
|
|
49
|
-
previewLabel: string
|
|
50
29
|
}
|
|
30
|
+
|
|
51
31
|
export type CodeMirrorFeatureConfig = Partial<CodeMirrorConfig>
|
|
52
32
|
|
|
53
33
|
export const codeMirror: DefineFeature<CodeMirrorFeatureConfig> = (
|
|
@@ -93,6 +73,9 @@ export const codeMirror: DefineFeature<CodeMirrorFeatureConfig> = (
|
|
|
93
73
|
return [icon, text].map((v) => v.trim()).join(' ')
|
|
94
74
|
},
|
|
95
75
|
previewLabel: config.previewLabel || defaultConfig.previewLabel,
|
|
76
|
+
previewLoading: config.previewLoading || defaultConfig.previewLoading,
|
|
77
|
+
previewOnlyByDefault:
|
|
78
|
+
config.previewOnlyByDefault ?? defaultConfig.previewOnlyByDefault,
|
|
96
79
|
}))
|
|
97
80
|
})
|
|
98
81
|
.use(codeBlockComponent)
|
|
@@ -35,12 +35,12 @@ export const latex: DefineFeature<LatexFeatureConfig> = (editor, config) => {
|
|
|
35
35
|
|
|
36
36
|
ctx.update(codeBlockConfig.key, (prev) => ({
|
|
37
37
|
...prev,
|
|
38
|
-
renderPreview: (language, content) => {
|
|
38
|
+
renderPreview: (language, content, applyPreview) => {
|
|
39
39
|
if (language.toLowerCase() === 'latex' && content.length > 0) {
|
|
40
40
|
return renderLatex(content, config?.katexOptions)
|
|
41
41
|
}
|
|
42
42
|
const renderPreview = prev.renderPreview
|
|
43
|
-
return renderPreview(language, content)
|
|
43
|
+
return renderPreview(language, content, applyPreview)
|
|
44
44
|
},
|
|
45
45
|
}))
|
|
46
46
|
|