prosemirror-view 1.33.11 → 1.34.0

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.34.0 (2024-08-23)
2
+
3
+ ### New features
4
+
5
+ The `DecorationGroup` interface now has a `forEachSet` method to iterate though the contained decoration sets.
6
+
1
7
  ## 1.33.11 (2024-08-19)
2
8
 
3
9
  ### Bug fixes
package/dist/index.cjs CHANGED
@@ -3816,6 +3816,11 @@ var DecorationSet = function () {
3816
3816
  }
3817
3817
  return result;
3818
3818
  }
3819
+ }, {
3820
+ key: "forEachSet",
3821
+ value: function forEachSet(f) {
3822
+ f(this);
3823
+ }
3819
3824
  }], [{
3820
3825
  key: "create",
3821
3826
  value: function create(doc, decorations) {
@@ -3879,6 +3884,11 @@ var DecorationGroup = function () {
3879
3884
  }
3880
3885
  return result ? removeOverlap(sorted ? result : result.sort(byPos)) : none;
3881
3886
  }
3887
+ }, {
3888
+ key: "forEachSet",
3889
+ value: function forEachSet(f) {
3890
+ for (var i = 0; i < this.members.length; i++) this.members[i].forEachSet(f);
3891
+ }
3882
3892
  }], [{
3883
3893
  key: "from",
3884
3894
  value: function from(members) {
package/dist/index.d.cts CHANGED
@@ -160,6 +160,10 @@ interface DecorationSource {
160
160
  Extract a DecorationSource containing decorations for the given child node at the given offset.
161
161
  */
162
162
  forChild(offset: number, child: Node): DecorationSource;
163
+ /**
164
+ Call the given function for each decoration set in the group.
165
+ */
166
+ forEachSet(f: (set: DecorationSet) => void): void;
163
167
  }
164
168
  /**
165
169
  A collection of [decorations](https://prosemirror.net/docs/ref/#view.Decoration), organized in such
@@ -215,6 +219,7 @@ declare class DecorationSet implements DecorationSource {
215
219
  The empty set of decorations.
216
220
  */
217
221
  static empty: DecorationSet;
222
+ forEachSet(f: (set: DecorationSet) => void): void;
218
223
  }
219
224
  declare class DecorationGroup implements DecorationSource {
220
225
  readonly members: readonly DecorationSet[];
@@ -224,6 +229,7 @@ declare class DecorationGroup implements DecorationSource {
224
229
  eq(other: DecorationGroup): boolean;
225
230
  locals(node: Node): readonly any[];
226
231
  static from(members: readonly DecorationSource[]): DecorationSource;
232
+ forEachSet(f: (set: DecorationSet) => void): void;
227
233
  }
228
234
 
229
235
  declare global {
package/dist/index.d.ts CHANGED
@@ -160,6 +160,10 @@ interface DecorationSource {
160
160
  Extract a DecorationSource containing decorations for the given child node at the given offset.
161
161
  */
162
162
  forChild(offset: number, child: Node): DecorationSource;
163
+ /**
164
+ Call the given function for each decoration set in the group.
165
+ */
166
+ forEachSet(f: (set: DecorationSet) => void): void;
163
167
  }
164
168
  /**
165
169
  A collection of [decorations](https://prosemirror.net/docs/ref/#view.Decoration), organized in such
@@ -215,6 +219,7 @@ declare class DecorationSet implements DecorationSource {
215
219
  The empty set of decorations.
216
220
  */
217
221
  static empty: DecorationSet;
222
+ forEachSet(f: (set: DecorationSet) => void): void;
218
223
  }
219
224
  declare class DecorationGroup implements DecorationSource {
220
225
  readonly members: readonly DecorationSet[];
@@ -224,6 +229,7 @@ declare class DecorationGroup implements DecorationSource {
224
229
  eq(other: DecorationGroup): boolean;
225
230
  locals(node: Node): readonly any[];
226
231
  static from(members: readonly DecorationSource[]): DecorationSource;
232
+ forEachSet(f: (set: DecorationSet) => void): void;
227
233
  }
228
234
 
229
235
  declare global {
package/dist/index.js CHANGED
@@ -4160,6 +4160,7 @@ class DecorationSet {
4160
4160
  }
4161
4161
  return result;
4162
4162
  }
4163
+ forEachSet(f) { f(this); }
4163
4164
  }
4164
4165
  /**
4165
4166
  The empty set of decorations.
@@ -4235,6 +4236,10 @@ class DecorationGroup {
4235
4236
  members.reduce((r, m) => r.concat(m instanceof DecorationSet ? m : m.members), []));
4236
4237
  }
4237
4238
  }
4239
+ forEachSet(f) {
4240
+ for (let i = 0; i < this.members.length; i++)
4241
+ this.members[i].forEachSet(f);
4242
+ }
4238
4243
  }
4239
4244
  function mapChildren(oldChildren, newLocal, mapping, node, offset, oldOffset, options) {
4240
4245
  let children = oldChildren.slice();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prosemirror-view",
3
- "version": "1.33.11",
3
+ "version": "1.34.0",
4
4
  "description": "ProseMirror's view component",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
package/src/decoration.ts CHANGED
@@ -262,6 +262,8 @@ export interface DecorationSource {
262
262
  forChild(offset: number, child: Node): DecorationSource
263
263
  /// @internal
264
264
  eq(other: DecorationSource): boolean
265
+ /// Call the given function for each decoration set in the group.
266
+ forEachSet(f: (set: DecorationSet) => void): void
265
267
  }
266
268
 
267
269
  /// A collection of [decorations](#view.Decoration), organized in such
@@ -475,6 +477,8 @@ export class DecorationSet implements DecorationSource {
475
477
 
476
478
  /// @internal
477
479
  static removeOverlap = removeOverlap
480
+
481
+ forEachSet(f: (set: DecorationSet) => void) { f(this) }
478
482
  }
479
483
 
480
484
  const empty = DecorationSet.empty
@@ -542,6 +546,10 @@ class DecorationGroup implements DecorationSource {
542
546
  [] as DecorationSet[]))
543
547
  }
544
548
  }
549
+
550
+ forEachSet(f: (set: DecorationSet) => void) {
551
+ for (let i = 0; i < this.members.length; i++) this.members[i].forEachSet(f)
552
+ }
545
553
  }
546
554
 
547
555
  function mapChildren(