django-wysiwyg Documentation



Similar documents
ANGULAR JS SOFTWARE ENGINEERING FOR WEB SERVICES HASAN FAIZAL K APRIL,2014

Edge Animate for Responsive BC Sites

Yandex.Widgets Quick start

JavaScript By: A. Mousavi & P. Broomhead SERG, School of Engineering Design, Brunel University, UK

MASTERTAG DEVELOPER GUIDE

Slide.Show Quick Start Guide

Script Handbook for Interactive Scientific Website Building

Further web design: HTML forms

Spectrum Technology Platform

Client-side Web Engineering From HTML to AJAX

Schenker Privpak AB Telefon VAT Nr. SE Schenker ABs ansvarsbestämmelser, identiska med Box 905 Faxnr Säte: Borås

c. Write a JavaScript statement to print out as an alert box the value of the third Radio button (whether or not selected) in the second form.

Website Implementation

ACCESSING THE PROGRESS OPENEDGE APPSERVER FROM PROGRESS ROLLBASE USING JSDO CODE

Web Development CSE2WD Final Examination June (a) Which organisation is primarily responsible for HTML, CSS and DOM standards?

PLAYER DEVELOPER GUIDE

Getting Started with SitePal

Website Login Integration

LAB 1: Getting started with WebMatrix. Introduction. Creating a new database. M1G505190: Introduction to Database Development

Outline. 1.! Development Platforms for Multimedia Programming!

JavaScript: Arrays Pearson Education, Inc. All rights reserved.

JavaScript: Introduction to Scripting Pearson Education, Inc. All rights reserved.

Intell-a-Keeper Reporting System Technical Programming Guide. Tracking your Bookings without going Nuts!

WebIOPi. Installation Walk-through Macros

JISIS and Web Technologies

JavaScript and Dreamweaver Examples

IMRG Peermap API Documentation V 5.0

The Feed URL is linked on your Module List under the Actions heading.

Implementing Specialized Data Capture Applications with InVision Development Tools (Part 2)

Embedding tracking code into IAS

Copyright by Object Computing, Inc. (OCI). All rights reserved. AngularJS Testing

JavaScript Basics & HTML DOM. Sang Shin Java Technology Architect Sun Microsystems, Inc. sang.shin@sun.com

WebRTC_call. Authorization. function logintowsc() { var wscdemobaseurl = " window.location.href =

the intro for RPG programmers Making mobile app development easier... of KrengelTech by Aaron Bartell

WIRIS quizzes web services Getting started with PHP and Java

Advanced BEx Web Application Designer Concepts. Prakash Darji NetWeaver RIG

JW Player Quick Start Guide

Table of Contents. Overview Supported Platforms Demos/Downloads Known Issues Note Included Files...

Tutorial: Building a Dojo Application using IBM Rational Application Developer Loan Payment Calculator

Chapter 1 Programming Languages for Web Applications

Technical University of Sofia Faculty of Computer Systems and Control. Web Programming. Lecture 4 JavaScript

React+d3.js. Build data visualizations with React and d3.js. Swizec Teller. This book is for sale at

Visualizing a Neo4j Graph Database with KeyLines

CSS Techniques: Scrolling gradient over a fixed background

The purpose of jquery is to make it much easier to use JavaScript on your website.

Overview. In the beginning. Issues with Client Side Scripting What is JavaScript? Syntax and the Document Object Model Moving forward with JavaScript

Visualizing an OrientDB Graph Database with KeyLines

Adform HTML5 Double Expanding Billboard (970x50 > 970x250 > 970x575) PRODUCTION GUIDE

Example. Represent this as XML

Developing an On-Demand Web Report Platform Using Stored Processes and SAS Web Application Server

Django Assess Managed Nicely Documentation

Web Development 1 A4 Project Description Web Architecture

In this tutorial, you learn how to create a new view master page and create a new view content page based on the master page.

T E C H N I C A L D O C U M E N T A T I O N. Intrexx 7.0 Update. Intrexx 7.0

Overview... 2 How to Add New Documents... 3 Adding a Note / SMS or Phone Message... 3 Adding a New Letter How to Create Letter Templates...

Setup The package simply needs to be installed and configured for the desired CDN s distribution server.

How to Deploy Custom Visualizations Using D3 on MSTR 10. Version 1.0. Presented by: Felipe Vilela

Building Ajax Applications with GT.M and EWD. Rob Tweed M/Gateway Developments Ltd

XHTML BASICS. Institute of Finance Management CIT Department Herman Mandari

Making Web Application using Tizen Web UI Framework. Koeun Choi

Cleo Communications. CUEScript Training

Quick Start Guide. This guide will help you get started with Kentico CMS for ASP.NET. It answers these questions:

CarTrawler AJAX Booking Engine Version: 5.10 Date: 01/10/13.

Fortigate SSL VPN 4 With PINsafe Installation Notes

CS412 Interactive Lab Creating a Simple Web Form

Configuring iplanet 6.0 Web Server For SSL and non-ssl Redirect

Fortigate SSL VPN 3.x With PINsafe Installation Notes

Web Development using PHP (WD_PHP) Duration 1.5 months

Word 2010: Mail Merge to with Attachments

Visualization: Combo Chart - Google Chart Tools - Google Code

OS OpenSpace Foundation workshop

Ansible. Configuration management tool and ad hoc solution. Marcel Nijenhof

MillMedia Guidelines

DIPLOMA IN WEBDEVELOPMENT

Data Visualization in Ext Js 3.4

Debugging JavaScript and CSS Using Firebug. Harman Goei CSCI 571 1/27/13

Workshop on Using Open Source Content Management System Drupal to build Library Websites Hasina Afroz Auninda Rumy Saleque

Fireworks 3 Animation and Rollovers

Intro to Web Development

Dynamic Web-Enabled Data Collection

Developer Guide: Hybrid Apps. SAP Mobile Platform 2.3

Internet Technologies

Magento OpenERP Integration Documentation

CSS - Cascading Style Sheets

Transcription:

django-wysiwyg Documentation Release 0.5.1 Daniel Greenfeld, Chris Adams, and contributors August 21, 2016

Contents 1 Installation 3 2 Examples 5 3 Extending django-wysiwyg 7 4 JavaScript API 9 5 Utility functions 11 6 Indices and tables 13 i

ii

django-wysiwyg Documentation, Release 0.5.1 Contents: Contents 1

django-wysiwyg Documentation, Release 0.5.1 2 Contents

CHAPTER 1 Installation in settings.py: INSTALLED_APPS = (... 'django_wysiwyg'... ) Other settings: DJANGO_WYSIWYG_FLAVOR = 'yui' # Default DJANGO_WYSIWYG_FLAVOR = 'ckeditor' # Requires you to also place the ckeditor files here: DJANGO_WYSIWYG_MEDIA_URL = STATIC_URL + "ckeditor/" The following editors are supported out of the box: ckeditor - The CKEditor, formally known as FCKEditor. redactor - The Redactor editor (requires a license). tinymce - The TinyMCE editor, in simple mode. tinymce_advanced - The TinyMCE editor with many more toolbar buttons. yui - The YAHOO editor (the default)> yui_advanced - The YAHOO editor with more toolbar buttons. 1.1 Media sources When you use one of the editors, you need to make sure that the editor distributables are also located in your project. By default django-wysiwyg looks for a STATIC_URL/flavor folder. You can also install django-ckeditor or djangotinymce to have the CKEditor and TinyMCE distributables respectively. django-wysiwyg will automatically find their sources if they are mentioned in the INSTALLED_APPS. It s also possible to add new editors, see extending django-wysiwyg 3

django-wysiwyg Documentation, Release 0.5.1 4 Chapter 1. Installation

CHAPTER 2 Examples Simple template example: {% load wysiwyg %} <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/tr/html4/strict.dtd"> <html lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <title>basic_test</title> {% wysiwyg_setup %} </head> <body> <textarea id="my_text">this is some text. Please edit it</textarea> {% wysiwyg_editor "my_text" %} </body> </html> 5

django-wysiwyg Documentation, Release 0.5.1 6 Chapter 2. Examples

CHAPTER 3 Extending django-wysiwyg The django-wysiwyg module can easily by extended with new editor types. The editor switching in implemented by selecting templates based on the DJANGO_WYSIWYG_FLAVOR setting. Adding an extra editor simply requires these templates to be added: django_wysiwyg/editorname/includes.html django_wysiwyg/editorname/editor_instance.html 3.1 includes.html The includes file will be added to the top of the page, to provide all required scripts. It is loaded by the {% wysiwyg_setup %} code. The template could contain something like: <script type="text/javascript" src="{{ DJANGO_WYSIWYG_MEDIA_URL }}editor.js"></script> <script type="text/javascript" src="{{ DJANGO_WYSIWYG_MEDIA_URL }}sample.css"></script> Secondly, the file has to provide a few JavaScript functions, to implement the JavaScript API This is used for Ajax environments, or interfaces which use a lot of DOM manipulation. The required API functions have the following structure: var django_wysiwyg_editor_configs = []; var django_wysiwyg_editor_config = {}; {% endblock %} // allow custom settings per editor ID{% block django_wysiw var django_wysiwyg = { editors: {}, // where the editor object can be stored. is_loaded: function() { //... some test to see if the scripts were loaded properly. return window.my_editor!= null; }, enable: function(editor_name, field_name, config) { if(!config ) { config = django_wysiwyg_editor_configs[field_id] django_wysiwyg_editor_config; } 7

django-wysiwyg Documentation, Release 0.5.1 }, if(!this.editors[editor_name] ) { this.editors[editor_name] = //... enable the editor for the field name } } disable: function(editor_name) { var editor = this.editors[editor_name]; if( editor ) { editor.the_destroy_function(); //... call the destroy function this.editors[editor_name] = null; } } The enable() function should be able to deal with attempts to enable the editor twice. It should also store the created WYSIWYG editor instance in the this.editors[editor_name] variable. That allows the caller to access the object when it needs to. For more inspiration, you can inspect the files in the django_wysiwyg template directory. 3.2 editor_instance.html The editor-instance template is used to instantiate a single editor statically. It is loaded by the {% wysiwyg_editor fieldname %} line in the template. The contents of the template can look something like: <script type="text/javascript"> (function(){ var config = {{ config }}; django_wysiwyg.enable('{{ editor_name }}', '{{ field_id }}', config); })(); </script> In most cases, this should be enough to instantiate the editor for a specific field. 3.3 Extending existing templates Some templates also provide blocks, that allow them to be extended. For example, the yui_advanced editor, is implemented by extending the yui templates. 8 Chapter 3. Extending django-wysiwyg

CHAPTER 4 JavaScript API To support the needs of more advanced web interfaces, django-wysiwyg provides a JavaScript API. This can be used to enable or disable WYSIWYG editors on demand, for example, because the element was inserted dynamically though DOM manipulation. Every editor type provides the following JavaScript functions: django_wysiwyg.is_loaded() - Whether the external scripts for the editor are loaded. This can be useful for offline-mode, to refrain from updating textarea fields. django_wysiwyg.enable(editor_name, field_name) - Enable an editor for a given field. django_wysiwyg.disable(editor_name) - Disable the editor. django_wysiwyg.editors[editor_name] - Access to the editor object (e.g. the CKEditor, or YUI Editor object). 4.1 Moving WYSIWYG editors in the DOM Most WYSIWYG editors are not built for being moved around in the DOM, and keep referring to old elements in the event handlers. A solution to this problem, is disabling the editor first (which removes all WYSIWYG nodes), and enable it again after moving the containr. 9

django-wysiwyg Documentation, Release 0.5.1 10 Chapter 4. JavaScript API

CHAPTER 5 Utility functions Django-wysiwyg provides a few utility functions to deal with HTML from WYSIWYG editors. Example: from django_wysiwyg.utils import clean_html, sanitize_html print clean_html("<b><i>test</b></i>") print sanitize_html("<b><script>alert(1)</script></b>") 11

django-wysiwyg Documentation, Release 0.5.1 12 Chapter 5. Utility functions

CHAPTER 6 Indices and tables genindex modindex search 13