Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 362505

Summary: webEditingPlugin not working
Product: [ECD] Orion Reporter: Mark Macdonald <mamacdon>
Component: ClientAssignee: Mark Macdonald <mamacdon>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: eclipse.felipe, john.arthorne, Silenio_Quarti, simon_kaegi, susan
Version: 0.3   
Target Milestone: 0.4 M1   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Mark Macdonald CLA 2011-10-31 11:53:45 EDT
Orion HEAD 10/31

The webEditingPlugin is not working, which means clicking a .js file doesn't open the Orion editor like it should.
Doing a Reload from the Plugins page gives this:

> Uncaught ReferenceError: define is not defined  webContentAssist.js:14
> Uncaught ReferenceError: define is not defined  htmlGrammar.js:15
> Uncaught ReferenceError: orion is not defined   webEditingPlugin.html:17
Comment 1 Simon Kaegi CLA 2011-11-01 06:29:20 EDT
Felipe is this in someway related to your recent change removing that old definition of define??
Comment 2 Mark Macdonald CLA 2011-11-01 09:58:06 EDT
Clients who use the editor code without requirejs must have a "define" property in the global object or else the "define || defineGlobal(" pattern will throw. This is probably also the cause of the non-requirejs unit test failures
Comment 3 Felipe Heidrich CLA 2011-11-01 10:07:33 EDT
(In reply to comment #2)
> Clients who use the editor code without requirejs must have a "define" property
> in the global object or else the "define || defineGlobal(" pattern will throw.
> This is probably also the cause of the non-requirejs unit test failures

Usually when a client does not use requirejs it needs to include 
<script src="../../orion/textview/global.js"></script>
see minimaleditor.html for an example.

how can I run the webEditingPlugin ?
Comment 4 Felipe Heidrich CLA 2011-11-01 10:23:38 EDT
BTW, the minimal editor works because of this hack
<script>
	// temporary
    	var __originalDefine = window.define;
</script>
<script>
	// temporary
    	window.define = __originalDefine;
</script>

We think the a better hack is to replace 'define' to window.define. But all plugins will still need to include the global.js script.

That said, maybe this is a naive question, but shouldn't plugins be using requirejs ?
Comment 6 John Arthorne CLA 2011-11-01 10:37:20 EDT
*** Bug 362569 has been marked as a duplicate of this bug. ***
Comment 7 John Arthorne CLA 2011-11-01 10:38:29 EDT
Changing to blocker. I tried deploying a build but it had complete lack of editors because of this problem.
Comment 8 John Arthorne CLA 2011-11-01 10:42:55 EDT
(In reply to comment #5)
> Released a fix for the plugin:
> http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=6ebf638b6245d7397cc27e804512f1f502c97578

This doesn't feel like the right fix to me. Are we saying all plugins must either use require.js or include textview/global.js? webEditingPlugin.html doesn't even really know anything about the editor. All this plugin is doing is contributing a couple of services (content assist, syntax highlighter). It doesn't really care who is using those services and having the dependency on the textview script doesn't look right.
Comment 9 Silenio Quarti CLA 2011-11-01 10:52:59 EDT
(In reply to comment #8)
> This doesn't feel like the right fix to me. Are we saying all plugins must
> either use require.js or include textview/global.js? webEditingPlugin.html
> doesn't even really know anything about the editor. All this plugin is doing is
> contributing a couple of services (content assist, syntax highlighter). It
> doesn't really care who is using those services and having the dependency on
> the textview script doesn't look right.

I agree this is a hack, but note the plugin already has a dependencies in the editor (webContentAssist.js and htmlGrammar.js).
Comment 10 John Arthorne CLA 2011-11-01 11:01:48 EDT
(In reply to comment #9)
> I agree this is a hack, but note the plugin already has a dependencies in the
> editor (webContentAssist.js and htmlGrammar.js).

I didn't notice those dependencies had been added. I still don't see why the dependency is there... webContentAssist is just listing a bunch of keywords. It doesn't refer to the editor anywhere in its implementation. Same for htmlGrammar.js. It is a purely declarative grammar definition - it doesn't care about who is using the grammar.

Interestingly my example ruby editor plugin still works even though it didn't add these dependencies (https://github.com/jarthorn/orion.ruby).
Comment 11 Mark Macdonald CLA 2011-11-01 11:54:21 EDT
(In reply to comment #10)
> Interestingly my example ruby editor plugin still works even though it didn't
> add these dependencies (https://github.com/jarthorn/orion.ruby).

Yes: you can contribute to the services without doing any require/global.js stuff. WebEditingPlugin is only doing this hack because it wants to use the implementation of CSS content assist + HTML highlighting that are in the editor code. So we're not forcing a general dependency here.

I'm going to close this since the fix in Comment 5 gets the editor working again. I'll open another bug about fixing the packaging of webEditingPlugin.