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

Append a zero width space to inserted links #807

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

live627
Copy link
Collaborator

@live627 live627 commented Mar 5, 2021

Fixes #644

@brunoais
Copy link
Collaborator

brunoais commented Mar 5, 2021

What happens with the BBCode plugin and the xHTML plugin when they encounter that character?
Is a filter necessary to avoid sending those characters when trying to get their value?

@samclarke
Copy link
Owner

Adding a zero width space will cause backspace to not behave as expected. It might be better after inserting the HTML to move the cursor if it's inside the link. Something like:

// Set cursor to after the a element if A is the parent
function placeCursorAfterLink(rangeHelper) {
	var parent = rangeHelper.parentNode();
	if (parent && parent.nodeName === 'A') {
		var range = rangeHelper.selectedRange();
		range.setStartAfter(parent);
		rangeHelper.selectRange(range);
	}
}

// After inserting link HTML move the cursor
placeCursorAfterLink(editor.getRangeHelper());

@brunoais you're right it would be best to avoid including any formatting in the final output. I think in this case the removeWhiteSpace() function will already strip any zero width spaces so it should be OK.

@live627
Copy link
Collaborator Author

live627 commented Mar 6, 2021

That works... until you click the editor and notice that the link is still selected when you keep typing.

@jdarwood007
Copy link
Collaborator

I agree with Sam's approach.

@brunoais
Copy link
Collaborator

brunoais commented Mar 6, 2021

@samclarke I think that should only happen if the user places the cursor after the last character of the link.

IMO:
When the user clicks at the end of the link, the cursor should be placed after it (and not when clicking the link). If then the user presses left, the cursor should go inside the link and after the last character (the link button becoming active should be the feedback). To exit the anchor, just press arrow to the right until 1ce after the last character of the link.

Dunno if this is too much for this PR but I think this should be its workings

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

Successfully merging this pull request may close these issues.

Bug - Firefox only: Insert a Link (Hyperlink) doesn't stop editing of the link it self
4 participants