You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Feat: customizable character and space shortcut events (singerdmx#2228)
* Added character shortcut events class
* Feat: support for character and space shortcut events
* Chore: added new gif video url
* Chore: improve and fix some parts of the new section in the README.md
* Merge from master
* Fix: typo in comment into the Shortcut event section
* chore: add a message for validating an assert in handleFormatByWrappingWithSingleCharacter()
* chore: fix analysis warning
* Chore: moved shortcut docs to its own file
* Chore: changed editor without shortcut gif url
* Chore: added description to asserts
* Chore: removed unnecessary default cases in format functions
* Fix: characterShortcutEvents param in raw configs is showing as it is deprecated
* Chore: dart format
* Chore: fixed some comments that references double chars instead single chars
* Fix: typo
* Chore: improved doc comments on format functions
* Chore: dart format
---------
Co-authored-by: CatHood0 <[email protected]>
Co-authored-by: Ellet <[email protected]>
Copy file name to clipboardExpand all lines: README.md
+12Lines changed: 12 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -58,11 +58,13 @@ You can join our [Slack Group] for discussion.
58
58
-[📦 Embed Blocks](#-embed-blocks)
59
59
-[🔄 Conversion to HTML](#-conversion-to-html)
60
60
-[📝 Spelling checker](#-spelling-checker)
61
+
-[✂️ Shortcut events](#-shortcut-events)
61
62
-[🌐 Translation](#-translation)
62
63
-[🧪 Testing](#-testing)
63
64
-[🤝 Contributing](#-contributing)
64
65
-[📜 Acknowledgments](#-acknowledgments)
65
66
67
+
66
68
## 📸 Screenshots
67
69
68
70
<details>
@@ -290,6 +292,16 @@ It's implemented using the package `simple_spell_checker` in the [Example](./exa
290
292
291
293
Take a look at [Spelling Checker](./doc/spell_checker.md) page for more info.
292
294
295
+
## ✂️ Shortcut events
296
+
297
+
We can customize some Shorcut events, using the parameters `characterShortcutEvents` or `spaceShortcutEvents` from `QuillEditorConfigurations` to add more functionality to our editor.
298
+
299
+
> [!NOTE]
300
+
>
301
+
> You can get all standard shortcuts using `standardCharactersShortcutEvents` or `standardSpaceShorcutEvents`
302
+
303
+
To see an example of this, you can check [customizing_shortcuts](./doc/customizing_shortcuts.md)
304
+
293
305
## 🌐 Translation
294
306
295
307
The package offers translations for the quill toolbar and editor, it will follow the system locale unless you set your
We will use a simple example to illustrate how to quickly add a `CharacterShortcutEvent` event.
4
+
5
+
In this example, text that starts and ends with an asterisk ( * ) character will be rendered in italics for emphasis. So typing `*xxx*` will automatically be converted into _`xxx`_.
class AsteriskToItalicStyle extends StatelessWidget {
14
+
const AsteriskToItalicStyle({super.key});
15
+
16
+
@override
17
+
Widget build(BuildContext context) {
18
+
return QuillEditor(
19
+
scrollController: <your_scrollController>,
20
+
focusNode: <your_focusNode>,
21
+
controller: <your_controller>,
22
+
configurations: QuillEditorConfigurations(
23
+
characterShortcutEvents: [],
24
+
),
25
+
);
26
+
}
27
+
}
28
+
```
29
+
30
+
At this point, nothing magic will happen after typing `*xxx*`.
31
+
32
+
<palign="center">
33
+
<imgsrc="https://github.com/user-attachments/assets/c9ab15ec-2ada-4a84-96e8-55e6145e7925"width="800px"alt="Editor without shortcuts gif">
34
+
</p>
35
+
36
+
To implement our shortcut event we will create a `CharacterShortcutEvent` instance to handle an asterisk input.
37
+
38
+
We need to define key and character in a `CharacterShortcutEvent` object to customize hotkeys. We recommend using the description of your event as a key. For example, if the asterisk `*` is defined to make text italic, the key can be 'Asterisk to italic'.
0 commit comments