Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 22, 2026

RTE blocks required both Stylesheet and Stylesheets properties to load styles, while BlockGrid and BlockList only needed Stylesheets. Root cause: RTE was reading from context settings instead of using API endpoints.

Changes

Backend

  • Added /preview/rte/stylesheets and /preview/rte/stylesheet (deprecated) endpoints to BlockPreviewApiController
  • Reuses existing GetStylesheetPaths() method which merges both properties

Frontend

  • Added getRteStylesheets() to BlockPreviewService with type definitions
  • Refactored rich-text-preview.custom-view.element.ts to fetch via API like Grid/List
  • Extracted stylesheet loading to #loadStylesheets() helper with error handling

Example

// Before: Read from context, only worked with Stylesheet property
this.observe(this.#blockPreviewContext?.settings, (settings) => {
    if (settings?.richText?.stylesheet) { /* ... */ }
});

// After: Fetch via API, works with either/both properties
const { data } = await BlockPreviewService.getRteStylesheets({
    query: { documentTypeUnique, nodeKey }
});

Now works with:

  • Stylesheets: ["/path/to/styles.css"]
  • Stylesheet: "/path/to/styles.css" ✅ (backward compatible)
  • Both properties ✅

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • www.myget.org
    • Triggering command: /usr/local/bin/node node /usr/local/bin/npm install (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>RTE blocks - Stylesheets not loading</issue_title>
<issue_description>### Which Umbraco.Community.BlockPreview version are you using?

5.2.0

Which Umbraco version are you using? For example: 10.4.0 - don't just write v10

17.10

Bug summary

Stylesheets are not loading, even though the path is correct, you need both Stylesheet and Stylesheets properties to be set for it to work

options.RichText = new()
{
Enabled = true,
Stylesheet = "/Static/dist/app.bundle.css",
Stylesheets = ["/Static/dist/app.bundle.css"],
ViewLocations =
[
"/Views/Partials/richtext/Components/{0}.cshtml"
]
}

This problem doesn't occur on Blockgrid or BlocList.

Steps to reproduce

Create a RTE block

Setup Stylesheets OR Stylesheet property

No styles are are loaded.

Setup Stylesheet AND Stylesheets property instead

Styles are loaded.

Expected result / actual result

No response</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 3 commits January 22, 2026 11:48
Co-authored-by: rickbutterfield <200450+rickbutterfield@users.noreply.github.com>
Co-authored-by: rickbutterfield <200450+rickbutterfield@users.noreply.github.com>
Co-authored-by: rickbutterfield <200450+rickbutterfield@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix stylesheets not loading in RTE blocks Fix RTE blocks stylesheet loading to match BlockGrid/BlockList behavior Jan 22, 2026
Copilot AI requested a review from rickbutterfield January 22, 2026 11:56
rickbutterfield and others added 2 commits January 23, 2026 19:58
- Add _isConnected flag and lifecycle methods to prevent API calls after disconnect
- Add early exit guards in observer callbacks when documentTypeUnique is empty
- Wrap stylesheet API calls with tryExecute for proper error handling
- Inline stylesheet loading in rich-text-preview to match grid/list pattern

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@rickbutterfield rickbutterfield changed the base branch from v5/main to v5/dev January 23, 2026 20:06
Added .claude/settings.local.json to .gitignore to exclude local Claude settings from version control. Removed entries for generated schema files and obj directory, so these files will now be tracked.
@rickbutterfield rickbutterfield marked this pull request as ready for review January 23, 2026 20:08
Copilot AI review requested due to automatic review settings January 23, 2026 20:08
@rickbutterfield rickbutterfield merged commit b28d4b1 into v5/dev Jan 23, 2026
3 checks passed
@rickbutterfield rickbutterfield deleted the copilot/fix-rte-block-stylesheets-loading branch January 23, 2026 20:09
rickbutterfield added a commit that referenced this pull request Jan 23, 2026
…ylesheets-loading

Fix RTE blocks stylesheet loading to match BlockGrid/BlockList behavior
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.

RTE blocks - Stylesheets not loading

2 participants