prosemirror-view 1.25.0 → 1.26.2

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,21 @@
1
+ ## 1.26.2 (2022-06-22)
2
+
3
+ ### Bug fixes
4
+
5
+ Mark prosemirror.css as having side effects in package.json.
6
+
7
+ ## 1.26.1 (2022-06-13)
8
+
9
+ ### Bug fixes
10
+
11
+ Fix incorrect types for `handleDrop` and `decorations`. Document open properties on widget specs
12
+
13
+ ## 1.26.0 (2022-06-07)
14
+
15
+ ### New features
16
+
17
+ Export the `NodeViewConstructor` and `MarkViewConstructor` types. Include Node/MarkViewConstructor in doc template
18
+
1
19
  ## 1.25.0 (2022-06-01)
2
20
 
3
21
  ### 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
@@ -536,7 +544,15 @@ declare class EditorView {
536
544
  */
537
545
  dispatch(tr: Transaction): void;
538
546
  }
547
+ /**
548
+ The type of function [provided](https://prosemirror.net/docs/ref/#view.ViewProps.nodeViews) to
549
+ create [node views](https://prosemirror.net/docs/ref/#view.NodeView).
550
+ */
539
551
  declare type NodeViewConstructor = (node: Node, view: EditorView, getPos: () => number, decorations: readonly Decoration[], innerDecorations: DecorationSource) => NodeView;
552
+ /**
553
+ The function types [used](https://prosemirror.net/docs/ref/#view.ViewProps.markViews) to create
554
+ mark views.
555
+ */
540
556
  declare type MarkViewConstructor = (mark: Mark, view: EditorView, inline: boolean) => {
541
557
  dom: HTMLElement;
542
558
  contentDOM?: HTMLElement;
@@ -575,7 +591,7 @@ interface EditorProps {
575
591
  default behavior).
576
592
  */
577
593
  handleDOMEvents?: {
578
- [event in string]: (view: EditorView, event: DOMEventMap[event]) => boolean | void;
594
+ [event in keyof DOMEventMap]?: (view: EditorView, event: DOMEventMap[event]) => boolean | void;
579
595
  };
580
596
  /**
581
597
  Called when the editor receives a `keydown` event.
@@ -628,7 +644,7 @@ interface EditorProps {
628
644
  true if this drop moves from the current selection (which should
629
645
  thus be deleted).
630
646
  */
631
- handleDrop?: (view: EditorView, event: MouseEvent, slice: Slice, moved: boolean) => boolean | void;
647
+ handleDrop?: (view: EditorView, event: DragEvent, slice: Slice, moved: boolean) => boolean | void;
632
648
  /**
633
649
  Called when the view, after updating its state, tries to scroll
634
650
  the selection into view. A handler function may return false to
@@ -738,7 +754,7 @@ interface EditorProps {
738
754
  A set of [document decorations](https://prosemirror.net/docs/ref/#view.Decoration) to show in the
739
755
  view.
740
756
  */
741
- decorations?: (state: EditorState) => DecorationSource | null;
757
+ decorations?: (state: EditorState) => DecorationSource | null | undefined;
742
758
  /**
743
759
  When this returns false, the content of the view is not directly
744
760
  editable.
@@ -812,4 +828,4 @@ interface DirectEditorProps extends EditorProps {
812
828
  dispatchTransaction?: (tr: Transaction) => void;
813
829
  }
814
830
 
815
- export { DOMEventMap, Decoration, DecorationAttrs, DecorationSet, DecorationSource, DirectEditorProps, EditorProps, EditorView, NodeView };
831
+ export { DOMEventMap, Decoration, DecorationAttrs, DecorationSet, DecorationSource, DirectEditorProps, EditorProps, EditorView, MarkViewConstructor, NodeView, NodeViewConstructor };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prosemirror-view",
3
- "version": "1.25.0",
3
+ "version": "1.26.2",
4
4
  "description": "ProseMirror's view component",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -13,7 +13,7 @@
13
13
  },
14
14
  "./style/prosemirror.css": "./style/prosemirror.css"
15
15
  },
16
- "sideEffects": false,
16
+ "sideEffects": ["./style/prosemirror.css"],
17
17
  "style": "style/prosemirror.css",
18
18
  "license": "MIT",
19
19
  "maintainers": [
package/src/README.md CHANGED
@@ -10,6 +10,10 @@ this module.
10
10
 
11
11
  @EditorProps
12
12
 
13
+ @NodeViewConstructor
14
+
15
+ @MarkViewConstructor
16
+
13
17
  @DirectEditorProps
14
18
 
15
19
  @NodeView
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
@@ -497,9 +497,14 @@ function checkStateComponent(plugin: Plugin) {
497
497
  throw new RangeError("Plugins passed directly to the view must not have a state component")
498
498
  }
499
499
 
500
- type NodeViewConstructor = (node: Node, view: EditorView, getPos: () => number,
501
- decorations: readonly Decoration[], innerDecorations: DecorationSource) => NodeView
502
- type MarkViewConstructor = (mark: Mark, view: EditorView, inline: boolean) => {dom: HTMLElement, contentDOM?: HTMLElement}
500
+ /// The type of function [provided](#view.ViewProps.nodeViews) to
501
+ /// create [node views](#view.NodeView).
502
+ export type NodeViewConstructor = (node: Node, view: EditorView, getPos: () => number,
503
+ decorations: readonly Decoration[], innerDecorations: DecorationSource) => NodeView
504
+
505
+ /// The function types [used](#view.ViewProps.markViews) to create
506
+ /// mark views.
507
+ export type MarkViewConstructor = (mark: Mark, view: EditorView, inline: boolean) => {dom: HTMLElement, contentDOM?: HTMLElement}
503
508
 
504
509
  type NodeViewSet = {[name: string]: NodeViewConstructor | MarkViewConstructor}
505
510
 
@@ -532,7 +537,7 @@ export interface EditorProps {
532
537
  /// `preventDefault` yourself (or not, if you want to allow the
533
538
  /// default behavior).
534
539
  handleDOMEvents?: {
535
- [event in string]: (view: EditorView, event: DOMEventMap[event]) => boolean | void
540
+ [event in keyof DOMEventMap]?: (view: EditorView, event: DOMEventMap[event]) => boolean | void
536
541
  }
537
542
 
538
543
  /// Called when the editor receives a `keydown` event.
@@ -574,7 +579,7 @@ export interface EditorProps {
574
579
  /// Called when something is dropped on the editor. `moved` will be
575
580
  /// true if this drop moves from the current selection (which should
576
581
  /// thus be deleted).
577
- handleDrop?: (view: EditorView, event: MouseEvent, slice: Slice, moved: boolean) => boolean | void
582
+ handleDrop?: (view: EditorView, event: DragEvent, slice: Slice, moved: boolean) => boolean | void
578
583
 
579
584
  /// Called when the view, after updating its state, tries to scroll
580
585
  /// the selection into view. A handler function may return false to
@@ -667,7 +672,7 @@ export interface EditorProps {
667
672
 
668
673
  /// A set of [document decorations](#view.Decoration) to show in the
669
674
  /// view.
670
- decorations?: (state: EditorState) => DecorationSource | null
675
+ decorations?: (state: EditorState) => DecorationSource | null | undefined
671
676
 
672
677
  /// When this returns false, the content of the view is not directly
673
678
  /// editable.