4 Commits

  1. 13
      CHANGELOG.md
  2. 1
      assets/css/app.scss
  3. 2
      assets/js/editor.js
  4. 8
      assets/js/hooks.js
  5. 91
      assets/package-lock.json
  6. 1
      assets/package.json
  7. 5
      lib/mirage/notes/tags.ex
  8. 1
      lib/mirage_web/live/goto_anything_live.ex
  9. 33
      lib/mirage_web/live/note_live/form_component.ex
  10. 5
      lib/mirage_web/live/note_live/form_component.html.leex
  11. 4
      lib/mirage_web/templates/user/index.html.eex
  12. 2
      mix.exs

13
CHANGELOG.md

@ -5,6 +5,19 @@ See [Conventional Commits](Https://conventionalcommits.org) for commit guideline
<!-- changelog -->
## [v0.55.0](https://git.inhji.de/inhji/mirage/compare/v0.54.2...v0.55.0) (2021-02-22)
### Features:
* niceeeee tag picker
### Bug Fixes:
* hide empty note categories on user index
## [v0.54.2](https://git.inhji.de/inhji/mirage/compare/v0.54.1...v0.54.2) (2021-02-22)

1
assets/css/app.scss

@ -2,6 +2,7 @@
@import "~minireset.css/minireset.css";
@import "~sass-material-colors/sass/sass-material-colors";
@import "~@yaireo/tagify/src/tagify";
/* === Color Definitions === */

2
assets/js/editor.js

@ -34,8 +34,6 @@ export default function initEditor(element) {
]
})
console.log(state.doc)
view = new EditorView({ state, parent })
}

8
assets/js/hooks.js

@ -15,6 +15,14 @@ export const NoteForm = {
initEditor("#editor")
})
}
if (document.querySelector("#tags")) {
import(/* webpackChunkName: "editor" */ "@yaireo/tagify").then(module => {
const allTags = document.querySelector("#all_tags").value
const tagsEl = document.querySelector("#tags")
var tagify = new module.default(tagsEl, {whitelist: allTags.split(",")})
})
}
window.scrollTo({top: 0, left: 0, behavior: 'smooth'})
}

91
assets/package-lock.json

