Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Google Documents integration #28

Open
bordaigorl opened this issue Aug 10, 2012 · 11 comments
Open

Google Documents integration #28

bordaigorl opened this issue Aug 10, 2012 · 11 comments

Comments

@bordaigorl
Copy link

Any chance to get this to work with Google Documents (aka Google Drive)?
I love this extension and I would really like to use it with my google docs: this would allow to easily adapt the appearance of the document elements without being constrained by google docs own styles/structure elements.
For example: there is no "code" style in google docs so the best you can do is manually select the font each time etc which is very unsatisfying.

An option would be to exploit the Google App Script framework but it does not seem to support injection of HTML+CSS into the document.

Any idea on how to do that?

@adam-p
Copy link
Owner

adam-p commented Aug 18, 2012

This would be super cool, but I don't have any good ideas how to do it. If you inspect the DOM of a GDoc, it's pretty crazy, and if you just start replacing DOM elements your changes won't get saved (without proper kix- class names?). Well, that's what I've seen in my brief testing.

So, the approach I've used for webmail probably wouldn't work. Maybe Google App Script? I suspect that an official programmatic interface like that would be the best bet, but if it can't modify document content... dunno.

It certainly would be great to support Google Docs, but I don't see it happening any time soon (not by me, anyway). I'll leave this open to remind myself to look at it again, though.

@chiphogg
Copy link

+1: this would be amazing. Google Docs has great collaborative features, but I feel crippled when I try to author content in them.

@steren
Copy link

steren commented Feb 4, 2013

Google docs is behaving nicely when pasting rich text content. Can't an idea be to cut the markdown text, convert it to HTML and store it into the clipboard, and then simulate a paste of this content ?

@adam-p
Copy link
Owner

adam-p commented Feb 17, 2013

@steren: Your paste idea is interesting, so I did some research into how feasible it is. And... it doesn't super hopeful. Basically: Chrome extensions can't trigger a paste. Also, it'll require extra (and unknown) effort to read the contents of the document (in order to get the Markdown). (Google Docs don't even use selections normally...)

I added my notes to the NOTES file, but I'll also paste them below.


  • Paste does work fairly well to get rendered Markdown into a Google Doc. (Although Paste vs. Paste and Match Style give different results.) Some massaging of the Markdown (<br> vs. <p>, maybe) might improve results.
  • Googling and experimentation suggests that pasting cannot be triggered from a Chrome extension. (Not to be confused with reading from the clipboard, which can be done in a background script.)
  • Pasting probably can be triggered in an old-style (non-Jetpack) Firefox/Thunderbird extension. But I suspect it can't be done in a Jetpack extension (as with Chrome).
  • (Probably also can't be done in a Safari extension.)
  • A common way for websites (including Github) to support copy-to-clipboard is to use Flash. The most popular seems to be ZeroClipboard -- but it doesn't magically provide pasting (even if I could figure out how to use it in an extension).
  • When pasting, the markdown-here-wrapper is lost. This means that reverting may not be possible (at the very least, it'll require another approach).
  • Copying arbitrary HTML to the clipboard is probably doable on all platforms (it is on Chrome, at least).

So, it seem that, at best, MDH could put the rendered Markdown HTML into the clipboard and then the user will have to manually paste it. This is not great, but is perhaps better than nothing.

Another really big outstanding question: Can MDH detect what's selected in the GDoc? Can it get the text? Can it change the selection? Can it delete or replace the selection? (Some simple getSelection() tests are not hopeful.)

@adam-p
Copy link
Owner

adam-p commented Feb 17, 2013

I'm really just adding this for completeness, but...

There's probably some potential in using the Google Drive API. I'm not going to speculate on how or what it would look like, but you can read and edit documents with the API, so there's probably/maybe something that can be done with it.

Really, the best thing would if Google added Markdown rendering support to GDrive, as requested here.

@steren
Copy link

steren commented Mar 12, 2014

Hi,
Google Docs just release an add-ons feature.
It is using Google Apps Script to be able to alter the document's content. I guess using this method would be slightly easier than using the Google Drive API from an extension since everything is hosted and approved by Google.

I may give it a try if I find time.

@bordaigorl
Copy link
Author

That sounds promising!
I hacked together a simple gapp script some time ago to export markdown from gdocs.
It may be useful as a starting point.
You can find it here
It is based on a similar script that can be found at mangini/gdocs2md

@owenthereal
Copy link

Any update on this?

@jbriales
Copy link

I support that this feature would be amazing. I have grown to like markdown so much that it's my first option for writing, always. But whenever I'm sharing documents with people (as in Drive) I still need to make the format understandable for everyone.
It would be great to listen from @adam-p or any other experienced contributor if this enhancement could be simpler now with Google docs add-ons.

@eliasmistler
Copy link

up -- is this still something that's being considered? The add-on is great for emails, but the Google Drive feature would take it a big step up

@n0oneshome
Copy link

I'm not sure if this is an obvious solution, and i'm just slow, but I was searching for a way to use "Markdown here" in Google Docs and it didnt seem to work just by clicking the extension icon.

But if I copied all of my markdown formatted text (say, from ChatGPT) , then right clicked In Google Docs, there's an option for "Paste from Markdown" which pasted the text with properly styled format.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants