Add extension menu items#21
Conversation
…elease Co-authored-by: cyanzhong <6745066+cyanzhong@users.noreply.github.com>
Co-authored-by: cyanzhong <6745066+cyanzhong@users.noreply.github.com>
|
|
||
| const repoUrl = 'https://github.com/MarkEdit-app/MarkEdit-proofreading'; | ||
|
|
||
| export function buildMenuItems(): MenuItem[] { |
There was a problem hiding this comment.
@copilot The menu hierarchy is wrong. It should be under a "Proofread" menu (leverage children).
Also, add icon to the "Proofread" menu, it's a sf symbol.
There was a problem hiding this comment.
Restructured as a parent "Proofread" menu with children and added icon: 'text.badge.checkmark' in a1867a3.
Co-authored-by: cyanzhong <6745066+cyanzhong@users.noreply.github.com>
| import { setDiagnosticsEffect, lintToDiagnostic } from './decoration'; | ||
| import { lint } from './lint'; | ||
|
|
||
| const repoUrl = 'https://github.com/MarkEdit-app/MarkEdit-proofreading'; |
| }; | ||
| } | ||
|
|
||
| export function addMenuItems() { |
There was a problem hiding this comment.
@copilot this is not needed, since buildMenuItem is already export, move it to main.ts.
There was a problem hiding this comment.
Removed addMenuItems() and moved the MarkEdit.addMainMenuItem(buildMenuItem()) call directly into main.ts in 992eccd.
…Item directly in main.ts Co-authored-by: cyanzhong <6745066+cyanzhong@users.noreply.github.com>
| const text = doc.sliceString(0); | ||
| const lints = await lint(text); | ||
|
|
||
| if (view.state.doc !== doc) { |
There was a problem hiding this comment.
@copilot What are you doing here? Is this really a needed pattern??
There was a problem hiding this comment.
Removed the stale document check in 70b343d. The lintScheduler in extension.ts already handles auto-refresh on doc changes, so this guard isn't needed for a manual user action.
Co-authored-by: cyanzhong <6745066+cyanzhong@users.noreply.github.com>
Co-authored-by: cyanzhong <6745066+cyanzhong@users.noreply.github.com>
|
|
||
| async function proofreadNow() { | ||
| const view = MarkEdit.editorView; | ||
| const text = view.state.doc.sliceString(0); |
There was a problem hiding this comment.
@copilot So you have two sliceString(0) in this codebase, this makes me doubt your skills.
These could have been just .toString(), why not use this?
There was a problem hiding this comment.
Replaced both sliceString(0) calls with .toString() in menu.ts and extension.ts in b9de631.
Co-authored-by: cyanzhong <6745066+cyanzhong@users.noreply.github.com>
|
@copilot Do final self-review. |
Final self-review complete on b9de631.
No additional code changes are needed from this self-review. |
There was a problem hiding this comment.
Pull request overview
Adds a “Proofread” submenu to the MarkEdit extension UI so users can manually trigger proofreading actions and navigate to release information, following the menu registration pattern used by MarkEdit extensions.
Changes:
- Injects
__PKG_VERSION__at build time via Vite and declares its TypeScript global type. - Introduces
src/menu.tsto build a parent “Proofread” menu with child actions (“Proofread Now”, “Ignore All”, version, releases link). - Registers the menu in
main.tsand adds a Vitest test to validate the menu structure.
Reviewed changes
Copilot reviewed 6 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| vite.config.mts | Defines __PKG_VERSION__ from package.json for build-time replacement. |
| types/globals.d.ts | Declares the global __PKG_VERSION__ type for TS. |
| tsconfig.json | Enables JSON module resolution needed for importing package.json. |
| src/menu.ts | Implements the “Proofread” menu structure and wires actions to lint/diagnostics. |
| src/extension.ts | Uses doc.toString() to read full document text during scheduled linting. |
| src/const.ts | Adds repoUrl constant for GitHub release links. |
| main.ts | Registers the menu item with MarkEdit.addMainMenuItem(...). |
| tests/menu.test.ts | Verifies parent/child menu structure and action presence. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Registers menu entries under a parent "Proofread" submenu with an SF Symbol icon, mirroring the pattern from MarkEdit-preview.
src/const.ts— Shared constants; exports therepoUrlfor the GitHub repository.src/menu.ts— New module withbuildMenuItem(). Creates a parent "Proofread" menu item (icon: 'text.badge.checkmark') withchildren: "Proofread Now" (re-runs Harper vialint()and dispatches results), "Ignore All" (clears diagnostics), separator, version item, and GitHub releases link.vite.config.mts— Injects__PKG_VERSION__frompackage.jsonat build time viadefine.types/globals.d.ts— Type declaration for the__PKG_VERSION__global.main.ts— CallsMarkEdit.addMainMenuItem(buildMenuItem())directly after extension registration.tests/menu.test.ts— Validates menu structure (parent title, icon, children count, titles, separator, action types).Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.