Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Error creating Xtext Web Editor (Ace) in custom div(I am only able to create an xtext-editor using Ace if I have div with id="xtext-editor")
Error creating Xtext Web Editor (Ace) in custom div [message #1737265] Wed, 06 July 2016 17:52 Go to next message
Shiv Kandikuppa is currently offline Shiv KandikuppaFriend
Messages: 10
Registered: May 2016
Junior Member
Hi

I am trying to create an xtext web editor using Ace in a div with an id other than xtext-editor. I have tried the following

				editor = xtext.createEditor({
					xtextLang: "infomodel",				
					syntaxDefinition: "xtext/mode-infomodel",
					serviceUrl: "/infomodel/xtext-service",
					enableFormattingAction: "true",
					showErrorDialogs: "true",
					parent: "xtext-editor-parent"
				});


		<div id="editor-container">
                <div data-editor-parent="xtext-editor-parent"></div>               
	    </div>


This method does not create an xtext editor in the div.

I have also tried using the following method

				editor = xtext.createEditor();
				xtext.createServices(editor,{
					xtextLang: "infomodel",				
					syntaxDefinition: "xtext/mode-infomodel",
					serviceUrl: "/infomodel/xtext-service",
					enableFormattingAction: "true",
					showErrorDialogs: "true",
					parent: "xtext-editor-parent"
				});


This gives an error:
xtext-ace.js:1486 Uncaught TypeError: this.editor.getSession is not a function

Could someone please help me with this

Thanks
Shiv

[Updated on: Wed, 06 July 2016 17:53]

Report message to a moderator

Re: Error creating Xtext Web Editor (Ace) in custom div [message #1737269 is a reply to message #1737265] Wed, 06 July 2016 18:26 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
did you have a look at https://github.com/eclipse/xtext-web/blob/f4c4d9bb228014c01f8f468eab12e57ddcd26755/org.eclipse.xtext.web.example.jetty/src/main/webapp/ace-statemachine-static-multi.html ???

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Error creating Xtext Web Editor (Ace) in custom div [message #1737272 is a reply to message #1737269] Wed, 06 July 2016 18:50 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
ps the following works for me

xtext.createEditor({
					baseUrl: baseUrl,
					syntaxDefinition: "xtext-resources/generated/mode-mydsl5",
					parent: "xtext-editor2"
				});
<div class="container">
	<div class="header">
		<h1>Example MyDsl Web Editor 2</h1>
	</div>
	<div class="content">
		<div id="xtext-editor2" data-editor-xtext-lang="mydsl5"></div>
	</div>
</div>
#xtext-editor2 {
	display: block;
	position: absolute;
	top: 0;
	bottom: 0;
	left: 0;
	right: 0;
	padding: 4px;
	border: 1px solid #aaa;
}


i asume you have already fixed the WebModule

class MyDslWebModule extends AbstractMyDslWebModule {

	def void configureIPreferenceValuesProvider(Binder binder) {
		binder.bind(IPreferenceValuesProvider).annotatedWith(FormatterPreferences).to(FormatterPreferenceValuesProvider)
	}
}


https://bugs.eclipse.org/bugs/show_bug.cgi?id=495851


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Error creating Xtext Web Editor (Ace) in custom div [message #1737295 is a reply to message #1737272] Thu, 07 July 2016 03:54 Go to previous message
Shiv Kandikuppa is currently offline Shiv KandikuppaFriend
Messages: 10
Registered: May 2016
Junior Member
Hi Christian

Thanks a lot, your example helped me get this working.
Previous Topic:install problem
Next Topic:xbaseCompiler methods
Goto Forum:
  


Current Time: Tue Apr 23 08:33:30 GMT 2024

Powered by FUDForum. Page generated in 0.03513 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top