hxgqh This code snippet DO NOT support multiple documents. If two panel added, sketch will crash.
websiddu What craft use is: https://github.com/sbooth/SFBPopovers. You can bring this framework to your plugin.
At ContentSync (https://www.contentsync.io) we have used a combination of listening to the OpenDocument notification and appending a view into the SplitView of Sketch. By handling the way we insert the view properly we get our plugin to work well with Craft and others.