actiontext 7.0.8.4 → 7.1.3.4
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of actiontext might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +56 -115
- data/MIT-LICENSE +1 -1
- data/README.md +2 -2
- data/app/assets/javascripts/actiontext.esm.js +889 -0
- data/app/assets/javascripts/actiontext.js +55 -73
- data/app/assets/javascripts/trix.js +12163 -19
- data/app/assets/stylesheets/trix.css +67 -30
- data/app/helpers/action_text/content_helper.rb +26 -4
- data/app/helpers/action_text/tag_helper.rb +11 -7
- data/app/models/action_text/encrypted_rich_text.rb +2 -0
- data/app/models/action_text/rich_text.rb +29 -1
- data/app/views/action_text/attachables/_content_attachment.html.erb +3 -0
- data/lib/action_text/attachable.rb +69 -5
- data/lib/action_text/attachables/content_attachment.rb +20 -18
- data/lib/action_text/attachables/missing_attachable.rb +17 -3
- data/lib/action_text/attachment.rb +43 -2
- data/lib/action_text/attribute.rb +10 -5
- data/lib/action_text/content.rb +45 -3
- data/lib/action_text/deprecator.rb +7 -0
- data/lib/action_text/engine.rb +15 -9
- data/lib/action_text/fixture_set.rb +2 -0
- data/lib/action_text/fragment.rb +4 -3
- data/lib/action_text/gem_version.rb +3 -3
- data/lib/action_text/html_conversion.rb +1 -1
- data/lib/action_text/rendering.rb +5 -2
- data/lib/action_text/trix_attachment.rb +2 -2
- data/lib/action_text/version.rb +1 -1
- data/lib/action_text.rb +19 -0
- data/lib/generators/action_text/install/install_generator.rb +21 -4
- data/lib/generators/action_text/install/templates/actiontext.css +0 -4
- data/package.json +7 -7
- metadata +15 -12
@@ -1,11 +1,7 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
(function (module, exports) {
|
6
|
-
(function(global, factory) {
|
7
|
-
factory(exports) ;
|
8
|
-
})(commonjsGlobal, (function(exports) {
|
1
|
+
(function(factory) {
|
2
|
+
typeof define === "function" && define.amd ? define(factory) : factory();
|
3
|
+
})((function() {
|
4
|
+
"use strict";
|
9
5
|
var sparkMd5 = {
|
10
6
|
exports: {}
|
11
7
|
};
|
@@ -506,7 +502,7 @@ var activestorage = {exports: {}};
|
|
506
502
|
}
|
507
503
|
}
|
508
504
|
class BlobRecord {
|
509
|
-
constructor(file, checksum, url) {
|
505
|
+
constructor(file, checksum, url, customHeaders = {}) {
|
510
506
|
this.file = file;
|
511
507
|
this.attributes = {
|
512
508
|
filename: file.name,
|
@@ -520,6 +516,9 @@ var activestorage = {exports: {}};
|
|
520
516
|
this.xhr.setRequestHeader("Content-Type", "application/json");
|
521
517
|
this.xhr.setRequestHeader("Accept", "application/json");
|
522
518
|
this.xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
|
519
|
+
Object.keys(customHeaders).forEach((headerKey => {
|
520
|
+
this.xhr.setRequestHeader(headerKey, customHeaders[headerKey]);
|
521
|
+
}));
|
523
522
|
const csrfToken = getMetaValue("csrf-token");
|
524
523
|
if (csrfToken != undefined) {
|
525
524
|
this.xhr.setRequestHeader("X-CSRF-Token", csrfToken);
|
@@ -599,11 +598,12 @@ var activestorage = {exports: {}};
|
|
599
598
|
}
|
600
599
|
let id = 0;
|
601
600
|
class DirectUpload {
|
602
|
-
constructor(file, url, delegate) {
|
601
|
+
constructor(file, url, delegate, customHeaders = {}) {
|
603
602
|
this.id = ++id;
|
604
603
|
this.file = file;
|
605
604
|
this.url = url;
|
606
605
|
this.delegate = delegate;
|
606
|
+
this.customHeaders = customHeaders;
|
607
607
|
}
|
608
608
|
create(callback) {
|
609
609
|
FileChecksum.create(this.file, ((error, checksum) => {
|
@@ -611,7 +611,7 @@ var activestorage = {exports: {}};
|
|
611
611
|
callback(error);
|
612
612
|
return;
|
613
613
|
}
|
614
|
-
const blob = new BlobRecord(this.file, checksum, this.url);
|
614
|
+
const blob = new BlobRecord(this.file, checksum, this.url, this.customHeaders);
|
615
615
|
notify(this.delegate, "directUploadWillCreateBlobWithXHR", blob.xhr);
|
616
616
|
blob.create((error => {
|
617
617
|
if (error) {
|
@@ -753,9 +753,9 @@ var activestorage = {exports: {}};
|
|
753
753
|
}
|
754
754
|
}
|
755
755
|
function didClick(event) {
|
756
|
-
const
|
757
|
-
if (
|
758
|
-
submitButtonsByForm.set(
|
756
|
+
const button = event.target.closest("button, input");
|
757
|
+
if (button && button.type === "submit" && button.form) {
|
758
|
+
submitButtonsByForm.set(button.form, button);
|
759
759
|
}
|
760
760
|
}
|
761
761
|
function didSubmitForm(event) {
|
@@ -818,63 +818,45 @@ var activestorage = {exports: {}};
|
|
818
818
|
}
|
819
819
|
}
|
820
820
|
setTimeout(autostart, 1);
|
821
|
-
|
822
|
-
|
823
|
-
|
824
|
-
|
825
|
-
|
826
|
-
}
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
|
832
|
-
|
833
|
-
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
|
843
|
-
|
844
|
-
}
|
845
|
-
|
846
|
-
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
}
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
url: this.createBlobUrl(attributes.signed_id, attributes.filename)
|
855
|
-
});
|
856
|
-
}
|
857
|
-
|
858
|
-
createBlobUrl(signedId, filename) {
|
859
|
-
return this.blobUrlTemplate
|
860
|
-
.replace(":signed_id", signedId)
|
861
|
-
.replace(":filename", encodeURIComponent(filename))
|
862
|
-
}
|
863
|
-
|
864
|
-
get directUploadUrl() {
|
865
|
-
return this.element.dataset.directUploadUrl
|
866
|
-
}
|
867
|
-
|
868
|
-
get blobUrlTemplate() {
|
869
|
-
return this.element.dataset.blobUrlTemplate
|
870
|
-
}
|
871
|
-
}
|
872
|
-
|
873
|
-
addEventListener("trix-attachment-add", event => {
|
874
|
-
const { attachment, target } = event;
|
875
|
-
|
876
|
-
if (attachment.file) {
|
877
|
-
const upload = new AttachmentUpload(attachment, target);
|
878
|
-
upload.start();
|
821
|
+
class AttachmentUpload {
|
822
|
+
constructor(attachment, element) {
|
823
|
+
this.attachment = attachment;
|
824
|
+
this.element = element;
|
825
|
+
this.directUpload = new DirectUpload(attachment.file, this.directUploadUrl, this);
|
826
|
+
}
|
827
|
+
start() {
|
828
|
+
this.directUpload.create(this.directUploadDidComplete.bind(this));
|
829
|
+
}
|
830
|
+
directUploadWillStoreFileWithXHR(xhr) {
|
831
|
+
xhr.upload.addEventListener("progress", (event => {
|
832
|
+
const progress = event.loaded / event.total * 100;
|
833
|
+
this.attachment.setUploadProgress(progress);
|
834
|
+
}));
|
835
|
+
}
|
836
|
+
directUploadDidComplete(error, attributes) {
|
837
|
+
if (error) {
|
838
|
+
throw new Error(`Direct upload failed: ${error}`);
|
839
|
+
}
|
840
|
+
this.attachment.setAttributes({
|
841
|
+
sgid: attributes.attachable_sgid,
|
842
|
+
url: this.createBlobUrl(attributes.signed_id, attributes.filename)
|
843
|
+
});
|
844
|
+
}
|
845
|
+
createBlobUrl(signedId, filename) {
|
846
|
+
return this.blobUrlTemplate.replace(":signed_id", signedId).replace(":filename", encodeURIComponent(filename));
|
847
|
+
}
|
848
|
+
get directUploadUrl() {
|
849
|
+
return this.element.dataset.directUploadUrl;
|
850
|
+
}
|
851
|
+
get blobUrlTemplate() {
|
852
|
+
return this.element.dataset.blobUrlTemplate;
|
853
|
+
}
|
879
854
|
}
|
880
|
-
|
855
|
+
addEventListener("trix-attachment-add", (event => {
|
856
|
+
const {attachment: attachment, target: target} = event;
|
857
|
+
if (attachment.file) {
|
858
|
+
const upload = new AttachmentUpload(attachment, target);
|
859
|
+
upload.start();
|
860
|
+
}
|
861
|
+
}));
|
862
|
+
}));
|