Coder Social home page Coder Social logo

Comments (5)

jaywcjlove avatar jaywcjlove commented on July 20, 2024 1

https://codesandbox.io/p/sandbox/markdown-editor-for-react-598-q2mtp4?file=%2Findex.js%3A1%2C1-42%2C1

import React, { useEffect } from "react";
import ReactDOM from "react-dom";
import MDEditor, { selectWord } from "@uiw/react-md-editor";
// No import is required in the WebPack.
// import "@uiw/react-md-editor/dist/markdown-editor.css";

const mkdStr = `
# Markdown Editor

<input type="text" />

`;

function App() {
  const [value, setValue] = React.useState(mkdStr);
  return (
    <div className="container">
      <MDEditor
        height={200}
        value={value}
        previewOptions={{
          components: {
            input: (props) => {
              return (
                <input
                  {...props}
                  onChange={(ev) => {
                    console.log("xx", ev.target.value);
                  }}
                />
              );
            },
          },
        }}
        onChange={setValue}
      />
    </div>
  );
}

ReactDOM.render(<App />, document.getElementById("container"));

from react-md-editor.

jaywcjlove avatar jaywcjlove commented on July 20, 2024

@SundaramMaheshkumar You can write your own rehype plugin to handle your own strings, like this:

https://github.com/uiwjs/react-markdown-preview/blob/dbbf2566834f15211d9f5d55aa7b7b9601b7e1d9/core/src/plugins/reservedMeta.ts#L1-L15

from react-md-editor.

SundaramMaheshkumar avatar SundaramMaheshkumar commented on July 20, 2024

@jaywcjlove

Thank you. I tried to look into rehype plugins but couldn't figure out how to achieve my use case. Currently, I cannot type or change the value inside that HTML input box in preview. What I want is to allow free typing in those input boxes!

Sorry. Could you please guide me with an example? Thank you so much.

from react-md-editor.

jaywcjlove avatar jaywcjlove commented on July 20, 2024

@SundaramMaheshkumar I don't know what you're going to do, like this:

https://codesandbox.io/p/sandbox/markdown-editor-for-react-598-q2mtp4?file=%2Findex.js%3A28%2C54

from react-md-editor.

SundaramMaheshkumar avatar SundaramMaheshkumar commented on July 20, 2024

Thank you so much @jaywcjlove. That's exactly what I needed.

from react-md-editor.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.