Skip to content

Conversation

@javan
Copy link
Contributor

@javan javan commented Jan 4, 2019

This PR improves the way Trix records input—particularly on mobile—by adding support for Level 2 InputEvents, which are currently implemented in Safari and Chrome, and in their companion webview implementations on iOS and Android. In all other browsers, Trix will continue to work exactly as it does today. Here's how:

First, Trix tests for InputEvent support:

supportsInputEvents: do ->
typeof InputEvent isnt "undefined" and
"inputType" of InputEvent.prototype and
"data" of InputEvent.prototype

Then, when a <trix-editor> initializes, its editor controller installs one of two input controllers:

@inputController = new Trix["Level#{Trix.config.input.getLevel()}InputController"](@editorElement)
@inputController.delegate = this
@inputController.responder = @composition

  1. Trix.Level2InputController if input events are supported
  2. Trix.Level0InputController, which is equivalent to the current Trix.InputController, if input events are not supported

Fixes #575
Fixes #574
Fixes #520
Fixes #494
Fixes #396
Fixes #315
Fixes #178
Closes #564

javan added 30 commits November 15, 2018 13:55
The default behavior is rarely what we want: <b> instead of <strong>, <i> instead of <em>, etc.
We don't technically need to cancel them and support is varied between Level 1 and 2 so skip it altogether for clarity.
To support Composition's special cases for removing formatting, selecting attachments, etc. when the selection is collapsed.
@javan javan added the WIP label Jan 4, 2019
javan added 19 commits January 4, 2019 17:15
# Conflicts:
#	.blade.yml
Fixes reordering images in galleries, and generally ensures that attachments remain managed.
Fixes handling multiple deletions within a single animation frame.
…ing attachments

Looking at you, Safari. Setting *any* dataTransfer values fixes it.
Safari's beforeinput.insertFromPaste event doesn't include files in its dataTransfer, and, annoyingly, does include text/html with an unusable <img src="blob:http://…">. So, handle and cancel the paste event just for file pastes.
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.

2 participants