add ctrl-enter submit

This commit is contained in:
shibao 2023-11-04 22:40:56 -04:00
parent 03021614b5
commit 1b49b668b3
17 changed files with 102 additions and 82 deletions

View File

@ -26,6 +26,8 @@ import 'phoenix_html'
import { Socket } from 'phoenix'
import { LiveSocket } from 'phoenix_live_view'
import topbar from 'topbar'
import CtrlEnter from './ctrlenter'
import Date from './date'
import DateTime from './datetime'
@ -34,7 +36,7 @@ let csrfToken
if (csrfTokenElement) { csrfToken = csrfTokenElement.getAttribute('content') }
const liveSocket = new LiveSocket('/live', Socket, {
params: { _csrf_token: csrfToken },
hooks: { Date, DateTime }
hooks: { CtrlEnter, Date, DateTime }
})
// Show progress bar on live navigation and form submits

12
assets/js/ctrlenter.js Normal file
View File

@ -0,0 +1,12 @@
export default {
addFormSubmit (context) {
context.el.addEventListener('keydown', (e) => {
if (e.ctrlKey && e.key === 'Enter') {
context.el.dispatchEvent(
new Event('submit', { bubbles: true, cancelable: true }))
}
})
},
mounted () { this.addFormSubmit(this) },
updated () { this.addFormSubmit(this) }
}

View File

@ -7,6 +7,7 @@
- Make content previews resizable
- Fix live flashes not dismissable by click
- Fix disconnection modal not displaying
- Submit items with ctrl-enter
# v0.1.12
- Code quality fixes

View File

