Skip to content

Commit

Permalink
fix: Trix image attachments
Browse files Browse the repository at this point in the history
  • Loading branch information
martintomas committed Jan 12, 2024
1 parent 9da98d5 commit 67169fc
Show file tree
Hide file tree
Showing 9 changed files with 86 additions and 23 deletions.
34 changes: 17 additions & 17 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ GEM
activerecord (>= 5.a)
database_cleaner-core (~> 2.0.0)
database_cleaner-core (2.0.1)
date (3.3.3)
date (3.3.4)
declarative (0.0.20)
devise (4.8.1)
bcrypt (~> 3.0)
Expand Down Expand Up @@ -208,8 +208,8 @@ GEM
formtastic_i18n (0.7.0)
friendly_id (5.4.2)
activerecord (>= 4.0.0)
globalid (1.1.0)
activesupport (>= 5.0)
globalid (1.2.1)
activesupport (>= 6.1)
google-apis-core (0.7.0)
addressable (~> 2.5, >= 2.5.1)
googleauth (>= 0.16.2, < 2.a)
Expand Down Expand Up @@ -281,7 +281,7 @@ GEM
listen (3.0.8)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
loofah (2.21.3)
loofah (2.22.0)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
mail (2.8.1)
Expand All @@ -295,24 +295,24 @@ GEM
method_source (1.0.0)
mini_magick (4.11.0)
mini_mime (1.1.5)
mini_portile2 (2.8.4)
minitest (5.19.0)
mini_portile2 (2.8.5)
minitest (5.21.1)
msgpack (1.5.3)
multi_json (1.15.0)
net-imap (0.3.7)
net-imap (0.4.9.1)
date
net-protocol
net-pop (0.1.2)
net-protocol
net-protocol (0.2.1)
net-protocol (0.2.2)
timeout
net-scp (1.2.1)
net-ssh (>= 2.6.5)
net-smtp (0.3.3)
net-smtp (0.4.0.1)
net-protocol
net-ssh (7.0.1)
nio4r (2.5.9)
nokogiri (1.15.4)
nio4r (2.7.0)
nokogiri (1.16.0)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
optimist (3.0.1)
Expand All @@ -338,7 +338,7 @@ GEM
public_suffix (4.0.7)
puma (5.6.7)
nio4r (~> 2.0)
racc (1.7.1)
racc (1.7.3)
rack (2.2.8)
rack-cors (1.1.1)
rack (>= 2.0.0)
Expand Down Expand Up @@ -379,7 +379,7 @@ GEM
rake (>= 12.2)
thor (~> 1.0)
rainbow (3.1.1)
rake (13.0.6)
rake (13.1.0)
ransack (2.6.0)
activerecord (>= 6.0.4)
activesupport (>= 6.0.4)
Expand Down Expand Up @@ -487,7 +487,7 @@ GEM
spring-watcher-listen (2.0.1)
listen (>= 2.7, < 4.0)
spring (>= 1.2, < 3.0)
sprockets (4.2.0)
sprockets (4.2.1)
concurrent-ruby (~> 1.0)
rack (>= 2.2.4, < 4)
sprockets-rails (3.4.2)
Expand All @@ -502,10 +502,10 @@ GEM
diff-lcs
patience_diff
test-prof (1.0.9)
thor (1.2.2)
thor (1.3.0)
tilt (2.0.10)
timecop (0.9.5)
timeout (0.4.0)
timeout (0.4.1)
trailblazer-option (0.1.2)
turbolinks (5.2.1)
turbolinks-source (~> 5.2)
Expand Down Expand Up @@ -543,7 +543,7 @@ GEM
rails (>= 3.2.16)
xpath (3.2.0)
nokogiri (~> 1.8)
zeitwerk (2.6.11)
zeitwerk (2.6.12)

PLATFORMS
ruby
Expand Down
26 changes: 26 additions & 0 deletions app/assets/stylesheets/admin/trix.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,29 @@ trix-toolbar {
}
}
}

.trix-editor, .trix-content {
font-size: 1rem;

.attachment {
&__caption {
display: none;
}
}

.attachment--preview {
//position: relative;
//float: left;
//width: auto;
//margin: 10px 10px 10px 0;
text-align: center;
max-width: 100%;
padding: 0;
}

&:after {
content: '';
display: block;
clear: both;
}
}
19 changes: 19 additions & 0 deletions app/assets/stylesheets/tpi/_pages.scss
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,25 @@ $margin-between-list-items: 20px;
margin-top: 30px;
margin-bottom: 30px;
}

.attachment {
&--preview {
//position: relative;
//float: left;
//margin: 10px 10px 10px 0;
text-align: center;
max-width: 100%;
padding: 0;

img {
margin: 0;
}
}

&__caption {
display: none;
}
}
}

