Skip to content

Commit 0104878

Browse files
committed
feat: disable preview panel buttons in read-only mode
- Block all buttons inside #markdown-preview (remove, run, fill, open, etc.) - Extend click interceptor to show toast for preview button clicks - Uses blanket selector for future-proof coverage
1 parent 45d1064 commit 0104878

3 files changed

Lines changed: 7 additions & 2 deletions

File tree

changelogs/CHANGELOG-readonly-lockdown.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@ Enforces true read-only mode when viewing shared documents. Previously only the
1010

1111
### styles.css
1212
- Added `body.editor-readonly` CSS rules targeting all editing buttons (`.fmt-btn`, tag buttons, QAB write controls, find/replace, dropzone)
13+
- Added `body.editor-readonly #markdown-preview button` to disable ALL interactive buttons in the preview panel (remove-tag, run, preview, fill, open, close, etc.)
1314
- Disabled buttons show `opacity: 0.35`, `cursor: not-allowed`, and `user-select: none` with `!important`
1415

1516
### js/cloud-share.js
1617
- `showSharedBanner()`: adds `editor-readonly` class to `<body>` alongside `readOnly = true`
1718
- `hideSharedBanner()`: removes `editor-readonly` class alongside `readOnly = false`
1819
- Added capturing click interceptor for disabled buttons — shows "🔒 Read-only mode — editing is disabled" toast
20+
- Click interceptor also covers all buttons inside `#markdown-preview`
1921

2022
### js/editor-features.js
2123
- Added `if (M.markdownEditor.readOnly) return;` guard to 7 core functions:

js/cloud-share.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,9 @@
459459
'#qab-copy, .ai-action-chip, .ai-ctx-btn, ' +
460460
'#replace-one, #replace-all, #qab-replace-one, #qab-replace-all'
461461
);
462-
if (target) {
462+
// Also block any button inside the preview panel
463+
var previewBtn = !target && e.target.closest('#markdown-preview button');
464+
if (target || previewBtn) {
463465
e.preventDefault();
464466
e.stopImmediatePropagation();
465467
if (M.showToast) M.showToast('🔒 Read-only mode — editing is disabled', 'warning');

styles.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6430,7 +6430,8 @@ body.editor-readonly #replace-one,
64306430
body.editor-readonly #replace-all,
64316431
body.editor-readonly #qab-replace-one,
64326432
body.editor-readonly #qab-replace-all,
6433-
body.editor-readonly .dropzone-wrapper {
6433+
body.editor-readonly .dropzone-wrapper,
6434+
body.editor-readonly #markdown-preview button {
64346435
opacity: 0.35 !important;
64356436
cursor: not-allowed !important;
64366437
user-select: none !important;

0 commit comments

Comments
 (0)