dstoc / pkmapp

Apache License 2.0
2 stars 0 forks source link

Solving insert-before and insert-after #354

Open dstoc opened 3 months ago

dstoc commented 3 months ago

[Enter] has currently has magical and broken behavior.

The reason... it seemed desirable that pressing [Enter] in a list item would create a sibling list item. The workaround [Shift-Enter] creates an adjacent paragraph within the list item.

Following on from that, it seemed reasonable that this behavior would apply to other block types. Pressing [Enter] in a block quote would create a paragraph adjacent to the block quote.

However, this feels wrong when the block-quote contains other items like sections -- because pressing [Enter] in a section still creates an adjacent paragraph in the section.

dstoc commented 3 months ago

Proposal: [Enter] creates adjacent paragraphs,

Except when:

This may solve insert-after in general, even for transclusions.

As for insert-before. Maybe something similar can work for first-child? E.g. to insert-before a transclusion, move the cursor to the start then press twice (or more? depending on the containing blocks). Sections would need special treatment.

dstoc commented 3 months ago

in a list-item, it will create an adjacent list-item

Unless it's not just a simple list item, that is it contains more than a single paragraph.

dstoc commented 3 months ago

There are lots of special cases.

With sections for example, when there's a section inside a list-item, the adjacent paragraph generated after the section gets consumed by the section in normalization. We probably want to insert a subsequent list-item instead, but what if there's a subsequent section? I think we need to introduce a mechanic that can split the contents of a list-item across multiple list items.

There already exist other problems now that this may help to solve, for example:

* a
  * b

  c 

Attempting to unindent "b", results in:

* a

  c
* b
dstoc commented 3 months ago

Some further thoughts on this, undistilled.

  1. The model for [Enter] on an empty paragraph is not necessarily insert-before or insert-after, but could be thought of as "move-outwards". If you press [Enter] enough you'll end up at the top level (or top level section).
  2. It may then follow that pressing [Enter] for an otherwise empty list-item is the same as the existing unindent behavior (the above example being an exception).

Splitting seems pretty complex, and I'm not sure there's an inverse. But maybe that's OK?

What can be split?