AcePhoenix
A Phoenix component for integrating the Ace code editor into your Phoenix applications.
Installation
Add ace_phoenix to your list of dependencies in mix.exs:
def deps do
[
{:ace_phoenix, "~> 0.1.0"}
]
endUsage
-
In your
app.js, import and set up the AceEditorHook:
import { AceEditorHook } from "ace_phoenix";
let Hooks = {};
Hooks.AceEditor = AceEditorHook;
let liveSocket = new LiveSocket("/live", Socket, { hooks: Hooks, params: { _csrf_token: csrfToken } });- In your LiveView or component:
import AcePhoenix.Components.AceEditor
def render(assigns) do
~H"""
<.ace_editor id="my-editor" content={@content} mode="elixir" theme="monokai" />
"""
end
def handle_event("ace-change", %{"content" => content}, socket) do
{:noreply, assign(socket, content: content)}
endLicense
This project is licensed under the MIT License.