cadorn / ace-extjs

ACE Editor for ExtJS
122 stars 41 forks source link

Multiple components on the same application #5

Open dedalo opened 12 years ago

dedalo commented 12 years ago

I'm trying to use the component on an application to edit files, each file is opened on a tab. It works for the firs one, but fails thereafter... have the same thing working out with textareas so it is not the loading process. some point to start working on the solution?

cadorn commented 12 years ago

I would not create more than one editor component but rather create it once and swap the underlying document for the editor when different tabs are selected. This should be way more performant especially if there are many "tabs". See the ACE api on how to set a new document (and keep the old one handy).

That being said multiple editors should work on the same page so I'll leave this issue open.

dedalo commented 12 years ago

maybe I'm reading the correct site https://github.com/ajaxorg/ace/wiki/Embedding---API cannot get the multiple documents information... do you have a link? thanks.

dedalo commented 12 years ago

sorry missed the button and close the issue

cadorn commented 12 years ago

Had a quick look. It looks like the setValue() function does it all for you already. The only part missing for a clean implementation is session re-use but that should be relatively easy for you to add. (I believe the session holds caret position and undo info which you probably want to keep.)

See: https://github.com/cadorn/ace-extjs/blob/08dbf6567cc5daac4571216b929e9bc7571a5f48/packages/extjs-ace/lib/component.js#L153-228

dedalo commented 12 years ago

I see.... if you look at http://ace.ajax.org/build/kitchen-sink.html if you make a change in a document, then select another one, and come back, the change is there. but the same on the ext wrapper demo does not work...

dedalo commented 12 years ago

I don't know how to link to a src inside git, but in your demo you use setValue but in the kitchen sink they use:

bindDropdown("doc", function(value) { var doc = docs[value]; var session = env.split.setSession(doc); session.name = doc.name;

    updateUIEditorOptions();

    env.editor.focus();
});

function updateUIEditorOptions() { var editor = env.editor; var session = editor.session;

    docEl.value = session.name;

... ...

cadorn commented 12 years ago

Right. That is my point. This needs to be fixed. Keep in mind that this project imports an older version of ACE which may/does not have some of the new API features.

You can hack things together now (should be possible) or wait until I update to the latest ACE (see Issue #4).