JSPM

@mfyz/markdown-editor-with-custom-directives

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 85
  • Score
    100M100P100Q76545F
  • License MIT

A React markdown editor with custom color and button directives

Package Exports

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@mfyz/markdown-editor-with-custom-directives) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    Markdown Editor with Custom Directives

    A React markdown editor with custom directives for colored text and styled buttons.

    Features

    • Full-featured markdown editor with preview
    • Custom directives for colored text and styled buttons
    • Dual-pane layout with live preview
    • Toolbar with formatting options
    • Responsive design

    Installation

    npm install @mfyz/markdown-editor-with-custom-directives

    Usage

    Editor Component

    import { MarkdownEditor } from '@mfyz/markdown-editor-with-custom-directives'
    import '@mfyz/markdown-editor-with-custom-directives/dist/styles/index.css'
    
    function App() {
      const [markdown, setMarkdown] = useState('# Hello World')
    
      return (
        <div className="app">
          <MarkdownEditor
            content={markdown}
            onChange={setMarkdown}
            placeholder="Start writing..."
            allowSourceView={true}
          />
        </div>
      )
    }

    Renderer Component

    If you only need to render markdown with the custom directives:

    import { MarkdownRenderer } from '@mfyz/markdown-editor-with-custom-directives'
    import '@mfyz/markdown-editor-with-custom-directives/dist/styles/index.css'
    
    function MarkdownDisplay({ content }) {
      return (
        <div className="markdown-display">
          <MarkdownRenderer content={content} />
        </div>
      )
    }

    Custom Directives

    Color Directive

    Format: :color[text]{#hexcolor}

    Example:

    This is :color[colored text]{#ff0000}.

    Button Directive

    Format: :button[button text]{url="https://example.com" shape="pill" color="blue"}

    Available shapes: pill, rounded, rect Available colors: purple, blue, green, red, yellow, gray, black

    Example:

    Click this :button[Button]{url="https://example.com" shape="pill" color="blue"}.

    API Reference

    MarkdownEditor Props

    Prop Type Description
    content string The markdown content
    onChange function Callback when content changes
    placeholder string Placeholder text when editor is empty (default: 'Write something...')
    className string Additional CSS class
    allowSourceView boolean Whether to allow switching to source view (default: true)
    singleLineMode boolean Whether to restrict editor to a single line (default: false)

    MarkdownRenderer Props

    Prop Type Description
    content string The markdown content to render
    className string Additional CSS class

    License

    MIT