microsoft / microsoft/monaco-editor

[Feature Request] colorize styles target

Open
#3,863 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature-request tokenization
Dominant language
JavaScript
Stars
46.8k
Forks
4.1k
Avg merge
17h 58m
Merged PRs (30d)
1

Description

Context
  • This issue is not a bug report. (please use a different template for reporting a bug)
  • This issue is not a duplicate of an existing issue. (please use the search to find existing issues)
Description

I am using monaco.editor.colorize to colorize text and set the result to an element in iframe (I tried monaco.editor.colorizeElement but it fails for nodeValue is null, so I just need to pass innerText instead and set innerHTML with the result).

The colorization seems to set monaco-colors style on the document the script is called from, however, I need it to apply to the iframe where I use the colorized HTML.

I suggest that either a document instance can be passed to the API to which the styles will be added, or the styles are returned as a part of the API result.

My current workaround is to take the monaco-colors style element inside the promise handler from the call-site document and insert it in the iframe document.

Monaco Editor Playground Link

No response

Monaco Editor Playground Code

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the monaco.editor.colorize and monaco.editor.colorizeElement APIs described in the issue, then inspect how the monaco-colors style is added to the calling document. Compare the proposed document-target and returned-styles approaches, using the iframe scenario as the acceptance case. Done means colorized HTML can apply its styles in the iframe without the current workaround.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
api, frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.