Skip to content
This repository has been archived by the owner on Nov 7, 2022. It is now read-only.

Some URLs do not display properly in the Embed Block in Preview mode #416

Closed
0xDing opened this issue Jul 19, 2022 · 0 comments · Fixed by #420
Closed

Some URLs do not display properly in the Embed Block in Preview mode #416

0xDing opened this issue Jul 19, 2022 · 0 comments · Fixed by #420
Assignees
Labels
bug Something isn't working richtext Related to the rich text editor module

Comments

@0xDing
Copy link
Contributor

0xDing commented Jul 19, 2022

Describe the bug

In packages/editor/src/components/blockViews/EmbedView/embedViews/PreviewView/useWebsiteDocumentStatus.ts, We use the following code to determine whether the iframe has loaded successfully:

  const handleLoad = useCallback<ReactEventHandler<HTMLIFrameElement>>(event => {
    if (((event.target as HTMLIFrameElement).contentWindow?.window.length ?? 0) > 0) return

    setError(true)
  }, [])

For sites like figma, which are based on canvas rather than dom, this can be a misjudgement.

But the fact is that the contentWindow is not available for cross-origin frames.

To Reproduce

  1. Create a Embed Block in Preview mode, and set url to https://www.figma.com/embed?embed_host=share&url=https%3A%2F%2Fwww.figma.com%2Ffile%2FRyaabEPkCD9l72OwwcNeSl%2FWeb-UI---C-Page%3Fnode-id%3D2876%253A189515
  2. A PREVIEW error occurred

Expected behavior

No response

Additional context

No response

https://stackoverflow.com/questions/375710/detect-failure-to-load-contents-of-an-iframe

Logs/tracebacks

No response

@0xDing 0xDing added the bug Something isn't working label Jul 19, 2022
0xDing pushed a commit that referenced this issue Jul 19, 2022
0xDing pushed a commit that referenced this issue Jul 20, 2022
0xDing pushed a commit that referenced this issue Jul 20, 2022
* fix(editor): fix preview mode in embed block

#416

* fix(editor): refactor preview mode in embed block
@stackia stackia added the richtext Related to the rich text editor module label Jul 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working richtext Related to the rich text editor module
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants