Git Product home page Git Product logo

fregante / ghosttext Goto Github PK

View Code? Open in Web Editor NEW
3.2K 37.0 116.0 6.13 MB

👻 Use your text editor to write in your browser. Everything you type in the editor will be instantly updated in the browser (and vice versa).

Home Page: https://GhostText.fregante.com

License: MIT License

JavaScript 78.80% HTML 6.25% CSS 4.80% Swift 7.22% Shell 2.93%
browser-extension chrome-extension firefox-extension safari-extension vscode-extension sublime-text-plugin

ghosttext's Introduction

ghosttext's People

Contributors

bfred-it avatar cacodaimon avatar chaorace avatar charness avatar elim avatar eugenesvk avatar feltzer avatar fhs avatar fregante avatar jirutka avatar jtojnar avatar lenbok avatar lsloan avatar luisherranz avatar mavit avatar natureshadow avatar newsch avatar pandysong avatar raghur avatar renovate[bot] avatar ryan6416 avatar subnut avatar sukima avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ghosttext's Issues

Doesn't work well with Windows 10 Virtual desktops

I'm using Windows 10's virtual desktops and have multiple sublime text windows open on multiple virtual desktops.

When I activate the browser extension (which is on one of the virtual desktops), it flickers through all desktops trying to find a sublime text window. I think it activates several windows which causes windows to jump to that window's desktops causing the flickering. It also doesn't use the last active sublime text window which is on the same desktop, it flickers through and find some other window (I think the one that was opened first).

Multiple textareas

OMG, this is sooo cool. I love this extension/sublime package.

Is there any way to have this work in codepen on all the textareas eg. HTML, CSS, JS?

P.S. Don't sell this to codepen :)

Submit form changes in textarea from Sublime

I am wondering, is it possible to submit form via Sublime?

Use case

If I am having opened code from textarea via GhostText in Sublime, and I edited something.
Now I want to submit these changes to original textarea which is inside

.
So I hit some shortcut and these data will be submited via form action.

Solutions

  1. Extracting action url and then send it from Sublime (which should be possible. I saw some httprequest addon for Sublime).
  2. Sending action to Chrome from Sublime. And this action will submit this form inside Chrome.

Refreshing data from textarea, after submiting form (in case, when you send form and page will redirect back to original with same textarea, but new data inside).

Is this idea possible for impelmenting?

[Feature Request] LivePreview Compatibility

When using GhostText in a text field which has LivePreview ( SublimeText Forum, StackOverflow, etc. ), the preview does not update unless you go back & manually edit the original text field:

ghosttext livepreview issue

It would be great if you could alter the output method so that it affects text fields as if a user was directly manipulating them.

Aside from that, awesome plugin man! 👍

Using Waffle.io for issue mangement

It' just an spontaneous idea, we could use waffle.io for managing the issues. Waffle displays all GH issues from one ore many repos in one Kanban like board. Custom columns are supported, too - I added the discussion column for example.

screenshot - 07172014 - 10 44 33 am

@bfred-it What do you think?

Limit the update rate when editing large files

This is a optional feature, which should limit the number of updates send to the client per second to an user defined maximum per second.

This should improve the performance when working with large file.

The a maximum wait time before sending an update could be defined in milliseconds the ST user preferences.

When the user sets this value 100ms for example, the maximum number of updates per second would be limited to 10.

How to install?

The Chrome extension can be added manually from the chrome://extensions "developer mode" page… but what about the Sublime Text package? It doesn't seem to work no matter where the folder is placed. Is there something missing?

Error in ST console when a connected tab is closed

Not a big bug since GhostText keeps working normally after this error, but maybe it can be solved easily

View with id: 38 closed
Triggering on_close
Unbind view with id: 38
Unbind view with id: 38
Exception in thread Thread-7:
Traceback (most recent call last):
  File "X/threading.py", line 639, in _bootstrap_inner
  File "/Users/bfred/Library/Application Support/Sublime Text 3/Packages/GhostText/GhostText.py", line 31, in run
    self._server.start()
  File "/Users/bfred/Library/Application Support/Sublime Text 3/Packages/GhostText/WebSocket/WebSocketServer.py", line 48, in start
    header = self._conn.recv(24)  # Max web socket header length