@ -8,6 +8,7 @@
"@codemirror/basic-setup": "^0.17.1",
"@codemirror/lang-markdown": "^0.17.2",
"@codemirror/theme-one-dark": "^0.17.5",
"@yaireo/tagify": "^3.22.3",
"minireset.css": "^0.0.7",
"nprogress": "^0.2.0",
"phoenix": "file:../deps/phoenix",
@ -1818,6 +1819,14 @@
"integrity": "sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ==",
"dev": true
},
"node_modules/@yaireo/tagify": {
"version": "3.22.3",
"resolved": "https://registry.npmjs.org/@yaireo/tagify/-/tagify-3.22.3.tgz",
"integrity": "sha512-jPDuX6gH0ryd0tDtNnUXQxw3hyKjQXwUfolDSLvVgj5VxDBpRXPkBT71cm6m+znFs1Ko3yhLIauxICzXUxn4tA==",
"peerDependencies": {
"prop-types": "^15.7.2"
}
},
"node_modules/acorn": {
"version": "8.0.5",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.0.5.tgz",
@ -4030,8 +4039,7 @@
"node_modules/js-tokens": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
"integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==",
"dev": true
"integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ=="
},
"node_modules/js-yaml": {
"version": "3.14.1",
@ -4214,6 +4222,18 @@
"integrity": "sha1-0CJTc662Uq3BvILklFM5qEJ1R3M=",
"dev": true
},
"node_modules/loose-envify": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz",
"integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==",
"peer": true,
"dependencies": {
"js-tokens": "^3.0.0 || ^4.0.0"
},
"bin": {
"loose-envify": "cli.js"
}
},
"node_modules/lru-cache": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz",
@ -4549,6 +4569,15 @@
"boolbase": "~1.0.0"
}
},
"node_modules/object-assign": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
"integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=",
"peer": true,
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/object-inspect": {
"version": "1.9.0",
"resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.9.0.tgz",
@ -6493,6 +6522,17 @@
"integrity": "sha1-mEcocL8igTL8vdhoEputEsPAKeM=",
"dev": true
},
"node_modules/prop-types": {
"version": "15.7.2",
"resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.7.2.tgz",
"integrity": "sha512-8QQikdH7//R2vurIJSutZ1smHYTcLpRWEOlHnzcWHmBYrOGUysKwSsrC89BCiFj3CbrfJ/nXFdJepOVrY1GCHQ==",
"peer": true,
"dependencies": {
"loose-envify": "^1.4.0",
"object-assign": "^4.1.1",
"react-is": "^16.8.1"
}
},
"node_modules/punycode": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz",
@ -6541,6 +6581,12 @@
"safe-buffer": "^5.1.0"
}
},
"node_modules/react-is": {
"version": "16.13.1",
"resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz",
"integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==",
"peer": true
},
"node_modules/readdirp": {
"version": "3.5.0",
"resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.5.0.tgz",
@ -9356,6 +9402,12 @@
"integrity": "sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ==",
"dev": true
},
"@yaireo/tagify": {
"version": "3.22.3",
"resolved": "https://registry.npmjs.org/@yaireo/tagify/-/tagify-3.22.3.tgz",
"integrity": "sha512-jPDuX6gH0ryd0tDtNnUXQxw3hyKjQXwUfolDSLvVgj5VxDBpRXPkBT71cm6m+znFs1Ko3yhLIauxICzXUxn4tA==",
"requires": {}
},
"acorn": {
"version": "8.0.5",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.0.5.tgz",
@ -11025,8 +11077,7 @@
"js-tokens": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
"integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==",
"dev": true
"integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ=="
},
"js-yaml": {
"version": "3.14.1",
@ -11178,6 +11229,15 @@
"integrity": "sha1-0CJTc662Uq3BvILklFM5qEJ1R3M=",
"dev": true
},
"loose-envify": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz",
"integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==",
"peer": true,
"requires": {
"js-tokens": "^3.0.0 || ^4.0.0"
}
},
"lru-cache": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz",
@ -11425,6 +11485,12 @@
"boolbase": "~1.0.0"
}
},
"object-assign": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
"integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=",
"peer": true
},
"object-inspect": {
"version": "1.9.0",
"resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.9.0.tgz",
@ -12872,6 +12938,17 @@
"integrity": "sha1-mEcocL8igTL8vdhoEputEsPAKeM=",
"dev": true
},
"prop-types": {
"version": "15.7.2",
"resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.7.2.tgz",
"integrity": "sha512-8QQikdH7//R2vurIJSutZ1smHYTcLpRWEOlHnzcWHmBYrOGUysKwSsrC89BCiFj3CbrfJ/nXFdJepOVrY1GCHQ==",
"peer": true,
"requires": {
"loose-envify": "^1.4.0",
"object-assign": "^4.1.1",
"react-is": "^16.8.1"
}
},
"punycode": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz",
@ -12899,6 +12976,12 @@
"safe-buffer": "^5.1.0"
}
},
"react-is": {
"version": "16.13.1",
"resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz",
"integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==",
"peer": true
},
"readdirp": {
"version": "3.5.0",
"resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.5.0.tgz",

1
assets/package.json

@ -8,6 +8,7 @@
"@codemirror/basic-setup": "^0.17.1",
"@codemirror/lang-markdown": "^0.17.2",
"@codemirror/theme-one-dark": "^0.17.5",
"@yaireo/tagify": "^3.22.3",
"minireset.css": "^0.0.7",
"nprogress": "^0.2.0",
"phoenix": "file:../deps/phoenix",

5
lib/mirage/notes/tags.ex

@ -4,6 +4,11 @@ defmodule Mirage.Notes.Tags do
alias Mirage.Notes.{Note, Topic, NoteTopic}
def list_tags() do
Topic
|> Repo.all()
end
@doc utils: :tag
@doc """
Updates tags of a given note.

1
lib/mirage_web/live/goto_anything_live.ex

@ -18,7 +18,6 @@ defmodule MirageWeb.GotoAnythingLive do
@impl true
def handle_event("hotkey", params, socket) do
IO.inspect(params)
{:noreply, socket}
end

33
lib/mirage_web/live/note_live/form_component.ex

@ -7,10 +7,16 @@ defmodule MirageWeb.NoteLive.FormComponent do
def update(%{note: note} = assigns, socket) do
changeset = Notes.change_note(note)
tags =
Mirage.Notes.Tags.list_tags()
|> Enum.map(fn tag -> tag.text end)
|> Enum.join(",")
{:ok,
socket
|> assign(assigns)
|> assign(:changeset, changeset)}
|> assign(:changeset, changeset)
|> assign(:tags, tags)}
end
@impl true
@ -28,10 +34,14 @@ defmodule MirageWeb.NoteLive.FormComponent do
end
defp save_note(socket, :edit, note_params) do
tag_string =
note_params["topic_string"]
|> tag_json_to_list()
case Notes.update_note(socket.assigns.note, note_params) do
{:ok, note} ->
note
|> Notes.Tags.update_tags(note_params["topic_string"])
|> Notes.Tags.update_tags(tag_string)
|> Notes.link_note()
{:noreply,
@ -45,11 +55,15 @@ defmodule MirageWeb.NoteLive.FormComponent do
end
defp save_note(socket, :new, note_params) do
tag_string =
note_params["topic_string"]
|> tag_json_to_list()
case Notes.create_note(note_params) do
{:ok, note} ->
note
|> Notes.preload_note()
|> Notes.Tags.update_tags(note_params["topic_string"])
|> Notes.Tags.update_tags(tag_string)
|> Notes.link_note()
{:noreply,
@ -61,4 +75,17 @@ defmodule MirageWeb.NoteLive.FormComponent do
{:noreply, assign(socket, changeset: changeset)}
end
end
def tag_json_to_list(json_string) do
case json_string do
"" ->
json_string
json ->
json
|> Jason.decode!()
|> Enum.map(&Map.get(&1, "value"))
|> Enum.join(",")
end
end
end

5
lib/mirage_web/live/note_live/form_component.html.leex

@ -14,8 +14,9 @@
<%= hidden_input f, :content, class: "editor-content" %>
<div id="editor" phx-update="ignore"></div>
<fieldset>
<%= text_input f, :topic_string, placeholder: "Tags, comma-separated" %>
<fieldset phx-update="ignore">
<%= text_input f, :topic_string, id: "tags", placeholder: "Tags, comma-separated" %>
<%= hidden_input f, :all_tags, value: @tags, id: "all_tags" %>
<%= error_tag f, :topic_string %>
</fieldset>

4
lib/mirage_web/templates/user/index.html.eex

@ -30,6 +30,7 @@
</div>
</section>
<%= if not Enum.empty?(@notes.unlinked) do %>
<section class="bg-content width-full">
<h3>🔗 Unlinked</h3>
@ -42,7 +43,9 @@
<% end %>
</div>
</section>
<% end %>
<%= if not Enum.empty?(@notes.untagged) do %>
<section class="bg-content width-full">
<h3>🔖 Untagged</h3>
@ -55,6 +58,7 @@
<% end %>
</div>
</section>
<% end %>
<section class="bg-content width-full">
<h3>🃏 At-Notes</h3>

2
mix.exs

@ -1,7 +1,7 @@
defmodule Mirage.MixProject do
use Mix.Project
@version "0.54.2"
@version "0.55.0"
def project do
[

Loading…
Cancel
Save