-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: support oceanbase monaco plugin (#1386)
- Loading branch information
Showing
8 changed files
with
2,474 additions
and
113 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
|
||
import type Plugin from '@oceanbase-odc/monaco-plugin-ob'; | ||
|
||
let plugin: Plugin; | ||
|
||
export async function register(): Promise<Plugin> { | ||
window.obMonaco = { | ||
getWorkerUrl: (type: string) => { | ||
switch (type) { | ||
case 'mysql': { | ||
return location.origin + '/_next/static/ob-workers/mysql.js' | ||
} | ||
case 'obmysql': { | ||
return location.origin + '/_next/static/ob-workers/obmysql.js' | ||
} | ||
case 'oboracle': { | ||
return location.origin + '/_next/static/ob-workers/oracle.js' | ||
} | ||
} | ||
return ""; | ||
} | ||
} | ||
const module = await import('@oceanbase-odc/monaco-plugin-ob') | ||
const Plugin = module.default; | ||
if (plugin) { | ||
return plugin; | ||
} | ||
plugin = new Plugin(); | ||
plugin.setup(["mysql"]); | ||
return plugin; | ||
} |
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,21 @@ | ||
import type { IModelOptions } from '@oceanbase-odc/monaco-plugin-ob/dist/type'; | ||
import { ISession } from '../monaco-editor'; | ||
|
||
|
||
export function getModelService( | ||
{ modelId, delimiter }: { modelId: string; delimiter: string }, | ||
session?: () => ISession | null | ||
): IModelOptions { | ||
return { | ||
delimiter, | ||
async getTableList(schemaName?: string) { | ||
return session?.()?.getTableList(schemaName) || [] | ||
}, | ||
async getTableColumns(tableName: string, dbName?: string) { | ||
return session?.()?.getTableColumns(tableName) || [] | ||
}, | ||
async getSchemaList() { | ||
return session?.()?.getSchemaList() || [] | ||
}, | ||
}; | ||
} |
Oops, something went wrong.