@blazetrails/actiontext 0.0.0-stage → 0.1.0-alpha0.2

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.
Files changed (155) hide show
  1. package/LICENSE +21 -0
  2. package/app/views/action-text/attachables/_content_attachment.html.tse +3 -0
  3. package/app/views/action-text/attachables/_missing_attachable.html.tse +1 -0
  4. package/app/views/action-text/attachables/_remote_image.html.tse +8 -0
  5. package/app/views/action-text/attachment-galleries/_attachment_gallery.html.tse +3 -0
  6. package/app/views/action-text/contents/_content.html.tse +1 -0
  7. package/app/views/active-storage/blobs/_blob.html.tse +14 -0
  8. package/app/views/layouts/action-text/contents/_content.html.tse +3 -0
  9. package/dist/.trails/views/action-text/attachables/_content_attachment.html.tse.js +35 -0
  10. package/dist/.trails/views/action-text/attachables/_content_attachment.html.tse.js.map +1 -0
  11. package/dist/.trails/views/action-text/attachables/_missing_attachable.html.tse.js +16 -0
  12. package/dist/.trails/views/action-text/attachables/_missing_attachable.html.tse.js.map +1 -0
  13. package/dist/.trails/views/action-text/attachables/_remote_image.html.tse.js +42 -0
  14. package/dist/.trails/views/action-text/attachables/_remote_image.html.tse.js.map +1 -0
  15. package/dist/.trails/views/action-text/attachment-galleries/_attachment_gallery.html.tse.js +37 -0
  16. package/dist/.trails/views/action-text/attachment-galleries/_attachment_gallery.html.tse.js.map +1 -0
  17. package/dist/.trails/views/action-text/contents/_content.html.tse.js +34 -0
  18. package/dist/.trails/views/action-text/contents/_content.html.tse.js.map +1 -0
  19. package/dist/.trails/views/active-storage/blobs/_blob.html.tse.js +57 -0
  20. package/dist/.trails/views/active-storage/blobs/_blob.html.tse.js.map +1 -0
  21. package/dist/.trails/views/layouts/action-text/contents/_content.html.tse.js +18 -0
  22. package/dist/.trails/views/layouts/action-text/contents/_content.html.tse.js.map +1 -0
  23. package/dist/action-text.js +73 -0
  24. package/dist/action-text.js.map +1 -0
  25. package/dist/app/helpers/action-text/content-helper.js +84 -0
  26. package/dist/app/helpers/action-text/content-helper.js.map +1 -0
  27. package/dist/app/helpers/action-text/tag-helper.js +115 -0
  28. package/dist/app/helpers/action-text/tag-helper.js.map +1 -0
  29. package/dist/app/views/action-text/attachables/_content_attachment.html.tse +3 -0
  30. package/dist/app/views/action-text/attachables/_missing_attachable.html.tse +1 -0
  31. package/dist/app/views/action-text/attachables/_remote_image.html.tse +8 -0
  32. package/dist/app/views/action-text/attachment-galleries/_attachment_gallery.html.tse +3 -0
  33. package/dist/app/views/action-text/contents/_content.html.tse +1 -0
  34. package/dist/app/views/active-storage/blobs/_blob.html.tse +14 -0
  35. package/dist/app/views/layouts/action-text/contents/_content.html.tse +3 -0
  36. package/dist/attachable.js +118 -0
  37. package/dist/attachable.js.map +1 -0
  38. package/dist/attachables/content-attachment.js +55 -0
  39. package/dist/attachables/content-attachment.js.map +1 -0
  40. package/dist/attachables/missing-attachable.js +30 -0
  41. package/dist/attachables/missing-attachable.js.map +1 -0
  42. package/dist/attachables/remote-image.js +46 -0
  43. package/dist/attachables/remote-image.js.map +1 -0
  44. package/dist/attachment-gallery.js +64 -0
  45. package/dist/attachment-gallery.js.map +1 -0
  46. package/dist/attachment.js +122 -0
  47. package/dist/attachment.js.map +1 -0
  48. package/dist/attachments/caching.js +17 -0
  49. package/dist/attachments/caching.js.map +1 -0
  50. package/dist/attachments/minification.js +15 -0
  51. package/dist/attachments/minification.js.map +1 -0
  52. package/dist/attachments/trix-conversion.js +37 -0
  53. package/dist/attachments/trix-conversion.js.map +1 -0
  54. package/dist/attribute.js +83 -0
  55. package/dist/attribute.js.map +1 -0
  56. package/dist/constants.action-text-install-install-generator.generated.js +4 -0
  57. package/dist/constants.action-text-install-install-generator.generated.js.map +1 -0
  58. package/dist/constants.encrypted-rich-text.generated.js +4 -0
  59. package/dist/constants.encrypted-rich-text.generated.js.map +1 -0
  60. package/dist/constants.engine.generated.js +4 -0
  61. package/dist/constants.engine.generated.js.map +1 -0
  62. package/dist/constants.generated.js +53 -0
  63. package/dist/constants.generated.js.map +1 -0
  64. package/dist/constants.rich-text.generated.js +4 -0
  65. package/dist/constants.rich-text.generated.js.map +1 -0
  66. package/dist/content.js +162 -0
  67. package/dist/content.js.map +1 -0
  68. package/dist/db/migrate/20180528164100_create_action_text_tables.js +31 -0
  69. package/dist/db/migrate/20180528164100_create_action_text_tables.js.map +1 -0
  70. package/dist/deprecator.js +8 -0
  71. package/dist/deprecator.js.map +1 -0
  72. package/dist/encrypted-rich-text.js +12 -0
  73. package/dist/encrypted-rich-text.js.map +1 -0
  74. package/dist/encryption.js +56 -0
  75. package/dist/encryption.js.map +1 -0
  76. package/dist/engine.js +125 -0
  77. package/dist/engine.js.map +1 -0
  78. package/dist/fixture-set.js +14 -0
  79. package/dist/fixture-set.js.map +1 -0
  80. package/dist/fragment.js +59 -0
  81. package/dist/fragment.js.map +1 -0
  82. package/dist/gem-version.js +18 -0
  83. package/dist/gem-version.js.map +1 -0
  84. package/dist/generators/action-text/install/install-generator.js +88 -0
  85. package/dist/generators/action-text/install/install-generator.js.map +1 -0
  86. package/dist/generators/action-text/install/templates/actiontext.css.tt +440 -0
  87. package/dist/generators/action-text/install/templates/actiontext.css.tt.js +12 -0
  88. package/dist/html-conversion.js +21 -0
  89. package/dist/html-conversion.js.map +1 -0
  90. package/dist/index.js +22 -0
  91. package/dist/index.js.map +1 -0
  92. package/dist/plain-text-conversion.js +126 -0
  93. package/dist/plain-text-conversion.js.map +1 -0
  94. package/dist/record.js +11 -0
  95. package/dist/record.js.map +1 -0
  96. package/dist/rendering.js +35 -0
  97. package/dist/rendering.js.map +1 -0
  98. package/dist/rich-text.js +70 -0
  99. package/dist/rich-text.js.map +1 -0
  100. package/dist/serialization.js +30 -0
  101. package/dist/serialization.js.map +1 -0
  102. package/dist/system-test-helper.js +38 -0
  103. package/dist/system-test-helper.js.map +1 -0
  104. package/dist/tasks/actiontext.rake.js +8 -0
  105. package/dist/tasks/actiontext.rake.js.map +1 -0
  106. package/dist/trails/generators/test-unit/install/install-generator.js +16 -0
  107. package/dist/trails/generators/test-unit/install/install-generator.js.map +1 -0
  108. package/dist/trails/generators/test-unit/install/templates/fixtures.yml.tt +4 -0
  109. package/dist/trails/generators/test-unit/install/templates/fixtures.yml.tt.js +12 -0
  110. package/dist/trix-attachment.js +105 -0
  111. package/dist/trix-attachment.js.map +1 -0
  112. package/dist/types/action-text.d.ts +75 -0
  113. package/dist/types/app/helpers/action-text/content-helper.d.ts +35 -0
  114. package/dist/types/app/helpers/action-text/tag-helper.d.ts +48 -0
  115. package/dist/types/attachable.d.ts +41 -0
  116. package/dist/types/attachables/content-attachment.d.ts +30 -0
  117. package/dist/types/attachables/missing-attachable.d.ts +9 -0
  118. package/dist/types/attachables/remote-image.d.ts +23 -0
  119. package/dist/types/attachment-gallery.d.ts +23 -0
  120. package/dist/types/attachment.d.ts +51 -0
  121. package/dist/types/attachments/caching.d.ts +15 -0
  122. package/dist/types/attachments/minification.d.ts +5 -0
  123. package/dist/types/attachments/trix-conversion.d.ts +17 -0
  124. package/dist/types/attribute.d.ts +27 -0
  125. package/dist/types/constants.action-text-install-install-generator.generated.d.ts +2 -0
  126. package/dist/types/constants.encrypted-rich-text.generated.d.ts +2 -0
  127. package/dist/types/constants.engine.generated.d.ts +2 -0
  128. package/dist/types/constants.generated.d.ts +2 -0
  129. package/dist/types/constants.rich-text.generated.d.ts +2 -0
  130. package/dist/types/content.d.ts +73 -0
  131. package/dist/types/db/migrate/20180528164100_create_action_text_tables.d.ts +9 -0
  132. package/dist/types/deprecator.d.ts +3 -0
  133. package/dist/types/encrypted-rich-text.d.ts +5 -0
  134. package/dist/types/encryption.d.ts +30 -0
  135. package/dist/types/engine.d.ts +28 -0
  136. package/dist/types/fixture-set.d.ts +6 -0
  137. package/dist/types/fragment.d.ts +19 -0
  138. package/dist/types/gem-version.d.ts +10 -0
  139. package/dist/types/generators/action-text/install/install-generator.d.ts +25 -0
  140. package/dist/types/html-conversion.d.ts +9 -0
  141. package/dist/types/index.d.ts +22 -0
  142. package/dist/types/plain-text-conversion.d.ts +41 -0
  143. package/dist/types/record.d.ts +4 -0
  144. package/dist/types/rendering.d.ts +15 -0
  145. package/dist/types/rich-text.d.ts +24 -0
  146. package/dist/types/serialization.d.ts +25 -0
  147. package/dist/types/system-test-helper.d.ts +18 -0
  148. package/dist/types/tasks/actiontext.rake.d.ts +2 -0
  149. package/dist/types/trails/generators/test-unit/install/install-generator.d.ts +5 -0
  150. package/dist/types/trix-attachment.d.ts +33 -0
  151. package/dist/types/version.d.ts +3 -0
  152. package/dist/version.js +7 -0
  153. package/dist/version.js.map +1 -0
  154. package/package.json +71 -3
  155. package/README.md +0 -3
