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

[WIP] Migrate to before̬̜input͎ #11456

Merged
merged 155 commits into from
Oct 13, 2022
Merged
Show file tree
Hide file tree
Changes from 151 commits
Commits
Show all changes
155 commits
Select commit Hold shift + click to select a range
2878a84
Improved InputObserver. Moved DataTransfer from clipboard to engine. …
oleq Mar 9, 2022
7b254e7
Updated import paths to DataTransfer in clipboard package.
oleq Mar 9, 2022
a9f2d33
Added beforeinput manual test.
oleq Mar 9, 2022
2f32c42
Migrated EnterObserver to beforeinput.
oleq Mar 9, 2022
3a44162
Migrated DeleteObserver to beforeinput.
oleq Mar 9, 2022
f211a0b
Migrated Delete plugin to beforeinput.
niegowski Mar 10, 2022
a4f707e
Updated docs for moved DataTransfer.
niegowski Mar 10, 2022
62c5fb3
Renamed InputCommand to InsertTextCommand.
niegowski Mar 10, 2022
8670724
The InsertTextCommand supports selection as an input option.
niegowski Mar 10, 2022
b9b8c4d
Migrated Input plugin to beforeinput.
niegowski Mar 10, 2022
d375334
Unified preventDefault() across delete, enter and insertText events (…
oleq Mar 11, 2022
e6f6dbc
Migrated block-quote to beforeinput.
oleq Mar 11, 2022
56f27b6
Code refactoring: flattened the input plugin tests structure.
oleq Mar 11, 2022
c223068
Docs.
oleq Mar 11, 2022
b9f02c4
Migrated link to beforeinput.
oleq Mar 11, 2022
e94ebeb
Migrated list to beforeinput.
oleq Mar 11, 2022
61be1c1
Migrated media embed to beforeinput.
oleq Mar 11, 2022
cbc055b
Migrated restricted-editing to beforeinput.
oleq Mar 11, 2022
7584079
Migrated special characters to beforeinput.
oleq Mar 11, 2022
e8a5541
Migrated tables to beforeinput.
oleq Mar 11, 2022
31aab04
Misc change in tables.
oleq Mar 11, 2022
beb78c9
Migrated misc typing tests to beforeinput.
oleq Mar 11, 2022
c1e1d2b
Migrated undo to beforeinput.
oleq Mar 11, 2022
064e3d8
Migrated Widget plugin tests to beforeinput.
oleq Mar 11, 2022
f345336
Updated tests for WTA.
niegowski Mar 11, 2022
d297a61
Updated tests for WTA.
niegowski Mar 11, 2022
b7eeada
Added test.
niegowski Mar 11, 2022
10ba908
Removed Shift+Delete handling on Windows from DeleteObserver. Handled…
oleq Mar 14, 2022
0d0c7c8
Cleaning delete event logic.
niegowski Mar 14, 2022
c584939
Code cleaning.
niegowski Mar 14, 2022
ed272ab
Added option to disable DeleteObserver.
niegowski Mar 14, 2022
edbf125
TODO pruning.
oleq Mar 14, 2022
7d7a7e7
Merge branch 'master' into ck/epic/11438-migrate-to-beforeinput
oleq Mar 15, 2022
422f5ae
Enabled inspector in beforeinput manual test.
oleq Mar 15, 2022
f107868
WIP.
oleq Mar 15, 2022
1a85154
Merged master. Resolved conflicts.
oleq Apr 11, 2022
f687650
Tests: Added contenteditable demo to the beforeinput manual test.
oleq Apr 11, 2022
7a21d57
Fixed wrong license headers.
oleq Apr 11, 2022
6ed368f
Tests: Enhanced manual test.
oleq Apr 11, 2022
b864a23
Tests: Enhanced manual test.
oleq Apr 11, 2022
fdfcd26
Merge branch 'ck/epic/11438-migrate-to-beforeinput' into ck/11438-bef…
oleq Apr 12, 2022
e9da12d
Tests: Enhanced manual test.
oleq Apr 12, 2022
7f1b18a
Merge branch 'ck/epic/11438-migrate-to-beforeinput' into ck/11438-bef…
oleq Apr 12, 2022
1c6cf6d
Trying to split composition handling.
niegowski Apr 15, 2022
bae3d20
Merge branch 'master' into ck/epic/11438-migrate-to-beforeinput
oleq Apr 15, 2022
89528a4
Merge branch 'ck/epic/11438-migrate-to-beforeinput' into ck/11438-bef…
oleq Apr 15, 2022
e15b2d4
Added PoC of fake caret support.
niegowski Apr 19, 2022
ba21f4b
Hide widget toolbars during composition so they do not break when the…
oleq Apr 20, 2022
975bfa4
Fixing DOM selection after composition abort.
niegowski Apr 21, 2022
9c2c32f
Addressed desync between view and DOM in the renderer on compositione…
oleq Apr 21, 2022
f360f76
Reverted insertText command isEnabled flag changes.
niegowski Apr 25, 2022
3714243
Fixed superfluous markToSync for UI and RAW element children.
niegowski Apr 25, 2022
2b6be89
Addressed error thrown when WidgetToolbarRepository is not loaded.
oleq Apr 26, 2022
f6b51c6
Merge branch 'master' into ck/epic/11438-migrate-to-beforeinput
oleq May 9, 2022
3ff4d4d
Merge branch 'ck/epic/11438-migrate-to-beforeinput' into ck/11438-bef…
oleq May 9, 2022
38382ca
Merge branch 'ck/11438-beforeinput-ime-research-vol1' into ck/11438-b…
oleq May 9, 2022
c0e2a2e
Restored MutationObserver.
oleq May 10, 2022
fa13181
Merge branch 'master' into ck/epic/11438-migrate-to-beforeinput
niegowski Jun 8, 2022
9f73cd6
Merge branch 'ck/epic/11438-migrate-to-beforeinput' into ck/11438-bef…
niegowski Jun 8, 2022
a52fc6e
Merge branch 'ck/11438-beforeinput-ime-research-vol1' into ck/11438-b…
niegowski Jun 8, 2022
a3eb855
Ported a manual test for a raw contenteditable from the Android branch.
Reinmar Jun 13, 2022
f0b0f9f
Revival of the MutationObserver in the basic form.
niegowski May 10, 2022
cae5ea7
Ditched compositionstart/end in favor of isComposing property.
niegowski May 10, 2022
5ebb08d
Applied generic changes from android research branch. Logging hidden …
niegowski Jun 14, 2022
5a9ae0f
Added logging of DataTransfer content.
niegowski Jun 21, 2022
bda7c88
Fixed DataTransfer logging.
niegowski Jun 21, 2022
9b07d25
Based on our research, keydown on Safari is fired after compositionst…
Reinmar Jun 22, 2022
2d44da4
Minor refactor: Moved the logic related to typing to the Input plugin.
Reinmar Jun 22, 2022
92490ab
The compositionend event to the insertText event translation moved to…
niegowski Jun 22, 2022
8fb4cb8
Merge branch 'master' into ck/epic/11438-migrate-to-beforeinput
oleq Jun 23, 2022
9be6372
Simplified target position of composed text.
niegowski Jun 24, 2022
0e5d651
Introduced CK_DEBUG_TYPING in place of a window property for logging.
niegowski Jun 24, 2022
aacca1f
More verbose typing flow logging.
niegowski Jun 29, 2022
9fba995
Merge branch 'master' into ck/epic/11438-migrate-to-beforeinput
niegowski Jul 1, 2022
fa87543
Merge branch 'ck/epic/11438-migrate-to-beforeinput' into ck/11438-bef…
niegowski Jul 1, 2022
2757f14
Added note about a debug flag in the manual test.
niegowski Jul 1, 2022
9232741
Cleaned up the test description.
Reinmar Jul 1, 2022
4c557fc
Adding tests.
niegowski Jul 4, 2022
45c2ec1
Cleaning of the new MutationObserver and added tests for new role.
niegowski Jul 5, 2022
d39f9c1
Added tests for InsertTextObserver. Fixed the isEnabled flag handling…
niegowski Jul 6, 2022
7ae0c7a
Added tests for input plugin composition start handling.
niegowski Jul 6, 2022
2a2e724
Added tests for WTA. Fixed the isEnabled flag handling of WTA.
niegowski Jul 6, 2022
18c8d63
Fixed keydown handling on links.
niegowski Jul 11, 2022
34c4db1
Prototyping a TypingSimulator.
niegowski Jul 11, 2022
908cdee
PoC of TypingSimulator.
niegowski Jul 12, 2022
7231e1c
Removed TypingSimulator.
niegowski Jul 13, 2022
fd3bea4
Fixed failing tests (invalid event mock).
niegowski Jul 13, 2022
e4bb6ac
Corrected MutationObserve's documentation.
Reinmar Jul 18, 2022
afaeca6
Minor wording corrections.
Reinmar Jul 18, 2022
bad982b
Removed not needed code.
niegowski Jul 19, 2022
56f4f41
Trying to workaround composition on Android.
niegowski Jul 28, 2022
4ffd85b
Merge remote-tracking branch 'origin/master' into ck/epic/11438-migra…
arkflpc Jul 29, 2022
3035122
Merge pull request #12024 from ckeditor/ck/11438-beforeinput-ime-rese…
Reinmar Aug 1, 2022
6ed2dd9
Merge commit 'f2e7b491e919353c48999aa3afa2d0b7e861bb90' into ck/epic/…
niegowski Aug 8, 2022
7b55c64
Merge branch 'master' into ck/epic/11438-migrate-to-beforeinput
niegowski Aug 8, 2022
1fccb60
Fix after merge.
niegowski Aug 8, 2022
e16d9c8
Merge commit '6ed2dd9a65d736a7bf1c9e4b56b8352464e0344c' into ck/11438…
niegowski Aug 8, 2022
8000f16
Merge branch 'ck/epic/11438-migrate-to-beforeinput' into ck/11438-bef…
niegowski Aug 8, 2022
9a02e6c
Fix after merge.
niegowski Aug 8, 2022
71a38bf
Experimenting with IME on Android.
niegowski Aug 9, 2022
fa216e5
Experimenting with not re-rendering while composing on Android until …
niegowski Aug 11, 2022
16e66a0
Updating text nodes instead of replacing them while renderer is updat…
niegowski Aug 17, 2022
bc2c5b9
Trying to postpone text update while composing.
niegowski Aug 17, 2022
1857833
Replacing text node content instead of replacing the whole node.
niegowski Aug 18, 2022
4d6a6ce
Removed unnecessary forceRender call. It's triggered by the MutationO…
niegowski Aug 18, 2022
a562f4b
WiP.
niegowski Aug 19, 2022
0f9abfa
WiP.
niegowski Aug 19, 2022
cd9c409
WiP.
niegowski Aug 19, 2022
2fb1daf
Disabled inline filler on Android after/before an inline element. The…
niegowski Aug 19, 2022
3f2a8b0
Added more logs.
niegowski Aug 19, 2022
0d6f7b8
Merge branch 'master' into ck/epic/11438-migrate-to-beforeinput
niegowski Sep 7, 2022
9a280d5
Merge branch 'ck/epic/11438-migrate-to-beforeinput' into ck/11438-bef…
niegowski Sep 7, 2022
f8131b3
Trimming text composed on Android to cover only inserted/removed data.
niegowski Sep 7, 2022
17162e1
Attempt to solve issue with insertCompositionText with newline charac…
niegowski Sep 7, 2022
1f74b50
The model delete content should not be triggered on composition start…
niegowski Sep 7, 2022
9044dea
Experiments with composition in the fake selection container on Andro…
niegowski Sep 9, 2022
9ede412
Renderer should not leave DOM partly updated.
niegowski Sep 13, 2022
0b00bc6
Fixing delete content on backspace on Android.
niegowski Sep 14, 2022
99bd926
Using input buffer while deleting non collapsed selection on composit…
niegowski Sep 15, 2022
f49a719
Removed old selection fixing on Android after delete.
niegowski Sep 15, 2022
a699fd9
Fixed non collapsed delete handling on Android.
niegowski Sep 15, 2022
6e1670b
Added more logging.
niegowski Sep 16, 2022
b9c4008
Fix (input). Fixes deleting all content in Chrome. Closes 11904.
arkflpc Sep 15, 2022
2812692
Delete in Chrome workaround: don't stop the keyup event
arkflpc Sep 19, 2022
b630ccb
Add TODO about Chromium bug
arkflpc Sep 19, 2022
f521ff3
Merge pull request #12474 from ckeditor/ck/11904
niegowski Sep 19, 2022
a359c7a
Merge branch 'master' into ck/epic/11438-migrate-to-beforeinput
niegowski Sep 19, 2022
fc99ff1
Merge branch 'ck/epic/11438-migrate-to-beforeinput' into ck/11438-bef…
niegowski Sep 19, 2022
54f7bfb
Fixed test after merge.
niegowski Sep 19, 2022
9dc8b51
Merge branch 'ck/epic/11438-migrate-to-beforeinput' into ck/11438-bef…
niegowski Sep 19, 2022
d7d14c6
Added tests.
niegowski Sep 19, 2022
8b883e2
Adding tests.
niegowski Sep 20, 2022
e303ae2
Adding tests.
niegowski Sep 21, 2022
13b8d0e
Added tests.
niegowski Sep 22, 2022
96ca498
Review fixes.
niegowski Sep 28, 2022
2b9e30f
Updated code comments.
niegowski Sep 30, 2022
3a40ca2
Merge branch 'master' into ck/epic/11438-migrate-to-beforeinput
niegowski Oct 6, 2022
9292593
Merge branch 'ck/epic/11438-migrate-to-beforeinput' into ck/11438-bef…
niegowski Oct 6, 2022
595a7dd
Fixed selection updating after fake selection.
niegowski Oct 10, 2022
39c65f7
Normalizing DOM children if there are text nodes next to one another.
niegowski Oct 10, 2022
09b29c3
Removed console.log().
niegowski Oct 11, 2022
1f3c8d0
Added test for 100cc.
niegowski Oct 11, 2022
79018da
Merge branch 'master' into ck/epic/11438-migrate-to-beforeinput
niegowski Oct 11, 2022
fd695a3
Merge branch 'ck/epic/11438-migrate-to-beforeinput' into ck/11438-bef…
niegowski Oct 11, 2022
17c7c49
Fixed domPositionToView() for cases when position is between inline f…
niegowski Oct 11, 2022
2494349
Placeholder should be hidden while composing.
niegowski Oct 11, 2022
eb7f60d
Merge pull request #12446 from ckeditor/ck/11438-beforeinput-ime-rese…
niegowski Oct 12, 2022
f8d4f32
Added tests.
niegowski Oct 12, 2022
0d5fcf7
Merge branch 'master' into ck/epic/11438-migrate-to-beforeinput
niegowski Oct 12, 2022
885dc2e
Merge pull request #12639 from ckeditor/ck/12389
arkflpc Oct 13, 2022
a3e6a57
Merge branch 'master' into ck/epic/11438-migrate-to-beforeinput
niegowski Oct 13, 2022
5fe4283
Change array style
arkflpc Oct 13, 2022
65c1dc9
After review.
niegowski Oct 13, 2022
044070d
Merge remote-tracking branch 'origin/ck/epic/11438-migrate-to-beforei…
niegowski Oct 13, 2022
2c08378
Merge branch 'master' into ck/epic/11438-migrate-to-beforeinput
niegowski Oct 13, 2022
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
9 changes: 5 additions & 4 deletions packages/ckeditor5-block-quote/tests/integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ describe( 'BlockQuote integration', () => {
return {
preventDefault: sinon.spy(),
direction: 'backward',
inputType: 'deleteContentBackward',
unit: 'character'
};
}
Expand Down Expand Up @@ -364,7 +365,7 @@ describe( 'BlockQuote integration', () => {

viewDocument.fire( 'delete', data );

// Only enter command should be executed.
// Only delete command should be executed.
expect( data.preventDefault.called ).to.be.true;
expect( execSpy.calledOnce ).to.be.true;
expect( execSpy.args[ 0 ][ 0 ] ).to.equal( 'delete' );
Expand All @@ -378,7 +379,7 @@ describe( 'BlockQuote integration', () => {

viewDocument.fire( 'delete', data );

// Only enter command should be executed.
// Only delete command should be executed.
expect( data.preventDefault.called ).to.be.true;
expect( execSpy.calledOnce ).to.be.true;
expect( execSpy.args[ 0 ][ 0 ] ).to.equal( 'delete' );
Expand All @@ -392,7 +393,7 @@ describe( 'BlockQuote integration', () => {

viewDocument.fire( 'delete', data );

// Only enter command should be executed.
// Only delete command should be executed.
expect( data.preventDefault.called ).to.be.true;
expect( execSpy.calledOnce ).to.be.true;
expect( execSpy.args[ 0 ][ 0 ] ).to.equal( 'delete' );
Expand All @@ -406,7 +407,7 @@ describe( 'BlockQuote integration', () => {

viewDocument.fire( 'delete', data );

// Only enter command should be executed.
// Only delete command should be executed.
expect( data.preventDefault.called ).to.be.true;
expect( execSpy.calledOnce ).to.be.true;
expect( execSpy.args[ 0 ][ 0 ] ).to.equal( 'delete' );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ When the user pastes or drops content into the editor, the browser fires an even

1. {@link module:clipboard/clipboardobserver~ClipboardObserver} turns this event into a synthetic {@link module:engine/view/document~Document#event:paste `view.Document#paste`} or {@link module:engine/view/document~Document#event:drop `view.Document#drop`}.
1. Since the content to be inserted by both actions (paste and drop) should usually be processed in the same way and both actions have a very similar effect, both events are turned into a single {@link module:engine/view/document~Document#event:clipboardInput `view.Document#clipboardInput`} event for easier handling.
1. Next, the clipboard feature listens to the `view.Document#clipboardInput` event, retrieves and pre-processes the `text/html` or `text/plain` content which it finds in the {@link module:clipboard/datatransfer~DataTransfer event's `dataTransfer`} and fires the {@link module:clipboard/clipboardpipeline~ClipboardPipeline#event:inputTransformation `ClipboardPipeline#inputTransformation`} event with the retrieved content in the event data `content` property as a {@link module:engine/view/documentfragment~DocumentFragment `view.DocumentFragment`}.
1. Next, the clipboard feature listens to the `view.Document#clipboardInput` event, retrieves and pre-processes the `text/html` or `text/plain` content which it finds in the {@link module:engine/view/datatransfer~DataTransfer event's `dataTransfer`} and fires the {@link module:clipboard/clipboardpipeline~ClipboardPipeline#event:inputTransformation `ClipboardPipeline#inputTransformation`} event with the retrieved content in the event data `content` property as a {@link module:engine/view/documentfragment~DocumentFragment `view.DocumentFragment`}.
1. Then, the clipboard feature listens to the `ClipboardPipeline#inputTransformation` event, takes the processed content, transforms it to the {@link module:engine/model/documentfragment~DocumentFragment `model.DocumentFragment`} and fires the {@link module:clipboard/clipboardpipeline~ClipboardPipeline#event:contentInsertion `ClipboardPipeline#contentInsertion`} event with the transformed content in the event data `content` property as a {@link module:engine/model/documentfragment~DocumentFragment `model.DocumentFragment`}.
1. Finally, the clipboard feature listens to the `ClipboardPipeline#contentInsertion` event, takes the model fragment, {@link module:engine/model/model~Model#insertContent inserts} it into the editor and stores the range which contains all the performed changes in the `resultRange` property of the event data.

Expand Down Expand Up @@ -60,7 +60,7 @@ The {@link module:engine/view/document~Document#event:clipboardInput `view.Docum

* Handle pasted or dropped files (that you can retrieve from the `dataTransfer`).

Handling file upload requires, however, a lot more than reading {@link module:clipboard/datatransfer~DataTransfer#files `dataTransfer.files`} so for a complete code example, check the source code of plugins like [`ImageUploadEditing`](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-image/src/imageupload/imageuploadediting.js).
Handling file upload requires, however, a lot more than reading {@link module:engine/view/datatransfer~DataTransfer#files `dataTransfer.files`} so for a complete code example, check the source code of plugins like [`ImageUploadEditing`](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-image/src/imageupload/imageuploadediting.js).
* Change the type of data that the clipboard feature reads from the clipboard. For instance, you may want to use `application/rtf` if it is present in the `dataTransfer` (and ignore `text/html` in that case).

```js
Expand Down
8 changes: 4 additions & 4 deletions packages/ckeditor5-clipboard/src/clipboardobserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import DomEventObserver from '@ckeditor/ckeditor5-engine/src/view/observer/domeventobserver';
import EventInfo from '@ckeditor/ckeditor5-utils/src/eventinfo';
import DataTransfer from './datatransfer';
import DataTransfer from '@ckeditor/ckeditor5-engine/src/view/datatransfer';

/**
* Clipboard events observer.
Expand Down Expand Up @@ -125,7 +125,7 @@ function getDropViewRange( view, domEvent ) {
* @see module:clipboard/clipboard~Clipboard
* @event module:engine/view/document~Document#event:clipboardInput
* @param {Object} data The event data.
* @param {module:clipboard/datatransfer~DataTransfer} data.dataTransfer The data transfer instance.
* @param {module:engine/view/datatransfer~DataTransfer} data.dataTransfer Data transfer instance.
* @param {'paste'|'drop'} method Whether the event was triggered by a paste or drop operation.
* @param {module:engine/view/element~Element} target The tree view element representing the target.
* @param {Array.<module:engine/view/range~Range>} data.targetRanges Ranges which are the target of the operation
Expand Down Expand Up @@ -224,7 +224,7 @@ function getDropViewRange( view, domEvent ) {
* The data transfer instance.
*
* @readonly
* @member {module:clipboard/datatransfer~DataTransfer} module:clipboard/clipboardobserver~ClipboardEventData#dataTransfer
* @member {module:engine/view/datatransfer~DataTransfer} module:clipboard/clipboardobserver~ClipboardEventData#dataTransfer
*/

/**
Expand All @@ -244,7 +244,7 @@ function getDropViewRange( view, domEvent ) {
* @see module:clipboard/clipboard~Clipboard
* @event module:engine/view/document~Document#event:dragging
* @param {Object} data The event data.
* @param {module:clipboard/datatransfer~DataTransfer} data.dataTransfer The data transfer instance.
* @param {module:engine/view/datatransfer~DataTransfer} data.dataTransfer The data transfer instance.
* @param {module:engine/view/element~Element} target The tree view element representing the target.
* @param {Array.<module:engine/view/range~Range>} data.targetRanges Ranges which are the target of the operation
* (usually – into which the content should be inserted).
Expand Down
6 changes: 3 additions & 3 deletions packages/ckeditor5-clipboard/src/clipboardpipeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ export default class ClipboardPipeline extends Plugin {
* @param {module:engine/view/documentfragment~DocumentFragment} data.content The event data. The content to be inserted into the editor.
* It can be modified by event listeners. Read more about the clipboard pipelines in
* the {@glink framework/guides/deep-dive/clipboard clipboard deep dive guide}.
* @param {module:clipboard/datatransfer~DataTransfer} data.dataTransfer The data transfer instance.
* @param {module:engine/view/datatransfer~DataTransfer} data.dataTransfer The data transfer instance.
* @param {'paste'|'drop'} data.method Whether the event was triggered by a paste or drop operation.
* @param {Array.<module:engine/view/range~Range>} data.targetRanges The target drop ranges.
*/
Expand All @@ -318,7 +318,7 @@ export default class ClipboardPipeline extends Plugin {
* @param {Object} data The event data.
* @param {module:engine/model/documentfragment~DocumentFragment} data.content The event data. The content to be inserted into the editor.
* Read more about the clipboard pipelines in the {@glink framework/guides/deep-dive/clipboard clipboard deep dive guide}.
* @param {module:clipboard/datatransfer~DataTransfer} data.dataTransfer The data transfer instance.
* @param {module:engine/view/datatransfer~DataTransfer} data.dataTransfer The data transfer instance.
* @param {'paste'|'drop'} data.method Whether the event was triggered by a paste or drop operation.
* @param {Array.<module:engine/view/range~Range>} data.targetRanges The target drop ranges.
* @param {module:engine/model/range~Range} data.resultRange The result of the `model.insertContent()` call
Expand Down Expand Up @@ -347,7 +347,7 @@ export default class ClipboardPipeline extends Plugin {
* The data transfer instance.
*
* @readonly
* @member {module:clipboard/datatransfer~DataTransfer} module:clipboard/clipboardpipeline~ClipboardOutputEventData#dataTransfer
* @member {module:engine/view/datatransfer~DataTransfer} module:clipboard/clipboardpipeline~ClipboardOutputEventData#dataTransfer
*/

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/ckeditor5-clipboard/tests/clipboardobserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
/* globals document */

import ClipboardObserver from '../src/clipboardobserver';
import DataTransfer from '../src/datatransfer';

import View from '@ckeditor/ckeditor5-engine/src/view/view';
import DataTransfer from '@ckeditor/ckeditor5-engine/src/view/datatransfer';
import DowncastWriter from '@ckeditor/ckeditor5-engine/src/view/downcastwriter';
import createViewRoot from '@ckeditor/ckeditor5-engine/tests/view/_utils/createroot';

Expand Down
2 changes: 1 addition & 1 deletion packages/ckeditor5-clipboard/tests/clipboardpipeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import ClipboardPipeline from '../src/clipboardpipeline';
import ClipboardObserver from '../src/clipboardobserver';
import DataTransfer from '../src/datatransfer';
import DataTransfer from '@ckeditor/ckeditor5-engine/src/view/datatransfer';

import VirtualTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/virtualtesteditor';
import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,20 @@
*/

/**
* @module clipboard/datatransfer
* @module engine/view/datatransfer
*/

type DomDataTransfer = globalThis.DataTransfer;

/**
* A facade over the native [`DataTransfer`](https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer) object.
*/
export default class DataTransfer {
constructor( nativeDataTransfer ) {
public readonly files: File[];
niegowski marked this conversation as resolved.
Show resolved Hide resolved

private _native: DomDataTransfer;

constructor( nativeDataTransfer: DomDataTransfer ) {
/**
* The array of files created from the native `DataTransfer#files` or `DataTransfer#items`.
*
Expand All @@ -34,7 +40,7 @@ export default class DataTransfer {
*
* @returns {Array.<String>}
*/
get types() {
public get types(): readonly string[] {
return this._native.types;
}

Expand All @@ -46,7 +52,7 @@ export default class DataTransfer {
* @param {String} type The MIME type. E.g. `text/html` or `text/plain`.
* @returns {String}
*/
getData( type ) {
public getData( type: string ): string {
return this._native.getData( type );
}

Expand All @@ -56,7 +62,7 @@ export default class DataTransfer {
* @param {String} type The MIME type. E.g. `text/html` or `text/plain`.
* @param {String} data
*/
setData( type, data ) {
public setData( type: string, data: string ): void {
this._native.setData( type, data );
}

Expand All @@ -65,11 +71,11 @@ export default class DataTransfer {
*
* @param {String} value
*/
set effectAllowed( value ) {
public set effectAllowed( value: DomDataTransfer[ 'effectAllowed' ] ) {
this._native.effectAllowed = value;
}

get effectAllowed() {
public get effectAllowed(): DomDataTransfer[ 'effectAllowed' ] {
return this._native.effectAllowed;
}

Expand All @@ -78,11 +84,11 @@ export default class DataTransfer {
*
* @param {String} value
*/
set dropEffect( value ) {
public set dropEffect( value: DomDataTransfer[ 'dropEffect' ] ) {
this._native.dropEffect = value;
}

get dropEffect() {
public get dropEffect(): DomDataTransfer[ 'dropEffect' ] {
return this._native.dropEffect;
}

Expand All @@ -91,12 +97,12 @@ export default class DataTransfer {
*
* @returns {Boolean}
*/
get isCanceled() {
return this._native.dropEffect == 'none' || !!this._native.mozUserCancelled;
public get isCanceled(): boolean {
return this._native.dropEffect == 'none' || !!( this._native as any ).mozUserCancelled;
}
}

function getFiles( nativeDataTransfer ) {
function getFiles( nativeDataTransfer: DomDataTransfer ): File[] {
// DataTransfer.files and items are array-like and might not have an iterable interface.
const files = Array.from( nativeDataTransfer.files || [] );
const items = Array.from( nativeDataTransfer.items || [] );
Expand All @@ -108,5 +114,5 @@ function getFiles( nativeDataTransfer ) {
// Chrome has empty DataTransfer.files, but allows getting files through the items interface.
return items
.filter( item => item.kind === 'file' )
.map( item => item.getAsFile() );
.map( item => item.getAsFile()! );
}
5 changes: 5 additions & 0 deletions packages/ckeditor5-engine/src/view/domconverter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -908,6 +908,11 @@ export default class DomConverter {
}
} else {
const domBefore = domParent.childNodes[ domOffset - 1 ];

if ( isText( domBefore ) && isInlineFiller( domBefore ) ) {
return this.domPositionToView( domBefore.parentNode!, indexOf( domBefore ) );
}

const viewBefore = isText( domBefore ) ?
this.findCorrespondingViewText( domBefore ) :
this.mapDomToView( domBefore as DomElement );
Expand Down
29 changes: 26 additions & 3 deletions packages/ckeditor5-engine/src/view/observer/compositionobserver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,42 @@ export default class CompositionObserver extends DomEventObserver<'compositionst
super( view );

this.domEventType = [ 'compositionstart', 'compositionupdate', 'compositionend' ];

const document = this.document;

document.on<CompositionObserverEvent>( 'compositionstart', () => {
// @if CK_DEBUG_TYPING // if ( window.logCKETyping ) {
// @if CK_DEBUG_TYPING // console.log( '%c[CompositionObserver] ' +
// @if CK_DEBUG_TYPING // '┌───────────────────────────── isComposing = true ─────────────────────────────┐',
// @if CK_DEBUG_TYPING // 'font-weight: bold; color: green'
// @if CK_DEBUG_TYPING // );
// @if CK_DEBUG_TYPING // }
document.isComposing = true;
} );
}, { priority: 'low' } );

document.on<CompositionObserverEvent>( 'compositionend', () => {
// @if CK_DEBUG_TYPING // if ( window.logCKETyping ) {
// @if CK_DEBUG_TYPING // console.log( '%c[CompositionObserver] ' +
// @if CK_DEBUG_TYPING // '└───────────────────────────── isComposing = false ─────────────────────────────┘',
// @if CK_DEBUG_TYPING // 'font-weight: bold; color: green'
// @if CK_DEBUG_TYPING // );
// @if CK_DEBUG_TYPING // }
document.isComposing = false;
} );
}, { priority: 'low' } );
}

public onDomEvent( domEvent: CompositionEvent ): void {
this.fire( domEvent.type, domEvent );
// @if CK_DEBUG_TYPING // if ( window.logCKETyping ) {
// @if CK_DEBUG_TYPING // console.group( `%c[CompositionObserver]%c ${ domEvent.type }`, 'color: green', '' );
// @if CK_DEBUG_TYPING // }

this.fire( domEvent.type, domEvent, {
data: domEvent.data
} );

// @if CK_DEBUG_TYPING // if ( window.logCKETyping ) {
// @if CK_DEBUG_TYPING // console.groupEnd();
// @if CK_DEBUG_TYPING // }
}
}

Expand Down
Loading