Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/assets/javascript/lexxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -8112,6 +8112,7 @@ class LexicalEditorElement extends HTMLElement {
#createDefaultToolbar() {
const toolbar = createElement("lexxy-toolbar");
toolbar.innerHTML = LexicalToolbarElement.defaultTemplate;
toolbar.setAttribute("data-attachments", this.supportsAttachments); // Drives toolbar CSS styles
this.prepend(toolbar);
return toolbar
}
Expand Down
Binary file modified app/assets/javascript/lexxy.js.br
Binary file not shown.
Binary file modified app/assets/javascript/lexxy.js.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion app/assets/javascript/lexxy.min.js

Large diffs are not rendered by default.

Binary file modified app/assets/javascript/lexxy.min.js.br
Binary file not shown.
Binary file modified app/assets/javascript/lexxy.min.js.gz
Binary file not shown.
4 changes: 4 additions & 0 deletions app/assets/stylesheets/lexxy-editor.css
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@
max-inline-size: 100%;
padding: 2px;
position: relative;

&[data-attachments="false"] button[name="upload"]{
display: none;
}
}

:where(.lexxy-editor__toolbar-button) {
Expand Down
1 change: 1 addition & 0 deletions src/elements/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ export default class LexicalEditorElement extends HTMLElement {
#createDefaultToolbar() {
const toolbar = createElement("lexxy-toolbar")
toolbar.innerHTML = LexicalToolbar.defaultTemplate
toolbar.setAttribute("data-attachments", this.supportsAttachments); // Drives toolbar CSS styles
this.prepend(toolbar)
return toolbar
}
Expand Down
2 changes: 1 addition & 1 deletion test/dummy/app/views/posts/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<div>
<%= form.label :body, style: "display: block" %>
<%= form.rich_text_area :body, placeholder: "Write something...",
attachments: params[:attachments_disabled] ? "false" : nil,
attachments: (params[:attachments_disabled] != "true"),
Copy link
Contributor Author

@AlexB52 AlexB52 Oct 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit annoying as this change now diverges from the other query parameter disabling option logic on L15: params[:toolbar_disabled] ? "false" : nil

toolbar: params[:toolbar_disabled] ? "false" : nil, required: true do %>
<lexxy-prompt trigger="1" empty-results="No results" name="mention">
<%= render partial: "people/prompt_item", collection: Person.all, as: :person %>
Expand Down
20 changes: 20 additions & 0 deletions test/system/toolbar_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,26 @@ class ToolbarTest < ApplicationSystemTestCase
assert_no_selector "lexxy-toolbar"
end

test "attachments icon display" do
assert_selector "lexxy-toolbar button[name=upload]"

visit edit_post_path(posts(:empty), attachments_disabled: true)

assert_no_selector "lexxy-toolbar button[name=upload]"

visit edit_post_path(posts(:empty), attachments_disabled: false)

assert_selector "lexxy-toolbar button[name=upload]"

visit edit_post_path(posts(:empty), attachments_disabled: nil)

assert_selector "lexxy-toolbar button[name=upload]"

visit edit_post_path(posts(:empty), attachments_disabled: 'invalid')

assert_selector "lexxy-toolbar button[name=upload]"
end

test "undo and redo commands" do
# Start with empty editor
visit edit_post_path(posts(:empty))
Expand Down