@jvs-milkdown/crepe 1.2.28 → 1.2.29
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.map +1 -1
- package/lib/cjs/index.js.map +1 -1
- package/lib/esm/feature/code-mirror/index.js.map +1 -1
- package/lib/esm/index.js.map +1 -1
- package/lib/theme/common/reset.css +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types/feature/code-mirror/index.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/feature/code-mirror/index.ts +51 -46
- package/src/theme/common/reset.css +1 -1
|
@@ -1 +1 @@
|
|
|
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,wCAAwC,CAAA;AAG/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AAe9C,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,
|
|
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,wCAAwC,CAAA;AAG/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AAe9C,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,CAoI7D,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jvs-milkdown/crepe",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.29",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"crepe",
|
|
6
6
|
"editor",
|
|
@@ -107,9 +107,9 @@
|
|
|
107
107
|
"@codemirror/theme-one-dark": "^6.1.2",
|
|
108
108
|
"@codemirror/view": "^6.26.0",
|
|
109
109
|
"@floating-ui/dom": "^1.7.6",
|
|
110
|
-
"@jvs-milkdown/kit": "^1.2.
|
|
111
|
-
"@jvs-milkdown/prose": "^1.2.
|
|
112
|
-
"@jvs-milkdown/utils": "^1.2.
|
|
110
|
+
"@jvs-milkdown/kit": "^1.2.29",
|
|
111
|
+
"@jvs-milkdown/prose": "^1.2.29",
|
|
112
|
+
"@jvs-milkdown/utils": "^1.2.29",
|
|
113
113
|
"@types/lodash-es": "^4.17.12",
|
|
114
114
|
"clsx": "^2.0.0",
|
|
115
115
|
"codemirror": "^6.0.1",
|
|
@@ -66,24 +66,29 @@ export const codeMirror: DefineFeature<CodeMirrorFeatureConfig> = (
|
|
|
66
66
|
noResultText:
|
|
67
67
|
config.noResultText || i18n(ctx, 'codeMirror.noResultText'),
|
|
68
68
|
renderLanguage: config.renderLanguage || defaultConfig.renderLanguage,
|
|
69
|
-
renderPreview:
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
69
|
+
renderPreview:
|
|
70
|
+
config.renderPreview ||
|
|
71
|
+
((language, content, applyPreview) => {
|
|
72
|
+
if (
|
|
73
|
+
language.toLowerCase() === 'mermaid' &&
|
|
74
|
+
content.trim().length > 0
|
|
75
|
+
) {
|
|
76
|
+
import('mermaid')
|
|
77
|
+
.then(({ default: mermaid }) => {
|
|
78
|
+
mermaid.initialize({
|
|
79
|
+
startOnLoad: false,
|
|
80
|
+
theme: 'default',
|
|
81
|
+
themeVariables: {
|
|
82
|
+
fontFamily: '"trebuchet ms", verdana, arial, sans-serif',
|
|
83
|
+
},
|
|
84
|
+
})
|
|
80
85
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
86
|
+
if (typeof document !== 'undefined') {
|
|
87
|
+
const styleId = 'mermaid-global-measurement-styles'
|
|
88
|
+
if (!document.getElementById(styleId)) {
|
|
89
|
+
const styleEl = document.createElement('style')
|
|
90
|
+
styleEl.id = styleId
|
|
91
|
+
styleEl.textContent = `
|
|
87
92
|
body,
|
|
88
93
|
.mermaid,
|
|
89
94
|
.relationshipLabel,
|
|
@@ -107,37 +112,37 @@ export const codeMirror: DefineFeature<CodeMirrorFeatureConfig> = (
|
|
|
107
112
|
overflow: visible !important;
|
|
108
113
|
}
|
|
109
114
|
`
|
|
110
|
-
|
|
115
|
+
document.head.appendChild(styleEl)
|
|
116
|
+
}
|
|
111
117
|
}
|
|
112
|
-
}
|
|
113
118
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
119
|
+
const id = `mermaid-${Math.random().toString(36).substring(2, 9)}`
|
|
120
|
+
mermaid
|
|
121
|
+
.render(id, content)
|
|
122
|
+
.then(({ svg }) => {
|
|
123
|
+
applyPreview(svg)
|
|
124
|
+
})
|
|
125
|
+
.catch((e) => {
|
|
126
|
+
const errorEl = document.getElementById(`d${id}`)
|
|
127
|
+
if (errorEl) {
|
|
128
|
+
errorEl.remove()
|
|
129
|
+
}
|
|
130
|
+
applyPreview(
|
|
131
|
+
`<div class="mermaid-error" style="color: red; padding: 10px; font-family: monospace;">${
|
|
132
|
+
e instanceof Error ? e.message : String(e)
|
|
133
|
+
}</div>`
|
|
134
|
+
)
|
|
135
|
+
})
|
|
136
|
+
})
|
|
137
|
+
.catch((err) => {
|
|
138
|
+
applyPreview(
|
|
139
|
+
`<div class="mermaid-error" style="color: red; padding: 10px; font-family: monospace;">Failed to load mermaid: ${err.message}</div>`
|
|
140
|
+
)
|
|
141
|
+
})
|
|
142
|
+
return
|
|
143
|
+
}
|
|
144
|
+
return defaultConfig.renderPreview(language, content, applyPreview)
|
|
145
|
+
}),
|
|
141
146
|
previewToggleButton: (previewOnlyMode) => {
|
|
142
147
|
const icon =
|
|
143
148
|
config.previewToggleIcon?.(previewOnlyMode) ||
|