@ -6,6 +6,7 @@
phx-target={@myself}
phx-change="validate"
phx-submit="save"
phx-hook="CtrlEnter"
class="flex flex-col justify-start items-stretch space-y-4"
>
<%= text_input(f, :slug,

View File

@ -10,6 +10,7 @@
phx-target={@myself}
phx-change="validate"
phx-submit="save"
phx-hook="CtrlEnter"
>
<div
:if={@changeset.action && not @changeset.valid?()}

View File

@ -6,6 +6,7 @@
phx-target={@myself}
phx-change="validate"
phx-submit="save"
phx-hook="CtrlEnter"
class="flex flex-col justify-start items-stretch space-y-4"
>
<%= text_input(f, :slug,

View File

@ -6,6 +6,7 @@
phx-target={@myself}
phx-change="validate"
phx-submit="save"
phx-hook="CtrlEnter"
class="flex flex-col justify-start items-stretch space-y-4"
>
<%= text_input(f, :slug,

View File

@ -6,6 +6,7 @@
phx-target={@myself}
phx-change="validate"
phx-submit="save"
phx-hook="CtrlEnter"
class="flex flex-col justify-start items-stretch space-y-4"
>
<%= text_input(f, :title,

View File

@ -108,11 +108,11 @@ msgstr ""
msgid "register"
msgstr ""
#: lib/memex_web/live/context_live/form_component.html.heex:46
#: lib/memex_web/live/invite_live/form_component.html.heex:46
#: lib/memex_web/live/note_live/form_component.html.heex:46
#: lib/memex_web/live/pipeline_live/form_component.html.heex:46
#: lib/memex_web/live/step_live/form_component.html.heex:30
#: lib/memex_web/live/context_live/form_component.html.heex:47
#: lib/memex_web/live/invite_live/form_component.html.heex:47
#: lib/memex_web/live/note_live/form_component.html.heex:47
#: lib/memex_web/live/pipeline_live/form_component.html.heex:47
#: lib/memex_web/live/step_live/form_component.html.heex:31
#, elixir-autogen, elixir-format
msgid "save"
msgstr ""

View File

@ -108,11 +108,11 @@ msgstr ""
msgid "register"
msgstr ""
#: lib/memex_web/live/context_live/form_component.html.heex:46
#: lib/memex_web/live/invite_live/form_component.html.heex:46
#: lib/memex_web/live/note_live/form_component.html.heex:46
#: lib/memex_web/live/pipeline_live/form_component.html.heex:46
#: lib/memex_web/live/step_live/form_component.html.heex:30
#: lib/memex_web/live/context_live/form_component.html.heex:47
#: lib/memex_web/live/invite_live/form_component.html.heex:47
#: lib/memex_web/live/note_live/form_component.html.heex:47
#: lib/memex_web/live/pipeline_live/form_component.html.heex:47
#: lib/memex_web/live/step_live/form_component.html.heex:31
#, elixir-autogen, elixir-format
msgid "save"
msgstr ""

View File

@ -45,8 +45,8 @@ msgstr ""
msgid "confirm new password"
msgstr ""
#: lib/memex_web/live/note_live/form_component.html.heex:23
#: lib/memex_web/live/note_live/form_component.html.heex:24
#: lib/memex_web/live/note_live/form_component.html.heex:25
#, elixir-autogen, elixir-format
msgid "content"
msgstr ""
@ -243,20 +243,20 @@ msgstr ""
msgid "report bugs or request features"
msgstr ""
#: lib/memex_web/live/context_live/form_component.html.heex:47
#: lib/memex_web/live/note_live/form_component.html.heex:47
#: lib/memex_web/live/pipeline_live/form_component.html.heex:47
#: lib/memex_web/live/step_live/form_component.html.heex:31
#: lib/memex_web/live/context_live/form_component.html.heex:48
#: lib/memex_web/live/note_live/form_component.html.heex:48
#: lib/memex_web/live/pipeline_live/form_component.html.heex:48
#: lib/memex_web/live/step_live/form_component.html.heex:32
#, elixir-autogen, elixir-format
msgid "saving..."
msgstr ""
#: lib/memex_web/live/context_live/form_component.html.heex:41
#: lib/memex_web/live/context_live/form_component.html.heex:42
#: lib/memex_web/live/note_live/form_component.html.heex:41
#: lib/memex_web/live/context_live/form_component.html.heex:43
#: lib/memex_web/live/note_live/form_component.html.heex:42
#: lib/memex_web/live/pipeline_live/form_component.html.heex:41
#: lib/memex_web/live/note_live/form_component.html.heex:43
#: lib/memex_web/live/pipeline_live/form_component.html.heex:42
#: lib/memex_web/live/pipeline_live/form_component.html.heex:43
#, elixir-autogen, elixir-format
msgid "select privacy"
msgstr ""
@ -272,12 +272,12 @@ msgstr ""
msgid "settings"
msgstr ""
#: lib/memex_web/live/context_live/form_component.html.heex:32
#: lib/memex_web/live/context_live/form_component.html.heex:33
#: lib/memex_web/live/note_live/form_component.html.heex:32
#: lib/memex_web/live/context_live/form_component.html.heex:34
#: lib/memex_web/live/note_live/form_component.html.heex:33
#: lib/memex_web/live/pipeline_live/form_component.html.heex:32
#: lib/memex_web/live/note_live/form_component.html.heex:34
#: lib/memex_web/live/pipeline_live/form_component.html.heex:33
#: lib/memex_web/live/pipeline_live/form_component.html.heex:34
#, elixir-autogen, elixir-format
msgid "tag1,tag2"
msgstr ""
@ -334,8 +334,8 @@ msgid "no contexts found"
msgstr ""
#: lib/memex_web/components/pipelines_table_component.ex:48
#: lib/memex_web/live/pipeline_live/form_component.html.heex:23
#: lib/memex_web/live/pipeline_live/form_component.html.heex:24
#: lib/memex_web/live/pipeline_live/form_component.html.heex:25
#, elixir-autogen, elixir-format
msgid "description"
msgstr ""
@ -387,12 +387,12 @@ msgstr ""
#: lib/memex_web/components/contexts_table_component.ex:47
#: lib/memex_web/components/notes_table_component.ex:47
#: lib/memex_web/components/pipelines_table_component.ex:47
#: lib/memex_web/live/context_live/form_component.html.heex:13
#: lib/memex_web/live/context_live/form_component.html.heex:14
#: lib/memex_web/live/note_live/form_component.html.heex:13
#: lib/memex_web/live/context_live/form_component.html.heex:15
#: lib/memex_web/live/note_live/form_component.html.heex:14
#: lib/memex_web/live/pipeline_live/form_component.html.heex:13
#: lib/memex_web/live/note_live/form_component.html.heex:15
#: lib/memex_web/live/pipeline_live/form_component.html.heex:14
#: lib/memex_web/live/pipeline_live/form_component.html.heex:15
#, elixir-autogen, elixir-format
msgid "slug"
msgstr ""
@ -409,8 +409,8 @@ msgstr ""
msgid "home"
msgstr ""
#: lib/memex_web/live/context_live/form_component.html.heex:23
#: lib/memex_web/live/context_live/form_component.html.heex:24
#: lib/memex_web/live/context_live/form_component.html.heex:25
#, elixir-autogen, elixir-format
msgid "use [[note-slug]] to link to a note"
msgstr ""
@ -471,14 +471,14 @@ msgstr ""
msgid "steps:"
msgstr ""
#: lib/memex_web/live/step_live/form_component.html.heex:13
#: lib/memex_web/live/step_live/form_component.html.heex:14
#: lib/memex_web/live/step_live/form_component.html.heex:15
#, elixir-autogen, elixir-format
msgid "title"
msgstr ""
#: lib/memex_web/live/step_live/form_component.html.heex:23
#: lib/memex_web/live/step_live/form_component.html.heex:24
#: lib/memex_web/live/step_live/form_component.html.heex:25
#, elixir-autogen, elixir-format
msgid "use [[context-slug]] to link to a context"
msgstr ""
@ -658,7 +658,7 @@ msgstr ""
msgid "keep me logged in for 60 days"
msgstr ""
#: lib/memex_web/live/invite_live/form_component.html.heex:21
#: lib/memex_web/live/invite_live/form_component.html.heex:22
#, elixir-autogen, elixir-format, fuzzy
msgid "name"
msgstr ""
@ -669,12 +669,12 @@ msgstr ""
msgid "password"
msgstr ""
#: lib/memex_web/live/invite_live/form_component.html.heex:31
#: lib/memex_web/live/invite_live/form_component.html.heex:32
#, elixir-autogen, elixir-format, fuzzy
msgid "uses left"
msgstr ""
#: lib/memex_web/live/invite_live/form_component.html.heex:43
#: lib/memex_web/live/invite_live/form_component.html.heex:44
#, elixir-autogen, elixir-format, fuzzy
msgid "leave \"uses left\" blank to make invite unlimited"
msgstr ""

View File

@ -137,7 +137,7 @@ msgstr ""
msgid "are you sure you want to delete %{email}? this action is permanent!"
msgstr ""
#: lib/memex_web/live/invite_live/form_component.html.heex:48
#: lib/memex_web/live/invite_live/form_component.html.heex:49
#, elixir-autogen, elixir-format, fuzzy
msgid "saving..."
msgstr ""

View File

@ -43,8 +43,8 @@ msgstr ""
msgid "confirm new password"
msgstr ""
#: lib/memex_web/live/note_live/form_component.html.heex:23
#: lib/memex_web/live/note_live/form_component.html.heex:24
#: lib/memex_web/live/note_live/form_component.html.heex:25
#, elixir-autogen, elixir-format
msgid "content"
msgstr ""
@ -241,20 +241,20 @@ msgstr ""
msgid "report bugs or request features"
msgstr ""
#: lib/memex_web/live/context_live/form_component.html.heex:47
#: lib/memex_web/live/note_live/form_component.html.heex:47
#: lib/memex_web/live/pipeline_live/form_component.html.heex:47
#: lib/memex_web/live/step_live/form_component.html.heex:31
#: lib/memex_web/live/context_live/form_component.html.heex:48
#: lib/memex_web/live/note_live/form_component.html.heex:48
#: lib/memex_web/live/pipeline_live/form_component.html.heex:48
#: lib/memex_web/live/step_live/form_component.html.heex:32
#, elixir-autogen, elixir-format
msgid "saving..."
msgstr ""
#: lib/memex_web/live/context_live/form_component.html.heex:41
#: lib/memex_web/live/context_live/form_component.html.heex:42
#: lib/memex_web/live/note_live/form_component.html.heex:41
#: lib/memex_web/live/context_live/form_component.html.heex:43
#: lib/memex_web/live/note_live/form_component.html.heex:42
#: lib/memex_web/live/pipeline_live/form_component.html.heex:41
#: lib/memex_web/live/note_live/form_component.html.heex:43
#: lib/memex_web/live/pipeline_live/form_component.html.heex:42
#: lib/memex_web/live/pipeline_live/form_component.html.heex:43
#, elixir-autogen, elixir-format
msgid "select privacy"
msgstr ""
@ -270,12 +270,12 @@ msgstr ""
msgid "settings"
msgstr ""
#: lib/memex_web/live/context_live/form_component.html.heex:32
#: lib/memex_web/live/context_live/form_component.html.heex:33
#: lib/memex_web/live/note_live/form_component.html.heex:32
#: lib/memex_web/live/context_live/form_component.html.heex:34
#: lib/memex_web/live/note_live/form_component.html.heex:33
#: lib/memex_web/live/pipeline_live/form_component.html.heex:32
#: lib/memex_web/live/note_live/form_component.html.heex:34
#: lib/memex_web/live/pipeline_live/form_component.html.heex:33
#: lib/memex_web/live/pipeline_live/form_component.html.heex:34
#, elixir-autogen, elixir-format
msgid "tag1,tag2"
msgstr ""
@ -332,8 +332,8 @@ msgid "no contexts found"
msgstr ""
#: lib/memex_web/components/pipelines_table_component.ex:48
#: lib/memex_web/live/pipeline_live/form_component.html.heex:23
#: lib/memex_web/live/pipeline_live/form_component.html.heex:24
#: lib/memex_web/live/pipeline_live/form_component.html.heex:25
#, elixir-autogen, elixir-format
msgid "description"
msgstr ""
@ -385,12 +385,12 @@ msgstr ""
#: lib/memex_web/components/contexts_table_component.ex:47
#: lib/memex_web/components/notes_table_component.ex:47
#: lib/memex_web/components/pipelines_table_component.ex:47
#: lib/memex_web/live/context_live/form_component.html.heex:13
#: lib/memex_web/live/context_live/form_component.html.heex:14
#: lib/memex_web/live/note_live/form_component.html.heex:13
#: lib/memex_web/live/context_live/form_component.html.heex:15
#: lib/memex_web/live/note_live/form_component.html.heex:14
#: lib/memex_web/live/pipeline_live/form_component.html.heex:13
#: lib/memex_web/live/note_live/form_component.html.heex:15
#: lib/memex_web/live/pipeline_live/form_component.html.heex:14
#: lib/memex_web/live/pipeline_live/form_component.html.heex:15
#, elixir-autogen, elixir-format
msgid "slug"
msgstr ""
@ -407,8 +407,8 @@ msgstr ""
msgid "home"
msgstr ""
#: lib/memex_web/live/context_live/form_component.html.heex:23
#: lib/memex_web/live/context_live/form_component.html.heex:24
#: lib/memex_web/live/context_live/form_component.html.heex:25
#, elixir-autogen, elixir-format
msgid "use [[note-slug]] to link to a note"
msgstr ""
@ -469,14 +469,14 @@ msgstr ""
msgid "steps:"
msgstr ""
#: lib/memex_web/live/step_live/form_component.html.heex:13
#: lib/memex_web/live/step_live/form_component.html.heex:14
#: lib/memex_web/live/step_live/form_component.html.heex:15
#, elixir-autogen, elixir-format
msgid "title"
msgstr ""
#: lib/memex_web/live/step_live/form_component.html.heex:23
#: lib/memex_web/live/step_live/form_component.html.heex:24
#: lib/memex_web/live/step_live/form_component.html.heex:25
#, elixir-autogen, elixir-format
msgid "use [[context-slug]] to link to a context"
msgstr ""
@ -656,7 +656,7 @@ msgstr ""
msgid "keep me logged in for 60 days"
msgstr ""
#: lib/memex_web/live/invite_live/form_component.html.heex:21
#: lib/memex_web/live/invite_live/form_component.html.heex:22
#, elixir-autogen, elixir-format
msgid "name"
msgstr ""
@ -667,12 +667,12 @@ msgstr ""
msgid "password"
msgstr ""
#: lib/memex_web/live/invite_live/form_component.html.heex:31
#: lib/memex_web/live/invite_live/form_component.html.heex:32
#, elixir-autogen, elixir-format
msgid "uses left"
msgstr ""
#: lib/memex_web/live/invite_live/form_component.html.heex:43
#: lib/memex_web/live/invite_live/form_component.html.heex:44
#, elixir-autogen, elixir-format
msgid "leave \"uses left\" blank to make invite unlimited"
msgstr ""

View File

@ -109,11 +109,11 @@ msgstr ""
msgid "register"
msgstr ""
#: lib/memex_web/live/context_live/form_component.html.heex:46
#: lib/memex_web/live/invite_live/form_component.html.heex:46
#: lib/memex_web/live/note_live/form_component.html.heex:46
#: lib/memex_web/live/pipeline_live/form_component.html.heex:46
#: lib/memex_web/live/step_live/form_component.html.heex:30
#: lib/memex_web/live/context_live/form_component.html.heex:47
#: lib/memex_web/live/invite_live/form_component.html.heex:47
#: lib/memex_web/live/note_live/form_component.html.heex:47
#: lib/memex_web/live/pipeline_live/form_component.html.heex:47
#: lib/memex_web/live/step_live/form_component.html.heex:31
#, elixir-autogen, elixir-format
msgid "save"
msgstr ""

View File

@ -44,8 +44,8 @@ msgstr ""
msgid "confirm new password"
msgstr ""
#: lib/memex_web/live/note_live/form_component.html.heex:23
#: lib/memex_web/live/note_live/form_component.html.heex:24
#: lib/memex_web/live/note_live/form_component.html.heex:25
#, elixir-autogen, elixir-format
msgid "content"
msgstr ""
@ -242,20 +242,20 @@ msgstr ""
msgid "report bugs or request features"
msgstr ""
#: lib/memex_web/live/context_live/form_component.html.heex:47
#: lib/memex_web/live/note_live/form_component.html.heex:47
#: lib/memex_web/live/pipeline_live/form_component.html.heex:47
#: lib/memex_web/live/step_live/form_component.html.heex:31
#: lib/memex_web/live/context_live/form_component.html.heex:48
#: lib/memex_web/live/note_live/form_component.html.heex:48
#: lib/memex_web/live/pipeline_live/form_component.html.heex:48
#: lib/memex_web/live/step_live/form_component.html.heex:32
#, elixir-autogen, elixir-format
msgid "saving..."
msgstr ""
#: lib/memex_web/live/context_live/form_component.html.heex:41
#: lib/memex_web/live/context_live/form_component.html.heex:42
#: lib/memex_web/live/note_live/form_component.html.heex:41
#: lib/memex_web/live/context_live/form_component.html.heex:43
#: lib/memex_web/live/note_live/form_component.html.heex:42
#: lib/memex_web/live/pipeline_live/form_component.html.heex:41
#: lib/memex_web/live/note_live/form_component.html.heex:43
#: lib/memex_web/live/pipeline_live/form_component.html.heex:42
#: lib/memex_web/live/pipeline_live/form_component.html.heex:43
#, elixir-autogen, elixir-format
msgid "select privacy"
msgstr ""
@ -271,12 +271,12 @@ msgstr ""
msgid "settings"
msgstr ""
#: lib/memex_web/live/context_live/form_component.html.heex:32
#: lib/memex_web/live/context_live/form_component.html.heex:33
#: lib/memex_web/live/note_live/form_component.html.heex:32
#: lib/memex_web/live/context_live/form_component.html.heex:34
#: lib/memex_web/live/note_live/form_component.html.heex:33
#: lib/memex_web/live/pipeline_live/form_component.html.heex:32
#: lib/memex_web/live/note_live/form_component.html.heex:34
#: lib/memex_web/live/pipeline_live/form_component.html.heex:33
#: lib/memex_web/live/pipeline_live/form_component.html.heex:34
#, elixir-autogen, elixir-format
msgid "tag1,tag2"
msgstr ""
@ -333,8 +333,8 @@ msgid "no contexts found"
msgstr ""
#: lib/memex_web/components/pipelines_table_component.ex:48
#: lib/memex_web/live/pipeline_live/form_component.html.heex:23
#: lib/memex_web/live/pipeline_live/form_component.html.heex:24
#: lib/memex_web/live/pipeline_live/form_component.html.heex:25
#, elixir-autogen, elixir-format
msgid "description"
msgstr ""
@ -386,12 +386,12 @@ msgstr ""
#: lib/memex_web/components/contexts_table_component.ex:47
#: lib/memex_web/components/notes_table_component.ex:47
#: lib/memex_web/components/pipelines_table_component.ex:47
#: lib/memex_web/live/context_live/form_component.html.heex:13
#: lib/memex_web/live/context_live/form_component.html.heex:14
#: lib/memex_web/live/note_live/form_component.html.heex:13
#: lib/memex_web/live/context_live/form_component.html.heex:15
#: lib/memex_web/live/note_live/form_component.html.heex:14
#: lib/memex_web/live/pipeline_live/form_component.html.heex:13
#: lib/memex_web/live/note_live/form_component.html.heex:15
#: lib/memex_web/live/pipeline_live/form_component.html.heex:14
#: lib/memex_web/live/pipeline_live/form_component.html.heex:15
#, elixir-autogen, elixir-format
msgid "slug"
msgstr ""
@ -408,8 +408,8 @@ msgstr ""
msgid "home"
msgstr ""
#: lib/memex_web/live/context_live/form_component.html.heex:23
#: lib/memex_web/live/context_live/form_component.html.heex:24
#: lib/memex_web/live/context_live/form_component.html.heex:25
#, elixir-autogen, elixir-format
msgid "use [[note-slug]] to link to a note"
msgstr ""
@ -470,14 +470,14 @@ msgstr ""
msgid "steps:"
msgstr ""
#: lib/memex_web/live/step_live/form_component.html.heex:13
#: lib/memex_web/live/step_live/form_component.html.heex:14
#: lib/memex_web/live/step_live/form_component.html.heex:15
#, elixir-autogen, elixir-format
msgid "title"
msgstr ""
#: lib/memex_web/live/step_live/form_component.html.heex:23
#: lib/memex_web/live/step_live/form_component.html.heex:24
#: lib/memex_web/live/step_live/form_component.html.heex:25
#, elixir-autogen, elixir-format
msgid "use [[context-slug]] to link to a context"
msgstr ""
@ -657,7 +657,7 @@ msgstr ""
msgid "keep me logged in for 60 days"
msgstr ""
#: lib/memex_web/live/invite_live/form_component.html.heex:21
#: lib/memex_web/live/invite_live/form_component.html.heex:22
#, elixir-autogen, elixir-format
msgid "name"
msgstr ""
@ -668,12 +668,12 @@ msgstr ""
msgid "password"
msgstr ""
#: lib/memex_web/live/invite_live/form_component.html.heex:31
#: lib/memex_web/live/invite_live/form_component.html.heex:32
#, elixir-autogen, elixir-format
msgid "uses left"
msgstr ""
#: lib/memex_web/live/invite_live/form_component.html.heex:43
#: lib/memex_web/live/invite_live/form_component.html.heex:44
#, elixir-autogen, elixir-format, fuzzy
msgid "leave \"uses left\" blank to make invite unlimited"
msgstr ""

View File

@ -138,7 +138,7 @@ msgstr ""
msgid "are you sure you want to delete %{email}? this action is permanent!"
msgstr ""
#: lib/memex_web/live/invite_live/form_component.html.heex:48
#: lib/memex_web/live/invite_live/form_component.html.heex:49
#, elixir-autogen, elixir-format, fuzzy
msgid "saving..."
msgstr ""

View File

@ -137,7 +137,7 @@ msgstr ""
msgid "are you sure you want to delete %{email}? this action is permanent!"
msgstr ""
#: lib/memex_web/live/invite_live/form_component.html.heex:48
#: lib/memex_web/live/invite_live/form_component.html.heex:49
#, elixir-autogen, elixir-format
msgid "saving..."
msgstr ""