dragDataHelper.js 593 B

1234567891011121314151617181920212223
  1. #ifdef 0
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  4. * You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #endif
  6. var gDragDataHelper = {
  7. get mimeType() {
  8. return "text/x-moz-url";
  9. },
  10. getLinkFromDragEvent: function(aEvent) {
  11. let dt = aEvent.dataTransfer;
  12. if (!dt || !dt.types.includes(this.mimeType)) {
  13. return null;
  14. }
  15. let data = dt.getData(this.mimeType) || "";
  16. let [url, title] = data.split(/[\r\n]+/);
  17. return {url: url, title: title};
  18. }
  19. };