OSError: [Errno 9] Bad file descriptor

Close tabs when the connection was closed

Add an optional feature which closes the view when the connection has been closed by the client.

Use the user preferences for enabling this feature which is disabled by default.

Occasional Python error on disconnect

Is there a way to disconnect and move to a different textarea? ST console when I close Chrome's tab:

ConnectionResetError: [Errno 54] Connection reset by peer

Chrome's console when I try connecting to a new textarea

Uncaught InvalidStateError: Failed to execute 'send' on 'WebSocket': Still in CONNECTING state. 

Right now the only way to disconnect a work on a new textarea is by closing Sublime. Even disabling+enabling the package is not enough. ST console when I re-enable the package.

OSError: [Errno 48] Address already in use

Ghosttext fills the Chrome developer console with "Array[2]"

I'm using Sublime Text 3 and Codepen, and its seems for every line that gets updated in Codepen one line of "Array[2]" gets added, so my console quickly ends up looking like this, which is rather annoying as I want to use it to debug my code:

VM193:1 Array[2]
VM193:1 Array[2]
VM193:1 Array[2]
VM193:1 Array[2]
VM193:1 Array[2]
VM193:1 Array[2]
VM193:1 Array[2]
VM193:1 Array[2]
VM193:1 Array[2]
VM193:1 Array[2]
VM193:1 Array[2]
VM193:1 Array[2]
VM193:1 Array[2]
VM193:1 Array[2]
VM193:1 Array[2]
VM193:1 Array[2]
VM193:1 Array[2]
VM193:1 Array[2]
VM193:1 Array[2]
VM193:1 Array[2]
VM193:1 Array[2]
VM193:1 Array[2]
VM193:1 Array[2]
VM193:1 Array[2]
VM193:1 Array[2]
VM193:1 Array[2]
VM193:1 Array[2]
VM193:1 Array[2]
VM193:1 Array[2]
VM193:1 Array[2]
VM193:1 Array[2]
VM193:1 Array[2]
VM193:1 Array[2]
VM193:1 Array[2]
VM193:1 Array[2]
VM193:1 Array[2]

HTTPS support for Chrome 36+

I tried doing exactly what you did in the video, but when clicking in the textarea nothing happens. This appears Chrome's console:

[blocked] The page at 'https://github.com/bfred-it/Sapere.it-Mobile/edit/master/action.js' was loaded over HTTPS, but ran insecure content from 'ws://localhost:1337/': this content should also be loaded over HTTPS. Uncaught SecurityError: Failed to construct 'WebSocket': An insecure WebSocket connection may not be initiated from a page loaded over HTTPS.

new_window_on_connect: Don't always spawn a new window

Hey guys,

I've been using the new_window_on_connect option for the past couple of weeks now. It's a very useful feature to have if you use GhostText while working on a different project.

I do feel that the way new Sublime instances are spawned could be improved, though. Most importantly, I don't think that GhostText should open a new window under the following circumstances:

  1. Connection to text field has already been established at least once.

    Currently if you start editing a text field, then close the connection and reconnect, a new empty Sublime window is spawned. So while GhostText does reestablish the right connection, it opens and focuses an unnecessary new window

  2. Only existing Sublime Text instance is empty.

    If you aren't working on something else before, you have to launch a new instance to be able to establish the connection. Even if this instance is empty GhostText will launch a new window when establishing the connection. A better solution, if feasible, would be to use the existing empty ST instance.

Thank you very much for considering this.

BR, Feltzer

Linux: Opening connection pushes all ST instances to the foreground if "new window" true

Hey guys,

I was trying out the "new_window_on_connect" option when I noticed this issue on Linux:

Steps to reproduce

  1. Set "new_window_on_connect": true in your user preferences
  2. Have multiple Sublime windows open
  3. activate the connection in GhostText for Chrome

Observed behaviour

GhostText will focus all existing ST instances, resulting in unrelated ST windows getting pushed to the foreground alongside the ST window meant for editing the text area

Expected behaviour

Only focus the newly spawned ST window meant for editing the text area (the most recent ST instance)

Thanks for reading this.

Firefox support?

Firefox seems to support Websockets...
any plans to support Firefox as well?
Very nice concept btw!

Make GIF of usage

We need a gif to put in the readme that shows how they users can benefit from GhostText. I made the video but it wasn't really thought out and people have told me Yeah it's cool, but why use it?

For us it's obvious, but some may not realize what they're missing:

  • Multiple cursors
  • Automatic formatting (like this bullet points list)
  • Shortcuts (like ctrl+D)
  • Autocomplete (like with Emmet and Hayaku)

What I'm asking

Specific (quick) examples to type for each of those (and more). Eventually it might even replace the video altogether.

Autocomplete example:

Type emmet#works.here [tab]

Output: <emmet id="works" class="here"></emmet>

Here's an example GIF

a

chrome extension not installing

on the store it says error occurred and when i try to install it unpacked as a developer it the error is could not find key specification for 'command[1].suggested_key':Either specify a key for 'linux', or specify default key.

does it have linux support?

GhostText doesn't fire keypress events

I've got a textarea which maps source text to a markdown preview which updates automatically on keypress events. GhostText doesn't fire any keypress events, because of this, the preview doesn't get updated at all.

Close connection when the ST tab is closed

Right now the connection seems to stay open even after the tab is closed, this causes an exception in ST when the user types in the browser:

Exception in thread Thread-5:
Traceback (most recent call last):
  File "X/threading.py", line 639, in _bootstrap_inner
  File "/Users/bfred/Library/Application Support/Sublime Text 3/Packages/GhostText/SublimeTextarea.py", line 30, in run
    self._server.start()
  File "/Users/bfred/Library/Application Support/Sublime Text 3/Packages/GhostText/WebSocket/WebSocketServer.py", line 80, in start
    self._on_message_handler.on_message(self._received_payload)
  File "/Users/bfred/Library/Application Support/Sublime Text 3/Packages/GhostText/SublimeTextarea.py", line 88, in on_message
    self._current_view.window().focus_view(self._current_view)
AttributeError: 'NoneType' object has no attribute 'focus_view'

Reuse existing non-connected tabs

Following the button toggle fix in GT-Ch, a possible improvement could be re-using the same editor tab if the same textarea is used. What do you think? Of course this is low priority and should only work if it's in the same tab. I'd rather see closing the connection on ST tab close first anyway.

html -> markdown -> html

I wanted to use this plugin to write emails with sublime text. But when I activate GhostText within a gmail compose box, I get html in Sublime, and I don't want to write my emails in html.

Would it be feasible to integrate GhostText with pandoc? Necessary additions would be

  • new setting "use_pandoc" defaults to false
  • detect if source is html
  • add pandoc -f html -t markdown filter between chrome and sublime
  • add pandoc -f markdown -t html filter between sublime and chrome

pandoc is very fast, so I don't think speed is a major concern here. If you're interested in this addition, I can implement it and make a pull request. (If you can tell me where the filters should go, that would be very helpful)

Wordpress 4.4.2 opens 3 tabs in Sublime 3

I am working on a Wordpress 4.4.2 site with Chrome Version 51.0.2662.0 canary (64-bit).
Sublime 3, build 3107
Mac OS 11.4

I choose the command Shift-command-k and sublime loads 3 tabs with my text in it.

Update the repo descriptions

  • Update the GhostText for Sublime Text repo description to

    Use Sublime Text to write in your browser. Everything you type in the editor will be instantly updated in the browser (and vice versa).

  • Update the GhostText for Chrome repo description to

    Use your text editor to write in Google Chrome. Everything you type in the editor will be instantly updated in the browser (and vice versa).

  • Update the GhostText for Firefox repo description to

    Use your text editor to write in Firefox. Everything you type in the editor will be instantly updated in the browser (and vice versa).

