Closed danielbayley closed 8 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?
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:
['buffer', 'update']
with a payload consisting of a path
to a stylesheet and the current editor buffer
as a string. This tells takana that it should re-render the stylesheet with the given buffer (when a user changes the stylesheet). ['buffer', 'reset']
with a payload consisting of a path
to a stylesheet. This tells takana that it should re-render the stylsheet using the file from disk (when a user closes a stylesheet without saving)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!
Cool, I might give it a shot when I get chance and you've added that example code.
@barnaby Yo b. Any chance you're working on getting an Atom plugin done? Suppose I could have a look…
@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?
@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
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.
Just published: https://atom.io/packages/takana-atom
Nice one :+1:
I'll check it out when I get chance.
Is there any way this can be adapted to work in a Coda plugin or Atom package?