-
Notifications
You must be signed in to change notification settings - Fork 845
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
Add paste options (bool plainTextOnly and a callback to view/modify a delta prior to pasting) #2350
Comments
This was originally discussed at flutter_quill_delta_from_html #12. This issue will be addressed in #2338 ( I'm thinking about moving the What to address:
Any suggestions? |
|
The
I agree, even though I introduced it in
How about adding both
It can be an image. I'm thinking about moving Since the |
This might be a good feature (#2354) to add or at least provide a way to customize the copy/cut behavior. |
Added the To try the latest pre-release version (#2338): dependencies:
flutter_quill: ^11.0.0-dev.6 See the migration guide. Use the QuillController.basic(
config: QuillControllerConfig(
clipboardConfig: QuillClipboardConfig(
onDeltaPaste: (delta) async {
// TODO: Your custom implementation or return the Delta directly
return delta;
},
onPlainTextPaste: (plainText) async {
// TODO: Your custom implementation or return the plain text directly
return plainText;
},
enableExternalRichPaste: false, // Currently default to true
),
),
); |
* fix!: remove super_clipboard from flutter_quill_extensions and move it to quill_super_clipboard (#2322) * chore!: remove the controller from the configuration class, remove the quill toolbar and editor provider widgets, and other minor breaking changes * chore!: remove SimpleSpellCheckerService from flutter_quill_extensions * chore!: remove experimental support for spell checking, remove the deprecated support for YouTube in flutter_quill_extensions, and other minor breaking changes * chore(deps): remove equatable * chore!: remove quill shared configuration and toolbar shared configuration * chore!: remove QuillController.setContents() * chore!: remove QuillController.editorFocusNode * chore: remove outdated comments * chore: always call setState() in _markNeedsBuild() in QuillRawEditorState even if dirty is already true (revert to old behavior) * chore: extract code from _requestKeyboard() and add docs comment for _requireEditorCurrentState * chore!: remove classes related to editor element options, minor docs updates in editor config, rename isOnTapOutsideEnabled to onTapOutsideEnabled * chore!: rename 'Configurations' to 'Config' * chore!: refactor build method of the embed block interface * chore!: remove the experimental table support from flutter_quill_extensions * chore!: remove old deprecated properties * chore!: rename rawItemsMap to items for font family and font size options * chore!: remove deprecated formula embed support from flutter_quill_extensions * chore!: remove deprecated class SuperClipboardService, rename the directory models to config in flutter_quill_extensions * chore: add commnet in imageProviderBuilder code docs comment in flutter_quill_extensions * docs: fix typos in migration * docs(readme): replace deprecated flutter_quill_internal.dart with internal.dart * docs(readme): improve README * docs(readme): add the GitHub flutter_quill code snippet back * docs: add more details to the migration guide * fix(ios): use the localized strings for 'open', 'copy', and 'remove' * chore: rename the file quill_controller_configurations.dart to quill_controller_config.dart * chore!: avoid storing quill editor config inside Document * chore: restore search within embed objects feature (revert removal of editor config inside the QuillController) * chore: add @experimental to some APIs * docs: add emojis to the migration guide, add the migration guide link in README.md * chore: removes quill controller web files, updates QuillControllerConfig.onClipboardPaste to allow overriding the default paste handling * docs: fix typos in the migration guide * chore: minor change in the migration guide * docs: update link of QuillControllerConfig.onClipboardPaste in the migration guide * chore: fix dart analysis issues * chore: mark QuillEditorConfig.customLeadingBlockBuilder as experimental * chore!: avoid exporting OptionalSize * chore: rename _restoreToolbar to _restoreToolbarAfterMagnifier in text_selection.dart * chore: annotate QuillEditorConfig.magnifierConfiguration as experimental * chore: minor cleanup to magnifier feature * chore: export missing class, fix #2333 * chore: fix dart analysis * chore(release): temp changes to publish 11.0.0 (will revert changes of this commit) * chore: add temp dependency_overrides to fix CI failure * chore: temp changes to publish 11.0.0-dev.1 * ci(publish): temp change to fix CI failure * chore: restore previous publish workflow (revert), update min version of flutter_quill in test and extensions packages, remove pubspec_overrides.yaml * chore: revert CHANGELOG.md and publish.yml changes * chore: revert a change in #2026 (see comment https://github.com/singerdmx/flutter-quill/pull/2026/files#r1679744497) * chore: revert change of reverting the removal of _handles check introduced by #2026 * docs(migration): clarify the removal of the QuillToolbar widget * docs(migration): improve removal of the QuillToolbar section * docs: add the custom toolbar page link in: removal of the QuillToolbar * docs: add important info at the top of the migration guide * feat(toolbar): add the base button options feature back, supports flutter_quill_extensions's buttons too. * chore: fix analysis warnings * docs: add more details in the migration guide in the breaking behavior with code snippets * chore: minor change to the 'Breaking behavior' section * chore(deps): improve dependencies constraints for compatibility - Fix #2341 - Fix #2347 * docs(migration): explain that QuillToolbar is not a visual widget like QuillSimpleToolbar * docs: minor changes to README.md and migration guide * feat: clipboard paste callbacks, partial fix to #2350 * docs: update outdated link in the migration guide * chore: rename deltaToPaste() to getDeltaToPaste() * docs: improve CHANGELOG.md format and quality, fixing #2211 * ci: pass the GitHub token to an action * docs: fix format of CHANGELOG.md * ci: use cider for CHANGELOG.md format validation * ci: add a TODO to improve CHANGELOG.md validation * chore: remove flutter_quill_extensions from publishing * chore: publish flutter_quill_extensions and add 'insertVideo' in quill_en.arb * chore(release): prepare to publish 11.0.0-dev.3 * ci: increase _expectedTranslationKeysLength due to 'insertVideo' * ci: use a GitHub action to update the release notes * chore(release): publish flutter_quill_extensions 11.0.0-dev.3 * chore(release): prepare to publish 11.0.0-dev.4 * ci: remove the release notes file creation * chore(example): delete the current example to recreate * chore: recreate the example (fix #2249), minor changes to flutter_quill_extensions * docs(readme): update the screenshots of the example app * docs(readme): update sample page link, remove 'breaking changes' from table of contents only * feat: add the option to disable rich text paste feature, partial fix to #2350 * chore(release): prepare to publish 11.0.0-dev.5 * chore: regenerate translations to reflect #2358 * chore: ignore deprecations * docs: fix a minor issue in the Contributing guide * chore(example): add file read access for macOS * feat(l10n): localize "insert video" for Khmer language Source: #2358 (comment) * chore: simplify PR template * docs: update development notes * docs(readme): use images from GitHub repo instead of relative path to load on pub.dev
@mtallenca Do the parameters What is missing is |
Yes, having these will fix the issue
…On Mon, Nov 11, 2024, 1:22 AM Ellet ***@***.***> wrote:
@mtallenca <https://github.com/mtallenca> Do the parameters onDeltaPaste,
onPlainTextPaste, and enableExternalRichPaste fix the issue?
What is missing is Paste as plain text (for the end-user) in the context
menu which is supported by default on native Android, we can add it on all
platforms or Android only, it's similar to native Android though not the
same.
—
Reply to this email directly, view it on GitHub
<#2350 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAXMGLNDN5OVAD7MXNZXQFL2ABZNTAVCNFSM6AAAAABRHUH7DSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINRXGYZTMMJQHA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Thank you very much for your reply! |
You can use /// Callback triggered when pasting plain text into the editor.
///
- /// Returns modified text to override the pasted content, or `null` to use the default.
+ /// Returns a [Delta] to override the pasted content, or `null` to use the default.
@experimental
- final Future<String?> Function(String plainText)? onPlainTextPaste;
+ final Future<Delta?> Function(String plainText)? onPlainTextPaste; The API design needs more consideration. |
This comment was marked as resolved.
This comment was marked as resolved.
I do agree with that as stated in my previous comment.
The behavior slightly changed in v11 (see breaking changes), it allows to override the default with a custom implementation, it can be used to check if the clipboard as plain text, process the paste and then return |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as resolved.
This comment was marked as resolved.
The issue has already been resolved in the pre-release. See this comment. The v11 is already stable. We didn't publish it as stable since we have one breaking change, which is removing the magnifier feature (see #2413 for more details). |
Thank you for your reply. But I meant the following one
|
We might need to change
Note
Here is an example after introducing the change: onPlainTextPaste: (String plainText) async {
return Delta()
..insert('The plain text from the clipboard', {'bold': true})
..insert(':\n')
..insert(plainText);
}, IssueAfterUnmergedChange.mov |
Hi, thx for your reply! But the latest code is still the old version
Is that change still in your local repo? When will it be merged into the master? THX! |
I'm only interested in altering pasted text when it's coming from the system clipboard (so I can ensure it's only using attributes that the current editor config has). I would like anything copied from the editor then pasted back into the editor to remain unmodified. Need a bool to indicate system clipboard? |
Yes, it needs more consideration before merging.
You're right. That is a separate topic and should be in #2156.
Currently, the The I'm considering
Having |
Is there an existing issue for this?
Use case
Problem: On iOS when pasting HTML, it is converted into a quill delta object and then performs a controller
replaceText()
. The conversion assumes the full functionality of the editor and keeps all converted attributes. If the QuillEditor implementation isn't using some of the Quill features, it can be inserted into the document and not be editable. i.e. fonts, colors, images, etc.I propose adding two changes to the controller.
Whenever HTML is pasted, pass the converted delta object to a callback that would allow the delta to be edited. The callback would return the edited delta object and that would be used with the replaceText controller method.
Provide a bool that would convert any pasted HTML into plain text prior to calling
replaceText()
.Alternative solutions: Currently in the onReplaceText controller callback, I'm examining the delta, removing any unsupported attributes, and then calling a 2nd replace text with the modified delta.
Proposal
quill_controller_rich_paste.dart
The text was updated successfully, but these errors were encountered: