@rails/actiontext 7.0.3 → 7.0.4-1

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.
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@rails/actiontext",
3
- "version": "7.0.3",
3
+ "version": "7.0.4-1",
4
4
  "description": "Edit and display rich text in Rails applications",
5
- "main": "app/javascript/actiontext/index.js",
5
+ "main": "app/assets/javascripts/actiontext.js",
6
6
  "type": "module",
7
7
  "files": [
8
- "app/javascript/actiontext/*.js"
8
+ "app/assets/javascripts/*.js"
9
9
  ],
10
10
  "homepage": "https://rubyonrails.org/",
11
11
  "repository": {
@@ -1,45 +0,0 @@
1
- import { DirectUpload } from "@rails/activestorage"
2
-
3
- export class AttachmentUpload {
4
- constructor(attachment, element) {
5
- this.attachment = attachment
6
- this.element = element
7
- this.directUpload = new DirectUpload(attachment.file, this.directUploadUrl, this)
8
- }
9
-
10
- start() {
11
- this.directUpload.create(this.directUploadDidComplete.bind(this))
12
- }
13
-
14
- directUploadWillStoreFileWithXHR(xhr) {
15
- xhr.upload.addEventListener("progress", event => {
16
- const progress = event.loaded / event.total * 100
17
- this.attachment.setUploadProgress(progress)
18
- })
19
- }
20
-
21
- directUploadDidComplete(error, attributes) {
22
- if (error) {
23
- throw new Error(`Direct upload failed: ${error}`)
24
- }
25
-
26
- this.attachment.setAttributes({
27
- sgid: attributes.attachable_sgid,
28
- url: this.createBlobUrl(attributes.signed_id, attributes.filename)
29
- })
30
- }
31
-
32
- createBlobUrl(signedId, filename) {
33
- return this.blobUrlTemplate
34
- .replace(":signed_id", signedId)
35
- .replace(":filename", encodeURIComponent(filename))
36
- }
37
-
38
- get directUploadUrl() {
39
- return this.element.dataset.directUploadUrl
40
- }
41
-
42
- get blobUrlTemplate() {
43
- return this.element.dataset.blobUrlTemplate
44
- }
45
- }
@@ -1,10 +0,0 @@
1
- import { AttachmentUpload } from "./attachment_upload"
2
-
3
- addEventListener("trix-attachment-add", event => {
4
- const { attachment, target } = event
5
-
6
- if (attachment.file) {
7
- const upload = new AttachmentUpload(attachment, target)
8
- upload.start()
9
- }
10
- })