@@ -0,0 +1,115 @@
1
+ import { delegate, humanize, mattrAccessor, stringifyKeys, tryCall, } from "@blazetrails/activesupport";
2
+ import { FormBuilder as ActionViewFormBuilder, FormHelper as ActionViewFormHelper, } from "@blazetrails/actionview/helpers/form-helper.js";
3
+ import { Base } from "@blazetrails/actionview/helpers/tags/base.js";
4
+ import { Placeholderable } from "@blazetrails/actionview/helpers/tags/placeholderable.js";
5
+ import { Translator } from "@blazetrails/actionview/helpers/tags/translator.js";
6
+ import { Tags } from "@blazetrails/actionview/namespaces.js";
7
+ import { ActionText as ActionTextNamespace } from "../../../action-text.js";
8
+ import { block, classModule, except, fetch, hashDelete, include, rbClearMethodCache, } from "@blazetrails/ruby-compat";
9
+ export class TagHelper {
10
+ /** @noRailsEquivalent PERMANENT */
11
+ static [classModule] = true;
12
+ static {
13
+ mattrAccessor.call(this, "id", { instanceAccessor: false, default: 0 });
14
+ }
15
+ /** @missingRailsArgs rails_service_blob_url — PERMANENT */
16
+ async richTextareaTag(name, value = null, options = {}) {
17
+ options = { ...options };
18
+ const form = hashDelete(options, "form");
19
+ if (options["input"] == null || options["input"] === false)
20
+ options["input"] = `trix_input_${(TagHelper.id += 1)}`;
21
+ if (options["class"] == null || options["class"] === false)
22
+ options["class"] = "trix-content";
23
+ if (options["data"] == null || options["data"] === false)
24
+ options["data"] = {};
25
+ const data = options["data"];
26
+ if (data["direct_upload_url"] == null || data["direct_upload_url"] === false) {
27
+ data["direct_upload_url"] = this.mainApp.trailsDirectUploadsUrl();
28
+ }
29
+ if (data["blob_url_template"] == null || data["blob_url_template"] === false) {
30
+ data["blob_url_template"] = this.mainApp.trailsServiceBlobUrl("::signed_id", "::filename");
31
+ }
32
+ const editorTag = this.contentTag("trix-editor", "", options);
33
+ const trixHtml = await tryCall(value, "toTrixHtml");
34
+ const inputTag = this.hiddenFieldTag(name, trixHtml != null && trixHtml !== false ? trixHtml : value, {
35
+ id: options["input"],
36
+ form,
37
+ });
38
+ return inputTag.plus(editorTag);
39
+ }
40
+ }
41
+ TagHelper.prototype.richTextAreaTag = TagHelper.prototype.richTextareaTag;
42
+ ActionTextNamespace.TagHelper = TagHelper;
43
+ export class ActionText extends Base {
44
+ /** @inlinedFrom ActionView::Helpers::Tags::Placeholderable#initialize rails/v8.0.5.2/actionview/lib/action_view/helpers/tags/placeholderable.rb:7-20 */
45
+ constructor(objectName, methodName, templateObject, options = {}) {
46
+ super(objectName, methodName, templateObject, options);
47
+ const tagValue = this._options["placeholder"];
48
+ if (tagValue != null && tagValue !== false) {
49
+ const isSymbol = typeof tagValue === "string" && tagValue.startsWith(":");
50
+ let placeholder = typeof tagValue === "string" && !isSymbol ? tagValue : null;
51
+ const methodAndValue = tagValue === true
52
+ ? this._methodName
53
+ : `${this._methodName}.${isSymbol ? tagValue.slice(1) : tagValue}`;
54
+ placeholder ??= new Translator(this.object, this._objectName, methodAndValue, {
55
+ scope: "helpers.placeholder",
56
+ }).translate();
57
+ placeholder ??= humanize(this._methodName);
58
+ this._options["placeholder"] = placeholder;
59
+ }
60
+ }
61
+ async render() {
62
+ const options = stringifyKeys(this._options);
63
+ this.addDefaultNameAndField(options);
64
+ if (this.object != null && this.object !== false) {
65
+ if (options["input"] == null || options["input"] === false) {
66
+ options["input"] = this.domId(this.object, [options["id"], "trix_input"].filter((x) => x != null).join("_"));
67
+ }
68
+ }
69
+ const htmlTag = await this._templateObject.richTextareaTag(hashDelete(options, "name"), fetch(options, "value", block(() => this.value())), except(options, "value"));
70
+ return this.errorWrapping(htmlTag);
71
+ }
72
+ }
73
+ include(ActionText, Placeholderable);
74
+ delegate.call(ActionText.prototype, "domId", { to: "::ActionView::RecordIdentifier" });
75
+ Tags.ActionText = ActionText;
76
+ export class FormHelper {
77
+ /** @noRailsEquivalent PERMANENT */
78
+ static [classModule] = true;
79
+ richTextarea(objectName, method, options = {}) {
80
+ return new Tags.ActionText(objectName, method, this, options).render();
81
+ }
82
+ }
83
+ FormHelper.prototype.richTextArea = FormHelper.prototype.richTextarea;
84
+ const formHelperMembers = {
85
+ richTextarea: FormHelper.prototype.richTextarea,
86
+ richTextArea: FormHelper.prototype.richTextArea,
87
+ };
88
+ for (const ref of ActionViewFormHelper._includers) {
89
+ const proto = ref.deref();
90
+ if (!proto) {
91
+ ActionViewFormHelper._includers.delete(ref);
92
+ continue;
93
+ }
94
+ for (const [name, method] of Object.entries(formHelperMembers)) {
95
+ const previous = Object.getOwnPropertyDescriptor(ActionViewFormHelper.prototype, name)?.value;
96
+ if (!Object.hasOwn(proto, name) || proto[name] === previous)
97
+ proto[name] = method;
98
+ }
99
+ }
100
+ Object.assign(ActionViewFormHelper.prototype, formHelperMembers);
101
+ rbClearMethodCache();
102
+ export class FormBuilder {
103
+ /** @noRailsEquivalent PERMANENT */
104
+ static [classModule] = true;
105
+ richTextarea(method, options = {}) {
106
+ return this._template.richTextarea(this.objectName, method, this.objectifyOptions(options));
107
+ }
108
+ }
109
+ FormBuilder.prototype.richTextArea = FormBuilder.prototype.richTextarea;
110
+ Object.assign(ActionViewFormBuilder.prototype, {
111
+ richTextarea: FormBuilder.prototype.richTextarea,
112
+ richTextArea: FormBuilder.prototype.richTextArea,
113
+ });
114
+ rbClearMethodCache();
115
+ //# sourceMappingURL=tag-helper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tag-helper.js","sourceRoot":"","sources":["../../../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AC,GAAG,IAAI,CAAC;IAErC,YAAY,CAAwB,MAAe,EAAE,OAAO,GAAY,EAAE;QACxE,OAAO,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC;IAC9F,CAAC;CAGF;AAED,WAAW,CAAC,SAAS,CAAC,YAAY,GAAG,WAAW,CAAC,SAAS,CAAC,YAAY,CAAC;AACxE,MAAM,CAAC,MAAM,CAAC,qBAAqB,CAAC,SAAS,EAAE;IAC7C,YAAY,EAAE,WAAW,CAAC,SAAS,CAAC,YAAY;IAChD,YAAY,EAAE,WAAW,CAAC,SAAS,CAAC,YAAY;CACjD,CAAC,CAAC;AACH,kBAAkB,EAAE,CAAC"}
@@ -0,0 +1,3 @@
1
+ <figure class="attachment attachment--content">
2
+ <%= await content_attachment.attachable.toString() %>
3
+ </figure>
@@ -0,0 +1,8 @@
1
+ <figure class="attachment attachment--preview">
2
+ <%= imageTag(remote_image.url, { width: remote_image.width, height: remote_image.height }) %>
3
+ <% const caption = remote_image.caption; if (caption != null) { %>
4
+ <figcaption class="attachment__caption">
5
+ <%= caption %>
6
+ </figcaption>
7
+ <% } %>
8
+ </figure>
@@ -0,0 +1,3 @@
1
+ <div class="attachment-gallery attachment-gallery--<%= await attachment_gallery.size() %>">
2
+ <%= yield() %>
3
+ </div>
@@ -0,0 +1 @@
1
+ <%= await renderActionTextContent(content) %>
@@ -0,0 +1,14 @@
1
+ <figure class="attachment attachment--<%= blob.isRepresentable() ? "preview" : "file" %> attachment--<%= blob.filename.extension() %>">
2
+ <% if (blob.isRepresentable()) { %>
3
+ <%= imageTag(blob.representation({ resizeToLimit: localAssigns.inGallery ? [ 800, 600 ] : [ 1024, 768 ] })) %>
4
+ <% } %>
5
+
6
+ <figcaption class="attachment__caption">
7
+ <% const caption = blob.caption; if (caption != null) { %>
8
+ <%= caption %>
9
+ <% } else { %>
10
+ <span class="attachment__name"><%= blob.filename %></span>
11
+ <span class="attachment__size"><%= numberToHumanSize(blob.byte_size) %></span>
12
+ <% } %>
13
+ </figcaption>
14
+ </figure>
@@ -0,0 +1,3 @@
1
+ <div class="trix-content">
2
+ <%= yield() -%>
3
+ </div>
@@ -0,0 +1,118 @@
1
+ import { Concern, extend, tryCall } from "@blazetrails/activesupport";
2
+ import { RecordNotFound } from "@blazetrails/activerecord";
3
+ import { Locator } from "@blazetrails/globalid";
4
+ import { rbCallSuper, rbObjRespondTo, toS } from "@blazetrails/ruby-compat";
5
+ import { ActionText } from "./action-text.js";
6
+ import { ContentAttachment } from "./attachables/content-attachment.js";
7
+ import { MissingAttachable } from "./attachables/missing-attachable.js";
8
+ import { RemoteImage } from "./attachables/remote-image.js";
9
+ function attributeNamesForSerialization() {
10
+ return [...rbCallSuper(this, attributeNamesForSerialization), "attachable_sgid"];
11
+ }
12
+ /** @missingRailsCall super — PERMANENT */
13
+ function readAttributeForSerialization(key) {
14
+ if (key === "attachable_sgid") {
15
+ return this.isPersisted() ? this.attachableSgid() : null;
16
+ }
17
+ else {
18
+ return rbCallSuper(this, readAttributeForSerialization, key);
19
+ }
20
+ }
21
+ export const Attachable = {
22
+ attachableSgid() {
23
+ return this.toSgid({ expiresIn: null, for: Attachable.LOCATOR_NAME }).toString();
24
+ },
25
+ attachableContentType() {
26
+ return tryCall(this, "contentType") ?? "application/octet-stream";
27
+ },
28
+ attachableFilename() {
29
+ if (rbObjRespondTo(this, "filename"))
30
+ return toS(this.filename);
31
+ return null;
32
+ },
33
+ attachableFilesize() {
34
+ return tryCall(this, "byteSize") ?? tryCall(this, "filesize");
35
+ },
36
+ attachableMetadata() {
37
+ return tryCall(this, "metadata") ?? {};
38
+ },
39
+ isPreviewableAttachable() {
40
+ return false;
41
+ },
42
+ toTrixContentAttachmentPartialPath() {
43
+ return this.toPartialPath();
44
+ },
45
+ toAttachablePartialPath() {
46
+ return this.toPartialPath();
47
+ },
48
+ toRichTextAttributes(attributes = {}) {
49
+ const attrs = { ...attributes };
50
+ attrs["sgid"] = this.attachableSgid();
51
+ attrs["contentType"] = this.attachableContentType();
52
+ if (this.isPreviewableAttachable())
53
+ attrs["previewable"] = true;
54
+ attrs["filename"] = this.attachableFilename();
55
+ attrs["filesize"] = this.attachableFilesize();
56
+ attrs["width"] = this.attachableMetadata()["width"];
57
+ attrs["height"] = this.attachableMetadata()["height"];
58
+ return Object.fromEntries(Object.entries(attrs).filter(([, v]) => v != null));
59
+ },
60
+ /** @internal */
61
+ attributeNamesForSerialization,
62
+ /** @internal */
63
+ readAttributeForSerialization,
64
+ };
65
+ extend(Attachable, Concern);
66
+ Object.defineProperty(Attachable, "LOCATOR_NAME", { value: "attachable", enumerable: false });
67
+ Object.defineProperty(Attachable, "fromNode", {
68
+ enumerable: false,
69
+ value: async function (node) {
70
+ let attachable;
71
+ if ((attachable = await Attachable.attachableFromSgid(node.get("sgid")))) {
72
+ return attachable;
73
+ }
74
+ else if ((attachable = await ContentAttachment.fromNode(node))) {
75
+ return attachable;
76
+ }
77
+ else if ((attachable = RemoteImage.fromNode(node))) {
78
+ return attachable;
79
+ }
80
+ else {
81
+ return new MissingAttachable(node.get("sgid"));
82
+ }
83
+ },
84
+ });
85
+ Object.defineProperty(Attachable, "fromAttachableSgid", {
86
+ enumerable: false,
87
+ value: async function (sgid, options = {}) {
88
+ const record = Array.isArray(sgid)
89
+ ? await Locator.locateManySigned(sgid, { ...options, for: Attachable.LOCATOR_NAME })
90
+ : await Locator.locateSigned(sgid, { ...options, for: Attachable.LOCATOR_NAME });
91
+ if (record == null)
92
+ throw new RecordNotFound();
93
+ return record;
94
+ },
95
+ });
96
+ Object.defineProperty(Attachable, "attachableFromSgid", {
97
+ enumerable: false,
98
+ value: async function (sgid) {
99
+ try {
100
+ return await Attachable.fromAttachableSgid(sgid);
101
+ }
102
+ catch (error) {
103
+ if (error instanceof RecordNotFound)
104
+ return null;
105
+ throw error;
106
+ }
107
+ },
108
+ });
109
+ Attachable.classMethods((mod) => {
110
+ mod.fromAttachableSgid = function (sgid) {
111
+ return Attachable.fromAttachableSgid(sgid, { only: this });
112
+ };
113
+ mod.toMissingAttachablePartialPath = function () {
114
+ return MissingAttachable.DEFAULT_PARTIAL_PATH;
115
+ };
116
+ });
117
+ ActionText.Attachable = Attachable;
118
+ //# sourceMappingURL=attachable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attachable.js","sourceRoot":"","sources":["../lib/attachable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAiB,MAAM,4BAA4B,CAAC;AACrF,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAEhD,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AACxE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAc5D,SAAS,8BAA8B;IACrC,OAAO,CAAC,GAAI,WAAW,CAAC,IAAI,EAAE,8BAA8B,CAAc,EAAE,iBAAiB,CAAC,CAAC;AACjG,CAAC;AAED,0CAA0C;AAC1C,SAAS,6BAA6B,CAAuB,GAAW;IACtE,IAAI,GAAG,KAAK,iBAAiB,EAAE,CAAC;QAC9B,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IAC3D,CAAC;SAAM,CAAC;QACN,OAAO,WAAW,CAAC,IAAI,EAAE,6BAA6B,EAAE,GAAG,CAAC,CAAC;IAC/D,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM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C7D,CAAC,CAAC;IAEF,GAAG,CAAC,8BAA8B,GAAG;QACnC,OAAO,iBAAiB,CAAC,oBAAoB,CAAC;IAChD,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,UAAU,CAAC,UAAU,GAAG,UAAU,CAAC"}
@@ -0,0 +1,55 @@
1
+ import { Model } from "@blazetrails/activemodel";
2
+ import { include } from "@blazetrails/activesupport";
3
+ import { ActionText } from "../action-text.js";
4
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
5
+ export class ContentAttachment {
6
+ /** @inlinedFrom ActiveModel::API#initialize rails/v8.0.5.2/activemodel/lib/active_model/api.rb:80-84 */
7
+ constructor(attributes = {}) {
8
+ if (attributes != null)
9
+ this.assignAttributes(attributes);
10
+ }
11
+ static async fromNode(node) {
12
+ const attachment = new this({
13
+ contentType: node.get("content-type"),
14
+ content: node.get("content"),
15
+ });
16
+ if (await attachment.isValid())
17
+ return attachment;
18
+ return null;
19
+ }
20
+ get contentType() {
21
+ return this._contentType;
22
+ }
23
+ set contentType(value) {
24
+ this._contentType = value;
25
+ }
26
+ get content() {
27
+ return this._content;
28
+ }
29
+ set content(value) {
30
+ this._content = value;
31
+ }
32
+ static {
33
+ include(this, Model);
34
+ this.validatesFormatOf("contentType", { with: /html/ });
35
+ this.validatesPresenceOf("content");
36
+ }
37
+ async attachablePlainTextRepresentation(_caption) {
38
+ return (await this.contentInstance()).fragment.source;
39
+ }
40
+ async toHtml() {
41
+ return (this._toHtml ??= await (await this.contentInstance()).render(await this.contentInstance()));
42
+ }
43
+ toString() {
44
+ return this.toHtml();
45
+ }
46
+ toPartialPath() {
47
+ return "action_text/attachables/content_attachment";
48
+ }
49
+ /** @internal */
50
+ async contentInstance() {
51
+ return (this._contentInstance ??= await ActionText.Content.new(this.content));
52
+ }
53
+ }
54
+ ActionText.Attachables.ContentAttachment = ContentAttachment;
55
+ //# sourceMappingURL=content-attachment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content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,iCAAiC,CAAC,QAAuB;QAC7D,OAAO,CAAC,MAAM,IAAI,CAAC,eAAe,EAAE,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC;IACxD,CAAC;IAED,KAAK,CAAC,MAAM;QACV,OAAO,CAAC,IAAI,CAAC,OAAO,KAAK,MAAM,CAC7B,MAAM,IAAI,CAAC,eAAe,EAAE,CAC7B,CAAC,MAAM,CAAC,MAAM,IAAI,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC;IAC1C,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC;IACvB,CAAC;IAED,aAAa;QACX,OAAO,4CAA4C,CAAC;IACtD,CAAC;IAED,gBAAgB;IACR,KAAK,CAAC,eAAe;QAC3B,OAAO,CAAC,IAAI,CAAC,gBAAgB,KAAK,MAAM,UAAU,CAAC,OAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;IACjF,CAAC;CACF;AAED,UAAU,CAAC,WAAW,CAAC,iBAAiB,GAAG,iBAAiB,CAAC"}
@@ -0,0 +1,30 @@
1
+ import { Naming } from "@blazetrails/activemodel";
2
+ import { extend, safeConstantize } from "@blazetrails/activesupport";
3
+ import { SignedGlobalID } from "@blazetrails/globalid";
4
+ import { toS } from "@blazetrails/ruby-compat";
5
+ import { ActionText } from "../action-text.js";
6
+ export class MissingAttachable {
7
+ static {
8
+ extend(this, Naming);
9
+ }
10
+ static DEFAULT_PARTIAL_PATH = "action_text/attachables/missing_attachable";
11
+ /** @internal */
12
+ sgid;
13
+ constructor(sgid) {
14
+ this.sgid = SignedGlobalID.parse(sgid, { for: ActionText.Attachable.LOCATOR_NAME });
15
+ }
16
+ toPartialPath() {
17
+ const model = this.model();
18
+ if (model != null) {
19
+ return model.toMissingAttachablePartialPath();
20
+ }
21
+ else {
22
+ return MissingAttachable.DEFAULT_PARTIAL_PATH;
23
+ }
24
+ }
25
+ model() {
26
+ return safeConstantize(toS(this.sgid?.modelName));
27
+ }
28
+ }
29
+ ActionText.Attachables.MissingAttachable = MissingAttachable;
30
+ //# sourceMappingURL=missing-attachable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"missing-attachable.js","sourceRoot":"","sources":["../../lib/attachables/missing-attachable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,MAAM,OAAO,iBAAiB;IAC5B;QACE,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACvB,CAAC;IAED,MAAM,CAAU,oBAAoB,GAAG,4CAA4C,CAAC;IAEpF,gBAAgB;IACC,IAAI,CAAwB;IAE7C,YAAY,IAAa;QACvB,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC,KAAK,CAAC,IAAc,EAAE,EAAE,GAAG,EAAE,UAAU,CAAC,UAAW,CAAC,YAAY,EAAE,CAAC,CAAC;IACjG,CAAC;IAED,aAAa;QACX,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC;QAC3B,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;YAClB,OACE,KACD,CAAC,8BAA8B,EAAE,CAAC;QACrC,CAAC;aAAM,CAAC;YACN,OAAO,iBAAiB,CAAC,oBAAoB,CAAC;QAChD,CAAC;IACH,CAAC;IAED,KAAK;QACH,OAAO,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC;IACpD,CAAC;CACF;AAED,UAAU,CAAC,WAAW,CAAC,iBAAiB,GAAG,iBAAiB,CAAC"}
@@ -0,0 +1,46 @@
1
+ import { Naming } from "@blazetrails/activemodel";
2
+ import { extend } from "@blazetrails/activesupport";
3
+ import { toS } from "@blazetrails/ruby-compat";
4
+ import { ActionText } from "../action-text.js";
5
+ export class RemoteImage {
6
+ static {
7
+ extend(this, Naming);
8
+ }
9
+ static fromNode(node) {
10
+ if (node.get("url") != null && this.isContentTypeIsImage(node.get("content-type"))) {
11
+ return new this(this.attributesFromNode(node));
12
+ }
13
+ return null;
14
+ }
15
+ /** @internal */
16
+ static isContentTypeIsImage(contentType) {
17
+ return /^image(\/.+|$)/m.test(toS(contentType));
18
+ }
19
+ /** @internal */
20
+ static attributesFromNode(node) {
21
+ return {
22
+ url: node.get("url"),
23
+ contentType: node.get("content-type"),
24
+ width: node.get("width"),
25
+ height: node.get("height"),
26
+ };
27
+ }
28
+ url;
29
+ contentType;
30
+ width;
31
+ height;
32
+ constructor(attributes = {}) {
33
+ this.url = attributes.url;
34
+ this.contentType = attributes.contentType;
35
+ this.width = attributes.width;
36
+ this.height = attributes.height;
37
+ }
38
+ attachablePlainTextRepresentation(caption) {
39
+ return `[${caption ?? "Image"}]`;
40
+ }
41
+ toPartialPath() {
42
+ return "action_text/attachables/remote_image";
43
+ }
44
+ }
45
+ ActionText.Attachables.RemoteImage = RemoteImage;
46
+ //# sourceMappingURL=remote-image.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remote-image.js","sourceRoot":"","sources":["../../lib/attachables/remote-image.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAEpD,OAAO,EAAE,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAS/C,MAAM,OAAO,WAAW;IACtB;QACE,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACvB,CAAC;IAED,MAAM,CAAC,QAAQ,CAAC,IAAe;QAC7B,IAAI,IAAI,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AC"}
@@ -0,0 +1,64 @@
1
+ import { Model } from "@blazetrails/activemodel";
2
+ import { include } from "@blazetrails/activesupport";
3
+ import { rbInspect, rbModName, toS } from "@blazetrails/ruby-compat";
4
+ import { ActionText } from "./action-text.js";
5
+ import { Fragment } from "./fragment.js";
6
+ const TAG_NAME = "div";
7
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
8
+ export class AttachmentGallery {
9
+ static {
10
+ include(this, Model);
11
+ }
12
+ static fragmentByCanonicalizingAttachmentGalleries(content) {
13
+ return this.fragmentByReplacingAttachmentGalleryNodes(content, (node) => `<${TAG_NAME}>${node.innerHtml()}</${TAG_NAME}>`);
14
+ }
15
+ static async fragmentByReplacingAttachmentGalleryNodes(content, block) {
16
+ return Fragment.wrap(content).update(async (source) => {
17
+ for (const node of this.findAttachmentGalleryNodes(source)) {
18
+ node.replace(toS(await block(node)));
19
+ }
20
+ });
21
+ }
22
+ static findAttachmentGalleryNodes(content) {
23
+ return Fragment.wrap(content)
24
+ .findAll(this.selector())
25
+ .toA()
26
+ .filter((node) => node.children.toA().every((child) => {
27
+ if (child.isText()) {
28
+ return /^(\n| )*$/.test(child.text);
29
+ }
30
+ else {
31
+ return child.isMatches(this.attachmentSelector());
32
+ }
33
+ }));
34
+ }
35
+ static fromNode(node) {
36
+ return new this(node);
37
+ }
38
+ static attachmentSelector() {
39
+ return `${ActionText.Attachment.tagName}[presentation=gallery]`;
40
+ }
41
+ static selector() {
42
+ return `${TAG_NAME}:has(${this.attachmentSelector()} + ${this.attachmentSelector()})`;
43
+ }
44
+ node;
45
+ /** @internal */
46
+ _attachments;
47
+ constructor(node) {
48
+ this.node = node;
49
+ }
50
+ async attachments() {
51
+ return (this._attachments ??= await Promise.all(this.node
52
+ .css(AttachmentGallery.attachmentSelector())
53
+ .toA()
54
+ .map(async (node) => (await ActionText.Attachment.fromNode(node)).withFullAttributes())));
55
+ }
56
+ async size() {
57
+ return (await this.attachments()).length;
58
+ }
59
+ async inspect() {
60
+ return `#<${rbModName(this.constructor)} size=${rbInspect(await this.size())}>`;
61
+ }
62
+ }
63
+ ActionText.AttachmentGallery = AttachmentGallery;
64
+ //# sourceMappingURL=attachment-gallery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attachment-gallery.js","sourceRoot":"","sources":["../lib/attachment-gallery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAErD,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,MAAM,QAAQ,GAAG,KAAK,CAAC;AAKvB,4EAA4E;AAC5E,MAAM,OAAO,iBAAiB;IAG5B;QACE,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACvB,CAAC;IAED,MAAM,CAAC,2CAA2C,CAAC,OAAgB;QACjE,OAAO,IAAI,CAAC,yCAAyC,CACnD,OAAO,EACP,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,QAAQ,IAAI,IAAI,CAAC,SAAS,EAAE,KAAK,QAAQ,GAAG,CAC3D,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,yCAAyC,CACpD,OAAgB,EAChB,KAAmC;QAEnC,OAAO,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE;YACpD,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,0BAA0B,CAAC,MAAM,CAAC,EAAE,CAAC;gBAC3D,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YACvC,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAA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AE,EAAE,CAAC,CAAC,MAAM,UAAU,CAAC,UAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,kBAAkB,EAAE,CAAC,CAC3F,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,IAAI;QACR,OAAO,CAAC,MAAM,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC;IAC3C,CAAC;IAED,KAAK,CAAC,OAAO;QACX,OAAO,KAAK,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,SAAS,SAAS,CAAC,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC;IAClF,CAAC;CACF;AAED,UAAU,CAAC,iBAAiB,GAAG,iBAAiB,CAAC"}
@@ -0,0 +1,122 @@
1
+ import { dasherize, delegate, delegateMissingTo, include, mattrAccessor, presence, stringifyKeys, tryCall, underscore, } from "@blazetrails/activesupport";
2
+ import { filterMap, rbFArray, rbInspect, rbModName, rbObjRespondTo, slice, toS, } from "@blazetrails/ruby-compat";
3
+ import { ActionText } from "./action-text.js";
4
+ import { Caching } from "./attachments/caching.js";
5
+ import { Minification } from "./attachments/minification.js";
6
+ import { TrixConversion } from "./attachments/trix-conversion.js";
7
+ import { HtmlConversion } from "./html-conversion.js";
8
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging -- see the interface above.
9
+ export class Attachment {
10
+ static {
11
+ include(this, TrixConversion);
12
+ include(this, Minification);
13
+ include(this, Caching);
14
+ mattrAccessor.call(this, "tagName", { default: "action-text-attachment" });
15
+ }
16
+ static ATTRIBUTES = [
17
+ "sgid",
18
+ "content-type",
19
+ "url",
20
+ "href",
21
+ "filename",
22
+ "filesize",
23
+ "width",
24
+ "height",
25
+ "previewable",
26
+ "presentation",
27
+ "caption",
28
+ "content",
29
+ ];
30
+ static async fragmentByCanonicalizingAttachments(content) {
31
+ return this.fragmentByMinifyingAttachments(await this.fragmentByConvertingTrixAttachments(content));
32
+ }
33
+ static async fromNode(node, attachable = null) {
34
+ return new this(node, attachable != null && attachable !== false
35
+ ? attachable
36
+ : await ActionText.Attachable.fromNode(node));
37
+ }
38
+ static fromAttachables(attachables) {
39
+ return filterMap(rbFArray(attachables), (attachable) => this.fromAttachable(attachable));
40
+ }
41
+ static fromAttachable(attachable, attributes = {}) {
42
+ const node = this.nodeFromAttributes(attachable.toRichTextAttributes(attributes));
43
+ if (node != null) {
44
+ return new this(node, attachable);
45
+ }
46
+ return null;
47
+ }
48
+ static async fromAttributes(attributes, attachable = null) {
49
+ const node = this.nodeFromAttributes(attributes);
50
+ if (node != null) {
51
+ return this.fromNode(node, attachable);
52
+ }
53
+ return null;
54
+ }
55
+ /** @internal */
56
+ static nodeFromAttributes(attributes) {
57
+ const processed = presence(this.processAttributes(attributes));
58
+ if (processed != null) {
59
+ return HtmlConversion.createElement(this.tagName, processed);
60
+ }
61
+ return null;
62
+ }
63
+ /** @internal */
64
+ static processAttributes(attributes) {
65
+ return slice(Object.fromEntries(Object.entries(attributes).map(([key, value]) => [dasherize(underscore(toS(key))), value])), ...this.ATTRIBUTES);
66
+ }
67
+ node;
68
+ attachable;
69
+ /** @internal */
70
+ _nodeAttributes;
71
+ /** @internal */
72
+ _attachableAttributes;
73
+ /** @internal */
74
+ _sgidAttributes;
75
+ constructor(node, attachable) {
76
+ this.node = node;
77
+ this.attachable = attachable;
78
+ }
79
+ get caption() {
80
+ return presence(this.nodeAttributes()["caption"] ?? null);
81
+ }
82
+ fullAttributes() {
83
+ return { ...this.nodeAttributes(), ...this.attachableAttributes(), ...this.sgidAttributes() };
84
+ }
85
+ withFullAttributes() {
86
+ return this.constructor.fromAttributes(this.fullAttributes(), this.attachable);
87
+ }
88
+ async toPlainText() {
89
+ if (rbObjRespondTo(this, "attachablePlainTextRepresentation")) {
90
+ return this.attachablePlainTextRepresentation(this.caption);
91
+ }
92
+ else {
93
+ return toS(this.caption);
94
+ }
95
+ }
96
+ toHtml() {
97
+ return HtmlConversion.nodeToHtml(this.node);
98
+ }
99
+ toString() {
100
+ return this.toHtml();
101
+ }
102
+ inspect() {
103
+ return `#<${rbModName(this.constructor)} attachable=${rbInspect(this.attachable)}>`;
104
+ }
105
+ /** @internal */
106
+ nodeAttributes() {
107
+ return (this._nodeAttributes ??= Object.fromEntries(Attachment.ATTRIBUTES.map((name) => [underscore(name), this.node.get(name)]).filter(([, value]) => value != null)));
108
+ }
109
+ /** @internal */
110
+ attachableAttributes() {
111
+ return (this._attachableAttributes ??= stringifyKeys(tryCall(this.attachable, "toRichTextAttributes") ?? {}));
112
+ }
113
+ /** @internal */
114
+ sgidAttributes() {
115
+ return (this._sgidAttributes ??=
116
+ presence(slice(this.nodeAttributes(), "sgid")) ?? slice(this.attachableAttributes(), "sgid"));
117
+ }
118
+ }
119
+ delegate.call(Attachment.prototype, "toParam", { to: "attachable" });
120
+ delegateMissingTo.call(Attachment, "attachable");
121
+ ActionText.Attachment = Attachment;
122
+ //# sourceMappingURL=attachment.js.map