Skip to content

Smart insertion/replacement algorithm #184

@salmenf

Description

@salmenf

Problem: For a given selection S (can be empty/nonempty, TextSelection/NodeSelection/GapSelection) and a fragment F, create a new fragment R that preserves as much of S as possible.

For S -> empty TextSelection:

  1. Replace block content in F with equivalent inline content if possible.
  2. If F is a single node and can replace the container of S, replace the container of S.
  3. Else insert content (and if F contains block content, split container at the block content).

For S -> nonempty TextSelection: ???

For S -> GapSelection:

  1. Replace inline content in F with equivalent block content if possible..
  2. If F still contains inline content, wrap each inline node in a valid container.
  3. Insert F.

For S -> NodeSelection:

  1. If selected node fits into F, place it in F.
  2. Else if selected node does not fit into F, replace it with F.

Metadata

Metadata

Assignees

No one assigned

    Labels

    for authorsBug or enhancement regarding explorable authors

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions