@@ -26,20 +26,37 @@ import { Signal, ISignal } from '@lumino/signaling';
2626import { DashboardIcons } from './icons' ;
2727
2828import { Widgetstore , WidgetPosition } from './widgetstore' ;
29- import { DashboardLayout } from './custom_layout' ;
3029
31- // HTML element classes
30+ import { DashboardLayout } from './layout' ;
3231
32+ /**
33+ * The class name added to dashboard outputs
34+ */
3335const DASHBOARD_WIDGET_CLASS = 'pr-DashboardWidget' ;
3436
37+ /**
38+ * The class name for the widget drag mime.
39+ */
3540const DASHBOARD_WIDGET_MIME = 'pr-DashboardWidgetMine' ;
3641
42+ /**
43+ * The class name added to the children of dashboard outputs.
44+ */
3745const DASHBOARD_WIDGET_CHILD_CLASS = 'pr-DashboardWidgetChild' ;
3846
47+ /**
48+ * The class name added to editable dashboard outputs.
49+ */
3950const EDITABLE_WIDGET_CLASS = 'pr-EditableWidget' ;
4051
52+ /**
53+ * The class name added to dashboard outputs being dragged.
54+ */
4155const IN_DRAG_CLASS = 'pr-InDrag' ;
4256
57+ /**
58+ * The class name added to markdown dashboard outputs.
59+ */
4360const MARKDOWN_OUTPUT_CLASS = 'pr-MarkdownOutput' ;
4461
4562/**
@@ -237,7 +254,7 @@ export class DashboardWidget extends Widget {
237254 }
238255
239256 /**
240- * Handle the `'dblclick'` event for the widget.
257+ * Handle the `'dblclick'` event for the widget. Currently a no-op.
241258 */
242259 private _evtDblClick ( event : MouseEvent ) : void {
243260 // Do nothing if it's not a left mouse press.
@@ -301,7 +318,7 @@ export class DashboardWidget extends Widget {
301318 }
302319
303320 /**
304- * Handle `mousemove` event of widget
321+ * Handle `mousemove` events for the widget.
305322 */
306323 private _evtMouseMove ( event : MouseEvent ) : void {
307324 switch ( this . _mouseMode ) {
@@ -316,6 +333,9 @@ export class DashboardWidget extends Widget {
316333 }
317334 }
318335
336+ /**
337+ * Handle `mousemove` events when the widget mouseMode is `drag`.
338+ */
319339 private _dragMouseMove ( event : MouseEvent ) : void {
320340 const data = this . _clickData ;
321341 const { clientX, clientY } = event ;
@@ -328,6 +348,9 @@ export class DashboardWidget extends Widget {
328348 }
329349 }
330350
351+ /**
352+ * Handle `mousemove` events when the widget mouseMode is `resize`.
353+ */
331354 private _resizeMouseMove ( event : MouseEvent ) : void {
332355 const { pressX, pressY, pressWidth, pressHeight } = this . _clickData ;
333356
@@ -358,6 +381,12 @@ export class DashboardWidget extends Widget {
358381 this . node . style . height = `${ element . clientHeight + 2 } px` ;
359382 }
360383
384+ /**
385+ * Determines whether the widget contains the point (left, top).
386+ *
387+ * ### Notes
388+ * Both `left` and `top` are relative to the dashboard.
389+ */
361390 containsPoint ( left : number , top : number ) : boolean {
362391 const pos = {
363392 left,
@@ -369,6 +398,13 @@ export class DashboardWidget extends Widget {
369398 return overlap . type !== 'none' ;
370399 }
371400
401+ /**
402+ * Determines whether the widget overlaps an area.
403+ *
404+ * @param _pos - the position and size of the test area.
405+ *
406+ * @returns - an object containing the type of overlap and this widget.
407+ */
372408 overlaps ( _pos : Widgetstore . WidgetPosition ) : DashboardWidget . Overlap {
373409 const { left, top, width, height } = _pos ;
374410 const pos = this . pos ;
@@ -430,6 +466,9 @@ export class DashboardWidget extends Widget {
430466 } ) ;
431467 }
432468
469+ /**
470+ * Handle `mouseUp` events for the widget.
471+ */
433472 private _evtMouseUp ( event : MouseEvent ) : void {
434473 event . stopPropagation ( ) ;
435474 event . preventDefault ( ) ;
@@ -449,6 +488,10 @@ export class DashboardWidget extends Widget {
449488
450489 /**
451490 * The widget's position on its dashboard.
491+ *
492+ * ### Notes
493+ * When setting the widget pos, fields that you don't want to modify
494+ * can be set as `undefined`.
452495 */
453496 get pos ( ) : WidgetPosition {
454497 return {
@@ -565,13 +608,19 @@ export class DashboardWidget extends Widget {
565608 return this . _ready ;
566609 }
567610
611+ /**
612+ * Whether the widget can be moved during a resize.
613+ */
568614 get locked ( ) : boolean {
569615 return this . _locked ;
570616 }
571617 set locked ( newState : boolean ) {
572618 this . _locked = newState ;
573619 }
574620
621+ /**
622+ * The content of the widget.
623+ */
575624 get content ( ) : Widget {
576625 return this . _content ;
577626 }
@@ -641,17 +690,29 @@ export namespace DashboardWidget {
641690 fit ?: boolean ;
642691 }
643692
693+ /**
694+ * A type for desccribing the direction of an overlap.
695+ */
644696 export type Direction = 'left' | 'right' | 'up' | 'down' | 'none' ;
645697
698+ /**
699+ * A type for describing an overlap between two widgets.
700+ */
646701 export type Overlap = {
647702 widget : DashboardWidget ;
648703 type : Direction ;
649704 } ;
650705
706+ /**
707+ * Create a unique widget id.
708+ */
651709 export function createDashboardWidgetId ( ) : string {
652710 return `DashboardWidget-${ UUID . uuid4 ( ) } ` ;
653711 }
654712
713+ /**
714+ * Create a resizer element for a dashboard widget.
715+ */
655716 export function createResizer ( ) : HTMLElement {
656717 const resizer = document . createElement ( 'div' ) ;
657718 resizer . classList . add ( 'pr-Resizer' ) ;
@@ -665,6 +726,18 @@ export namespace DashboardWidget {
665726 return resizer ;
666727 }
667728
729+ /**
730+ * Create a dashboard widget based on a WidgetInfo object.
731+ *
732+ * @param options - the options used to create the widget.
733+ *
734+ * @param notebookTracker - a notebook tracker used to locate a
735+ * notebook/cell for the widget given a notebook/cell id.
736+ *
737+ * @param fit - whether to fit the new widget to its content.
738+ *
739+ * @returns - a new dashboard widget.
740+ */
668741 export function createWidget (
669742 options : Widgetstore . WidgetInfo ,
670743 notebookTracker : INotebookTracker ,
@@ -701,6 +774,10 @@ export namespace DashboardWidget {
701774 return widget ;
702775 }
703776
777+ /**
778+ * A type to describe the different kinds of mouseMoves that can occur
779+ * on a widget.
780+ */
704781 export type MouseMode = 'drag' | 'resize' | 'none' ;
705782
706783 /**
@@ -740,8 +817,11 @@ namespace Private {
740817 * mouse is moved beyond a certain distance (DRAG_THRESHOLD).
741818 *
742819 * @param prevX - X Coordinate of the mouse pointer during the mousedown event
820+ *
743821 * @param prevY - Y Coordinate of the mouse pointer during the mousedown event
822+ *
744823 * @param nextX - Current X Coordinate of the mouse pointer
824+ *
745825 * @param nextY - Current Y Coordinate of the mouse pointer
746826 */
747827 export function shouldStartDrag (
0 commit comments