@mdxeditor/editor 3.0.0-alpha.2 → 3.0.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.
|
@@ -7,6 +7,7 @@ var __publicField = (obj, key, value) => {
|
|
|
7
7
|
import { useCellValue } from "@mdxeditor/gurx";
|
|
8
8
|
import { DecoratorNode } from "lexical";
|
|
9
9
|
import React__default from "react";
|
|
10
|
+
import { defaultCodeBlockLanguage$ } from "./index.js";
|
|
10
11
|
import { voidEmitter } from "../../utils/voidEmitter.js";
|
|
11
12
|
import { codeBlockEditorDescriptors$, NESTED_EDITOR_UPDATED_COMMAND } from "../core/index.js";
|
|
12
13
|
class CodeBlockNode extends DecoratorNode {
|
|
@@ -131,7 +132,11 @@ function useCodeBlockEditorContext() {
|
|
|
131
132
|
}
|
|
132
133
|
const CodeBlockEditorContainer = (props) => {
|
|
133
134
|
const codeBlockEditorDescriptors = useCellValue(codeBlockEditorDescriptors$);
|
|
134
|
-
const
|
|
135
|
+
const defaultCodeBlockLanguage = useCellValue(defaultCodeBlockLanguage$);
|
|
136
|
+
let descriptor = codeBlockEditorDescriptors.sort((a, b) => b.priority - a.priority).find((descriptor2) => descriptor2.match(props.language || "", props.meta || ""));
|
|
137
|
+
if (!descriptor) {
|
|
138
|
+
descriptor = codeBlockEditorDescriptors.find((descriptor2) => descriptor2.match(defaultCodeBlockLanguage || "", props.meta || ""));
|
|
139
|
+
}
|
|
135
140
|
if (!descriptor) {
|
|
136
141
|
throw new Error(`No CodeBlockEditor registered for language=${props.language} meta=${props.meta}`);
|
|
137
142
|
}
|