@elabs-ai/components-editor 5.0.0 → 5.2.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.
- package/dist/{chunk-FO5S3YZM.js → chunk-VTGYYWGH.js} +21 -4
- package/dist/chunk-VTGYYWGH.js.map +1 -0
- package/dist/index.js +1 -1
- package/dist/markdown/index.js +1 -1
- package/package.json +7 -5
- package/src/markdown-editor/directive-nodes.ts +30 -3
- package/src/markdown-editor/markdown-editor.directives.test.tsx +12 -0
- package/src/markdown-editor/markdown-editor.insert.test.tsx +37 -0
- package/src/markdown-editor/markdown-editor.tsx +9 -3
- package/dist/chunk-FO5S3YZM.js.map +0 -1
|
@@ -1374,8 +1374,23 @@ import { TextSelection } from "@milkdown/kit/prose/state";
|
|
|
1374
1374
|
|
|
1375
1375
|
// src/markdown-editor/directive-nodes.ts
|
|
1376
1376
|
import { $nodeSchema, $remark } from "@milkdown/kit/utils";
|
|
1377
|
-
import
|
|
1378
|
-
|
|
1377
|
+
import { directiveFromMarkdown, directiveToMarkdown } from "mdast-util-directive";
|
|
1378
|
+
import { directive } from "micromark-extension-directive";
|
|
1379
|
+
function remarkBlockDirectives() {
|
|
1380
|
+
const data = this.data();
|
|
1381
|
+
const micromark = data.micromarkExtensions ??= [];
|
|
1382
|
+
const from = data.fromMarkdownExtensions ??= [];
|
|
1383
|
+
const to = data.toMarkdownExtensions ??= [];
|
|
1384
|
+
const { flow } = directive();
|
|
1385
|
+
micromark.push({ flow });
|
|
1386
|
+
from.push(directiveFromMarkdown());
|
|
1387
|
+
const serializer = directiveToMarkdown();
|
|
1388
|
+
serializer.unsafe = (serializer.unsafe ?? []).filter(
|
|
1389
|
+
(rule) => !(rule.character === ":" && rule.inConstruct !== void 0 && !rule.atBreak)
|
|
1390
|
+
);
|
|
1391
|
+
to.push(serializer);
|
|
1392
|
+
}
|
|
1393
|
+
var directiveRemark = $remark("brandDirective", () => remarkBlockDirectives);
|
|
1379
1394
|
var containerDirectiveSchema = $nodeSchema("brand_container_directive", () => ({
|
|
1380
1395
|
content: "block+",
|
|
1381
1396
|
group: "block",
|
|
@@ -2213,6 +2228,7 @@ import { commonmark } from "@milkdown/kit/preset/commonmark";
|
|
|
2213
2228
|
import { gfm } from "@milkdown/kit/preset/gfm";
|
|
2214
2229
|
import { history } from "@milkdown/kit/plugin/history";
|
|
2215
2230
|
import { listener, listenerCtx } from "@milkdown/kit/plugin/listener";
|
|
2231
|
+
import { Slice } from "@milkdown/kit/prose/model";
|
|
2216
2232
|
import { TextSelection as TextSelection3 } from "@milkdown/kit/prose/state";
|
|
2217
2233
|
import { getMarkdown, replaceAll } from "@milkdown/kit/utils";
|
|
2218
2234
|
import { cn as cn8 } from "@elabs-ai/components-ui/lib/cn";
|
|
@@ -3682,7 +3698,8 @@ var MarkdownEditorView = forwardRef6(function MarkdownEditorView2({
|
|
|
3682
3698
|
view.dispatch(view.state.tr.insertText(md));
|
|
3683
3699
|
return;
|
|
3684
3700
|
}
|
|
3685
|
-
const
|
|
3701
|
+
const only = parsed.childCount === 1 ? parsed.firstChild : null;
|
|
3702
|
+
const tr = only && only.type.name === "paragraph" ? view.state.tr.replaceSelection(new Slice(only.content, 0, 0)) : view.state.tr.replaceSelectionWith(parsed);
|
|
3686
3703
|
view.dispatch(tr);
|
|
3687
3704
|
});
|
|
3688
3705
|
} catch {
|
|
@@ -3917,4 +3934,4 @@ export {
|
|
|
3917
3934
|
CopyButton,
|
|
3918
3935
|
monacoContentAccess
|
|
3919
3936
|
};
|
|
3920
|
-
//# sourceMappingURL=chunk-
|
|
3937
|
+
//# sourceMappingURL=chunk-VTGYYWGH.js.map
|