What pressing Enter does
Many people work with applications like Microsoft Word and this has shaped their pattern of expectations about what is going to happen when pressing enter. The underlying structure of Word is fairly accomodating for this behaviour, but nonetheless it is rather complex.
Pressing Enter in Xopus has similar complex behaviour under the hood. In plain terms , and in order, what happens is the following:
-
Xopus first looks for the parent block element. A block element is defined here as an element that can have no text, but only nodes, as content.
-
Secondly if the element is empty (no content) we try to remove the element and split the parent element. So if you are in an empty list-item, the empty item is removed and a new list is made, with a new item.
-
If the element is not empty and the cursor is at the beginning or end of the element's content, a similar element is added, before or after the current one. The element that is added is the type of element with the paragraph role as defined in your configuration.
This is normal list/paragraph behaviour. You are in a paragraph of list item, press enter and you have a new paragraph or list item.
-
If you are not at the beginning or end, Xopus tries to split the element.
This is also normal, expected, behaviour.
-
if none of the above applies Xopus starts looking for the next expected element, and tries to add this. This element is looked for in the Schema, and therefore it depends on your Schema whether Xopus will or will not find something.
-
Lastly if really nothing worked, the same steps are gone through for the parent element.
In a structure of a document like that of Word, where elements such as titles, headers, paragraphs, lists and tables occur, predicting what is meant by pressing enter can be very difficult.
Perhaps you mean to continue what you were doing, but if you have a paragraph in your list item, are you trying to make a new paragraph or a new list item. As you can see the above code will create a new list item if you press enter in an empty paragraph in a list item.
A lot of this depends on your Schema as well as your configuration. We are constantly working on improving these kinds of behaviour, although we do not always seek to emulate Word. We look for what suits the user best.
- Support /
- Documentation /
- FAQ /
- What pressing Enter does