-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
feat: add more text formats to telegram editor #1499
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
Open
pottycat
wants to merge
7
commits into
gitroomhq:main
Choose a base branch
from
pottycat:feature/add-telegram-text-formats
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+501
−29
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
18805ef
feat: add more text formats to telegram editor
pottycat 3b4f256
chore: remove unnecessary console.log & format code
pottycat 6ccd9d1
chore: fix blockquote & Link bug
pottycat 0795521
chore: utilise existing AComponent for link insertion
pottycat 9e6bfa6
text formats available to all providers
pottycat f9a0021
align text formats
pottycat 00a29cf
fix: handle multiline content in convertToAscii
pottycat File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
apps/frontend/src/components/new-launch/blockquote.text.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| import { FC } from 'react'; | ||
|
|
||
| export const BlockquoteText: FC<{ | ||
| editor: any; | ||
| }> = ({ editor }) => { | ||
| const mark = () => { | ||
| editor?.commands?.toggleBlockquote(); | ||
| editor?.commands?.focus(); | ||
| }; | ||
| return ( | ||
| <div | ||
| data-tooltip-id="tooltip" | ||
| data-tooltip-content="Blockquote" | ||
| onClick={mark} | ||
| className="select-none cursor-pointer rounded-[6px] w-[30px] h-[30px] bg-newColColor flex justify-center items-center" | ||
| > | ||
| <svg | ||
| xmlns="http://www.w3.org/2000/svg" | ||
| width="16" | ||
| height="16" | ||
| viewBox="0 0 16 16" | ||
| fill="none" | ||
| > | ||
| <path | ||
| d="M2.66699 6.00033C2.66699 4.52757 3.86090 3.33366 5.33366 3.33366H5.66699C6.03518 3.33366 6.33366 3.63214 6.33366 4.00033C6.33366 4.36852 6.03518 4.66699 5.66699 4.66699H5.33366C4.59728 4.66699 4.00033 5.26395 4.00033 6.00033V6.33366H5.66699C6.03518 6.33366 6.33366 6.63214 6.33366 7.00033V10.667C6.33366 11.0352 6.03518 11.3337 5.66699 11.3337H2.66699C2.29880 11.3337 2.00033 11.0352 2.00033 10.667V6.00033H2.66699ZM2.00033 6.00033H2.66699" | ||
| stroke="currentColor" | ||
| strokeWidth="1.2" | ||
| strokeLinecap="round" | ||
| strokeLinejoin="round" | ||
| /> | ||
| <path | ||
| d="M9.33366 6.00033C9.33366 4.52757 10.5276 3.33366 12.0003 3.33366H12.3337C12.7018 3.33366 13.0003 3.63214 13.0003 4.00033C13.0003 4.36852 12.7018 4.66699 12.3337 4.66699H12.0003C11.2640 4.66699 10.667 5.26395 10.667 6.00033V6.33366H12.3337C12.7018 6.33366 13.0003 6.63214 13.0003 7.00033V10.667C13.0003 11.0352 12.7018 11.3337 12.3337 11.3337H9.33366C8.96547 11.3337 8.66699 11.0352 8.66699 10.667V6.00033H9.33366ZM8.66699 6.00033H9.33366" | ||
| stroke="currentColor" | ||
| strokeWidth="1.2" | ||
| strokeLinecap="round" | ||
| strokeLinejoin="round" | ||
| /> | ||
| </svg> | ||
| </div> | ||
| ); | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| import { FC } from 'react'; | ||
|
|
||
| export const CodeText: FC<{ | ||
| editor: any; | ||
| }> = ({ editor }) => { | ||
| const mark = () => { | ||
| editor?.commands?.toggleCode(); | ||
| editor?.commands?.focus(); | ||
| }; | ||
| return ( | ||
| <div | ||
| data-tooltip-id="tooltip" | ||
| data-tooltip-content="Code Text" | ||
| onClick={mark} | ||
| className="select-none cursor-pointer rounded-[6px] w-[30px] h-[30px] bg-newColColor flex justify-center items-center" | ||
| > | ||
| <svg | ||
| xmlns="http://www.w3.org/2000/svg" | ||
| width="16" | ||
| height="16" | ||
| viewBox="0 0 16 16" | ||
| fill="none" | ||
| > | ||
| <path | ||
| d="M5.33333 5.33301L2 7.99967L5.33333 10.6663M10.6667 5.33301L14 7.99967L10.6667 10.6663" | ||
| stroke="currentColor" | ||
| strokeWidth="1.2" | ||
| strokeLinecap="round" | ||
| strokeLinejoin="round" | ||
| /> | ||
| </svg> | ||
| </div> | ||
| ); | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| import { FC } from 'react'; | ||
|
|
||
| export const ItalicText: FC<{ | ||
| editor: any; | ||
| }> = ({ editor }) => { | ||
| const mark = () => { | ||
| editor?.commands?.toggleItalic(); | ||
| editor?.commands?.focus(); | ||
| }; | ||
| return ( | ||
| <div | ||
| data-tooltip-id="tooltip" | ||
| data-tooltip-content="Italic Text" | ||
| onClick={mark} | ||
| className="select-none cursor-pointer rounded-[6px] w-[30px] h-[30px] bg-newColColor flex justify-center items-center" | ||
| > | ||
| <svg | ||
| xmlns="http://www.w3.org/2000/svg" | ||
| width="16" | ||
| height="16" | ||
| viewBox="0 0 16 16" | ||
| fill="none" | ||
| > | ||
| <path | ||
| d="M10 2.66699H6.66667M9.33333 13.3337H6M8.66667 2.66699L7.33333 13.3337" | ||
| stroke="currentColor" | ||
| strokeWidth="1.2" | ||
| strokeLinecap="round" | ||
| strokeLinejoin="round" | ||
| /> | ||
| </svg> | ||
| </div> | ||
| ); | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| import { FC } from 'react'; | ||
|
|
||
| export const StrikeText: FC<{ | ||
| editor: any; | ||
| }> = ({ editor }) => { | ||
| const mark = () => { | ||
| editor?.commands?.toggleStrike(); | ||
| editor?.commands?.focus(); | ||
| }; | ||
| return ( | ||
| <div | ||
| data-tooltip-id="tooltip" | ||
| data-tooltip-content="Strike Text" | ||
| onClick={mark} | ||
| className="select-none cursor-pointer rounded-[6px] w-[30px] h-[30px] bg-newColColor flex justify-center items-center" | ||
| > | ||
| <svg | ||
| xmlns="http://www.w3.org/2000/svg" | ||
| width="16" | ||
| height="16" | ||
| viewBox="0 0 16 16" | ||
| fill="none" | ||
| > | ||
| <path | ||
| d="M2 8H14M5.33333 5.33301C5.33333 3.86025 6.52724 2.66634 8 2.66634C9.47276 2.66634 10.6667 3.86025 10.6667 5.33301C10.6667 6.80577 9.47276 8.00033 8 8.00033M8 8.00033C9.47276 8.00033 10.6667 9.19423 10.6667 10.667C10.6667 12.1397 9.47276 13.3337 8 13.3337C6.52724 13.3337 5.33333 12.1397 5.33333 10.667" | ||
| stroke="currentColor" | ||
| strokeWidth="1.2" | ||
| strokeLinecap="round" | ||
| strokeLinejoin="round" | ||
| /> | ||
| </svg> | ||
| </div> | ||
| ); | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Bug: The blockquote button is incorrectly enabled for non-Telegram providers, causing text to be converted to full-width Unicode characters when posted.
Severity: HIGH
Suggested Fix
Conditionally render the blockquote button to only appear for editors where it is semantically supported, such as Telegram. This can be achieved by moving the button inside the
identifier === 'telegram'check, similar to how the link insertion button is handled.Prompt for AI Agent
Also affects:
libraries/helpers/src/utils/strip.html.validation.ts:581~586There 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.
@nevo-david I am facing confusion about placement of text format buttons. I am thinking about placing Bold, Italic and Underline in global mode. Strikethrough, Blockquote, and Code in editorType html or mardown. The link insertion button on Telegram only.
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 have placed all Bold, Italic, Underline, Strikethough, Blockquote and Code in global mode because it is converted into ASCII which is rendered well in all the platform. The link insertion is only available to Telegram for the moment. I am thinking about raising a separate PR for including link insertion options to all the platform that supports it in message.