feat: plugin config
update: package.json
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import RevueFlow from './container/RevueFlow';
|
||||
import { App, inject, InjectionKey } from 'vue-demi';
|
||||
|
||||
export default RevueFlow;
|
||||
|
||||
@@ -25,3 +26,32 @@ export { default as useUpdateNodeInternals } from './hooks/useUpdateNodeInternal
|
||||
|
||||
export * from './additional-components';
|
||||
export * from './types';
|
||||
|
||||
export interface RevueFlowOptions {
|
||||
theme: string;
|
||||
}
|
||||
|
||||
export interface RevueFlowPlugin {
|
||||
options?: RevueFlowOptions;
|
||||
|
||||
install(app: App): void;
|
||||
}
|
||||
|
||||
export const RevueFlowPluginSymbol: InjectionKey<RevueFlowPlugin> = Symbol();
|
||||
|
||||
export function RevueFlowPlugin(): RevueFlowPlugin {
|
||||
const RevueFlowPlugin = inject(RevueFlowPluginSymbol);
|
||||
if (!RevueFlowPlugin) throw new Error('No RevueFlowPlugin provided.');
|
||||
|
||||
return RevueFlowPlugin;
|
||||
}
|
||||
|
||||
export function createVueCounterPlugin(options?: RevueFlowOptions): RevueFlowPlugin {
|
||||
return {
|
||||
options,
|
||||
install(app: App) {
|
||||
app.component('revue-flow', RevueFlow);
|
||||
app.provide(RevueFlowPluginSymbol, this);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user