Bytemd Markdown 文本编辑器 Demo

官方网站 https://bytemd.js.org/

  • 约 7 分钟
  • 1,834 字
YAML
# frontmatter: https://jekyllrb.com/docs/front-matter/
layout: post
title: Blogging Like a Hacker

Markdown Basic Syntax

I just love bold text. Italicized text is the cat's meow. At the command prompt, type nano.
My favorite markdown editor is ByteMD.
  1. First item
  2. Second item
  3. Third item
Dorothy followed her through many of the beautiful rooms in her castle.
JavaScript
import gfm from '@bytemd/plugin-gfm'
import { Editor, Viewer } from 'bytemd'

const plugins = [
  gfm(),
  // Add more plugins here
]

const editor = new Editor({
  target: document.body, // DOM to render
  props: {
    value: '',
    plugins,
  },
})

editor.on('change', (e) => {
  editor.$set({ value: e.detail.value })
})

GFM Extended Syntax

The world is flat. We now know that the world is round.
  • Write the press release
  • Update the website
  • Contact the media
Syntax
Description
Header
Title
Paragraph
Text

Footnotes

Here's a simple footnote,[1] and here's a longer one.[bignote]
[1]
This is the first footnote.
[bignote]
Here's one with multiple paragraphs and code.
Indent paragraphs to include them in the footnote.
{ my code }
Add as many paragraphs as you like.

Gemoji

Thumbs up: :+1:, thumbs down: :-1:.
Families: :family_man_man_boy_boy:
Long flags: :wales:, :scotland:, :england:.

Math Equation

Inline math equation: a+ba+b
(∑k=1nakbk)2≤(∑k=1nak2)(∑k=1nbk2)\displaystyle \left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right)

Mermaid Diagrams

graph TD
mermaid
graph TD
Start --> Stop
sequenceDiagram
mermaid
sequenceDiagram
Alice->>John: Hello John, how are you?
John-->>Alice: Great!
Alice-)John: See you later!
classDiagram
mermaid
classDiagram
Animal <|-- Duck
Animal <|-- Fish
Animal <|-- Zebra
Animal : +int age
Animal : +String gender
Animal: +isMammal()
Animal: +mate()
class Duck{
+String beakColor
+swim()
+quack()
}
class Fish{
-int sizeInFeet
-canEat()
}
class Zebra{
+bool is_wild
+run()
}
stateDiagram-v2
mermaid
stateDiagram-v2
[*] --> Still
Still --> [*]

Still --> Moving
Moving --> Still
Moving --> Crash
Crash --> [*]
erDiagram
mermaid
erDiagram
CUSTOMER ||--o{ ORDER : places
ORDER ||--|{ LINE-ITEM : contains
CUSTOMER }|..|{ DELIVERY-ADDRESS : uses
journey
mermaid
journey
title My working day
section Go to work
Make tea: 5: Me
Go upstairs: 3: Me
Do work: 1: Me, Cat
section Go home
Go downstairs: 5: Me
Sit down: 5: Me
gantt
mermaid
gantt
title A Gantt Diagram
dateFormat  YYYY-MM-DD
section Section
A task           :a1, 2014-01-01, 30d
Another task     :after a1  , 20d
section Another
Task in sec      :2014-01-12  , 12d
another task      : 24d
pie title Pets adopted by volunteers
mermaid
pie title Pets adopted by volunteers
"Dogs" : 386
"Cats" : 85
"Rats" : 15
mermaid
graph TD;
  A-->B;
  A-->C;
  B-->D;
  C-->D;

评论栏

分享你的想法,或参与下面的讨论。

参与讨论

支持 Markdown、代码和图片

撰写评论
正在加载编辑器…

友善交流,让讨论更有价值。

更多留言

加载中…