-
Notifications
You must be signed in to change notification settings - Fork 0
Improve editor to prevent layout breakage #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
timlandolt
wants to merge
22
commits into
develop
Choose a base branch
from
feature/25970-non-breaking-layout
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
d5e327a
Move editor to partial
timlandolt f8cb52f
Adjust styles
timlandolt 5bb286a
Add iframe for page
timlandolt edead94
Add correct styles + js
timlandolt 87ee9f6
Adjust editor to iframe approach
timlandolt faf2d98
Clean up css
timlandolt 53769c5
Make new editor useable
timlandolt 821e3d4
Update search bar when selecting new partial
timlandolt 79dc581
Add editor test
timlandolt a51c075
Reformat show template
timlandolt 102d320
Separate js cleanly
timlandolt 2f22c9f
Set display contents on template elements
timlandolt c5f6185
Add demo for display contents
timlandolt 70e0abc
Use only one controller
timlandolt 16e1eb5
Combine editor and template controller
timlandolt 5c341f1
Clean up js
timlandolt 577b113
Fix renderpath links
timlandolt 335f8a9
Improve title
timlandolt 6251ae3
Remove unused helper method
timlandolt 5222728
Remove outdated steps from readme
timlandolt ff25cee
Clean up controller test
timlandolt d7c02e2
Us link as close button
timlandolt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| import FerbeTemplate from "ferbe/elements/ferbe_template"; | ||
| import { application } from "controllers/application"; | ||
| import FerbeEditorController from "ferbe/controllers/ferbe_editor_controller"; | ||
|
|
||
| customElements.define("ferbe-template", FerbeTemplate); | ||
| application.register("ferbe-editor", FerbeEditorController); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import FerbeTemplate from "ferbe/elements/ferbe_template"; | ||
| import editorUrl from "ferbe/utils/editor_url"; | ||
|
|
||
| customElements.define("ferbe-template", FerbeTemplate); | ||
|
|
||
| addEventListener("ferbe:open-editor", (event) => { | ||
| const editor = document.getElementById("ferbe-editor"); | ||
| if (editor) return; | ||
|
|
||
| const template = event.detail; | ||
| window.location.href = editorUrl(template); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| export default function editorUrl(template) { | ||
| const params = new URLSearchParams(); | ||
|
|
||
| params.append("url", template.url); | ||
| params.append("template[path]", template.filePath); | ||
| template.renderPath.forEach((p) => | ||
| params.append("template[render_path][]", p), | ||
| ); | ||
|
|
||
| return `/ferbe/template/edit?${params.toString()}`; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| ferbe-template { | ||
| display: contents; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| <%# locals: (url:, template:) %> | ||
|
|
||
| <div data-controller="ferbe-editor" | ||
| data-action="ferbe:open-editor@window->ferbe-editor#open"> | ||
| <div class="ferbe__header"> | ||
| <%= link_to "❌", url, class: "ferbe__button" %> | ||
| <h2><%= Pathname.new(template[:path]).relative_path_from(Rails.root) %></h2> | ||
| </div> | ||
| <pre class="ferbe__render-path"> | ||
| <% template[:render_path].each_with_index do |path, level| %> | ||
| <%= " " * level %>> <%= link_to(Pathname.new(path).relative_path_from(Rails.root), | ||
| edit_template_url(url: , | ||
| template: { | ||
| path: path, | ||
| render_path: template[:render_path] | ||
| }), | ||
| data: { turbo_stream: true }) %> | ||
| <% end %> | ||
| </pre> | ||
| <%= form_with url: template_url, | ||
| method: :patch, | ||
| scope: :template, | ||
| data: { ferbe_editor_target: "form" } do |form| %> | ||
| <%= form.hidden_field :path, value: template[:path] %> | ||
| <%= form.hidden_field :content, | ||
| value: template[:content], | ||
| data: { ferbe_editor_target: "input" } %> | ||
| <pre><code data-ferbe-editor-target="editor" | ||
| data-action="keydown.ctrl+s->ferbe-editor#save:prevent | ||
| keydown.meta+s->ferbe-editor#save:prevent"><%= template[:content] %></code></pre> | ||
| <%= form.submit "💾", class: "ferbe__button ferbe__save-button" %> | ||
| <% end %> | ||
| </div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| <div class="ferbe__page"> | ||
| <iframe src="<%= @url %>"></iframe> | ||
|
|
||
| <%= tag.div class: "ferbe__editor", id: "ferbe-editor", data: { | ||
| modifier_key: Ferbe.configuration.modifier_key, | ||
| use_local_editor: Ferbe.configuration.use_local_editor, | ||
| turbo_permanent: true | ||
| } do %> | ||
| <%= render partial: "editor", locals: { url: @url, template: @template } %> | ||
| <% end %> | ||
| </div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,32 +1,3 @@ | ||
| <%= turbo_stream.update "ferbe-editor" do %> | ||
| <div data-controller="ferbe-editor"> | ||
| <div class="ferbe__header"> | ||
| <button data-action="ferbe-editor#close" class="ferbe__button">❌</button> | ||
| <h2><%= Pathname.new(@template[:path]).relative_path_from(Rails.root) %></h2> | ||
| </div> | ||
| <pre class="ferbe__render-path"> | ||
| <% @template[:render_path].each_with_index do |path, level| %> | ||
| <%= " " * level %>> <%= link_to( Pathname.new(path).relative_path_from(Rails.root), | ||
| edit_template_url(template: { | ||
| path: path, | ||
| render_path: @template[:render_path] | ||
| }), | ||
| data: { turbo_stream: true }) %> | ||
| <% end %> | ||
| </pre> | ||
| <%= form_with url: template_url, | ||
| method: :patch, | ||
| scope: :template, | ||
| data: { ferbe_editor_target: "form" } do |form| %> | ||
| <%= form.hidden_field :path, value: @template[:path] %> | ||
| <%= form.hidden_field :content, | ||
| value: @template[:content], | ||
| data: { ferbe_editor_target: "input" } %> | ||
| <pre><code data-ferbe-editor-target="editor" | ||
| data-action="keydown.ctrl+s->ferbe-editor#save:prevent | ||
| keydown.meta+s->ferbe-editor#save:prevent"><%= @template[:content] %></code></pre> | ||
| <%= form.submit "💾", class: "ferbe__button ferbe__save-button" %> | ||
| <% end %> | ||
| <pre class="ferbe__error-container" data-ferbe-editor-target="errorContainer"></pre> | ||
| </div> | ||
| <%= render partial: "editor", locals: { url: @url, template: @template } %> | ||
| <% end %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| <!DOCTYPE html> | ||
| <html> | ||
| <head> | ||
| <title>Ferbe Editor</title> | ||
| <%= csrf_meta_tags %> | ||
| <%= csp_meta_tag %> | ||
|
|
||
| <%= yield :head %> | ||
|
|
||
| <%= javascript_importmap_tags %> | ||
| <%= javascript_import_module_tag "ferbe/application" %> | ||
|
|
||
| <%= stylesheet_link_tag "ferbe/highlight", media: "all" %> | ||
| <%= stylesheet_link_tag "ferbe/application", media: "all" %> | ||
| </head> | ||
| <body> | ||
|
|
||
| <%= yield %> | ||
|
|
||
| </body> | ||
| </html> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are still static paths.