phlex-forms 0.3.0 → 0.3.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +16 -0
- data/README.md +2 -2
- data/lib/forms/form.rb +2 -2
- data/lib/forms/rich_textarea.rb +35 -2
- data/lib/phlex_forms/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9541561e98ecd2afda34daf77d2eeebd725aac0badde75fdbf51401628d081f6
|
|
4
|
+
data.tar.gz: 5d4008e8e6e5748ae12fdbcd12a667d016ab30549da71498dbc2e286fe202d81
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f10fd9155f6ff9841bdae9c34fb2ac89dbbdbc49df33c012af7efad526fa914d21c6379430e1ee66a1aadeff387dcc9bab353d33cb017ce8b07798dd8058dd2c
|
|
7
|
+
data.tar.gz: 7ea1bdaa7fea101bde79b7975759c79b30bc502fb50c2b18e279a5cf4032b294745055e23f2f66ed22cba33c4e43c637c6499ea3c62059f425a3b3aec141ad83
|
data/CHANGELOG.md
CHANGED
|
@@ -9,6 +9,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
9
9
|
|
|
10
10
|
### Fixed
|
|
11
11
|
|
|
12
|
+
- **`rich_textarea` forwards its block into `<lexxy-editor>`**: Lexxy configures
|
|
13
|
+
an editor through CHILD elements — `<lexxy-prompt>` for @mentions,
|
|
14
|
+
`<lexxy-code-language-picker>` for code blocks — but the component rendered
|
|
15
|
+
the element with no block and `Form#rich_textarea` never forwarded one, so
|
|
16
|
+
`f.rich_textarea(:content) { ... }` silently dropped its content. A host
|
|
17
|
+
could wire @mentions and get an editor that never prompts, with no error
|
|
18
|
+
anywhere (a host app's mention endpoint 500'd for months unnoticed, because
|
|
19
|
+
nothing ever called it).
|
|
20
|
+
- **`rich_textarea` wires Active Storage's direct-upload endpoints**: Lexxy
|
|
21
|
+
uploads attachments through `data-direct-upload-url` /
|
|
22
|
+
`data-blob-url-template` on the element. Lexxy's own Rails tag helper sets
|
|
23
|
+
them; this component built the element itself and did not, so rich text
|
|
24
|
+
editors silently lost image uploads. Set as PATHS (a multi-host app must not
|
|
25
|
+
pin uploads to whichever host rendered the page first), fully guarded — no
|
|
26
|
+
Rails dependency is introduced, and a caller-supplied value always wins.
|
|
27
|
+
|
|
12
28
|
- **`FileInput` multiple uploads submit an array** (Rails `file_field` parity):
|
|
13
29
|
with `multiple:` set, the input name now gets `[]` appended (unless already
|
|
14
30
|
present), for the standalone component, the `Plain` variant, and the form
|
data/README.md
CHANGED
|
@@ -4,7 +4,7 @@ A model-bound form builder for [Phlex](https://www.phlex.fun) — forms as
|
|
|
4
4
|
first-class Phlex classes, types inferred from your model, DaisyUI styling by
|
|
5
5
|
default (and a plain-HTML theme when you want none), and optional
|
|
6
6
|
**server-truth live validation** over
|
|
7
|
-
[phlex-reactive](https://github.com/
|
|
7
|
+
[phlex-reactive](https://github.com/zoolutions/phlex-reactive).
|
|
8
8
|
|
|
9
9
|
```ruby
|
|
10
10
|
class UserForm < Forms::Base
|
|
@@ -158,7 +158,7 @@ Both work on inline forms (`f.row { … }`) and inside `fields_for` builders.
|
|
|
158
158
|
|
|
159
159
|
`as: :tags` renders a polished tag/chip input — label + error/hint chrome and
|
|
160
160
|
daisyUI styling on top of
|
|
161
|
-
[phlex-reactive](https://github.com/
|
|
161
|
+
[phlex-reactive](https://github.com/zoolutions/phlex-reactive)'s client-only tag
|
|
162
162
|
primitives (form state, no server round trips). **Requires phlex-reactive** (the `:tags` role is
|
|
163
163
|
registered only when it's loaded).
|
|
164
164
|
|
data/lib/forms/form.rb
CHANGED
|
@@ -78,8 +78,8 @@ module Forms
|
|
|
78
78
|
render theme[:submit].new(*, model: @model, **, &)
|
|
79
79
|
end
|
|
80
80
|
|
|
81
|
-
def rich_textarea(name, *modifiers,
|
|
82
|
-
render field_object(name).rich_textarea(*modifiers, **)
|
|
81
|
+
def rich_textarea(name, *modifiers, **, &)
|
|
82
|
+
render field_object(name).rich_textarea(*modifiers, **), &
|
|
83
83
|
end
|
|
84
84
|
alias rich_text_area rich_textarea
|
|
85
85
|
|
data/lib/forms/rich_textarea.rb
CHANGED
|
@@ -14,21 +14,54 @@ module Forms
|
|
|
14
14
|
@id = id || name.to_s.gsub(/[\[\]]/, "_").gsub(/_+$/, "")
|
|
15
15
|
@value = value
|
|
16
16
|
@options = options
|
|
17
|
+
apply_direct_upload_defaults
|
|
17
18
|
super()
|
|
18
19
|
end
|
|
19
20
|
|
|
20
|
-
|
|
21
|
+
# Lexxy configures the editor through CHILD elements — `<lexxy-prompt>` for
|
|
22
|
+
# @mentions, `<lexxy-code-language-picker>` for code blocks — so the block
|
|
23
|
+
# has to reach the element, not be dropped.
|
|
24
|
+
def view_template(&)
|
|
21
25
|
lexxy_editor(
|
|
22
26
|
name: @name,
|
|
23
27
|
id: @id,
|
|
24
28
|
value: formatted_value,
|
|
25
29
|
class: editor_classes,
|
|
26
|
-
**@options.except(:class, :error)
|
|
30
|
+
**@options.except(:class, :error),
|
|
31
|
+
&
|
|
27
32
|
)
|
|
28
33
|
end
|
|
29
34
|
|
|
30
35
|
private
|
|
31
36
|
|
|
37
|
+
# Lexxy uploads attachments through Active Storage's direct-upload
|
|
38
|
+
# endpoints, read off the element. Lexxy's own Rails tag helper sets them;
|
|
39
|
+
# this component builds the element itself, so without these an editor
|
|
40
|
+
# silently loses image uploads. Paths, not URLs: a multi-host app must not
|
|
41
|
+
# pin uploads to whichever host rendered the page first.
|
|
42
|
+
#
|
|
43
|
+
# Fully guarded — the gem has no Rails dependency, and a host without
|
|
44
|
+
# Active Storage (or with its own values) is left alone.
|
|
45
|
+
def apply_direct_upload_defaults
|
|
46
|
+
helpers = rails_url_helpers or return
|
|
47
|
+
|
|
48
|
+
data = (@options[:data] ||= {})
|
|
49
|
+
data[:direct_upload_url] ||= helpers.rails_direct_uploads_path
|
|
50
|
+
data[:blob_url_template] ||= helpers.rails_service_blob_path(":signed_id", ":filename")
|
|
51
|
+
rescue StandardError
|
|
52
|
+
nil
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def rails_url_helpers
|
|
56
|
+
return unless defined?(Rails) && Rails.respond_to?(:application)
|
|
57
|
+
|
|
58
|
+
helpers = Rails.application&.routes&.url_helpers
|
|
59
|
+
return unless helpers.respond_to?(:rails_direct_uploads_path)
|
|
60
|
+
return unless helpers.respond_to?(:rails_service_blob_path)
|
|
61
|
+
|
|
62
|
+
helpers
|
|
63
|
+
end
|
|
64
|
+
|
|
32
65
|
def formatted_value
|
|
33
66
|
return nil if @value.nil? || (@value.respond_to?(:blank?) && @value.blank?)
|
|
34
67
|
|
data/lib/phlex_forms/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: phlex-forms
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.
|
|
4
|
+
version: 0.3.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Mikael Henriksson
|
|
@@ -179,13 +179,13 @@ files:
|
|
|
179
179
|
- lib/phlex_forms/version.rb
|
|
180
180
|
- lib/rubocop/phlex_forms/cop/legacy_form_method.rb
|
|
181
181
|
- lib/rubocop/phlex_forms/cop/raw_form.rb
|
|
182
|
-
homepage: https://github.com/
|
|
182
|
+
homepage: https://github.com/zoolutions/phlex-forms
|
|
183
183
|
licenses:
|
|
184
184
|
- MIT
|
|
185
185
|
metadata:
|
|
186
|
-
source_code_uri: https://github.com/
|
|
187
|
-
changelog_uri: https://github.com/
|
|
188
|
-
bug_tracker_uri: https://github.com/
|
|
186
|
+
source_code_uri: https://github.com/zoolutions/phlex-forms
|
|
187
|
+
changelog_uri: https://github.com/zoolutions/phlex-forms/blob/main/CHANGELOG.md
|
|
188
|
+
bug_tracker_uri: https://github.com/zoolutions/phlex-forms/issues
|
|
189
189
|
rubygems_mfa_required: 'true'
|
|
190
190
|
rdoc_options: []
|
|
191
191
|
require_paths:
|