Skip to content

Commit

Permalink
Add insert button for diagrams (#1134)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonatanklosko authored Apr 19, 2022
1 parent b570fcf commit 4e49b6e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/livebook_web/live/session_live.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1281,6 +1281,22 @@ defmodule LivebookWeb.SessionLive do
{:smart, %{kind: kind}}
end

defp cell_type_and_attrs_from_params(%{"type" => "diagram"}) do
source = """
<!-- Learn more at https://mermaid-js.github.io/mermaid -->
```mermaid
graph TD;
A-->B;
A-->C;
B-->D;
C-->D;
```\
"""

{:markdown, %{source: source}}
end

defp section_with_next_index(notebook, section_id, cell_id)

defp section_with_next_index(notebook, section_id, nil) do
Expand Down
10 changes: 10 additions & 0 deletions lib/livebook_web/live/session_live/insert_buttons_component.ex
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@ defmodule LivebookWeb.SessionLive.InsertButtonsComponent do
<.remix_icon icon="h-2" />
<span class="font-medium">Section</span>
</button>
<div class="my-2 border-b border-gray-200"></div>
<button class="menu-item text-gray-500"
role="menuitem"
phx-click="insert_cell_below"
phx-value-type="diagram"
phx-value-section_id={@section_id}
phx-value-cell_id={@cell_id}>
<.remix_icon icon="organization-chart" />
<span class="font-medium">Diagram</span>
</button>
</:content>
</.menu>
<%= cond do %>
Expand Down

0 comments on commit 4e49b6e

Please sign in to comment.