fix: insert link/media lands at the cursor and closes the overlay instead of breaking the editor
This commit is contained in:
@@ -155,7 +155,7 @@ defmodule BDS.Desktop.ShellLive.OverlayManager do
|
||||
ShellOverlayComponents.markdown_link(result.title, result.canonical_url)}
|
||||
)
|
||||
|
||||
socket
|
||||
assign(socket, :shell_overlay, nil)
|
||||
end
|
||||
|
||||
{%{kind: :insert_media}, %{type: :post, id: post_id}} ->
|
||||
@@ -172,7 +172,7 @@ defmodule BDS.Desktop.ShellLive.OverlayManager do
|
||||
end
|
||||
|
||||
Notify.parent({:post_editor_insert_content, post_id, syntax})
|
||||
socket
|
||||
assign(socket, :shell_overlay, nil)
|
||||
end
|
||||
|
||||
_other ->
|
||||
@@ -197,10 +197,11 @@ defmodule BDS.Desktop.ShellLive.OverlayManager do
|
||||
|
||||
if details do
|
||||
Notify.parent({:post_editor_insert_content, post_id, details})
|
||||
assign(socket, :shell_overlay, nil)
|
||||
else
|
||||
socket
|
||||
end
|
||||
|
||||
socket
|
||||
|
||||
_other ->
|
||||
socket
|
||||
end
|
||||
|
||||
@@ -117,7 +117,6 @@ defmodule BDS.Desktop.ShellLive.PostEditor do
|
||||
id: socket.assigns.post_id,
|
||||
content: content
|
||||
})
|
||||
|> assign(:shell_overlay, nil)
|
||||
|
||||
{:ok, socket}
|
||||
end
|
||||
@@ -316,18 +315,6 @@ defmodule BDS.Desktop.ShellLive.PostEditor do
|
||||
{:noreply, do_remove_list_value(socket, :categories, category)}
|
||||
end
|
||||
|
||||
def handle_event("insert_content", %{"content" => content}, socket) do
|
||||
socket =
|
||||
socket
|
||||
|> Phoenix.LiveView.push_event("post-editor-insert-content", %{
|
||||
id: socket.assigns.post_id,
|
||||
content: content
|
||||
})
|
||||
|> assign(:shell_overlay, nil)
|
||||
|
||||
{:noreply, socket}
|
||||
end
|
||||
|
||||
def handle_event("close_quick_actions", _params, socket) do
|
||||
socket =
|
||||
socket
|
||||
@@ -892,7 +879,7 @@ defmodule BDS.Desktop.ShellLive.PostEditor do
|
||||
end)
|
||||
|
||||
if map_size(attrs) == 0 do
|
||||
assign(socket, :shell_overlay, nil)
|
||||
socket
|
||||
else
|
||||
case Posts.update_post(post_id, attrs) do
|
||||
{:ok, updated_post} ->
|
||||
@@ -910,7 +897,6 @@ defmodule BDS.Desktop.ShellLive.PostEditor do
|
||||
)
|
||||
|> assign(:save_state, :dirty)
|
||||
|> assign(:dirty?, true)
|
||||
|> assign(:shell_overlay, nil)
|
||||
|> build_data()
|
||||
|
||||
Notify.dirty(:post, post_id, true)
|
||||
|
||||
Reference in New Issue
Block a user