avo-rhino_field 0.0.11
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 +7 -0
- data/README.md +16 -0
- data/app/assets/builds/avo-rhino_field.css +1004 -0
- data/app/assets/builds/avo-rhino_field.css.map +1 -0
- data/app/assets/builds/avo-rhino_field.js +29477 -0
- data/app/assets/builds/avo-rhino_field.js.map +7 -0
- data/app/assets/stylesheets/avo-rhino_field.css +19 -0
- data/app/assets/svgs/avo/gradient.svg +3 -0
- data/app/components/avo/fields/rhino_field/edit_component.html.erb +58 -0
- data/app/components/avo/fields/rhino_field/edit_component.rb +21 -0
- data/app/components/avo/fields/rhino_field/show_component.html.erb +14 -0
- data/app/components/avo/fields/rhino_field/show_component.rb +4 -0
- data/avo-rhino_field.gemspec +19 -0
- data/lib/avo/rhino_field/engine.rb +24 -0
- data/lib/avo/rhino_field/fields/rhino_field.rb +21 -0
- data/lib/avo/rhino_field/version.rb +5 -0
- data/lib/avo/rhino_field.rb +13 -0
- metadata +57 -0
@@ -0,0 +1,19 @@
|
|
1
|
+
@import "./../../../node_modules/rhino-editor/exports/styles/trix.css";
|
2
|
+
|
3
|
+
@tailwind base;
|
4
|
+
@tailwind components;
|
5
|
+
@tailwind utilities;
|
6
|
+
|
7
|
+
.rhino-editor .rhino-toolbar-button,
|
8
|
+
.rhino-editor::part(toolbar__button) {
|
9
|
+
--rhino-toolbar-icon-size: 18px;
|
10
|
+
@apply flex items-center justify-center border-none;
|
11
|
+
|
12
|
+
&:hover {
|
13
|
+
@apply shadow-none bg-gray-100;
|
14
|
+
}
|
15
|
+
}
|
16
|
+
|
17
|
+
.hidden-until-rhino-boots-up {
|
18
|
+
@apply !hidden;
|
19
|
+
}
|
@@ -0,0 +1,3 @@
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24">
|
2
|
+
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M9 12h.01M6 12h.01M9 16h.01M6 16h.01M12 12h.01M12 16h.01M15 12h.01M18 12h.01M15 16h.01M18 16h.01m-4.51-2h.01m-.01 4h.01m-3.01-4h.01m-.01 4h.01M7.5 14h.01m-.01 4h.01M17 14h.01M17 18h.01M5.75 19.25h12.5a1 1 0 0 0 1-1V5.75a1 1 0 0 0-1-1H5.75a1 1 0 0 0-1 1v12.5a1 1 0 0 0 1 1Z"></path>
|
3
|
+
</svg>
|
@@ -0,0 +1,58 @@
|
|
1
|
+
<%= field_wrapper **field_wrapper_args, full_width: true do %>
|
2
|
+
<%= content_tag :div, class: "relative block overflow-x-auto max-w-4xl" do %>
|
3
|
+
<%= content_tag 'avo-rhino-editor',
|
4
|
+
data: {
|
5
|
+
controller: "rhino-field",
|
6
|
+
blob_url_template: helpers.main_app.rails_service_blob_url(":signed_id", ":filename"),
|
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,
|
12
|
+
placeholder: @field.placeholder do %>
|
13
|
+
<button
|
14
|
+
type="button"
|
15
|
+
slot="after-link-button"
|
16
|
+
class="toolbar__button rhino-toolbar-button flex flex-col items-center grow-0 text-sm hidden-until-rhino-boots-up"
|
17
|
+
data-role="toolbar-item"
|
18
|
+
tabindex="-1"
|
19
|
+
data-action="click->rhino-field#openTextColorPicker"
|
20
|
+
>
|
21
|
+
<%= helpers.svg "heroicons/outline/swatch", class: "!min-h-4 !max-h-4" %>
|
22
|
+
<input
|
23
|
+
type="color"
|
24
|
+
slot="after-undo-button"
|
25
|
+
data-action="input->rhino-field#setTextColor"
|
26
|
+
data-rhino-field-target="textColorInput"
|
27
|
+
class="h-3.5 w-5 bg-transparent -mt-px -mb-1"
|
28
|
+
/>
|
29
|
+
</button>
|
30
|
+
<button
|
31
|
+
type="button"
|
32
|
+
slot="after-link-button"
|
33
|
+
class="toolbar__button rhino-toolbar-button flex flex-col items-center grow-0 text-sm hidden-until-rhino-boots-up"
|
34
|
+
data-role="toolbar-item"
|
35
|
+
tabindex="-1"
|
36
|
+
data-action="click->rhino-field#openBackgroundColorPicker"
|
37
|
+
>
|
38
|
+
<%= helpers.svg "avo/gradient", class: "!min-h-4 !max-h-4" %>
|
39
|
+
<input
|
40
|
+
type="color"
|
41
|
+
slot="after-undo-button"
|
42
|
+
data-action="input->rhino-field#setBackgroundColor"
|
43
|
+
data-rhino-field-target="backgroundColorInput"
|
44
|
+
class="h-3.5 w-5 bg-transparent -mt-px -mb-1"
|
45
|
+
/>
|
46
|
+
</button>
|
47
|
+
<% end %>
|
48
|
+
<%= @form.text_area @field.id,
|
49
|
+
value: @field.value.try(:to_trix_html) || @field.value,
|
50
|
+
class: classes("w-full hidden"),
|
51
|
+
data: @field.get_html(:data, view: view, element: :input),
|
52
|
+
disabled: disabled?,
|
53
|
+
id: field_id,
|
54
|
+
placeholder: @field.placeholder,
|
55
|
+
style: @field.get_html(:style, view: view, element: :input)
|
56
|
+
%>
|
57
|
+
<% end %>
|
58
|
+
<% end %>
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Avo::Fields::RhinoField::EditComponent < Avo::Fields::EditComponent
|
4
|
+
attr_reader :resource
|
5
|
+
|
6
|
+
def initialize(**args)
|
7
|
+
@resource = args[:resource]
|
8
|
+
@resource_id = args[:resource_id] || @resource&.record&.to_param
|
9
|
+
@resource_name = args[:resource_name] || @resource&.singular_route_key
|
10
|
+
|
11
|
+
super(**args)
|
12
|
+
end
|
13
|
+
|
14
|
+
def field_id
|
15
|
+
if @resource_name.present?
|
16
|
+
"rhino_#{@resource_name}_#{@field.id}"
|
17
|
+
elsif form.present?
|
18
|
+
"rhino_#{form.index}_#{@field.id}"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<%= field_wrapper **field_wrapper_args do %>
|
2
|
+
<%
|
3
|
+
content_classes = 'trix-content py-2 max-w-4xl'
|
4
|
+
content_classes << ' hidden' unless @field.always_show
|
5
|
+
%>
|
6
|
+
<div data-controller="hidden-input">
|
7
|
+
<% unless @field.always_show %>
|
8
|
+
<%= link_to t('avo.show_content'), 'javascript:void(0);', class: 'font-bold inline-block', data: { action: 'click->hidden-input#showContent' } %>
|
9
|
+
<% end %>
|
10
|
+
<div class="<%= content_classes %> " data-hidden-input-target="content">
|
11
|
+
<%= @field.value.html_safe %>
|
12
|
+
</div>
|
13
|
+
</div>
|
14
|
+
<% end %>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
$:.push File.expand_path("lib", __dir__)
|
2
|
+
|
3
|
+
require "avo/rhino_field/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "avo-rhino_field"
|
7
|
+
spec.version = Avo::RhinoField::VERSION
|
8
|
+
spec.summary = "rhino field for Avo."
|
9
|
+
spec.description = "rhino field for Avo."
|
10
|
+
spec.authors = ["Adrian Marin"]
|
11
|
+
spec.email = "adrian@adrianthedev.com"
|
12
|
+
|
13
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
14
|
+
Dir["{app,lib}/**/*", "Rakefile", "README.md", "avo-rhino_field.gemspec"]
|
15
|
+
end
|
16
|
+
spec.files.reject! { |file_name| %w[app/javascript].any? { |rejected_file| file_name.include? rejected_file } }
|
17
|
+
|
18
|
+
spec.homepage = "https://avohq.io"
|
19
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require_relative "fields/rhino_field"
|
2
|
+
|
3
|
+
module Avo
|
4
|
+
module RhinoField
|
5
|
+
class Engine < Rails::Engine
|
6
|
+
isolate_namespace Avo::RhinoField
|
7
|
+
|
8
|
+
initializer "avo-rhino_field.init" do |app|
|
9
|
+
ActiveSupport.on_load(:avo_boot) do
|
10
|
+
Avo.plugin_manager.register :rhino
|
11
|
+
|
12
|
+
Avo.plugin_manager.register_field :rhino, Avo::Fields::RhinoField
|
13
|
+
|
14
|
+
Avo.asset_manager.add_stylesheet "avo-rhino_field"
|
15
|
+
Avo.asset_manager.add_javascript "avo-rhino_field"
|
16
|
+
end
|
17
|
+
|
18
|
+
app.config.assets.paths << root.join("app", "assets", "svgs", "avo")
|
19
|
+
app.config.assets.precompile += %w(avo-rhino_field.css avo-rhino_field.js)
|
20
|
+
app.config.assets.precompile << '*.svg'
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Avo
|
2
|
+
module RhinoField
|
3
|
+
module Fields
|
4
|
+
class RhinoField < Avo::Fields::BaseField
|
5
|
+
attr_reader :always_show
|
6
|
+
|
7
|
+
def initialize(id, **args, &block)
|
8
|
+
super(id, **args, &block)
|
9
|
+
|
10
|
+
hide_on :index
|
11
|
+
|
12
|
+
@always_show = args[:always_show] || false
|
13
|
+
end
|
14
|
+
|
15
|
+
def view_component_namespace
|
16
|
+
"Avo::Fields::RhinoField"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: avo-rhino_field
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.11
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Adrian Marin
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-11-15 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: rhino field for Avo.
|
14
|
+
email: adrian@adrianthedev.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- README.md
|
20
|
+
- app/assets/builds/avo-rhino_field.css
|
21
|
+
- app/assets/builds/avo-rhino_field.css.map
|
22
|
+
- app/assets/builds/avo-rhino_field.js
|
23
|
+
- app/assets/builds/avo-rhino_field.js.map
|
24
|
+
- app/assets/stylesheets/avo-rhino_field.css
|
25
|
+
- app/assets/svgs/avo/gradient.svg
|
26
|
+
- app/components/avo/fields/rhino_field/edit_component.html.erb
|
27
|
+
- app/components/avo/fields/rhino_field/edit_component.rb
|
28
|
+
- app/components/avo/fields/rhino_field/show_component.html.erb
|
29
|
+
- app/components/avo/fields/rhino_field/show_component.rb
|
30
|
+
- avo-rhino_field.gemspec
|
31
|
+
- lib/avo/rhino_field.rb
|
32
|
+
- lib/avo/rhino_field/engine.rb
|
33
|
+
- lib/avo/rhino_field/fields/rhino_field.rb
|
34
|
+
- lib/avo/rhino_field/version.rb
|
35
|
+
homepage: https://avohq.io
|
36
|
+
licenses: []
|
37
|
+
metadata: {}
|
38
|
+
post_install_message:
|
39
|
+
rdoc_options: []
|
40
|
+
require_paths:
|
41
|
+
- lib
|
42
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - ">="
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: '0'
|
52
|
+
requirements: []
|
53
|
+
rubygems_version: 3.4.10
|
54
|
+
signing_key:
|
55
|
+
specification_version: 4
|
56
|
+
summary: rhino field for Avo.
|
57
|
+
test_files: []
|