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

FIX: Links: Can't add plain text after insert link at end of paragraph #2483

Merged
merged 1 commit into from
Aug 21, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion blocks/editable/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ function createTinyMCEElement( type, props, ...children ) {
);
}

function isLinkBoundary( fragment ) {
return fragment.childNodes && fragment.childNodes.length === 1 &&
fragment.childNodes[ 0 ].nodeName === 'A' && fragment.childNodes[ 0 ].text.length === 1 &&
fragment.childNodes[ 0 ].text[ 0 ] === '\uFEFF';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's fine for now, but maybe this character could be included in a constant somewhere in TinyMCE to avoid issues if it's changed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@youknowriad there's a function in TinyMCE we can look at exposing

}

export default class Editable extends Component {
constructor( props ) {
super( ...arguments );
Expand Down Expand Up @@ -369,7 +375,7 @@ export default class Editable extends Component {
const afterFragment = afterRange.extractContents();

const beforeElement = nodeListToReact( beforeFragment.childNodes, createTinyMCEElement );
const afterElement = nodeListToReact( afterFragment.childNodes, createTinyMCEElement );
const afterElement = isLinkBoundary( afterFragment ) ? [] : nodeListToReact( afterFragment.childNodes, createTinyMCEElement );

this.setContent( beforeElement );
this.props.onSplit( beforeElement, afterElement, ...blocks );
Expand Down