Vditor Markdown Editor

repository·master·Indexed 11 days ago

https://github.com/vanessa219/vditor

A versatile, browser-based Markdown editor implemented in TypeScript. It supports three editing modes—WYSIWYG, Instant Rendering (IR), and Split-screen (SV)—and integrates with Vue, React, Angular, and Svelte. Vditor features extensive syntax support including CommonMark, GFM, Mermaid diagrams, MathJax/KaTeX, ECharts, and WaveDrom. Version 3.11.3 provides a rich feature set with multi-theme switching, multi-language support, and customizable toolbars.

Tokens
13.8K
Snippets
44
Records
65
Agent score
95%

What's inside Vditor

  1. Overview of Vditor features and capabilities

    master
    Vditor is a browser-side Markdown editor built with TypeScript. It is designed to adapt to various application scenarios by providing three distinct editing modes. It supports modern Markdown specifications (CommonMark and GFM) and includes extensive support for advanced syntax like mathematical formulas, charts, and mind maps. It is compatible with native JavaScript and major frameworks including Vue, React, Angular, and Svelte.
  2. Overview of Vditor Markdown Editor

    master

    Vditor is a browser-based Markdown editor designed to adapt to various application scenarios. It is implemented in TypeScript and supports integration with native JavaScript as well as modern frameworks like Vue, React, Angular, and Svelte.

    Key capabilities include:

    • Three Editing Modes: WYSIWYG (What You See Is What You Get), IR (Instant Rendering), and SV (Split-screen Preview).
    • Extensive Syntax Support: CommonMark and GFM specifications, plus extensions like Mermaid diagrams, MathJax/KaTeX for math, ECharts for charts, and WaveDrom for digital waveforms.
    • Rich Feature Set: Outline support, mind maps, task lists, image lazy loading, multi-theme switching (Black, White, Green), and multi-language support (Chinese, English, Korean).
  3. Configure Vditor Editor Themes

    master

    Vditor supports different themes for the editor, the rendered content, and code blocks.

    Editor Themes

    Built-in themes: classic, dark.

    • Set via options.theme during initialization.
    • Update via setTheme() after initialization.
    • Customize by modifying variables in index.less.

    Content Themes

    Applies to the HTML output of Markdown. Built-in themes: ant-design, light, dark, wechat.

    • Requirement: The display element must have class="vditor-reset".
    • Set via options.preview.theme during initialization.
    • Update via setTheme() or setContentTheme().

    Code Block Themes

    Built-in themes: github and 36 others.

    • Set via options.preview.hljs during initialization.
    • Update via setTheme() or setCodeTheme().
  4. Vditor Syntax and Extension Support

    master

    Vditor supports a wide array of Markdown syntaxes and specialized extensions:

    Core Specifications

    • CommonMark: Full support for headers, code blocks, HTML blocks, lists, emphasis, links, images, etc.
    • GFM (GitHub Flavored Markdown): Tables, task lists, strikethrough, and auto-links.

    Specialized Extensions

    • Diagrams & Charts:
      • Flowcharts, Sequence diagrams, and Gantt charts via Mermaid.
      • Graphviz rendering.
      • Line charts, Pie charts, and Mind maps via ECharts.
      • Digital waveforms via WaveDrom.
      • UML diagrams via PlantUML.
    • Mathematics: Math blocks and inline math via MathJax and KaTeX.
    • Music: Sheet music via abc.js.
    • Other:
      • YAML Front Matter.
      • Footnotes and Table of Contents (ToC).
      • Chinese context optimizations (e.g., automatic spacing between Chinese and English characters).
  5. Understand Vditor editing modes

    master

    Vditor provides three modes to suit different user preferences and application needs:

    1. WYSIWYG (wysiwyg): A rich-text style mode friendly to users unfamiliar with Markdown, while remaining seamless for experienced users.
    2. Instant Rendering (ir): An elegant mode similar to Typora, where Markdown is rendered immediately as you type.
    3. Split View (sv): A traditional mode where the editing area and the preview area are separated, ideal for large-screen typesetting.

    Most features associated with these modes can be enabled or disabled via configuration switches.

  6. Understand Vditor's three editing modes

    master

    Vditor provides three distinct modes to cater to different user expertise and screen real estate:

    1. WYSIWYG (What You See Is What You Get): Best for users unfamiliar with Markdown syntax. It provides a rich-text-like experience where formatting is applied immediately.
    2. IR (Instant Rendering): Designed for advanced Markdown users (similar to Typora). It provides an elegant experience where the syntax is rendered into its visual form as you type.
    3. SV (Split-screen Preview): The traditional Markdown approach. It features a separate editing area and a preview area, which is ideal for large screens and traditional layout workflows.
  7. Configure Vditor themes

    master

    Vditor supports four theme sets: and-design, classic, dark, and wechat.

    • You can customize styles using Less/CSS.
    • Theme colors can be modified by changing variables in index.less.
    • To display content more effectively, add class="vditor-reset" (for classic theme) or class="vditor-reset vditor-reset--dark" (for dark theme) to the content display element.
  8. Markdown Syntax Guide for Vditor

    master

    Vditor supports a wide range of Markdown syntax for rich text editing. Key features include:

    • Basic Formatting: Bold (**text**), Italics (*text*), Strikethrough (~~text~~), and Inline Code (`code`).
    • Links: Standard hyperlinks [text](url "title") and reference-style links [text][ref] with [ref]: url definitions.
    • Mentions: Use @username to mention users (requires a space after the username).
    • Emojis: Support for standard emojis via : syntax (e.g., :smile:). Custom emoji sets can be pre-registered in settings.
    • Headings: Supports H1 through H6 using # syntax. Note: A space is required after the # character. It is recommended to use H3 or lower for post content to avoid conflicting with site-level H1/H2.
    • Lists: Supports unordered lists, ordered lists, and task checkboxes (- [x], - [ ]).
    • Tables: Standard Markdown table syntax.
    • Footnotes: Use [^1] for references and [^1]: definition for the footnote content.
    • Details/Summary: HTML <details> and <summary> tags for collapsible content.
    - **bold**
    - *italic*
    - ~~strikethrough~~
    - `code tag`
    - [hyperlink](https://www.google.com "google")
    - [^1]
    [^1]: Footnote definition.
  9. Set up a local development environment

    master

    To develop on Vditor, ensure you have the Node.js LTS version installed. Follow these steps to run the project locally:

    1. Download and unzip the latest source code.
    2. Run npm install in the root directory to install dependencies.
    3. Run npm run start to launch a local server at http://localhost:9000.
    4. After making modifications, run npm run build to package the code into the dist directory.
    npm install
    npm run start
    npm run build
  10. Initialize Vditor in CommonJS/TypeScript

    master

    Import Vditor and its associated styles, then instantiate it by passing an element ID and an options object.

    import Vditor from 'vditor'
    import "~vditor/src/assets/less/index"
    
    const vditor = new Vditor(id, {options...})