-
Notifications
You must be signed in to change notification settings - Fork 882
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
33 changed files
with
1,206 additions
and
672 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { Plugin } from '@fe/context' | ||
import { getInitialized, getLoadStatus } from '@fe/others/extension' | ||
import type { languages } from 'monaco-editor' | ||
|
||
export default { | ||
name: 'ai-copilot', | ||
register: ctx => { | ||
ctx.editor.whenEditorReady().then(({ monaco }) => { | ||
const extensionId = '@yank-note/extension-ai-copilot' | ||
const actionId = 'install-ai-copilot-extension' | ||
const checkExtensionLoaded = () => !!getLoadStatus(extensionId).version | ||
|
||
monaco.languages.registerCodeActionProvider('*', { | ||
provideCodeActions (): languages.CodeActionList { | ||
const actionTitle = ctx.i18n.t('edit-or-generate-text-using-ai') | ||
|
||
if (!getInitialized() || checkExtensionLoaded()) { | ||
return { dispose: () => 0, actions: [] } | ||
} | ||
|
||
const actions: languages.CodeAction[] = [{ | ||
title: actionTitle, | ||
command: { id: actionId, title: actionTitle }, | ||
kind: 'refactor', | ||
diagnostics: [], | ||
isPreferred: true, | ||
}] | ||
|
||
return { | ||
dispose: () => 0, | ||
actions | ||
} | ||
}, | ||
|
||
async resolveCodeAction (codeAction: languages.CodeAction): Promise<languages.CodeAction | undefined> { | ||
if (codeAction.command?.id === actionId) { | ||
ctx.showExtensionManager(extensionId) | ||
} | ||
|
||
return undefined | ||
} | ||
}) | ||
}) | ||
} | ||
} as Plugin |
Oops, something went wrong.