mirror of
https://github.com/discourse/discourse.git
synced 2025-06-05 14:07:30 +08:00
FIX: generates markdown from pasting link (#21241)
After removing `TextareaTextManipulation` from `ChatComposer` and using `TextareaInteractor` as a proxy, one function has been forgotten: `paste(event)` which is not available in glimmer components anymore, and even less avaiable now that the mixin is not tied to a component anymore but a real DOM node. As a solution we now add a manual paste event listener which will call `paste(event)`.
This commit is contained in:
@ -262,4 +262,35 @@ RSpec.describe "Chat composer", type: :system, js: true do
|
||||
expect(find(".chat-composer__input").value).to eq("bb")
|
||||
end
|
||||
end
|
||||
|
||||
context "when pasting link over selected text" do
|
||||
before do
|
||||
channel_1.add(current_user)
|
||||
sign_in(current_user)
|
||||
end
|
||||
|
||||
it "outputs a markdown link" do
|
||||
modifier = /darwin/i =~ RbConfig::CONFIG["host_os"] ? :command : :control
|
||||
select_text = <<-JS
|
||||
const element = document.querySelector(arguments[0]);
|
||||
element.focus();
|
||||
element.setSelectionRange(0, element.value.length)
|
||||
JS
|
||||
|
||||
chat.visit_channel(channel_1)
|
||||
|
||||
find("body").send_keys("https://www.discourse.org")
|
||||
page.execute_script(select_text, ".chat-composer__input")
|
||||
|
||||
page.send_keys [modifier, "c"]
|
||||
page.send_keys [:backspace]
|
||||
|
||||
find("body").send_keys("discourse")
|
||||
page.execute_script(select_text, ".chat-composer__input")
|
||||
|
||||
page.send_keys [modifier, "v"]
|
||||
|
||||
expect(find(".chat-composer__input").value).to eq("[discourse](https://www.discourse.org)")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user