Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add InputEvent
  • Loading branch information
armanbilge committed Apr 16, 2022
commit aba6ff84b7a8e5ccb564d48b5817f97984b1252e
55 changes: 55 additions & 0 deletions dom/src/main/scala-2/org/scalajs/dom/InputType.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package org.scalajs.dom

import scala.scalajs.js

@js.native
sealed trait InputType extends js.Any

object InputType {
val insertText: InputType = "insertText".asInstanceOf[InputType]
val insertReplacementText: InputType = "insertReplacementText".asInstanceOf[InputType]
val insertLineBreak: InputType = "insertLineBreak".asInstanceOf[InputType]
val insertParagraph: InputType = "insertParagraph".asInstanceOf[InputType]
val insertOrderedList: InputType = "insertOrderedList".asInstanceOf[InputType]
val insertUnorderedList: InputType = "insertUnorderedList".asInstanceOf[InputType]
val insertHorizontalRule: InputType = "insertHorizontalRule".asInstanceOf[InputType]
val insertFromYank: InputType = "insertFromYank".asInstanceOf[InputType]
val insertFromDrop: InputType = "insertFromDrop".asInstanceOf[InputType]
val insertFromPaste: InputType = "insertFromPaste".asInstanceOf[InputType]
val insertFromPasteAsQuotation: InputType = "insertFromPasteAsQuotation".asInstanceOf[InputType]
val insertTranspose: InputType = "insertTranspose".asInstanceOf[InputType]
val insertCompositionText: InputType = "insertCompositionText".asInstanceOf[InputType]
val insertLink: InputType = "insertLink".asInstanceOf[InputType]
val deleteWordBackward: InputType = "deleteWordBackward".asInstanceOf[InputType]
val deleteWordForward: InputType = "deleteWordForward".asInstanceOf[InputType]
val deleteSoftLineBackward: InputType = "deleteSoftLineBackward".asInstanceOf[InputType]
val deleteSoftLineForward: InputType = "deleteSoftLineForward".asInstanceOf[InputType]
val deleteEntireSoftLine: InputType = "deleteEntireSoftLine".asInstanceOf[InputType]
val deleteHardLineBackward: InputType = "deleteHardLineBackward".asInstanceOf[InputType]
val deleteHardLineForward: InputType = "deleteHardLineForward".asInstanceOf[InputType]
val deleteByDrag: InputType = "deleteByDrag".asInstanceOf[InputType]
val deleteByCut: InputType = "deleteByCut".asInstanceOf[InputType]
val deleteContent: InputType = "deleteContent".asInstanceOf[InputType]
val deleteContentBackward: InputType = "deleteContentBackward".asInstanceOf[InputType]
val deleteContentForward: InputType = "deleteContentForward".asInstanceOf[InputType]
val historyUndo: InputType = "historyUndo".asInstanceOf[InputType]
val historyRedo: InputType = "historyRedo".asInstanceOf[InputType]
val formatBold: InputType = "formatBold".asInstanceOf[InputType]
val formatItalic: InputType = "formatItalic".asInstanceOf[InputType]
val formatUnderline: InputType = "formatUnderline".asInstanceOf[InputType]
val formatStrikeThrough: InputType = "formatStrikeThrough".asInstanceOf[InputType]
val formatSuperscript: InputType = "formatSuperscript".asInstanceOf[InputType]
val formatSubscript: InputType = "formatSubscript".asInstanceOf[InputType]
val formatJustifyFull: InputType = "formatJustifyFull".asInstanceOf[InputType]
val formatJustifyCenter: InputType = "formatJustifyCenter".asInstanceOf[InputType]
val formatJustifyRight: InputType = "formatJustifyRight".asInstanceOf[InputType]
val formatJustifyLeft: InputType = "formatJustifyLeft".asInstanceOf[InputType]
val formatIndent: InputType = "formatIndent".asInstanceOf[InputType]
val formatOutdent: InputType = "formatOutdent".asInstanceOf[InputType]
val formatRemove: InputType = "formatRemove".asInstanceOf[InputType]
val formatSetBlockTextDirection: InputType = "formatSetBlockTextDirection".asInstanceOf[InputType]
val formatSetInlineTextDirection: InputType = "formatSetInlineTextDirection".asInstanceOf[InputType]
val formatBackColor: InputType = "formatBackColor".asInstanceOf[InputType]
val formatFontColor: InputType = "formatFontColor".asInstanceOf[InputType]
val formatFontName: InputType = "formatFontName".asInstanceOf[InputType]
}
54 changes: 54 additions & 0 deletions dom/src/main/scala-3/org/scalajs/dom/InputType.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package org.scalajs.dom

import scala.scalajs.js

opaque type InputType <: String = String

object InputType {
val insertText: InputType = "insertText"
val insertReplacementText: InputType = "insertReplacementText"
val insertLineBreak: InputType = "insertLineBreak"
val insertParagraph: InputType = "insertParagraph"
val insertOrderedList: InputType = "insertOrderedList"
val insertUnorderedList: InputType = "insertUnorderedList"
val insertHorizontalRule: InputType = "insertHorizontalRule"
val insertFromYank: InputType = "insertFromYank"
val insertFromDrop: InputType = "insertFromDrop"
val insertFromPaste: InputType = "insertFromPaste"
val insertFromPasteAsQuotation: InputType = "insertFromPasteAsQuotation"
val insertTranspose: InputType = "insertTranspose"
val insertCompositionText: InputType = "insertCompositionText"
val insertLink: InputType = "insertLink"
val deleteWordBackward: InputType = "deleteWordBackward"
val deleteWordForward: InputType = "deleteWordForward"
val deleteSoftLineBackward: InputType = "deleteSoftLineBackward"
val deleteSoftLineForward: InputType = "deleteSoftLineForward"
val deleteEntireSoftLine: InputType = "deleteEntireSoftLine"
val deleteHardLineBackward: InputType = "deleteHardLineBackward"
val deleteHardLineForward: InputType = "deleteHardLineForward"
val deleteByDrag: InputType = "deleteByDrag"
val deleteByCut: InputType = "deleteByCut"
val deleteContent: InputType = "deleteContent"
val deleteContentBackward: InputType = "deleteContentBackward"
val deleteContentForward: InputType = "deleteContentForward"
val historyUndo: InputType = "historyUndo"
val historyRedo: InputType = "historyRedo"
val formatBold: InputType = "formatBold"
val formatItalic: InputType = "formatItalic"
val formatUnderline: InputType = "formatUnderline"
val formatStrikeThrough: InputType = "formatStrikeThrough"
val formatSuperscript: InputType = "formatSuperscript"
val formatSubscript: InputType = "formatSubscript"
val formatJustifyFull: InputType = "formatJustifyFull"
val formatJustifyCenter: InputType = "formatJustifyCenter"
val formatJustifyRight: InputType = "formatJustifyRight"
val formatJustifyLeft: InputType = "formatJustifyLeft"
val formatIndent: InputType = "formatIndent"
val formatOutdent: InputType = "formatOutdent"
val formatRemove: InputType = "formatRemove"
val formatSetBlockTextDirection: InputType = "formatSetBlockTextDirection"
val formatSetInlineTextDirection: InputType = "formatSetInlineTextDirection"
val formatBackColor: InputType = "formatBackColor"
val formatFontColor: InputType = "formatFontColor"
val formatFontName: InputType = "formatFontName"
}
41 changes: 41 additions & 0 deletions dom/src/main/scala/org/scalajs/dom/InputEvent.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/** All documentation for facades is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API
* and available under the Creative Commons Attribution-ShareAlike v2.5 or later.
* http://creativecommons.org/licenses/by-sa/2.5/
*
* Everything else is under the MIT License http://opensource.org/licenses/MIT
*/
package org.scalajs.dom

import scala.scalajs.js
import scala.scalajs.js.annotation._

/** The InputEvent interface represents an event notifying the user of editable content changes. */
@js.native
@JSGlobal
class InputEvent(typeArg: String, init: InputEventInit) extends UIEvent(typeArg, init) {

def this(typeArg: String) = this(typeArg, js.native)

/** Returns a DOMString with the inserted characters. This may be an empty string if the change doesn't insert text
* (such as when deleting characters, for example).
*/
def data: String = js.native

/** Returns a DataTransfer object containing information about richtext or plaintext data being added to or removed
* from editable content.
*/
def dataTransfer: DataTransfer = js.native

/** Returns the type of change for editable content such as, for example, inserting, deleting, or formatting text. See
* the property page for a complete list of input types.
*/
def inputType: InputType = js.native

/** Returns a Boolean value indicating if the event is fired after compositionstart and before compositionend. */
def isComposing: Boolean = js.native

/** Returns an array of static ranges that will be affected by a change to the DOM if the input event is not canceled.
*/
def getTargetRanges(): js.Array[StaticRange] = js.native

}
17 changes: 17 additions & 0 deletions dom/src/main/scala/org/scalajs/dom/InputEventInit.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/** All documentation for facades is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API
* and available under the Creative Commons Attribution-ShareAlike v2.5 or later.
* http://creativecommons.org/licenses/by-sa/2.5/
*
* Everything else is under the MIT License http://opensource.org/licenses/MIT
*/
package org.scalajs.dom

import scala.scalajs.js

trait InputEventInit extends UIEventInit {
var inputType: js.UndefOr[InputType] = js.undefined
var data: js.UndefOr[String] = js.undefined
var dataTransfer: js.UndefOr[DataTransfer] = js.undefined
var isComposing: js.UndefOr[Boolean] = js.undefined
var ranges: js.UndefOr[js.Array[StaticRange]]
}