I would like to suggest adding keyboard shortcuts for cloze-related functions in Logseq. Similar to the functionality of pressing “Ctrl+B” to bold selected text, I would like the ability to select text and use certain shortcuts to add “{{cloze xxx}}” around the selected text.
Bader
May 29, 2023, 3:44am
2
Good idea! I can implement this easily after #9245 is merged.
logseq:master
← Bad3r:enhance/underline-shortcut
opened 03:46AM - 26 Apr 23 UTC
Update formatting functions and format-text! to use %s pattern
TODO
- [ ] … use `util/get-selected-text`
Depends on:
- #9388
breaking change:
- Remove `/underline` command and replace it with `modKey + u` shortcut
issues:
- close #9390
- close https://github.com/logseq/logseq/issues/8790#issuecomment-1464049503
- close #8819 (duplicate)
forum posts:
- https://discuss.logseq.com/t/more-options-for-text-formatting-bold-strikethrough-underline-etc/
-
# QA Testing Instructions for Text Formatting Feature
Repeat the steps for markdown and org-mode formats.
## Initial Setup:
1. Create a new block with the sentence: `LOGSEQ: Logical Organization Graphical-System for Efficient Querying.`
## Test for Text Formatting Features:
### Bold:
2. Select the word `Graphical` and apply bold formatting (`$MOD+b`)
3. Expected Result: `**Graphical**|-System`
4. Verify the result and cursor (`|`) position.
Select the styled word `Graphical` again and remove the formatting by pressing the same shortcut.
### Italic:
5. Select the word `Graphical` and apply italic formatting (`$MOD+i`)
6. Expected Result: `*Graphical*|-System`
7. Verify the result and cursor (`|`) position.
Select the styled word `Graphical` again and remove the formatting by pressing the same shortcut.
### Underline:
8. Select the word `Graphical` and apply underline formatting (`$MOD+u`)
9. Expected Result: `<u>Graphical</u>|-System`
10. Verify the result and cursor (`|`) position.
Select the styled word `Graphical` again and remove the formatting by pressing the same shortcut.
### Strikethrough:
11. Select the word `Graphical` and apply the strikethrough formatting (`$MOD+Shift+s`).
12. Expected Result: `~~Graphical~~|-System`
13. Verify the result and cursor (`|`) position.
Select the styled word `Graphical` again and remove the formatting by pressing the same shortcut.
### Sequential Application and Removal of Formatting:
14. Select the word `Graphical` and apply all the text formatting shortcuts. Example: `$MOD+i`, `$MOD+u`, `$MOD+Shift+s`, `$MOD+b`.
15. Expected Result: `**~~<u>*Graphical*</u>~~**|-System`
16. Verify the result and cursor (`|`) position.
17. Then, remove each formatting one by one in reverse order.
18. Expected Result: `Graphical|-System` (`Graphical` should remain selected)
19. Expected Result: The word `Graphical` should remain selected after removing the formatting.
## Test for Formatting Without Selection:
26. In a new block without any text selected, apply each formatting command or shortcut. Example: `$MOD+i`, `$MOD+u`, `$MOD+Shift+s`, `$MOD+b`.
15. Expected Result: `**~~<u>*|*</u>~~**`
28. Verify the result and cursor position.
Please remember to document any discrepancies between the expected and actual results, along with any error messages or issues encountered during testing.
https://user-images.githubusercontent.com/25513724/235405226-f17ee2ab-3f55-4a34-85bb-a35e91324d08.mp4
This PR updates the text formatting functions to use a consistent %s pattern for wrapping text with the appropriate formatting markers. The `format-text!` function has also been updated to accommodate these changes.
- Updated get-bold, get-italic, get-strike-through, get-underline, and get-highlight functions to use %s pattern
- Modified format-text! to handle the new %s pattern in the formatting functions
- Ensured compatibility with existing text formatting behavior
The result of this change is introducing a new feature; underline text using `mod + u`. Since markdown doesn't support underlining, HTML syntax is needed. Due to the opening and closing tags being different for HTML, there was a need to update the `text-format!` function to accommodate this case. Instead of writing a special case for underlines, I opted to modify the existing format used to a more malleable one.
---
> **Warning**
> Old PR description
Discord: https://discord.com/channels/725182569297215569/735747000649252894/1100463176270745640
This pull request introduces a new feature that adds a keyboard shortcut for underlining text `Mod + u` in both Markdown and Org-mode formats. The implementation modifies the `get-underline` function and introduces the `underline-format!` function to support the respective underline syntax for each format. In Org-mode, the underscore (_) syntax is used, while in Markdown, the text is wrapped with the `<u>` and `</u>` HTML tags.
Since Markdown does not natively support underlines, I opted to use HTML tags as a workaround. This presented a challenge as the opening and closing tags are different. Initially, I considered modifying the `format-text!` function to handle this case, but doing so could potentially break other features. As a result, I decided to not change it.
This approach may have introduced some code duplication, and there could be a more efficient solution beyond my current understanding of the code. I apologize if this adds extra work to the review process. Please let me know if you have any suggestions for improvements or if further modifications are needed.
All translations have been added and its been added to the shortcuts page.
Video Demo:
https://user-images.githubusercontent.com/25513724/234464747-0310092b-6c94-424b-a65d-f3486ee69b5b.mp4
QA Steps:
- open a markdown and/or org-mode graph
- select some text
- use the shortcut Mod + u to underline it
Test unwrapping
- select wrapped text
- use the same shortcut to undo the formatting.
1 Like
Edwin
September 5, 2023, 1:38am
3
Great request!
I would like to suggest the option to specify a cloze number too as I solely use these types of clozes, so for example using alt+0 for {{cloze xxx}}, but also:
alt+1 for {{c1 xxx}}, alt+2 for {{c2 xxx}}, alt+3 for {{c3 xxx}}, etc.
1 Like