Skip to content
This repository has been archived by the owner on Aug 18, 2022. It is now read-only.

初步构想

DZ Chan edited this page Oct 26, 2016 · 1 revision

初步构想

打算手动造轮子,初步构想这个MarkDown编辑器由一下几个部分组成

TextModel -> AST -> Virtual DOM -> DOM

正在考虑 Virtual DOM 步骤是否可以去除,直接从AST 生成DOM

TextModel

采用Chains of lines,那么定位一个字符就用{line, offset}来表示

AST

我们假设有这样的Markdown

# Title

content **bold** something

another line

- list one
- list two
  - sublist one
  - sublist two
- list three

那么我们就会生成如下AST:

Root
 - Title
 - Line
   - Text
   - Bold
   - Text
 - Line
   - Text
 - List
   - Line
   - Line
     - List
       - Line
       - Line
   - Line

遍历AST 生成相应的 Virtual DOM

Clone this wiki locally