Hi Joe,
I can only sympathize with you for having to deal with JS dependency
hell, especially having done it a few weeks back with integrating JOBAD
in MediaWiki. I'll try to share my experience with that, in case it is
useful for you.
In general any big framework (Drupal, MediaWiki) ends up creating some
overarching pipeline for loading its dependencies and you really need to
understand how that works in order to cleanly integrate a non-trivial
external (especially a JavaScript one).
For example, MediaWiki's internally rewrites the name of each piece of
JavaScript during runtime and does a bunch of dynamic server-side magic
to prevent you from loading dependencies from within JavaScript. That's
a security stunt in order to control all JS code from within PHP.
Looking at the errors you're posting, the Drupal inclusion mechanisms
look similar to MediaWiki's to an extent. I think for a clean fix you need:
1. The self-contained editor (without its standard dependencies, such as
jQuery) packed into a single minimized file.
2. A clean list of external dependencies for the editor, e.g. jQuery,
Ribbon, etc. (ideally with versions)
3. Checking with Drupal whether any of the dependencies are loaded by
default, and additionally trying to find a system for dependency
management that will make sure to prevent loading things twice. (Loading
two different versions of jQuery for example is a recipe for disaster).
My JOBAD loading in MediaWiki ended up looking like (sharing for the
spirit of it):
$wgResourceModules['ext.MathMenu'] = $moduleTemplate + array(
'scripts' => array(
'jobad/build/release/JOBAD.min.js',
# ... list of MathMenu modules to be loaded
),
'dependencies' => array('jquery','jquery.ui.core'),
'styles' => 'jobad/build/release/JOBAD.css',
);
Note the encapsulation achieved with this approach, and more importantly
the standardized "dependencies" key.
Deyan