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

A way for node types to control/restrict their content #220

Closed
marijnh opened this issue Feb 25, 2016 · 6 comments
Closed

A way for node types to control/restrict their content #220

marijnh opened this issue Feb 25, 2016 · 6 comments

Comments

@marijnh
Copy link
Member

marijnh commented Feb 25, 2016

We will need this for various use cases:

  • 'heading can only appear as the first node of a section'
  • 'a figure has a caption followed by one or more images'
  • 'all rows in a table have the same number of columns'

Designing a usable and sound way to do this remains a partially open question. Feel free to submit additional use cases. This also ties into #187 since preserving these restrictions during replace is the hardest aspect.

@ericandrewlewis ericandrewlewis added this to the 0.5.0 milestone Feb 25, 2016
@ericandrewlewis ericandrewlewis removed this from the 0.5.0 milestone Mar 31, 2016
@WesleyKapow
Copy link
Contributor

Few use cases of mine:

  • Lists can only contain paragraphs and other lists
  • Blockquotes can only contain paragraphs
  • Headings can only contain text and certain marks (notably NOT bold)

@marijnh
Copy link
Member Author

marijnh commented Mar 31, 2016

@Wes-R Those can all be expressed in the current system (and the new one will definitely keep on supporting them)

@kiejo
Copy link
Contributor

kiejo commented Mar 31, 2016

I have the following use case: Creating a "task list" which contains list items that have exactly two children, a checkbox as the first child and a paragraph as the second. Apart from this constraint the task list should behave the same way as a BulletList and ListItems (support nesting, lifting, sinking).

@mworrell
Copy link

mworrell commented May 3, 2016

This sounds as a sanitizer/validator.
Which could be expressed by parsing the (markup-) tree using, for example, an EBNF grammar.

Note that during editing the tree doesn't necessarily match the grammar. For example, in the above task-list description, the insertion of both child-nodes is probably not an atomic operation. This makes it necessary to either insert missing nodes, or have specific validation moments.

@marijnh
Copy link
Member Author

marijnh commented May 3, 2016

The idea is to enforce these at every point. Inserting two child nodes can be made an atomic operation. There are some other constraints, such as paragraphs not being empty, that would be better suited for a validator, since it'd be painful to not be able to have empty paragraphs during editing.

@marijnh
Copy link
Member Author

marijnh commented May 11, 2016

This has landed in ba98389...f6839de. Please open new issues for problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants