diff --git a/README.txt b/README.txt index 1af96d0..66c9f4b 100644 --- a/README.txt +++ b/README.txt @@ -29,22 +29,25 @@ Rationales Loading Aloha Editor plug-ins ----------------------------- -Follow these steps: -1) Add a dependency on the "aloha" module if your module is useless without it. -2) Implement hook_library_info(). Use a name such as "mymodule.aloha". Add a - dependency on each Aloha Editor plug-in that you need. E.g. if you're adding - the "extra/captioned-image" plug-in that ships with Aloha Editor, you'll want - to specify a dependency on "aloha.common/block", which is part of the "aloha" - module. -3) To ensure that the plug-ins you're trying to load actually get loaded, you +1) Implement hook_library_info(). Use a name such as "aloha.mymodule.pluginname". + Add a dependency on each Aloha Editor plug-in that you need. + + E.g. if you're adding the "extra/captioned-image" plug-in that ships with + Aloha Editor, you'll want to specify a dependency on "aloha.common/block", + which is part of the "aloha" module. + +2) To ensure that the plug-ins you're trying to load actually get loaded, you have to send the necessary settings to Aloha (i.e. they have to end up in - Aloha.settings). To do this, specify a "JavaScript setting" in your library, - you can use the public API function aloha_plugin_js_settings() to simplify - this. -4) Finally, to ensure that Drupal will make your Aloha Editor plug-in available + Aloha.settings). To do this, specify JavaScript settings for your library. + +3) Finally, to ensure that Drupal will make your Aloha Editor plug-in available wherever Aloha Editor is available, you should implement hook_library_info_alter() and whenever $module == "aloha", you can add your dependency like so: - $libraries['aloha']['dependencies'][] = array('mymodule', 'mymodule.aloha'); + + $libraries['aloha']['dependencies'][] = array('mymodule', 'aloha.mymodule.pluginname'); + +4) Add a dependency on the "aloha" module if your module is useless without it. + 5) For more details, see the ASCII diagram and aloha_library(). diff --git a/aloha.module b/aloha.module index 44c6a4d..9f5b430 100644 --- a/aloha.module +++ b/aloha.module @@ -5,32 +5,20 @@ * Provides integration with the Aloha Editor WYSIWYG editor. */ -/** - * @todo: the currently included build of AE is not yet optimal for Drupal; we - * must create a build of AE that bundles the JS and CSS in single JS & - * CSS files on a per-AE plug-in basis. Then, we'll be able to define - * libraries in hook_library_info() for each of the plug-ins, allowing - * Drupal to reason about AE's dependencies. - * So: finish + leverage @nod_'s 'build-with-plugin-separated' profile in - * AE. - */ - -define('ALOHA_VERSION', "custom build: 0.21.2 + patches"); // @todo: establish a versioning scheme for our custom build - +// @todo Establish a versioning scheme for our custom build. +const ALOHA_VERSION = 'custom build: 0.21.2 + patches'; /** * Implements hook_menu(). */ function aloha_menu() { - $items = array(); $items['aloha/repository/link/%'] = array( - 'page callback' => 'aloha_repository_link', - 'page arguments' => array(3), + 'page callback' => 'aloha_repository_link', + 'page arguments' => array(3), 'access arguments' => array('access content'), - 'type' => MENU_CALLBACK, - 'file' => 'includes/pages.inc', + 'type' => MENU_CALLBACK, + 'file' => 'includes/pages.inc', ); - return $items; } @@ -38,15 +26,16 @@ function aloha_menu() { * Implements hook_library_info(). */ function aloha_library_info() { + $module_path = drupal_get_path('module', 'aloha'); // Location of Aloha Editor build we're using and the main JS file within it. - $library_path = drupal_get_path('module', 'aloha') . '/build/alohaeditor'; + $library_path = $module_path . '/build/alohaeditor'; $library_file = "aloha.js"; $libraries['aloha-for-textareas'] = array( 'title' => 'Drupal behavior to enable Aloha Editor WYSIWYG editing on textareas.', 'version' => VERSION, 'js' => array( - drupal_get_path('module', 'aloha') . '/js/aloha.textareas.js' => array(), + $module_path . '/js/aloha.textareas.js' => array(), aloha_plugin_js_settings(array( // Allow other modules, e.g. the Edit module, to embed the rendered // toolbar within their own DOM infrastructure. @@ -82,7 +71,7 @@ function aloha_library_info() { array('aloha', 'aloha.common/link'), array('aloha', 'aloha.common/paste'), // Tight Drupal integration. - array('aloha', 'aloha.drupal-aloha/drupal'), + array('aloha', 'drupal.aloha'), ), ); @@ -116,7 +105,7 @@ function aloha_library_info() { 'data-aloha-defer-init' => 'true', ), ), - drupal_get_path('module', 'aloha') . '/js/drupal-aloha.js' => array( + $module_path . '/js/drupal-aloha.js' => array( 'group' => JS_LIBRARY, 'defer' => FALSE, ), @@ -138,6 +127,7 @@ function aloha_library_info() { ); // Aloha Editor: "common" bundle of plug-ins (shipped with Aloha Editor). + // @todo Library names should only contain dots/periods. $libraries['aloha.common/ui'] = array( 'title' => 'Aloha Editor plug-in: UI.', 'version' => ALOHA_VERSION, @@ -266,11 +256,12 @@ function aloha_library_info() { 'version' => VERSION, 'js' => array( aloha_plugin_js_settings(array( - 'bundles' => array('drupal-aloha' => file_create_url(drupal_get_path('module', 'aloha') . '/aloha/')) + // @todo Rename the bundle to just 'drupal'. + 'bundles' => array('drupal-aloha' => file_create_url($module_path . '/aloha/')) )), ), ); - $libraries['aloha.drupal-aloha/drupal'] = array( + $libraries['drupal.aloha'] = array( 'title' => '"Drupal" Aloha Editor plug-in: contenthandler + link repository', 'version' => VERSION, 'js' => array( @@ -296,9 +287,9 @@ function aloha_library_info() { array('aloha', 'aloha.common/contenthandler'), ) ); - $ui_path = drupal_get_path('module', 'aloha') . '/aloha/drupal-ui/lib'; + $ui_path = $module_path . '/aloha/drupal-ui/lib'; $libraries['aloha.drupal-aloha/drupal-ui'] = array( - 'title' => 'Drupal-specific UI for Aloha Editor, initially built for Spark.', + 'title' => 'Drupal-specific UI for Aloha Editor.', 'version' => VERSION, 'js' => array( aloha_plugin_js_settings(array( @@ -307,6 +298,7 @@ function aloha_library_info() { // here. 'requireConfig' => array( 'paths' => array( + // @todo Usage of file_create_url() here and elsewhere doesn't look right. 'ui/multiSplit' => file_create_url($ui_path . '/multiSplit'), 'ui/utils' => file_create_url($ui_path . '/utils'), 'ui/toolbar' => file_create_url($ui_path . '/toolbar'), @@ -317,7 +309,7 @@ function aloha_library_info() { )), ), 'css' => array( - drupal_get_path('module', 'aloha') . '/css/aloha-drupal-ui.css' => array( + $module_path . '/css/aloha-drupal-ui.css' => array( 'weight' => 50, ), ), @@ -355,8 +347,8 @@ function aloha_pre_render_text_format($element) { return $element; } // Allow modules to programmatically enforce no client-side editor by setting - // the #aloha property to FALSE. - if (isset($element['#aloha']) && !$element['#aloha']) { + // the #wysiwyg property to FALSE. + if (isset($element['#wysiwyg']) && !$element['#wysiwyg']) { return $element; } @@ -369,6 +361,8 @@ function aloha_pre_render_text_format($element) { $format_id = $field['#format']; // Gather all necessary metadata for all available formats for this field. + // @todo This needs to be provided by the filter system. + // @see http://drupal.org/node/1782838 foreach ($format_field['format']['#options'] as $format_id => $format_name) { $filter_types = filter_get_filter_types_by_format($format_id); $allowed_tags = filter_get_allowed_tags_by_format($format_id); @@ -426,11 +420,6 @@ function aloha_pre_render_text_format($element) { } /** - * @defgroup aloha_api Aloha Editor API - * @{ - */ - -/** * Helper function to create Aloha.settings entries for Aloha Editor plug-ins * that are defined in hook_library_info() as libraries. * @@ -443,6 +432,8 @@ function aloha_pre_render_text_format($element) { * * @param $settings * The Aloha settings to add. + * + * @todo Remove this. */ function aloha_plugin_js_settings($settings) { return array( @@ -450,7 +441,3 @@ function aloha_plugin_js_settings($settings) { 'data' => array('aloha' => array('settings' => $settings)) ); } - -/** - * @} End of "defgroup aloha_api". - */