@jvs-milkdown/crepe 1.2.26 → 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/block-edit/index.js +3 -3
- package/lib/cjs/feature/block-edit/index.js.map +1 -1
- package/lib/cjs/feature/code-mirror/index.js +63 -1
- package/lib/cjs/feature/code-mirror/index.js.map +1 -1
- package/lib/cjs/feature/toolbar/index.js +1 -1
- package/lib/cjs/feature/toolbar/index.js.map +1 -1
- package/lib/cjs/index.js +79 -5
- package/lib/cjs/index.js.map +1 -1
- package/lib/esm/feature/block-edit/index.js +3 -3
- package/lib/esm/feature/block-edit/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/feature/toolbar/index.js +1 -1
- package/lib/esm/feature/toolbar/index.js.map +1 -1
- package/lib/esm/index.js +79 -5
- package/lib/esm/index.js.map +1 -1
- package/lib/theme/common/block-edit.css +5 -3
- package/lib/theme/common/code-mirror.css +19 -0
- package/lib/theme/common/link-tooltip.css +2 -2
- package/lib/theme/common/toolbar.css +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types/default-config/index.d.ts.map +1 -1
- package/lib/types/feature/block-edit/handle/index.d.ts.map +1 -1
- package/lib/types/feature/block-edit/menu/component.d.ts.map +1 -1
- package/lib/types/feature/code-mirror/index.d.ts.map +1 -1
- package/package.json +5 -4
- package/src/default-config/index.ts +17 -1
- package/src/feature/block-edit/handle/index.ts +8 -2
- package/src/feature/block-edit/menu/component.tsx +4 -1
- package/src/feature/code-mirror/index.ts +72 -1
- package/src/theme/common/block-edit.css +5 -3
- package/src/theme/common/code-mirror.css +19 -0
- package/src/theme/common/link-tooltip.css +2 -2
- package/src/theme/common/toolbar.css +1 -1
|
@@ -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":"AAKA,OAAO,EAAgB,KAAK,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAwBlE,eAAO,MAAM,aAAa,EAAE,kBAU3B,CAAA;AAED,eAAO,MAAM,WAAW,GAAI,YAAY,OAAO,CAAC,kBAAkB,CAAC,qDAOlE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/feature/block-edit/handle/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAA;AAehD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/feature/block-edit/handle/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAA;AAehD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAA;AAwRtD,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,GAAG,EACR,MAAM,CAAC,EAAE,sBAAsB,QA2ChC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../../../src/feature/block-edit/menu/component.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAA;AAYhD,OAAO,EAOL,KAAK,GAAG,EAGT,MAAM,KAAK,CAAA;AAEZ,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,IAAI,CAAA;AAwBhD,KAAK,SAAS,GAAG;IACf,GAAG,EAAE,GAAG,CAAA;IACR,IAAI,EAAE,GAAG,CAAC,OAAO,CAAC,CAAA;IAClB,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IACnB,IAAI,EAAE,MAAM,IAAI,CAAA;IAChB,MAAM,CAAC,EAAE,sBAAsB,CAAA;IAC/B,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;CACvB,CAAA;AAED,eAAO,MAAM,IAAI,
|
|
1
|
+
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../../../src/feature/block-edit/menu/component.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAA;AAYhD,OAAO,EAOL,KAAK,GAAG,EAGT,MAAM,KAAK,CAAA;AAEZ,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,IAAI,CAAA;AAwBhD,KAAK,SAAS,GAAG;IACf,GAAG,EAAE,GAAG,CAAA;IACR,IAAI,EAAE,GAAG,CAAC,OAAO,CAAC,CAAA;IAClB,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IACnB,IAAI,EAAE,MAAM,IAAI,CAAA;IAChB,MAAM,CAAC,EAAE,sBAAsB,CAAA;IAC/B,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;CACvB,CAAA;AAED,eAAO,MAAM,IAAI,oWAuxCf,CAAA"}
|
|
@@ -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",
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { LanguageDescription } from '@codemirror/language'
|
|
1
2
|
import { languages } from '@codemirror/language-data'
|
|
2
3
|
import { oneDark } from '@codemirror/theme-one-dark'
|
|
3
4
|
import { mergeWith } from 'lodash-es'
|
|
@@ -11,10 +12,25 @@ import {
|
|
|
11
12
|
visibilityOffIcon,
|
|
12
13
|
} from '../icons'
|
|
13
14
|
|
|
15
|
+
const mermaidLanguage = LanguageDescription.of({
|
|
16
|
+
name: 'Mermaid',
|
|
17
|
+
alias: ['mermaid'],
|
|
18
|
+
load: () => {
|
|
19
|
+
const fallback =
|
|
20
|
+
languages.find((l) => l.name === 'YAML') ||
|
|
21
|
+
languages.find((l) => l.name === 'Markdown')
|
|
22
|
+
return fallback ? fallback.load() : Promise.resolve(null as any)
|
|
23
|
+
},
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
const allLanguages = [mermaidLanguage, ...languages].sort((a, b) =>
|
|
27
|
+
a.name.localeCompare(b.name)
|
|
28
|
+
)
|
|
29
|
+
|
|
14
30
|
export const defaultConfig: CrepeFeatureConfig = {
|
|
15
31
|
[CrepeFeature.CodeMirror]: {
|
|
16
32
|
theme: oneDark,
|
|
17
|
-
languages,
|
|
33
|
+
languages: allLanguages,
|
|
18
34
|
expandIcon: chevronDownIcon,
|
|
19
35
|
searchIcon: searchIcon,
|
|
20
36
|
clearSearchIcon: clearIcon,
|
|
@@ -96,7 +96,10 @@ class BlockHandleView implements PluginView {
|
|
|
96
96
|
node.type.name.includes('math') ||
|
|
97
97
|
hasMediaChild
|
|
98
98
|
const isEmpty =
|
|
99
|
-
node.
|
|
99
|
+
node.type.name === 'paragraph' &&
|
|
100
|
+
node.textContent.length === 0 &&
|
|
101
|
+
node.content.size <= 2 &&
|
|
102
|
+
!isMedia
|
|
100
103
|
if (isEmpty) {
|
|
101
104
|
this.#content.classList.add('empty-block')
|
|
102
105
|
} else {
|
|
@@ -158,7 +161,10 @@ class BlockHandleView implements PluginView {
|
|
|
158
161
|
node.type.name.includes('math') ||
|
|
159
162
|
hasMediaChild
|
|
160
163
|
const isEmpty =
|
|
161
|
-
node.
|
|
164
|
+
node.type.name === 'paragraph' &&
|
|
165
|
+
node.textContent.length === 0 &&
|
|
166
|
+
node.content.size <= 2 &&
|
|
167
|
+
!isMedia
|
|
162
168
|
if (isEmpty) {
|
|
163
169
|
this.#content.classList.add('empty-block')
|
|
164
170
|
} else {
|
|
@@ -685,7 +685,10 @@ export const Menu = defineComponent<MenuProps>({
|
|
|
685
685
|
const showAlign = !isMedia || isImageBlock
|
|
686
686
|
|
|
687
687
|
const isEmpty = node
|
|
688
|
-
? node.
|
|
688
|
+
? node.type.name === 'paragraph' &&
|
|
689
|
+
node.textContent.length === 0 &&
|
|
690
|
+
node.content.size <= 2 &&
|
|
691
|
+
!isMedia
|
|
689
692
|
: false
|
|
690
693
|
|
|
691
694
|
const currentAlign = node?.attrs?.align || 'left'
|
|
@@ -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) ||
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
.milkdown {
|
|
2
|
-
&:has(.milkdown-slash-menu[data-show='true'][data-mode='block'])
|
|
3
|
-
|
|
2
|
+
&:has(.milkdown-slash-menu[data-show='true'][data-mode='block'])
|
|
3
|
+
.milkdown-block-handle,
|
|
4
|
+
&:has(.milkdown-slash-menu[data-show='true'][data-mode='list'])
|
|
5
|
+
.milkdown-block-handle {
|
|
4
6
|
opacity: 1 !important;
|
|
5
7
|
pointer-events: auto !important;
|
|
6
8
|
}
|
|
@@ -107,7 +109,7 @@
|
|
|
107
109
|
}
|
|
108
110
|
|
|
109
111
|
position: absolute;
|
|
110
|
-
z-index:
|
|
112
|
+
z-index: 200;
|
|
111
113
|
display: block;
|
|
112
114
|
font-family: var(--crepe-font-default);
|
|
113
115
|
color: var(--crepe-color-on-surface);
|
|
@@ -334,6 +334,25 @@
|
|
|
334
334
|
.preview {
|
|
335
335
|
text-align: center;
|
|
336
336
|
overflow-x: auto;
|
|
337
|
+
--mermaid-font-family: 'trebuchet ms', verdana, arial, sans-serif;
|
|
338
|
+
|
|
339
|
+
svg * {
|
|
340
|
+
font-family: 'trebuchet ms', verdana, arial, sans-serif !important;
|
|
341
|
+
line-height: normal !important;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
svg .relationshipLabel,
|
|
345
|
+
svg .relationshipLabel *,
|
|
346
|
+
svg .edgeLabel,
|
|
347
|
+
svg .edgeLabel *,
|
|
348
|
+
svg .edgeLabelText,
|
|
349
|
+
svg .edgeLabelText * {
|
|
350
|
+
font-size: 11px !important;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
svg foreignObject {
|
|
354
|
+
overflow: visible !important;
|
|
355
|
+
}
|
|
337
356
|
}
|
|
338
357
|
}
|
|
339
358
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
.milkdown {
|
|
2
2
|
.milkdown-link-preview {
|
|
3
3
|
position: absolute;
|
|
4
|
-
z-index:
|
|
4
|
+
z-index: 200;
|
|
5
5
|
&[data-show='false'] {
|
|
6
6
|
display: none;
|
|
7
7
|
}
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
|
|
72
72
|
.milkdown-link-edit {
|
|
73
73
|
position: absolute;
|
|
74
|
-
z-index:
|
|
74
|
+
z-index: 200;
|
|
75
75
|
&[data-show='false'] {
|
|
76
76
|
display: none;
|
|
77
77
|
}
|