-
-
Notifications
You must be signed in to change notification settings - Fork 635
feat: Merged getSelection and getSelectionCutBlocks
#1699
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
base: main
Are you sure you want to change the base?
Conversation
- AI Menu items look more similar to Notion - `getDefaultAIMenuItems` uses same pattern as `getDefaultSlashMenuItems` - AI Block actually sets the `timeGenerated` prop after generating a response - AI Block only appears in the block type dropdown when the selection is in one - AI button in Formatting Toolbar now opens the AI Menu normally instead of in a popover
* Added right section to input and fixed AI UI * Implemented PR feedback * Fixed translations
* Added custom AI menu items example * Updated AI example READMEs
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
| _meta: { | ||
| startPos: tr.selection.from, | ||
| endPos: tr.selection.to, | ||
| }, |
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.
I think this is useful to have, so let's just make it meta
| blocksCutAtStart: | ||
| startNode.nodeSize !== cutStartNode!.nodeSize | ||
| ? $startBlockBeforePos.nodeAfter!.attrs.id | ||
| : undefined, | ||
| blocksCutAtEnd: | ||
| endNode!.nodeSize !== cutEndNode!.nodeSize | ||
| ? $endBlockBeforePos.nodeAfter!.attrs.id | ||
| : undefined, |
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.
I'm still going to have to push back on this naming, I don't know what a blocksCutAtStart means.
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.
OK, I think I understand what cutBlocks are now from the tests. It is the slice of content that the selection range is over. imo, I don't think we should introduce another term on top of what prosemirror has already established for this (a slice).
I think it should be: blockSlice, I still don't understand the usefulness of blocksCutAtStart & blocksCutAtEnd, but I think it is something more like startBlockId or sliceBlockId
| node.type.name === startNode.type.name && | ||
| node.attrs.id === startNode.attrs.id |
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.
| node.type.name === startNode.type.name && | |
| node.attrs.id === startNode.attrs.id | |
| node.eq(startNode) |
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.
Ah maybe this won't match because it is the sliced node?
| node.type.name === endNode.type.name && | ||
| node.attrs.id === endNode.attrs.id |
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.
| node.type.name === endNode.type.name && | |
| node.attrs.id === endNode.attrs.id | |
| node.eq(endNode) |
| cutBlocks: Block<BSchema, I, S>[]; | ||
| blocksCutAtStart: string | undefined; | ||
| blocksCutAtEnd: string | undefined; | ||
| _meta: { |
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.
Can we add JSDoc to describe what each of these mean, and how they are different from each other?
This PR merges the currently 2 separate
getSelectionmethods into one.The functionality of
getSelectionis unchanged, only the additional fields fromgetSelectionCutBlockshave been added (withblocksrenamed tocutBlocks).getSelectionCutBlocksis slightly different as theblocksfield has been renamed tocutBlocksso as not to clash with the same field that was already ingetSelection. Also, now returnsundefinedwhen the selection is collapsed.TODO: