Skip to content

Formatters: remove need for zero-width spaces. #414

@diegoreymendez

Description

@diegoreymendez

Description:

Currently, our formatters require zero-width spaces so that they can apply styles (such as header, blockquote, list) to an empty range of text.

The problem with adding these characters is that we must remove them too, once they're no longer necessary. This has not been the case so far.

We need to remove the need to have those characters inserted to begin with.

Details:

Some research has shown that modifying the typing attributes has an impact on how the text view lays out its contents. This is the direction that should enable us to draw blockquotes, lists, etc without really adding any content.

The problem with this approach is that NSLayoutManager does not have access to the typingAttributes of its parent UITextView.

There are some hints online that these attributes are actually accessible through a private property. Search for typingAttributes in these NextStep sources.

Proposal:

  • Make sure styles are applied to typingAttributes whenever the line is empty (if there's a newline character, the line is NOT empty).
  • Consider drawing the bullet items for lists in TextView instead of LayoutManager.
  • Make sure whenever a formatter enables or disables a style, the line where the caret is placed is redrawn (we probably need to redraw al involved lines when there's a selection instead of a caret).
  • Remove zero-width space markers everywhere.

Child issues:

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions