fregante / GhostText

đź‘» 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).
https://GhostText.fregante.com
MIT License
3.25k stars 116 forks source link

Improve TiddlyWiki support #284

Closed holdenrohrer closed 1 year ago

holdenrohrer commented 1 year ago

This fixes #236. There seems to still be a hangup in tiddlywiki that requires a user to click twice on the <textarea> immediately after load, but this doesn't seem to be persisent, so I'm not all too worried about it. I'm not very familiar with the browser extension APIs, so I'm not sure if running code inside iframes is supposed to be done differently, but this worked in both Firefox 111.0.1 and Chromium 112.0.5615.49 (with vim-GhostText).

holdenrohrer commented 1 year ago

Hm I can fix up those lint errors soon, but you're right about how hacky this is. Looks like there is a nicer approach mentioned on StackOverflow for web extensions API that I think I'll try to implement so as not to break CORS behavior, if that approach sounds reasonable to you.

fregante commented 1 year ago

That’s too complicated for now, let’s stick to this approach. The fix for #237, coming after Firefox supports it, could improve iframe support further.

holdenrohrer commented 1 year ago

EDIT: Just after sending this, I found a bug happening because I don't remove textareas that are no longer displayed, which breaks TiddlyWiki. Shouldn't be a long fix, but I don't have time at this moment to find it.

Hi,

The lint should be fixed, and I also put in some edits to make the TiddlyWiki functionality not broken around the "Right click to run GhostText on this field" button (these are the changes in the object; hopefully, they're not too big/invasive).

Since TiddlyWiki is an offline platform that can show up on a lot of different websites (sort of like a JS framework like Vue or Angular), I use a meta tags to detect tiddlywiki instead of a domain. Hopefully, this makes sense.

Thanks for taking a look at this PR

holdenrohrer commented 1 year ago

Hey! I fixed the last bug I was talking about and it works pretty well in TiddlyWiki and the normal test-case now.

However, there are a few new changes that may make the app slightly less efficient in general. I haven't noticed any performance issues in my few use-cases, but if you want me to wrap more of my changes in conditional code, I can do that.

Thanks, Holden

fregante commented 1 year ago

I have good news: https://github.com/fregante/GhostText/issues/236#issuecomment-1546720740

I have more good news: this is easily fixable. The user just needs to grant full permissions to the current domain. I'll send a PR.

Question: do you use this tool exclusively on tiddlywiki.com or can it appear on any website?

holdenrohrer commented 1 year ago

That's great news! But yes, TiddlyWiki can show up on any website. A manual (persistent) toggle would be plenty for my use case---and more flexible too---but I also have a function in this PR that detects TiddlyWiki5 instances if you want that.

fregante commented 1 year ago

https://github.com/fregante/GhostText/pull/285 is the right solution for now. A solution for #273 would probably add a “Field not found? Go deeper” prompt that: