Skip to content

Commit

Permalink
fix: fix not unique plugin name, and overwriting each other
Browse files Browse the repository at this point in the history
  • Loading branch information
wa0x6e committed Mar 16, 2023
1 parent 96b376f commit 87cd250
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ declare namespace CalHeatmap {
destroy: () => Promise<unknown>;
}
export interface IPluginContructor {
new (calendar: CalHeatmap): IPlugin;
new (calendar?: CalHeatmap): IPlugin;
}

export interface PluginOptions {
Expand Down
13 changes: 5 additions & 8 deletions src/plugins/CalendarLabel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,17 @@ export default class CalendarLabel implements IPlugin {
computedOptions: ComputedOptions;

constructor(calendar: CalHeatmap) {
const {
radius, width, height, gutter,
} =
calendar.options.options.subDomain;
const subDomain = calendar?.options?.options?.subDomain;

this.calendar = calendar;
this.root = null;
this.shown = false;
this.options = defaultOptions;
this.computedOptions = {
radius,
width,
height,
gutter,
radius: subDomain?.radius,
width: subDomain?.width,
height: subDomain?.height,
gutter: subDomain?.gutter,
textAlign: 'start',
};
}
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/PluginManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ function createPlugin(
}

function extractPluginName(
pluginClass: IPluginContructor,
PluginClass: IPluginContructor,
options?: PluginOptions,
): string {
return `${pluginClass.name}${options?.key || ''}`;
return `${new PluginClass().name}${options?.key || ''}`;
}

export default class PluginManager {
Expand Down

0 comments on commit 87cd250

Please sign in to comment.