# django-mdeditor
[![ENV](https://img.shields.io/badge/release-v0.1.1-blue.svg)](https://github.com/pylixm/django-mdeditor)
[![ENV](https://img.shields.io/badge/Chinese Docs-v0.1.1-blue.svg)](./README_CN.md)
[![ENV](https://img.shields.io/badge/Gitter-v0.1.1-blue.svg)](https://gitter.im/django-mdeditor/Lobby)
[![ENV](https://img.shields.io/badge/python-2.x/3.x-green.svg)](https://github.com/pylixm/django-mdeditor)
[![ENV](https://img.shields.io/badge/django-1.7+-green.svg)](https://github.com/pylixm/django-mdeditor)
[![LICENSE](https://img.shields.io/badge/license-GPL3.0-green.svg)](https://github.com/pylixm/django-mdeditor/master/LICENSE.txt)
![](./django_and_editor.png)
**Django-mdeditor** is Markdown Editor plugin application for [django](djangoproject.com) base on [Editor.md](https://github.com/pandao/editor.md).
**Django-mdeditor** was inspired by great [django-ckeditor](https://github.com/django-ckeditor/django-ckeditor).
## Features
- Almost Editor.md features
- Support Standard Markdown / CommonMark and GFM (GitHub Flavored Markdown);
- Full-featured: Real-time Preview, Image (cross-domain) upload, Preformatted text/Code blocks/Tables insert, Search replace, Themes, Multi-languages;
- Markdown Extras : Support ToC (Table of Contents), Emoji;
- Support TeX (LaTeX expressions, Based on KaTeX), Flowchart and Sequence Diagram of Markdown extended syntax;
- Can constom Editor.md toolbar
- The MDTextField field is provided for the model and can be displayed directly in the django admin.
- The MDTextFormField is provided for the Form and ModelForm.
- The MDEditorWidget is provided for the Admin custom widget.
## Quick start
- Installation.
```bash
pipenv install django-mdeditor
# or
pip install django-mdeditor
```
- Add `mdeditor` to your INSTALLED_APPS setting like this:
```python
INSTALLED_APPS = [
...
'mdeditor',
]
```
- Add 'media' url to your settings like this:
```python
MEDIA_ROOT = os.path.join(BASE_DIR, 'uploads')
MEDIA_URL = '/media/'
```
Make floder `uploads/editor` in you project for media files.
- Add url to your urls like this:
```python
from django.conf.urls import url, include
from django.conf.urls.static import static
from django.conf import settings
...
urlpatterns = [
...
url(r'mdeditor/', include('mdeditor.urls'))
]
if settings.DEBUG:
# static files (images, css, javascript, etc.)
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
```
- Write your models like this:
```python
from django.db import models
from mdeditor.fields import MDTextField
class ExampleModel(models.Model):
name = models.CharField(max_length=10)
content = MDTextField()
```
- Register your model in `admin.py`
- Run `python manage.py makemigrations` and `python manage.py migrate` to create your models.
- Login Admin ,you can see a markdown editor text field like this:
![](/screenshot/admin-example.png)
## Usage
### Edit fields in the model using Markdown
Using Markdown to edit the fields in the model, we simply replace the `TextField` of the model with` MDTextField`.
```python
from django.db import models
from mdeditor.fields import MDTextField
class ExampleModel (models.Model):
name = models.CharField (max_length = 10)
content = MDTextField ()
```
Admin in the background, will automatically display markdown edit rich text.
Used in front-end template, you can use like this:
```python
{% load staticfiles%}
<! DOCTYPE html>
<html lang = "en">
<head>
<meta http-equiv = "Content-Type" content = "text / html; charset = utf-8" />
</ head>
<body>
<form method = "post" action = "./">
{% csrf_token%}
{{form.media}}
{{form.as_p}}
<p> <input type = "submit" value = "post"> </ p>
</ form>
</ body>
</ html>
```
### Edit fields in the Form using markdown
Use markdown to edit fields in the Form, use `MDTextFormField` instead of` forms.CharField`, as follows:
```python
from mdeditor.fields import MDTextFormField
class MDEditorForm (forms.Form):
name = forms.CharField ()
content = MDTextFormField ()
```
`ModelForm` can automatically convert the corresponding model field to the form field, which can be used normally:
```python
class MDEditorModleForm (forms.ModelForm):
class Meta:
model = ExampleModel
fields = '__all__'
```
### Use the markdown widget in admin
Use the markdown widget in admin like as :
```python
from django.contrib import admin
from django.db import models
# Register your models here.
from. import models as demo_models
from mdeditor.widgets import MDEditorWidget
class ExampleModelAdmin (admin.ModelAdmin):
formfield_overrides = {
models.TextField: {'widget': MDEditorWidget}
}
admin.site.register (demo_models.ExampleModel, ExampleModelAdmin)
```
### Customize the toolbar
Add the following configuration to `settings`:
```python
MDEDITOR_CONFIGS = {
'width': '90% ', # Custom edit box width
'heigth': 500, # Custom edit box height
'toolbar': ["undo", "redo", "|",
"bold", "del", "italic", "quote", "ucwords", "uppercase", "lowercase", "|",
"h1", "h2", "h3", "h5", "h6", "|",
"list-ul", "list-ol", "hr", "|",
"link", "reference-link", "image", "code", "preformatted-text", "code-block", "table", "datetime"
"emoji", "html-entities", "pagebreak", "goto-line", "|",
"help", "info",
"||", "preview", "watch", "fullscreen"], # custom edit box toolbar
'upload_image_formats': ["jpg", "jpeg", "gif", "png", "bmp", "webp"], # image upload format type
'image_floder': 'editor', # image save the folder name
'theme': 'default', # edit box theme, dark / default
'preview_theme': 'default', # Preview area theme, dark / default
'editor_theme': 'default', # edit area theme, pastel-on-dark / default
'toolbar_autofixed': True, # Whether the toolbar capitals
'search_replace': True, # Whether to open the search for replacement
'emoji': True, # whether to open the expression function
'tex': True, # whether to open the tex chart function
'flow_chart': True, # whether to open the flow chart function
'sequence': True # Whether to open the sequence diagram function
}
```
## Feedback
[issue]
Welcome to use and feedback!
## Reference
- [django-ckeditor] (https://github.com/django-ckeditor/django-ckeditor)
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
共403个文件
js:191个
html:100个
css:53个
资源分类:Python库 所属语言:Python 资源全名:django-mdeditor-0.1.2.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
资源推荐
资源详情
资源评论
收起资源包目录
Python库 | django-mdeditor-0.1.2.tar.gz (403个子文件)
AUTHORS 6KB
setup.cfg 38B
editormd.css 81KB
editormd.min.css 60KB
editormd.preview.css 59KB
editormd.preview.min.css 44KB
ambiance.css 26KB
codemirror.css 8KB
codemirror.min.css 5KB
mdn-like.css 5KB
solarized.css 5KB
merge.css 3KB
lint.css 3KB
xq-dark.css 3KB
lesser-dark.css 2KB
pastel-on-dark.css 2KB
xq-light.css 2KB
editormd.logo.css 2KB
tomorrow-night-eighties.css 2KB
erlang-dark.css 2KB
zenburn.css 2KB
style.css 2KB
twilight.css 2KB
midnight.css 2KB
vibrant-ink.css 2KB
mbo.css 2KB
base16-dark.css 2KB
base16-light.css 2KB
tern.css 2KB
3024-night.css 2KB
paraiso-dark.css 2KB
paraiso-light.css 2KB
tomorrow-night-bright.css 2KB
3024-day.css 2KB
blackboard.css 2KB
colorforth.css 2KB
editormd.logo.min.css 2KB
the-matrix.css 2KB
night.css 2KB
rubyblue.css 2KB
monokai.css 1KB
cobalt.css 1KB
simplescrollbars.css 1KB
eclipse.css 1KB
neo.css 932B
elegant.css 768B
neat.css 693B
show-hint.css 662B
dialog.css 502B
tiki.css 440B
foldgutter.css 435B
tiddlywiki.css 220B
matchesonscrollbar.css 188B
fullscreen.css 116B
ambiance-mobile.css 103B
fontawesome-webfont.eot 59KB
editormd-logo.eot 1KB
loading@3x.gif 21KB
loading@2x.gif 16KB
loading.gif 8KB
scala.html 28KB
index.html 22KB
index.html 17KB
index.html 13KB
index.html 13KB
index.html 11KB
index.html 10KB
index.html 9KB
index.html 8KB
index.html 8KB
index.html 7KB
index.html 7KB
index.html 6KB
index.html 6KB
index.html 6KB
index.html 6KB
index.html 6KB
index.html 6KB
index.html 5KB
index.html 5KB
index.html 4KB
index.html 4KB
index.html 4KB
index.html 4KB
index.html 4KB
index.html 4KB
index.html 4KB
less.html 4KB
index.html 4KB
index.html 3KB
index.html 3KB
index.html 3KB
index.html 3KB
index.html 3KB
index.html 3KB
index.html 3KB
index.html 3KB
scss.html 3KB
index.html 3KB
index.html 3KB
共 403 条
- 1
- 2
- 3
- 4
- 5
资源评论
挣扎的蓝藻
- 粉丝: 13w+
- 资源: 15万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 基于GUI+MYSQL+JAVA图书管理系统文档说明+源码(高分大作业项目).zip
- 基于Qt使用C++实现图书管理系统源码+数据库(95分以上).zip
- 基于GUI+MYSQL+JAVA票务管理系统文档介绍+源码+数据库(高分大作业).zip
- 优先编码器除法电微分运算电路 全加器函数发生电路等电路经典Multisim仿真实验源文件合集(25个).zip
- 2331308JS课堂案例.zip
- STM32H750VBT6单片机最小系统开发板AD设计硬件(原理图+PCB+3D封装库)工程文件.zip
- 基于74LS161+ 74LS192芯片实现倒计时定时器Multisim仿真源文件,Multisim10以上版本可打开运行
- 科大讯飞语音引擎 jar包 demo,科大讯飞语音合成引擎3.0,支持4.0系统以上,文字转语音输出.zip
- Java架构面试笔试专题资料及经验(含答案)SpringBoot面试Linux面试专题及答案 合集.zip
- 头歌c语言实验答案tion-model-for-ne开发笔记
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功