-
Notifications
You must be signed in to change notification settings - Fork 52
/
Copy pathindex.ts
executable file
·44 lines (38 loc) · 1.26 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import type { App } from "vue";
import type { EditorConfiguration, Editor } from "codemirror";
import VueCodemirror from "./src/components/index.vue";
import "./src/style/index.css";
import _CodeMirror from "./src/sourceLib";
interface CmComp {
cminstance: Editor;
resize: (width?: string | number | null, height?: string | number | null) => void;
refresh: () => void;
destroy: () => void;
}
export type CmComponentRef = CmComp | null;
declare interface InstallConfig {
options: EditorConfiguration;
componentName: string;
}
const install = (app: App, config?: InstallConfig) => {
if (config) {
if (config.options) {
VueCodemirror.props.globalOptions.default = () => config.options;
}
}
app.component(config?.componentName || "Codemirror", VueCodemirror);
return app;
};
const CodeMirror = window.CodeMirror || _CodeMirror;
/**
* Use global components.
* @example
* import { createApp } from "vue";
* const app = createApp(App);
* app.use(InstallCodeMirror, { componentName: "customCodemirrorComponentName" });
*/
const GlobalCmComponent = install;
const InstallCodeMirror = install;
export * from "./src/components/presetMode/log/utils";
export { CodeMirror, GlobalCmComponent, InstallCodeMirror, VueCodemirror };
export default VueCodemirror;