lexxy 0.1.1.beta

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 (34) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +289 -0
  4. data/Rakefile +8 -0
  5. data/app/assets/javascript/lexxy.js +8463 -0
  6. data/app/assets/javascript/lexxy.js.br +0 -0
  7. data/app/assets/javascript/lexxy.js.gz +0 -0
  8. data/app/assets/javascript/lexxy.min.js +10 -0
  9. data/app/assets/javascript/lexxy.min.js.br +0 -0
  10. data/app/assets/javascript/lexxy.min.js.gz +0 -0
  11. data/app/assets/stylesheets/lexxy-content.css +347 -0
  12. data/app/assets/stylesheets/lexxy-editor.css +255 -0
  13. data/app/assets/stylesheets/lexxy-variables.css +51 -0
  14. data/app/assets/stylesheets/lexxy.css +2 -0
  15. data/app/controllers/actiontext/lexical/application_controller.rb +6 -0
  16. data/app/helpers/actiontext/lexical/application_helper.rb +6 -0
  17. data/app/jobs/actiontext/lexical/application_job.rb +6 -0
  18. data/app/mailers/actiontext/lexical/application_mailer.rb +8 -0
  19. data/app/models/actiontext/lexical/application_record.rb +7 -0
  20. data/app/views/layouts/actiontext/lexical/application.html.erb +17 -0
  21. data/app/views/people/_person.html.erb +1 -0
  22. data/app/views/people/_prompt_item.html.erb +6 -0
  23. data/app/views/people/index.html.erb +3 -0
  24. data/config/routes.rb +2 -0
  25. data/lib/active_storage/blob_with_preview_url.rb +18 -0
  26. data/lib/lexxy/action_text_tag.rb +18 -0
  27. data/lib/lexxy/engine.rb +43 -0
  28. data/lib/lexxy/form_builder.rb +9 -0
  29. data/lib/lexxy/form_helper.rb +9 -0
  30. data/lib/lexxy/rich_text_area_tag.rb +38 -0
  31. data/lib/lexxy/version.rb +3 -0
  32. data/lib/lexxy.rb +6 -0
  33. data/lib/tasks/actiontext/lexical_tasks.rake +4 -0
  34. metadata +173 -0
@@ -0,0 +1 @@
1
+ <em><%= person.name %></em> (<strong><%= person.initials %></strong>)
@@ -0,0 +1,6 @@
1
+ <lexxy-prompt-item search="<%= "#{person.name} #{person.initials}" %>" sgid="<%= person.attachable_sgid %>">
2
+ <template type="menu"><%= person.name %></template>
3
+ <template type="editor">
4
+ <%= render "people/person", person: person %>
5
+ </template>
6
+ </lexxy-prompt-item>
@@ -0,0 +1,3 @@
1
+ <% @people.each do |person| %>
2
+ <%= render "people/prompt_item", person: person %>
3
+ <% end %>
data/config/routes.rb ADDED
@@ -0,0 +1,2 @@
1
+ Lexxy::Engine.routes.draw do
2
+ end
@@ -0,0 +1,18 @@
1
+ module ActiveStorage
2
+ module BlobWithPreviewUrl
3
+ PREVIEW_SIZE = [ 1024, 768 ]
4
+
5
+ def as_json(options = nil)
6
+ json = super(options)
7
+
8
+ if previewable?
9
+ json["previewable"] = true
10
+ json["url"] = Rails.application.routes.url_helpers.rails_representation_path(
11
+ preview(resize_to_limit: PREVIEW_SIZE), ActiveStorage::Current.url_options.merge(only_path: true)
12
+ )
13
+ end
14
+
15
+ json
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ module Lexxy
2
+ module ActionTextTag
3
+ def initialize(object_name, method_name, template_object, options = {}, &block)
4
+ super
5
+
6
+ @block = block
7
+ end
8
+
9
+ def render
10
+ options = @options.stringify_keys
11
+
12
+ add_default_name_and_id(options)
13
+ options["input"] ||= dom_id(object, [ options["id"], :trix_input ].compact.join("_")) if object
14
+ html_tag = @template_object.rich_textarea_tag(options.delete("name"), options.fetch("value") { value }, options.except("value"), &@block)
15
+ error_wrapping(html_tag)
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,43 @@
1
+ require_relative "rich_text_area_tag"
2
+ require_relative "form_helper"
3
+ require_relative "form_builder"
4
+ require_relative "action_text_tag"
5
+
6
+ require "active_storage/blob_with_preview_url"
7
+
8
+ module Lexxy
9
+ class Engine < ::Rails::Engine
10
+ isolate_namespace Lexxy
11
+
12
+ initializer "lexxy.initialize" do |app|
13
+ app.config.to_prepare do
14
+ # TODO: We need to move these extensions to Action Text
15
+ ActionText::TagHelper.prepend(Lexxy::TagHelper)
16
+ ActionView::Helpers::FormHelper.prepend(Lexxy::FormHelper)
17
+ ActionView::Helpers::FormBuilder.prepend(Lexxy::FormBuilder)
18
+ ActionView::Helpers::Tags::ActionText.prepend(Lexxy::ActionTextTag)
19
+ end
20
+ end
21
+
22
+ initializer "lexxy.assets" do |app|
23
+ app.config.assets.paths << root.join("app/assets/stylesheets")
24
+ app.config.assets.paths << root.join("app/javascript")
25
+ end
26
+
27
+ initializer "lexxy.sanitization" do |app|
28
+ ActiveSupport.on_load(:action_text_content) do
29
+ default_allowed_tags = Class.new.include(ActionText::ContentHelper).new.sanitizer_allowed_tags
30
+ ActionText::ContentHelper.allowed_tags = default_allowed_tags + %w[ video audio source embed ]
31
+
32
+ default_allowed_attributes = Class.new.include(ActionText::ContentHelper).new.sanitizer_allowed_attributes
33
+ ActionText::ContentHelper.allowed_attributes = default_allowed_attributes + %w[ controls poster data-language style ]
34
+ end
35
+ end
36
+
37
+ initializer "lexxy.blob_with_preview" do |app|
38
+ ActiveSupport.on_load(:active_storage_blob) do
39
+ prepend ActiveStorage::BlobWithPreviewUrl
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,9 @@
1
+ module Lexxy
2
+ module FormBuilder
3
+ def rich_textarea(method, options = {}, &block)
4
+ @template.rich_textarea(@object_name, method, objectify_options(options), &block)
5
+ end
6
+
7
+ alias_method :rich_text_area, :rich_textarea
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module Lexxy
2
+ module FormHelper
3
+ def rich_textarea(object_name, method, options = {}, &block)
4
+ ActionView::Helpers::Tags::ActionText.new(object_name, method, self, options, &block).render
5
+ end
6
+
7
+ alias_method :rich_text_area, :rich_textarea
8
+ end
9
+ end
@@ -0,0 +1,38 @@
1
+ module Lexxy
2
+ module TagHelper
3
+ def rich_textarea_tag(name, value = nil, options = {}, &block)
4
+ options = options.symbolize_keys
5
+ form = options.delete(:form)
6
+
7
+ value = render_custom_attachments_in(value)
8
+ value = "<div>#{value}</div>" if value
9
+
10
+ options[:name] ||= name
11
+ options[:value] ||= value
12
+ options[:class] ||= "lexxy-content"
13
+ options[:data] ||= {}
14
+ options[:data][:direct_upload_url] ||= main_app.rails_direct_uploads_url
15
+ options[:data][:blob_url_template] ||= main_app.rails_service_blob_url(":signed_id", ":filename")
16
+
17
+ editor_tag = content_tag("lexxy-editor", "", options, &block)
18
+ editor_tag
19
+ end
20
+
21
+ alias_method :rich_text_area_tag, :rich_textarea_tag
22
+
23
+ private
24
+ # Tempoary: we need to *adaptarize* action text
25
+ def render_custom_attachments_in(value)
26
+ if html = value.try(:body_before_type_cast).presence
27
+ Nokogiri::HTML.fragment(html).tap do |fragment|
28
+ fragment.css("action-text-attachment").each do |node|
29
+ if node["url"].blank?
30
+ attachment = ActionText::Attachment.from_node(node)
31
+ node["content"] = render_action_text_attachment(attachment).to_json
32
+ end
33
+ end
34
+ end.to_html
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,3 @@
1
+ module Lexxy
2
+ VERSION = "0.1.1.beta"
3
+ end
data/lib/lexxy.rb ADDED
@@ -0,0 +1,6 @@
1
+ require "lexxy/version"
2
+ require "lexxy/engine"
3
+
4
+ module Lexxy
5
+ # Your code goes here...
6
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :actiontext_lexical do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,173 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lexxy
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1.beta
5
+ platform: ruby
6
+ authors:
7
+ - Jorge Manrubia
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 2025-09-04 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: rails
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: 8.0.2
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: 8.0.2
26
+ - !ruby/object:Gem::Dependency
27
+ name: turbo-rails
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ - !ruby/object:Gem::Dependency
41
+ name: stimulus-rails
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ type: :development
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ - !ruby/object:Gem::Dependency
55
+ name: capybara
56
+ requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ type: :development
62
+ prerelease: false
63
+ version_requirements: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ - !ruby/object:Gem::Dependency
69
+ name: selenium-webdriver
70
+ requirement: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ type: :development
76
+ prerelease: false
77
+ version_requirements: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ - !ruby/object:Gem::Dependency
83
+ name: cuprite
84
+ requirement: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ type: :development
90
+ prerelease: false
91
+ version_requirements: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ - !ruby/object:Gem::Dependency
97
+ name: image_processing
98
+ requirement: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ type: :development
104
+ prerelease: false
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ description: A new editor for Action Text based on Meta's Lexical framework.
111
+ email:
112
+ - jorge@37signals.com
113
+ executables: []
114
+ extensions: []
115
+ extra_rdoc_files: []
116
+ files:
117
+ - MIT-LICENSE
118
+ - README.md
119
+ - Rakefile
120
+ - app/assets/javascript/lexxy.js
121
+ - app/assets/javascript/lexxy.js.br
122
+ - app/assets/javascript/lexxy.js.gz
123
+ - app/assets/javascript/lexxy.min.js
124
+ - app/assets/javascript/lexxy.min.js.br
125
+ - app/assets/javascript/lexxy.min.js.gz
126
+ - app/assets/stylesheets/lexxy-content.css
127
+ - app/assets/stylesheets/lexxy-editor.css
128
+ - app/assets/stylesheets/lexxy-variables.css
129
+ - app/assets/stylesheets/lexxy.css
130
+ - app/controllers/actiontext/lexical/application_controller.rb
131
+ - app/helpers/actiontext/lexical/application_helper.rb
132
+ - app/jobs/actiontext/lexical/application_job.rb
133
+ - app/mailers/actiontext/lexical/application_mailer.rb
134
+ - app/models/actiontext/lexical/application_record.rb
135
+ - app/views/layouts/actiontext/lexical/application.html.erb
136
+ - app/views/people/_person.html.erb
137
+ - app/views/people/_prompt_item.html.erb
138
+ - app/views/people/index.html.erb
139
+ - config/routes.rb
140
+ - lib/active_storage/blob_with_preview_url.rb
141
+ - lib/lexxy.rb
142
+ - lib/lexxy/action_text_tag.rb
143
+ - lib/lexxy/engine.rb
144
+ - lib/lexxy/form_builder.rb
145
+ - lib/lexxy/form_helper.rb
146
+ - lib/lexxy/rich_text_area_tag.rb
147
+ - lib/lexxy/version.rb
148
+ - lib/tasks/actiontext/lexical_tasks.rake
149
+ homepage: https://github.com/basecamp/lexxy
150
+ licenses:
151
+ - MIT
152
+ metadata:
153
+ homepage_uri: https://github.com/basecamp/lexxy
154
+ source_code_uri: https://github.com/basecamp/lexxy
155
+ changelog_uri: https://github.com/basecamp/lexxy
156
+ rdoc_options: []
157
+ require_paths:
158
+ - lib
159
+ required_ruby_version: !ruby/object:Gem::Requirement
160
+ requirements:
161
+ - - ">="
162
+ - !ruby/object:Gem::Version
163
+ version: '0'
164
+ required_rubygems_version: !ruby/object:Gem::Requirement
165
+ requirements:
166
+ - - ">="
167
+ - !ruby/object:Gem::Version
168
+ version: '0'
169
+ requirements: []
170
+ rubygems_version: 3.6.2
171
+ specification_version: 4
172
+ summary: A new editor for Action Text based on Meta's Lexical framework.
173
+ test_files: []