Repository navigation
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
| * @param editor - The lexical editor | ||
| * @returns window of current default view | ||
| */ | ||
| export function getWindow( |
There was a problem hiding this comment.
Maybe instead of (or in addition to) this, we should just have something like our own implementation of instanceof:
function instanceOf(instance, target): boolean
which just gets the correct window in it's implementation.
There was a problem hiding this comment.
I'm not sure how we can get the window from this function, we would need to get the target that blongs to window of current view beforehand :
function instanceOf(instance, target): booleanusage:
const windowOfCurrentView = getWindow(editor)
inctanceof(event, windowOfCurrentView.DrageEvent)There was a problem hiding this comment.
In retrospect, exporting the getWindow might help in other situations where properties of window/document are accessed .
examples:
window.getSelection()
document.caretRangeFromPoint
document.createRange()
window.createElementwe can see a number of PRs that addresses this issue and this function might help
see discussions here #4649
here also @zurfyx comment here #5547 (review)
I'm willing to go around and address this iframe issues and i believe this utility is usefull
There was a problem hiding this comment.
@acywatson I have used objectKlassEquals function introduced in #4649 , it's better than getWindow each time
can you review it again please ?
|
@acywatson , this is a gentle reminder of the fix, all comments been reviewed for a better solution by using |
|
Closing this PR due to staleness! If there are new updates, please reopen the PR. |
conext
In checking for event prototype ancestry , lexical assumes the default window is the browser window.
example:
this is like :
This will fail and return false even thought the event is indeed a
DragEventbecause the event is an instance of the iframe window's DragEvent :instanceof checks for Prototype ancestry. When you ask is some event instanceof DragEvent it translate to
but
PR
This pr tries to do the following:
1- Export
getWindowfunction as utility throught@lexical/utils2- Uses
getWindowto access window whenever instanceof is used on constructor that belongs to window where editor residesPoC maybe ??
Yes here is a link to code demonstating this :
https://stackblitz.com/edit/vitejs-vite-sfz7ft?file=src%2FApp.tsx