Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simulator extensions: apply aspect ratio to simx iframe #10222

Merged
merged 3 commits into from
Oct 9, 2024

Conversation

eanders-ms
Copy link
Contributor

  • Simulator extensions can be configured with a custom aspectRatio, but it was getting ignored. Modified startSimulatorExtension method to take an aspectRatio parameter and apply it to the simulator extension's iframe.
  • Sanitize message channel string before using it as a class name in the simulator extension frame.

@eanders-ms eanders-ms requested a review from a team October 9, 2024 04:07
Copy link
Contributor

@srietkerk srietkerk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a question about the regex, but otherwise looks good

// Copied from pxtlib/util.ts
export function sanitizeFileName(name: string): string {
/* eslint-disable no-control-regex */
return name.replace(/[()\\\/.,?*^:<>!;'#$%^&|"@+=«»°{}\[\]¾½¼³²¦¬¤¢£~­¯¸`±\x00-\x1F]/g, '').trim().replace(/\s+/g, '-');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two questions for this regex. Is there not a way to capture all special characters without something like this? Also, how were you able to type some of these?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method was copy/pasted from pxtlib/util.ts, because that module is not available in the simulator. I don't know the history of this regex, but wanted to use it for consistency.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree the regex could be written a lot better. It should take the approach of defining what is allowed rather than what is not.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your comment made me realize that css has slightly different validation rules than filenames. css names can't start with a number, for example. Pushed an update to fix this.

@eanders-ms eanders-ms merged commit 73b79ea into master Oct 9, 2024
6 checks passed
@eanders-ms eanders-ms deleted the eanders-ms/simx2 branch October 9, 2024 17:12
eanders-ms added a commit that referenced this pull request Oct 11, 2024
* apply simx aspect ratio

* lint

* sanitizeCssName
eanders-ms added a commit that referenced this pull request Oct 11, 2024
* Support for 3rd-party simulator extensions (#10213)

* support for simulator extensions

* lint

* lint

* n

* restore

* restore

* read

* wording

* simxdevmode

* add test simx

* async componentDidMount

* `e` -> `x`

* Add simulator extension doc page (#10219)

* support for simulator extensions

* lint

* lint

* n

* restore

* restore

* read

* wording

* simxdevmode

* add test simx

* async componentDidMount

* `e` -> `x`

* update docs

* simulator extensions: apply aspect ratio to simx iframe (#10222)

* apply simx aspect ratio

* lint

* sanitizeCssName

* Fix simx path formatting issue (#10229)

* fix path formatting issue

* simpler fix

* restore comment
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.

2 participants