Skip to content

Commit

Permalink
trick to replace remove leaves; bump 0.5.27
Browse files Browse the repository at this point in the history
  • Loading branch information
tiye committed May 20, 2021
1 parent 887fc80 commit 041628c
Show file tree
Hide file tree
Showing 5 changed files with 298 additions and 257 deletions.
48 changes: 42 additions & 6 deletions calcit.cirru
Original file line number Diff line number Diff line change
Expand Up @@ -2012,11 +2012,12 @@
|T $ {} (:type :leaf) (:by |S1lNv50FW) (:at 1590859806430) (:text |not)
|j $ {} (:type :expr) (:by |S1lNv50FW) (:at 1590859806430)
:data $ {}
|T $ {} (:type :leaf) (:by |S1lNv50FW) (:at 1590859806430) (:text |string/blank?)
|T $ {} (:type :leaf) (:by |S1lNv50FW) (:at 1621491703610) (:text |=)
|j $ {} (:type :expr) (:by |S1lNv50FW) (:at 1590859806430)
:data $ {}
|T $ {} (:type :leaf) (:by |S1lNv50FW) (:at 1590859806430) (:text |:new-name)
|j $ {} (:type :leaf) (:by |S1lNv50FW) (:at 1590859806430) (:text |state)
|r $ {} (:type :leaf) (:by |S1lNv50FW) (:at 1621491705503) (:text "|\"")
|r $ {} (:type :expr) (:by |S1lNv50FW) (:at 1590859806430)
:data $ {}
|T $ {} (:type :leaf) (:by |S1lNv50FW) (:at 1590859806430) (:text |on-replace)
Expand All @@ -2043,6 +2044,10 @@
|L $ {} (:type :expr) (:by |S1lNv50FW) (:at 1590859809429)
:data $ {}
|T $ {} (:type :leaf) (:by |S1lNv50FW) (:at 1590859812809) (:text |d!)
|P $ {} (:type :expr) (:by |S1lNv50FW) (:at 1621491753308)
:data $ {}
|T $ {} (:type :leaf) (:by |S1lNv50FW) (:at 1621491754908) (:text |;)
|j $ {} (:type :leaf) (:by |S1lNv50FW) (:at 1621491795462) (:text "|\"special trick to use spaces to remove a leaf")
|r $ {} (:type :expr) (:by |S1lNv50FW) (:at 1590858007394)
:data $ {}
|T $ {} (:type :expr) (:by |S1lNv50FW) (:at 1590858009327)
Expand Down Expand Up @@ -26791,6 +26796,37 @@
|j $ {} (:type :expr) (:by |S1lNv50FW) (:at 1580646258900)
:data $ {}
|T $ {} (:type :leaf) (:by |S1lNv50FW) (:at 1580646258900) (:text |{})
|t $ {} (:type :expr) (:by |S1lNv50FW) (:at 1621491554528)
:data $ {}
|T $ {} (:type :leaf) (:by |S1lNv50FW) (:at 1621492809407) (:text |remove)
|j $ {} (:type :expr) (:by |S1lNv50FW) (:at 1621491555739)
:data $ {}
|T $ {} (:type :leaf) (:by |S1lNv50FW) (:at 1621491556775) (:text |fn)
|j $ {} (:type :expr) (:by |S1lNv50FW) (:at 1621491557660)
:data $ {}
|T $ {} (:type :expr) (:by |S1lNv50FW) (:at 1621491558718)
:data $ {}
|T $ {} (:type :leaf) (:by |S1lNv50FW) (:at 1621491559009) (:text |[])
|j $ {} (:type :leaf) (:by |S1lNv50FW) (:at 1621491559882) (:text |k)
|r $ {} (:type :leaf) (:by |S1lNv50FW) (:at 1621491560207) (:text |v)
|l $ {} (:type :expr) (:by |S1lNv50FW) (:at 1621492778470)
:data $ {}
|T $ {} (:type :expr) (:by |S1lNv50FW) (:at 1621492772935)
:data $ {}
|T $ {} (:type :leaf) (:by |S1lNv50FW) (:at 1621492773040) (:text |=)
|j $ {} (:type :expr) (:by |S1lNv50FW) (:at 1621492773779)
:data $ {}
|T $ {} (:type :leaf) (:by |S1lNv50FW) (:at 1621492774529) (:text |:type)
|j $ {} (:type :leaf) (:by |S1lNv50FW) (:at 1621492871281) (:text |v)
|r $ {} (:type :leaf) (:by |S1lNv50FW) (:at 1621492777669) (:text |:leaf)
|D $ {} (:type :leaf) (:by |S1lNv50FW) (:at 1621492779316) (:text |and)
|j $ {} (:type :expr) (:by |S1lNv50FW) (:at 1621492779768)
:data $ {}
|T $ {} (:type :leaf) (:by |S1lNv50FW) (:at 1621492937599) (:text |string/blank?)
|j $ {} (:type :expr) (:by |S1lNv50FW) (:at 1621492784227)
:data $ {}
|T $ {} (:type :leaf) (:by |S1lNv50FW) (:at 1621492785070) (:text |:text)
|j $ {} (:type :leaf) (:by |S1lNv50FW) (:at 1621492872193) (:text |v)
|v $ {} (:type :expr) (:by |S1lNv50FW) (:at 1580646258900)
:data $ {}
|T $ {} (:type :leaf) (:by |S1lNv50FW) (:at 1580646258900) (:text |:leaf)
Expand All @@ -26806,12 +26842,12 @@
|T $ {} (:type :leaf) (:by |S1lNv50FW) (:at 1580646258900) (:text |:text)
|j $ {} (:type :leaf) (:by |S1lNv50FW) (:at 1580646258900) (:text |expr)
|r $ {} (:type :leaf) (:by |S1lNv50FW) (:at 1580646258900) (:text |from)
|r $ {} (:type :expr) (:by |S1lNv50FW) (:at 1580646258900)
|r $ {} (:type :expr) (:by |S1lNv50FW) (:at 1621492860808)
:data $ {}
|T $ {} (:type :leaf) (:by |S1lNv50FW) (:at 1580646258900) (:text |assoc)
|j $ {} (:type :leaf) (:by |S1lNv50FW) (:at 1580646258900) (:text |expr)
|r $ {} (:type :leaf) (:by |S1lNv50FW) (:at 1580646258900) (:text |:text)
|v $ {} (:type :leaf) (:by |S1lNv50FW) (:at 1580646258900) (:text |to)
|T $ {} (:type :leaf) (:by |S1lNv50FW) (:at 1621492860808) (:text |assoc)
|j $ {} (:type :leaf) (:by |S1lNv50FW) (:at 1621492860808) (:text |expr)
|r $ {} (:type :leaf) (:by |S1lNv50FW) (:at 1621492860808) (:text |:text)
|v $ {} (:type :leaf) (:by |S1lNv50FW) (:at 1621492860808) (:text |to)
|D $ {} (:type :leaf) (:by |S1lNv50FW) (:at 1594573671230) (:text |cond)
|j $ {} (:type :expr) (:by |S1lNv50FW) (:at 1594573672890)
:data $ {}
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "calcit-editor",
"version": "0.5.26",
"version": "0.5.27",
"description": "Cirru Calcit Editor",
"bin": {
"calcit-editor": "dist/server.js",
Expand All @@ -23,12 +23,12 @@
"license": "MIT",
"devDependencies": {
"feather-icons": "^4.28.0",
"shadow-cljs": "^2.12.1",
"shadow-cljs": "^2.13.0",
"source-map-support": "^0.5.19",
"url-parse": "^1.5.1"
},
"dependencies": {
"chalk": "^4.1.0",
"chalk": "^4.1.1",
"dayjs": "^1.10.4",
"express": "^4.17.1",
"gaze": "^1.1.3",
Expand All @@ -38,6 +38,6 @@
"nrepl-client": "^0.3.0",
"serve-index": "^1.9.1",
"shortid": "^2.2.16",
"ws": "^7.4.4"
"ws": "^7.4.5"
}
}
3 changes: 2 additions & 1 deletion src/app/comp/replace_name.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
(let [cursor (:cursor states)
state (or (:data states) {:old-name "", :new-name "", :show? false})
on-submit (fn [d!]
(comment "special trick to use spaces to remove a leaf")
(when (and (not (string/blank? (:old-name state)))
(not (string/blank? (:new-name state))))
(not (= (:new-name state) "")))
(on-replace (:old-name state) (:new-name state) d!)
(d! cursor (assoc state :show? false))))]
{:ui (comp-modal
Expand Down
6 changes: 5 additions & 1 deletion src/app/updater/ir.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,11 @@
(update
expr
:data
(fn [data] (->> data (map (fn [[k v]] [k (call-replace-expr v from to)])) (into {}))))
(fn [data]
(->> data
(map (fn [[k v]] [k (call-replace-expr v from to)]))
(remove (fn [[k v]] (and (= (:type v) :leaf) (string/blank? (:text v)))))
(into {}))))
:leaf
(cond
(= (:text expr) from) (assoc expr :text to)
Expand Down
Loading

0 comments on commit 041628c

Please sign in to comment.