Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create sibling for block with just comments #2329

Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 26 additions & 17 deletions src/cljs/athens/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -1092,27 +1092,36 @@
- If value is empty, unindent.
- If caret is at start and there is a value, create new block below but keep same block index."
[rfdb uid d-key-down]
(let [root-embed? (= (some-> d-key-down :target
(.. (closest ".block-embed"))
(. -firstChild)
(.getAttribute "data-uid"))
uid)
[uid embed-id] (db/uid-and-embed-id uid)
block (db/get-block [:block/uid uid])
(let [root-embed? (= (some-> d-key-down :target
(.. (closest ".block-embed"))
(. -firstChild)
(.getAttribute "data-uid"))
uid)
[uid embed-id] (db/uid-and-embed-id uid)
block (db/get-block [:block/uid uid])
block-properties (common-db/get-block-property-document @db/dsdb [:block/uid uid])
has-children-without-prop? (empty? (:block/children block))
{parent-uid :block/uid
:as parent} (db/get-parent [:block/uid uid])
is-parent-root-embed? (= (some-> d-key-down :target
(.. (closest ".block-embed"))
(. -firstChild)
(.getAttribute "data-uid"))
(str parent-uid "-embed-" embed-id))
root-block? (boolean (:node/title parent))
context-root-uid (get-in rfdb [:current-route :path-params :id])
new-uid (common.utils/gen-block-uid)
has-children? (seq (common-db/sorted-prop+children-uids @db/dsdb [:block/uid uid]))
:as parent} (db/get-parent [:block/uid uid])
is-parent-root-embed? (= (some-> d-key-down :target
(.. (closest ".block-embed"))
(. -firstChild)
(.getAttribute "data-uid"))
(str parent-uid "-embed-" embed-id))
root-block? (boolean (:node/title parent))
context-root-uid (get-in rfdb [:current-route :path-params :id])
new-uid (common.utils/gen-block-uid)
has-children? (seq (common-db/sorted-prop+children-uids @db/dsdb [:block/uid uid]))

{:keys [value start]} d-key-down
event (cond
(and (not-empty (get block-properties ":comment/threads"))
sid597 marked this conversation as resolved.
Show resolved Hide resolved
has-children-without-prop?
sid597 marked this conversation as resolved.
Show resolved Hide resolved
(= start (count value)))
sid597 marked this conversation as resolved.
Show resolved Hide resolved
[:enter/new-block {:block block
:parent parent
:new-uid new-uid
:embed-id embed-id}]
(:block/key block)
[:enter/split-block {:uid uid
:value value
Expand Down