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

API wishes #11

Closed
michael opened this issue Aug 20, 2012 · 0 comments
Closed

API wishes #11

michael opened this issue Aug 20, 2012 · 0 comments

Comments

@michael
Copy link
Member

michael commented Aug 20, 2012

The more I think about it, the less I think we should have an apply-like interface. Also the current API is misleading..

Annotations Manipulation API

as surface.apply(["insert", {type: "em"}], I'd rather respect a text insert.. than an annotation insert...

Maybe an explicit annotations interface is better..

surface.annotate({id: "annotation:1", type: "em", pos: [0,5]};

Or for comments:

surface.annotate({id: "annotation:2", type: "comment", pos: [0,10], properties: {"content": "Hi, I'm a comment"}});

No UI logic should be within Surface.. prompt() ing for a links url etc. should be handled outside.

In order to make passing annotations to the constructor work.. we can use that interface internally..

function(options) {
  var that = this;
  _.each(options.annotations, function(annotation) {
    that.annotate(annotation);
  });
}

Text Manipulation

surface.setText("initialized with new text");

This might brake the annotations. So we might want to allow only a full update of the surface, passing in the text content and all annotations.

surface.update({content: "foo", annotations: []});

Actually all init functionality could go into update.. and we just call it from the constructor.

Delta Updates

We might want to consider supporting delta updates but this would involve pulling in third party libs.. like Tim's Operation.js. We wanna wait with that I think.. and make surface small.. and dumb... and don't try to guess use-cases.

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