Skip to content

Commit

Permalink
Add Django setting option to customize the button bar with a default …
Browse files Browse the repository at this point in the history
…set in place.
  • Loading branch information
FlipperPA committed May 13, 2017
1 parent f28fe7d commit 4c0804e
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 18 deletions.
69 changes: 62 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,62 @@
/bin
/include
/lib
/lib64
/local
/.tx
/translations
/media

# Python bytecode:
*.py[co]

# Packaging files:
*.egg*

# Sphinx docs:
build

# SQLite3 database files:
*.db

# Logs:
*.log

# Eclipse
.project

# Linux Editors
*~
\#*\#
/.emacs.desktop
/.emacs.desktop.lock
.elc
auto-save-list
tramp
.\#*
*.swp
*.swo

# Mac
.DS_Store
._*

# Windows
Thumbs.db
Desktop.ini

# Dev tools
.idea
.vagrant

# Ignore local configurations
config/settings/local.py
db.sqlite3

# Node modules
node_modules/

# Bower components
bower_components/

# Coverage
htmlcov/
.coverage

# dumpdata file
db.json
/static
/config/settings/user.py
13 changes: 13 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,19 @@ These are configured as a list of menu bars, each containing a list of groups, e

By default, TinyMCE is loaded with buttons for undo/redo, a styles dropdown, bold/italic, lists and tables, link/unlink, Wagtail documents/images/embeds, paste filter toggle and edit fullscreen.

These can be overridden with a Django settings variable:

WAGTAILTINYMCE_BUTTON_LIST = [
['undo', 'redo'],
['styleselect'],
['bold', 'italic'],
['bullist', 'numlist', 'outdent', 'indent'],
['table'],
['link', 'unlink'],
['wagtaildoclink', 'wagtailimage', 'wagtailembed'],
['pastetext', 'fullscreen'],
]

Menu
----

Expand Down
13 changes: 3 additions & 10 deletions wagtailtinymce/rich_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,16 @@
from wagtail.wagtailcore.rich_text import DbWhitelister
from wagtail.wagtailcore.rich_text import expand_db_html

from .settings import get_default_buttons


class TinyMCERichTextArea(WidgetWithScript, widgets.Textarea):

@classmethod
def getDefaultArgs(cls):
return {
'buttons': [
[
['undo', 'redo'],
['styleselect'],
['bold', 'italic'],
['bullist', 'numlist', 'outdent', 'indent'],
['table'],
['link', 'unlink'],
['wagtaildoclink', 'wagtailimage', 'wagtailembed'],
['pastetext', 'fullscreen'],
]
get_default_buttons(),
],
'menus': False,
'options': {
Expand Down
21 changes: 21 additions & 0 deletions wagtailtinymce/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from django.conf import settings


def get_default_buttons():
"""
Return set of buttons for the Django project, or use
the default.
"""

default_button_list = [
['undo', 'redo'],
['styleselect'],
['bold', 'italic'],
['bullist', 'numlist', 'outdent', 'indent'],
['table'],
['link', 'unlink'],
['wagtaildoclink', 'wagtailimage', 'wagtailembed'],
['pastetext', 'fullscreen'],
]

return getattr(settings, 'WAGTAILTINYMCE_BUTTON_LIST', default_button_list)
2 changes: 1 addition & 1 deletion wagtailtinymce/static/wagtailtinymce/js/tinymce-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
var mcePlugins = ['hr', 'code', 'fullscreen', 'noneditable', 'paste', 'table'],
mceTools = ['inserttable'],
mceExternalPlugins = {};

function registerMCEPlugin(name, path, language) {
if (path) {
mceExternalPlugins[name] = path;
Expand All @@ -52,6 +51,7 @@ function makeTinyMCEEditable(id, kwargs) {
$.extend(kwargs, {
selector: '#' + id.toString(),
plugins: mcePlugins,
paste_as_text: true,
tools: mceTools,
external_plugins: mceExternalPlugins,
setup: function (editor) {
Expand Down

0 comments on commit 4c0804e

Please sign in to comment.