mechio / takana

Takana lets you see your SCSS and CSS style changes live, in the browser, as you type them
http://takana.io
MIT License
1.11k stars 61 forks source link

Restricted to Sublime Text? #58

Closed danielbayley closed 8 years ago

danielbayley commented 9 years ago

Is there any way this can be adapted to work in a Coda plugin or Atom package?

MattDiMu commented 9 years ago

I'd also love to use Takana with brackets.io. What are the restrictions, what needs to be done by the editor/editor-extension to make takana work?

barnaby commented 9 years ago

Making a new editor integration is actually really easy if you're using javascript.

We use nssocket for editor <-> takana communication over TCP.

An editor sends two types of messages to takana's EditorManager:

I'll add some example code over the next few days, but in the mean time let me know if you have any more questions!

danielbayley commented 9 years ago

Cool, I might give it a shot when I get chance and you've added that example code.

yoamomonstruos commented 9 years ago

@barnaby Yo b. Any chance you're working on getting an Atom plugin done? Suppose I could have a look…

obibring commented 9 years ago

@barnaby, I'm attempting to write my own Atom package. My package sends ['editor', 'update'] and ['editor', 'reset'] messages to the Takana server on port 48627. When a relevant file is updated in Atom, I see log output from the server: buffer updated for <file>, so it seems the connection is working. However, I don't see the changes reflected in the browser.

The ['editor', 'update'] messages are sent like so:

socket.send ['editor', 'update'],
  path: 'test.css' 
  buffer: editor.getText() # This contains the entire test.css file as a string
  created_at: new Date().getTime()

and the stylesheet is browser is added like so:

<link rel="stylesheet" href="test.css">

Any idea what needs to be done to see changes to test.css go live in the browser?

barnaby commented 9 years ago

@obibring awesome!

looks like you're sending ['editor', 'reset'] instead of ['buffer', 'reset'] and similarly for the update messages.

Please let me know if that works

obibring commented 9 years ago

It's been working seamlessly for a few days now :). I'll clean up the repo and publish to APM so others can use it. Still haven't integrated compilation errors though.

obibring commented 9 years ago

Just published: https://atom.io/packages/takana-atom

danielbayley commented 9 years ago

Nice one :+1:

I'll check it out when I get chance.