mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-10-26 13:27:05 +08:00
Add insert button for diagrams (#1134)
This commit is contained in:
parent
b570fcffe3
commit
4e49b6e643
2 changed files with 26 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 %>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue