fix: lints

This commit is contained in:
Gabriel Horner
2024-06-03 14:13:55 -04:00
parent df10beb325
commit 5ecb3fe3d4
16 changed files with 36 additions and 90 deletions

View File

@@ -361,6 +361,36 @@
{:init-tx init-tx
:block-props-tx block-props-tx}))
(defn- build-blocks-tx*
[{:keys [pages-and-blocks properties classes graph-namespace]
:as options}]
(let [;; add uuids before tx for refs in :properties
pages-and-blocks' (mapv (fn [{:keys [page blocks]}]
(cond-> {:page (merge {:block/uuid (random-uuid)} page)}
(seq blocks)
(assoc :blocks (mapv #(merge {:block/uuid (random-uuid)} %) blocks))))
pages-and-blocks)
page-uuids (create-page-uuids pages-and-blocks')
all-idents (create-all-idents properties classes graph-namespace)
properties-tx (build-properties-tx properties page-uuids all-idents)
classes-tx (build-classes-tx classes properties page-uuids all-idents)
class-ident->id (->> classes-tx (map (juxt :db/ident :db/id)) (into {}))
;; Replace idents with db-ids to avoid any upsert issues
properties-tx' (mapv (fn [m]
(if (:property/schema.classes m)
(update m :property/schema.classes
(fn [cs]
(mapv #(or (some->> (:db/ident %) class-ident->id (hash-map :db/id))
(throw (ex-info (str "No :db/id found for :db/ident " (pr-str (:db/ident %))) {})))
cs)))
m))
properties-tx)
pages-and-blocks-tx (build-pages-and-blocks-tx pages-and-blocks' all-idents page-uuids options)]
;; Properties first b/c they have schema and are referenced by all. Then classes b/c they can be referenced by pages. Then pages
(split-blocks-tx (concat properties-tx'
classes-tx
pages-and-blocks-tx))))
(defn build-blocks-tx
"Given an EDN map for defining pages, blocks and properties, this creates a map
with two keys of transactable data for use with d/transact!. The :init-tx key
@@ -368,8 +398,7 @@
The blocks that can be created have the following limitations:
* Only top level blocks can be easily defined. Other level blocks can be
defined but they require explicit setting of attributes like :block/order and :block/parent
* Block content containing page refs or tags is not supported yet
defined but they require explicit setting of :block/parent
The EDN map has the following keys:
@@ -401,35 +430,9 @@
supported: :default, :url, :checkbox, :number, :page and :date. :checkbox and
:number values are written as booleans and integers/floats. :page references
are written as vectors e.g. `[:page \"PAGE NAME\"]`"
[{:keys [pages-and-blocks properties classes graph-namespace]
:as options}]
(let [_ (validate-options options)
;; add uuids before tx for refs in :properties
pages-and-blocks' (mapv (fn [{:keys [page blocks]}]
(cond-> {:page (merge {:block/uuid (random-uuid)} page)}
(seq blocks)
(assoc :blocks (mapv #(merge {:block/uuid (random-uuid)} %) blocks))))
pages-and-blocks)
page-uuids (create-page-uuids pages-and-blocks')
all-idents (create-all-idents properties classes graph-namespace)
properties-tx (build-properties-tx properties page-uuids all-idents)
classes-tx (build-classes-tx classes properties page-uuids all-idents)
class-ident->id (->> classes-tx (map (juxt :db/ident :db/id)) (into {}))
;; Replace idents with db-ids to avoid any upsert issues
properties-tx' (mapv (fn [m]
(if (:property/schema.classes m)
(update m :property/schema.classes
(fn [cs]
(mapv #(or (some->> (:db/ident %) class-ident->id (hash-map :db/id))
(throw (ex-info (str "No :db/id found for :db/ident " (pr-str (:db/ident %))) {})))
cs)))
m))
properties-tx)
pages-and-blocks-tx (build-pages-and-blocks-tx pages-and-blocks' all-idents page-uuids options)]
;; Properties first b/c they have schema and are referenced by all. Then classes b/c they can be referenced by pages. Then pages
(split-blocks-tx (concat properties-tx'
classes-tx
pages-and-blocks-tx))))
[options]
(validate-options options)
(build-blocks-tx* options))
(defn create-blocks
"Builds txs with build-blocks-tx and transacts them. Usually used for testing"

View File

@@ -143,24 +143,6 @@
bp (->breakpoint (when (some? rect) (.-width rect)))]
[ref bp])))
(defn use-click-outside
"Returns a function that can be used to register a callback
that will be called when the user clicks outside the given dom node"
[handler & {:keys [capture? event]
:or {capture? false
event "click"}}] ;; could be "mousedown" or "click"
(let [[ref set-ref] (rum/use-state nil)]
(rum/use-effect!
(fn []
(let [listener (fn [e]
(when (and ref
(not (.. ref (contains (.-target e)))))
(handler e)))]
(js/document.addEventListener event listener capture?)
#(js/document.removeEventListener event listener capture?)))
[ref])
set-ref))
(defonce *key->atom (atom {}))
(defn cached-derived-atom
"Make sure to return the same atom if `key` is the same."

View File

@@ -10,7 +10,6 @@
["emoji-mart" :as emoji-mart]
[cljs-bean.core :as bean]
[clojure.string :as string]
[datascript.core :as d]
[electron.ipc :as ipc]
[frontend.components.svg :as svg]
[frontend.config :as config]
@@ -1160,24 +1159,6 @@
ref (.-ref inViewState)]
(lazy-visible-inner visible? content-fn ref fade-in?))))
(rum/defc portal
([children]
(portal children {:attach-to (fn [] js/document.body)
:prepend? false}))
([children {:keys [attach-to prepend?]}]
(let [[portal-anchor set-portal-anchor] (rum/use-state nil)]
(rum/use-effect!
(fn []
(let [div (js/document.createElement "div")
attached (or (if (fn? attach-to) (attach-to) attach-to) js/document.body)]
(.setAttribute div "data-logseq-portal" (str (d/squuid)))
(if prepend? (.prepend attached div) (.append attached div))
(set-portal-anchor div)
#(.remove div)))
[])
(when portal-anchor
(rum/portal (rum/fragment children) portal-anchor)))))
(rum/defc menu-heading
([add-heading-fn auto-heading-fn rm-heading-fn]
(menu-heading nil add-heading-fn auto-heading-fn rm-heading-fn))

View File

@@ -409,7 +409,6 @@
:whiteboard/arrow-head "Pfeilspitze"
:whiteboard/auto-resize "Automatisch Grösse ändern"
:whiteboard/bold "Fett"
:whiteboard/cache-outdated "Der Cache ist veraltet. Klicken Sie auf 'Neu indizieren' im Dropdown-Menu des Graphen."
:whiteboard/circle "Kreis"
:whiteboard/collapse "Einklappen"
:whiteboard/color "Farbe"

View File

@@ -438,7 +438,6 @@
:whiteboard/new-whiteboard "New whiteboard"
:whiteboard/search-only-blocks "Search only blocks"
:whiteboard/search-only-pages "Search only pages"
:whiteboard/cache-outdated "Cache is outdated. Please click the 'Re-index' button in the graph's dropdown menu."
:whiteboard/shape-quick-links "Shape Quick Links"
:whiteboard/edit-pdf "Edit PDF"
:whiteboard/dashboard-card-new-whiteboard "New whiteboard"
@@ -447,7 +446,6 @@
:whiteboard/toggle-grid "Toggle grid"
:whiteboard/snap-to-grid "Snap to grid"
:whiteboard/toggle-pen-mode "Toggle pen mode"
:whiteboard/reference-count (fn [refs-count] (if (= refs-count 1) "Reference" "References"))
:flashcards/modal-welcome-title "Time to create a card!"
:flashcards/modal-welcome-desc-1 "You can add \"#card\" to any block to turn it into a card or trigger \"/cloze\" to add some clozes."
:flashcards/modal-welcome-desc-2 "You can "

View File

@@ -667,7 +667,6 @@
:whiteboard/arrow-head "Cabeza de flecha"
:whiteboard/auto-resize "Cambiar tamaño automáticamente"
:whiteboard/bold "Negrita"
:whiteboard/cache-outdated "La caché está desactualizada. Por favor da clic en el botón 'Reindexar' en el menú desplegable del grafo."
:whiteboard/circle "Círculo"
:whiteboard/collapse "Colapsar"
:whiteboard/color "Color"
@@ -719,7 +718,6 @@
:whiteboard/paste-as-link "Pegar como enlace"
:whiteboard/rectangle "Recargar"
:whiteboard/redo "Rehacer"
:whiteboard/reference-count (fn [refs-count] (if (= refs-count 1) "Referencia" "Referencias"))
:whiteboard/references "Referencias"
:whiteboard/reload "Recargar"
:whiteboard/remove-link "Eliminar enlace"

View File

@@ -491,7 +491,6 @@
:whiteboard/color "Couleur"
:whiteboard/collapse "Réduire"
:whiteboard/circle "Cercle"
:whiteboard/cache-outdated "Le cache n'est plus à jour. Cliquez sur 'Ré-indexer' mais…"
:whiteboard/bold "Gras"
:whiteboard/auto-resize "Redimensionnement automatique"
:whiteboard/arrow-head "Pointe de flèche"
@@ -502,7 +501,6 @@
:whiteboard/align-center-horizontally "Aligner horizontalement au centre"
:whiteboard/align-bottom "Aligner en bas"
:whiteboard/add-block-or-page "Ajouter un bloc ou une page"
:whiteboard/reference-count (fn [refs-count] (if (= refs-count 1) "Référence" "Références"))
:whiteboard/toggle-pen-mode "Activer/désactiver le mode stylet"
:tips/all-done "Tout est complété !"
:shortcut.category/whiteboard "Tableau blanc"

View File

@@ -405,7 +405,6 @@
:whiteboard/new-whiteboard "Papan tulis baru"
:whiteboard/search-only-blocks "Cari hanya blok"
:whiteboard/search-only-pages "Cari hanya halaman"
:whiteboard/cache-outdated "Cache sudah ketinggalan zaman. Klik tombol 'Re-indeks' dalam menu tarik-turun grafik."
:whiteboard/shape-quick-links "Tautan Cepat Bentuk"
:whiteboard/edit-pdf "Sunting PDF"
:whiteboard/dashboard-card-new-whiteboard "Papan tulis baru"

View File

@@ -656,7 +656,6 @@
:whiteboard/arrow-head "Punta della freccia"
:whiteboard/auto-resize "Ridimensiona automaticamente"
:whiteboard/bold "Grassetto"
:whiteboard/cache-outdated "La cache è obsoleta. Clicca 'Re-indicizza' nel menù a discesa del grafo."
:whiteboard/circle "Cerchio"
:whiteboard/collapse "Collassa"
:whiteboard/color "Colore"
@@ -754,5 +753,4 @@
:linked-references/filter-includes "Include: "
:linked-references/reference-count (fn [filtered-count total] (str (when filtered-count (str filtered-count " di ")) total (if (= total 1) " Riferimento Collegato" " Riferimenti Collegati")))
:settings-page/git-commit-on-close "Esegui commit Git alla chiusura della finestra"
:unlinked-references/reference-count (fn [total] (str total (if (= total 1) " Riferimento Scollegato" " Riferimenti Scollegati")))
:whiteboard/reference-count (fn [refs-count] (if (= refs-count 1) "Riferimento" "Riferimenti"))}
:unlinked-references/reference-count (fn [total] (str total (if (= total 1) " Riferimento Scollegato" " Riferimenti Scollegati")))}

View File

@@ -415,7 +415,6 @@
:whiteboard/new-whiteboard "新しいホワイトボード"
:whiteboard/search-only-blocks "ブロックだけを検索"
:whiteboard/search-only-pages "ページだけを検索"
:whiteboard/cache-outdated "キャッシュが古くなっています。グラフのドロップダウンメニューにある「インデックス再構築」ボタンをクリックしてください。"
:whiteboard/shape-quick-links "図形のクイックリンク"
:whiteboard/edit-pdf "PDFを編集"
:whiteboard/dashboard-card-new-whiteboard "新しいホワイトボード"

View File

@@ -491,7 +491,6 @@
:whiteboard/arrow-head "Pilhode"
:whiteboard/auto-resize "Automatisk endre størrelse"
:whiteboard/bold "Fet"
:whiteboard/cache-outdated "Cache er utdatert. Vennligst klikk 'Re-indekser' knappen"
:whiteboard/circle "Sirkel"
:whiteboard/collapse "Trekk sammen"
:whiteboard/color "Farge"
@@ -761,5 +760,4 @@
:linked-references/filter-includes "Inkluderer: "
:linked-references/reference-count (fn [filtered-count total] (str (when filtered-count (str filtered-count " av ")) total (if (= total 1) " Lenket Referanse" " Lenkede Referanser")))
:pdf/auto-open-context-menu "Auto-åpne kontekstmeny for valg"
:unlinked-references/reference-count (fn [total] (str total (if (= total 1) " Ulenket Referanse" " Ulenkede Referanser")))
:whiteboard/reference-count (fn [refs-count] (if (= refs-count 1) "Referanse" "Referanser"))}
:unlinked-references/reference-count (fn [total] (str total (if (= total 1) " Ulenket Referanse" " Ulenkede Referanser")))}

View File

@@ -409,7 +409,6 @@
:whiteboard/new-whiteboard "Novo whiteboard"
:whiteboard/search-only-blocks "Pesquisar apenas blocos"
:whiteboard/search-only-pages "Pesquisar apenas páginas"
:whiteboard/cache-outdated "O cache está desatualizado. Clique no botão 'Re-indexar' no menu suspenso do grafo."
:whiteboard/shape-quick-links "Links Rápidos de Forma"
:whiteboard/edit-pdf "Editar PDF"
:whiteboard/dashboard-card-new-whiteboard "Novo whiteboard"
@@ -762,7 +761,6 @@
:linked-references/reference-count (fn [filtered-count total] (str (when filtered-count (str filtered-count " de ")) total (if (= total 1) " Referência Vinculada" " Referências Vinculadas")))
:settings-page/git-commit-on-close "Commitar mudanças no Git ao fechar a janela"
:unlinked-references/reference-count (fn [total] (str total (if (= total 1) " Referência Não-Vinculada" " Referências Não-Vinculadas")))
:whiteboard/reference-count (fn [refs-count] (if (= refs-count 1) "Referência" "Referências"))
;; Allowed duplicates - start
:settings-of-plugins "Plugins"

View File

@@ -305,7 +305,6 @@
:whiteboard/new-whiteboard "Новая интерактивная доска"
:whiteboard/search-only-blocks "Поиск только по блокам"
:whiteboard/search-only-pages "Поиск только по страницам"
:whiteboard/cache-outdated "Кэш устарел. Пожалуйста, нажмите кнопку 'Переиндексировать' в выпадающем меню графов."
:whiteboard/shape-quick-links "Быстрые ссылки элемента"
:home "Домой"
:new-page "Новая страница:"

