Açıklama Yok

MediaMsg.js 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. "use strict";
  2. var __extends = (this && this.__extends) || (function () {
  3. var extendStatics = function (d, b) {
  4. extendStatics = Object.setPrototypeOf ||
  5. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  6. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  7. return extendStatics(d, b);
  8. };
  9. return function (d, b) {
  10. extendStatics(d, b);
  11. function __() { this.constructor = d; }
  12. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  13. };
  14. })();
  15. var __assign = (this && this.__assign) || function () {
  16. __assign = Object.assign || function(t) {
  17. for (var s, i = 1, n = arguments.length; i < n; i++) {
  18. s = arguments[i];
  19. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
  20. t[p] = s[p];
  21. }
  22. return t;
  23. };
  24. return __assign.apply(this, arguments);
  25. };
  26. Object.defineProperty(exports, "__esModule", { value: true });
  27. var MsgBase_1 = require("./MsgBase");
  28. var MediaMsg = (function (_super) {
  29. __extends(MediaMsg, _super);
  30. function MediaMsg() {
  31. var _this = _super !== null && _super.apply(this, arguments) || this;
  32. _this.type = 'media';
  33. return _this;
  34. }
  35. MediaMsg.createMsg = function (baseMsg) {
  36. var msg = new MediaMsg();
  37. Object.assign(msg, baseMsg);
  38. return msg;
  39. };
  40. MediaMsg.createFromClipboard = function (baseMsg, clipboardData) {
  41. if (clipboardData && clipboardData.types) {
  42. if (clipboardData.items.length > 0) {
  43. var blob = clipboardData.items[0].getAsFile();
  44. var url = window.URL.createObjectURL(blob);
  45. return MediaMsg.createMsg(__assign({}, baseMsg, { file: {
  46. data: blob,
  47. url: url
  48. } }));
  49. }
  50. }
  51. return null;
  52. };
  53. return MediaMsg;
  54. }(MsgBase_1.MsgBase));
  55. exports.MediaMsg = MediaMsg;