Sha256: 502b874a9b9f7352c3a008b5f48f464d207e30478533d79f0664cad236619e6e
Contents?: true
Size: 1.35 KB
Versions: 469
Compression:
Stored size: 1.35 KB
Contents
<%= pb_rails("rich_text_editor", props: { id: "content-preview-editor" }) %> <div id="card-obfuscation" style="display:none"> <%= pb_rails("card", props: { margin_top: "md", max_width: "md", padding: "sm" }) do %> <div id="content-preview" class="trix-content"> </div> <% end %> </div> <%= pb_rails("button", props: { id: "preview-button", variant: "secondary", margin_top: "md" }) do %> <span>Preview Output</span> <% end %> <script> document.addEventListener('DOMContentLoaded', () => { function handleButtonClick() { const editorContainer = [...document.querySelectorAll('[data-react-props]')] .find(element => element.getAttribute('data-react-props')?.includes('"id":"content-preview-editor"')) const editorElement = editorContainer?.querySelector('trix-editor') const inputId = editorElement?.getAttribute('input') const inputElement = inputId && document.getElementById(inputId) const editorContent = inputElement?.value || '' const previewArea = document.getElementById('content-preview') const cardDiv = document.getElementById('card-obfuscation') if (previewArea && cardDiv) { previewArea.innerHTML = editorContent cardDiv.style.display = 'block' } } document.getElementById('preview-button')?.addEventListener('click', handleButtonClick) }) </script>
Version data entries
469 entries across 469 versions & 2 rubygems