Skip to content

feat: add more text formats to telegram editor#1499

Open
pottycat wants to merge 7 commits into
gitroomhq:mainfrom
pottycat:feature/add-telegram-text-formats
Open

feat: add more text formats to telegram editor#1499
pottycat wants to merge 7 commits into
gitroomhq:mainfrom
pottycat:feature/add-telegram-text-formats

Conversation

@pottycat
Copy link
Copy Markdown

@pottycat pottycat commented May 7, 2026

Closes #1352

What kind of change does this PR introduce?

It adds following text formats to telegram editor

  • italic
  • strikethrough
  • blockquote
  • code
  • link insertion

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
telegramoutput

Checklist:

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

  • I have read the CONTRIBUTING guide.
  • I confirm I have not used AI to submit this PR or generate code for it.
  • I checked that there were no similar issues or PRs already open for this.
  • This PR fixes just ONE issue

@postiz-contribution postiz-contribution Bot added the contribution:approved Approved contributor label May 7, 2026
@pottycat pottycat marked this pull request as ready for review May 7, 2026 10:16
Comment on lines +941 to +943
Link.extend({
inclusive: false,
}),

This comment was marked as outdated.

Comment on lines +581 to +586
.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.

Comment on lines +7 to +9
editor?.commands?.unsetUnderline();
editor?.commands?.toggleCode();
editor?.commands?.focus();

This comment was marked as outdated.

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 ?? {};
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@nevo-david
Copy link
Copy Markdown
Contributor

@pottycat since you added also an ascii version of it, I think we can enable it on all the providers no?

@postiz-contribution

This comment has been minimized.

@postiz-contribution postiz-contribution Bot added contribution:denied Application denied and removed contribution:approved Approved contributor labels May 9, 2026
@postiz-contribution postiz-contribution Bot reopened this May 9, 2026
@postiz-contribution
Copy link
Copy Markdown

@pottycat's application for Postiz was approved — reopening this PR.

@postiz-contribution postiz-contribution Bot added contribution:approved Approved contributor and removed contribution:denied Application denied labels May 9, 2026
@pottycat
Copy link
Copy Markdown
Author

@pottycat since you added also an ascii version of it, I think we can enable it on all the providers no?

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

@pottycat pottycat force-pushed the feature/add-telegram-text-formats branch from 5af8474 to 143dd06 Compare May 14, 2026 05:58
Comment on lines 795 to 805
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.

Comment on lines +800 to +806
<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' && (
Copy link
Copy Markdown

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
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

Copy link
Copy Markdown
Author

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.

Copy link
Copy Markdown
Author

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.

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.

Comment on lines +569 to +579
.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(''));
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@pottycat pottycat force-pushed the feature/add-telegram-text-formats branch from b4bac3d to 00a29cf Compare May 18, 2026 05:20
@egelhaus egelhaus added the contribution:evaluate Evaluate the PR again label May 30, 2026
@postiz-contribution
Copy link
Copy Markdown

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.

@postiz-contribution postiz-contribution Bot added contribution:cla-pending Awaiting CLA signature / DCO sign-off and removed contribution:approved Approved contributor contribution:evaluate Evaluate the PR again labels May 30, 2026
@postiz-contribution postiz-contribution Bot added contribution:approved Approved contributor and removed contribution:cla-pending Awaiting CLA signature / DCO sign-off labels May 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contribution:approved Approved contributor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Telegram texts formatting and ability to make link of the text

3 participants