# Pull Request Template ## Description This PR includes, 1. **Channel-specific formatting and menu options** for the rich reply editor. 2. **Removal of the plain reply editor** and full **standardization** on the rich reply editor across all channels. 3. **Fix for multiple canned responses insertion:** * **Before:** The plain editor only allowed inserting canned responses at the beginning of a message, making it impossible to combine multiple canned responses in a single reply. This caused inconsistent behavior across the app. * **Solution:** Replaced the plain reply editor with the rich (ProseMirror) editor to ensure a unified experience. Agents can now insert multiple canned responses at any cursor position. 4. **Floating editor menu** for the reply box to improve accessibility and overall user experience. 5. **New Strikethrough formatting option** added to the editor menu. --- **Editor repo PR**: https://github.com/chatwoot/prosemirror-schema/pull/36 Fixes https://github.com/chatwoot/chatwoot/issues/12517, [CW-5924](https://linear.app/chatwoot/issue/CW-5924/standardize-the-editor), [CW-5679](https://linear.app/chatwoot/issue/CW-5679/allow-inserting-multiple-canned-responses-in-a-single-message) ## Type of change - [x] Bug fix (non-breaking change which fixes an issue) ## How Has This Been Tested? ### Screenshot **Dark** <img width="850" height="345" alt="image" src="https://github.com/user-attachments/assets/47748e6c-380f-44a3-9e3b-c27e0c830bd0" /> **Light** <img width="850" height="345" alt="image" src="https://github.com/user-attachments/assets/6746cf32-bf63-4280-a5bd-bbd42c3cbe84" /> ## Checklist: - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my code - [x] I have commented on my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged and published in downstream modules --------- Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com> Co-authored-by: Pranav <pranav@chatwoot.com> Co-authored-by: Vinay Keerthi <11478411+stonecharioteer@users.noreply.github.com>
98 lines
3.3 KiB
Ruby
98 lines
3.3 KiB
Ruby
require 'rails_helper'
|
|
|
|
RSpec.describe ChatwootMarkdownRenderer do
|
|
let(:markdown_content) { 'This is a *test* content with ^markdown^' }
|
|
let(:plain_text_content) { 'This is a test content with markdown' }
|
|
let(:doc) { instance_double(CommonMarker::Node) }
|
|
let(:renderer) { described_class.new(markdown_content) }
|
|
let(:markdown_renderer) { instance_double(CustomMarkdownRenderer) }
|
|
let(:base_markdown_renderer) { instance_double(BaseMarkdownRenderer) }
|
|
let(:html_content) { '<p>This is a <em>test</em> content with <sup>markdown</sup></p>' }
|
|
|
|
before do
|
|
allow(CommonMarker).to receive(:render_doc).with(markdown_content, :DEFAULT, [:strikethrough]).and_return(doc)
|
|
allow(CustomMarkdownRenderer).to receive(:new).and_return(markdown_renderer)
|
|
allow(markdown_renderer).to receive(:render).with(doc).and_return(html_content)
|
|
end
|
|
|
|
describe '#render_article' do
|
|
before do
|
|
allow(CommonMarker).to receive(:render_doc).with(markdown_content, :DEFAULT, [:table]).and_return(doc)
|
|
end
|
|
|
|
let(:rendered_content) { renderer.render_article }
|
|
|
|
it 'renders the markdown content to html' do
|
|
expect(rendered_content.to_s).to eq(html_content)
|
|
end
|
|
|
|
it 'returns an html safe string' do
|
|
expect(rendered_content).to be_html_safe
|
|
end
|
|
|
|
context 'when tables in markdown' do
|
|
let(:markdown_content) do
|
|
<<~MARKDOWN
|
|
This is a **bold** text and *italic* text.
|
|
|
|
| Header1 | Header2 |
|
|
| ------------ | ------------ |
|
|
| **Bold Cell**| *Italic Cell*|
|
|
| Cell3 | Cell4 |
|
|
MARKDOWN
|
|
end
|
|
|
|
let(:html_content) do
|
|
<<~HTML
|
|
<p>This is a <strong>bold</strong> text and <em>italic</em> text.</p>
|
|
<table>
|
|
<thead>
|
|
<tr><th>Header1</th><th>Header2</th></tr>
|
|
</thead>
|
|
<tbody>
|
|
<tr><td><strong>Bold Cell</strong></td><td><em>Italic Cell</em></td></tr>
|
|
<tr><td>Cell3</td><td>Cell4</td></tr>
|
|
</tbody>
|
|
</table>
|
|
HTML
|
|
end
|
|
|
|
it 'renders tables in html' do
|
|
expect(rendered_content.to_s).to eq(html_content)
|
|
end
|
|
end
|
|
end
|
|
|
|
describe '#render_message' do
|
|
let(:message_html_content) { '<p>This is a <em>test</em> content with ^markdown^</p>' }
|
|
let(:rendered_message) { renderer.render_message }
|
|
|
|
before do
|
|
allow(CommonMarker).to receive(:render_html).with(markdown_content).and_return(message_html_content)
|
|
allow(BaseMarkdownRenderer).to receive(:new).and_return(base_markdown_renderer)
|
|
allow(base_markdown_renderer).to receive(:render).with(doc).and_return(message_html_content)
|
|
end
|
|
|
|
it 'renders the markdown message to html' do
|
|
expect(rendered_message.to_s).to eq(message_html_content)
|
|
end
|
|
|
|
it 'returns an html safe string' do
|
|
expect(rendered_message).to be_html_safe
|
|
end
|
|
end
|
|
|
|
describe '#render_markdown_to_plain_text' do
|
|
let(:rendered_content) { renderer.render_markdown_to_plain_text }
|
|
|
|
before do
|
|
allow(CommonMarker).to receive(:render_doc).with(markdown_content, :DEFAULT).and_return(doc)
|
|
allow(doc).to receive(:to_plaintext).and_return(plain_text_content)
|
|
end
|
|
|
|
it 'renders the markdown content to plain text' do
|
|
expect(rendered_content).to eq(plain_text_content)
|
|
end
|
|
end
|
|
end
|