prosemirror-view 1.29.0 → 1.29.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.29.1 (2022-11-14)
2
+
3
+ ### Bug fixes
4
+
5
+ Fix a problem when returning decorations from an outer editor from the `decorations` prop.
6
+
1
7
  ## 1.29.0 (2022-10-12)
2
8
 
3
9
  ### Bug fixes
package/README.md CHANGED
@@ -19,7 +19,7 @@ This code is released under an
19
19
  [MIT license](https://github.com/prosemirror/prosemirror/tree/master/LICENSE).
20
20
  There's a [forum](http://discuss.prosemirror.net) for general
21
21
  discussion and support requests, and the
22
- [Github bug tracker](https://github.com/prosemirror/prosemirror/issues)
22
+ [GitHub bug tracker](https://github.com/prosemirror/prosemirror/issues)
23
23
  is the place to report issues.
24
24
 
25
25
  We aim to be an inclusive, welcoming community. To make that explicit,
package/dist/index.cjs CHANGED
@@ -4442,7 +4442,11 @@ var DecorationGroup = function () {
4442
4442
  return members[0];
4443
4443
 
4444
4444
  default:
4445
- return new DecorationGroup(members);
4445
+ return new DecorationGroup(members.every(function (m) {
4446
+ return m instanceof DecorationSet;
4447
+ }) ? members : members.reduce(function (r, m) {
4448
+ return r.concat(m instanceof DecorationSet ? m : m.members);
4449
+ }, []));
4446
4450
  }
4447
4451
  }
4448
4452
  }]);
package/dist/index.js CHANGED
@@ -3976,7 +3976,8 @@ class DecorationGroup {
3976
3976
  switch (members.length) {
3977
3977
  case 0: return empty;
3978
3978
  case 1: return members[0];
3979
- default: return new DecorationGroup(members);
3979
+ default: return new DecorationGroup(members.every(m => m instanceof DecorationSet) ? members :
3980
+ members.reduce((r, m) => r.concat(m instanceof DecorationSet ? m : m.members), []));
3980
3981
  }
3981
3982
  }
3982
3983
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prosemirror-view",
3
- "version": "1.29.0",
3
+ "version": "1.29.1",
4
4
  "description": "ProseMirror's view component",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
package/src/decoration.ts CHANGED
@@ -528,11 +528,14 @@ class DecorationGroup implements DecorationSource {
528
528
 
529
529
  // Create a group for the given array of decoration sets, or return
530
530
  // a single set when possible.
531
- static from(members: readonly DecorationSet[]): DecorationSet | DecorationGroup {
531
+ static from(members: readonly DecorationSource[]): DecorationSource {
532
532
  switch (members.length) {
533
533
  case 0: return empty
534
534
  case 1: return members[0]
535
- default: return new DecorationGroup(members)
535
+ default: return new DecorationGroup(
536
+ members.every(m => m instanceof DecorationSet) ? members as DecorationSet[] :
537
+ members.reduce((r, m) => r.concat(m instanceof DecorationSet ? m : (m as DecorationGroup).members),
538
+ [] as DecorationSet[]))
536
539
  }
537
540
  }
538
541
  }
@@ -753,8 +756,8 @@ function insertAhead(array: Decoration[], i: number, deco: Decoration) {
753
756
  }
754
757
 
755
758
  // Get the decorations associated with the current props of a view.
756
- export function viewDecorations(view: EditorView): DecorationSet | DecorationGroup {
757
- let found = []
759
+ export function viewDecorations(view: EditorView): DecorationSource {
760
+ let found: DecorationSource[] = []
758
761
  view.someProp("decorations", f => {
759
762
  let result = f(view.state)
760
763
  if (result && result != empty) found.push(result)