awcodes / filament-tiptap-editor

A Rich Text Editor plugin for Filament Forms.
MIT License
290 stars 79 forks source link

3.x Find extension with regex to account for presigned #160

Closed Orrison closed 1 year ago

Orrison commented 1 year ago

Same as #159 but for v3.x.

In my project, I am currently working on allowing for the full usage of private media inserts by implementing my own MediaAction and possibly extending the TiptapEditor field. This way, pre-signed URLs are properly generated on-load and used. This is due to some requirements in my application that all assets be fully private and only accessed via a signed URL.

If it goes well, I would be happy to submit a PR to allow this functionality in the package as well if there is a desire for it.

The one issue I have, regardless of whether I am doing my own implementation or not, is these lines here during the JS TipTap media insert. Because, before, it did pop() on . it would not work for pre-signed URLs that would contain png??X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Al... for example.

This should resolve that issue by using regex to find the extension regardless of the presence of text after the extension.

I tested it locally, and it seems to work just fine.

awcodes commented 1 year ago

Don't these kinds of tokens have expiration times?

Orrison commented 1 year ago

Don't these kinds of tokens have expiration times?

They do. I am allowing for that by saving the URLs as little variables that get found during hydrate (and during my blade output) and replacing them with a new temporary URL. I extended the Field and am using my own Media action in my implementation.

https://github.com/canyongbs/assistforhighered-2/pull/68

It looks like this at the end in the DB: <p><img src="{{media|path:/kb-images/b757ee38-7ea8-4982-b5d7-b203daa0d6d4.jpg;disk:s3;}}" width="2000" height="1581"></p>

But unfortunately, that all won't work unless this JS allows for finding the extension of URLS that have anything after the .[EXT]