.pages__content {
Expand Down
4 changes: 1 addition & 3 deletions app/decorators/news_article_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ def tpi_sector_links
end

def preview_url
h.tpi_publication_url(
model, {type: 'NewsArticle', host: Rails.configuration.try(:tpi_domain)}.compact
)
h.show_news_article_tpi_publication_path(model, {host: Rails.configuration.try(:tpi_domain)}.compact)
end
end
2 changes: 2 additions & 0 deletions app/inputs/trix_input.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ def to_html
input_wrapping do
editor_tag_params = {
input: input_html_options[:id],
'data-direct-upload-url': Rails.application.routes.url_helpers.rails_direct_uploads_path,
'data-blob-url-template': Rails.application.routes.url_helpers.rails_service_blob_path(':signed_id', ':filename'),
class: 'trix-content'
}

Expand Down
3 changes: 3 additions & 0 deletions app/javascript/packs/admin.js
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
import 'admin';

require('@rails/activestorage');
require('@rails/actiontext');
2 changes: 1 addition & 1 deletion bin/yarn
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ APP_ROOT = File.expand_path('..', __dir__)
Dir.chdir(APP_ROOT) do
yarn = ENV["PATH"].split(File::PATH_SEPARATOR).
select { |dir| File.expand_path(dir) != __dir__ }.
product(["yarn", "yarn.exe"]).
product(["yarn", "yarn.cmd", "yarn.ps1"]).
map { |dir, file| File.expand_path(file, dir) }.
find { |file| File.executable?(file) }

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"@hotwired/stimulus": "^3.1.0",
"@hotwired/stimulus-webpack-helpers": "^1.0.1",
"@rails/actioncable": "^6.0.3-3",
"@rails/actiontext": "^6.1.7-6",
"@rails/activestorage": "^6.0.3-3",
"@rails/ujs": "^6.0.3-3",
"@rails/webpacker": "^5.2.1",
Expand Down Expand Up @@ -63,7 +64,7 @@
"react_ujs": "^2.6.0",
"simple-statistics": "^7.1.0",
"tiny-slider": "^2.9.3",
"trix": "^1.2.4",
"trix": "^1.2.0",
"turbolinks": "^5.2.0"
},
"devDependencies": {
Expand Down
16 changes: 15 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1241,6 +1241,20 @@
resolved "https://registry.yarnpkg.com/@rails/actioncable/-/actioncable-6.0.5.tgz#a889f25b0c13ea0215d747e32fa3d1a52967f17b"
integrity sha512-79sIsTpIoHnJ6pRHKaC6h5NMRpY+VZD4mqOKN/035X1ehxHgToDWvgMZ4jV5y1qeObg4enmNESmgeKoImYGzOw==

"@rails/actiontext@^6.1.7-6":
version "6.1.7"
resolved "https://registry.yarnpkg.com/@rails/actiontext/-/actiontext-6.1.7.tgz#62997bda1d938743ed36bb802885592b01bc6782"
integrity sha512-o3TYFeFzDQKR22EGqE9qqJ6SD4DM+cATw8nioPtrRkIlAsBIHeaV0h4Kok1sDXyNjXiJztCr89CsfV7YXnYFmw==
dependencies:
"@rails/activestorage" "^6.0.0"

"@rails/activestorage@^6.0.0":
version "6.1.7"
resolved "https://registry.yarnpkg.com/@rails/activestorage/-/activestorage-6.1.7.tgz#5aaae9f4d10800fdb4fd6fe26fd8b4218579c6e3"
integrity sha512-h++k8LBLns4O8AqzdaFp1TsCLP9VSc2hgWI37bjzJ+4D995X7Rd8kdkRmXRaNAUlHDJgy6RpnbhBJ5oiIgWTDw==
dependencies:
spark-md5 "^3.0.0"

"@rails/activestorage@^6.0.3-3":
version "6.0.5"
resolved "https://registry.yarnpkg.com/@rails/activestorage/-/activestorage-6.0.5.tgz#446e4b3f45bf1d4e1c6fd0b8b6e2566cb70c2b18"
Expand Down Expand Up @@ -8724,7 +8738,7 @@ topojson-client@^3.0.0:
dependencies:
commander "2"

trix@^1.2.4:
trix@^1.2.0:
version "1.3.1"
resolved "https://registry.yarnpkg.com/trix/-/trix-1.3.1.tgz#ccce8d9e72bf0fe70c8c019ff558c70266f8d857"
integrity sha512-BbH6mb6gk+AV4f2as38mP6Ucc1LE3OD6XxkZnAgPIduWXYtvg2mI3cZhIZSLqmMh9OITEpOBCCk88IVmyjU7bA==
Expand Down

0 comments on commit 67169fc

Please sign in to comment.