Multiple editors

68 views
Skip to first unread message

Soroush Hat

unread,
May 3, 2013, 6:08:51 PM5/3/13
to sha...@googlegroups.com
Hi,

I've already checked the forum for topics related to this matter, but I haven't find any useful information...

So the problem is that I want to have multiple CodeMirror instances in one page, and per each I open a Sharejs doc, and I'm making sure that I'm opening each doc only once. however it seems that there is an issue with having multiple editors in one page, how can I fix this?

One more thing is that I'm using the same code from demos to attach the Sharejs(0.6.0) doc to the CodeMirror:

sharejs.open(docName, 'text', function(error, newDoc) {
      if (doc !== null) { //here I get that the doc is not defined!
          doc.close();
          doc.detach_cm();
      }

      doc = newDoc;

      if (error) {
          console.error(error);
          return;
      }
      doc.attach_cm(editor);
  });

but I get this error on the first line that the doc is not defined. any ideas?

Wout Mertens

unread,
May 4, 2013, 7:07:21 AM5/4/13
to sha...@googlegroups.com

Try putting "var doc" before all that code?

--
You received this message because you are subscribed to the Google Groups "ShareJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sharejs+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Soroush Hat

unread,
May 5, 2013, 7:02:50 AM5/5/13
to sha...@googlegroups.com
I've already fixed that, any ideas about multiple editors?

Joseph Gentle

unread,
May 5, 2013, 11:15:12 AM5/5/13
to sha...@googlegroups.com

Multiple editors should work fine. Open a doc per editor and attach it to code mirror. What's the problem?

(For those following along, multiple editors all editing one doc also works in the ShareJS rewrite.)

Soroush Hat

unread,
May 5, 2013, 6:38:49 PM5/5/13
to sha...@googlegroups.com
AAAAAH, stupid problem in my code.

I keep the current editor in a variable named "window.editor", which was causing the problem in "share/cm.js" (it uses the same name)


On Sunday, May 5, 2013 8:15:12 AM UTC-7, Joseph Gentle wrote:

Multiple editors should work fine. Open a doc per editor and attach it to code mirror. What's the problem?

Great! 
Reply all
Reply to author
Forward
0 new messages