More monaco fixes#656
Merged
david-poindexter merged 2 commits intoDNNCommunity:release/0.16.0from Dec 5, 2022
Merged
Conversation
david-poindexter
approved these changes
Dec 5, 2022
Contributor
david-poindexter
left a comment
There was a problem hiding this comment.
Fantastic @valadas - only one minor commit I'll make to remove a double space.
| link.rel = "stylesheet"; | ||
| document.head.appendChild(link); | ||
| } | ||
| let path = import.meta.url.substring(0, import.meta.url.lastIndexOf('/')); |
Contributor
There was a problem hiding this comment.
This is really cool - I had no clue about this!
Member
Author
There was a problem hiding this comment.
Yeah, learned that too digging around...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In a previous attempt, we were distributing the monaco CSS file as an asset but in DNN context we had no great way to know in which path those files would actually live as we are producing components and not a website. So I reverted to using an scss import as that part was working right, it's only the font that was not working
In order to fix the font I discovered that chrome has a bug with fonts defined inside shadow-root and the workaround is to use scripts to import the font on the document head. I learned that one can use
import.meta.urlin the context of es-modules to get the URL to the module and not the page or otherwise.For assets paths, since we have no clue where the path would be for a consumer, I learned that one can use
import.meta.urlinside an es-module to get the actual path where the module loaded from. We can now use this to reference the assets path correctly no matter where they get distributed by consumers.I also learned that since Stencil supports workers out of the box, it is better to use
getWorkerrather thangetWorkerUrlfor performance and maybe we also avoid some path issues this way as Stencil will know what to bundle how.I changed some monaco default options that I did not know existed. The most notable one being
ariaContainerElement, unless this is set, the default is to inject the aria-text directly at the document end. I am now setting it to a local hidden div for screen-readers only and it no longer shows under the editor.