-
Notifications
You must be signed in to change notification settings - Fork 246
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
[SuperEditor] Add tap handler to add an empty paragraph when tapping below the end of document (Resolves #2395) #2397
base: main
Are you sure you want to change the base?
Conversation
When creating a breaking change with a known solution, please demonstrate that change in the PR so that readers can come here and copy the fix. |
final DocumentPosition position; | ||
|
||
/// Whether the gesture occurred above the first node in the document. | ||
final bool isGestureAboveStartOfDocument; |
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.
This is definitely far too specific to this one particular goal. There could be 100 different queries that apps might want. We'd end up with 100 properties.
Can you please propose an alternate approach? Can we pass a reference to the document layout and let the implementer check whatever they want?
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 pushed a alternative approach, placing the checks directly on the handler.
I'm still curious about the concept of passing the document layout. Can you think of any reason why we wouldn't want to pass the layout with the event? We're currently reporting the "tap position" in terms of the tapped document node. But this is already a bit of overreach on our end. What if the handler wants to find the "nearest position"? Or, if we're currently looking up the nearest position, what if the handler only wants to consider positions that are actually touched? So I'm wondering, what if we pass the document layout and the global offset? Can you think of any downsides from that? Any hurdles that might get in our way? |
I don't have anything against passing the document layout. Are you saying we should remove |
Yeah, I think we can leave it up to the client to decide what info they wanna pull out of the layout. |
@matthew-carroll Updated. |
@@ -1723,3 +1729,82 @@ class SuperEditorLaunchLinkTapHandler extends ContentTapDelegate { | |||
return null; | |||
} | |||
} | |||
|
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.
Putting this comment here, but it's related to the delegate, itself.
Should we switch to a chain of responsibility so that multiple delegates can be provided? If we don't, and a developer wants multiple situations to be considered, then that developer will have to implement his own chain of responsibility.
Is there any reason that it's important for us to have only a single delegate?
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.
Updated to multiple delegates. We would already need multiple delegates for the spellcheck PR.
@@ -1723,3 +1729,82 @@ class SuperEditorLaunchLinkTapHandler extends ContentTapDelegate { | |||
return null; | |||
} | |||
} | |||
|
|||
SuperEditorAddEmptyParagraphTapHandler superEditorAddEmptyParagraphTapHandlerFactory(SuperEditorContext editContext) => |
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.
This probably doesn't belong in super_editor.dart - we should create a more appropriate source file for such things, or add it to a related existing file.
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.
Updated.
66f8179
to
5e89455
Compare
[SuperEditor] Add tap handler to add an empty paragraph when tapping below the end of document. Resolves #2395
Currently, tapping below the end of the document places the caret at the end of the last selectable component.
This PR modifies the
ContentTapDelegate
to expose theDocumentLayout
, so apps can query the information necessary to make decisions.This PR also introduces a
SuperEditorAddEmptyParagraphTapHandler
, so apps can choose to add an empty paragraph to the end of the document instead.This is a breaking change, but resolving it is pretty simple:
Also, now multiple factories are allowed, which is also a breaking change, solvable with: