actiontext 7.2.2.1 → 8.0.0.beta1

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: ae880abbc66a8b853cce05dc41d2962a78d7ce409fb7329a58f39bb1621cf4b2
4
- data.tar.gz: 0eed3fd02e87093e9520e90577fe1fd560e0ef7da9eaa7ccb1e49751d50362ba
3
+ metadata.gz: 47681928e4eb5de7fb4d7958ec7071174c8671e9750049693f8bc6a4742d90be
4
+ data.tar.gz: 162c998b362b84e68c0a404014c227a04925c3554de18ad66563dd3b00759040
5
5
  SHA512:
6
- metadata.gz: 9d2628de4f89b6f688536e657b1e89d058ae119b5c4f253b836cf51b96a35949bccc673e9a86f9e1dbc35013d66651534e1bb94460ce7374b88ef6575f22d5fa
7
- data.tar.gz: ad9de254ed7ab1ceb550c44fbae23a594e2abbcaf3533460eb9ecb0544eda5024c6f7c7d3d576c13511bfc11ada6b69f5a75bbf3e1c31cd6afcb1d6121733977
6
+ metadata.gz: 13900860666132a1931d50ce22c8cb65f5a39f09a65f7fcc893aece5c55b292d7c7c63735450da6181d3736944e1ce4610cb2407a24e6740991ddf0c30f2a3fe
7
+ data.tar.gz: 02ed293526d7691e072e5f8711e8fd69dabcf6c7aaa3dcaf01d07c29d09d43629acf60f6aa65d22a67727a1f5622ef4c3cfbc8bc69108cd8240fcbb1c960d9d8
data/CHANGELOG.md CHANGED
@@ -1,85 +1,44 @@
1
- ## Rails 7.2.2.1 (December 10, 2024) ##
1
+ ## Rails 8.0.0.beta1 (September 26, 2024) ##
2
2
 
3
- * Update vendored trix version to 2.1.10
3
+ * Dispatch direct-upload events on attachment uploads
4
4
 
5
- *John Hawthorn*
5
+ When using Action Text's rich textarea, it's possible to attach files to the
6
+ editor. Previously, that action didn't dispatch any events, which made it hard
7
+ to react to the file uploads. For instance, if an upload failed, there was no
8
+ way to notify the user about it, or remove the attachment from the editor.
6
9
 
10
+ This commits adds new events - `direct-upload:start`, `direct-upload:progress`,
11
+ and `direct-upload:end` - similar to how Active Storage's direct uploads work.
7
12
 
8
- ## Rails 7.2.2 (October 30, 2024) ##
13
+ *Matheus Richard*, *Brad Rees*
9
14
 
10
- * No changes.
15
+ * Add `store_if_blank` option to `has_rich_text`
11
16
 
17
+ Pass `store_if_blank: false` to not create `ActionText::RichText` records when saving with a blank attribute, such as from an optional form parameter.
12
18
 
13
- ## Rails 7.2.1.2 (October 23, 2024) ##
14
-
15
- * No changes.
16
-
17
-
18
- ## Rails 7.2.1.1 (October 15, 2024) ##
19
-
20
- * Avoid backtracing in plain_text_for_blockquote_node
21
-
22
- [CVE-2024-47888]
19
+ ```ruby
20
+ class Message
21
+ has_rich_text :content, store_if_blank: false
22
+ end
23
23
 
24
- *John Hawthorn*
24
+ Message.create(content: "hi") # creates an ActionText::RichText
25
+ Message.create(content: "") # does not create an ActionText::RichText
26
+ ```
25
27
 
26
- ## Rails 7.2.1 (August 22, 2024) ##
28
+ *Alex Ghiculescu*
27
29
 
28
30
  * Strip `content` attribute if the key is present but the value is empty
29
31
 
30
32
  *Jeremy Green*
31
33
 
34
+ * Rename `rich_text_area` methods into `rich_textarea`
32
35
 
33
- ## Rails 7.2.0 (August 09, 2024) ##
34
- * Only sanitize `content` attribute when present in attachments.
35
-
36
- *Petrik de Heus*
37
-
38
- * Sanitize ActionText HTML ContentAttachment in Trix edit view
39
- [CVE-2024-32464]
40
-
41
- *Aaron Patterson*, *Zack Deveau*
42
-
43
- * Use `includes` instead of `eager_load` for `with_all_rich_text`.
44
-
45
- *Petrik de Heus*
46
-
47
- * Delegate `ActionText::Content#deconstruct` to `Nokogiri::XML::DocumentFragment#elements`.
48
-
49
- ```ruby
50
- content = ActionText::Content.new <<~HTML
51
- <h1>Hello, world</h1>
52
-
53
- <div>The body</div>
54
- HTML
55
-
56
- content => [h1, div]
57
-
58
- assert_pattern { h1 => { content: "Hello, world" } }
59
- assert_pattern { div => { content: "The body" } }
60
- ```
36
+ Old names are still available as aliases.
61
37
 
62
38
  *Sean Doyle*
63
39
 
64
- * Fix all Action Text database related models to respect
65
- `ActiveRecord::Base.table_name_prefix` configuration.
66
-
67
- *Chedli Bourguiba*
68
-
69
- * Compile ESM package that can be used directly in the browser as actiontext.esm.js
70
-
71
- *Matias Grunberg*
72
-
73
- * Fix using actiontext.js with Sprockets.
74
-
75
- *Matias Grunberg*
76
-
77
- * Upgrade Trix to 2.0.7
78
-
79
- *Hartley McGuire*
80
-
81
- * Fix using Trix with Sprockets.
40
+ * Only sanitize `content` attribute when present in attachments.
82
41
 
83
- *Hartley McGuire*
42
+ *Petrik de Heus*
84
43
 
85
- Please check [7-1-stable](https://github.com/rails/rails/blob/7-1-stable/actiontext/CHANGELOG.md) for previous changes.
44
+ 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
  }