1
+ //
[email protected] downloaded from https://unpkg.com/
[email protected] /dist/trix.umd.js
2
+
1
3
/*
2
- Trix 2.1.14
4
+ Trix 2.1.15
3
5
Copyright © 2025 37signals, LLC
4
6
*/
5
7
(function (global, factory) {
@@ -9,7 +11,7 @@ Copyright © 2025 37signals, LLC
9
11
})(this, (function () { 'use strict';
10
12
11
13
var name = "trix";
12
- var version = "2.1.14 ";
14
+ var version = "2.1.15 ";
13
15
var description = "A rich text editor for everyday writing";
14
16
var main = "dist/trix.umd.min.js";
15
17
var module = "dist/trix.esm.min.js";
3091
3093
const DEFAULT_FORBIDDEN_PROTOCOLS = "javascript:".split(" ");
3092
3094
const DEFAULT_FORBIDDEN_ELEMENTS = "script iframe form noscript".split(" ");
3093
3095
class HTMLSanitizer extends BasicObject {
3094
- static setHTML(element, html) {
3095
- const sanitizedElement = new this(html).sanitize();
3096
+ static setHTML(element, html, options ) {
3097
+ const sanitizedElement = new this(html, options ).sanitize();
3096
3098
const sanitizedHtml = sanitizedElement.getHTML ? sanitizedElement.getHTML() : sanitizedElement.outerHTML;
3097
3099
element.innerHTML = sanitizedHtml;
3098
3100
}
@@ -3105,18 +3107,21 @@ $\
3105
3107
let {
3106
3108
allowedAttributes,
3107
3109
forbiddenProtocols,
3108
- forbiddenElements
3110
+ forbiddenElements,
3111
+ purifyOptions
3109
3112
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3110
3113
super(...arguments);
3111
3114
this.allowedAttributes = allowedAttributes || DEFAULT_ALLOWED_ATTRIBUTES;
3112
3115
this.forbiddenProtocols = forbiddenProtocols || DEFAULT_FORBIDDEN_PROTOCOLS;
3113
3116
this.forbiddenElements = forbiddenElements || DEFAULT_FORBIDDEN_ELEMENTS;
3117
+ this.purifyOptions = purifyOptions || {};
3114
3118
this.body = createBodyElementForHTML(html);
3115
3119
}
3116
3120
sanitize() {
3117
3121
this.sanitizeElements();
3118
3122
this.normalizeListElementNesting();
3119
- purify.setConfig(dompurify);
3123
+ const purifyConfig = Object.assign({}, dompurify, this.purifyOptions);
3124
+ purify.setConfig(purifyConfig);
3120
3125
this.body = purify.sanitize(this.body);
3121
3126
return this.body;
3122
3127
}
@@ -8369,11 +8374,13 @@ $\
8369
8374
}
8370
8375
constructor(html) {
8371
8376
let {
8372
- referenceElement
8377
+ referenceElement,
8378
+ purifyOptions
8373
8379
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
8374
8380
super(...arguments);
8375
8381
this.html = html;
8376
8382
this.referenceElement = referenceElement;
8383
+ this.purifyOptions = purifyOptions;
8377
8384
this.blocks = [];
8378
8385
this.blockElements = [];
8379
8386
this.processedElements = [];
8387
8394
parse() {
8388
8395
try {
8389
8396
this.createHiddenContainer();
8390
- HTMLSanitizer.setHTML(this.containerElement, this.html);
8397
+ HTMLSanitizer.setHTML(this.containerElement, this.html, {
8398
+ purifyOptions: this.purifyOptions
8399
+ });
8391
8400
const walker = walkTree(this.containerElement, {
8392
8401
usingFilter: nodeFilter
8393
8402
});
@@ -9067,7 +9076,11 @@ $\
9067
9076
}
9068
9077
}
9069
9078
insertHTML(html) {
9070
- const document = HTMLParser.parse(html).getDocument();
9079
+ const document = HTMLParser.parse(html, {
9080
+ purifyOptions: {
9081
+ SAFE_FOR_XML: true
9082
+ }
9083
+ }).getDocument();
9071
9084
const selectedRange = this.getSelectedRange();
9072
9085
this.setDocument(this.document.mergeDocumentAtRange(document, selectedRange));
9073
9086
const startPosition = selectedRange[0];
0 commit comments