prosemirror-view 1.32.7 → 1.33.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,15 @@
1
+ ## 1.33.1 (2024-02-15)
2
+
3
+ ### Bug fixes
4
+
5
+ Fix a type error in the published type declarations in 1.33.0.
6
+
7
+ ## 1.33.0 (2024-02-15)
8
+
9
+ ### New features
10
+
11
+ The `DecorationSource.forChild` method is now public.
12
+
1
13
  ## 1.32.7 (2023-12-18)
2
14
 
3
15
  ### Bug fixes
package/dist/index.d.cts CHANGED
@@ -75,8 +75,8 @@ declare class Decoration {
75
75
  */
76
76
  key?: string;
77
77
  /**
78
- Called when the widget decoration is removed as a result of
79
- mapping
78
+ Called when the widget decoration is removed or the editor is
79
+ destroyed.
80
80
  */
81
81
  destroy?: (node: DOMNode) => void;
82
82
  /**
@@ -156,6 +156,10 @@ interface DecorationSource {
156
156
  document.
157
157
  */
158
158
  map: (mapping: Mapping, node: Node) => DecorationSource;
159
+ /**
160
+ Extract a DecorationSource containing decorations for the given child node at the given offset.
161
+ */
162
+ forChild(offset: number, child: Node): DecorationSource;
159
163
  }
160
164
  /**
161
165
  A collection of [decorations](https://prosemirror.net/docs/ref/#view.Decoration), organized in such
@@ -206,11 +210,21 @@ declare class DecorationSet implements DecorationSource {
206
210
  */
207
211
  remove(decorations: Decoration[]): DecorationSet;
208
212
  private removeInner;
213
+ forChild(offset: number, node: Node): DecorationSet | DecorationGroup;
209
214
  /**
210
215
  The empty set of decorations.
211
216
  */
212
217
  static empty: DecorationSet;
213
218
  }
219
+ declare class DecorationGroup implements DecorationSource {
220
+ readonly members: readonly DecorationSet[];
221
+ constructor(members: readonly DecorationSet[]);
222
+ map(mapping: Mapping, doc: Node): DecorationSource;
223
+ forChild(offset: number, child: Node): DecorationSource | DecorationSet;
224
+ eq(other: DecorationGroup): boolean;
225
+ locals(node: Node): readonly any[];
226
+ static from(members: readonly DecorationSource[]): DecorationSource;
227
+ }
214
228
 
215
229
  declare global {
216
230
  interface Node {
package/dist/index.d.ts CHANGED
@@ -75,8 +75,8 @@ declare class Decoration {
75
75
  */
76
76
  key?: string;
77
77
  /**
78
- Called when the widget decoration is removed as a result of
79
- mapping
78
+ Called when the widget decoration is removed or the editor is
79
+ destroyed.
80
80
  */
81
81
  destroy?: (node: DOMNode) => void;
82
82
  /**
@@ -156,6 +156,10 @@ interface DecorationSource {
156
156
  document.
157
157
  */
158
158
  map: (mapping: Mapping, node: Node) => DecorationSource;
159
+ /**
160
+ Extract a DecorationSource containing decorations for the given child node at the given offset.
161
+ */
162
+ forChild(offset: number, child: Node): DecorationSource;
159
163
  }
160
164
  /**
161
165
  A collection of [decorations](https://prosemirror.net/docs/ref/#view.Decoration), organized in such
@@ -206,11 +210,21 @@ declare class DecorationSet implements DecorationSource {
206
210
  */
207
211
  remove(decorations: Decoration[]): DecorationSet;
208
212
  private removeInner;
213
+ forChild(offset: number, node: Node): DecorationSet | DecorationGroup;
209
214
  /**
210
215
  The empty set of decorations.
211
216
  */
212
217
  static empty: DecorationSet;
213
218
  }
219
+ declare class DecorationGroup implements DecorationSource {
220
+ readonly members: readonly DecorationSet[];
221
+ constructor(members: readonly DecorationSet[]);
222
+ map(mapping: Mapping, doc: Node): DecorationSource;
223
+ forChild(offset: number, child: Node): DecorationSource | DecorationSet;
224
+ eq(other: DecorationGroup): boolean;
225
+ locals(node: Node): readonly any[];
226
+ static from(members: readonly DecorationSource[]): DecorationSource;
227
+ }
214
228
 
215
229
  declare global {
216
230
  interface Node {
package/dist/index.js CHANGED
@@ -4022,9 +4022,6 @@ class DecorationSet {
4022
4022
  return this;
4023
4023
  return local.length || children.length ? new DecorationSet(local, children) : empty;
4024
4024
  }
4025
- /**
4026
- @internal
4027
- */
4028
4025
  forChild(offset, node) {
4029
4026
  if (this == empty)
4030
4027
  return this;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prosemirror-view",
3
- "version": "1.32.7",
3
+ "version": "1.33.1",
4
4
  "description": "ProseMirror's view component",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
package/src/decoration.ts CHANGED
@@ -179,8 +179,8 @@ export class Decoration {
179
179
  /// different keys.
180
180
  key?: string
181
181
 
182
- /// Called when the widget decoration is removed as a result of
183
- /// mapping
182
+ /// Called when the widget decoration is removed or the editor is
183
+ /// destroyed.
184
184
  destroy?: (node: DOMNode) => void
185
185
 
186
186
  /// Specs allow arbitrary additional properties.
@@ -258,7 +258,7 @@ export interface DecorationSource {
258
258
  map: (mapping: Mapping, node: Node) => DecorationSource
259
259
  /// @internal
260
260
  locals(node: Node): readonly Decoration[]
261
- /// @internal
261
+ /// Extract a DecorationSource containing decorations for the given child node at the given offset.
262
262
  forChild(offset: number, child: Node): DecorationSource
263
263
  /// @internal
264
264
  eq(other: DecorationSource): boolean
@@ -413,7 +413,6 @@ export class DecorationSet implements DecorationSource {
413
413
  return local.length || children.length ? new DecorationSet(local, children) : empty
414
414
  }
415
415
 
416
- /// @internal
417
416
  forChild(offset: number, node: Node): DecorationSet | DecorationGroup {
418
417
  if (this == empty) return this
419
418
  if (node.isLeaf) return DecorationSet.empty