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/nodes | |
| 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/nodes')
| -rw-r--r-- | app/views/nodes/edit.html.erb | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/app/views/nodes/edit.html.erb b/app/views/nodes/edit.html.erb index e0e51d8..9506995 100644 --- a/app/views/nodes/edit.html.erb +++ b/app/views/nodes/edit.html.erb | |||
| @@ -116,10 +116,27 @@ | |||
| 116 | <div class="node_content"><%= d.text_area :abstract %></div> | 116 | <div class="node_content"><%= d.text_area :abstract %></div> |
| 117 | 117 | ||
| 118 | <div class="node_description">Body</div> | 118 | <div class="node_description">Body</div> |
| 119 | <div class="node_content"><%= d.text_area :body, :class => 'with_editor' %></div> | 119 | <div class="body_toolbar_row"> |
| 120 | <button type="button" id="preview_toggle" class="view_toggle" aria-pressed="false" aria-label="Toggle live preview" title="Toggle live preview"> | ||
| 121 | <%= icon("layout-sidebar-right", library: "tabler", "aria-hidden": true) %> <span>Live preview</span> | ||
| 122 | </button> | ||
| 123 | <button type="button" id="preview_force_render" class="view_toggle" style="display:none" aria-label="Force preview render" title="Force preview render"> | ||
| 124 | <%= icon("refresh", library: "tabler", "aria-hidden": true) %> <span>Force refresh</span> | ||
| 125 | </button> | ||
| 126 | </div> | ||
| 127 | |||
| 128 | <div id="editor_and_preview"> | ||
| 129 | <div class="preview_content"> | ||
| 130 | <div class="node_content"><%= d.text_area :body, :class => 'with_editor' %></div> | ||
| 131 | </div> | ||
| 132 | <div id="preview_panel" style="display:none"> | ||
| 133 | <iframe id="live_preview_iframe" title="Live preview" data-src="<%= preview_page_path(@page, :locale => I18n.default_locale) %>"></iframe> | ||
| 134 | </div> | ||
| 135 | </div> | ||
| 136 | </div> | ||
| 120 | <% end %> | 137 | <% end %> |
| 121 | 138 | ||
| 122 | <div class="node_action_bar node_action_bar_save"> | 139 | <div class="node_action_bar"> |
| 123 | <%= f.submit 'Save Draft' %> | 140 | <%= f.submit 'Save Draft' %> |
| 124 | <%= f.submit 'Save + Unlock + Exit' %> | 141 | <%= f.submit 'Save + Unlock + Exit' %> |
| 125 | </div> | 142 | </div> |
