-
Notifications
You must be signed in to change notification settings - Fork 2k
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
[Bug]: ExternalContentSourcesExample is broken #2200
Comments
Hey! Looks like this example works by pasting something to the canvas instead of dragging a file. You can try it out by copying some code from VS Code, then pasting this code to the example. Here's the PR where this was added #1925 CleanShot.2023-11-30.at.11.51.42.mp4If you wanted to check for files you would create a I'll update the example since the comment there is quite confusing, thanks for bringing this up! |
Update the External content sources example. The comment was misleading as it mentioned dragging a file, but the example only works when you paste the `text/html` content. https://github.com/tldraw/tldraw/assets/2523721/7c4193ff-e2ba-417f-95c0-7da1f10b585b Improves #2200 ### Change Type - [ ] `patch` — Bug fix - [ ] `minor` — New feature - [ ] `major` — Breaking change - [ ] `dependencies` — Changes to package dependencies[^1] - [x] `documentation` — Changes to the documentation only[^2] - [ ] `tests` — Changes to any test code only[^2] - [ ] `internal` — Any other changes that don't affect the published package[^2] - [ ] I don't know [^1]: publishes a `patch` release, for devDependencies use `internal` [^2]: will not publish a new version ### Release Notes - Improve the comment for one of our examples.
Thanks for capturing the video. I might be misunderstanding something, but the video you uploaded seems to just be pasting a rich formatted text to the canvas, which creates a box with the text content. Based on the name and code of the example, I think the initial intention was to allow for something more powerful (and potentially dangerous, but that's a separate topic): pasting a bit of HTML code (or a HTML file) onto the canvas, which would then create a new shape that actually contains the HTML content in the DOM of the shape. Not just the code pasted as text. Note in the example's code, the To give more context on what I was trying to do: I wanted to try tldraw for making easily editable financial dashboards. There's a library called TradingView that lets you embed a financial chart in a webpage. For example I have this simple HTML code: <div class="tradingview-widget-container" style="height:400px;width:800px">
<div id="tradingview_4347c" style="height:100%;width:100%"></div>
<script type="text/javascript" src="https://s3.tradingview.com/tv.js"></script>
<script type="text/javascript">
new TradingView.widget({
"autosize": false,
"width": "100%",
"height": "300px",
"symbol": "OANDA:EURPLN",
"interval": "D",
"timezone": "Etc/UTC",
"theme": "light",
"style": "1",
"locale": "en",
"enable_publishing": false,
"allow_symbol_change": true,
"container_id": "tradingview_4347c"
});
</script>
</div> If you just paste this snippet into an empty local HTML file and then open the local file in a browser, it should display a financial chart. So I know that some pasted content in tldraw is automatically recognised, like when you paste a google maps link it becomes an embed. What I was trying to do is to paste this HTML into tldraw and get a financial chart embed. I understand this currently doesn't work, but I think it was actually the original intention behind the example... Maybe the original author could pitch in on whether something changed in the tldraw API that broke the example over time? |
The example does allow for that, but it's a bit tricky to make it work. For example, if I copy your html example here (using the copy button that GitHub provides) then this goes to the clipboard as type CleanShot.2024-01-15.at.15.53.45.mp4If I copy some text from VS Code (as I did in the previous example) then our example sees that VS Code put a bunch of sources to the clipboard, one of them being of type CleanShot.2024-01-15.at.15.50.13.mp4So if you wanted to achieve what you want to achieve you can either:
Here's me doing the #1 option for the VS Code example. You can see that now we actually do see the rendered html inside this shape. CleanShot.2024-01-15.at.15.59.47.mp4My feeling is that this example is meant to show how you can offer better integration with tools that do put content as cc @steveruizok to maybe clarify. |
Thanks for the in-depth explanation, that's very useful. What would be a way to enable dropping a file with a text/html MIME type onto the canvas, and then its contents being passed to the text/html handler? Is it possible at all? I don't think there's an example for that |
What happened?
I've tried using the example of external HTML content handler (
/apps/examples/src/examples/ExternalContentSourcesExample.tsx
) through the code sandbox but it seems to be broken - I've tried both dropping an .html file onto the canvas, as well as copy-pasting some HTML.When dropping
test.html
onto the canvas, I get a warning in the console:test.html not loaded - Extension not allowed.
It seems that the current version of the library only allows whitelisting mime types through
acceptedImageMimeTypes
andacceptedVideoMimeTypes
- addingtext/html
to one of these props removes the warning, but then the editor tries to parse the html file as an image/video, which obviously fails.How can we reproduce the bug?
What browsers are you seeing the problem on?
Firefox, Chrome
Contact Details
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: