diff --git a/api-reports/2_12.txt b/api-reports/2_12.txt index f03765312..3b7ff2ff9 100644 --- a/api-reports/2_12.txt +++ b/api-reports/2_12.txt @@ -993,11 +993,11 @@ Clients[JT] def openWindow(url: String): js.Promise[WindowClient] Clipboard[JT] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit Clipboard[JT] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit Clipboard[JT] def dispatchEvent(evt: Event): Boolean -Clipboard[JT] def read(): js.Promise[DataTransfer] +Clipboard[JT] def read(): js.Promise[js.Array[ClipboardItem]] Clipboard[JT] def readText(): js.Promise[String] Clipboard[JT] def removeEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit Clipboard[JT] def removeEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit -Clipboard[JT] def write(data: DataTransfer): js.Promise[Unit] +Clipboard[JT] def write(data: js.Array[ClipboardItem]): js.Promise[Unit] Clipboard[JT] def writeText(newClipText: String): js.Promise[Unit] ClipboardEvent[JC] def bubbles: Boolean ClipboardEvent[JC] def cancelBubble: Boolean @@ -1019,6 +1019,10 @@ ClipboardEventInit[JT] var composed: js.UndefOr[Boolean] ClipboardEventInit[JT] var data: js.UndefOr[String] ClipboardEventInit[JT] var dataType: js.UndefOr[String] ClipboardEventInit[JT] var scoped: js.UndefOr[Boolean] +ClipboardItem[JC] def getType(`type`: String): js.Promise[Blob] +ClipboardItem[JC] def presentationStyle: PresentationStyle +ClipboardItem[JC] def types: FrozenArray[String] +ClipboardItemOptions[JT] def presentationStyle: js.UndefOr[PresentationStyle] CloseEvent[JT] def bubbles: Boolean CloseEvent[JT] def cancelBubble: Boolean CloseEvent[JT] def cancelable: Boolean @@ -2017,6 +2021,8 @@ FrameType[SO] val auxiliary: FrameType FrameType[SO] val nested: FrameType FrameType[SO] val none: FrameType FrameType[SO] val `top-level` = "top-level".asInstanceOf[FrameType] +FrozenArray[JT] @js.annotation.JSBracketAccess def apply(index: Int): T +FrozenArray[JT] val length: Int FullscreenOptions[JT] var navigationUI: js.UndefOr[String] GainNode[JT] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit GainNode[JT] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit @@ -16226,6 +16232,10 @@ PositionError[JT] def message: String PositionOptions[JC] var enableHighAccuracy: Boolean PositionOptions[JC] var maximumAge: Int PositionOptions[JC] var timeout: Int +PresentationStyle[JT] +PresentationStyle[SO] val attachment: PresentationStyle +PresentationStyle[SO] val inline: PresentationStyle +PresentationStyle[SO] val unspecified: PresentationStyle ProcessingInstruction[JC] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit ProcessingInstruction[JC] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit ProcessingInstruction[JC] def appendChild(newChild: Node): Node @@ -26946,6 +26956,7 @@ package[SO] type BufferSource = ArrayBufferView | ArrayBuffer package[SO] type ByteString = String package[SO] type ClientRect = DOMRect (@deprecated in 2.0.0) package[SO] type ClientRectList = DOMRectList (@deprecated in 2.0.0) +package[SO] type ClipboardItemData = js.Promise[String | Blob] package[SO] type HashAlgorithmIdentifier = HashAlgorithm | String package[SO] type HeadersInit = Headers | Sequence[Sequence[ByteString]] | OpenEndedDictionary[ByteString] package[SO] type IDBKey = Any diff --git a/api-reports/2_13.txt b/api-reports/2_13.txt index f03765312..3b7ff2ff9 100644 --- a/api-reports/2_13.txt +++ b/api-reports/2_13.txt @@ -993,11 +993,11 @@ Clients[JT] def openWindow(url: String): js.Promise[WindowClient] Clipboard[JT] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit Clipboard[JT] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit Clipboard[JT] def dispatchEvent(evt: Event): Boolean -Clipboard[JT] def read(): js.Promise[DataTransfer] +Clipboard[JT] def read(): js.Promise[js.Array[ClipboardItem]] Clipboard[JT] def readText(): js.Promise[String] Clipboard[JT] def removeEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit Clipboard[JT] def removeEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit -Clipboard[JT] def write(data: DataTransfer): js.Promise[Unit] +Clipboard[JT] def write(data: js.Array[ClipboardItem]): js.Promise[Unit] Clipboard[JT] def writeText(newClipText: String): js.Promise[Unit] ClipboardEvent[JC] def bubbles: Boolean ClipboardEvent[JC] def cancelBubble: Boolean @@ -1019,6 +1019,10 @@ ClipboardEventInit[JT] var composed: js.UndefOr[Boolean] ClipboardEventInit[JT] var data: js.UndefOr[String] ClipboardEventInit[JT] var dataType: js.UndefOr[String] ClipboardEventInit[JT] var scoped: js.UndefOr[Boolean] +ClipboardItem[JC] def getType(`type`: String): js.Promise[Blob] +ClipboardItem[JC] def presentationStyle: PresentationStyle +ClipboardItem[JC] def types: FrozenArray[String] +ClipboardItemOptions[JT] def presentationStyle: js.UndefOr[PresentationStyle] CloseEvent[JT] def bubbles: Boolean CloseEvent[JT] def cancelBubble: Boolean CloseEvent[JT] def cancelable: Boolean @@ -2017,6 +2021,8 @@ FrameType[SO] val auxiliary: FrameType FrameType[SO] val nested: FrameType FrameType[SO] val none: FrameType FrameType[SO] val `top-level` = "top-level".asInstanceOf[FrameType] +FrozenArray[JT] @js.annotation.JSBracketAccess def apply(index: Int): T +FrozenArray[JT] val length: Int FullscreenOptions[JT] var navigationUI: js.UndefOr[String] GainNode[JT] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit GainNode[JT] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit @@ -16226,6 +16232,10 @@ PositionError[JT] def message: String PositionOptions[JC] var enableHighAccuracy: Boolean PositionOptions[JC] var maximumAge: Int PositionOptions[JC] var timeout: Int +PresentationStyle[JT] +PresentationStyle[SO] val attachment: PresentationStyle +PresentationStyle[SO] val inline: PresentationStyle +PresentationStyle[SO] val unspecified: PresentationStyle ProcessingInstruction[JC] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit ProcessingInstruction[JC] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit ProcessingInstruction[JC] def appendChild(newChild: Node): Node @@ -26946,6 +26956,7 @@ package[SO] type BufferSource = ArrayBufferView | ArrayBuffer package[SO] type ByteString = String package[SO] type ClientRect = DOMRect (@deprecated in 2.0.0) package[SO] type ClientRectList = DOMRectList (@deprecated in 2.0.0) +package[SO] type ClipboardItemData = js.Promise[String | Blob] package[SO] type HashAlgorithmIdentifier = HashAlgorithm | String package[SO] type HeadersInit = Headers | Sequence[Sequence[ByteString]] | OpenEndedDictionary[ByteString] package[SO] type IDBKey = Any diff --git a/dom/src/main/scala-2/org/scalajs/dom/PresentationStyle.scala b/dom/src/main/scala-2/org/scalajs/dom/PresentationStyle.scala new file mode 100644 index 000000000..0d1c69f69 --- /dev/null +++ b/dom/src/main/scala-2/org/scalajs/dom/PresentationStyle.scala @@ -0,0 +1,16 @@ +package org.scalajs.dom + +import scala.scalajs.js + +/** + * Helps distinguish whether apps "pasting" a clipboard item should insert the contents of an appropriate representation inline at the point of paste or if it should be treated as an attachment. + * See [[https://w3c.github.io/clipboard-apis/#enumdef-presentationstyle PresentationStyle enum]] + */ +@js.native +sealed trait PresentationStyle extends js.Any + +object PresentationStyle{ + val unspecified: PresentationStyle = "unspecified".asInstanceOf[PresentationStyle] + val inline: PresentationStyle = "inline".asInstanceOf[PresentationStyle] + val attachment: PresentationStyle = "attachment".asInstanceOf[PresentationStyle] +} diff --git a/dom/src/main/scala-3/org/scalajs/dom/PresentationStyle.scala b/dom/src/main/scala-3/org/scalajs/dom/PresentationStyle.scala new file mode 100644 index 000000000..1c09ad1ab --- /dev/null +++ b/dom/src/main/scala-3/org/scalajs/dom/PresentationStyle.scala @@ -0,0 +1,15 @@ +package org.scalajs.dom + +import scala.scalajs.js + +/** + * Helps distinguish whether apps "pasting" a clipboard item should insert the contents of an appropriate representation inline at the point of paste or if it should be treated as an attachment. + * See [[https://w3c.github.io/clipboard-apis/#enumdef-presentationstyle PresentationStyle enum]] + */ +opaque type PresentationStyle <: String = String + +object PresentationStyle { + val unspecified: PresentationStyle = "unspecified" + val inline: PresentationStyle = "inline" + val attachment: PresentationStyle = "attachment" +} \ No newline at end of file diff --git a/dom/src/main/scala/org/scalajs/dom/Clipboard.scala b/dom/src/main/scala/org/scalajs/dom/Clipboard.scala index e07c4ed6d..bdb6b0e92 100644 --- a/dom/src/main/scala/org/scalajs/dom/Clipboard.scala +++ b/dom/src/main/scala/org/scalajs/dom/Clipboard.scala @@ -25,7 +25,7 @@ trait Clipboard extends EventTarget { * * To read from the clipboard, you must first have the "clipboard-read" permission. */ - def read(): js.Promise[DataTransfer] = js.native + def read(): js.Promise[js.Array[ClipboardItem]] = js.native /** The readText() method returns a Promise which resolves with a copy of the textual contents of the system * clipboard. @@ -38,7 +38,7 @@ trait Clipboard extends EventTarget { * Before you can write to the clipboard, you need to use the Permissions API to get the "clipboard-write" * permission. */ - def write(data: DataTransfer): js.Promise[Unit] = js.native + def write(data: js.Array[ClipboardItem]): js.Promise[Unit] = js.native /** The writeText() method writes the specified text string to the system clipboard. */ def writeText(newClipText: String): js.Promise[Unit] = js.native diff --git a/dom/src/main/scala/org/scalajs/dom/ClipboardItem.scala b/dom/src/main/scala/org/scalajs/dom/ClipboardItem.scala new file mode 100644 index 000000000..bf7203759 --- /dev/null +++ b/dom/src/main/scala/org/scalajs/dom/ClipboardItem.scala @@ -0,0 +1,28 @@ +/** 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._ + +/** A clipboard item is conceptually data that the user has expressed a desire to make shareable by invoking a "cut" or + * "copy" command + */ +@js.native +@JSGlobal +class ClipboardItem(items: js.Dictionary[ClipboardItemData], options: ClipboardItemOptions = js.native) + extends js.Object { + def presentationStyle: PresentationStyle = js.native + + /** Returns an Array of MIME types available within the ClipboardItem. */ + def types: FrozenArray[String] = js.native + + /** Returns a Promise that resolves with a Blob of the requested MIME type, or an error if the MIME type is not found. + */ + def getType(`type`: String): js.Promise[Blob] = js.native + +} diff --git a/dom/src/main/scala/org/scalajs/dom/ClipboardItemOptions.scala b/dom/src/main/scala/org/scalajs/dom/ClipboardItemOptions.scala new file mode 100644 index 000000000..04921d2a9 --- /dev/null +++ b/dom/src/main/scala/org/scalajs/dom/ClipboardItemOptions.scala @@ -0,0 +1,13 @@ +/** 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 ClipboardItemOptions extends js.Object { + def presentationStyle: js.UndefOr[PresentationStyle] = js.undefined +} diff --git a/dom/src/main/scala/org/scalajs/dom/FrozenArray.scala b/dom/src/main/scala/org/scalajs/dom/FrozenArray.scala new file mode 100644 index 000000000..eb3848e15 --- /dev/null +++ b/dom/src/main/scala/org/scalajs/dom/FrozenArray.scala @@ -0,0 +1,23 @@ +/** 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 + +/** A frozen array type is a parameterized type whose values are references to objects that hold a fixed length array of + * unmodifiable values. The values in the array are of type T. + * + * Since FrozenArray values are references, they are unlike sequence types, which are lists of values that are + * passed by value. + */ +@js.native +trait FrozenArray[+T] extends js.Iterable[T] { + val length: Int = js.native + + @js.annotation.JSBracketAccess + def apply(index: Int): T = js.native +} diff --git a/dom/src/main/scala/org/scalajs/dom/package.scala b/dom/src/main/scala/org/scalajs/dom/package.scala index a17cd5c33..95bf272d9 100644 --- a/dom/src/main/scala/org/scalajs/dom/package.scala +++ b/dom/src/main/scala/org/scalajs/dom/package.scala @@ -114,4 +114,6 @@ package object dom { val webcrypto: Crypto = js.native type BlobPart = BufferSource | Blob | String + + type ClipboardItemData = js.Promise[String | Blob] }