Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [orion-dev] Issue with embedding Orion.Client



On Thu, Jun 28, 2012 at 12:36 PM, John Arthorne <John_Arthorne@xxxxxxxxxx> wrote:
The problems seem to be wider than just the editor. We have examples that show embedding a very basic Orion editor and I think they are fairly straight-forward. The trick is when you want to start pulling in more scripts for outlining, highlighting, content assist, etc. In theory require.js helps with wiring up all the inter-script dependencies, but you need a main require.js configuration that maps all the source locations to module names.

Yup, for example:
https://github.com/johnjbarton/sirius/blob/master/extension/OrionEditorEmbedded/requireConfig.js

The issue includes orion parts like paths/that/go/way/way/down.and.include.lots.of.dots and require parts like some rules that apply to module identifiers and some to .js files names.  The really killer is the almost none-existent error feedback. Mostly you just learn that the load failed.

Related is the (personally challenging) super long list of arguments in orion module. For that I build up objects:

https://github.com/johnjbarton/sirius/blob/master/extension/OrionEditorEmbedded/orionAssembly.js

I actually prefer my previous version of this approach, where I copied all of the properties in orion/edtior/* onto orion.editor. That avoids silly things like:
orion.editor.cssContentAssist.CssContentAssistProvider

in favor of

orion.editor.CssContentAssistProvider
but it also risks collisions.

The scarier problem that Andy mentioned is that even once you do this, there are timing problems if the scripts aren't loaded/run in the same order as we have in Orion. These are the cases we need to track down and figure out how to make our code less brittle.

I think this problem may be described slightly differently: conventional synchronization techniques like iframe onload events just do not work with require.js scripts. The symptom will be intermittent failure during start up.  Editor embedders must explicitly block any code that may use the editor until the completion of the script loading at the end of the top level require() call. 

jjb

Back to the top