prosemirror-view 1.26.0 → 1.26.1

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/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 1.26.1 (2022-06-13)
2
+
3
+ ### Bug fixes
4
+
5
+ Fix incorrect types for `handleDrop` and `decorations`. Document open properties on widget specs
6
+
1
7
  ## 1.26.0 (2022-06-07)
2
8
 
3
9
  ### New features
package/dist/index.d.ts CHANGED
@@ -79,6 +79,10 @@ declare class Decoration {
79
79
  mapping
80
80
  */
81
81
  destroy?: (node: DOMNode) => void;
82
+ /**
83
+ Specs allow arbitrary additional properties.
84
+ */
85
+ [key: string]: any;
82
86
  }): Decoration;
83
87
  /**
84
88
  Creates an inline decoration, which adds the given attributes to
@@ -99,6 +103,10 @@ declare class Decoration {
99
103
  [`inclusiveStart`](https://prosemirror.net/docs/ref/#view.Decoration^inline^spec.inclusiveStart).
100
104
  */
101
105
  inclusiveEnd?: boolean;
106
+ /**
107
+ Specs may have arbitrary additional properties.
108
+ */
109
+ [key: string]: any;
102
110
  }): Decoration;
103
111
  /**
104
112
  Creates a node decoration. `from` and `to` should point precisely
@@ -583,7 +591,7 @@ interface EditorProps {
583
591
  default behavior).
584
592
  */
585
593
  handleDOMEvents?: {
586
- [event in string]: (view: EditorView, event: DOMEventMap[event]) => boolean | void;
594
+ [event in keyof DOMEventMap]?: (view: EditorView, event: DOMEventMap[event]) => boolean | void;
587
595
  };
588
596
  /**
589
597
  Called when the editor receives a `keydown` event.
@@ -636,7 +644,7 @@ interface EditorProps {
636
644
  true if this drop moves from the current selection (which should
637
645
  thus be deleted).
638
646
  */
639
- handleDrop?: (view: EditorView, event: MouseEvent, slice: Slice, moved: boolean) => boolean | void;
647
+ handleDrop?: (view: EditorView, event: DragEvent, slice: Slice, moved: boolean) => boolean | void;
640
648
  /**
641
649
  Called when the view, after updating its state, tries to scroll
642
650
  the selection into view. A handler function may return false to
@@ -746,7 +754,7 @@ interface EditorProps {
746
754
  A set of [document decorations](https://prosemirror.net/docs/ref/#view.Decoration) to show in the
747
755
  view.
748
756
  */
749
- decorations?: (state: EditorState) => DecorationSource | null;
757
+ decorations?: (state: EditorState) => DecorationSource | null | undefined;
750
758
  /**
751
759
  When this returns false, the content of the view is not directly
752
760
  editable.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prosemirror-view",
3
- "version": "1.26.0",
3
+ "version": "1.26.1",
4
4
  "description": "ProseMirror's view component",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
package/src/decoration.ts CHANGED
@@ -182,6 +182,9 @@ export class Decoration {
182
182
  /// Called when the widget decoration is removed as a result of
183
183
  /// mapping
184
184
  destroy?: (node: DOMNode) => void
185
+
186
+ /// Specs allow arbitrary additional properties.
187
+ [key: string]: any
185
188
  }): Decoration {
186
189
  return new Decoration(pos, pos, new WidgetType(toDOM, spec))
187
190
  }
@@ -200,6 +203,9 @@ export class Decoration {
200
203
  /// See
201
204
  /// [`inclusiveStart`](#view.Decoration^inline^spec.inclusiveStart).
202
205
  inclusiveEnd?: boolean
206
+
207
+ /// Specs may have arbitrary additional properties.
208
+ [key: string]: any
203
209
  }) {
204
210
  return new Decoration(from, to, new InlineType(attrs, spec))
205
211
  }
package/src/index.ts CHANGED
@@ -537,7 +537,7 @@ export interface EditorProps {
537
537
  /// `preventDefault` yourself (or not, if you want to allow the
538
538
  /// default behavior).
539
539
  handleDOMEvents?: {
540
- [event in string]: (view: EditorView, event: DOMEventMap[event]) => boolean | void
540
+ [event in keyof DOMEventMap]?: (view: EditorView, event: DOMEventMap[event]) => boolean | void
541
541
  }
542
542
 
543
543
  /// Called when the editor receives a `keydown` event.
@@ -579,7 +579,7 @@ export interface EditorProps {
579
579
  /// Called when something is dropped on the editor. `moved` will be
580
580
  /// true if this drop moves from the current selection (which should
581
581
  /// thus be deleted).
582
- handleDrop?: (view: EditorView, event: MouseEvent, slice: Slice, moved: boolean) => boolean | void
582
+ handleDrop?: (view: EditorView, event: DragEvent, slice: Slice, moved: boolean) => boolean | void
583
583
 
584
584
  /// Called when the view, after updating its state, tries to scroll
585
585
  /// the selection into view. A handler function may return false to
@@ -672,7 +672,7 @@ export interface EditorProps {
672
672
 
673
673
  /// A set of [document decorations](#view.Decoration) to show in the
674
674
  /// view.
675
- decorations?: (state: EditorState) => DecorationSource | null
675
+ decorations?: (state: EditorState) => DecorationSource | null | undefined
676
676
 
677
677
  /// When this returns false, the content of the view is not directly
678
678
  /// editable.