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

modelCursor not set properly on auto-paragraphing #3309

Closed
scofalik opened this issue Feb 25, 2019 · 2 comments
Closed

modelCursor not set properly on auto-paragraphing #3309

scofalik opened this issue Feb 25, 2019 · 2 comments
Labels
package:paragraph resolution:expired This issue was closed due to lack of feedback. status:stale type:bug This issue reports a buggy (incorrect) behavior.

Comments

@scofalik
Copy link
Contributor

As we know, paragraph feature introduces also auto-paragraphing mechanism. Every non-converted paragraph-like element (e.g. <div>) is converted as it is a paragraph.

// Output range starts before paragraph but ends inside it after last child.
// This is because we want to keep siblings inside the same paragraph as long as it is possible.
// When next node won't be allowed in a paragraph it will split this paragraph anyway.
data.modelRange = writer.createRange( writer.createPositionBefore( paragraph ), modelRange.end );
data.modelCursor = data.modelRange.end;

This is how modelCursor is set in auto-paragraphing. This is how it is set in upcast conversion helper:

// Now we need to check where the modelCursor should be.
// If we had to split parent to insert our element then we want to continue conversion inside split parent.
//
// before: <allowed><notAllowed>[]</notAllowed></allowed>
// after:  <allowed><notAllowed></notAllowed><converted></converted><notAllowed>[]</notAllowed></allowed>
if ( splitResult.cursorParent ) {
	data.modelCursor = conversionApi.writer.createPositionAt( splitResult.cursorParent, 0 );
	// Otherwise just continue after inserted element.
} else {
	data.modelCursor = data.modelRange.end;
}

I think we should do it in the same or similar way as in upcast conversion helper, because following can happen:

<div><h2>Foo</h2></div>

<div> is auto-paragraphed but it is also broken by <h2> (which is converted to heading1).

<paragraph></paragraph><heading1>Foo</heading1><paragraph></paragraph>

And in this case, the modelCursor is incorrectly set after <heading1> instead of inside second <paragraph>.

@mlewand mlewand transferred this issue from ckeditor/ckeditor5-paragraph Oct 9, 2019
@mlewand mlewand added this to the backlog milestone Oct 9, 2019
@mlewand mlewand added status:confirmed type:bug This issue reports a buggy (incorrect) behavior. package:paragraph labels Oct 9, 2019
@pomek pomek removed this from the backlog milestone Feb 21, 2022
@CKEditorBot
Copy link
Collaborator

There has been no activity on this issue for the past year. We've marked it as stale and will close it in 30 days. We understand it may be relevant, so if you're interested in the solution, leave a comment or reaction under this issue.

@CKEditorBot
Copy link
Collaborator

We've closed your issue due to inactivity over the last year. We understand that the issue may still be relevant. If so, feel free to open a new one (and link this issue to it).

@CKEditorBot CKEditorBot added the resolution:expired This issue was closed due to lack of feedback. label Nov 7, 2023
@CKEditorBot CKEditorBot closed this as not planned Won't fix, can't repro, duplicate, stale Nov 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package:paragraph resolution:expired This issue was closed due to lack of feedback. status:stale type:bug This issue reports a buggy (incorrect) behavior.
Projects
None yet
Development

No branches or pull requests

4 participants