README.txt 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  1. TABLE OF CONTENTS
  2. -----------------
  3. * Overview
  4. * More Information and License
  5. * Requirements
  6. * Installation Paths
  7. * Installation / Configuration
  8. * Installation Troubleshooting
  9. * Uploading Images and Files
  10. * Installing CKFinder
  11. * Managing Plugins
  12. * Installing Additional Plugins
  13. * Integrating a Plugin with the CKEditor Module (for Plugin Developers)
  14. * Setting up Security Filters
  15. * HTML Filters and Inline Styling
  16. * Integrating a Custom Security Filter with the CKEditor Module (for Developers)
  17. * Upgrading Instructions
  18. * Help & Contribution
  19. * Credits
  20. Overview
  21. --------
  22. This module allows Drupal to replace textarea fields with CKEditor.
  23. CKEditor is an online rich text editor that can be embedded inside web pages.
  24. It is a WYSIWYG (What You See Is What You Get) editor which means that the
  25. text edited in it looks as similar as possible to the results end users will
  26. see after the document gets published. It brings to the Web popular editing
  27. features found in desktop word processors such as Microsoft Word and
  28. OpenOffice.org Writer. CKEditor is truly lightweight and does not require any
  29. kind of installation on the client computer.
  30. More Information and License
  31. ----------------------------
  32. CKEditor - The text editor for the Internet
  33. Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.
  34. Licensed under the terms of the GNU Lesser General Public License:
  35. http://www.opensource.org/licenses/lgpl-license.php
  36. For further information visit:
  37. http://ckeditor.com/
  38. Requirements
  39. ------------
  40. - Drupal 7.x,
  41. - PHP 5.2 or greater,
  42. - CKEditor 3.4 or greater.
  43. You will need to download CKEditor from the official download site: http://ckeditor.com/download.
  44. It is recommended to always use the latest CKEditor version available.
  45. Installation Paths
  46. ------------------
  47. It is recommended to install the CKEditor for Drupal module in the "sites/all/modules" directory.
  48. When adding the files for standalone CKEditor and CKFinder, you can use one of the following directories:
  49. - "sites/all/modules/ckeditor/"
  50. - "sites/all/libraries/"
  51. and create a "ckeditor" or "ckfinder" directory inside.
  52. The CKEditor module will automatically recognize the proper path to the editor and the file browser.
  53. All installation and configuration instructions in this README file assume that you use the first option and place the CKEditor and CKFinder files in the "sites/all/modules/ckeditor/" directory. If you want to use the "sites/all/libraries/" directory, you will need to adjust the paths given in the instructions accordingly.
  54. Installation / Configuration
  55. ----------------------------
  56. Note: these instructions assume that you install the CKEditor for Drupal module in the
  57. "sites/all/modules" directory (recommended).
  58. 1. Unzip the module files to the "sites/all/modules" directory. It should now
  59. contain a "ckeditor" directory.
  60. 2. Download standalone CKEditor from http://ckeditor.com/download. Unzip the
  61. contents of the "ckeditor" directory from the installation package to the
  62. "sites/all/modules/ckeditor/ckeditor" (or "sites/all/libraries/ckeditor") directory.
  63. Note: you can skip uploading the "_samples" and "_source" folders.
  64. 3. Enable the module in the "Administration panel > Modules > User Interface" section.
  65. 4. Grant permissions for using CKEditor in the
  66. "Administration panel > People > Permissions" section.
  67. Note: In order to enable the file browser, refer to the
  68. "Installing CKFinder" section.
  69. 5. Adjust CKEditor profiles in the
  70. "Administration panel > Configuration > Content Authoring > CKEditor" section.
  71. Profiles determine which options are available to users based on the input format system.
  72. 6. For the Rich Text Editing to work you also need to configure your filters
  73. for the users that may access Rich Text Editing.
  74. Either grant those users Full HTML access or use the following tags:
  75. <a> <p> <span> <div> <h1> <h2> <h3> <h4> <h5> <h6> <img> <map> <area> <hr>
  76. <br> <br /> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <em> <b> <u> <i> <strong>
  77. <del> <ins> <sub> <sup> <quote> <blockquote> <pre> <address> <code>
  78. <cite> <embed> <object> <param> <strike> <caption> <tbody>
  79. To make copying the list easier, below all tags were placed in one line:
  80. <a> <p> <span> <div> <h1> <h2> <h3> <h4> <h5> <h6> <img> <map> <area> <hr> <br> <br /> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <em> <b> <u> <i> <strong> <del> <ins> <sub> <sup> <quote> <blockquote> <pre> <address> <code> <cite> <embed> <object> <param> <strike> <caption> <tbody>
  81. If you are going to use CKEditor with the Filtered HTML input format,
  82. please refer to the "HTML Filters and Inline Styling" section.
  83. 7. To have better control over line breaks, you may disable the line break converter
  84. for a given text format in the "Administration panel > Configuration > Content authoring > Text formats" section (recommended).
  85. 8. Modify the ckeditor.config.js file to adjust it to your needs (optional).
  86. Configuration options are described here:
  87. http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.config.html
  88. Developer's documentation for CKEditor:
  89. http://docs.cksource.com/CKEditor_3.x/Developers_Guide
  90. WARNING: Remember to clear the browser cache after you have modified any of the JavaScript files.
  91. If you skip this step, you may notice that the browser is ignoring your changes.
  92. Installation Troubleshooting
  93. ----------------------------
  94. If CKEditor does not appear on the page, check if all files were extracted correctly.
  95. The "sites/all/modules/ckeditor/ckeditor/" directory should contain the following files:
  96. ckeditor.js, config.js, contents.css
  97. and directories: "skins", "themes", "lang", "images".
  98. The correct directory structure is as follows:
  99. modules <dir>
  100. ckeditor <dir>
  101. ckeditor.module
  102. ckeditor.admin.inc
  103. ...
  104. ckeditor <dir>
  105. _source <dir>
  106. images <dir>
  107. lang <dir>
  108. plugins <dir>
  109. skins <dir>
  110. themes <dir>
  111. COPY_HERE.txt
  112. ckeditor.js
  113. ...
  114. As noted above, alternatively the "sites/all/libraries/ckeditor" directory can be used.
  115. The "libraries" directory is the default path when drush is used to download the editor JavaScript code.
  116. If you are still experiencing problems with your CKEditor installation, scroll down to the "Help & Contribution" section.
  117. Uploading Images and Files
  118. --------------------------
  119. There are two methods for uploading files:
  120. - by using a commercial file browser like CKFinder (http://ckfinder.com), an advanced Ajax file manager;
  121. - by using modules like IMCE.
  122. To select a preferred file browser, adjust CKEditor profiles in the
  123. "Administration panel > Configuration > Content Authoring > CKEditor" section.
  124. In the "File browser settings" section you can choose which file browser will be used for each profile.
  125. Note: in order to choose an upload module other than CKFinder, you should install an appropriate Drupal module first.
  126. Installing CKFinder
  127. -------------------
  128. CKFinder is an Ajax-based file manager created by CKEditor developers: http://ckfinder.com/.
  129. 1. Download CKFinder for PHP: http://ckfinder.com/download
  130. 2. Unpack CKFinder to the directory containing the CKEditor module and place it in the
  131. "sites/all/modules/ckeditor/ckfinder" (or "sites/all/libraries/ckfinder") folder.
  132. The correct directory structure is as follows:
  133. modules <dir>
  134. ckeditor <dir>
  135. ckeditor.module
  136. ckeditor.admin.inc
  137. ...
  138. ckeditor <dir>
  139. _source <dir>
  140. images <dir>
  141. ckeditor.js
  142. ...
  143. ckfinder <dir>
  144. core <dir>
  145. ckfinder.php
  146. config.php
  147. ...
  148. 3. Grant the "CKFinder access" permission in the "Administration panel > People > Permissions" section.
  149. Note: if you do not see this permission, it means that CKEditor did not find CKFinder
  150. and you have probably uploaded CKFinder into a wrong directory.
  151. 4. Open the CKFinder configuration file (ckfinder/config.php) and do the following:
  152. I) Remove the CheckAuthentication() function:
  153. (do not worry, this function is defined in filemanager.config.php, see below)
  154. function CheckAuthentication() <- remove it
  155. { <- remove it
  156. //WARNING : DO NOT simply... <- remove it
  157. ... <- remove it
  158. return false; <- remove it
  159. } <- remove it
  160. II) Add:
  161. - for CKFinder installed in the "sites/all/modules/ckeditor/ckfinder" directory:
  162. require_once '../../../../includes/filemanager.config.php';
  163. - for CKFinder installed in the "sites/all/libraries/ckfinder" directory:
  164. require_once '../../../../../modules/ckeditor/includes/filemanager.config.php';
  165. straight below the following line:
  166. $baseDir = resolveUrl($baseUrl);
  167. 5. Open the Drupal settings file (sites/default/settings.php) and do the following:
  168. I) Uncomment the $base_url variable and set the base URL of your website (without the trailing slash).
  169. II) Uncomment the $cookie_domain variable and set the domain name of your website.
  170. 6. Select CKFinder as a preferred file browser in the
  171. "Administration panel > Configuration > Content Authoring > CKEditor" section
  172. (for a selected CKEditor profile scroll down to the "File browser settings" section).
  173. In the "File browser settings" section you may also change destination folders for files uploaded with CKFinder.
  174. Managing Plugins
  175. ----------------
  176. If you want to manage CKEditor plugins for a profile, go to the "Administration panel > Configuration > Content Authoring > CKEditor" section. This section lets you choose plugins relevant for each CKEditor profile from a list.
  177. In order to activate a plugin, go to the "Editor appearance > Plugins" section and select the checkbox next to a required plugin name.
  178. If a plugin contains toolbar buttons, you will need to drag and drop them to an appropriate toolbar position by using the toolbar wizard. If this is the case, the button should be added to the CKEditor toolbar by using the method described below:
  179. - Enter the "Editor appearance > Toolbar" section.
  180. - Check whether the plugin button that you want to use is present in the "Used buttons" sections. If not, find it in the "All buttons" section and drag and drop to the toolbar configuration from the "Used buttons" section.
  181. Alternatively, if you turned off the toolbar wizard and prefer to enter the toolbar configuration manually, you will need to add the plugin button by yourself by appending it to your toolbar definition code.
  182. Please note that some plugins require installing additional modules to work correctly.
  183. Installing Additional Plugins
  184. -----------------------------
  185. The installation process is based on placing the plugin folder in the "plugins" directory of the CKEditor module (usually "sites/all/modules/ckeditor").
  186. The plugin folder should contain at least the plugin.js file that is responsible for the plugin logic.
  187. The plugin description will be displayed in the "Administration panel" if it is added to the plugin.js file by using the following special comment:
  188. /**
  189. * @file Plugin description
  190. */
  191. Hint: The "Administration panel" automatically detects the toolbar buttons available in the plugin and adds them to the toolbar wizard.
  192. A plugin can be enabled by using the same method as described above - see the "Managing Plugins" section.
  193. Integrating a Plugin with the CKEditor Module (for Plugin Developers)
  194. ---------------------------------------------------------------------
  195. Integrating your application with the CKEditor module by adding a plugin works through a special hook.
  196. An example of the hook is shown below:
  197. function MODULENAME_ckeditor_plugin() {
  198. return array(
  199. 'plugin_name' => array(
  200. // Plugin name.
  201. 'name' => 'plugin_name',
  202. // Plugin description - it will be displayed in the plugins management section of the profile settings.
  203. 'desc' => t('Plugin description'),
  204. // The full path to the CKEditor plugin directory, trailing slash included.
  205. 'path' => drupal_get_path('module', 'my_module') . '/plugin_dir/',
  206. // Plugin buttons definition (optional).
  207. 'buttons' => array(
  208. 'button_name' => array('label' => 'Button label', 'icon' => '/path/to/icon/image'),
  209. 'button_name' => array('label' => 'Button label', 'icon' => '/path/to/icon/image'),
  210. ...
  211. )
  212. )
  213. );
  214. }
  215. Please note that MODULENAME in the code above is the name of the module.
  216. After the hook is used the plugin will automatically appear on the plugin list for each CKEditor profile where you will be able to enable it as described in the "Managing Plugins" section.
  217. Setting up Security Filters
  218. ---------------------------
  219. The CKEditor security system protects you from executing malicious code that is already in your database. In plain textareas database content is harmless because it is not executed, but a WYSIWYG editor interprets HTML like a Web browser and thus the content needs to be filtered before it is loaded.
  220. In order to configure the security filters, go to the "Administration panel > Configuration > Content Authoring > CKEditor" section. Enter the profile configuration and go to the "Security" section.
  221. The "Security" section lists all the security filters that are currently supported by the CKEditor for Drupal module along with their status for each text format.
  222. The CKEditor for Drupal module has built-in support for some popular security filter modules which you will need to download and install by yourself first. Visit the official websites for each module in order to get the files and find installation and configuration instructions.
  223. When a filter module is installed, you will be able to configure its security filters and enable for a given text format. The list of active text formats is displayed in the "Security" section along with the links that will take you to the "Administration panel > Configuration > Content authoring > Text formats" section where you will be able to configure the filters for each of the text formats. The filters will then be run on the content during the filtering process.
  224. The "Security Settings" option in the "Security" section lets you choose whether to always run the security filters on CKEditor content (recommended and default option) or run them only when CKEditor is set to start automatically. If you change this setting to only run the filters when CKEditor starts automatically, you will not be protected when toggling manually between a plain textarea and the WYSIWYG editor.
  225. The following security filter modules are currently supported:
  226. - HTML Purifier - http://drupal.org/project/htmlpurifier
  227. - htmLawed - http://drupal.org/project/htmLawed
  228. - Htmltidy - http://drupal.org/project/htmltidy
  229. - WYSIWYG Filter - http://drupal.org/project/wysiwyg_filter
  230. HTML Filters and Inline Styling
  231. -------------------------------
  232. In the "Administration panel > Configuration > Content Authoring > Text fromats" section, Filtered HTML is the default filter.
  233. Due to security reasons enabling Full HTML is only an option for trusted users.
  234. To take full advantage of using CKEditor you can extend the list of allowed tags in the HTML filter that is enabled in the Filtered HTML input format. If you do not do this, you may notice that a page created in CKEditor looks different after saving.
  235. Unfortunately, even if you extend the list of allowed tags, one problem still remains: Filtered HTML not only strips disallowed tags, but also strips inline style definitions. It basically means that you are unable to apply a different font color, size or family, align images etc. using CKEditor out of the box.
  236. You can solve this problem by creating another input format that will work in a similar way as Filtered HTML (will only allow specified tags), but in a much better way - i.e. it will not strip inline styles that CKEditor is using when
  237. formatting text or images after the page is saved. To create such an input format, you will need an HTML filter. See the list of HTML filter modules that are supported by the CKEditor module in the "Setting up Security Filters" section above.
  238. It is up to you to decide which one to use. Just make sure that you will only allow to use proper inline styles, tags, and attributes.
  239. Integrating a Custom Security Filter with the CKEditor Module (for Developers)
  240. ------------------------------------------------------------------------------
  241. Integrating your application with the CKEditor module by adding a security filter works through a special hook.
  242. An example of the hook is shown below:
  243. function MODULENAME_ckeditor_security_filter() {
  244. return array(
  245. 'security_filter_name' => array(
  246. // Security filter title - it would be displayed in the "Security > Security filters" section of profile settings.
  247. 'title' => t('Security filter title'),
  248. // Security filter description - it would be displayed in the "Security > Security filters" section of profile settings.
  249. 'description' => t('Security filter description'),
  250. )
  251. );
  252. }
  253. Please note that MODULENAME in the code above is the name of the module.
  254. After the hook is used the security filter will automatically appear on the filters list for each CKEditor profile where you will be able to enable it as described in the "Setting up Filters" section.
  255. Upgrading Instructions
  256. ----------------------
  257. This instruction assumes that you are upgrading the CKEditor module [M] and CKEditor (the editor) [E] at the same time.
  258. Instructions specific for module upgrades are tagged with [M]. Steps that must be taken when upgrading CKEditor (the editor) are marked with [E].
  259. 1. [M] Download the latest version of the CKEditor module from http://drupal.org/project/ckeditor (it is advised to read the release notes before going further).
  260. 2. [E] Download the latest version of CKEditor from http://ckeditor.com/download (it is advised to read the "What's New" page before going further: http://ckeditor.com/whatsnew).
  261. 3. [M] Back up your database.
  262. 4. [EM] Place the site in the "Off-line" mode to let the database updates run without interruption and to avoid displaying errors to end users of the site.
  263. 5. [E] If you are using CKFinder, make sure you will not delete it, and move it to a safe place.
  264. 6. [E] If you introduced any changes (e.g. custom toolbar definitions etc.) in the sites/all/modules/ckeditor/ckeditor.config.js file (or sites/all/modules/ckeditor/ckeditor/config.js), write down your changes and add them again after uploading new files.
  265. In general, try to avoid making any changes to CKEditor's config.js file and add everything to ckeditor.config.js.
  266. 7. Delete old files:
  267. [EM]* Simply remove the "modules/ckeditor" directory if upgrading both the editor and the module.
  268. [M] If you are upgrading the module only, remember to leave the "modules/ckeditor/ckeditor" directory untouched.
  269. [E] When upgrading the editor, remove the contents of the "modules/ckeditor/ckeditor" directory only.
  270. WARNING: If you do not remove old files and just rename the "ckeditor" directory instead (e.g. to "ckeditor_old"), Drupal may use the module from the renamed "ckeditor_old" directory.
  271. 8. [M] Upload the CKEditor module (extracted files and folders) to the "sites/all/modules" directory.
  272. 9. [E] Upload standalone CKEditor (extracted files and folders from the "ckeditor" directory) to the "sites/modules/ckeditor/ckeditor" directory (i.e. where the COPY HERE.txt file exists).
  273. 10. [E] Restore the CKFinder files from where you copied them (see step 5).
  274. 11. [E] Apply your modifications to default configuration in the ckeditor.config.js file (see step 6).
  275. 12. [M] Run update.php.
  276. 13. [EM] Put the site back online.
  277. Help & Contribution
  278. -------------------
  279. If you are looking for more information, have any trouble with the configuration of the module
  280. or if you found an issue, please visit the official project page:
  281. http://drupal.org/project/ckeditor
  282. Having problems? Take a look at the list of common problems when installing CKEditor:
  283. http://docs.cksource.com/CKEditor_for_Drupal/Troubleshooting
  284. Learn how to adjust CKEditor to your theme and configure the spellchecker:
  285. http://docs.cksource.com/CKEditor_for_Drupal/Tricks
  286. If you would like to help in the development of the module, we encourage you to join our team.
  287. Any help will be greatly appreciated!
  288. Credits
  289. -------
  290. - CKEditor for Drupal is currently maintained by the CKEditor team and Jorrit Schippers.
  291. http://ckeditor.com/
  292. - CKEditor - The text editor for the Internet
  293. Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.
  294. http://cksource.com/