View File

@@ -407,7 +407,6 @@
:whiteboard/new-whiteboard "Nová tabuľa"
:whiteboard/search-only-blocks "Vyhľadávať iba bloky"
:whiteboard/search-only-pages "Vyhľadávať iba stránky"
:whiteboard/cache-outdated "Cache je zastaraná. Kliknite na tlačidlo 'Preindexovať' v rozbaľovacom menu grafu."
:whiteboard/shape-quick-links "Rýchle odkazy na tvary"
:whiteboard/edit-pdf "Upraviť PDF"
:whiteboard/dashboard-card-new-whiteboard "Nová tabuľa"

View File

@@ -434,7 +434,6 @@
:whiteboard/new-whiteboard "Yeni beyaz tahta"
:whiteboard/search-only-blocks "Yalnızca blokları ara"
:whiteboard/search-only-pages "Yalnızca sayfaları ara"
:whiteboard/cache-outdated "Önbellek eski. Lütfen grafın açılır menüsündeki 'Yeniden dizin oluştur' düğmesini tıklayın."
:whiteboard/shape-quick-links "Hızlı Bağlantıları Şekillendir"
:whiteboard/edit-pdf "PDF'yi düzenle"
:whiteboard/dashboard-card-new-whiteboard "Yeni beyaz tahta"
@@ -443,7 +442,6 @@
:whiteboard/toggle-grid "Kılavuzu aç/kapat"
:whiteboard/snap-to-grid "Kılavuzlara daya"
:whiteboard/toggle-pen-mode "Kalem modunu aç/kapat"
:whiteboard/reference-count (fn [refs-count] (if (= refs-count 1) "Referans" "Referans"))
:flashcards/modal-welcome-title "Bir kart oluşturma zamanı!"
:flashcards/modal-welcome-desc-1 "Herhangi bir bloğu karta dönüştürmek için \"#card\" etiketini ekleyebilir veya cümle tamamlama eklemek için \"/cloze\" komutunu kullanabilirsiniz."
:flashcards/modal-welcome-desc-2 "Belgeleri kontrol etmek için "

View File

@@ -409,7 +409,6 @@
:whiteboard/new-whiteboard "新白板:"
:whiteboard/search-only-blocks "仅搜索块"
:whiteboard/search-only-pages "仅搜索页面"
:whiteboard/cache-outdated "缓存已过期。 请点击图谱下拉菜单中的 '重新建立索引' 按钮重建索引。"
:whiteboard/shape-quick-links "形状快速链接"
:whiteboard/dashboard-card-new-whiteboard "新建白板"
:whiteboard/dashboard-card-created "创建于 "