diff options
author | Fawn <fangrui_tong@brown.edu> | 2019-04-06 16:28:11 -0400 |
---|---|---|
committer | Fawn <fangrui_tong@brown.edu> | 2019-04-06 16:28:11 -0400 |
commit | 12ab72292f38cae162bbca970b52a7d0d19b002b (patch) | |
tree | 60454e929dc8656dea5195e3d8c74b5ee70ba2a2 /src/client/views/nodes/DocumentView.tsx | |
parent | 16e861bd4c16483783cdc0534af614625dd0f775 (diff) |
can toggle base layout
Diffstat (limited to 'src/client/views/nodes/DocumentView.tsx')
-rw-r--r-- | src/client/views/nodes/DocumentView.tsx | 41 |
1 files changed, 23 insertions, 18 deletions
diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx index e5c6859f8..2ede6d28e 100644 --- a/src/client/views/nodes/DocumentView.tsx +++ b/src/client/views/nodes/DocumentView.tsx @@ -95,7 +95,8 @@ export class DocumentView extends React.Component<DocumentViewProps> { private _downY: number = 0; private _reactionDisposer: Opt<IReactionDisposer>; private _templates: Set<Template> = new Set<Template>(); - private _basicLayout: string = this.props.Document.GetText(KeyStore.Layout, "<p>Error loading layout data</p>"); + private _useBase: boolean = true; + private _baseLayout: string = this.props.Document.GetText(KeyStore.Layout, "<p>Error loading layout data</p>"); @computed get active(): boolean { return SelectionManager.IsSelected(this) || !this.props.ContainingCollectionView || this.props.ContainingCollectionView.active(); } @computed get topMost(): boolean { return !this.props.ContainingCollectionView || this.props.ContainingCollectionView.collectionViewType == CollectionViewType.Docking; } @computed get layout(): string { return this.props.Document.GetText(KeyStore.Layout, "<p>Error loading layout data</p>"); } @@ -275,30 +276,34 @@ export class DocumentView extends React.Component<DocumentViewProps> { } } - @action - addTemplate = (template: Template) => { - this._templates.add(template); - - // TODO: apply templates to original layout - this.props.Document.SetText(KeyStore.Layout, this._basicLayout); + updateLayout = (): void => { + let base = this._useBase ? this._baseLayout : "<div style='margin: auto; width: 100%; height: 100%; border: 1px solid black'></div>"; + // this.props.Document.SetText(KeyStore.Layout, base); this._templates.forEach(temp => { let text = temp.Layout; - let oldLayout = this.props.Document.GetText(KeyStore.Layout, ""); - let layout = text.replace("{layout}", oldLayout); - this.props.Document.SetText(KeyStore.Layout, layout); + base = text.replace("{layout}", base); + // let oldLayout = this.props.Document.GetText(KeyStore.Layout, ""); + // let layout = text.replace("{layout}", oldLayout); + // this.props.Document.SetText(KeyStore.Layout, layout); }); + this.props.Document.SetText(KeyStore.Layout, base); + } + + @action + toggleBase = (useBase: boolean) => { + this._useBase = useBase; + this.updateLayout(); + } + + @action + addTemplate = (template: Template) => { + this._templates.add(template); + this.updateLayout(); } @action removeTemplate = (template: Template) => { this._templates.delete(template); - - this.props.Document.SetText(KeyStore.Layout, this._basicLayout); - this._templates.forEach(temp => { - let text = temp.Layout; - let oldLayout = this.props.Document.GetText(KeyStore.Layout, ""); - let layout = text.replace("{layout}", oldLayout); - this.props.Document.SetText(KeyStore.Layout, layout); - }); + this.updateLayout(); } @action |