Giter VIP home page Giter VIP logo

dock-spawn-ts's Introduction

dock-spawn-ts

A TypeScript Version of dock-spawn (see https://github.com/coderespawn/dock-spawn)

Homepage at https://node-projects.github.io/dock-spawn-ts/

NPM version Downloads

info

Dock Spawn TS is a Typescript Docking Framework to create a Visual Studio like IDE in HTML

Logo

es5 version

There is an ES5 Version in the lib/es5 directory Usage Example is in page/demo/demo_simple_es5.html

differences to original dockspawn

  • typescript
  • bugfixes / preformance optimations
  • save/restore fixed and saveing/restoring of dialogs
  • touch support (works on ipad/iphone and android devices)
  • performance fixes (unnessecary removeing and adding to dom reduced, not needed elements are hidden, not removed from dom)
  • multiple dockspawn's in one page
  • removed font-awesome dependency
  • settings (dockManger.config)
  • ContextMenu to close all docks (Document Docks only)
  • wip webcomponent support

testing

how to use:

   dockspawn div container needs position absolute or relative 

<div id="dock_div" style="height: calc(100% - 45px);">
    <div id="my_dock_manager" class="my-dock-manager" style="position: relative;"></div>
    <div id="solution_window" data-panel-caption="Solution Explorer" data-panel-icon="test.png" class="solution-window" hidden></div>
    <div id="properties_window" data-panel-caption="Properties" class="properties-window" hidden></div>
    <div id="state_window" data-panel-caption="state" class="state-window" hidden></div>
    <div id="editor1_window" data-panel-caption="Steering.h" class="editor1-window editor-host" hidden></div>
    <div id="editor2_window" data-panel-caption="Steering.cpp" class="editor2-window editor-host" hidden></div>
    <div id="infovis" data-panel-caption="Dock Tree Visualizer" class="editor2-window editor-host" hidden></div>
    <div id="output_window" data-panel-caption="Output" class="output-window editor-host" hidden></div>
    <div id="outline_window" data-panel-caption="Outline" class="outline-window" hidden></div>
    <div id="toolbox_window" data-panel-caption="Toolbox" class="toolbox-window" hidden></div>
</div>
    import { DockManager } from "../DockManager.js";
    import { PanelContainer } from "../PanelContainer.js";

    // Convert a div to a dock manager.  Panels can then be docked on to it
    let divDockManager = document.getElementById('dock_div');
    let dockManager = new DockManager(document.getElementById('my_dock_manager'));
    dockManager.initialize();

    // Let the dock manager element fill in the entire screen
    window.onresize = function () {
        dockManager.resize(
            window.innerWidth - (divDockManager.clientLeft + divDockManager.offsetLeft),
            window.innerHeight - (divDockManager.clientTop + divDockManager.offsetTop)
        );
    };
    window.onresize(null);

    // Convert existing elements on the page into "Panels". 
    // They can then be docked on to the dock manager 
    // Panels get a titlebar and a close button, and can also be 
    // converted to a floatingdialog box which can be dragged / resized 
    let solution = new PanelContainer(document.getElementById("#solution_window"), dockManager);
    let output = new PanelContainer(document.getElementById("#output_window"), dockManager);
    let properties = new PanelContainer(document.getElementById("#properties_window"), dockManager);
    let toolbox = new PanelContainer(document.getElementById("#toolbox_window"), dockManager);
    let outline = new PanelContainer(document.getElementById("#outline_window"), dockManager);
    let state = new PanelContainer(document.getElementById("#state_window"), dockManager);
    let editor1 = new PanelContainer(document.getElementById("#editor1_window"), dockManager);
    let editor2 = new PanelContainer(document.getElementById("#editor2_window"), dockManager);
    let infovis = new PanelContainer(document.getElementById("infovis"), dockManager);

    // Dock the panels on the dock manager
    let documentNode = dockManager.context.model.documentManagerNode;
    let solutionNode = dockManager.dockLeft(documentNode, solution, 0.20);
    let outlineNode = dockManager.dockFill(solutionNode, outline);
    let propertiesNode = dockManager.dockDown(outlineNode, properties, 0.6);
    let outputNode = dockManager.dockDown(documentNode, output, 0.4);
    let stateNode = dockManager.dockRight(outputNode, state, 0.40);
    let toolboxNode = dockManager.dockRight(documentNode, toolbox, 0.20);
    let editor1Node = dockManager.dockFill(documentNode, editor1);
    let editor2Node = dockManager.dockFill(documentNode, editor2);
    dockManager.floatDialog(infovis, 50, 50);

    // You could listen to callbacks of DockManager like this, there are more event's then close available see ILayoutEventListener
      dockManager.addLayoutListener({
         onClosePanel: (dockManager, panel) => {
            console.log('onClosePanel: ', dockManager, panel);
            localStorage.setItem(storeKey, dockManager.saveState());
        }
    });

other html docking frameworks in comparison

Url Licence Touch support Dialogs Keep Content in DOM Autocolapsing Panels Dialogs in new Browserwindows Dock Back from extra Browserwindow
dock-spawn-ts MIT Yes Yes Yes No Yes No
https://github.com/golden-layout/golden-layout MIT No No Yes
https://github.com/WebCabin/wcDocker MIT Yes Yes No
https://jspanel.de MIT Yes Yes No
http://www.htmldockfloat.com Commerical/free No Yes No
http://phosphorjs.github.io/ BSD 3 ? ? No
https://github.com/tupilabs/vue-lumino Apache2 ? No No
https://github.com/mathuo/dockview MIT ? No No

dock-spawn-ts's People

Contributors

7evenk avatar ampam avatar dependabot[bot] avatar jogibear9988 avatar jzeyer avatar kkranich97 avatar razenpok avatar ribbanya avatar sprotty avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dock-spawn-ts's Issues

Open own context menu for TabHandle

Hello,

Is there an easy way to override the default context menu of a TabHandle?

I create a new Panel like this:
let messageDetail = new PanelContainer(document.getElementById("testComponent"), this.dockManager, PanelType.panel);
And override the contextmenu:
messageDetail.elementTitle.addEventListener('contextmenu', this.oncontextMenuClicked.bind(messageDetail.containerElement));
This works fine.

But as soon as I dock the Panel to the "main" dock-node, i only have the TabHandles, where i could call my own context menu from.
It currently always shows the options "Close all documents" and "Close all documents but this".
Is it possible to override this contextmenu?

Regards.

async breaks ES5 compatibility

I am evaluating this lib for my project.
Thereby, I encountered an issue in the es5 minified version: regeneratorRuntime is not defined

Indeed, the file contains a reference to regeneratorRuntime.
From my findings, this is a compatibility layer for async/await introduced by babel (or webpack, not sure).

Luckily, there is only a single use of async in PanelContainer.ts, introduced by commit d74fe1a

After downgrading to 2.301, the issue is gone, because there is no use of async/await in this version.

Please verify whether async is required in this project. Maybe a callback or Promise would be an alternative?
If it is indeed required, please change the ES5 code generation to include all dependencies.

Closing tab with 3 or more tabs bug

Trying to close a panel with at least 3 tabs causes the panel to not actually be removed. This causes several odd issues such as the panel to be closed "x" button remaining in place, thus disallowing removal of other tabs. To recreate, open IDE demo and dock infovis dock tree visualizer into outline/solution explorer panel area. Then, press the close button on the now docked tree visualizer tab. This leads me to suspect the issue is in the else block of the DockLayoutEngine close function.

else {
    // the node to be removed has 2 or more other siblings. So it is safe to continue
    // using the parent composite container.
    parentNode.performLayout(false);
    if (activetabClosed) {
        let nextActiveSibling = parentNode.children[Math.max(0, siblingIndex - 1)];
        if (nextActiveSibling != null)
            parentNode.container.setActiveChild(nextActiveSibling.container);
    }
 }`

dynamic data-panel-caption

Hello,
I would like to know if and how can I set the "data-panel-caption" dynamically (=bound it to my model)
thanks
l.

Cannot re-open floating dialog

This may be a bug, I'm not too sure, but if you know of a way to work around it, please let me know.

I wanted to make a button that adds a panel back onto the screen after you close it. This seems to work fine if the panel is added to one of the docks (ex. docked on the left, right, etc). You can close it with the x button in the corner and reopen it by calling the same dockLeft, dockRight, etc command. I assume this is because when you close the node, it isn't actually destroying it?

Regardless, if you build a panel with floatDialog, close the panel, and then try to reopen it with the same floatDialog command, it just doesn't do anything. The element returns null, and a panel is not created.

Interestingly enough, if you dock the floating panel and then close it, you are able to reopen it with the same command. It does not work if you dock the panel, undock it, and then close it though.

Do you know of any work around for this?

It also might be because of how I'm checking to see if their panel already exists on the screen. Right now, it seems that when the panel has been closed, using getElementById on it returns null.
Here's my code for a basic add:

function toggleTools(){ console.log(document.getElementById("tools")); if(document.getElementById("tools") == null){ dockManager.floatDialog(tools, 50, 50); } }

Panels shrink or expand when another panel is docked

I've noticed this issue when I dock new panels onto the screen. Its something that occurs with existing panels as well though. When docking the panels, like, say, on the right, I'd expect all the panels to shrink in order to make space for the new panel. However, this doesn't really happen. Instead the panels act strange, and they might expand or shrink.

Take this example on the IDE demo
resizing_issue

Repeatedly putting this panel into the same place shrinks the panel itself.
Is there a way to set it as a steady number? Like make it always take up half the space?

Proposed new resize events for dialogs (floating windows)

It would be nice if we would have 3 new events for dialogs like:

onResizeStartDialog - when you engage in a resize operation (click down)
onResizeDialog - when you actually move the cursor
onResizeEndDialog - when you release the mouse and the final size is set up

Doing Tab splitting (vertical/horizontal)

Hi, we're using this with an Angular 9 project to create a genuine cloud based IDE...dock spawn was an awesome accelerator, thanks for this project! :)

But...I'm not sure how to properly do tab splitting, like if I have two tabs open...and I just want to drag one of them to be beside the other so I can view both at the same time, or one below the other, again to see both at the same time...it works...but the one I drag...is no longer tabbed. :(

Style gets messed up a bit and I can't close that one :( I guess what its implying is that when I drag a tab, I want it dock with another document manager now just the general top/down/left/right node.

How can I force the landing to become a tabbed window? I think I might be able to do it in initialization of the document window...but not sure, if you can give any pointers here it would be greatly appreciated. Being able to view tab content at the same time would be super valuable for us.

Exception when dragging a tab which was docked "fill"

When undocking/dragging a tab which was docked in "fill" mode exceptions are raised in DockManager::_requestTabReorder.
The call to methode _findNodeFromContainer return "null".
The error is reproducible in de IDE demo (see attached screen shots).

demo-gui
console_output

How to understand the different grid elements.

There seem to be at least two different kinds of grid elements. In the IDE demo, there is an area with some source code tabs, with the tabs at the top. There are also panels which have a persistent header at the top and tabs at the bottom. When one of those tabs is clicked the header title changes to reflect which was chosen. Also, in these (the inverted tabs with header), the close "X" is at the top right of the header, but applies to the currently active tab.

It would be great to have some documentation about the different kinds of panels and tabs, as well as how to integrate other features such as menus, etc.

demo_simple_es5.html does not work correctly

after loading the application, this demo does not work correctly:
http://127.0.0.1:8080/page/demo/demo_simple_es5.html

browser issues:
dock-spawn-ts.js:1 Uncaught ReferenceError: regeneratorRuntime is not defined
at dock-spawn-ts.js:1:20198
at dock-spawn-ts.js:1:21001
at dock-spawn-ts.js:1:21185
at dock-spawn-ts.js:1:101970
(anonymous) @ dock-spawn-ts.js:1
(anonymous) @ dock-spawn-ts.js:1
(anonymous) @ dock-spawn-ts.js:1
(anonymous) @ dock-spawn-ts.js:1
demo_simple_es5.html:26 Uncaught TypeError: Cannot read properties of undefined (reading 'DockManager')
at window.onload (demo_simple_es5.html:26:47)

Dock spawn closing panels

when we closed the dock spawn panels ,again I'm unable to open the panel. Can anyone tell me the solution

Reloading saved layout

How can I load the json that has been saved (-of my changed layout..) using this.dockManager.saveState()
Also I would like to load this.dockManager.resumeLayout(panel)
using the build in functions - how can I do that?
thanks and have a great day for now

Move groups of tabs together

It would be great to be able to move a group of tabs together, perhaps by dragging on the empty space to the right of the tabs (if there aren't too many). And/or, have a panel with a header bar that you put tabs into, and then drag that.

Sticky panel on drag

Let me start by saying that this is an amazing job.

I would like to propose an improvement, when you drag a panel some icons appear and if you drop on them then the panel dock into the layout.

Would it be possible to make the dock process sticky by showing a preview area where the panel is going to snap?

There are a lot of examples but I can think of a few:

Setting the active panel does not work

Setting the active panel via this.dockManager.activePanel = newActivePanel does not work. The GUI does not reflect the changes.
In the IDE demo lets say you want to set the "Outline" tab as the active tab and not "Solution Explorer" but you want the order of the tabs exactly as they are, how can this be achived? Setting this.dockManager.activePanel does not work.
active-tab-gui

Integration with Vue

Hi, I am trying to use the libraries with Vue project. I am a bit lost here. I have a vue project and I have added dock-spawn-ts libraries to it. Where should I write my integration code.

create a webcomponents version

Create a Version wich uses webcomponents, so it's easier to use.
May the user then can use it without writing a line of javascript.

How to capture the panel resize event of a docked element

How can I receive the events of a resize between two docked panels? I can't find anything about events in the docs, here or Stack Overflow. I tried registering events to the dock manager, to the panel, directly to the divs inside the panel, and nothing is triggering. Source code seems to send the events, but they don't reach the places I listen to.

I need this event, because once it is resized, I must refresh a Three.js instance inside one of them. It works fine when listening to resize events of the window, but I can't get events from panels.

Angular integration

Awesome lib, it perfeclty matches my task, but is there any way yo use it with angular?

tabListElement in TabHost.js file - always on top

if (this.tabStripDirection === TabHostDirection.TOP && this.tabStripDirection === TabHostDirection.BOTTOM) {
this.hostElement.appendChild(this.tabListElement);
this.hostElement.appendChild(this.separatorElement);
this.hostElement.appendChild(this.contentElement);
}
at TabHost.js
tried to define it like this - so the tabListElement will always be on the top (-and not the bottom)
with no luck...
how come?

Resize Cracking

Hi we're using dock spawn ts in an Angular 9 project, to make a genuine cloud based IDE...its working great, thanks! But, when we change the size of panes internally, like by closing a pane or dragging a pane slider...the overall "resize" isn't always called, and the layout "cracks", it leaves gaps and you can see the background behind the dock manager.

There is a simple work around...I just resize the browser itself, and that seems to always force a resize of all the panels as needed, and the gaps disappear. But...would be much better if there was a way to ensure the dock spawn panels always update resizing when the size of any internal pane changes. maybe I did something wrong in initialization, or didn't register all the needed resize callbacks or something?

If you can give some pointers on that or suggest things I can try, would be greatly appreciated. Thanks again for this project, its a great head start on the whole dockable windows thing.

More control over tab positioning / GUI element creation

Lets say you have a panel which is docked "bottom". Then you drag another panel on top of the first one and dock it "filled". Then the two visible tabs are at the bottom edge of the panels. It would be great if this can be customized (for example put the tabs on the top border). It would be great if there was an option that all tabs of "filled" panels are presented like the tabs of dockFill panels that are directly under the documentNode (editor1 and editor2 in the IDE demo).
If the tabs are on the top border the "header line" would be redundant and could be removed.

tab-location-gui

Escape button is closing focused pane

Hello,
While clicking on a pane\document in the dock manager and afterwards on the escape button the pane get closed
How can I prevent it?
thanks
l.

Resizing issue with the splitbar-horizontal

That are still resizing issues, which is also present in the older project. When 1st grabbing the bar to the right of the middle window (right of the Steering.cpp), the resizing glitches. It's possibly from a resizing calculation issue.
Capture

Restrict Panel Movement to Specific Boundaries

Is there a way to restrict panel movement to a set of defined boundaries?

Like for an example, lets say I have a box on the screen, with a panel inside of it. When I move the panel, I can move it around freely like normal, however, I will not be able to move it outside of the box. I would only be able to move it within the boundaries of the box.

save new dock manger layout

hello,
Is it possible to save the changed panes' positions ? If I want to have a mechanism that saves user's preferences for the layout...

tree data structure that represents the current state?

It would be really useful for frameworks like React/Vue/Svelte integrations if docks spawn would have an exposed tree data structure with what is currently in play.

Something like:

[
  // browser windows - For future detachable windows support
  {
    id: 'browser window 0',
    floatingWindows: [
      {
     id: 'flaoting window 0',
     width: 300,
     height:300,
     topPos: 50,
     widthPos: 50,
     .... and so on
     },
     {
      id: 'flaoting window 1',
      width: 300,
      height:300,
      topPos: 50,
      widthPos: 50,
      .... and so on
      }
    ]
     rootPanel: {
      id: 'docked panel 0',
      children: [
        {
          id: 'docked panel 1',
          width: 100,
          height:300,
          percentage: 33
          .... and so on
        },
        {
          id: 'docked panel 2',
          width: 200,
          height:300,
          percentage: 66
          .... and so on,
          children: [
            {
              id: 'docked panel 3',
              width: 100,
              height:300,
              percentage: 50
              .... and so on
            },
            {
              id: 'docked panel 4',
              width: 100,
              height:300,
              percentage: 50
              .... and so on
              },
          ]
          },
      ]
     }
    
  }
]

nodes' dock-spawn-ts issue

Hello, and thanks again for this amazing dock-spawn-ts' project!

I can't really point it out but every once in a while, I get this error message and I can't run my project - Can you tell me the reason for this? Or maybe you could suggest to me how to handle this? or what is missing...

image

Thank you,
l.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.