Feat(CodeEditor): Support add extra libs
This commit is contained in:
33
src/util/editorExtraLibs/_NativeApi.d.ts
vendored
Normal file
33
src/util/editorExtraLibs/_NativeApi.d.ts
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
interface NativeApi {
|
||||
/**
|
||||
* Copy text to clipboard
|
||||
*
|
||||
* @param {string} text Text to be copied to clipboard
|
||||
* @returns {boolean} Result
|
||||
*/
|
||||
copyToClipboard: (text: string) => boolean
|
||||
|
||||
/**
|
||||
* Read text from clipboard
|
||||
*
|
||||
* @returns {string} Result
|
||||
*/
|
||||
readClipboard: () => string
|
||||
|
||||
/**
|
||||
* Save file to download directory
|
||||
*
|
||||
* @param {string} dataBase64 Base64 encoded data
|
||||
* @param {string} fileName File name to be saved
|
||||
* @returns {boolean} Result
|
||||
*
|
||||
* @example
|
||||
* // From Unit8Array:
|
||||
* NativeApi.saveToDownloads(btoa(String.fromCharCode(...data)))
|
||||
* // From string:
|
||||
* NativeApi.saveToDownloads(btoa(String.fromCharCode(...new TextEncoder().encode(text))))
|
||||
*/
|
||||
saveToDownloads: (dataBase64: string, fileName: string) => boolean
|
||||
}
|
||||
|
||||
declare const NativeApi: NativeApi
|
||||
7
src/util/editorExtraLibs/_index.d.ts
vendored
Normal file
7
src/util/editorExtraLibs/_index.d.ts
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
interface Window {
|
||||
/**
|
||||
* Initialization tool.\
|
||||
* This method must be implemented to run the tool.
|
||||
*/
|
||||
initOxygenTool: (id: string) => void
|
||||
}
|
||||
16
src/util/editorExtraLibs/index.ts
Normal file
16
src/util/editorExtraLibs/index.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { ExtraLib } from '@/components/Playground/CodeEditor/Editor'
|
||||
import indexDTS from '@/util/editorExtraLibs/_index.d.ts?raw'
|
||||
import nativeApiDTS from '@/util/editorExtraLibs/_NativeApi.d.ts?raw'
|
||||
|
||||
const editorExtraLibs: ExtraLib[] = [
|
||||
{
|
||||
path: 'file:///node_modules/_index.d.ts',
|
||||
content: indexDTS
|
||||
},
|
||||
{
|
||||
path: 'file:///node_modules/_NativeApi.d.ts',
|
||||
content: nativeApiDTS
|
||||
}
|
||||
]
|
||||
|
||||
export default editorExtraLibs
|
||||
Reference in New Issue
Block a user