Skip to content

Commit

Permalink
Fix(Regions): setOptions type (#3972)
Browse files Browse the repository at this point in the history
  • Loading branch information
katspaugh authored Dec 25, 2024
1 parent 7008eb3 commit 404f7ea
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/plugins/regions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,11 @@ class SingleRegion extends EventEmitter<RegionEvents> implements Region {
}

/** Update the region's options */
public setOptions(options: Omit<RegionParams, 'minLength' | 'maxLength'>) {
public setOptions(
options: Partial<
Pick<RegionParams, 'color' | 'start' | 'end' | 'drag' | 'content' | 'id' | 'resize' | 'resizeStart' | 'resizeEnd'>
>,
) {
if (options.color) {
this.color = options.color
this.element.style.backgroundColor = this.color
Expand Down Expand Up @@ -607,10 +611,7 @@ class RegionsPlugin extends BasePlugin<RegionsPluginEvents, RegionsPluginOptions

this.subscriptions.push(...regionSubscriptions)

// A small timeout to allow internal events to be emitted first
setTimeout(() => {
this.emit('region-created', region)
}, 0)
this.emit('region-created', region)
}

/** Create a region with given parameters */
Expand Down

0 comments on commit 404f7ea

Please sign in to comment.