prosemirror-view 1.42.2 → 1.42.3
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 +10 -0
- package/dist/index.cjs +16 -6
- package/dist/index.js +16 -3
- package/package.json +1 -1
- package/src/clipboard.ts +7 -2
- package/src/viewdesc.ts +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
## 1.42.3 (2026-08-25)
|
|
2
|
+
|
|
3
|
+
### Bug fixes
|
|
4
|
+
|
|
5
|
+
Don't set `contenteditable=false` on widgets that already have a `contenteditable` attribute.
|
|
6
|
+
|
|
7
|
+
Fix a bug that broke pasting when there was a default trusted type policy defined without a `createHTML` function.
|
|
8
|
+
|
|
9
|
+
Run attribute validators on attributes provided via slice context in clipboard content. This closes an XSS vulnerability (found by Pedro Paniago).
|
|
10
|
+
|
|
1
11
|
## 1.42.2 (2026-07-24)
|
|
2
12
|
|
|
3
13
|
### Bug fixes
|
package/dist/index.cjs
CHANGED
|
@@ -1105,7 +1105,7 @@ var WidgetViewDesc = function (_ViewDesc) {
|
|
|
1105
1105
|
wrap.appendChild(dom);
|
|
1106
1106
|
dom = wrap;
|
|
1107
1107
|
}
|
|
1108
|
-
dom.contentEditable = "false";
|
|
1108
|
+
if (!dom.hasAttribute("contenteditable")) dom.contentEditable = "false";
|
|
1109
1109
|
dom.classList.add("ProseMirror-widget");
|
|
1110
1110
|
}
|
|
1111
1111
|
_this = _super.call(this, parent, [], dom, null);
|
|
@@ -2852,11 +2852,16 @@ var _policy = null;
|
|
|
2852
2852
|
function maybeWrapTrusted(html) {
|
|
2853
2853
|
var trustedTypes = window.trustedTypes;
|
|
2854
2854
|
if (!trustedTypes) return html;
|
|
2855
|
-
if (!_policy)
|
|
2856
|
-
|
|
2857
|
-
return
|
|
2858
|
-
}
|
|
2859
|
-
|
|
2855
|
+
if (!_policy) {
|
|
2856
|
+
if (_policy = trustedTypes.defaultPolicy) try {
|
|
2857
|
+
return _policy.createHTML(html);
|
|
2858
|
+
} catch (_a) {}
|
|
2859
|
+
_policy = trustedTypes.createPolicy("ProseMirrorClipboard", {
|
|
2860
|
+
createHTML: function createHTML(s) {
|
|
2861
|
+
return s;
|
|
2862
|
+
}
|
|
2863
|
+
});
|
|
2864
|
+
}
|
|
2860
2865
|
return _policy.createHTML(html);
|
|
2861
2866
|
}
|
|
2862
2867
|
function readHTML(html) {
|
|
@@ -2907,6 +2912,11 @@ function addContext(slice, context) {
|
|
|
2907
2912
|
for (var i = array.length - 2; i >= 0; i -= 2) {
|
|
2908
2913
|
var type = schema.nodes[array[i]];
|
|
2909
2914
|
if (!type || type.hasRequiredAttrs()) break;
|
|
2915
|
+
try {
|
|
2916
|
+
type.checkAttrs(array[i + 1]);
|
|
2917
|
+
} catch (e) {
|
|
2918
|
+
break;
|
|
2919
|
+
}
|
|
2910
2920
|
content = prosemirrorModel.Fragment.from(type.create(array[i + 1], content));
|
|
2911
2921
|
openStart++;
|
|
2912
2922
|
openEnd++;
|
package/dist/index.js
CHANGED
|
@@ -1169,7 +1169,8 @@ class WidgetViewDesc extends ViewDesc {
|
|
|
1169
1169
|
wrap.appendChild(dom);
|
|
1170
1170
|
dom = wrap;
|
|
1171
1171
|
}
|
|
1172
|
-
dom.
|
|
1172
|
+
if (!dom.hasAttribute("contenteditable"))
|
|
1173
|
+
dom.contentEditable = "false";
|
|
1173
1174
|
dom.classList.add("ProseMirror-widget");
|
|
1174
1175
|
}
|
|
1175
1176
|
super(parent, [], dom, null);
|
|
@@ -3017,8 +3018,14 @@ function maybeWrapTrusted(html) {
|
|
|
3017
3018
|
// With the require-trusted-types-for CSP, Chrome will block
|
|
3018
3019
|
// innerHTML, even on a detached document. This wraps the string in
|
|
3019
3020
|
// a way that makes the browser allow us to use its parser again.
|
|
3020
|
-
if (!_policy)
|
|
3021
|
-
_policy = trustedTypes.defaultPolicy
|
|
3021
|
+
if (!_policy) {
|
|
3022
|
+
if (_policy = trustedTypes.defaultPolicy)
|
|
3023
|
+
try {
|
|
3024
|
+
return _policy.createHTML(html);
|
|
3025
|
+
}
|
|
3026
|
+
catch (_a) { }
|
|
3027
|
+
_policy = trustedTypes.createPolicy("ProseMirrorClipboard", { createHTML: (s) => s });
|
|
3028
|
+
}
|
|
3022
3029
|
return _policy.createHTML(html);
|
|
3023
3030
|
}
|
|
3024
3031
|
function readHTML(html) {
|
|
@@ -3075,6 +3082,12 @@ function addContext(slice, context) {
|
|
|
3075
3082
|
let type = schema.nodes[array[i]];
|
|
3076
3083
|
if (!type || type.hasRequiredAttrs())
|
|
3077
3084
|
break;
|
|
3085
|
+
try {
|
|
3086
|
+
type.checkAttrs(array[i + 1]);
|
|
3087
|
+
}
|
|
3088
|
+
catch (e) {
|
|
3089
|
+
break;
|
|
3090
|
+
}
|
|
3078
3091
|
content = Fragment.from(type.create(array[i + 1], content));
|
|
3079
3092
|
openStart++;
|
|
3080
3093
|
openEnd++;
|
package/package.json
CHANGED
package/src/clipboard.ts
CHANGED
|
@@ -215,8 +215,11 @@ function maybeWrapTrusted(html: string): string {
|
|
|
215
215
|
// With the require-trusted-types-for CSP, Chrome will block
|
|
216
216
|
// innerHTML, even on a detached document. This wraps the string in
|
|
217
217
|
// a way that makes the browser allow us to use its parser again.
|
|
218
|
-
if (!_policy)
|
|
219
|
-
_policy = trustedTypes.defaultPolicy
|
|
218
|
+
if (!_policy) {
|
|
219
|
+
if (_policy = trustedTypes.defaultPolicy)
|
|
220
|
+
try { return _policy.createHTML(html) } catch {}
|
|
221
|
+
_policy = trustedTypes.createPolicy("ProseMirrorClipboard", {createHTML: (s: string) => s})
|
|
222
|
+
}
|
|
220
223
|
return _policy.createHTML(html)
|
|
221
224
|
}
|
|
222
225
|
|
|
@@ -267,6 +270,8 @@ function addContext(slice: Slice, context: string) {
|
|
|
267
270
|
for (let i = array.length - 2; i >= 0; i -= 2) {
|
|
268
271
|
let type = schema.nodes[array[i]]
|
|
269
272
|
if (!type || type.hasRequiredAttrs()) break
|
|
273
|
+
try { type.checkAttrs(array[i + 1]) }
|
|
274
|
+
catch(e) { break }
|
|
270
275
|
content = Fragment.from(type.create(array[i + 1], content))
|
|
271
276
|
openStart++; openEnd++
|
|
272
277
|
}
|
package/src/viewdesc.ts
CHANGED
|
@@ -555,7 +555,8 @@ class WidgetViewDesc extends ViewDesc {
|
|
|
555
555
|
wrap.appendChild(dom)
|
|
556
556
|
dom = wrap
|
|
557
557
|
}
|
|
558
|
-
|
|
558
|
+
if (!(dom as HTMLElement).hasAttribute("contenteditable"))
|
|
559
|
+
(dom as HTMLElement).contentEditable = "false"
|
|
559
560
|
;(dom as HTMLElement).classList.add("ProseMirror-widget")
|
|
560
561
|
}
|
|
561
562
|
super(parent, [], dom, null)
|