Skip to content

Block Editor: Add <base> to Block Canvas Iframe head#56533

Closed
vonloxx wants to merge 1 commit into
WordPress:trunkfrom
vonloxx:patch-1
Closed

Block Editor: Add <base> to Block Canvas Iframe head#56533
vonloxx wants to merge 1 commit into
WordPress:trunkfrom
vonloxx:patch-1

Conversation

@vonloxx

@vonloxx vonloxx commented Nov 26, 2023

Copy link
Copy Markdown
Contributor

This allows relative paths to work inside a Block Canvas IFrame.

What?

Adding <base> with the current location to the blob used as a source for the Block Canvas Iframe.

Why?

In WordPress that's not an issue but on other projects using the Block Editor component it might be. It is an issue at Drupal Gutenberg.

How?

By adding<base>with current location, all urls will consider the url from that tag.

Testing Instructions

Not really an issue on WordPress but it can been seen at Drupal Gutenberg 3.0.0 Beta.

Testing Instructions for Keyboard

Screenshots or screencast

This allows relative urls to be used in <link>, <a>, <img>, etc.
@vonloxx vonloxx requested a review from ellatrix as a code owner November 26, 2023 20:35
@github-actions

Copy link
Copy Markdown

Warning: Type of PR label mismatch

To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.

  • Type-related labels to choose from: [Type] Automated Testing, [Type] Breaking Change, [Type] Bug, [Type] Build Tooling, [Type] Code Quality, [Type] Copy, [Type] Developer Documentation, [Type] Enhancement, [Type] Experimental, [Type] Feature, [Type] New API, [Type] Task, [Type] Performance, [Type] Project Management, [Type] Regression, [Type] Security, [Type] WP Core Ticket, Backport from WordPress Core.
  • Labels found: .

Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task.

@ellatrix

Copy link
Copy Markdown
Member

This should fix the issue too right? #55152

@ellatrix

Copy link
Copy Markdown
Member

I think it might be best to allow passing a head prop so you can add any HTML you want. The problem with this PR is that it assumes what the URLs are relative to. It might need a path as well, or maybe the front-end is hosted on a different domain.

@vonloxx

vonloxx commented Nov 27, 2023

Copy link
Copy Markdown
Contributor Author

Ah, tried to search for similar issue/PR but I missed that. Yes, this approach is not very flexible regarding paths or different domains.
The approach at #55152 seems a good solution.
I think that passing a head prop (if in block editor) won't work, for example, for Drupal Gutenberg because it uses the full Edit Post component 😬
I'll try #55152 and maybe close this later 😅

@Soean

Soean commented Nov 7, 2024

Copy link
Copy Markdown
Member

Merged in #66751

@Soean Soean closed this Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants