Skip to content

Commit c2847f3

Browse files
committed
fix old dragdrop p-* events to lm-*
1 parent 29f5921 commit c2847f3

File tree

2 files changed

+26
-23
lines changed

2 files changed

+26
-23
lines changed

coderibbon-theia/src/browser/cr-patch.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
BoxSizer,
1616
} from "@lumino/widgets";
1717
import {
18-
Drag, IDragEvent
18+
Drag,
1919
} from '@lumino/dragdrop';
2020
import {
2121
MimeData

coderibbon-theia/src/browser/cr-ribbon.ts

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,10 @@ export class CodeRibbonTheiaRibbonPanel extends BoxPanel implements EventListene
170170
* A message handler invoked on a `'before-attach'` message.
171171
*/
172172
protected onBeforeAttach(msg: Message): void {
173-
this.node.addEventListener('p-dragenter', this);
174-
this.node.addEventListener('p-dragleave', this);
175-
this.node.addEventListener('p-dragover', this);
176-
this.node.addEventListener('p-drop', this);
173+
this.node.addEventListener('lm-dragenter', this);
174+
this.node.addEventListener('lm-dragleave', this);
175+
this.node.addEventListener('lm-dragover', this);
176+
this.node.addEventListener('lm-drop', this);
177177
this.node.addEventListener('mousedown', this);
178178

179179
crdebug("Ribbon onBeforeAttach will run autoAdjustRibbonTailLength");
@@ -183,34 +183,34 @@ export class CodeRibbonTheiaRibbonPanel extends BoxPanel implements EventListene
183183
* A message handler invoked on an `'after-detach'` message.
184184
*/
185185
protected onAfterDetach(msg: Message): void {
186-
this.node.removeEventListener('p-dragenter', this);
187-
this.node.removeEventListener('p-dragleave', this);
188-
this.node.removeEventListener('p-dragover', this);
189-
this.node.removeEventListener('p-drop', this);
186+
this.node.removeEventListener('lm-dragenter', this);
187+
this.node.removeEventListener('lm-dragleave', this);
188+
this.node.removeEventListener('lm-dragover', this);
189+
this.node.removeEventListener('lm-drop', this);
190190
this.node.removeEventListener('mousedown', this);
191191
this._releaseMouse();
192192
}
193193

194194
/**
195-
* handling DOM & phosphor events
195+
* handling DOM & phosphor(lumino) events
196196
* @param event DOM event
197197
*
198-
* the p-* are the ones used to move patches around, they are from
199-
* phosphorjs and have the different type and more data
198+
* the lm-* are the ones used to move patches around, they are from
199+
* phosphorjs(now lumino) and have the different type and more data
200200
*/
201201
handleEvent(event: Event): void {
202202
// crdebug("patch handlin event:", event);
203203
switch (event.type) {
204-
case 'p-dragenter':
204+
case 'lm-dragenter':
205205
this._evtDragEnter(event as IDragEvent);
206206
break;
207-
case 'p-dragleave':
207+
case 'lm-dragleave':
208208
this._evtDragLeave(event as IDragEvent);
209209
break;
210-
case 'p-dragover':
210+
case 'lm-dragover':
211211
this._evtDragOver(event as IDragEvent);
212212
break;
213-
case 'p-drop':
213+
case 'lm-drop':
214214
this._evtDrop(event as IDragEvent);
215215
break;
216216
case 'dragenter':
@@ -231,6 +231,9 @@ export class CodeRibbonTheiaRibbonPanel extends BoxPanel implements EventListene
231231
// If the factory mime type is present, mark the event as
232232
// handled in order to get the rest of the drag events.
233233
if (event.mimeData.hasData('application/vnd.phosphor.widget-factory')) {
234+
console.error("CR: received a phosphor (NOT lumino) factory in event data!", event);
235+
}
236+
if (event.mimeData.hasData('application/vnd.lumino.widget-factory')) {
234237
event.preventDefault();
235238
event.stopPropagation();
236239
}
@@ -242,8 +245,8 @@ export class CodeRibbonTheiaRibbonPanel extends BoxPanel implements EventListene
242245
event.stopPropagation();
243246

244247
// The new target might be a descendant, so we might still handle the drop.
245-
// Hide asynchronously so that if a p-dragover event bubbles up to us, the
246-
// hide is cancelled by the p-dragover handler's show overlay logic.
248+
// Hide asynchronously so that if a lm-dragover event bubbles up to us, the
249+
// hide is cancelled by the lm-dragover handler's show overlay logic.
247250
this.overlay.hide(1);
248251
}
249252

@@ -292,7 +295,7 @@ export class CodeRibbonTheiaRibbonPanel extends BoxPanel implements EventListene
292295

293296
// Bail if the factory mime type has invalid data.
294297
let mimeData = event.mimeData;
295-
let factory = mimeData.getData('application/vnd.phosphor.widget-factory');
298+
let factory = mimeData.getData('application/vnd.lumino.widget-factory');
296299
if (typeof factory !== 'function') {
297300
event.dropAction = 'none';
298301
return;
@@ -452,7 +455,7 @@ export class CodeRibbonTheiaRibbonPanel extends BoxPanel implements EventListene
452455
// Setup the mime data for the drag operation.
453456
let mimeData = new MimeData();
454457
let factory = () => title.owner;
455-
mimeData.setData('application/vnd.phosphor.widget-factory', factory);
458+
mimeData.setData('application/vnd.lumino.widget-factory', factory);
456459

457460
// Create the drag image for the drag operation.
458461
let dragImage = tab.cloneNode(true) as HTMLElement;
@@ -470,7 +473,7 @@ export class CodeRibbonTheiaRibbonPanel extends BoxPanel implements EventListene
470473
// Create the cleanup callback.
471474
let cleanup = (() => {
472475
this._drag = null;
473-
tab.classList.remove('p-mod-hidden');
476+
tab.classList.remove('lm-mod-hidden');
474477
});
475478

476479
// Start the drag operation and cleanup when done.
@@ -1008,7 +1011,7 @@ export class CodeRibbonTheiaRibbonPanel extends BoxPanel implements EventListene
10081011
return this.tracker.currentWidget;
10091012
}
10101013

1011-
// NOTE === phosphor DockPanel API compatility section === NOTE //
1014+
// NOTE === phosphor(now lumino) DockPanel API compatility section === NOTE //
10121015
// we might want to split this into a `ImprovedBoxPanel` class instead?
10131016
// this section is because phosphor's BoxPanel has only a tiny fraction of the
10141017
// features that DockPanel has, and they're expected by Theia
@@ -1139,7 +1142,7 @@ export class CodeRibbonTheiaRibbonPanel extends BoxPanel implements EventListene
11391142
return this._layoutModified;
11401143
}
11411144

1142-
// overriding BoxPanel's p-BoxPanel-child
1145+
// overriding BoxPanel's lm-BoxPanel-child
11431146
override onChildAdded(msg: Widget.ChildMessage) {
11441147
msg.child.addClass("cr-RibbonPanel-child");
11451148

0 commit comments

Comments
 (0)