-
Notifications
You must be signed in to change notification settings - Fork 6
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
upgrade all the prosemirror libs to latest (incl. regenerating yarn.lock
)
#350
Conversation
…ypes/prosemirror-view`
…arious prosemirror libs (and their interdependence)
…rosemirror-view` `1.30.2` - ProseMirror/prosemirror-view#153 - note the warning ProseMirror/prosemirror-view#153 (comment))
24c8645
to
4c70100
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One question, but lgtm.
@@ -171,7 +171,7 @@ const createNodeView = < | |||
): NodeViewCreator => (initElementNode, view, _getPos, _, innerDecos) => { | |||
const dom = document.createElement("div"); | |||
dom.contentEditable = "false"; | |||
const getPos = typeof _getPos === "boolean" ? () => 0 : _getPos; | |||
const getPos = () => _getPos() ?? NaN; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this change required?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from PR description
notably to reflect type signature changes of
getPos
function (introduced inprosemirror-view
1.30.2
- ProseMirror/prosemirror-view#153 - note the warning ProseMirror/prosemirror-view#153 (comment))
... the type signature of the getPos
function passed in on line 171 (called _getPos) is now () => number | undefined
which needs to be handled at some point as the getPos
everywhere else in @guardian/prosemirror-elements expects () => number
and the ripple effect of changing those type signatures then wasn't handled by the prosemirror libs that the functions are sometimes passed back into. So I changed this to return NaN
if _getPos
returns undefined
so that it will explode in the relevant places whilst still adhering to the type number
.
You're right to raise this though, as whatever was happening before would possibly return 0, which I didn't think was correct as the undefined
is only returned if the node is not in the doc and returning 0 would imply its at the start of the doc... but perhaps there is logic littered around which relies on it falling back to zero rather than exploding. On balance, I think this change is worth it and nothing has exploded in my anecdotal testing thus far, let me know if you disagree though and I can perhaps have another go at propagating the () => number | undefined
out further through the codebase.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for missing that, too early in the morning.
When attempting to upgrade
prosemirror-view
from1.29.1
to1.33.1
(to take advantage of ProseMirror/prosemirror-view#165 and ProseMirror/prosemirror-view#166, as a pre-requisite to #349) I ran into some breaking changes to the types, notably to reflect type signature changes ofgetPos
function (introduced inprosemirror-view
1.30.2
- ProseMirror/prosemirror-view#153 - note the warning ProseMirror/prosemirror-view#153 (comment)) but also cascaded into requiring upgrade ofprosemirror-state
... so for good measure decided to upgrade all the prosemirror libs to latest.There were some very strange incompatibilities after I'd done this, which AFAICT derived from multiple conflicting versions of packages referenced in the
yarn.lock
so I decided to delete and regenerate, which solved all the strange issues - but has resulted in a chunky diff - sorry.