diff --git a/app/controllers/dtext_previews_controller.rb b/app/controllers/dtext_previews_controller.rb index 7fd6c901e..08e9ba702 100644 --- a/app/controllers/dtext_previews_controller.rb +++ b/app/controllers/dtext_previews_controller.rb @@ -1,5 +1,8 @@ class DtextPreviewsController < ApplicationController def create - render :inline => "<%= format_text(params[:body]) %>" + @inline = params[:inline].to_s.truthy? + @disable_mentions = params[:disable_mentions].to_s.truthy? + + render inline: "<%= format_text(params[:body], inline: @inline, disable_mentions: @disable_mentions) %>" end end diff --git a/app/javascript/src/javascripts/dtext.js b/app/javascript/src/javascripts/dtext.js index 59121e65b..94d708f79 100644 --- a/app/javascript/src/javascripts/dtext.js +++ b/app/javascript/src/javascripts/dtext.js @@ -21,20 +21,14 @@ Dtext.initialize_expandables = function() { }); } -Dtext.call_preview = function(e, $button, $input, $preview) { +Dtext.call_preview = async function(e, $button, $input, $preview) { $button.val("Edit"); $input.hide(); $preview.text("Loading...").fadeIn("fast"); - $.ajax({ - type: "post", - url: "/dtext_preview", - data: { - body: $input.val() - }, - success: function(data) { - $preview.html(data).fadeIn("fast"); - } - }); + + let inline = $input.is("input"); + let html = await $.post("/dtext_preview", { body: $input.val(), inline: inline }); + $preview.html(html).fadeIn("fast"); } Dtext.call_edit = function(e, $button, $input, $preview) { diff --git a/app/views/post_appeals/index.html.erb b/app/views/post_appeals/index.html.erb index 7415b91ef..dbdf868a6 100644 --- a/app/views/post_appeals/index.html.erb +++ b/app/views/post_appeals/index.html.erb @@ -20,9 +20,9 @@ <%= PostPresenter.preview(post_appeal.post, :tags => "status:any") %> -
- <%= format_text post_appeal.reason %> -
+ + <%= format_text post_appeal.reason, inline: true %> + <%= link_to post_appeal.post.appeals.size, post_appeals_path(search: { post_id: post_appeal.post_id }) %> diff --git a/app/views/post_flags/index.html.erb b/app/views/post_flags/index.html.erb index 1c9806d75..dca1804d2 100644 --- a/app/views/post_flags/index.html.erb +++ b/app/views/post_flags/index.html.erb @@ -21,9 +21,9 @@ <%= PostPresenter.preview(post_flag.post, :tags => "status:any") %> -
- <%= format_text post_flag.reason %> -
+ + <%= format_text post_flag.reason, inline: true %> + <%= link_to post_flag.post.flags.size, post_flags_path(search: { post_id: post_flag.post_id }) %>