Make preview overlay's inset configurable via CSS variable#95
Merged
cyanzhong merged 2 commits intoMarkEdit-app:mainfrom Apr 29, 2026
Merged
Make preview overlay's inset configurable via CSS variable#95cyanzhong merged 2 commits intoMarkEdit-app:mainfrom
cyanzhong merged 2 commits intoMarkEdit-app:mainfrom
Conversation
In preview-only mode, the preview pane uses position:absolute + inset:0, which is sized against the viewport regardless of any padding on body. That makes it impossible for a third-party plugin (e.g. a left-edge sidebar) to coexist with preview mode without overriding this rule via class-name targeting. Replace inset:0 with explicit top/right/bottom values plus left: var(--markedit-content-inset-left, 0). The fallback keeps existing behaviour identical when no plugin sets the variable. Plugins that occupy a horizontal slice on the left can now declare their offset via the CSS variable and compose cleanly with preview overlay mode without reaching into preview's class names.
Contributor
|
Thank you for your contribution. The idea makes sense to me. |
cyanzhong
reviewed
Apr 29, 2026
| top: 0; | ||
| right: 0; | ||
| bottom: 0; | ||
| left: var(--markedit-content-inset-left, 0); |
Contributor
There was a problem hiding this comment.
@gpolitis Instead of only left, what about make inset a variable?
Do you think if it will be more useful or too much?
Contributor
Author
There was a problem hiding this comment.
Good call, agreed. Pushed 5beca15 switching to a single --markedit-content-inset variable. Plugins set the shorthand (e.g. --markedit-content-inset: 0 0 0 268px;), and calc() / nested var() work inside it.
Per review feedback: cover all four edges with one shorthand-valued custom property instead of a per-side variable for left only. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
Author
|
Thank you for accepting this! |
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.
Why
Third-party plugins that occupy a slice on the left edge of the viewport (e.g. a TOC sidebar) can't currently coexist with preview-only mode:
.markdown-body.overlayusesposition: absolute; inset: 0against the viewport, ignoring anypadding-inline-startonbody. The only workaround is!importantoverrides targeting preview's class names, which is fragile.Concrete example — my outline plugin currently ships with this compatibility shim:
https://github.com/gpolitis/MarkEdit-outline/blob/2cbbea0bb99de604a5a1cf73862155bcb95e8ee3/markedit-outline.js#L164-L170
The shim works but couples the two plugins via class-name targeting, which silently breaks if either side renames a class.
What
Replace
inset: 0with explicit per-side values, readingleftfrom a CSS custom property with a0fallback:A plugin that claims a left slice declares the variable on
bodywhen active:CSS custom properties cascade through the DOM, so preview's overlay pane picks it up automatically.
Backward compatibility
When no plugin sets the variable,
0is used and the layout is byte-identical to today. No other selectors changed.Scope
Scoped to
leftonly since that's the only side affected today. If future plugins need other edges, mirror variables fortop/right/bottomare a natural addition — leaving that for when there's a concrete use case.