uiwjs / react-md-editor

A simple markdown editor with preview, implemented with React.js and TypeScript.
https://uiwjs.github.io/react-md-editor
MIT License
2.03k stars 149 forks source link

is it possible add embedded youtube video in editor ? #642

Open rasel-stacklearner opened 1 month ago

rasel-stacklearner commented 1 month ago

i want to embed youtube videos in the editor. is it possible now?

jaywcjlove commented 1 month ago

@rasel-stacklearner

Using the remark-oembed plugin allows displaying youtube videos in the preview area.

You can also create a custom plugin to solve your own problem.

rasel-stacklearner commented 1 month ago

@rasel-stacklearner

Using the remark-oembed plugin allows displaying youtube videos in the preview area.

You can also create a custom plugin to solve your own problem.

Can you give me some example codes? and one more thing is it possible to embed "MDX Embed" https://mdx-embed.netlify.app/?path=/docs/introduction--page

jaywcjlove commented 1 month ago

@rasel-stacklearner The recommended plugin doesn't seem to be working. I found a new one that should work.

https://www.npmjs.com/package/remark-youtube

import { useState } from "react";
import MDEditor from "@uiw/react-md-editor";
import "@uiw/react-md-editor/dist/mdeditor.css";
import youtube from "remark-youtube";

const markdown = `Hey this is a nice youtube video about making modern react apps with gatsby:

https://www.youtube.com/watch?v=GN0xHSk2P8Q

Check it out 👆`;

export default function App() {
  const [value, setValue] = useState(markdown);
  return (
    <div>
      <MDEditor
        value={value}
        onChange={setValue}
        previewOptions={{
          remarkPlugins: [[youtube]],
        }}
      />
    </div>
  );
}
rasel-stacklearner commented 1 month ago

@rasel-stacklearner The recommended plugin doesn't seem to be working. I found a new one that should work.

https://www.npmjs.com/package/remark-youtube

import { useState } from "react";
import MDEditor from "@uiw/react-md-editor";
import "@uiw/react-md-editor/dist/mdeditor.css";
import youtube from "remark-youtube";

const markdown = `Hey this is a nice youtube video about making modern react apps with gatsby:

https://www.youtube.com/watch?v=GN0xHSk2P8Q

Check it out 👆`;

export default function App() {
  const [value, setValue] = useState(markdown);
  return (
    <div>
      <MDEditor
        value={value}
        onChange={setValue}
        previewOptions={{
          remarkPlugins: [[youtube]],
        }}
      />
    </div>
  );
}

is there any way to work with it "https://mdx-embed.netlify.app/?path=/docs/introduction--page" ?

jaywcjlove commented 1 month ago

@rasel-stacklearner I'm not sure what you're trying to do. Are you looking to replace the markdown preview area with MDX?

rasel-stacklearner commented 1 month ago

@rasel-stacklearner I'm not sure what you're trying to do. Are you looking to replace the markdown preview area with MDX?

yes. Is it possible? So that i can embed the components of MDX-Embed

rasel-stacklearner commented 1 month ago

@rasel-stacklearner I'm not sure what you're trying to do. Are you looking to replace the markdown preview area with MDX?

@jaywcjlove Basically I want to do something like this =>

image

I try to extend the component functionality with MDX-Embed Component.
image

image