Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

always display loading... in the editor #16

Closed
vampirefan opened this issue Jun 11, 2014 · 6 comments
Closed

always display loading... in the editor #16

vampirefan opened this issue Jun 11, 2014 · 6 comments

Comments

@vampirefan
Copy link

[Error] open@http://localhost:3000/packages/sharejs.js?60558bce27a82a9deeefcde0e812d180e4364ab0:157:27630
http://localhost:3000/packages/sharejs.js?60558bce27a82a9deeefcde0e812d180e4364ab0:157:27370
emit@http://localhost:3000/packages/sharejs.js?60558bce27a82a9deeefcde0e812d180e4364ab0:157:1368
setState@http://localhost:3000/packages/sharejs.js?60558bce27a82a9deeefcde0e812d180e4364ab0:157:26404
onopen@http://localhost:3000/packages/sharejs.js?60558bce27a82a9deeefcde0e812d180e4364ab0:157:13628
e@http://localhost:3000/packages/sharejs.js?60558bce27a82a9deeefcde0e812d180e4364ab0:133:52
channelOpened@http://localhost:3000/packages/sharejs.js?60558bce27a82a9deeefcde0e812d180e4364ab0:133:216
Rb@http://localhost:3000/packages/sharejs.js?60558bce27a82a9deeefcde0e812d180e4364ab0:123:146
nd@http://localhost:3000/packages/sharejs.js?60558bce27a82a9deeefcde0e812d180e4364ab0:101:252
md@http://localhost:3000/packages/sharejs.js?60558bce27a82a9deeefcde0e812d180e4364ab0:96:297
ec@http://localhost:3000/packages/sharejs.js?60558bce27a82a9deeefcde0e812d180e4364ab0:94:485
Bc@http://localhost:3000/packages/sharejs.js?60558bce27a82a9deeefcde0e812d180e4364ab0:93:311
yc@http://localhost:3000/packages/sharejs.js?60558bce27a82a9deeefcde0e812d180e4364ab0:80:386
dispatchEvent@http://localhost:3000/packages/sharejs.js?60558bce27a82a9deeefcde0e812d180e4364ab0:79:353
Rc@http://localhost:3000/packages/sharejs.js?60558bce27a82a9deeefcde0e812d180e4364ab0:87:190
uc@http://localhost:3000/packages/sharejs.js?60558bce27a82a9deeefcde0e812d180e4364ab0:86:402
Qb@http://localhost:3000/packages/sharejs.js?60558bce27a82a9deeefcde0e812d180e4364ab0:86:379
[native code]
e (sharejs.js, line 133)
channelOpened (sharejs.js, line 133)
Rb (sharejs.js, line 123)
nd (sharejs.js, line 101)
md (sharejs.js, line 96)
ec (sharejs.js, line 94)
Bc (sharejs.js, line 93)
yc (sharejs.js, line 80)
dispatchEvent (sharejs.js, line 79)
Rc (sharejs.js, line 87)
uc (sharejs.js, line 86)
Qb (sharejs.js, line 86)
(anonymous function)


[Error] TypeError: 'null' is not an object (evaluating 'this.zb.n')
Sb (sharejs.js, line 119)
(anonymous function)
(anonymous function) (sharejs.js, line 130)

@vampirefan
Copy link
Author

I get it work by give a docID from template helper.
the problem is that i want to set its init content instead of session value.

    Template['editor'].helpers({
      docId: function () {
        return this._id;
      },
      config: function () {
        var content = this.content;
        return function (editor) {
          // ace.setTheme('ace/theme/monokai');
          editor.setShowPrintMargin(false);
          editor.getSession().setUseWrapMode(true);
          editor.setValue(content);
          console.log(editor);
          console.log(content);
        }
      }
    });

Content is loaded right, but just a second, it disappeared and overwrited by content the last time I edited.

So may be I can edit the content from the document collection or something?

@mizzao
Copy link
Owner

mizzao commented Jun 11, 2014

I think this is a problem with how we can react to updated data in Blaze, similar to Meteor-Community-Packages/meteor-autocomplete#30. The current system is a bit of a hack until the Blaze Component API is finalized. You are probably not using the helper as recommended, hence the bug. I'm not planning to completely fix this until an API for components is better defined.

Can you please provide the templates that you are using to load the editor? At least, you should try loading the package the way that the demo does it.

You may also be talking about the ShareJS option to replace a document's data when connecting. We don't really support that right now because the editor is initialized along with the open command.

Can you also please verify that you are on the latest version?

@vampirefan
Copy link
Author

Here is my editor related code:

  • iron-router controller:
    var EditorController = RouteController.extend({
      template: 'editor',
      data: function () {
        return Posts.findOne(this.params._id); 
      }
    });

    Router.map(function () {
      this.route('home', {
        path: '/home',
        controller: HomeController
      });

      this.route('editor', {
        path: '/home/editor/:_id',
        controller: EditorController
      });
    });
  • editor template
    <template name="editor">
        {{> sharejsAce docid=docId callback=config id="editor"}}
    </template>
  • editor template helper
    Template['editor'].helpers({
      docId: function () {
        return this._id;
      },
      config: function () {
        var content = this.content;
        return function (editor) {
          // ace.setTheme('ace/theme/monokai');
          editor.setShowPrintMargin(false);
          editor.getSession().setUseWrapMode(true);
          editor.setValue(content);
          console.log(editor);
          console.log(content);
        }
      }
    });
  • my Posts collection has a property content stored markdown text.

@vampirefan
Copy link
Author

When the editor refill its value from cache, it outputs the following line in the terminal:

I20140613-14:38:39.071(8)? Catchup X4pi9bCmWGQS5RDMn 0 -> 8

I just want to overwrite its init value, not from cache, but programmable initialize it.

@mizzao
Copy link
Owner

mizzao commented Jun 13, 2014

I can't tell from your description whether this is a UI issue that's causing the editor to be hooked up to the wrong document, or a feature request that is unsupported.

If you connect to a document with a certain name, you will get the contents of that document. That is what you are seeing with the Catchup ... stuff as ShareJS is sending over the operations. If you want to "overwrite" the contents of the document, you can either replace it with something else, or just create a new empty document and write in the contents. What is it exactly that you are trying to do?

@mizzao
Copy link
Owner

mizzao commented Jul 25, 2014

Closing due to lack of response from @vampirefan.

In order to change the contents of documents, you will have to submit operations to the ShareJS server from either server or client code. Simply changing the value of the editor won't cut it. There are also some other options such as opening the ShareJS operation with the replace option.

If you explain your use case better, I could provide some other suggestions. I have a feeling it's not necessary to do what you are doing now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants