prosemirror-view 1.24.0-beta.2 → 1.24.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -538,6 +538,14 @@ declare class EditorView {
538
538
  }
539
539
  declare type NodeViewConstructor = (node: Node, view: EditorView, getPos: () => number | undefined, decorations: readonly Decoration[], innerDecorations: DecorationSource) => NodeView;
540
540
  /**
541
+ Helper type that maps event names to event object types, but
542
+ includes events that TypeScript's HTMLElementEventMap doesn't know
543
+ about.
544
+ */
545
+ interface DOMEventMap extends HTMLElementEventMap {
546
+ [event: string]: Event;
547
+ }
548
+ /**
541
549
  Props are configuration values that can be passed to an editor view
542
550
  or included in a plugin. This interface lists the supported props.
543
551
 
@@ -563,7 +571,7 @@ interface EditorProps {
563
571
  default behavior).
564
572
  */
565
573
  handleDOMEvents?: {
566
- [event: string]: (view: EditorView, event: Event) => boolean | void;
574
+ [event in string]: (view: EditorView, event: DOMEventMap[event]) => boolean | void;
567
575
  };
568
576
  /**
569
577
  Called when the editor receives a `keydown` event.
@@ -788,4 +796,4 @@ interface DirectEditorProps extends EditorProps {
788
796
  dispatchTransaction?: (tr: Transaction) => void;
789
797
  }
790
798
 
791
- export { Decoration, DecorationAttrs, DecorationSet, DecorationSource, DirectEditorProps, EditorProps, EditorView, NodeView };
799
+ export { DOMEventMap, Decoration, DecorationAttrs, DecorationSet, DecorationSource, DirectEditorProps, EditorProps, EditorView, NodeView };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prosemirror-view",
3
- "version": "1.24.0-beta.2",
3
+ "version": "1.24.0-beta.3",
4
4
  "description": "ProseMirror's view component",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
package/src/README.md CHANGED
@@ -14,6 +14,8 @@ this module.
14
14
 
15
15
  @NodeView
16
16
 
17
+ @DOMEventMap
18
+
17
19
  ### Decorations
18
20
 
19
21
  Decorations make it possible to influence the way the document is
package/src/index.ts CHANGED
@@ -498,6 +498,13 @@ function checkStateComponent(plugin: Plugin) {
498
498
  type NodeViewConstructor = (node: Node, view: EditorView, getPos: () => number | undefined,
499
499
  decorations: readonly Decoration[], innerDecorations: DecorationSource) => NodeView
500
500
 
501
+ /// Helper type that maps event names to event object types, but
502
+ /// includes events that TypeScript's HTMLElementEventMap doesn't know
503
+ /// about.
504
+ export interface DOMEventMap extends HTMLElementEventMap {
505
+ [event: string]: Event
506
+ }
507
+
501
508
  /// Props are configuration values that can be passed to an editor view
502
509
  /// or included in a plugin. This interface lists the supported props.
503
510
  ///
@@ -519,7 +526,9 @@ export interface EditorProps {
519
526
  /// from such a function, you are responsible for calling
520
527
  /// `preventDefault` yourself (or not, if you want to allow the
521
528
  /// default behavior).
522
- handleDOMEvents?: {[event: string]: (view: EditorView, event: Event) => boolean | void}
529
+ handleDOMEvents?: {
530
+ [event in string]: (view: EditorView, event: DOMEventMap[event]) => boolean | void
531
+ }
523
532
 
524
533
  /// Called when the editor receives a `keydown` event.
525
534
  handleKeyDown?: (view: EditorView, event: KeyboardEvent) => boolean | void