Skip to content

Commit 2ad44cc

Browse files
committed
Merge branch 'master' of github.com:froala/django-froala-editor
2 parents 743c2fb + bfb493d commit 2ad44cc

File tree

3 files changed

+156
-186
lines changed

3 files changed

+156
-186
lines changed

README.md

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
# Django Froala WYSIWYG Editor
2+
3+
>django-froala-editor package helps integrate [Froala WYSIWYG HTML editor](https://froala.com/wysiwyg-editor/) with Django.
4+
5+
## Getting started
6+
7+
1. Install the package:
8+
9+
`pip install django-froala-editor`
10+
11+
OR
12+
13+
Add the directory `froala_editor` from this repo to your Python path.
14+
15+
1. Add `froala_editor` to INSTALLED_APPS in `settings.py`.
16+
17+
2. Add the following line to `urlpatterns` in your application's `urls.py`.
18+
19+
```python
20+
url(r'^froala_editor/', include('froala_editor.urls')),
21+
```
22+
23+
Skip this url inclusion if you don't want image and file upload inside WYSIWYG editor. Images from URLs can still be embedded.
24+
25+
## Usage
26+
27+
```python
28+
from django.db import models
29+
from froala_editor.fields import FroalaField
30+
31+
class Page(models.Model):
32+
content = FroalaField()
33+
```
34+
35+
`FroalaField` uses `froala_editor.widgets.FroalaEditor` as its widget. You may directly use this widget with any of your forms.py:
36+
37+
```python
38+
from django import forms
39+
from froala_editor.widgets import FroalaEditor
40+
41+
class PageForm(forms.ModelForm):
42+
content = forms.CharField(widget=FroalaEditor)
43+
```
44+
45+
### Usage outside admin
46+
47+
When used outside the Django admin, the media files are to be manually included in the template. Inside the ``<head>`` section or before the form is rendered, include:
48+
49+
```python
50+
{{ form.media }}
51+
```
52+
53+
In case of jQuery conflict (when your project template already has jQuery), you need to include the following files instead of `{{ form.media }}` plus the static files for theme (if not default) and required plugins.
54+
55+
```python
56+
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.4.0/css/font-awesome.min.css" type="text/css" media="all" rel="stylesheet" />
57+
<link href="{{STATIC_URL}}froala_editor/css/froala_editor.min.css" type="text/css" media="all" rel="stylesheet" />
58+
<link href="{{STATIC_URL}}froala_editor/css/froala_style.min.css" type="text/css" media="all" rel="stylesheet" />
59+
<script type="text/javascript" src="{{STATIC_URL}}froala_editor/js/froala_editor.min.js"></script>
60+
```
61+
62+
Or simply, you may use the following in your `settings.py` if you don't want Froala to include jQuery by itself, thus preventing any conflicts:
63+
64+
```python
65+
FROALA_INCLUDE_JQUERY = False
66+
```
67+
68+
### Options
69+
70+
Froala Editor provides several options for customizing the editor. See [https://froala.com/wysiwyg-editor/docs](https://froala.com/wysiwyg-editor/docs) for all available options.
71+
You can provide a dictionary of these options as `FROALA_EDITOR_OPTIONS` setting in `settings.py`. These options would then be used for all instances of the WYSIWYG editor in the project.
72+
73+
Options for individual field can also be provided via `FroalaField` or `FroalaEditor` class. This overrides any options set via `FROALA_EDITOR_OPTIONS`:
74+
75+
```python
76+
from django.db import models
77+
from froala_editor.fields import FroalaField
78+
79+
class Page(models.Model):
80+
content = FroalaField(options={
81+
'toolbarInline': True,
82+
})
83+
```
84+
85+
```python
86+
from django import forms
87+
from froala_editor.widgets import FroalaEditor
88+
89+
class PageForm(forms.ModelForm):
90+
content = forms.TextField(widget=FroalaEditor(options={
91+
'toolbarInline': True,
92+
}))
93+
```
94+
95+
### Theme
96+
97+
You may provide the name of the theme to be used as `theme` argument to `FroalaField` or `FroalaEditor`.
98+
99+
```python
100+
from django.db import models
101+
from froala_editor.fields import FroalaField
102+
103+
class Page(models.Model):
104+
content = FroalaField(theme='dark')
105+
```
106+
107+
`FROALA_EDITOR_THEME` can be set in `settings.py` making all instances of the editor to use a theme. However, `theme` argument in `FroalaField` and `FroalaEditor` overrides `FROALA_EDITOR_THEME`. Using a theme named 'dark' would require the existence of the file `froala_editor/static/froala_editor/css/themes/dark.min.css`. Available themes are: 'dark', 'gray' and 'red'.
108+
109+
### Plugins
110+
111+
Froala Editor comes with the plugins: block style, text & background colors, font size, font family, insert video, insert table, media manager, lists and file upload. By default, all plugins are enabled by default in this package. See [https://froala.com/wysiwyg-editor/docs/plugins](<https://froala.com/wysiwyg-editor/docs/plugins>) for all available plugins.
112+
113+
`FROALA_EDITOR_PLUGINS` can be set in `settings.py` to tell which plugins should all instances of Froala Editor be using. By default, it is
114+
115+
```python
116+
FROALA_EDITOR_PLUGINS = ('align', 'char_counter', 'code_beautifier' ,'code_view', 'colors', 'draggable', 'emoticons',
117+
'entities', 'file', 'font_family', 'font_size', 'fullscreen', 'image_manager', 'image', 'inline_style',
118+
'line_breaker', 'link', 'lists', 'paragraph_format', 'paragraph_style', 'quick_insert', 'quote', 'save', 'table',
119+
'url', 'video')
120+
```
121+
122+
The usage of `plugins` argument with `FroalaEditor` or `FroalaField` overrides this for that particular instance.
123+
124+
```python
125+
from django.db import models
126+
from froala_editor.fields import FroalaField
127+
128+
class Page(models.Model):
129+
content = FroalaField(plugins=('font_size', 'font_family'))
130+
```
131+
132+
### Image upload
133+
134+
`FroalaEditor` and `FroalaField` optionally take in a boolean value for `image_upload` argument to enable or disable image uploads. Image uploads are enabled by default if the urls of this package are included in your urls.py.
135+
136+
You can use `FROALA_UPLOAD_PATH` setting in `settings.py` to change the path where uploaded files are stored within the `MEDIA_ROOT`. By default, `uploads/froala_editor/images` is used for storing uploaded images.
137+
138+
### Include jQuery
139+
140+
jQuery is included by default in form media. If you don't want to include jQuery, you may pass `include_jquery=False` to `FroalaEditor` or `FroalaField`. `FROALA_INCLUDE_JQUERY` can be also set in `settings.py` for project wide effects.
141+
142+
## License
143+
144+
This package is available under BSD License. However, in order to use Froala WYSIWYG HTML Editor plugin you should purchase a license for it.
145+
146+
See [https://froala.com/wysiwyg-editor/pricing](https://froala.com/wysiwyg-editor/pricing) for licensing the Froala Editor.
147+
148+
If you bought a license and got your key, the easiest way to implement it is to put it into the `FROALA_EDITOR_OPTIONS` setting in `settings.py`:
149+
150+
```python
151+
FROALA_EDITOR_OPTIONS = {
152+
'key': '<our key goes here>',
153+
# other options
154+
# ...
155+
}

README.rst

Lines changed: 0 additions & 185 deletions
This file was deleted.

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
url='http://github.com/froala/django-froala-editor/',
1212
license='BSD License',
1313
description='django-froala-editor package helps integrate Froala WYSIWYG HTML editor with Django.',
14-
long_description=open('README.rst').read(),
14+
long_description=open('README.md').read(),
1515
include_package_data=True,
1616
zip_safe=False,
1717
keywords='froala,django,admin,wysiwyg,editor,text,html,editor,rich, web',

0 commit comments

Comments
 (0)