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

Migrate the Enter and ShiftEnter plugins to beforeInput #7999

Closed
oleq opened this issue Sep 2, 2020 · 3 comments
Closed

Migrate the Enter and ShiftEnter plugins to beforeInput #7999

oleq opened this issue Sep 2, 2020 · 3 comments
Assignees
Labels
domain:dx This issue reports a developer experience problem or possible improvement. domain:ui/ux This issue reports a problem related to UI or UX. package:typing type:task This issue reports a chore (non-production change) and other types of "todos".

Comments

@oleq
Copy link
Member

oleq commented Sep 2, 2020

Provide a description of the task

At this moment EnterObserver is used to detect Enter and Shift+Enter keystrokes. This can be handled via beforeInput insertParagraph and insertLineBreak event types, though, for instance:

editor.editing.view.document.on( 'beforeinput', ( evt, data ) => {
	const domEvent = data.domEvent;

	if ( domEvent.inputType === 'insertLineBreak' ) {
		editor.execute( 'shiftEnter' );

		evt.stop();
		data.preventDefault();
	}
} );
@oleq oleq added type:task This issue reports a chore (non-production change) and other types of "todos". domain:dx This issue reports a developer experience problem or possible improvement. domain:ui/ux This issue reports a problem related to UI or UX. package:typing labels Sep 2, 2020
@Reinmar Reinmar mentioned this issue Sep 3, 2020
13 tasks
@oleq
Copy link
Member Author

oleq commented Sep 3, 2020

Features that listen to enter:

  • BlockQuoteEditing,
  • CodeBlockEditing,
  • ListEditing,
  • WidgetTypeAround

@oleq oleq added this to the nice-to-have milestone Sep 3, 2020
@oleq
Copy link
Member Author

oleq commented Sep 3, 2020

Idea: Split the logic inside EnterObserver to either use keydown or beforeInput.

@oleq oleq added the squad:dx label Sep 3, 2020
@oleq oleq self-assigned this Sep 29, 2020
@oleq oleq modified the milestones: nice-to-have, iteration 37 Sep 29, 2020
oleq added a commit that referenced this issue Oct 6, 2020
Feature (typing): Migrated `Input` and `Delete` features to the `beforeinput` event. Implemented `InsertTextCommand` and the `insertText` view document event. Closes [#7997](#7997). Closes [#7998](#7998). 

Feature (enter): Migrated the `Enter` feature (and `EnterObserver`) to the `beforeinput` event. Closes [#7999](#7999).

Other (engine): `MutationObserver` should only be loaded when the web browser does not support Input Events. Closes [#7999](#7999).

Other (engine): Added the `isComposing` property to the `beforeinput` event data (see [#7997](#7997)).

Tests (block-quote): Aligned feature tests to `beforeinput`-driven delete (see [#7998](#7998)).

Internal (engine): Aligned the `SelectionObserver` to the `beforeinput`-driven typing (see [#799](#7998).

Internal (link): Aligned the `LinkEditing` feature to the `beforeinput`-driven deleting. Used the `InsertTextCommand` instead of `InputCommand` in the `AutoLink` plugin. (see [#799](#7998, [#7998](#7998)).

Tests (list): Used `InsertTextCommand` instead of deprecated `InputCommand` (see [#799](#7998).

Tests (media-embed): Used `InsertTextCommand` instead of deprecated `InputCommand` (see [#799](#7998).

Internal (restricted-editing): Used `InsertTextCommand` instead of deprecated `InputCommand` (see [#799](#7998).

Internal (special-characters): Used `InsertTextCommand` instead of deprecated `InputCommand` (see [#799](#7998).

Internal (table): Aligned the `TableSelection` plugin to the `beforeinput`-driven typing (see [#799](#7998).

Internal (widget): Aligned the `WidgetTypeAround` plugin to the `beforeinput`-driven typing (see [#799](#7998).

BREAKING CHANGE (engine): The [`MutationObserver`](https://ckeditor.com/docs/ckeditor5/latest/api/module_engine_view_observer_mutationobserver-MutationObserver.html) may no longer be [loaded by the editing view](https://ckeditor.com/docs/ckeditor5/latest/framework/guides/architecture/editing-engine.html#observers). In web browsers that support DOM Input Events, its responsibilities have been taken over by [`InputObserver`](https://ckeditor.com/docs/ckeditor5/latest/api/module_engine_view_observer_inputobserver-InputObserver.html).

BREAKING CHANGE (engine): The [`mutations`](https://ckeditor.com/docs/ckeditor5/latest/api/module_engine_view_document-Document.html#event-event:mutations) event is no longer fired by the view document in web browsers that support DOM Input Events. To react to low-level changes in the document, use the [`beforeinput`](https://ckeditor.com/docs/ckeditor5/latest/api/module_engine_view_document-Document.html#event-event:beforeinput) event instead, or better yet, take advantage of [`delete`](https://ckeditor.com/docs/ckeditor5/latest/api/module_engine_view_document-Document.html#event-event:delete) and [`insertText`](https://ckeditor.com/docs/ckeditor5/latest/api/module_engine_view_document-Document.html#event-event:insertText) events.

BREAKING CHANGE (typing): The [InputCommand](https://ckeditor.com/docs/ckeditor5/latest/api/module_typing_inputcommand-InputCommand.html) has been deprecated. Use the [`InsertTextCommand`](https://ckeditor.com/docs/ckeditor5/latest/api/module_typing_inserttextcommand-InsertTextCommand.html) instead (`editor.execute( 'insertText', options )`).

BREAKING CHANGE (typing): The [`@ckeditor/ckeditor5-typing/src/utils/injectunsafekeystrokeshandling`](https://ckeditor.com/docs/ckeditor5/latest/api/module_typing_utils_injectunsafekeystrokeshandling.html) module containing typing helpers (e.g. [`isNonTypingKeystroke()`](https://ckeditor.com/docs/ckeditor5/latest/api/module_typing_utils_injectunsafekeystrokeshandling.html#function-isNonTypingKeystroke)) is now available under `@ckeditor/ckeditor5-typing/src/utils/input/utils`. Please update import paths in your projects to avoid import errors.
@oleq
Copy link
Member Author

oleq commented Oct 8, 2020

Closed in #8176.

@oleq oleq closed this as completed Oct 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:dx This issue reports a developer experience problem or possible improvement. domain:ui/ux This issue reports a problem related to UI or UX. package:typing type:task This issue reports a chore (non-production change) and other types of "todos".
Projects
None yet
Development

No branches or pull requests

1 participant