mizzao / meteor-sharejs

Meteor smart package for transparently adding ShareJS editors to an app
MIT License
225 stars 53 forks source link

Passing in additional data variables to the template? #56

Closed aamdani closed 8 years ago

aamdani commented 9 years ago

This isn't so much an issue as a question or enhancement request. Is there a way I can pass in additional data variables to the template helper so that I can decorate the resulting textarea with custom attributes?

The reason I ask is because I want to support some simple markdown editing using Bootstrap Markdown. All I really need to include is a data-provide="markdown" or "markdown-editable" but I can't seem to figure out a good way to pass this in.

I forked your package earlier, cloned it, and made my own shareJSMarkdown template, but I couldn't get the package to build successfully (I'll admit, I was out of my depth here). Also, even when I got it to work locally, the template didn't seem to make it across, and it's because I believe your helper needs to call the appropriate constructor and handle it in a string that gets generated and returned.

corv89 commented 8 years ago

Have you figured this out? I'd like to pass the autofocus attribute to the textarea since .focus() won't work.

aamdani commented 8 years ago

I wasn't able to figure this out, no. I am just going to try and create an alternative editor, one that doesn't work through ShareJS but maybe still using OT.

corv89 commented 8 years ago

That's unfortunate. I also figured I would write my own editor since I only need a subset of ShareJS' functionality. What's OT?

mizzao commented 8 years ago

OT = operational transformation, the algorithm that allows multiple people to edit a document simultaneously and to have the resulting output be coherent and synchronized to all editors.

https://en.wikipedia.org/wiki/Operational_transformation

corv89 commented 8 years ago

Thanks, that's useful to know.

DavidSichau commented 8 years ago

What kind of attributes do you want to pass? For styling I would suggest to use the css class .shareJSAce.

aamdani commented 8 years ago

This involved passing in the data-* html5 attributes to the template itself. But, ideally, there would be a way to pass in any HTML attributes to the template, though because of the way it actually renders, with multiple elements emitted, it doesn't necessarily make sense to do so, nor is it as clear-cut. I had downloaded the source and made the modifications myself, and even though I got it partially working, it butchered an otherwise elegant solution.

I recommend writing a function to reactively modify the DOM after the rendering of this template is complete.