Skip to content

Commit 431b8bc

Browse files
committed
add toolbarVisible setting for the viewer
1 parent b95d963 commit 431b8bc

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

src/DiagramViewer.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,23 @@ export class DiagramViewer extends HTMLElement {
223223
*/
224224
public readonly settings: DiagramSettings = new DiagramSettings();
225225

226+
private _toolbarVisible = true;
227+
/**
228+
* Returns whether toolbar is visible (enabled)
229+
*/
230+
public get toolbarVisible() {
231+
return this._toolbarVisible;
232+
}
233+
/**
234+
* Sets whether toolbar is visible (enabled)
235+
*/
236+
public set toolbarVisible(value) {
237+
this._toolbarVisible = value;
238+
if (this._toolbarContainer !== undefined) {
239+
this._toolbarContainer.style.display = value ? '' : 'none';
240+
}
241+
}
242+
226243
/**
227244
* Creates a new instance of the Diagram Viewer.
228245
*/
@@ -364,7 +381,10 @@ export class DiagramViewer extends HTMLElement {
364381

365382
panel.appendToolbar(toolbar);
366383

367-
this._toolbarContainer?.appendChild(panel);
384+
if (this._toolbarContainer !== undefined) {
385+
this._toolbarContainer.style.display = this.toolbarVisible ? '' : 'none';
386+
this._toolbarContainer.appendChild(panel);
387+
}
368388
}
369389

370390
private toolbarButtonClicked(ev: CustomEvent<ButtonEventData>) {

test/manual/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,8 @@ export class Experiments {
241241
// this.viewer.stencilSet = networkStencilSet;
242242
// this.viewer.stencilSet = mindMapStencilSet;
243243

244+
this.viewer.toolbarVisible = false;
245+
244246
const manualState: DiagramState = {
245247
stencils: [
246248
<TextStencilState>{

0 commit comments

Comments
 (0)