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

Fix #524, Fix #534 #535

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Fix #524, Fix #534 #535

wants to merge 5 commits into from

Conversation

themoenen
Copy link

@themoenen themoenen commented Mar 27, 2024

Description

This pull request addresses issues #524 and #534:

  • Allow Miew to be initialized within a CORS iframe (essential for Jupyter Notebook support)
  • Prevent certain keys from being blocked when typing in text fields on pages where Miew is initialized

Should be reviewed by someone more familiar with the codebase to make sure there's no unintended consequences.

Type of changes

  • Bug fix (non-breaking change that fixes an issue)

Checklist

  • I have read CONTRIBUTING and CODE_OF_CONDUCT guides.
  • I have followed the code style of this project.
  • I have run yarn run ci: lint and tests pass locally with my changes.
  • I have added tests that prove my fix/feature works OR The changes do not require updated tests.
  • I have added the necessary documentation OR The changes do not require updated docs.

Moenen Erbuer added 5 commits February 27, 2024 12:09
… this was breaking initialization when being rendered inside a cross-orgin iframe
…ult for s/+/- keys when input of textarea is in focus anywhere
@themoenen themoenen changed the title Fix for issues #524 & #534 Fix #524, Fix #534 Mar 27, 2024
Copy link
Member

@paulsmirnov paulsmirnov left a comment

Choose a reason for hiding this comment

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

We appreciate your help on this! I am sorry I am not ready to give it a full thought currently but here are my quick notes on the changes.

Copy link
Member

Choose a reason for hiding this comment

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

The dist/ folder is updated only on new version releases (and corresponds to the version published in NPM) so I don't think we should edit files here manually in PRs.

@@ -2888,24 +2897,30 @@ Miew.prototype._onKeyDown = function (event) {
}
break;
case 'S'.charCodeAt(0):
event.preventDefault();
event.stopPropagation();
if (!['TEXTAREA', 'INPUT'].includes(document.activeElement?.tagName)) {
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if there are other tag names to support. Or even there could be an arbitrary DIV element (a React component) waiting for the S key and this solution wouldn't help. This fix might be a short-term solution if miew.enableHotKeys(false) doesn't work for you.

The long-term solution I see is:

  • move all key handlers to the demo apps providing proper public methods in the library;
  • disable the S key completely as it looks more like a debugging key;

However, it is just my quick glance with a dump of current thoughts.

Copy link
Member

Choose a reason for hiding this comment

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

It seems a random file has arrived from a MacOS. We'd better put the name into .gitignore.

@@ -23,6 +23,6 @@
},
"packageManager": "yarn@3.6.3",
"resolutions": {
"nomnom": "^1.8.1"
"nomnom": "^1.8.1"
Copy link
Member

Choose a reason for hiding this comment

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

An irrelevant change but a good catch nevertheless.

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.

None yet

2 participants