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

Selection position is lost when unwrapping range #3999

Closed
Reinmar opened this issue Feb 23, 2017 · 4 comments · Fixed by ckeditor/ckeditor5-engine#856
Closed

Selection position is lost when unwrapping range #3999

Reinmar opened this issue Feb 23, 2017 · 4 comments · Fixed by ckeditor/ckeditor5-engine#856
Assignees
Labels
package:engine type:bug This issue reports a buggy (incorrect) behavior.
Milestone

Comments

@Reinmar
Copy link
Member

Reinmar commented Feb 23, 2017

setModelData(
	doc,
	'<heading>a[bc</heading>' +
	'<messageQuote><paragraph>x]x</paragraph></messageQuote>' +
	'<paragraph>def</paragraph>'
);

batch.unwrap( quote );

console.log( getModelData( doc ) ); // <heading>a[bc</heading><paragraph>xx</paragraph>]<paragraph>def</paragraph>
@Reinmar
Copy link
Member Author

Reinmar commented Feb 24, 2017

I also get:

<messageQuote><heading>a[bc</heading><paragraph>def</paragraph><paragraph>xx</paragraph>]</messageQuote><paragraph>ghi</paragraph>

For this content:

setModelData(
	doc,
	'<heading>a[bc</heading>' +
	'<paragraph>def</paragraph>' +
	'<messageQuote><paragraph>x]x</paragraph></messageQuote>' +
	'<paragraph>ghi</paragraph>'
);

And this:

[<messageQuote><paragraph>abc</paragraph></messageQuote><widget>xx</widget>]<messageQuote><paragraph>def</paragraph></messageQuote>

When wrapping both paragraphs separately:

<paragraph>a[bc</paragraph><widget>xx</widget><paragraph>de]f</paragraph>

@Reinmar Reinmar self-assigned this Feb 24, 2017
@Reinmar
Copy link
Member Author

Reinmar commented Feb 24, 2017

I pushed t/841 with tests. All red :D

@Reinmar
Copy link
Member Author

Reinmar commented Feb 27, 2017

I feel I'll need this many times, so a snippet for debugging this:

import { stringify } from '../dev-utils/model';

result[ 0 ] && console.log( 0, changeType, deltaType, stringify( result[ 0 ].root, result[ 0 ] ) );
result[ 1 ] && console.log( 1, changeType, deltaType, stringify( result[ 1 ].root, result[ 1 ] ) );
result[ 2 ] && console.log( 2, changeType, deltaType, stringify( result[ 2 ].root, result[ 2 ] ) );

@Reinmar
Copy link
Member Author

Reinmar commented Feb 27, 2017

t/841 contains a potential fix for this issue now, but I'd need to add a few tests in the range itself (e.g. for getTransformedByDelta()) or move the current ones there before it could be merged, so I'll first work on the message quote feature to validate these changes.

Reinmar referenced this issue in ckeditor/ckeditor5-engine Mar 7, 2017
Fix: Fixed a bug where `LiveRange` position would be lost when using wrap and unwrap deltas. Closes #841.
@mlewand mlewand transferred this issue from ckeditor/ckeditor5-engine Oct 9, 2019
@mlewand mlewand added this to the iteration 9 milestone Oct 9, 2019
@mlewand mlewand added status:confirmed type:bug This issue reports a buggy (incorrect) behavior. package:engine labels Oct 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package:engine type:bug This issue reports a buggy (incorrect) behavior.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants