Skip to content

Commit

Permalink
Merge pull request #65 from dheerajaccolite/v3
Browse files Browse the repository at this point in the history
V3
  • Loading branch information
stefanneculai authored Apr 5, 2019
2 parents d63f73c + 96c5261 commit e70b402
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 33 deletions.
19 changes: 0 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,6 @@ When used outside the Django admin, the media files are to be manually included
{{ form.media }}
```

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.

```python
<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" />
<link href="{{STATIC_URL}}froala_editor/css/froala_editor.min.css" type="text/css" media="all" rel="stylesheet" />
<link href="{{STATIC_URL}}froala_editor/css/froala_style.min.css" type="text/css" media="all" rel="stylesheet" />
<script type="text/javascript" src="{{STATIC_URL}}froala_editor/js/froala_editor.min.js"></script>
```

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:

```python
FROALA_INCLUDE_JQUERY = False
```

### Options

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.
Expand Down Expand Up @@ -153,10 +138,6 @@ Use your key for SCAYT Web SpellChecker with `SCAYT_CUSTOMER_ID` in your project

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.

### Include jQuery

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.

### Other Settings

`USE_FROALA_EDITOR` - default True
Expand Down
5 changes: 2 additions & 3 deletions froala_editor/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@ def __init__(self, *args, **kwargs):
self.theme = kwargs.pop('theme', getattr(settings, 'FROALA_EDITOR_THEME', None))
self.plugins = kwargs.pop('plugins', getattr(settings, 'FROALA_EDITOR_PLUGINS', PLUGINS))
self.third_party = kwargs.pop('plugins', getattr(settings, 'FROALA_EDITOR_THIRD_PARTY', THIRD_PARTY))
self.include_jquery = kwargs.pop('include_jquery', getattr(settings, 'FROALA_INCLUDE_JQUERY', True))
self.image_upload = kwargs.pop('image_upload', True)
self.file_upload = kwargs.pop('file_upload', True)
self.use_froala = kwargs.pop('include_jquery', getattr(settings, 'USE_FROALA_EDITOR', True))
self.use_froala = kwargs.pop('', getattr(settings, 'USE_FROALA_EDITOR', True))
super(FroalaField, self).__init__(*args, **kwargs)

def get_internal_type(self):
Expand All @@ -27,7 +26,7 @@ def get_internal_type(self):
def formfield(self, **kwargs):
if self.use_froala:
widget = FroalaEditor(options=self.options, theme=self.theme, plugins=self.plugins,
include_jquery=self.include_jquery, image_upload=self.image_upload,
image_upload=self.image_upload,
file_upload=self.file_upload, third_party=self.third_party)
else:
widget = Textarea()
Expand Down
2 changes: 1 addition & 1 deletion froala_editor/static/froala_editor/js/froala-django.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ function getCookie(name) {
if (document.cookie && document.cookie != '') {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = jQuery.trim(cookies[i]);
var cookie = cookies[i].trim();
// Does this cookie string begin with the name we want?
if (cookie.substring(0, name.length + 1) == (name + '=')) {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
Expand Down
11 changes: 2 additions & 9 deletions froala_editor/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ def __init__(self, *args, **kwargs):
self.plugins = kwargs.pop('plugins', getattr(settings, 'FROALA_EDITOR_PLUGINS', PLUGINS))
self.third_party = kwargs.pop('third_party', getattr(settings, 'FROALA_EDITOR_THIRD_PARTY', THIRD_PARTY))
self.theme = kwargs.pop('theme', getattr(settings, 'FROALA_EDITOR_THEME', None))
self.include_jquery = kwargs.pop('include_jquery', getattr(settings, 'FROALA_INCLUDE_JQUERY', True))
self.image_upload = kwargs.pop('image_upload', True)
self.file_upload = kwargs.pop('file_upload', True)
self.language = (getattr(settings, 'FROALA_EDITOR_OPTIONS', {})).get('language', '')
Expand Down Expand Up @@ -71,23 +70,17 @@ def trigger_froala(self, el_id, options):

str = """
<script>
$(function(){
$('#%s').froalaEditor(%s)
});
new FroalaEditor('#%s',%s)
</script>""" % (el_id, options)
return str

def _media(self):
css = {
'all': ('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.4.0/css/font-awesome.min.css',
'froala_editor/css/froala_editor.min.css', 'froala_editor/css/froala_style.min.css',
'all': ('froala_editor/css/froala_editor.min.css', 'froala_editor/css/froala_style.min.css',
'froala_editor/css/froala-django.css')
}
js = ('froala_editor/js/froala_editor.min.js', 'froala_editor/js/froala-django.js',)

if self.include_jquery:
js = ('https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.0/jquery.min.js',) + js

if self.theme:
css['all'] += ('froala_editor/css/themes/' + self.theme + '.min.css',)

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='django-froala-editor',
version='2.9.3',
version='3.0.0-beta.1',
author='Dipesh Acharya',
author_email='[email protected]',
maintainer='Froala Labs',
Expand Down

0 comments on commit e70b402

Please sign in to comment.