Connection Error (Win7x64 + Chrome 40.0.2214.115 + Sublime Text 3 b.: 3065)

Hi,

I am having problem when I close opened file via GhostText in Chrome. After closing file in Sublime, I see error popup with text:
GhostText: Connection error. Make sure that Sublime Text is open and has GhostText installed. Try closing and opening it and try again. Make sure that the port matches (4001 is the default). See if there are any errors in Sublime Text's console

So I looked at Sublime console a here is this (looks like everything is ok):
GhostText is starting now… Setting on request handler HTTP Start WebSocketServer id: 1 Setting on message handler Setting on close handler Start Listening on: 51017 WebSocketServer id: 2 Setting on message handler Setting on close handler Start Listening on: 51021 Bind view with id: 20 Setting on message handler Package Control: Skipping automatic upgrade, last run at 2015-02-23 14:03:43, next run at 2015-02-23 15:03:43 or after View with id: 20 closed Triggering on_close Unbind view with id: 20 Unbind view with id: 20 Stop Triggering on_close

Otherwise plugin works fine, I can edit textareas via Sublime and it reflects my changes, so there is only problem with this annoying message.

Anyway really great addon! :)

All I get is a red box with Connection Error

I tried using Sublime Text and GhostText for Chrome with the html editor in WordPress and the textarea box here on Github where I am typing this text. All that happens when I click the GhostText icon (or Ctrl-Shift-K) is a red box pops up with Connection Error and says check if Sublime Text is open and GhostText is installed. I am using the GhostText plugin for Chrome (lastest version) on Windows10. I had the same problem using the FireFox plugin. I cannot find anyone else reporting this issue.

Fails after switching to Sublime Text (OSX 10.9.4, Sublime Text 3) #42

Original issue: Cacodaimon/GhostText-for-Chrome#42

When I click on the button in chrome, it switches to sublime text and nothing happens. The error in the console is:

WebSocketServer id: 1
Setting on message handler
Setting on close handler
Start
Listening on: 52672
Exception in thread Thread-82:
Traceback (most recent call last):
  File "WebSocket.WebSocketServer in /Users/JConnolly/Library/Application Support/Sublime Text 3/Installed Packages/GhostText.sublime-package", line 61, in start
  File "WebSocket.Frame in /Users/JConnolly/Library/Application Support/Sublime Text 3/Installed Packages/GhostText.sublime-package", line 52, in parse
IndexError: index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "./threading.py", line 901, in _bootstrap_inner
  File "GhostText in /Users/JConnolly/Library/Application Support/Sublime Text 3/Installed Packages/GhostText.sublime-package", line 33, in run
  File "WebSocket.WebSocketServer in /Users/JConnolly/Library/Application Support/Sublime Text 3/Installed Packages/GhostText.sublime-package", line 63, in start
UnboundLocalError: local variable 'e' referenced before assignment

I'm also experiencing this issue, I was also gettting an error relating to the location of my settings file:

FileNotFoundError: [Errno 2] No such file or directory: '/Users/lawrenceberry/Library/Application Support/Sublime Text 3/Packages/GhostText/GhostText.sublime-settings'

It was only once I move the sublime-settings file (which did exist but wasn't in that folder, in fact the folder itself didn't exist) that I encountered the error above.

Refactor the protocol

Refactor the protocol between client/server.

  • The HTTP Server should send the protocol version on a request.
  • Optional: The client and the server should send the syntax.
  • Optional: The client and the server should send the cursor position/selection, the cursor position/selection is an array of possible multiple selections.
  • The Client has to send the tab's HTML title.
  • The whole content has to be send on each request, no fancy diff only transferring it's localhost only traffic.

Ghosttext does not behave as expected on Codepen

I can pick an editor on Codepen using the browser plugin, but the editor I select doesn't get highlighted, and typing in Sublime doesn't affect the editor.

