@jvs-milkdown/crepe 1.2.27 → 1.2.28
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 +63 -1
- package/lib/cjs/feature/code-mirror/index.js.map +1 -1
- package/lib/cjs/index.js +63 -1
- package/lib/cjs/index.js.map +1 -1
- package/lib/esm/feature/code-mirror/index.js +63 -1
- package/lib/esm/feature/code-mirror/index.js.map +1 -1
- package/lib/esm/index.js +63 -1
- package/lib/esm/index.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types/feature/code-mirror/index.d.ts.map +1 -1
- package/package.json +5 -4
- package/src/feature/code-mirror/index.ts +72 -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,CA+H7D,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.28",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"crepe",
|
|
6
6
|
"editor",
|
|
@@ -107,15 +107,16 @@
|
|
|
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.28",
|
|
111
|
+
"@jvs-milkdown/prose": "^1.2.28",
|
|
112
|
+
"@jvs-milkdown/utils": "^1.2.28",
|
|
113
113
|
"@types/lodash-es": "^4.17.12",
|
|
114
114
|
"clsx": "^2.0.0",
|
|
115
115
|
"codemirror": "^6.0.1",
|
|
116
116
|
"diff": "^9.0.0",
|
|
117
117
|
"katex": "^0.16.0",
|
|
118
118
|
"lodash-es": "^4.17.21",
|
|
119
|
+
"mermaid": "^11.15.0",
|
|
119
120
|
"prosemirror-virtual-cursor": "^0.4.2",
|
|
120
121
|
"remark-math": "^6.0.0",
|
|
121
122
|
"unist-util-visit": "^5.0.0",
|
|
@@ -66,7 +66,78 @@ 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: config.renderPreview ||
|
|
69
|
+
renderPreview: config.renderPreview || ((language, content, applyPreview) => {
|
|
70
|
+
if (language.toLowerCase() === 'mermaid' && content.trim().length > 0) {
|
|
71
|
+
import('mermaid')
|
|
72
|
+
.then(({ default: mermaid }) => {
|
|
73
|
+
mermaid.initialize({
|
|
74
|
+
startOnLoad: false,
|
|
75
|
+
theme: 'default',
|
|
76
|
+
themeVariables: {
|
|
77
|
+
fontFamily: '"trebuchet ms", verdana, arial, sans-serif',
|
|
78
|
+
},
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
if (typeof document !== 'undefined') {
|
|
82
|
+
const styleId = 'mermaid-global-measurement-styles'
|
|
83
|
+
if (!document.getElementById(styleId)) {
|
|
84
|
+
const styleEl = document.createElement('style')
|
|
85
|
+
styleEl.id = styleId
|
|
86
|
+
styleEl.textContent = `
|
|
87
|
+
body,
|
|
88
|
+
.mermaid,
|
|
89
|
+
.relationshipLabel,
|
|
90
|
+
.edgeLabel,
|
|
91
|
+
.edgeLabelText,
|
|
92
|
+
.label,
|
|
93
|
+
.nodeLabel,
|
|
94
|
+
svg * {
|
|
95
|
+
font-family: "trebuchet ms", verdana, arial, sans-serif !important;
|
|
96
|
+
line-height: normal !important;
|
|
97
|
+
}
|
|
98
|
+
.relationshipLabel,
|
|
99
|
+
.relationshipLabel *,
|
|
100
|
+
.edgeLabel,
|
|
101
|
+
.edgeLabel *,
|
|
102
|
+
.edgeLabelText,
|
|
103
|
+
.edgeLabelText * {
|
|
104
|
+
font-size: 11px !important;
|
|
105
|
+
}
|
|
106
|
+
svg foreignObject {
|
|
107
|
+
overflow: visible !important;
|
|
108
|
+
}
|
|
109
|
+
`
|
|
110
|
+
document.head.appendChild(styleEl)
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const id = `mermaid-${Math.random().toString(36).substring(2, 9)}`
|
|
115
|
+
mermaid
|
|
116
|
+
.render(id, content)
|
|
117
|
+
.then(({ svg }) => {
|
|
118
|
+
applyPreview(svg)
|
|
119
|
+
})
|
|
120
|
+
.catch((e) => {
|
|
121
|
+
const errorEl = document.getElementById(`d${id}`)
|
|
122
|
+
if (errorEl) {
|
|
123
|
+
errorEl.remove()
|
|
124
|
+
}
|
|
125
|
+
applyPreview(
|
|
126
|
+
`<div class="mermaid-error" style="color: red; padding: 10px; font-family: monospace;">${
|
|
127
|
+
e instanceof Error ? e.message : String(e)
|
|
128
|
+
}</div>`
|
|
129
|
+
)
|
|
130
|
+
})
|
|
131
|
+
})
|
|
132
|
+
.catch((err) => {
|
|
133
|
+
applyPreview(
|
|
134
|
+
`<div class="mermaid-error" style="color: red; padding: 10px; font-family: monospace;">Failed to load mermaid: ${err.message}</div>`
|
|
135
|
+
)
|
|
136
|
+
})
|
|
137
|
+
return
|
|
138
|
+
}
|
|
139
|
+
return defaultConfig.renderPreview(language, content, applyPreview)
|
|
140
|
+
}),
|
|
70
141
|
previewToggleButton: (previewOnlyMode) => {
|
|
71
142
|
const icon =
|
|
72
143
|
config.previewToggleIcon?.(previewOnlyMode) ||
|