Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 31 additions & 3 deletions src/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,18 @@ export default class TableBlock {
return this.container;
}

/**
* Hook called after the block is fully rendered and mounted
* Set this.block.stretched here as block is not initialized in render().
*
* @returns {void}
*/
rendered() {
if (this.block) {
this.block.stretched = !!this.data.stretched;
}
}

/**
* Returns plugin settings
*
Expand All @@ -119,7 +131,7 @@ export default class TableBlock {
toggle: true,
onActivate: () => {
this.data.withHeadings = true;
this.table.setHeadingsSetting(this.data.withHeadings);
this._updateTunes();
}
}, {
label: this.api.i18n.t('Without headings'),
Expand All @@ -129,7 +141,7 @@ export default class TableBlock {
toggle: true,
onActivate: () => {
this.data.withHeadings = false;
this.table.setHeadingsSetting(this.data.withHeadings);
this._updateTunes();
}
}, {
label: this.data.stretched ? this.api.i18n.t('Collapse') : this.api.i18n.t('Stretch'),
Expand All @@ -138,11 +150,26 @@ export default class TableBlock {
toggle: true,
onActivate: () => {
this.data.stretched = !this.data.stretched;
this.block.stretched = this.data.stretched;
this._updateTunes();
}
}
];
}

/**
* Handle updating UI for tunes
*
* @returns {void}
*/
_updateTunes() {
this.table.setHeadingsSetting(this.data.withHeadings);

if (this.block) {
this.block.stretched = !!this.data.stretched;
this.block.dispatchChange();
}
}

/**
* Extract table data from the view
*
Expand Down Expand Up @@ -222,6 +249,7 @@ export default class TableBlock {
/** Update Tool's data */
this.data = {
withHeadings: firstRowHeading !== null,
stretched: false,
content
};
Comment thread
neSpecc marked this conversation as resolved.

Expand Down