-
Notifications
You must be signed in to change notification settings - Fork 849
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
! Support clipboard actions from the toolbar. #1843
Changes from all commits
3217059
ea7ba7e
0593877
ae4c828
b0d92d1
66f0aa1
472b89c
dd03bff
04f086c
7419af6
b793796
5249ad3
2334d79
55cb35d
1131828
9e2d3d5
1db1f8b
e76daa2
f1231b7
c9d105a
e681e66
8854bb0
03a9d14
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export 'editor/editor_configurations.dart'; | ||
export 'quill_controller_configurations.dart'; | ||
export 'quill_shared_configurations.dart'; | ||
export 'toolbar/simple_toolbar_configurations.dart'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
class QuillControllerConfigurations { | ||
const QuillControllerConfigurations({this.onClipboardPaste}); | ||
|
||
/// Callback when the user pastes and data has not already been processed | ||
/// | ||
/// Return true if the paste operation was handled | ||
final Future<bool> Function()? onClipboardPaste; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -107,6 +107,9 @@ class QuillSimpleToolbarConfigurations extends QuillSharedToolbarProperties { | |
this.showSearchButton = true, | ||
this.showSubscript = true, | ||
this.showSuperscript = true, | ||
this.showClipboardCut = true, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Showing new buttons in a minor version is also a breaking change. We should focus on having less buttons and an opinioned toolbar that fit the needs of most of our users, noticed that currently, the toolbar takes more than half of the screen, which is an issue I introduced in 2023 when I introduced support for Material 3. We should make it take less space, with less buttons, and instead have sections or groups where each group have related buttons, users can navigate between them, we should not touch the The toolbar is one of the things that really need improvements. The UI is important for the end user. |
||
this.showClipboardCopy = true, | ||
this.showClipboardPaste = true, | ||
this.linkStyleType = LinkStyleType.original, | ||
this.headerStyleType = HeaderStyleType.original, | ||
|
||
|
@@ -195,6 +198,9 @@ class QuillSimpleToolbarConfigurations extends QuillSharedToolbarProperties { | |
final bool showSearchButton; | ||
final bool showSubscript; | ||
final bool showSuperscript; | ||
final bool showClipboardCut; | ||
final bool showClipboardCopy; | ||
final bool showClipboardPaste; | ||
|
||
/// Toolbar items to display for controls of embed blocks | ||
final List<EmbedButtonBuilder>? embedButtons; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -407,20 +407,20 @@ base class Line extends QuillContainer<Leaf?> { | |
final data = queryChild(offset, true); | ||
var node = data.node as Leaf?; | ||
if (node != null) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this change related? Not sure why we need it for this feature. |
||
var pos = 0; | ||
pos = node.length - data.offset; | ||
var pos = math.min(local, node.length - data.offset); | ||
if (node is QuillText && node.style.isNotEmpty) { | ||
result.add(OffsetValue(beg, node.style, node.length)); | ||
result.add(OffsetValue(beg, node.style, pos)); | ||
} else if (node.value is Embeddable) { | ||
result.add(OffsetValue(beg, node.value as Embeddable, node.length)); | ||
result.add(OffsetValue(beg, node.value as Embeddable, pos)); | ||
} | ||
|
||
while (!node!.isLast && pos < local) { | ||
node = node.next as Leaf; | ||
final span = math.min(local - pos, node.length); | ||
if (node is QuillText && node.style.isNotEmpty) { | ||
result.add(OffsetValue(pos + beg, node.style, node.length)); | ||
result.add(OffsetValue(pos + beg, node.style, span)); | ||
} else if (node.value is Embeddable) { | ||
result.add( | ||
OffsetValue(pos + beg, node.value as Embeddable, node.length)); | ||
result.add(OffsetValue(pos + beg, node.value as Embeddable, span)); | ||
} | ||
pos += node.length; | ||
} | ||
|
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.
We should not change this in the
build
method since it is called more often, users use the example as a source of using the library. This can impact performance more than not using theconst
keyword inQuillEditorConfigurations
.We should focus on important aspects that improve the performance noticeably.