actiontext 7.2.3 → 8.0.5

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 869e5401e58b257f94f6048b071b07d381c61b7f07e218df68e46dc7c77fef85
4
- data.tar.gz: c96716739a2e88fc2a2a626b4fb6fd94aa678080866fb8bf3f62b9a41b757607
3
+ metadata.gz: '0349d2c780ecb15d7f62a3f118294e191700e23e0e62333da3e8b04d06e3823d'
4
+ data.tar.gz: 27e28a7f062489e3f20adc49bd38b4dc1f59e2d44bce16b644152bebf1e99e4e
5
5
  SHA512:
6
- metadata.gz: 45325a2ff01f0c41ba30de96633ba3391c8b04c0762d78092a3a2264e23f3ccdf6cb3c7dd1e922589423075d77e5200da7ce4ba06c92e38517e28fe0cf764bfb
7
- data.tar.gz: 5d01fbb40a0547e53b7e9284aed64c950304640370ef82a692878b5b80d1a05de9ca8bb036a80b91e054d662ba12952e2f6f18c2d5936611e685ad1f89995b8c
6
+ metadata.gz: b65e10fca9d0ceebc8955a8045efbc84abd326ec34590b5004fc183d98ef83693d62eabbb75b25da57c221bce37b8a65b48fec1d466f444ca1b23062c8214124
7
+ data.tar.gz: 7c331fe4354f2b44fc80891563f4057a313a3b4b9d90e76a51d6c2f3bd34f693e66c741ed6d00cd9fac730b0d8851f06745494cadce84e5a2fcd4f7d3fdb673f
data/CHANGELOG.md CHANGED
@@ -1,95 +1,107 @@
1
- ## Rails 7.2.3 (October 28, 2025) ##
1
+ ## Rails 8.0.5 (March 24, 2026) ##
2
2
 
3
3
  * No changes.
4
4
 
5
5
 
6
- ## Rails 7.2.2.2 (August 13, 2025) ##
6
+ ## Rails 8.0.4.1 (March 23, 2026) ##
7
7
 
8
8
  * No changes.
9
9
 
10
10
 
11
- ## Rails 7.2.2.1 (December 10, 2024) ##
11
+ ## Rails 8.0.4 (October 28, 2025) ##
12
12
 
13
- * Update vendored trix version to 2.1.10
13
+ * No changes.
14
14
 
15
- *John Hawthorn*
16
15
 
16
+ ## Rails 8.0.3 (September 22, 2025) ##
17
+
18
+ * Add rollup-plugin-terser as a dev dependency.
17
19
 
18
- ## Rails 7.2.2 (October 30, 2024) ##
20
+ *Édouard Chin*
21
+
22
+
23
+ ## Rails 8.0.2.1 (August 13, 2025) ##
19
24
 
20
25
  * No changes.
21
26
 
22
27
 
23
- ## Rails 7.2.1.2 (October 23, 2024) ##
28
+ ## Rails 8.0.2 (March 12, 2025) ##
29
+
30
+ * No changes.
31
+
32
+ ## Rails 8.0.2 (March 12, 2025) ##
24
33
 
25
34
  * No changes.
26
35
 
27
36
 
28
- ## Rails 7.2.1.1 (October 15, 2024) ##
37
+ ## Rails 8.0.1 (December 13, 2024) ##
38
+
39
+ * No changes.
40
+
29
41
 
30
- * Avoid backtracing in plain_text_for_blockquote_node
42
+ ## Rails 8.0.0.1 (December 10, 2024) ##
31
43
 
32
- [CVE-2024-47888]
44
+ * Update vendored trix version to 2.1.10
33
45
 
34
46
  *John Hawthorn*
35
47
 
36
- ## Rails 7.2.1 (August 22, 2024) ##
37
48
 
38
- * Strip `content` attribute if the key is present but the value is empty
49
+ ## Rails 8.0.0 (November 07, 2024) ##
39
50
 
40
- *Jeremy Green*
51
+ * No changes.
41
52
 
42
53
 
43
- ## Rails 7.2.0 (August 09, 2024) ##
44
- * Only sanitize `content` attribute when present in attachments.
54
+ ## Rails 8.0.0.rc2 (October 30, 2024) ##
45
55
 
46
- *Petrik de Heus*
56
+ * No changes.
47
57
 
48
- * Sanitize ActionText HTML ContentAttachment in Trix edit view
49
- [CVE-2024-32464]
50
58
 
51
- *Aaron Patterson*, *Zack Deveau*
59
+ ## Rails 8.0.0.rc1 (October 19, 2024) ##
52
60
 
53
- * Use `includes` instead of `eager_load` for `with_all_rich_text`.
61
+ * No changes.
54
62
 
55
- *Petrik de Heus*
56
63
 
57
- * Delegate `ActionText::Content#deconstruct` to `Nokogiri::XML::DocumentFragment#elements`.
64
+ ## Rails 8.0.0.beta1 (September 26, 2024) ##
58
65
 
59
- ```ruby
60
- content = ActionText::Content.new <<~HTML
61
- <h1>Hello, world</h1>
66
+ * Dispatch direct-upload events on attachment uploads
62
67
 
63
- <div>The body</div>
64
- HTML
68
+ When using Action Text's rich textarea, it's possible to attach files to the
69
+ editor. Previously, that action didn't dispatch any events, which made it hard
70
+ to react to the file uploads. For instance, if an upload failed, there was no
71
+ way to notify the user about it, or remove the attachment from the editor.
65
72
 
66
- content => [h1, div]
73
+ This commits adds new events - `direct-upload:start`, `direct-upload:progress`,
74
+ and `direct-upload:end` - similar to how Active Storage's direct uploads work.
67
75
 
68
- assert_pattern { h1 => { content: "Hello, world" } }
69
- assert_pattern { div => { content: "The body" } }
70
- ```
76
+ *Matheus Richard*, *Brad Rees*
71
77
 
72
- *Sean Doyle*
78
+ * Add `store_if_blank` option to `has_rich_text`
73
79
 
74
- * Fix all Action Text database related models to respect
75
- `ActiveRecord::Base.table_name_prefix` configuration.
80
+ Pass `store_if_blank: false` to not create `ActionText::RichText` records when saving with a blank attribute, such as from an optional form parameter.
76
81
 
77
- *Chedli Bourguiba*
82
+ ```ruby
83
+ class Message
84
+ has_rich_text :content, store_if_blank: false
85
+ end
86
+
87
+ Message.create(content: "hi") # creates an ActionText::RichText
88
+ Message.create(content: "") # does not create an ActionText::RichText
89
+ ```
78
90
 
79
- * Compile ESM package that can be used directly in the browser as actiontext.esm.js
91
+ *Alex Ghiculescu*
80
92
 
81
- *Matias Grunberg*
93
+ * Strip `content` attribute if the key is present but the value is empty
82
94
 
83
- * Fix using actiontext.js with Sprockets.
95
+ *Jeremy Green*
84
96
 
85
- *Matias Grunberg*
97
+ * Rename `rich_text_area` methods into `rich_textarea`
86
98
 
87
- * Upgrade Trix to 2.0.7
99
+ Old names are still available as aliases.
88
100
 
89
- *Hartley McGuire*
101
+ *Sean Doyle*
90
102
 
91
- * Fix using Trix with Sprockets.
103
+ * Only sanitize `content` attribute when present in attachments.
92
104
 
93
- *Hartley McGuire*
105
+ *Petrik de Heus*
94
106
 
