Updated shareable preview#108
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
This PR updates the “share via URL” experience by introducing a dedicated Share modal (with view-only vs edit link modes) and adjusting shared-link loading behavior to open the appropriate view mode. It also adds a preprocessing step intended to protect escaped dollar signs from being misinterpreted by MathJax.
Changes:
- Add a new Share modal UI to generate/copy share links with “View only” vs “Edit” modes.
- Update share-hash loading to support an
&edit=1flag and switch view mode accordingly. - Add Share modal styles and a Markdown preprocess step for escaped dollar signs.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
index.html |
Adds Share modal markup (mode cards, URL field, copy/close controls). |
styles.css |
Adds styling for the Share modal and selectable mode cards. |
script.js |
Implements Share modal behavior, share URL building/parsing (incl. edit=1), and adds a preprocess hook for escaped $. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+669
to
+670
| // This prevents MathJax from treating lone $ as a math delimiter. | ||
| const protectedMarkdown = markdown.replace(/\\\$/g, '$'); |
Comment on lines
+5062
to
+5081
| function openShareModal() { | ||
| // Reset to view-only by default each time | ||
| shareModeView.checked = true; | ||
| syncShareCardStyles(); | ||
| updateShareUrlField(); | ||
| shareModal.style.display = ''; | ||
| requestAnimationFrame(() => { | ||
| shareModal.classList.add('is-visible'); | ||
| shareModal.setAttribute('aria-hidden', 'false'); | ||
| }); | ||
| } | ||
|
|
||
| const originalHTML = btn.innerHTML; | ||
| const copiedHTML = '<i class="bi bi-check-lg"></i> Copied!'; | ||
| function closeShareModal() { | ||
| shareModal.classList.remove('is-visible'); | ||
| shareModal.setAttribute('aria-hidden', 'true'); | ||
| shareModal.addEventListener('transitionend', function handler() { | ||
| shareModal.style.display = 'none'; | ||
| shareModal.removeEventListener('transitionend', handler); | ||
| }); | ||
| } |
| } | ||
|
|
||
| .share-mode-card.is-selected { | ||
| border-color: var(--accent-color); |
Comment on lines
+2724
to
+2730
| .share-mode-card.is-selected { | ||
| border-color: var(--accent-color); | ||
| background: color-mix(in srgb, var(--accent-color) 8%, transparent); | ||
| } | ||
|
|
||
| .share-mode-card input[type="radio"] { | ||
| display: none; |
| </div> | ||
| <div class="share-url-row"> | ||
| <input type="text" id="share-url-input" class="rename-modal-input share-url-input" readonly placeholder="Generating link…" aria-label="Share URL" /> | ||
| <button class="reset-modal-btn share-copy-btn" id="share-copy-btn" title="Copy link"> |
Comment on lines
+484
to
+528
| <!-- Share Modal --> | ||
| <div id="share-modal" class="reset-modal-overlay modal-overlay" role="dialog" aria-modal="true" aria-labelledby="share-modal-title" aria-hidden="true" style="display:none;"> | ||
| <div class="reset-modal-box reset-modal-box--wide modal-box"> | ||
| <div class="modal-header"> | ||
| <p id="share-modal-title" class="reset-modal-message">Share Document</p> | ||
| <button type="button" class="modal-close-btn" id="share-modal-close-icon" aria-label="Close share dialog"> | ||
| <i class="bi bi-x-lg"></i> | ||
| </button> | ||
| </div> | ||
| <div class="modal-body"> | ||
| <p class="share-modal-description">Choose how recipients can interact with this document.</p> | ||
| <div class="share-mode-cards"> | ||
| <label class="share-mode-card" id="share-card-view" for="share-mode-view"> | ||
| <input type="radio" id="share-mode-view" name="share-mode" value="view" checked /> | ||
| <span class="share-card-icon"><i class="bi bi-eye"></i></span> | ||
| <span class="share-card-body"> | ||
| <span class="share-card-title">View only</span> | ||
| <span class="share-card-desc">Opens in preview mode. The editor is hidden.</span> | ||
| </span> | ||
| <span class="share-card-check"><i class="bi bi-check-lg"></i></span> | ||
| </label> | ||
| <label class="share-mode-card" id="share-card-edit" for="share-mode-edit"> | ||
| <input type="radio" id="share-mode-edit" name="share-mode" value="edit" /> | ||
| <span class="share-card-icon"><i class="bi bi-pencil-square"></i></span> | ||
| <span class="share-card-body"> | ||
| <span class="share-card-title">Edit</span> | ||
| <span class="share-card-desc">Opens in split editor + preview mode.</span> | ||
| </span> | ||
| <span class="share-card-check"><i class="bi bi-check-lg"></i></span> | ||
| </label> | ||
| </div> | ||
| <div class="share-url-row"> | ||
| <input type="text" id="share-url-input" class="rename-modal-input share-url-input" readonly placeholder="Generating link…" aria-label="Share URL" /> | ||
| <button class="reset-modal-btn share-copy-btn" id="share-copy-btn" title="Copy link"> | ||
| <i class="bi bi-clipboard"></i> | ||
| </button> | ||
| </div> | ||
| <p class="share-modal-notice"><i class="bi bi-info-circle"></i> The entire document is encoded in the URL. No data is sent to any server.</p> | ||
| </div> | ||
| <div class="reset-modal-actions"> | ||
| <button class="reset-modal-btn reset-modal-cancel" id="share-modal-close">Close</button> | ||
| </div> | ||
| </div> | ||
| </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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.