5 Commits

  1. 17
      CHANGELOG.md
  2. 12
      assets/js/editor.js
  3. 104
      assets/package-lock.json
  4. 6
      lib/mirage_web/live/note_live/form_component.html.leex
  5. 2
      mix.exs

17
CHANGELOG.md

@ -5,6 +5,23 @@ See [Conventional Commits](Https://conventionalcommits.org) for commit guideline
<!-- changelog -->
## [v0.68.2](https://git.inhji.de/inhji/mirage/compare/v0.68.1...v0.68.2) (2021-03-11)
### Chores:
* update npm deps
### Bug Fixes:
* properly ignore live view updates from affecting the editor elements
* prevent instanciating editor twice
* properly declare content var lol
## [v0.68.1](https://git.inhji.de/inhji/mirage/compare/v0.68.0...v0.68.1) (2021-03-11)

12
assets/js/editor.js

@ -7,15 +7,21 @@ import {markdown} from "@codemirror/lang-markdown"
import {oneDark} from "@codemirror/theme-one-dark"
const contentElement = "input.editor-content"
const editorElement = "div.cm-wrap"
let view
export default function initEditor(element) {
content = findContentElement()
const content = findContentElement()
if (content === null) {
throw Error(`Content Element not found. Looking for ${contentElement}.`)
}
// Prevent instancing the editor twice on regular GET requests
if (findInstanciatedEditor()) {
return
}
attachFormHandler()
const parent = document.querySelector(element)
@ -47,6 +53,10 @@ function findContentElement() {
}
}
function findInstanciatedEditor() {
return !!document.querySelector(editorElement)
}
function attachFormHandler() {
const el = document.querySelector(contentElement)
const formEl = el.form

104
assets/package-lock.json

@ -1257,9 +1257,9 @@
}
},
"node_modules/@codemirror/autocomplete": {
"version": "0.18.0",
"resolved": "https://registry.npmjs.org/@codemirror/autocomplete/-/autocomplete-0.18.0.tgz",
"integrity": "sha512-8MzkXNh/Sj2pcCPYWe+1vjQ51rmmGI+Nx95TJ4xJoH9uEMqnFSrOuxr0x52eLUwYIOihXt9OV6vjERr+p2IZzg==",
"version": "0.18.1",
"resolved": "https://registry.npmjs.org/@codemirror/autocomplete/-/autocomplete-0.18.1.tgz",
"integrity": "sha512-6Em//s+xt+lkFE3mAsSSIHtukITQNkdCSPg8IDop5kYLPkrhi7IX5NnYqQoPi06sWdUySyF9+h1+zpZQW3BG6Q==",
"dependencies": {
"@codemirror/language": "^0.18.0",
"@codemirror/state": "^0.18.0",
@ -1501,9 +1501,9 @@
}
},
"node_modules/@codemirror/state": {
"version": "0.18.0",
"resolved": "https://registry.npmjs.org/@codemirror/state/-/state-0.18.0.tgz",
"integrity": "sha512-E5Tgx/CVmQQdiIOoJ4xX4hy2RGqTjxbpzDifGn8wUu3Driq/uZ+ncr7M4ojWs1T83yYFevNBmPtT5vprD25vYA==",
"version": "0.18.1",
"resolved": "https://registry.npmjs.org/@codemirror/state/-/state-0.18.1.tgz",
"integrity": "sha512-rVSY4Yi9FNRnaYbQ6deuj6yQ8RYQrKD6HsJi7KYUrWhHZF2MnPD3K2hdj177DgcZKy40U8kVz33X3irWU0dD5w==",
"dependencies": {
"@codemirror/text": "^0.18.0"
}
@ -2234,9 +2234,9 @@
}
},
"node_modules/caniuse-lite": {
"version": "1.0.30001197",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001197.tgz",
"integrity": "sha512-8aE+sqBqtXz4G8g35Eg/XEaFr2N7rd/VQ6eABGBmNtcB8cN6qNJhMi6oSFy4UWWZgqgL3filHT8Nha4meu3tsw==",
"version": "1.0.30001198",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001198.tgz",
"integrity": "sha512-r5GGgESqOPZzwvdLVER374FpQu2WluCF1Z2DSiFJ89KSmGjT0LVKjgv4NcAqHmGWF9ihNpqRI9KXO9Ex4sKsgA==",
"dev": true
},
"node_modules/chalk": {
@ -2305,9 +2305,9 @@
}
},
"node_modules/clipboard": {
"version": "2.0.7",
"resolved": "https://registry.npmjs.org/clipboard/-/clipboard-2.0.7.tgz",
"integrity": "sha512-8M8WEZcIvs0hgOma+wAPkrUxpv0PMY1L6VsAJh/2DOKARIMpyWe6ZLcEoe1qktl6/ced5ceYHs+oGedSbgZ3sg==",
"version": "2.0.8",
"resolved": "https://registry.npmjs.org/clipboard/-/clipboard-2.0.8.tgz",
"integrity": "sha512-Y6WO0unAIQp5bLmk1zdThRhgJt/x3ks6f30s3oE3H1mgIEU33XyQjEf8gsf6DxC7NPX8Y1SsNWjUjL/ywLnnbQ==",
"optional": true,
"dependencies": {
"good-listener": "^1.2.2",
@ -2588,16 +2588,16 @@
}
},
"node_modules/css-loader": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/css-loader/-/css-loader-5.1.1.tgz",
"integrity": "sha512-5FfhpjwtuRgxqmusDidowqmLlcb+1HgnEDMsi2JhiUrZUcoc+cqw+mUtMIF/+OfeMYaaFCLYp1TaIt9H6I/fKA==",
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/css-loader/-/css-loader-5.1.2.tgz",
"integrity": "sha512-T7vTXHSx0KrVEg/xjcl7G01RcVXpcw4OELwDPvkr7izQNny85A84dK3dqrczuEfBcu7Yg7mdTjJLSTibRUoRZg==",
"dev": true,
"dependencies": {
"camelcase": "^6.2.0",
"cssesc": "^3.0.0",
"icss-utils": "^5.1.0",
"loader-utils": "^2.0.0",
"postcss": "^8.2.6",
"postcss": "^8.2.8",
"postcss-modules-extract-imports": "^3.0.0",
"postcss-modules-local-by-default": "^4.0.0",
"postcss-modules-scope": "^3.0.0",
@ -3138,9 +3138,9 @@
"dev": true
},
"node_modules/electron-to-chromium": {
"version": "1.3.683",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.683.tgz",
"integrity": "sha512-8mFfiAesXdEdE0DhkMKO7W9U6VU/9T3VTWwZ+4g84/YMP4kgwgFtQgUxuu7FUMcvSeKSNhFQNU+WZ68BQTLT5A==",
"version": "1.3.686",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.686.tgz",
"integrity": "sha512-SOJT3m00NX/gT3sD6E3PcZX6u3+zUmQq4+yp8QCKLOwf2ECnmh9eAY+eonhC/AAu5Gg2WrtUU2m7/+e85O0l6A==",
"dev": true
},
"node_modules/emojis-list": {
@ -4260,11 +4260,11 @@
}
},
"node_modules/lezer-html": {
"version": "0.13.3",
"resolved": "https://registry.npmjs.org/lezer-html/-/lezer-html-0.13.3.tgz",
"integrity": "sha512-3uluh9NDSXBNLUGbnZhjyWwcVK0cdcCRraKOzjcdPTpf1gPlY6fAr1eN9cdDoq6WI3bDLP/PwYnpXPOT9CHJDw==",
"version": "0.13.4",
"resolved": "https://registry.npmjs.org/lezer-html/-/lezer-html-0.13.4.tgz",
"integrity": "sha512-qBBEJO+pQ8jVFin/1C7lj7QFrr+pTzRmJDgKxaZqIHr7IKzq2jN+NXQVprru4g6l+2b0h4350wKeVGP9kLkq0A==",
"dependencies": {
"lezer": "^0.13.2"
"lezer": "^0.13.3"
}
},
"node_modules/lezer-javascript": {
@ -4969,9 +4969,9 @@
}
},
"node_modules/postcss": {
"version": "8.2.7",
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.2.7.tgz",
"integrity": "sha512-DsVLH3xJzut+VT+rYr0mtvOtpTjSyqDwPf5EZWXcb0uAKfitGpTY9Ec+afi2+TgdN8rWS9Cs88UDYehKo/RvOw==",
"version": "8.2.8",
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.2.8.tgz",
"integrity": "sha512-1F0Xb2T21xET7oQV9eKuctbM9S7BC0fetoHCc4H13z0PT6haiRLP4T0ZY4XWh7iLP0usgqykT6p9B2RtOf4FPw==",
"dev": true,
"dependencies": {
"colorette": "^1.2.2",
@ -8995,9 +8995,9 @@
}
},
"@codemirror/autocomplete": {
"version": "0.18.0",
"resolved": "https://registry.npmjs.org/@codemirror/autocomplete/-/autocomplete-0.18.0.tgz",
"integrity": "sha512-8MzkXNh/Sj2pcCPYWe+1vjQ51rmmGI+Nx95TJ4xJoH9uEMqnFSrOuxr0x52eLUwYIOihXt9OV6vjERr+p2IZzg==",
"version": "0.18.1",
"resolved": "https://registry.npmjs.org/@codemirror/autocomplete/-/autocomplete-0.18.1.tgz",
"integrity": "sha512-6Em//s+xt+lkFE3mAsSSIHtukITQNkdCSPg8IDop5kYLPkrhi7IX5NnYqQoPi06sWdUySyF9+h1+zpZQW3BG6Q==",
"requires": {
"@codemirror/language": "^0.18.0",
"@codemirror/state": "^0.18.0",
@ -9239,9 +9239,9 @@
}
},
"@codemirror/state": {
"version": "0.18.0",
"resolved": "https://registry.npmjs.org/@codemirror/state/-/state-0.18.0.tgz",
"integrity": "sha512-E5Tgx/CVmQQdiIOoJ4xX4hy2RGqTjxbpzDifGn8wUu3Driq/uZ+ncr7M4ojWs1T83yYFevNBmPtT5vprD25vYA==",
"version": "0.18.1",
"resolved": "https://registry.npmjs.org/@codemirror/state/-/state-0.18.1.tgz",
"integrity": "sha512-rVSY4Yi9FNRnaYbQ6deuj6yQ8RYQrKD6HsJi7KYUrWhHZF2MnPD3K2hdj177DgcZKy40U8kVz33X3irWU0dD5w==",
"requires": {
"@codemirror/text": "^0.18.0"
}
@ -9851,9 +9851,9 @@
}
},
"caniuse-lite": {
"version": "1.0.30001197",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001197.tgz",
"integrity": "sha512-8aE+sqBqtXz4G8g35Eg/XEaFr2N7rd/VQ6eABGBmNtcB8cN6qNJhMi6oSFy4UWWZgqgL3filHT8Nha4meu3tsw==",
"version": "1.0.30001198",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001198.tgz",
"integrity": "sha512-r5GGgESqOPZzwvdLVER374FpQu2WluCF1Z2DSiFJ89KSmGjT0LVKjgv4NcAqHmGWF9ihNpqRI9KXO9Ex4sKsgA==",
"dev": true
},
"chalk": {
@ -9905,9 +9905,9 @@
"dev": true
},
"clipboard": {
"version": "2.0.7",
"resolved": "https://registry.npmjs.org/clipboard/-/clipboard-2.0.7.tgz",
"integrity": "sha512-8M8WEZcIvs0hgOma+wAPkrUxpv0PMY1L6VsAJh/2DOKARIMpyWe6ZLcEoe1qktl6/ced5ceYHs+oGedSbgZ3sg==",
"version": "2.0.8",
"resolved": "https://registry.npmjs.org/clipboard/-/clipboard-2.0.8.tgz",
"integrity": "sha512-Y6WO0unAIQp5bLmk1zdThRhgJt/x3ks6f30s3oE3H1mgIEU33XyQjEf8gsf6DxC7NPX8Y1SsNWjUjL/ywLnnbQ==",
"optional": true,
"requires": {
"good-listener": "^1.2.2",
@ -10136,16 +10136,16 @@
}
},
"css-loader": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/css-loader/-/css-loader-5.1.1.tgz",
"integrity": "sha512-5FfhpjwtuRgxqmusDidowqmLlcb+1HgnEDMsi2JhiUrZUcoc+cqw+mUtMIF/+OfeMYaaFCLYp1TaIt9H6I/fKA==",
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/css-loader/-/css-loader-5.1.2.tgz",
"integrity": "sha512-T7vTXHSx0KrVEg/xjcl7G01RcVXpcw4OELwDPvkr7izQNny85A84dK3dqrczuEfBcu7Yg7mdTjJLSTibRUoRZg==",
"dev": true,
"requires": {
"camelcase": "^6.2.0",
"cssesc": "^3.0.0",
"icss-utils": "^5.1.0",
"loader-utils": "^2.0.0",
"postcss": "^8.2.6",
"postcss": "^8.2.8",
"postcss-modules-extract-imports": "^3.0.0",
"postcss-modules-local-by-default": "^4.0.0",
"postcss-modules-scope": "^3.0.0",
@ -10549,9 +10549,9 @@
"dev": true
},
"electron-to-chromium": {
"version": "1.3.683",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.683.tgz",
"integrity": "sha512-8mFfiAesXdEdE0DhkMKO7W9U6VU/9T3VTWwZ+4g84/YMP4kgwgFtQgUxuu7FUMcvSeKSNhFQNU+WZ68BQTLT5A==",
"version": "1.3.686",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.686.tgz",
"integrity": "sha512-SOJT3m00NX/gT3sD6E3PcZX6u3+zUmQq4+yp8QCKLOwf2ECnmh9eAY+eonhC/AAu5Gg2WrtUU2m7/+e85O0l6A==",
"dev": true
},
"emojis-list": {
@ -11368,11 +11368,11 @@
}
},
"lezer-html": {
"version": "0.13.3",
"resolved": "https://registry.npmjs.org/lezer-html/-/lezer-html-0.13.3.tgz",
"integrity": "sha512-3uluh9NDSXBNLUGbnZhjyWwcVK0cdcCRraKOzjcdPTpf1gPlY6fAr1eN9cdDoq6WI3bDLP/PwYnpXPOT9CHJDw==",
"version": "0.13.4",
"resolved": "https://registry.npmjs.org/lezer-html/-/lezer-html-0.13.4.tgz",
"integrity": "sha512-qBBEJO+pQ8jVFin/1C7lj7QFrr+pTzRmJDgKxaZqIHr7IKzq2jN+NXQVprru4g6l+2b0h4350wKeVGP9kLkq0A==",
"requires": {
"lezer": "^0.13.2"
"lezer": "^0.13.3"
}
},
"lezer-javascript": {
@ -11892,9 +11892,9 @@
}
},
"postcss": {
"version": "8.2.7",
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.2.7.tgz",
"integrity": "sha512-DsVLH3xJzut+VT+rYr0mtvOtpTjSyqDwPf5EZWXcb0uAKfitGpTY9Ec+afi2+TgdN8rWS9Cs88UDYehKo/RvOw==",
"version": "8.2.8",
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.2.8.tgz",
"integrity": "sha512-1F0Xb2T21xET7oQV9eKuctbM9S7BC0fetoHCc4H13z0PT6haiRLP4T0ZY4XWh7iLP0usgqykT6p9B2RtOf4FPw==",
"dev": true,
"requires": {
"colorette": "^1.2.2",

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

@ -11,8 +11,10 @@
<%= text_input f, :title, placeholder: "What is this note about?", class: "title" %>
</fieldset>
<%= hidden_input f, :content, class: "editor-content" %>
<div id="editor" phx-update="ignore"></div>
<fieldset phx-update="ignore">
<%= hidden_input f, :content, class: "editor-content" %>
<div id="editor"></div>
</fieldset>
<fieldset phx-update="ignore">
<%= text_input f, :topic_string, id: "tags", placeholder: "Tags, comma-separated" %>

2
mix.exs

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

Loading…
Cancel
Save