diff options
-rw-r--r-- | src/views/collections/CollectionDockingView.tsx | 41 | ||||
-rw-r--r-- | src/views/nodes/DocumentView.tsx | 5 |
2 files changed, 44 insertions, 2 deletions
diff --git a/src/views/collections/CollectionDockingView.tsx b/src/views/collections/CollectionDockingView.tsx index c5d4272bf..8c8238ee0 100644 --- a/src/views/collections/CollectionDockingView.tsx +++ b/src/views/collections/CollectionDockingView.tsx @@ -182,9 +182,48 @@ export class CollectionDockingView extends React.Component<CollectionViewProps> CollectionDockingView.myLayout._maximizedStack = null; } } + + // + // Creates a vertical split on the right side of the docking view, and then adds the Document to that split + // + public static AddRightSplit(document: Document) { + var newItemConfig = { + type: 'component', + componentName: 'documentViewComponent', + componentState: { doc: document } + } + let newItemStackConfig = { + type: 'stack', + content: [newItemConfig] + }; + var newContentItem = new CollectionDockingView.myLayout._typeToItem[newItemStackConfig.type](CollectionDockingView.myLayout, newItemStackConfig, parent); + + if (CollectionDockingView.myLayout.root.contentItems[0].isRow) { + var rowlayout = CollectionDockingView.myLayout.root.contentItems[0]; + var lastRowItem = rowlayout.contentItems[rowlayout.contentItems.length - 1]; + + lastRowItem.config["width"] *= 0.5; + newContentItem.config["width"] = lastRowItem.config["width"]; + rowlayout.addChild(newContentItem, rowlayout.contentItems.length, true); + rowlayout.callDownwards('setSize'); + } + else { + var collayout = CollectionDockingView.myLayout.root.contentItems[0]; + var newRow = collayout.layoutManager.createContentItem({ type: "row" }, CollectionDockingView.myLayout); + collayout.parent.replaceChild(collayout, newRow); + + newRow.addChild(newContentItem, undefined, true); + newRow.addChild(collayout, 0, true); + + collayout.config["width"] = 50; + newContentItem.config["width"] = 50; + collayout.parent.callDownwards('setSize'); + } + } goldenLayoutFactory() { CollectionDockingView.myLayout = this.modelForGoldenLayout; + var layout = CollectionDockingView.myLayout; CollectionDockingView.myLayout.on('tabCreated', function (tab: any) { if (CollectionDockingView._dragDiv) { CollectionDockingView._dragDiv.removeChild(CollectionDockingView._dragElement); @@ -196,9 +235,7 @@ export class CollectionDockingView extends React.Component<CollectionViewProps> tab.setTitle(tab.contentItem.config.componentState.doc.Title); tab.closeElement.off('click') //unbind the current click handler .click(function () { - //if (confirm('really close this?')) { tab.contentItem.remove(); - //} }); }); diff --git a/src/views/nodes/DocumentView.tsx b/src/views/nodes/DocumentView.tsx index ae5712182..e77d4a274 100644 --- a/src/views/nodes/DocumentView.tsx +++ b/src/views/nodes/DocumentView.tsx @@ -314,6 +314,10 @@ export class DocumentView extends React.Component<DocumentViewProps> { } } + openRight = (e: React.MouseEvent): void => { + CollectionDockingView.AddRightSplit(this.props.Document); + } + deleteClicked = (e: React.MouseEvent): void => { if (this.props.ContainingCollectionView instanceof CollectionFreeFormView) { this.props.ContainingCollectionView.removeDocument(this.props.Document) @@ -356,6 +360,7 @@ export class DocumentView extends React.Component<DocumentViewProps> { ContextMenu.Instance.clearItems(); ContextMenu.Instance.addItem({ description: "Full Screen", event: this.fullScreenClicked }) + ContextMenu.Instance.addItem({ description: "Open Right", event: this.openRight }) ContextMenu.Instance.addItem({ description: "Delete", event: this.deleteClicked }) ContextMenu.Instance.displayMenu(e.pageX - 15, e.pageY - 15) SelectionManager.SelectDoc(this, e.ctrlKey); |