feat: add more text formats to telegram editor#1499
Conversation
| Link.extend({ | ||
| inclusive: false, | ||
| }), |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
| .replace(/<blockquote>(.+?)<\/blockquote>/gi, (match, p1) => { | ||
| const replacer = p1.split('').map((char: string) => { | ||
| return blockquote?.[char] || char; | ||
| }); | ||
| return match.replace(p1, replacer.join('')); | ||
| }) |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
| editor?.commands?.unsetUnderline(); | ||
| editor?.commands?.toggleCode(); | ||
| editor?.commands?.focus(); |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
| const [isModalOpen, setIsModalOpen] = useState(false); | ||
| const [selectedText, setSelectedText] = useState(''); | ||
| // Get the currently selected text from the editor (if any) | ||
| const { from, to } = editor?.state?.selection ?? {}; |
There was a problem hiding this comment.
Bug: The LinkText component fails to apply links because it captures the text selection at render time, and the selection is lost when the link modal opens.
Severity: HIGH
Suggested Fix
Before calling editor?.commands?.setLink(), the editor's focus and selection range should be restored. This can be achieved by calling editor?.chain()?.focus() and potentially extendMarkRange('link') to re-select the intended text, similar to the implementation in a.component.tsx.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location: apps/frontend/src/components/new-launch/link.text.tsx#L103
Potential issue: The `LinkText` component captures the editor's selection state (`from`,
`to`) at the time the component renders, not when the link button is clicked. When the
button is clicked, a modal opens, which causes the editor to lose focus and its text
selection to be cleared. When the user confirms the link in the modal, the `handleApply`
function calls `editor?.commands?.setLink()`. This command operates on the editor's
current selection, which is now empty. As a result, the link is not applied to the
originally selected text.
|
@pottycat since you added also an ascii version of it, I think we can enable it on all the providers no? |
This comment has been minimized.
This comment has been minimized.
|
@pottycat's application for Postiz was approved — reopening this PR. |
I tested it. So, yes we can enable it on all platforms. I will make changes to enable it in all providers not just in telegram |
5af8474 to
143dd06
Compare
| editor={editorRef?.current?.editor} | ||
| currentValue={props.value!} | ||
| /> | ||
| <ItalicText editor={editorRef?.current?.editor} /> | ||
| <StrikeText editor={editorRef?.current?.editor} /> | ||
| <BlockquoteText editor={editorRef?.current?.editor} /> | ||
| <CodeText editor={editorRef?.current?.editor} /> | ||
| <AComponent editor={editorRef?.current?.editor} /> | ||
| </> | ||
| )} | ||
| {(editorType === 'markdown' || editorType === 'html') && |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
| <BlockquoteText editor={editorRef?.current?.editor} /> | ||
| <CodeText editor={editorRef?.current?.editor} /> | ||
| </> | ||
| )} | ||
| {/* link insertion may not work on all providers e.g insta, x, facebook */} | ||
| {(editorType === 'html' || editorType === 'markdown') && | ||
| identifier === 'telegram' && ( |
There was a problem hiding this comment.
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
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location: apps/frontend/src/components/new-launch/editor.tsx#L800-L806
Potential issue: The blockquote formatting button has been made available for all editor
types, including 'normal' editors used for platforms like X, Instagram, and LinkedIn.
However, the underlying implementation for these platforms was not updated to support
blockquotes. When a user applies blockquote formatting, the content is processed by
`convertToAscii`, which converts the text within `<blockquote>` tags into full-width
Unicode characters (e.g., 'a' becomes 'a'). This results in posts with garbled,
unintended text on platforms that do not have native blockquote support, as the feature
was only intended to work for Telegram.
Also affects:
libraries/helpers/src/utils/strip.html.validation.ts:581~586
There was a problem hiding this comment.
@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.
@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.
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.
| .replace(/<em>(.+?)<\/em>/gi, (match, p1) => { | ||
| const replacer = p1.split('').map((char: string) => { | ||
| return italic?.[char] || char; | ||
| }); | ||
| return match.replace(p1, replacer.join('')); | ||
| }) | ||
| .replace(/<s>(.+?)<\/s>/gi, (match, p1) => { | ||
| const replacer = p1.split('').map((char: string) => { | ||
| return strikethrough?.[char] || char; | ||
| }); | ||
| return match.replace(p1, replacer.join('')); |
There was a problem hiding this comment.
Bug: The regex for <em>, <s>, and <code> tags in convertToAscii does not handle multiline content, unlike the regex for <blockquote>.
Severity: LOW
Suggested Fix
Update the regular expressions for <em>, <s>, and <code> tags to use [\s\S]+? instead of .+?. This will ensure consistency with the <blockquote> handling and correctly process multiline content within these tags.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location: libraries/helpers/src/utils/strip.html.validation.ts#L569-L579
Potential issue: In the `convertToAscii` function, the regular expressions used to
capture content within `<em>`, `<s>`, and `<code>` tags use the pattern `.+?`. This
pattern does not match newline characters. This is inconsistent with the regex for
`<blockquote>`, which correctly uses `[\s\S]+?` to handle multiline content. While the
current editor configuration makes it unlikely for these inline tags to contain
newlines, this is a latent bug. If content with newlines is pasted into the editor or if
the editor's behavior changes in the future (e.g., to support soft breaks), formatting
will be silently lost for any multiline formatted text.
b4bac3d to
00a29cf
Compare
|
Hi @pottycat! Before we can accept contributions to Postiz you need to sign the Contributor License Agreement. Sign here: https://contribute.postiz.com/p/postiz/cla. Your PR stays open and we'll re-check automatically once signed. |
Closes #1352
What kind of change does this PR introduce?
It adds following text formats to telegram editor
Why was this change needed?
Currently, Postiz editor only provides underline and bold text format options. Telegram also supports italic, strikethough, blockquote, code and link insertion in text messages. The change will help user utilize all the formats supported by telegram in postiz editor.
Other information:
a working demo
Postiz.Calendar.-.7.May.2026.mp4
telegram result

Checklist:
Put a "X" in the boxes below to indicate you have followed the checklist;