Conversation
Co-authored-by: cyanzhong <6745066+cyanzhong@users.noreply.github.com>
Co-authored-by: cyanzhong <6745066+cyanzhong@users.noreply.github.com>
.gitignore
Outdated
main.ts
Outdated
main.ts
Outdated
| { separator: true }, | ||
| ...createHtmlItems(), | ||
| { separator: true }, | ||
| { |
…ubmenu Co-authored-by: cyanzhong <6745066+cyanzhong@users.noreply.github.com>
main.ts
Outdated
| state: () => ({ isEnabled: isPageZoomAvailable() }), | ||
| }, | ||
| { | ||
| title: localized('resetZoom'), |
There was a problem hiding this comment.
@copilot make this the first item (don't forget the change the order of code used in other places)
There was a problem hiding this comment.
Reordered in 3bed8d8. Reset Zoom is now the first menu item, and the order has been updated consistently in:
- Menu items (main.ts)
- Function definitions (src/view.ts)
- Import statements (main.ts)
- Localization keys (src/strings.ts for all 3 locales)
Co-authored-by: cyanzhong <6745066+cyanzhong@users.noreply.github.com>
src/view.ts
Outdated
| const MIN_ZOOM_LEVEL = 0.5; | ||
| const MAX_ZOOM_LEVEL = 3.0; | ||
|
|
||
| function clampZoom(value: number): string { |
There was a problem hiding this comment.
@copilot Private should be the bottom, move this after updateGutterStyle.
There was a problem hiding this comment.
Moved in b6cbfdb. The clampZoom function and zoom constants (DEFAULT_ZOOM_LEVEL, MIN_ZOOM_LEVEL, MAX_ZOOM_LEVEL) are now positioned after updateGutterStyle, placing private functions at the bottom of the file as requested.
src/view.ts
Outdated
| case '-': previewPane.style.zoom = clamp(zoom - 0.1); break; | ||
| case '=': previewPane.style.zoom = clamp(zoom + 0.1); break; | ||
| case '0': previewPane.style.zoom = '1'; break; | ||
| case '-': previewPane.style.zoom = clampZoom(zoom - 0.1); break; |
There was a problem hiding this comment.
@copilot think about, can we leverage the newly added functions?
There was a problem hiding this comment.
Refactored in abd0c5b. handlePageZoom now calls resetPageZoom(), increasePageZoom(), and decreasePageZoom() directly instead of duplicating the zoom logic.
src/view.ts
Outdated
|
|
||
| export function resetPageZoom() { | ||
| previewPane.style.zoom = String(DEFAULT_ZOOM_LEVEL); | ||
| localStorage.setItem( |
Co-authored-by: cyanzhong <6745066+cyanzhong@users.noreply.github.com>
Co-authored-by: cyanzhong <6745066+cyanzhong@users.noreply.github.com>
|
@copilot In this PR, you should never run npm install or yarn install, revert changes in |
Co-authored-by: cyanzhong <6745066+cyanzhong@users.noreply.github.com>
src/view.ts
Outdated
| } | ||
|
|
||
| export function resetPageZoom() { | ||
| previewPane.style.zoom = String(DEFAULT_ZOOM_LEVEL); |
There was a problem hiding this comment.
@copilot define a const zoom to be consistent with others.
There was a problem hiding this comment.
Fixed in 412aff4. Now resetPageZoom() defines const zoom = DEFAULT_ZOOM_LEVEL to match the pattern used in increasePageZoom() and decreasePageZoom().
Co-authored-by: cyanzhong <6745066+cyanzhong@users.noreply.github.com>
main.ts
Outdated
| { | ||
| title: localized('resetZoom'), | ||
| action: resetPageZoom, | ||
| key: '0', |
main.ts
Outdated
| { separator: true }, | ||
| ...createHtmlItems(), | ||
| { separator: true }, | ||
| { |
There was a problem hiding this comment.
@copilot Add this menu only if MarkEdit version >= 1.29.2, you can get the version number from navigator.userAgent, which returns a value like Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) macOS/26.3.0 MarkEdit/1.29.1.
There was a problem hiding this comment.
Implemented in 85af9c6. The Page Zoom menu is now conditionally added only when MarkEdit version >= 1.29.2. The version is extracted from navigator.userAgent using a regex pattern that matches "MarkEdit/x.y.z" format.
Co-authored-by: cyanzhong <6745066+cyanzhong@users.noreply.github.com>
5b83ed9 to
c197038
Compare
c197038 to
bd6c6c3
Compare
src/strings.ts
Outdated
| copyCode: 'Copy Code', | ||
| untitled: 'Untitled', | ||
| pageZoom: 'Page Zoom', | ||
| resetZoom: 'Reset Zoom', |
There was a problem hiding this comment.
@copilot do you think if "Reset Zoom Level", "Increase Zoom Level" are better narrative?
There was a problem hiding this comment.
Updated in 4d61ce9. Changed to "Reset Zoom Level", "Increase Zoom Level", and "Decrease Zoom Level" for better clarity. The "Level" suffix makes it more explicit what's being reset/adjusted.
src/utils.ts
Outdated
| @@ -1,3 +1,29 @@ | |||
| export function appVersionGreaterThan(target: string) { | |||
There was a problem hiding this comment.
@copilot Do you have better naming idea for this function? Also try if you can improve the implementation, don't create new functions.
There was a problem hiding this comment.
Improved in 4d61ce9:
- Renamed to
appVersionGreaterOrEqual(more accurate since it returns true on equality) - Simplified implementation: removed IIFE, used ternary for clearer code
- Fixed logic: now returns
truefor equal versions (was incorrectly returningfalse) - Updated version check to '1.29.2' to match the requirement
Co-authored-by: cyanzhong <6745066+cyanzhong@users.noreply.github.com>
Adds a "Page Zoom" submenu to the View Mode menu with options to reset, increase, and decrease page zoom levels. The menu is conditionally displayed only in MarkEdit version 1.29.2 or later for backward compatibility.
Changes Made
resetPageZoom(),increasePageZoom(), anddecreasePageZoom()functions in view.ts with shared helpersavePageZoom()to persist zoom statecanHandlePageZoom()helperappVersionGreaterOrEqual()utility functionhandlePageZoomto reuse the new zoom functions, eliminating code duplication. Extracted shared constants (DEFAULT_ZOOM_LEVEL, MIN_ZOOM_LEVEL, MAX_ZOOM_LEVEL) and helper functions (clampZoom, savePageZoom)appVersionGreaterOrEqual()to correctly handle version equality and simplified its implementationTechnical Details
state: () => ({ isEnabled: canHandlePageZoom() })pattern for dynamic availabilityappVersionGreaterOrEqual()utility that parses user agent format: "Mozilla/5.0 (...) macOS/26.3.0 MarkEdit/1.29.1"handlePageZoomfunctionThe implementation follows existing code patterns and maintains consistency with the codebase style.
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.