Skip to content

Commit

Permalink
feat: add custom storage prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
iklimis authored and bampakoa committed Jan 13, 2022
1 parent 05a10aa commit e9318f3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions projects/ngx-grapesjs/src/lib/grapesjs.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ export interface Config {
parser: {
parserHtml: {}
};
storageManager: {
id: string
};
}

export interface CommandSender {
Expand Down
8 changes: 7 additions & 1 deletion projects/ngx-grapesjs/src/lib/ngx-grapesjs.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ export class NgxGrapesjsComponent implements OnInit {
this.config.components = content;
}
@Input() placeholders: Placeholder[] = [];
@Input()
set storagePrefix(prefix: string) {
this.config.storageManager.id = prefix;
}

private editor: GrapesJsEditor | undefined = undefined;
private config: Config = {
Expand All @@ -32,6 +36,9 @@ export class NgxGrapesjsComponent implements OnInit {
},
parser: {
parserHtml: {}
},
storageManager: {
id: 'gjs-'
}
};

Expand All @@ -40,7 +47,6 @@ export class NgxGrapesjsComponent implements OnInit {
ngOnInit(): void {
// setup the default parser. It can be overriden by providing a custom implementation of the NgxGrapesjsService
this.config.parser.parserHtml = this.ngxGrapesJsService?.parserHtml;

// initialize the editor
this.editor = grapesjs.init(this.config);

Expand Down

0 comments on commit e9318f3

Please sign in to comment.