95
- Please check [7-1-stable](https://github.com/rails/rails/blob/7-1-stable/actiontext/CHANGELOG.md) for previous changes.
107
+ Please check [7-2-stable](https://github.com/rails/rails/blob/7-2-stable/actiontext/CHANGELOG.md) for previous changes.
@@ -853,25 +853,47 @@ class AttachmentUpload {
853
853
  }
854
854
  start() {
855
855
  this.directUpload.create(this.directUploadDidComplete.bind(this));
856
+ this.dispatch("start");
856
857
  }
857
858
  directUploadWillStoreFileWithXHR(xhr) {
858
859
  xhr.upload.addEventListener("progress", (event => {
859
860
  const progress = event.loaded / event.total * 100;
860
861
  this.attachment.setUploadProgress(progress);
862
+ if (progress) {
863
+ this.dispatch("progress", {
864
+ progress: progress
865
+ });
866
+ }
861
867
  }));
862
868
  }
863
869
  directUploadDidComplete(error, attributes) {
864
870
  if (error) {
865
- throw new Error(`Direct upload failed: ${error}`);
871
+ this.dispatchError(error);
872
+ } else {
873
+ this.attachment.setAttributes({
874
+ sgid: attributes.attachable_sgid,
875
+ url: this.createBlobUrl(attributes.signed_id, attributes.filename)
876
+ });
877
+ this.dispatch("end");
866
878
  }
867
- this.attachment.setAttributes({
868
- sgid: attributes.attachable_sgid,
869
- url: this.createBlobUrl(attributes.signed_id, attributes.filename)
870
- });
871
879
  }
872
880
  createBlobUrl(signedId, filename) {
873
881
  return this.blobUrlTemplate.replace(":signed_id", signedId).replace(":filename", encodeURIComponent(filename));
874
882
  }
883
+ dispatch(name, detail = {}) {
884
+ detail.attachment = this.attachment;
885
+ return dispatchEvent(this.element, `direct-upload:${name}`, {
886
+ detail: detail
887
+ });
888
+ }
889
+ dispatchError(error) {
890
+ const event = this.dispatch("error", {
891
+ error: error
892
+ });
893
+ if (!event.defaultPrevented) {
894
+ alert(error);
895
+ }
896
+ }
875
897
  get directUploadUrl() {
876
898
  return this.element.dataset.directUploadUrl;
877
899
  }
@@ -826,25 +826,47 @@
826
826
  }
827
827
  start() {
828
828
  this.directUpload.create(this.directUploadDidComplete.bind(this));
829
+ this.dispatch("start");
829
830
  }
830
831
  directUploadWillStoreFileWithXHR(xhr) {
831
832
  xhr.upload.addEventListener("progress", (event => {
832
833
  const progress = event.loaded / event.total * 100;
833
834
  this.attachment.setUploadProgress(progress);
835
+ if (progress) {
836
+ this.dispatch("progress", {
837
+ progress: progress
838
+ });
839
+ }
834
840
  }));
835
841
  }
836
842
  directUploadDidComplete(error, attributes) {
837
843
  if (error) {
838
- throw new Error(`Direct upload failed: ${error}`);
844
+ this.dispatchError(error);
845
+ } else {
846
+ this.attachment.setAttributes({
847
+ sgid: attributes.attachable_sgid,
848
+ url: this.createBlobUrl(attributes.signed_id, attributes.filename)
849
+ });
850
+ this.dispatch("end");
839
851
  }
840
- this.attachment.setAttributes({
841
- sgid: attributes.attachable_sgid,
842
- url: this.createBlobUrl(attributes.signed_id, attributes.filename)
843
- });
844
852
  }
845
853
  createBlobUrl(signedId, filename) {
846
854
  return this.blobUrlTemplate.replace(":signed_id", signedId).replace(":filename", encodeURIComponent(filename));
847
855
  }
856
+ dispatch(name, detail = {}) {
857
+ detail.attachment = this.attachment;
858
+ return dispatchEvent(this.element, `direct-upload:${name}`, {
859
+ detail: detail
860
+ });
861
+ }
862
+ dispatchError(error) {
863
+ const event = this.dispatch("error", {
864
+ error: error
865
+ });
866
+ if (!event.defaultPrevented) {
867
+ alert(error);
868
+ }
869
+ }
848
870
  get directUploadUrl() {
849
871
  return this.element.dataset.directUploadUrl;
850
872
  }
@@ -1,5 +1,5 @@
1
1
  /*
2
- Trix 2.1.10
2
+ Trix 2.1.12
3
3
  Copyright © 2024 37signals, LLC
4
4
  */
5
5
  (function (global, factory) {
@@ -9,7 +9,7 @@ Copyright © 2024 37signals, LLC
9
9
  })(this, (function () { 'use strict';
10
10
 
11
11
  var name = "trix";
12
- var version = "2.1.10";
12
+ var version = "2.1.12";
13
13
  var description = "A rich text editor for everyday writing";
14
14
  var main = "dist/trix.umd.min.js";
15
15
  var module = "dist/trix.esm.min.js";
@@ -44,6 +44,7 @@ Copyright © 2024 37signals, LLC
44
44
  "@rollup/plugin-node-resolve": "^13.3.0",
45
45
  "@web/dev-server": "^0.1.34",
46
46
  "babel-eslint": "^10.1.0",
47
+ chokidar: "^4.0.2",
47
48
  concurrently: "^7.4.0",
48
49
  eslint: "^7.32.0",
49
50
  esm: "^3.2.25",
@@ -51,12 +52,12 @@ Copyright © 2024 37signals, LLC
51
52
  "karma-chrome-launcher": "3.2.0",
52
53
  "karma-qunit": "^4.1.2",
53
54
  "karma-sauce-launcher": "^4.3.6",
54
- "node-sass": "^7.0.1",
55
55
  qunit: "2.19.1",
56
56
  rangy: "^1.3.0",
57
57
  rollup: "^2.56.3",
58
58
  "rollup-plugin-includepaths": "^0.2.4",
59
59
  "rollup-plugin-terser": "^7.0.2",
60
+ sass: "^1.83.0",
60
61
  svgo: "^2.8.0",
61
62
  webdriverio: "^7.19.5"
62
63
  };
@@ -64,7 +65,7 @@ Copyright © 2024 37signals, LLC
64
65
  webdriverio: "^7.19.5"
65
66
  };
66
67
  var scripts = {
67
- "build-css": "node-sass --functions=./assets/trix/stylesheets/functions assets/trix.scss dist/trix.css",
68
+ "build-css": "bin/sass-build assets/trix.scss dist/trix.css",
68
69
  "build-js": "rollup -c",
69
70
  "build-assets": "cp -f assets/*.html dist/",
70
71
  build: "yarn run build-js && yarn run build-css && yarn run build-assets",
@@ -209,6 +210,12 @@ Copyright © 2024 37signals, LLC
209
210
  attachmentGallery: "attachment-gallery"
210
211
  };
211
212
 
213
+ var dompurify = {
214
+ ADD_ATTR: ["language"],
215
+ SAFE_FOR_XML: false,
216
+ RETURN_DOM: true
217
+ };
218
+
212
219
  var lang$1 = {
213
220
  attachFiles: "Attach Files",
214
221
  bold: "Bold",
@@ -631,7 +638,7 @@ Copyright © 2024 37signals, LLC
631
638
 
632
639
  var toolbar = {
633
640
  getDefaultHTML() {
634
- return "<div class=\"trix-button-row\">\n <span class=\"trix-button-group trix-button-group--text-tools\" data-trix-button-group=\"text-tools\">\n <button type=\"button\" class=\"trix-button trix-button--icon trix-button--icon-bold\" data-trix-attribute=\"bold\" data-trix-key=\"b\" title=\"".concat(lang$1.bold, "\" tabindex=\"-1\">").concat(lang$1.bold, "</button>\n <button type=\"button\" class=\"trix-button trix-button--icon trix-button--icon-italic\" data-trix-attribute=\"italic\" data-trix-key=\"i\" title=\"").concat(lang$1.italic, "\" tabindex=\"-1\">").concat(lang$1.italic, "</button>\n <button type=\"button\" class=\"trix-button trix-button--icon trix-button--icon-strike\" data-trix-attribute=\"strike\" title=\"").concat(lang$1.strike, "\" tabindex=\"-1\">").concat(lang$1.strike, "</button>\n <button type=\"button\" class=\"trix-button trix-button--icon trix-button--icon-link\" data-trix-attribute=\"href\" data-trix-action=\"link\" data-trix-key=\"k\" title=\"").concat(lang$1.link, "\" tabindex=\"-1\">").concat(lang$1.link, "</button>\n </span>\n\n <span class=\"trix-button-group trix-button-group--block-tools\" data-trix-button-group=\"block-tools\">\n <button type=\"button\" class=\"trix-button trix-button--icon trix-button--icon-heading-1\" data-trix-attribute=\"heading1\" title=\"").concat(lang$1.heading1, "\" tabindex=\"-1\">").concat(lang$1.heading1, "</button>\n <button type=\"button\" class=\"trix-button trix-button--icon trix-button--icon-quote\" data-trix-attribute=\"quote\" title=\"").concat(lang$1.quote, "\" tabindex=\"-1\">").concat(lang$1.quote, "</button>\n <button type=\"button\" class=\"trix-button trix-button--icon trix-button--icon-code\" data-trix-attribute=\"code\" title=\"").concat(lang$1.code, "\" tabindex=\"-1\">").concat(lang$1.code, "</button>\n <button type=\"button\" class=\"trix-button trix-button--icon trix-button--icon-bullet-list\" data-trix-attribute=\"bullet\" title=\"").concat(lang$1.bullets, "\" tabindex=\"-1\">").concat(lang$1.bullets, "</button>\n <button type=\"button\" class=\"trix-button trix-button--icon trix-button--icon-number-list\" data-trix-attribute=\"number\" title=\"").concat(lang$1.numbers, "\" tabindex=\"-1\">").concat(lang$1.numbers, "</button>\n <button type=\"button\" class=\"trix-button trix-button--icon trix-button--icon-decrease-nesting-level\" data-trix-action=\"decreaseNestingLevel\" title=\"").concat(lang$1.outdent, "\" tabindex=\"-1\">").concat(lang$1.outdent, "</button>\n <button type=\"button\" class=\"trix-button trix-button--icon trix-button--icon-increase-nesting-level\" data-trix-action=\"increaseNestingLevel\" title=\"").concat(lang$1.indent, "\" tabindex=\"-1\">").concat(lang$1.indent, "</button>\n </span>\n\n <span class=\"trix-button-group trix-button-group--file-tools\" data-trix-button-group=\"file-tools\">\n <button type=\"button\" class=\"trix-button trix-button--icon trix-button--icon-attach\" data-trix-action=\"attachFiles\" title=\"").concat(lang$1.attachFiles, "\" tabindex=\"-1\">").concat(lang$1.attachFiles, "</button>\n </span>\n\n <span class=\"trix-button-group-spacer\"></span>\n\n <span class=\"trix-button-group trix-button-group--history-tools\" data-trix-button-group=\"history-tools\">\n <button type=\"button\" class=\"trix-button trix-button--icon trix-button--icon-undo\" data-trix-action=\"undo\" data-trix-key=\"z\" title=\"").concat(lang$1.undo, "\" tabindex=\"-1\">").concat(lang$1.undo, "</button>\n <button type=\"button\" class=\"trix-button trix-button--icon trix-button--icon-redo\" data-trix-action=\"redo\" data-trix-key=\"shift+z\" title=\"").concat(lang$1.redo, "\" tabindex=\"-1\">").concat(lang$1.redo, "</button>\n </span>\n </div>\n\n <div class=\"trix-dialogs\" data-trix-dialogs>\n <div class=\"trix-dialog trix-dialog--link\" data-trix-dialog=\"href\" data-trix-dialog-attribute=\"href\">\n <div class=\"trix-dialog__link-fields\">\n <input type=\"url\" name=\"href\" class=\"trix-input trix-input--dialog\" placeholder=\"").concat(lang$1.urlPlaceholder, "\" aria-label=\"").concat(lang$1.url, "\" required data-trix-input>\n <div class=\"trix-button-group\">\n <input type=\"button\" class=\"trix-button trix-button--dialog\" value=\"").concat(lang$1.link, "\" data-trix-method=\"setAttribute\">\n <input type=\"button\" class=\"trix-button trix-button--dialog\" value=\"").concat(lang$1.unlink, "\" data-trix-method=\"removeAttribute\">\n </div>\n </div>\n </div>\n </div>");
641
+ return "<div class=\"trix-button-row\">\n <span class=\"trix-button-group trix-button-group--text-tools\" data-trix-button-group=\"text-tools\">\n <button type=\"button\" class=\"trix-button trix-button--icon trix-button--icon-bold\" data-trix-attribute=\"bold\" data-trix-key=\"b\" title=\"".concat(lang$1.bold, "\" tabindex=\"-1\">").concat(lang$1.bold, "</button>\n <button type=\"button\" class=\"trix-button trix-button--icon trix-button--icon-italic\" data-trix-attribute=\"italic\" data-trix-key=\"i\" title=\"").concat(lang$1.italic, "\" tabindex=\"-1\">").concat(lang$1.italic, "</button>\n <button type=\"button\" class=\"trix-button trix-button--icon trix-button--icon-strike\" data-trix-attribute=\"strike\" title=\"").concat(lang$1.strike, "\" tabindex=\"-1\">").concat(lang$1.strike, "</button>\n <button type=\"button\" class=\"trix-button trix-button--icon trix-button--icon-link\" data-trix-attribute=\"href\" data-trix-action=\"link\" data-trix-key=\"k\" title=\"").concat(lang$1.link, "\" tabindex=\"-1\">").concat(lang$1.link, "</button>\n </span>\n\n <span class=\"trix-button-group trix-button-group--block-tools\" data-trix-button-group=\"block-tools\">\n <button type=\"button\" class=\"trix-button trix-button--icon trix-button--icon-heading-1\" data-trix-attribute=\"heading1\" title=\"").concat(lang$1.heading1, "\" tabindex=\"-1\">").concat(lang$1.heading1, "</button>\n <button type=\"button\" class=\"trix-button trix-button--icon trix-button--icon-quote\" data-trix-attribute=\"quote\" title=\"").concat(lang$1.quote, "\" tabindex=\"-1\">").concat(lang$1.quote, "</button>\n <button type=\"button\" class=\"trix-button trix-button--icon trix-button--icon-code\" data-trix-attribute=\"code\" title=\"").concat(lang$1.code, "\" tabindex=\"-1\">").concat(lang$1.code, "</button>\n <button type=\"button\" class=\"trix-button trix-button--icon trix-button--icon-bullet-list\" data-trix-attribute=\"bullet\" title=\"").concat(lang$1.bullets, "\" tabindex=\"-1\">").concat(lang$1.bullets, "</button>\n <button type=\"button\" class=\"trix-button trix-button--icon trix-button--icon-number-list\" data-trix-attribute=\"number\" title=\"").concat(lang$1.numbers, "\" tabindex=\"-1\">").concat(lang$1.numbers, "</button>\n <button type=\"button\" class=\"trix-button trix-button--icon trix-button--icon-decrease-nesting-level\" data-trix-action=\"decreaseNestingLevel\" title=\"").concat(lang$1.outdent, "\" tabindex=\"-1\">").concat(lang$1.outdent, "</button>\n <button type=\"button\" class=\"trix-button trix-button--icon trix-button--icon-increase-nesting-level\" data-trix-action=\"increaseNestingLevel\" title=\"").concat(lang$1.indent, "\" tabindex=\"-1\">").concat(lang$1.indent, "</button>\n </span>\n\n <span class=\"trix-button-group trix-button-group--file-tools\" data-trix-button-group=\"file-tools\">\n <button type=\"button\" class=\"trix-button trix-button--icon trix-button--icon-attach\" data-trix-action=\"attachFiles\" title=\"").concat(lang$1.attachFiles, "\" tabindex=\"-1\">").concat(lang$1.attachFiles, "</button>\n </span>\n\n <span class=\"trix-button-group-spacer\"></span>\n\n <span class=\"trix-button-group trix-button-group--history-tools\" data-trix-button-group=\"history-tools\">\n <button type=\"button\" class=\"trix-button trix-button--icon trix-button--icon-undo\" data-trix-action=\"undo\" data-trix-key=\"z\" title=\"").concat(lang$1.undo, "\" tabindex=\"-1\">").concat(lang$1.undo, "</button>\n <button type=\"button\" class=\"trix-button trix-button--icon trix-button--icon-redo\" data-trix-action=\"redo\" data-trix-key=\"shift+z\" title=\"").concat(lang$1.redo, "\" tabindex=\"-1\">").concat(lang$1.redo, "</button>\n </span>\n </div>\n\n <div class=\"trix-dialogs\" data-trix-dialogs>\n <div class=\"trix-dialog trix-dialog--link\" data-trix-dialog=\"href\" data-trix-dialog-attribute=\"href\">\n <div class=\"trix-dialog__link-fields\">\n <input type=\"url\" name=\"href\" class=\"trix-input trix-input--dialog\" placeholder=\"").concat(lang$1.urlPlaceholder, "\" aria-label=\"").concat(lang$1.url, "\" data-trix-validate-href required data-trix-input>\n <div class=\"trix-button-group\">\n <input type=\"button\" class=\"trix-button trix-button--dialog\" value=\"").concat(lang$1.link, "\" data-trix-method=\"setAttribute\">\n <input type=\"button\" class=\"trix-button trix-button--dialog\" value=\"").concat(lang$1.unlink, "\" data-trix-method=\"removeAttribute\">\n </div>\n </div>\n </div>\n </div>");
635
642
  }
636
643
  };
637
644
 
@@ -645,6 +652,7 @@ Copyright © 2024 37signals, LLC
645
652
  blockAttributes: attributes,
646
653
  browser: browser$1,
647
654
  css: css$3,
655
+ dompurify: dompurify,
648
656
  fileSize: file_size_formatting,
649
657
  input: input,
650
658
  keyNames: key_names,
@@ -3064,6 +3072,12 @@ $\
3064
3072
  }
3065
3073
  var purify = createDOMPurify();
3066
3074
 
3075
+ purify.addHook("uponSanitizeAttribute", function (node, data) {
3076
+ const allowedAttributePattern = /^data-trix-/;
3077
+ if (allowedAttributePattern.test(data.attrName)) {
3078
+ data.forceKeepAttr = true;
3079
+ }
3080
+ });
3067
3081
  const DEFAULT_ALLOWED_ATTRIBUTES = "style href src width height language class".split(" ");
3068
3082
  const DEFAULT_FORBIDDEN_PROTOCOLS = "javascript:".split(" ");
3069
3083
  const DEFAULT_FORBIDDEN_ELEMENTS = "script iframe form noscript".split(" ");
@@ -3093,10 +3107,9 @@ $\
3093
3107
  sanitize() {
3094
3108
  this.sanitizeElements();
3095
3109
  this.normalizeListElementNesting();
3096
- return purify.sanitize(this.body, {
3097
- ADD_ATTR: ["language"],
3098
- RETURN_DOM: true
3099
- });
3110
+ purify.setConfig(dompurify);
3111
+ this.body = purify.sanitize(this.body);
3112
+ return this.body;
3100
3113
  }
3101
3114
  getHTML() {
3102
3115
  return this.body.innerHTML;
@@ -12626,16 +12639,26 @@ $\
12626
12639
  return (_this$delegate6 = this.delegate) === null || _this$delegate6 === void 0 ? void 0 : _this$delegate6.toolbarDidShowDialog(dialogName);
12627
12640
  }
12628
12641
  setAttribute(dialogElement) {
12642
+ var _this$delegate7;
12629
12643
  const attributeName = getAttributeName(dialogElement);
12630
12644
  const input = getInputForDialog(dialogElement, attributeName);
12631
- if (input.willValidate && !input.checkValidity()) {
12632
- input.setAttribute("data-trix-validate", "");
12633
- input.classList.add("trix-validate");
12634
- return input.focus();
12645
+ if (input.willValidate) {
12646
+ input.setCustomValidity("");
12647
+ if (!input.checkValidity() || !this.isSafeAttribute(input)) {
12648
+ input.setCustomValidity("Invalid value");
12649
+ input.setAttribute("data-trix-validate", "");
12650
+ input.classList.add("trix-validate");
12651
+ return input.focus();
12652
+ }
12653
+ }
12654
+ (_this$delegate7 = this.delegate) === null || _this$delegate7 === void 0 || _this$delegate7.toolbarDidUpdateAttribute(attributeName, input.value);
12655
+ return this.hideDialog();
12656
+ }
12657
+ isSafeAttribute(input) {
12658
+ if (input.hasAttribute("data-trix-validate-href")) {
12659
+ return purify.isValidAttribute("a", "href", input.value);
12635
12660
  } else {
12636
- var _this$delegate7;
12637
- (_this$delegate7 = this.delegate) === null || _this$delegate7 === void 0 || _this$delegate7.toolbarDidUpdateAttribute(attributeName, input.value);
12638
- return this.hideDialog();
12661
+ return true;
12639
12662
  }
12640
12663
  }
12641
12664
  removeAttribute(dialogElement) {