Git Product home page Git Product logo

Comments (9)

josephg avatar josephg commented on August 22, 2024

Wasn't this done?

from sharejs.

nornagon avatar nornagon commented on August 22, 2024

I think I got part-way there and hit some sort of road block, but I can't remember what.

BTW, your github avatar looks like an alien.

from sharejs.

josephg avatar josephg commented on August 22, 2024

Cheers :p

Yeah - for some reason I thought we had this working. Don't sub-documents (foo.at('bar')) support the text API? If so, we should probably make an example.

from sharejs.

gohf avatar gohf commented on August 22, 2024

Has anyone had a chance to look at this yet, it would be incredibly useful.

from sharejs.

nornagon avatar nornagon commented on August 22, 2024

@josephg probably, mostly. You should try it :)

On reflection, I think the roadblock I hit was the events stuff, which should be mostly working now.

from sharejs.

gohf avatar gohf commented on August 22, 2024

Hi Guys,

I hacked around and managed to make it work but had to make a couple changes to the source. Luckily subdoc provides the same interface (mostly).

webclient\json.uncompressed.js

Need to make subdoc public

516c462,464
<   window.sharejs.SubDoc = SubDoc = (function() {
---
>
>   SubDoc = (function() {

webclient\textarea.js

attach "attach_textarea" to subdoc

23c22,23
<   window.sharejs.SubDoc.prototype.attach_textarea = window.sharejs.Doc.prototype.attach_textarea = function(elem) {
---
>
>   window.sharejs.Doc.prototype.attach_textarea = function(elem) {
26c26
<     elem.value = this.getText();//snapshot;
---
>     elem.value = this.snapshot;

Example use:

var el = $('input')[0];
var key = ['list', 0, 'title'];
var foo = doc.at(key);
if (foo) {
    foo.attach_textarea(el);
}

from sharejs.

josephg avatar josephg commented on August 22, 2024

Can you make a pull request?

@nornagon - can you review it?

from sharejs.

nornagon avatar nornagon commented on August 22, 2024

This has been merged and seems to work fine for attach_textarea, too.

from sharejs.

vincentwoo avatar vincentwoo commented on August 22, 2024

Are we sure this works? In testing:

doc.at('editor').attach_ace(editor);

I get

TypeError: Cannot read property 'text' of undefined
at e.attach_ace (http://vm.vincentwoo.com:5000/share/ace.js:42:23)
at http://vm.vincentwoo.com:5000/:60:24
at exports.Doc (http://vm.vincentwoo.com:5000/share/share.uncompressed.js:1008:18)
at Connection.makeDoc (http://vm.vincentwoo.com:5000/share/share.uncompressed.js:891:16)
at Doc.open._openCallback (http://vm.vincentwoo.com:5000/share/share.uncompressed.js:752:49)
at Doc._onMessage (http://vm.vincentwoo.com:5000/share/share.uncompressed.js:596:64)
at Connection.socket.onmessage (http://vm.vincentwoo.com:5000/share/share.uncompressed.js:821:38)
at ce.c.channelHandleArray (http://vm.vincentwoo.com:5000/channel/bcsocket.js:91:346)
at Kd.t.Nb (http://vm.vincentwoo.com:5000/channel/bcsocket.js:81:351)
at uc (http://vm.vincentwoo.com:5000/channel/bcsocket.js:45:213) 

and if I change the invocation to doc.at('editor').doc.attach_ace(editor);

Error: Only text documents can be attached to ace
at Doc.attach_ace (http://vm.vincentwoo.com:5000/share/ace.js:43:13)
at http://vm.vincentwoo.com:5000/:60:28
at exports.Doc (http://vm.vincentwoo.com:5000/share/share.uncompressed.js:1008:18)
at Connection.makeDoc (http://vm.vincentwoo.com:5000/share/share.uncompressed.js:891:16)
at Doc.open._openCallback (http://vm.vincentwoo.com:5000/share/share.uncompressed.js:752:49)
at Doc._onMessage (http://vm.vincentwoo.com:5000/share/share.uncompressed.js:596:64)
at Connection.socket.onmessage (http://vm.vincentwoo.com:5000/share/share.uncompressed.js:821:38)
at ce.c.channelHandleArray (http://vm.vincentwoo.com:5000/channel/bcsocket.js:91:346)
at Kd.t.Nb (http://vm.vincentwoo.com:5000/channel/bcsocket.js:81:351)
at uc (http://vm.vincentwoo.com:5000/channel/bcsocket.js:45:213) 

from sharejs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.