Skip to content

Commit

Permalink
Enable visual editor on new pages
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristianTovar committed Jun 26, 2024
1 parent 657a805 commit ca86272
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,9 @@ defmodule Beacon.LiveAdmin.PageEditorLive.FormComponent do
<.header>
<%= @page_title %>
<:actions>
<.button :if={@live_action == :edit && @editor == "code" && @page.format == :heex} type="button" phx-click="enable_editor" phx-value-editor="visual" class="uppercase">Visual Editor</.button>
<.button :if={@live_action in [:new, :edit] && @editor == "code" && @page.format == :heex} type="button" phx-click="enable_editor" phx-value-editor="visual" class="uppercase">
Visual Editor
</.button>
<.button :if={@live_action == :edit && @editor == "visual"} type="button" phx-click="enable_editor" phx-value-editor="code" class="uppercase">Code Editor</.button>
<.button :if={@live_action == :new} phx-disable-with="Saving..." form="page-form" class="uppercase">Create Draft Page</.button>
<.button :if={@live_action == :edit} phx-disable-with="Saving..." form="page-form" class="uppercase">Save Changes</.button>
Expand Down
8 changes: 6 additions & 2 deletions lib/beacon/live_admin/live/page_editor_live/new.ex
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,15 @@ defmodule Beacon.LiveAdmin.PageEditorLive.New do
end

defp build_new_page(site, [layout | _] = _layouts) do
id = Ecto.UUID.generate()

%Beacon.Content.Page{
path: "",
path: "/page-#{id}",
site: site,
layout_id: layout.id,
layout: layout
layout: layout,
title: "/page-#{id}",
template: "<div>Welcome to BeaconCMS!</div>"
}
end

Expand Down

0 comments on commit ca86272

Please sign in to comment.