diff options
| author | erdgeist <erdgeist@erdgeist.org> | 2026-07-14 04:10:01 +0200 |
|---|---|---|
| committer | erdgeist <erdgeist@erdgeist.org> | 2026-07-14 04:10:01 +0200 |
| commit | e0f2394fd0816ef03bf4b928ab9fa5a18c32ffda (patch) | |
| tree | 0c346c5167c06f1bd4be03c8fd4e358215ed2fbe /app/views/page_translations/edit.html.erb | |
| parent | 88ebeaac7fcf140cbab489e841bf9c197f84c4ea (diff) | |
Add a toggleable live preview panel to both editors
Hidden by default, shares horizontal space with the body editor once
opened rather than a separate section, and only requests the iframe's
src on first toggle -- no preview traffic at all until someone
actually wants to see it. Refreshes automatically on every successful
autosave; a separate force-render button re-attempts a save-and-
refresh cycle immediately, for when the normal 7-second cycle has
been interrupted (a lock-lost error, a transient failure) and waiting
for the next tick isn't good enough.
Diffstat (limited to 'app/views/page_translations/edit.html.erb')
| -rw-r--r-- | app/views/page_translations/edit.html.erb | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/app/views/page_translations/edit.html.erb b/app/views/page_translations/edit.html.erb index 981fb743..0f64d400 100644 --- a/app/views/page_translations/edit.html.erb +++ b/app/views/page_translations/edit.html.erb | |||
| @@ -20,8 +20,8 @@ | |||
| 20 | </div> | 20 | </div> |
| 21 | 21 | ||
| 22 | <div id="page_editor"> | 22 | <div id="page_editor"> |
| 23 | <%= form_with url: node_translation_path(@node, @locale), method: :patch, local: true, id: "translation_edit_form", | 23 | <%= form_with url: node_translation_path(@node, @locale), method: :patch, local: true, id: "translation_edit_form", |
| 24 | data: { autosave_url: autosave_node_translation_path(@node, @locale), show_url: node_path(@node) } do |f| %> | 24 | data: { autosave_url: autosave_node_translation_path(@node, @locale), show_url: node_path(@node) } do |f| %> |
| 25 | <div id="content"> | 25 | <div id="content"> |
| 26 | <div class="node_description">Title</div> | 26 | <div class="node_description">Title</div> |
| 27 | <div class="node_content"> | 27 | <div class="node_content"> |
| @@ -34,8 +34,24 @@ | |||
| 34 | </div> | 34 | </div> |
| 35 | 35 | ||
| 36 | <div class="node_description">Body</div> | 36 | <div class="node_description">Body</div> |
| 37 | <div class="node_content"> | 37 | <div class="body_toolbar_row"> |
| 38 | <%= text_area_tag "page[body]", @translation&.body, :class => 'with_editor' %> | 38 | <button type="button" id="preview_toggle" class="view_toggle" aria-pressed="false" aria-label="Toggle live preview" title="Toggle live preview"> |
| 39 | <%= icon("layout-sidebar-right", library: "tabler", "aria-hidden": true) %> <span>Live preview</span> | ||
| 40 | </button> | ||
| 41 | <button type="button" id="preview_force_render" class="view_toggle" style="display:none" aria-label="Force preview render" title="Force preview render"> | ||
| 42 | <%= icon("refresh", library: "tabler", "aria-hidden": true) %> <span>Force refresh</span> | ||
| 43 | </button> | ||
| 44 | </div> | ||
| 45 | |||
| 46 | <div id="editor_and_preview"> | ||
| 47 | <div class="preview_content"> | ||
| 48 | <div class="node_content"> | ||
| 49 | <%= text_area_tag "page[body]", @translation&.body, :class => 'with_editor' %> | ||
| 50 | </div> | ||
| 51 | </div> | ||
| 52 | <div id="preview_panel" style="display:none"> | ||
| 53 | <iframe id="live_preview_iframe" title="Live preview" data-src="<%= preview_page_path(@page, :locale => @locale) %>"></iframe> | ||
| 54 | </div> | ||
| 39 | </div> | 55 | </div> |
| 40 | </div> | 56 | </div> |
| 41 | <% end %> | 57 | <% end %> |