It's a problem specifically on Codepen.io, it's not a codemirror issue, since ghosttext works fine on JSFiddle.

Note that I've only tried this in Firefox, I had some issues with my chrome browser, rendering me unable to install ghosttext.

Support for inputs other than TextArea

Hi, do you plan to support other input types? The ace editor is an often used input for coding on the web. I think, an integration into your package would be appreciated by many users ;)

Add connection indicator somewhere

Right now it's impossible to see whether a Sublime Text tab is currently listening for events and "connected".

Perhaps even just [CONNECTED] in the tab title and/or a blue circle on the first line's gutter using add_regions()

blue circle in gutter

Running GhostText on `chrome-extension://` pages like TamperMonkey’s

I write a lot of userscripts for Tampermonkey and just discovered GhostText. I thought it would be neat if I could click the 'new script' button in there, then use GhostText to switch and start writing in Sublime right away. I imagine it would involve changing some permissions in the manifest file. Currently, there's a kind of Tampermonkey workaround where you can include a local file as a '@require', but this other way would be more convenient.

GhostText as a Chrome alternative to It's All Text for Firefox

Apparently there's a popular Firefox add-on called It's All Text that seems to do the same thing GhostText does, but it's been inactive for a year. Actually there a few more alternatives on SO:

We have have a look at It's All Text's issues to see what problems we can expect to run into

Multi connection support

The aim is supporting multiple connections, we have to choose one of "two" possible methods.

The first one is using a single WebSocket and "route" incoming text changes to the right editor tab, the browser extension has to route incoming text changes to the right textarea, too. This solution need only one open Socket, but needs more logic at the client side and is limited to one running browser instance (Using a normal and a incognito window at the same time won't work). Since we have no experience with developing Firefox plugins, I can't say that this solution will work at the Firefox.

The other solution is that the browser send a request to the running editor which response is the TCP port of a WebSocket waiting for a new connection. Using a simple HTTP server on the editor side might be the best way, due to HTTP characteristics automatically closing the connection after sending the response. This means we would need at least one HTTP server running at the editor which "starts a WebSocket" on a request. The port of the WebSocket could be determined by the OS but we need a "default" port for the HTTP server.
The pros of this solution is that large parts of the chrome and sublime plugins can be reused, the cons are the added complexity to the editors side, on the client a simple single ajax request would do the job. Another pro that this solution seems to be more Firefox save.

Ctrl+S in Sublime to click on submit button in Chrome

Hi,

First off all congrats on the job well done.

I suggest a feature that when a user saves the file in Sublime it automatically clicks on the submit button on the related page in Chrome so it's update there also. It's best to keep the possibility to undo any changes.

Very useful for making live editing in WordPress and other CMSs. It skips the step of installing a plugin to do it every time.

Regards,
Radu

Close server when the plugin is disabled/reloaded

Right now every time the plugin is updated, this error comes up and ST has to be restarted

reloading plugin GhostText.GhostText
Traceback (most recent call last):
  File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 126, in reload_plugin
    el.on_activated(v)
  File "/Users/bfred/Library/Application Support/Sublime Text 3/Packages/GhostText/GhostText.py", line 129, in on_activated
    http_status_server_thread = HttpStatusServerThread(server_port)
  File "/Users/bfred/Library/Application Support/Sublime Text 3/Packages/GhostText/GhostText.py", line 54, in __init__
    self._server = HttpServer('localhost', server_port)
  File "/Users/bfred/Library/Application Support/Sublime Text 3/Packages/GhostText/Http/HttpServer.py", line 13, in __init__
    self._socket.bind((host, port))
OSError: [Errno 48] Address already in use

Verify that a syntax exists before trying to set it

Error loading syntax file "Packages/Markdown/Markdown.tmLanguage": Unable to open Packages/Markdown/Markdown.tmLanguage

I've had this problem for a while but I just clicked on "Ok" and it didn't appear anymore until I restarted ST. It looks like I don't have that file installed, I just use the MarkdownEditing package, which is pretty good.

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.