avo-rhino_field 0.0.11 → 0.0.13
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 +4 -4
- data/app/assets/builds/avo-rhino_field.js +312 -0
- data/app/assets/builds/avo-rhino_field.js.map +4 -4
- data/app/components/avo/fields/rhino_field/edit_component.html.erb +14 -9
- data/app/components/avo/fields/rhino_field/edit_component.rb +20 -3
- data/lib/avo/rhino_field/engine.rb +1 -1
- data/lib/avo/rhino_field/version.rb +1 -1
- metadata +2 -2
@@ -1,14 +1,9 @@
|
|
1
1
|
<%= field_wrapper **field_wrapper_args, full_width: true do %>
|
2
2
|
<%= content_tag :div, class: "relative block overflow-x-auto max-w-4xl" do %>
|
3
3
|
<%= content_tag 'avo-rhino-editor',
|
4
|
-
data
|
5
|
-
|
6
|
-
|
7
|
-
direct_upload_url: helpers.main_app.rails_direct_uploads_url,
|
8
|
-
action: "rhino-before-initialize->rhino-field#onRhinoBeforeInitialize rhino-initialize->rhino-field#onRhinoInitialize rhino-change->rhino-field#onRhinoChange rhino-paste->rhino-field#onRhinoPaste rhino-selection-change->rhino-field#onRhinoSelectionChange rhino-focus->rhino-field#onRhinoFocus rhino-blur->rhino-field#onRhinoBlur rhino-file-accept->rhino-field#onRhinoFileAccept rhino-attachment-add->rhino-field#onRhinoAttachmentAdd rhino-attachment-remove->rhino-field#onRhinoAttachmentRemove",
|
9
|
-
**@field.get_html(:data, view: view, element: :input)
|
10
|
-
},
|
11
|
-
input: field_id,
|
4
|
+
data:,
|
5
|
+
input: unique_id,
|
6
|
+
class: class_names(unique_id),
|
12
7
|
placeholder: @field.placeholder do %>
|
13
8
|
<button
|
14
9
|
type="button"
|
@@ -44,13 +39,23 @@
|
|
44
39
|
class="h-3.5 w-5 bg-transparent -mt-px -mb-1"
|
45
40
|
/>
|
46
41
|
</button>
|
42
|
+
<button
|
43
|
+
type="button"
|
44
|
+
slot="before-attach-files-button"
|
45
|
+
class="toolbar__button rhino-toolbar-button flex flex-col items-center grow-0 text-sm hidden-until-rhino-boots-up"
|
46
|
+
data-role="toolbar-item"
|
47
|
+
tabindex="-1"
|
48
|
+
data-action="click->rhino-field#openGallery"
|
49
|
+
>
|
50
|
+
<%= helpers.svg "heroicons/outline/photo", class: "!min-h-4 !max-h-4" %>
|
51
|
+
</button>
|
47
52
|
<% end %>
|
48
53
|
<%= @form.text_area @field.id,
|
49
54
|
value: @field.value.try(:to_trix_html) || @field.value,
|
50
55
|
class: classes("w-full hidden"),
|
51
56
|
data: @field.get_html(:data, view: view, element: :input),
|
52
57
|
disabled: disabled?,
|
53
|
-
id:
|
58
|
+
id: unique_id,
|
54
59
|
placeholder: @field.placeholder,
|
55
60
|
style: @field.get_html(:style, view: view, element: :input)
|
56
61
|
%>
|
@@ -9,13 +9,30 @@ class Avo::Fields::RhinoField::EditComponent < Avo::Fields::EditComponent
|
|
9
9
|
@resource_name = args[:resource_name] || @resource&.singular_route_key
|
10
10
|
|
11
11
|
super(**args)
|
12
|
+
|
13
|
+
@unique_random_id = SecureRandom.hex(4)
|
12
14
|
end
|
13
15
|
|
14
|
-
def
|
16
|
+
def unique_id
|
15
17
|
if @resource_name.present?
|
16
|
-
"rhino_#{@resource_name}_#{@field.id}"
|
18
|
+
"rhino_#{@resource_name}_#{@field.id}_#{@unique_random_id}"
|
17
19
|
elsif form.present?
|
18
|
-
"rhino_#{form.index}_#{@field.id}"
|
20
|
+
"rhino_#{form.index}_#{@field.id}_#{@unique_random_id}"
|
19
21
|
end
|
20
22
|
end
|
23
|
+
|
24
|
+
def unique_selector = ".#{unique_id}"
|
25
|
+
|
26
|
+
def data
|
27
|
+
{
|
28
|
+
controller: "rhino-field",
|
29
|
+
rhino_field_unique_selector_value: unique_selector, # mandatory
|
30
|
+
rhino_field_resource_name_value: @resource_name,
|
31
|
+
rhino_field_resource_id_value: @resource_id,
|
32
|
+
blob_url_template: helpers.main_app.rails_service_blob_url(":signed_id", ":filename"),
|
33
|
+
direct_upload_url: helpers.main_app.rails_direct_uploads_url,
|
34
|
+
action: "rhino-before-initialize->rhino-field#onRhinoBeforeInitialize rhino-initialize->rhino-field#onRhinoInitialize rhino-change->rhino-field#onRhinoChange rhino-paste->rhino-field#onRhinoPaste rhino-selection-change->rhino-field#onRhinoSelectionChange rhino-focus->rhino-field#onRhinoFocus rhino-blur->rhino-field#onRhinoBlur rhino-file-accept->rhino-field#onRhinoFileAccept rhino-attachment-add->rhino-field#onRhinoAttachmentAdd rhino-attachment-remove->rhino-field#onRhinoAttachmentRemove",
|
35
|
+
**@field.get_html(:data, view: view, element: :input)
|
36
|
+
}
|
37
|
+
end
|
21
38
|
end
|
@@ -9,7 +9,7 @@ module Avo
|
|
9
9
|
ActiveSupport.on_load(:avo_boot) do
|
10
10
|
Avo.plugin_manager.register :rhino
|
11
11
|
|
12
|
-
Avo.plugin_manager.register_field :rhino, Avo::Fields::RhinoField
|
12
|
+
Avo.plugin_manager.register_field :rhino, Avo::RhinoField::Fields::RhinoField
|
13
13
|
|
14
14
|
Avo.asset_manager.add_stylesheet "avo-rhino_field"
|
15
15
|
Avo.asset_manager.add_javascript "avo-rhino_field"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: avo-rhino_field
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adrian Marin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-12-29 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: rhino field for Avo.
|
14
14
|
email: adrian@adrianthedev.com
|