Skip to content
This repository has been archived by the owner on May 20, 2020. It is now read-only.

Why does CKEditor 5 Classic convert newlines in snippets to @ symbols? #231

Open
GaurangTandon opened this issue Sep 14, 2018 · 2 comments
Labels
bug can-reproduce bug reports that can be reproduced by the owner, on the then app version snippet-insertion

Comments

@GaurangTandon
Copy link
Owner

To reproduce this issue, run any multi-line snippet like letter in the editor.

@GaurangTandon GaurangTandon added bug snippet-insertion rejected enhancement that won't be made can-reproduce bug reports that can be reproduced by the owner, on the then app version wont-fix labels Sep 14, 2018
@GaurangTandon
Copy link
Owner Author

By closely inspecting the breakpoints, I found that under mutationobserver.js (@module engine/view/observer/mutationobserver)

    let viewSelection = null;

	if ( domSelection && domSelection.anchorNode ) {
		// If `domSelection` is inside a dom node that is already bound to a view node from view tree, get
		// corresponding selection in the view and pass it together with `viewMutations`. The `viewSelection` may
		// be used by features handling mutations.
		// Only one range is supported.

		const viewSelectionAnchor = domConverter.domPositionToView( domSelection.anchorNode, domSelection.anchorOffset );
		const viewSelectionFocus = domConverter.domPositionToView( domSelection.focusNode, domSelection.focusOffset );

		// Anchor and focus has to be properly mapped to view.
		if ( viewSelectionAnchor && viewSelectionFocus ) {
			viewSelection = new ViewSelection( viewSelectionAnchor );
			viewSelection.setFocus( viewSelectionFocus );
		}
	}

	this.document.fire( 'mutations', viewMutations, viewSelection );

as soon as the line this.document.fire executes, the correctly inserted newlines (and the correctly highlighted placeholders) are replaced by @, and the caret is misplaced.

I still need to figure out a way to avoid this from happening. CKEditor has a range of super popular editors, and we can become popular for supporting their editors.

@GaurangTandon GaurangTandon removed wont-fix rejected enhancement that won't be made labels Sep 14, 2018
@GaurangTandon
Copy link
Owner Author

Considering that other text expanders work nicely in ckeditor, I was led to believe that the problem is basically that prokeys wraps the entire insertion in a span element while the others do not. This directly relates to #259

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug can-reproduce bug reports that can be reproduced by the owner, on the then app version snippet-insertion
Projects
None yet
Development

No branches or pull requests

1 participant