actiontext 7.2.1.1 → 8.0.0.rc1

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