From 7e5d8ebc2c829dd8f15e557d00f82db5cea580e3 Mon Sep 17 00:00:00 2001 From: Thelonius Kort Date: Mon, 13 Jul 2020 18:53:18 +0200 Subject: [PATCH] basically working for one user (no user/all users actually) --- assets/js/app.js | 12 ++++++++++- lib/clip_web/live/board_live.ex | 38 +++++++++++++++++++++++++++++++++ lib/clip_web/router.ex | 3 ++- 3 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 lib/clip_web/live/board_live.ex diff --git a/assets/js/app.js b/assets/js/app.js index dc8033b..81d9aa9 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -17,8 +17,18 @@ import {Socket} from "phoenix" import NProgress from "nprogress" import {LiveSocket} from "phoenix_live_view" +let Hooks = {} +Hooks.SnippetInput = { + updated(){ + // + cursor reposition logic + // console.log(['dings', this.el.dataset]) + this.el.value = this.el.dataset.updatedVal + // this.el.select() + } +} + let csrfToken = document.querySelector("meta[name='csrf-token']").getAttribute("content") -let liveSocket = new LiveSocket("/live", Socket, {params: {_csrf_token: csrfToken}}) +let liveSocket = new LiveSocket("/live", Socket, {hooks: Hooks, params: {_csrf_token: csrfToken}}) // Show progress bar on live navigation and form submits window.addEventListener("phx:page-loading-start", info => NProgress.start()) diff --git a/lib/clip_web/live/board_live.ex b/lib/clip_web/live/board_live.ex new file mode 100644 index 0000000..c70036f --- /dev/null +++ b/lib/clip_web/live/board_live.ex @@ -0,0 +1,38 @@ +defmodule ClipWeb.BoardLive do + use ClipWeb, :live_view + + @impl true + def render(assigns) do + ~L""" +
+ +
+ Current content: <%= @snippet %> +