Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
trungleduc committed Nov 2, 2023
1 parent 0685df0 commit 4d7d072
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 8 deletions.
10 changes: 5 additions & 5 deletions src/editor/gridstack/layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,16 +144,16 @@ export class GridStackLayout extends Layout {
this._prepareGrid();
}

/**
/**
* Create an iterator over the widgets in the layout.
*
* @returns A new iterator over the widgets in the layout.
*/
*[Symbol.iterator](): IterableIterator<Widget> {
for (const item of this._gridItems) {
yield item;
}
*[Symbol.iterator](): IterableIterator<Widget> {
for (const item of this._gridItems) {
yield item;
}
}

/**
* Remove a widget from the layout.
Expand Down
26 changes: 23 additions & 3 deletions src/editor/gridstack/widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class GridStackWidget extends Widget {
this.addClass('grid-editor');
this._model = model;

this.layout = new GridStackLayout(this._model.info);
this._gridlayout = new GridStackLayout(this._model.info);
this.layout.gridItemChanged.connect(this._onGridItemChange, this);

this._model.ready.connect(() => {
Expand All @@ -62,6 +62,27 @@ export class GridStackWidget extends Widget {
});
}

get layout(): GridStackLayout {
return this._gridlayout;
}

set layout(value: GridStackLayout) {
if (this._gridlayout === value) {
return;
}
if (this.testFlag(Widget.Flag.DisallowLayout)) {
throw new Error('Cannot set widget layout.');
}
if (this._gridlayout) {
throw new Error('Cannot change widget layout.');
}
if (value!.parent) {

Check warning on line 79 in src/editor/gridstack/widget.ts

View workflow job for this annotation

GitHub Actions / build

Forbidden non-null assertion
throw new Error('Cannot change layout parent.');
}
this._gridlayout = value;
value!.parent = this;

Check warning on line 83 in src/editor/gridstack/widget.ts

View workflow job for this annotation

GitHub Actions / build

Forbidden non-null assertion
}

/**
* Update the layout to reclaim any empty space
*/
Expand Down Expand Up @@ -733,8 +754,7 @@ export class GridStackWidget extends Widget {
}
}

//@ts-ignore
layout: GridStackLayout;
private _gridlayout: GridStackLayout;

private _model: GridStackModel;
private _shadowWidget: GridItemHTMLElement | null = null;
Expand Down

0 comments on commit 4d7d072

Please sign in to comment.