diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/client/views/collections/CollectionDockingView.tsx | 79 | ||||
-rw-r--r-- | src/client/views/nodes/DocumentView.tsx | 2 |
2 files changed, 80 insertions, 1 deletions
diff --git a/src/client/views/collections/CollectionDockingView.tsx b/src/client/views/collections/CollectionDockingView.tsx index 022eccc13..9fa6edf8a 100644 --- a/src/client/views/collections/CollectionDockingView.tsx +++ b/src/client/views/collections/CollectionDockingView.tsx @@ -174,7 +174,7 @@ export class CollectionDockingView extends React.Component<SubCollectionViewProp } // - // Creates a vertical split on the right side of the docking view, and then adds the Document to that split + // Creates a vertical split on the right side of the docking view, and then adds the Document to the right of that split // @undoBatch @action @@ -207,6 +207,77 @@ export class CollectionDockingView extends React.Component<SubCollectionViewProp instance.layoutChanged(); return true; } + + // + // Creates a horizontal split on the docking view, and then adds the Document to the top of that split + // + @undoBatch + @action + public static AddTopSplit(document: Doc, dataDoc: Doc | undefined, libraryPath?: Doc[]) { + if (!CollectionDockingView.Instance) return false; + const instance = CollectionDockingView.Instance; + const newItemStackConfig = { + type: 'stack', + content: [CollectionDockingView.makeDocumentConfig(document, dataDoc, undefined, libraryPath)] + }; + + const newContentItem = instance._goldenLayout.root.layoutManager.createContentItem(newItemStackConfig, instance._goldenLayout); + + if (instance._goldenLayout.root.contentItems.length === 0) { + instance._goldenLayout.root.addChild(newContentItem, 0); + } else if (instance._goldenLayout.root.contentItems[0].isColumn) { + instance._goldenLayout.root.contentItems[0].addChild(newContentItem, 0); + } else { + const hlayout = instance._goldenLayout.root.contentItems[0]; + const newColumn = hlayout.layoutManager.createContentItem({ type: "column" }, instance._goldenLayout); + hlayout.parent.replaceChild(hlayout, newColumn); + + newColumn.addChild(newContentItem, 0, true); + newColumn.addChild(hlayout, undefined, true); + + hlayout.config.height = 50; + newContentItem.config.height = 50; + } + newContentItem.callDownwards('_$init'); + instance.layoutChanged(); + return true; + } + + // + // Creates a horizontal split on the docking view, and then adds the Document to the bottom of that split + // + @undoBatch + @action + public static AddBottomSplit(document: Doc, dataDoc: Doc | undefined, libraryPath?: Doc[]) { + if (!CollectionDockingView.Instance) return false; + const instance = CollectionDockingView.Instance; + const newItemStackConfig = { + type: 'stack', + content: [CollectionDockingView.makeDocumentConfig(document, dataDoc, undefined, libraryPath)] + }; + + const newContentItem = instance._goldenLayout.root.layoutManager.createContentItem(newItemStackConfig, instance._goldenLayout); + + if (instance._goldenLayout.root.contentItems.length === 0) { + instance._goldenLayout.root.addChild(newContentItem); + } else if (instance._goldenLayout.root.contentItems[0].isColumn) { + instance._goldenLayout.root.contentItems[0].addChild(newContentItem); + } else { + const hlayout = instance._goldenLayout.root.contentItems[0]; + const newColumn = hlayout.layoutManager.createContentItem({ type: "column" }, instance._goldenLayout); + hlayout.parent.replaceChild(hlayout, newColumn); + + newColumn.addChild(newContentItem, undefined, true); + newColumn.addChild(hlayout, 0, true); + + hlayout.config.height = 50; + newContentItem.config.height = 50; + } + newContentItem.callDownwards('_$init'); + instance.layoutChanged(); + return true; + } + // // Creates a vertical split on the right side of the docking view, and then adds the Document to that split // @@ -703,6 +774,10 @@ export class DockedFrameRenderer extends React.Component<DockedFrameProps> { return MainView.Instance.openWorkspace(doc); } else if (location === "onRight") { return CollectionDockingView.AddRightSplit(doc, dataDoc, libraryPath); + } else if (location === "onTop") { + return CollectionDockingView.AddTopSplit(doc, dataDoc, libraryPath); + } else if (location === "onBottom") { + return CollectionDockingView.AddBottomSplit(doc, dataDoc, libraryPath); } else if (location === "close") { return CollectionDockingView.CloseRightSplit(doc); } else { @@ -754,3 +829,5 @@ export class DockedFrameRenderer extends React.Component<DockedFrameProps> { } Scripting.addGlobal(function openOnRight(doc: any) { CollectionDockingView.AddRightSplit(doc, undefined); }); Scripting.addGlobal(function useRightSplit(doc: any) { CollectionDockingView.UseRightSplit(doc, undefined); }); +Scripting.addGlobal(function openOnTop(doc: any) { CollectionDockingView.AddTopSplit(doc, undefined); }); // TEMPORARY didnt really know what this did but it seems important so +Scripting.addGlobal(function openOnBottom(doc: any) { CollectionDockingView.AddBottomSplit(doc, undefined); }); // TEMPORARY didnt really know what this did but it seems important so diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx index dabe5a7aa..845a2d3ab 100644 --- a/src/client/views/nodes/DocumentView.tsx +++ b/src/client/views/nodes/DocumentView.tsx @@ -601,6 +601,8 @@ export class DocumentView extends DocComponent<DocumentViewProps, Document>(Docu subitems.push({ description: "Open Full Screen", event: () => CollectionDockingView.Instance && CollectionDockingView.Instance.OpenFullScreen(this, this.props.LibraryPath), icon: "desktop" }); subitems.push({ description: "Open Tab ", event: () => this.props.addDocTab(this.props.Document, this.props.DataDoc, "inTab", this.props.LibraryPath), icon: "folder" }); subitems.push({ description: "Open Right ", event: () => this.props.addDocTab(this.props.Document, this.props.DataDoc, "onRight", this.props.LibraryPath), icon: "caret-square-right" }); + subitems.push({ description: "Open Top ", event: () => this.props.addDocTab(this.props.Document, this.props.DataDoc, "onTop", this.props.LibraryPath), icon: "caret-square-right" }); // TEMPORARY for gestures + subitems.push({ description: "Open Bottom ", event: () => this.props.addDocTab(this.props.Document, this.props.DataDoc, "onBottom", this.props.LibraryPath), icon: "caret-square-right" }); // TEMPORARY for gestures subitems.push({ description: "Open Alias Tab ", event: () => this.props.addDocTab(Doc.MakeAlias(this.props.Document), this.props.DataDoc, "inTab"), icon: "folder" }); subitems.push({ description: "Open Alias Right", event: () => this.props.addDocTab(Doc.MakeAlias(this.props.Document), this.props.DataDoc, "onRight"), icon: "caret-square-right" }); subitems.push({ description: "Open Fields ", event: () => this.props.addDocTab(Docs.Create.KVPDocument(this.props.Document, { width: 300, height: 300 }), undefined, "onRight"), icon: "layer-group" }); |