@jvs-milkdown/crepe 1.2.26 → 1.2.27

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/esm/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { replaceAll, $prose as $prose$1, getHTML } from '@jvs-milkdown/utils';
2
2
  import { defaultsDeep } from 'lodash-es';
3
+ import { LanguageDescription } from '@codemirror/language';
3
4
  import { languages } from '@codemirror/language-data';
4
5
  import { oneDark } from '@codemirror/theme-one-dark';
5
6
  import { createSlice } from '@jvs-milkdown/kit/ctx';
@@ -675,10 +676,21 @@ const importIcon = `
675
676
  </svg>
676
677
  `;
677
678
 
679
+ const mermaidLanguage = LanguageDescription.of({
680
+ name: "Mermaid",
681
+ alias: ["mermaid"],
682
+ load: () => {
683
+ const fallback = languages.find((l) => l.name === "YAML") || languages.find((l) => l.name === "Markdown");
684
+ return fallback ? fallback.load() : Promise.resolve(null);
685
+ }
686
+ });
687
+ const allLanguages = [mermaidLanguage, ...languages].sort(
688
+ (a, b) => a.name.localeCompare(b.name)
689
+ );
678
690
  const defaultConfig = {
679
691
  [CrepeFeature.CodeMirror]: {
680
692
  theme: oneDark,
681
- languages,
693
+ languages: allLanguages,
682
694
  expandIcon: chevronDownIcon,
683
695
  searchIcon,
684
696
  clearSearchIcon: clearIcon,
@@ -3064,7 +3076,7 @@ const Menu = defineComponent({
3064
3076
  const isTableBlock = (node == null ? void 0 : node.type.name) === "table";
3065
3077
  const isMedia = ((_a = node == null ? void 0 : node.type.name) == null ? void 0 : _a.includes("image")) || isAttachmentBlock || isImageParagraph || (node == null ? void 0 : node.type.name) === "hr" || isTableBlock;
3066
3078
  const showAlign = !isMedia || isImageBlock;
3067
- const isEmpty = node ? node.textContent.length === 0 && node.content.size <= 2 && !isMedia : false;
3079
+ const isEmpty = node ? node.type.name === "paragraph" && node.textContent.length === 0 && node.content.size <= 2 && !isMedia : false;
3068
3080
  const currentAlign = ((_b = node == null ? void 0 : node.attrs) == null ? void 0 : _b.align) || "left";
3069
3081
  const currentIndent = ((_c = node == null ? void 0 : node.attrs) == null ? void 0 : _c.indent) || 0;
3070
3082
  const setAlign = (alignValue) => {
@@ -4020,7 +4032,7 @@ class BlockHandleView {
4020
4032
  });
4021
4033
  }
4022
4034
  const isMedia = node.type.name.includes("image") || node.type.name.includes("attachment") || node.type.name === "hr" || node.type.name.includes("math") || hasMediaChild;
4023
- const isEmpty = node.textContent.length === 0 && node.content.size <= 2 && !isMedia;
4035
+ const isEmpty = node.type.name === "paragraph" && node.textContent.length === 0 && node.content.size <= 2 && !isMedia;
4024
4036
  if (isEmpty) {
4025
4037
  __privateGet$5(this, _content$3).classList.add("empty-block");
4026
4038
  } else {
@@ -4171,7 +4183,7 @@ class BlockHandleView {
4171
4183
  });
4172
4184
  }
4173
4185
  const isMedia = node.type.name.includes("image") || node.type.name.includes("attachment") || node.type.name === "hr" || node.type.name.includes("math") || hasMediaChild;
4174
- const isEmpty = node.textContent.length === 0 && node.content.size <= 2 && !isMedia;
4186
+ const isEmpty = node.type.name === "paragraph" && node.textContent.length === 0 && node.content.size <= 2 && !isMedia;
4175
4187
  if (isEmpty) {
4176
4188
  __privateGet$5(this, _content$3).classList.add("empty-block");
4177
4189
  } else {