Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V3 #65

Merged
merged 4 commits into from Apr 5, 2019
Merged

V3 #65

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 0 additions & 19 deletions README.md
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
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
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
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
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='dipesh@awecode.com',
maintainer='Froala Labs',
Expand Down