Skip to content

Commit

Permalink
[feature] update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
lencyforce committed May 25, 2020
1 parent 2ddca8c commit 5f36545
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 1 deletion.
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,12 +201,25 @@ let websocketEndpoint = "ws://localhost:8080";
editor.syncThroughWebsocket(websocketEndpoint, "examples", "test-doc");

```
***Content display***

The content is stored as Delta in the backend database, which should be converted into
HTML before rendering on a web page. For details please refer to the Development section.

Since Quill uses CSS to implement some of the functions such as [list](https://github.com/quilljs/quill/issues/979).
The relevent CSS rules should also be added to the content displaying page. We extract the
required CSS rules in ```display.styl``` file to be imported in the content displaying page.
Import the file and add a class ```ql-editor``` to the parent element of HTML content to
properly render the content. Check the demo for details.


## Development

There's a demo included in this repository to load the editor,
which could also be used to do the development. The demo is located under ```demo``` directory.

***Load the editor***

Node modules should be installed first:

```bash
Expand All @@ -231,4 +244,20 @@ $ npm start

Now you should be able to see a webpage popup with a loaded editor.

***Display the content***

Since the content is stored in Delta format, it must be converted into HTML before
rendered on a web page. We could use Quill to do the converting. A demo is included
in ```display.js```. Open another browser tab and navigate to:

```
http://127.0.0.1:9001/display.html
```

And you will see a web page with rendered HTML content displayed.

## Contribution

Any kind of contribution is welcome!

Don't hesitate! Submit your PR!
29 changes: 28 additions & 1 deletion README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,22 @@ editor.syncThroughWebsocket(websocketEndpoint, "examples", "test-doc");

```

## Development
***内容加载***

编辑后的内容以Delta的形式存储在后端数据库中,展示前需要使用Quill编辑器转换为HTML。在demo中包含了
HTML转换的示例代码,详情参见后面的开发章节。

由于Quill使用了CSS来实现一些功能,比如[多级嵌套列表](https://github.com/quilljs/quill/issues/979),在展示内容时,
必须把这些CSS同时加载出来,内容才能正确显示。在本项目的```display.styl```样式文件中包含了展示内容时需要
加载的CSS。在展示内容的页面需要加载这个文件,并且在内容的父级元素上添加一个class:```ql-editor```
可以参考demo中的示例代码。

## 开发

开发时可以使用本仓库中包含的demo来启动编辑器进行调试。Demo代码位于```demo```文件夹中。

***加载编辑器***

首先安装npm依赖:

```bash
Expand All @@ -155,4 +167,19 @@ $ npm start

浏览器应该已经自动弹出新窗口,并且加载出了编辑器和测试的内容。

***加载内容***
由于后端存储的内容是Delta格式,在页面上进行展示时,需要转换为HTML格式。我们可以通过Quill编辑器完成
转换。在demo中包含了一个转换内容并展示的页面```display.js``。打开一个新的浏览器窗口并访问:

```
http://127.0.0.1:9001/display.html
```
可以看到转换后的内容。

## 贡献

欢迎任何形式的贡献。

有任何问题,欢迎提交Issue。欢迎提交PR。

加微信交流:lencyforce

0 comments on commit 5f36545

Please sign in to comment.