Add insert button for diagrams (#1134)

This commit is contained in:
Jonatan Kłosko 2022-04-19 16:51:46 +02:00 committed by GitHub
parent b570fcffe3
commit 4e49b6e643
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 0 deletions

View file

@ -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

View file

@ -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 %>