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

Cannot delete paragraph before and after a widget / Delete space above widget #1572

Closed
HarryMuc opened this issue Feb 2, 2018 · 11 comments
Closed
Assignees
Labels
status:confirmed An issue confirmed by the development team. support An issue reported by a commercially licensed client. type:bug A bug.
Milestone

Comments

@HarryMuc
Copy link

HarryMuc commented Feb 2, 2018

Are you reporting a feature request or a bug?

The old issues
"Cannot delete paragraph before and after a widget"
"Delete space above widget"
are still not fixed

Check if the issue is already reported

https://dev.ckeditor.com/ticket/12778
https://dev.ckeditor.com/ticket/13864

Provide detailed reproduction steps (if any)

Just open this page:
https://sdk.ckeditor.com/samples/simplebox.html

Paste this Code:

<h1>&nbsp;</h1>
<div class="simplebox align-center" style="width:750px">
<h2 class="simplebox-title">Title</h2>
<div class="simplebox-content">
<p>Foo <strong>bar</strong>.</p>
<ul>
	<li>Foo!</li>
	<li>Bar!</li>
</ul>
</div>
</div>
<p>&nbsp;</p>
<div class="simplebox align-center" style="width:750px">
<h2 class="simplebox-title">Title</h2>
<div class="simplebox-content">
<p>Foo <strong>bar</strong>.</p>
<ul>
	<li>Foo!</li>
	<li>Bar!</li>
</ul>
</div>
</div>
<p>&nbsp;</p>

And try to delete the paragraphs before, between and after the widgets - not possible!

Expected result

The paragraphs should be deletable

Actual result

Paragraphs are not deleted

Other details

Plase check my workaround in core/selection.js:

	// Handle left, right, delete and backspace keystrokes next to non-editable elements
	// by faking selection on them.
	function getOnKeyDownListener( editor ) {
		var keystrokes = { 37: 1, 39: 1, 8: 1, 46: 1 };

		return function( evt ) {
			var keystroke = evt.data.getKeystroke();

			// Handle only left/right/del/bspace keys.
			if ( !keystrokes[ keystroke ] )
				return;

			var sel = editor.getSelection(),
				ranges = sel.getRanges(),
				range = ranges[ 0 ];

			// Handle only single range and it has to be collapsed.
			if ( ranges.length != 1 || !range.collapsed )
				return;

			var next = range[ keystroke < 38 ? 'getPreviousEditableNode' : 'getNextEditableNode' ]();

			if ( next && next.type == CKEDITOR.NODE_ELEMENT && next.getAttribute( 'contenteditable' ) == 'false' ) {
				/* $custom: added if case to allow removal of empty paragraphs, see incidents
					https://dev.ckeditor.com/ticket/12778
					https://dev.ckeditor.com/ticket/13864 */
				if(sel._ && sel._.cache && sel._.cache.nativeSel && sel._.cache.nativeSel.baseNode && sel._.cache.nativeSel.baseNode.nodeName === 'P'){
					range.endContainer.$.remove();
				} else {
					editor.getSelection().fake( next );
					evt.data.preventDefault();
					evt.cancel();
				}
			}
		};
	}
@jacekbogdanski jacekbogdanski self-assigned this Feb 5, 2018
@jacekbogdanski
Copy link
Member

Hello!

I can reproduce the issue and it's related to #749. It would be great if you could push Pull Request with your bug fix. We have some manual how to contribute to CKEDITOR 4, so if you are interested, please check How to contribute article.

@jacekbogdanski jacekbogdanski added status:confirmed An issue confirmed by the development team. type:bug A bug. labels Feb 5, 2018
@jacekbogdanski jacekbogdanski removed their assignment Feb 5, 2018
HarryMuc added a commit to HarryMuc/ckeditor-dev that referenced this issue Feb 5, 2018
@HarryMuc
Copy link
Author

HarryMuc commented Feb 5, 2018

#1584

@hissy
Copy link

hissy commented Aug 8, 2019

I can still reproduce this issue.

@bunglegrind
Copy link
Contributor

Hey folks, I noticed that HarryMuc provided a fix for this issue, but it was rejected because he didn't follow the contribution guidelines.

I want to resume his contribution, but I am having some difficulty for the setup of the test environment. Where is the right place to ask for support?

@f1ames
Copy link
Contributor

f1ames commented Dec 4, 2020

@bunglegrind please refer to our contributing guide.

@bunglegrind
Copy link
Contributor

bunglegrind commented Dec 4, 2020

yes, I've already did it, but there are some discrepances (maybe because I'm using Win10?) .

Specifically:

  1. without any change in the master branch, some tests are failing;
  2. If I insert invalid lines in the source code, the command grunt does not signal anything

immagine

@bunglegrind
Copy link
Contributor

Issue 2) was because grunt checks only the files in stage.

Anyway, I wrote some tests; performed a refactoring on the patch provided by HarryMuc, but I'm still puzzled about the overall test issue (see my point 1 above). Which is the minimum (number/kind/type) of tests a pull request must pass before it can be merged?

@Dumluregn
Copy link
Contributor

Hi @bunglegrind, as for the issue with failing tests - Win10 may be an issue here, could you give total number of failing tests? Basically all tests need to pass on all the browsers we support, but there is not a fixed number of tests that need to be added to the PR - it depends on the issue: sometimes 1 is enough, sometimes 4 is not.

I suggest you push a PR (I think it would be best if you create a new one instead of resurrecting #1584) and we'll see what CI tells about tests.

@bunglegrind
Copy link
Contributor

Sorry, I wasn't referring to the new tests I added, but to the old tests which were failing even before I changed a single line of code.
Anyway, I will follow your suggestion and I will prepare a PR for today. Cheers!

@CKEditorBot
Copy link
Collaborator

Closed in #4433

@CKEditorBot CKEditorBot added this to the 4.16.1 milestone Feb 23, 2021
@nuander
Copy link

nuander commented May 18, 2021

It would be nice if this fix also included the ability to delete break tabs from around widgets

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:confirmed An issue confirmed by the development team. support An issue reported by a commercially licensed client. type:bug A bug.
Projects
None yet
9 participants