@remirror/extension-image
Advanced tools
Comparing version 3.0.0-beta.2 to 3.0.0-beta.3
@@ -1,5 +0,17 @@ | ||
var _initClass, _ImageExtension, _dec, _dec2, _dec3, _initProto, _class; | ||
var _initClass, _ImageExtension, _dec, _dec2, _dec3, _initProto, _class, _applyDecs2, _applyDecs2$e, _applyDecs2$c; | ||
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } | ||
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } | ||
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } } | ||
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } | ||
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; } | ||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } | ||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } | ||
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } | ||
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } | ||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); } | ||
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } | ||
function createAddInitializerMethod(e, t) { return function (r) { assertNotFinished(t, "addInitializer"), assertCallable(r, "An initializer"), e.push(r); }; } | ||
function assertInstanceIfPrivate(e, t) { if (!e(t)) throw new TypeError("Attempted to access private element on non-instance"); } | ||
function memberDec(e, t, r, a, n, i, s, o, c, l, u) { var f; switch (i) { case 1: f = "accessor"; break; case 2: f = "method"; break; case 3: f = "getter"; break; case 4: f = "setter"; break; default: f = "field"; } var d, p, h = { kind: f, name: o ? "#" + r : r, static: s, private: o, metadata: u }, v = { v: !1 }; if (0 !== i && (h.addInitializer = createAddInitializerMethod(n, v)), o || 0 !== i && 2 !== i) { if (2 === i) d = function (e) { return assertInstanceIfPrivate(l, e), a.value; };else { var y = 0 === i || 1 === i; (y || 3 === i) && (d = o ? function (e) { return assertInstanceIfPrivate(l, e), a.get.call(e); } : function (e) { return a.get.call(e); }), (y || 4 === i) && (p = o ? function (e, t) { assertInstanceIfPrivate(l, e), a.set.call(e, t); } : function (e, t) { a.set.call(e, t); }); } } else d = function (e) { return e[r]; }, 0 === i && (p = function (e, t) { e[r] = t; }); var m = o ? l.bind() : function (e) { return r in e; }; h.access = d && p ? { get: d, set: p, has: m } : d ? { get: d, has: m } : { set: p, has: m }; try { return e.call(t, c, h); } finally { v.v = !0; } } | ||
function memberDec(e, t, r, a, n, i, s, o, c, l, u) { var f; switch (i) { case 1: f = "accessor"; break; case 2: f = "method"; break; case 3: f = "getter"; break; case 4: f = "setter"; break; default: f = "field"; } var d, p, h = { kind: f, name: o ? "#" + r : r, static: s, private: o, metadata: u }, v = { v: !1 }; if (0 !== i && (h.addInitializer = createAddInitializerMethod(n, v)), o || 0 !== i && 2 !== i) { if (2 === i) d = function d(e) { return assertInstanceIfPrivate(l, e), a.value; };else { var y = 0 === i || 1 === i; (y || 3 === i) && (d = o ? function (e) { return assertInstanceIfPrivate(l, e), a.get.call(e); } : function (e) { return a.get.call(e); }), (y || 4 === i) && (p = o ? function (e, t) { assertInstanceIfPrivate(l, e), a.set.call(e, t); } : function (e, t) { a.set.call(e, t); }); } } else d = function d(e) { return e[r]; }, 0 === i && (p = function p(e, t) { e[r] = t; }); var m = o ? l.bind() : function (e) { return r in e; }; h.access = d && p ? { get: d, set: p, has: m } : d ? { get: d, has: m } : { set: p, has: m }; try { return e.call(t, c, h); } finally { v.v = !0; } } | ||
function assertNotFinished(e, t) { if (e.v) throw new Error("attempted to call " + t + " after decoration was finished"); } | ||
@@ -10,4 +22,4 @@ function assertCallable(e, t) { if ("function" != typeof e) throw new TypeError(t + " must be a function"); } | ||
function curryThis2(e) { return function (t) { e(this, t); }; } | ||
function applyMemberDec(e, t, r, a, n, i, s, o, c, l, u) { var f, d, p, h, v, y, m = r[0]; a || Array.isArray(m) || (m = [m]), o ? f = 0 === i || 1 === i ? { get: curryThis1(r[3]), set: curryThis2(r[4]) } : 3 === i ? { get: r[3] } : 4 === i ? { set: r[3] } : { value: r[3] } : 0 !== i && (f = Object.getOwnPropertyDescriptor(t, n)), 1 === i ? p = { get: f.get, set: f.set } : 2 === i ? p = f.value : 3 === i ? p = f.get : 4 === i && (p = f.set); for (var g = a ? 2 : 1, b = m.length - 1; b >= 0; b -= g) { var I; if (void 0 !== (h = memberDec(m[b], a ? m[b - 1] : void 0, n, f, c, i, s, o, p, l, u))) assertValidReturnValue(i, h), 0 === i ? I = h : 1 === i ? (I = h.init, v = h.get || p.get, y = h.set || p.set, p = { get: v, set: y }) : p = h, void 0 !== I && (void 0 === d ? d = I : "function" == typeof d ? d = [d, I] : d.push(I)); } if (0 === i || 1 === i) { if (void 0 === d) d = function (e, t) { return t; };else if ("function" != typeof d) { var w = d; d = function (e, t) { for (var r = t, a = w.length - 1; a >= 0; a--) r = w[a].call(e, r); return r; }; } else { var M = d; d = function (e, t) { return M.call(e, t); }; } e.push(d); } 0 !== i && (1 === i ? (f.get = p.get, f.set = p.set) : 2 === i ? f.value = p : 3 === i ? f.get = p : 4 === i && (f.set = p), o ? 1 === i ? (e.push(function (e, t) { return p.get.call(e, t); }), e.push(function (e, t) { return p.set.call(e, t); })) : 2 === i ? e.push(p) : e.push(function (e, t) { return p.call(e, t); }) : Object.defineProperty(t, n, f)); } | ||
function applyMemberDecs(e, t, r, a) { for (var n, i, s, o = [], c = new Map(), l = new Map(), u = 0; u < t.length; u++) { var f = t[u]; if (Array.isArray(f)) { var d, p, h = f[1], v = f[2], y = f.length > 3, m = 16 & h, g = !!(8 & h), b = r; if (h &= 7, g ? (d = e, 0 !== h && (p = i = i || []), y && !s && (s = function (t) { return _checkInRHS(t) === e; }), b = s) : (d = e.prototype, 0 !== h && (p = n = n || [])), 0 !== h && !y) { var I = g ? l : c, w = I.get(v) || 0; if (!0 === w || 3 === w && 4 !== h || 4 === w && 3 !== h) throw new Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + v); I.set(v, !(!w && h > 2) || h); } applyMemberDec(o, d, f, m, v, h, g, y, p, b, a); } } return pushInitializers(o, n), pushInitializers(o, i), o; } | ||
function applyMemberDec(e, t, r, a, n, i, s, o, c, l, u) { var f, d, p, h, v, y, m = r[0]; a || Array.isArray(m) || (m = [m]), o ? f = 0 === i || 1 === i ? { get: curryThis1(r[3]), set: curryThis2(r[4]) } : 3 === i ? { get: r[3] } : 4 === i ? { set: r[3] } : { value: r[3] } : 0 !== i && (f = Object.getOwnPropertyDescriptor(t, n)), 1 === i ? p = { get: f.get, set: f.set } : 2 === i ? p = f.value : 3 === i ? p = f.get : 4 === i && (p = f.set); for (var g = a ? 2 : 1, b = m.length - 1; b >= 0; b -= g) { var I; if (void 0 !== (h = memberDec(m[b], a ? m[b - 1] : void 0, n, f, c, i, s, o, p, l, u))) assertValidReturnValue(i, h), 0 === i ? I = h : 1 === i ? (I = h.init, v = h.get || p.get, y = h.set || p.set, p = { get: v, set: y }) : p = h, void 0 !== I && (void 0 === d ? d = I : "function" == typeof d ? d = [d, I] : d.push(I)); } if (0 === i || 1 === i) { if (void 0 === d) d = function d(e, t) { return t; };else if ("function" != typeof d) { var w = d; d = function d(e, t) { for (var r = t, a = w.length - 1; a >= 0; a--) r = w[a].call(e, r); return r; }; } else { var M = d; d = function d(e, t) { return M.call(e, t); }; } e.push(d); } 0 !== i && (1 === i ? (f.get = p.get, f.set = p.set) : 2 === i ? f.value = p : 3 === i ? f.get = p : 4 === i && (f.set = p), o ? 1 === i ? (e.push(function (e, t) { return p.get.call(e, t); }), e.push(function (e, t) { return p.set.call(e, t); })) : 2 === i ? e.push(p) : e.push(function (e, t) { return p.call(e, t); }) : Object.defineProperty(t, n, f)); } | ||
function applyMemberDecs(e, t, r, a) { for (var n, i, s, o = [], c = new Map(), l = new Map(), u = 0; u < t.length; u++) { var f = t[u]; if (Array.isArray(f)) { var d, p, h = f[1], v = f[2], y = f.length > 3, m = 16 & h, g = !!(8 & h), b = r; if (h &= 7, g ? (d = e, 0 !== h && (p = i = i || []), y && !s && (s = function s(t) { return _checkInRHS(t) === e; }), b = s) : (d = e.prototype, 0 !== h && (p = n = n || [])), 0 !== h && !y) { var I = g ? l : c, w = I.get(v) || 0; if (!0 === w || 3 === w && 4 !== h || 4 === w && 3 !== h) throw new Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + v); I.set(v, !(!w && h > 2) || h); } applyMemberDec(o, d, f, m, v, h, g, y, p, b, a); } } return pushInitializers(o, n), pushInitializers(o, i), o; } | ||
function pushInitializers(e, t) { t && e.push(function (e) { for (var r = 0; r < t.length; r++) t[r].call(e); return e; }); } | ||
@@ -35,6 +47,5 @@ function applyClassDecs(e, t, r, a) { if (t.length) { for (var n = [], i = e, s = e.name, o = r ? 2 : 1, c = t.length - 1; c >= 0; c -= o) { var l = { v: !1 }; try { var u = t[c].call(r ? t[c - 1] : void 0, i, { kind: "class", name: s, addInitializer: createAddInitializerMethod(n, l), metadata: a }); } finally { l.v = !0; } void 0 !== u && (assertValidReturnValue(5, u), i = u); } return [defineMetadata(i, a), function () { for (var e = 0; e < n.length; e++) n[e].call(i); }]; } } | ||
} | ||
createElement({ | ||
node | ||
}) { | ||
const inner = document.createElement("img"); | ||
createElement(_ref) { | ||
var node = _ref.node; | ||
var inner = document.createElement("img"); | ||
inner.setAttribute("src", node.attrs.src); | ||
@@ -63,4 +74,4 @@ setStyle(inner, { | ||
}), _dec2 = command(), _dec3 = command(), (_class = class ImageExtension extends NodeExtension { | ||
constructor(...args) { | ||
super(...args); | ||
constructor() { | ||
super(...arguments); | ||
_initProto(this); | ||
@@ -75,12 +86,10 @@ } | ||
createNodeSpec(extra, override) { | ||
const { | ||
preferPastedTextContent | ||
} = this.options; | ||
return { | ||
var _override$parseDOM; | ||
var preferPastedTextContent = this.options.preferPastedTextContent; | ||
return _objectSpread(_objectSpread({ | ||
inline: true, | ||
draggable: true, | ||
selectable: false, | ||
...override, | ||
attrs: { | ||
...extra.defaults(), | ||
selectable: false | ||
}, override), {}, { | ||
attrs: _objectSpread(_objectSpread({}, extra.defaults()), {}, { | ||
alt: { | ||
@@ -113,3 +122,3 @@ default: "" | ||
} | ||
}, | ||
}), | ||
parseDOM: [{ | ||
@@ -120,3 +129,3 @@ tag: "img[src]", | ||
var _attrs$src; | ||
const attrs = getImageAttributes({ | ||
var attrs = getImageAttributes({ | ||
element, | ||
@@ -132,22 +141,17 @@ parse: extra.parse | ||
} | ||
}, ...(override.parseDOM ?? [])], | ||
}, ...((_override$parseDOM = override.parseDOM) !== null && _override$parseDOM !== void 0 ? _override$parseDOM : [])], | ||
toDOM: node => { | ||
const attrs = omitExtraAttributes(node.attrs, extra); | ||
return ["img", { | ||
...extra.dom(node), | ||
...attrs | ||
}]; | ||
var attrs = omitExtraAttributes(node.attrs, extra); | ||
return ["img", _objectSpread(_objectSpread({}, extra.dom(node)), attrs)]; | ||
} | ||
}; | ||
}); | ||
} | ||
insertImage(attributes, selection) { | ||
return ({ | ||
tr, | ||
dispatch | ||
}) => { | ||
const { | ||
from, | ||
to | ||
} = getTextSelection(selection ?? tr.selection, tr.doc); | ||
const node = this.type.create(attributes); | ||
return _ref2 => { | ||
var tr = _ref2.tr, | ||
dispatch = _ref2.dispatch; | ||
var _getTextSelection = getTextSelection(selection !== null && selection !== void 0 ? selection : tr.selection, tr.doc), | ||
from = _getTextSelection.from, | ||
to = _getTextSelection.to; | ||
var node = this.type.create(attributes); | ||
dispatch === null || dispatch === void 0 ? void 0 : dispatch(tr.replaceRangeWith(from, to, node)); | ||
@@ -158,12 +162,9 @@ return true; | ||
uploadImage(value, onElement) { | ||
const { | ||
updatePlaceholder, | ||
destroyPlaceholder, | ||
createPlaceholder: createPlaceholder2 | ||
} = this.options; | ||
var _this$options = this.options, | ||
updatePlaceholder = _this$options.updatePlaceholder, | ||
destroyPlaceholder = _this$options.destroyPlaceholder, | ||
createPlaceholder2 = _this$options.createPlaceholder; | ||
return props => { | ||
const { | ||
tr | ||
} = props; | ||
let pos = tr.selection.from; | ||
var tr = props.tr; | ||
var pos = tr.selection.from; | ||
return this.store.createPlaceholderCommand({ | ||
@@ -177,3 +178,3 @@ promise: value, | ||
createElement: (view, pos2) => { | ||
const element = createPlaceholder2(view, pos2); | ||
var element = createPlaceholder2(view, pos2); | ||
onElement === null || onElement === void 0 ? void 0 : onElement(element); | ||
@@ -190,7 +191,6 @@ return element; | ||
onSuccess: (value2, range, commandProps) => this.insertImage(value2, range)(commandProps) | ||
}).validate(({ | ||
tr: tr2, | ||
dispatch | ||
}) => { | ||
const insertPos = insertPoint(tr2.doc, pos, this.type); | ||
}).validate(_ref3 => { | ||
var tr2 = _ref3.tr, | ||
dispatch = _ref3.dispatch; | ||
var insertPos = insertPoint(tr2.doc, pos, this.type); | ||
if (insertPos == null) { | ||
@@ -209,25 +209,32 @@ return false; | ||
var _event$clipboardData; | ||
const { | ||
preferPastedTextContent, | ||
uploadHandler: uploadHandler2 | ||
} = this.options; | ||
var _this$options2 = this.options, | ||
preferPastedTextContent = _this$options2.preferPastedTextContent, | ||
uploadHandler2 = _this$options2.uploadHandler; | ||
if (preferPastedTextContent && isClipboardEvent(event) && (_event$clipboardData = event.clipboardData) !== null && _event$clipboardData !== void 0 && _event$clipboardData.getData("text/plain")) { | ||
return false; | ||
} | ||
const { | ||
commands, | ||
chain | ||
} = this.store; | ||
const filesWithProgress = files.map((file, index) => ({ | ||
var _this$store = this.store, | ||
commands = _this$store.commands, | ||
chain = _this$store.chain; | ||
var filesWithProgress = files.map((file, index) => ({ | ||
file, | ||
progress: progress => { | ||
commands.updatePlaceholder(uploads[index], progress); | ||
progress: _progress => { | ||
commands.updatePlaceholder(uploads[index], _progress); | ||
} | ||
})); | ||
const uploads = uploadHandler2(filesWithProgress); | ||
var uploads = uploadHandler2(filesWithProgress); | ||
if (isNumber(pos)) { | ||
chain.selectText(pos); | ||
} | ||
for (const upload of uploads) { | ||
chain.uploadImage(upload); | ||
var _iterator = _createForOfIteratorHelper(uploads), | ||
_step; | ||
try { | ||
for (_iterator.s(); !(_step = _iterator.n()).done;) { | ||
var upload = _step.value; | ||
chain.uploadImage(upload); | ||
} | ||
} catch (err) { | ||
_iterator.e(err); | ||
} finally { | ||
_iterator.f(); | ||
} | ||
@@ -242,3 +249,3 @@ chain.run(); | ||
fileHandler: props => { | ||
const pos = props.type === "drop" ? props.pos : void 0; | ||
var pos = props.type === "drop" ? props.pos : void 0; | ||
return this.fileUploadFileHandler(props.files, props.event, pos); | ||
@@ -254,6 +261,3 @@ } | ||
} | ||
}, ({ | ||
e: [_initProto], | ||
c: [_ImageExtension, _initClass] | ||
} = _applyDecs(_class, [[_dec2, 2, "insertImage"], [_dec3, 2, "uploadImage"]], [_dec])), _initClass())), _ImageExtension); | ||
}, (_applyDecs2 = _applyDecs(_class, [[_dec2, 2, "insertImage"], [_dec3, 2, "uploadImage"]], [_dec]), _applyDecs2$e = _slicedToArray(_applyDecs2.e, 1), _initProto = _applyDecs2$e[0], _applyDecs2$c = _slicedToArray(_applyDecs2.c, 2), _ImageExtension = _applyDecs2$c[0], _initClass = _applyDecs2$c[1]), _initClass())), _ImageExtension); | ||
var IMAGE_FILE_TYPES = /* @__PURE__ */new Set(["image/jpeg", "image/gif", "image/png", "image/jpg", "image/svg", "image/webp"]); | ||
@@ -264,6 +268,5 @@ function isImageFileType(file) { | ||
function getDimensions(element) { | ||
let { | ||
width, | ||
height | ||
} = element.style; | ||
var _element$style = element.style, | ||
width = _element$style.width, | ||
height = _element$style.height; | ||
width = width || element.getAttribute("width") || ""; | ||
@@ -276,22 +279,20 @@ height = height || element.getAttribute("height") || ""; | ||
} | ||
function getImageAttributes({ | ||
element, | ||
parse | ||
}) { | ||
const { | ||
width, | ||
height | ||
} = getDimensions(element); | ||
return { | ||
...parse(element), | ||
alt: element.getAttribute("alt") ?? "", | ||
function getImageAttributes(_ref4) { | ||
var _element$getAttribute, _element$getAttribute2, _element$getAttribute3, _element$getAttribute4; | ||
var element = _ref4.element, | ||
parse = _ref4.parse; | ||
var _getDimensions = getDimensions(element), | ||
width = _getDimensions.width, | ||
height = _getDimensions.height; | ||
return _objectSpread(_objectSpread({}, parse(element)), {}, { | ||
alt: (_element$getAttribute = element.getAttribute("alt")) !== null && _element$getAttribute !== void 0 ? _element$getAttribute : "", | ||
height: Number.parseInt(height || "0", 10) || null, | ||
src: element.getAttribute("src") ?? null, | ||
title: element.getAttribute("title") ?? "", | ||
src: (_element$getAttribute2 = element.getAttribute("src")) !== null && _element$getAttribute2 !== void 0 ? _element$getAttribute2 : null, | ||
title: (_element$getAttribute3 = element.getAttribute("title")) !== null && _element$getAttribute3 !== void 0 ? _element$getAttribute3 : "", | ||
width: Number.parseInt(width || "0", 10) || null, | ||
fileName: element.getAttribute("data-file-name") ?? null | ||
}; | ||
fileName: (_element$getAttribute4 = element.getAttribute("data-file-name")) !== null && _element$getAttribute4 !== void 0 ? _element$getAttribute4 : null | ||
}); | ||
} | ||
function createPlaceholder(_, __) { | ||
const element = document.createElement("div"); | ||
var element = document.createElement("div"); | ||
element.classList.add(ExtensionImageTheme.IMAGE_LOADER); | ||
@@ -305,23 +306,34 @@ return element; | ||
}); | ||
let completed = 0; | ||
const promises = []; | ||
for (const { | ||
file, | ||
progress | ||
} of files) { | ||
promises.push(() => new Promise(resolve => { | ||
const reader = new FileReader(); | ||
reader.addEventListener("load", readerEvent => { | ||
var _readerEvent$target; | ||
completed += 1; | ||
progress(completed / files.length); | ||
resolve({ | ||
src: (_readerEvent$target = readerEvent.target) === null || _readerEvent$target === void 0 ? void 0 : _readerEvent$target.result, | ||
fileName: file.name | ||
var completed = 0; | ||
var promises = []; | ||
var _iterator2 = _createForOfIteratorHelper(files), | ||
_step2; | ||
try { | ||
var _loop = function _loop() { | ||
var _step2$value = _step2.value, | ||
file = _step2$value.file, | ||
progress = _step2$value.progress; | ||
promises.push(() => new Promise(resolve => { | ||
var reader = new FileReader(); | ||
reader.addEventListener("load", readerEvent => { | ||
var _readerEvent$target; | ||
completed += 1; | ||
progress(completed / files.length); | ||
resolve({ | ||
src: (_readerEvent$target = readerEvent.target) === null || _readerEvent$target === void 0 ? void 0 : _readerEvent$target.result, | ||
fileName: file.name | ||
}); | ||
}, { | ||
once: true | ||
}); | ||
}, { | ||
once: true | ||
}); | ||
reader.readAsDataURL(file); | ||
})); | ||
reader.readAsDataURL(file); | ||
})); | ||
}; | ||
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { | ||
_loop(); | ||
} | ||
} catch (err) { | ||
_iterator2.e(err); | ||
} finally { | ||
_iterator2.f(); | ||
} | ||
@@ -328,0 +340,0 @@ return promises; |
{ | ||
"name": "@remirror/extension-image", | ||
"version": "3.0.0-beta.2", | ||
"version": "3.0.0-beta.3", | ||
"description": "Add images to your editor.", | ||
@@ -42,3 +42,3 @@ "keywords": [ | ||
"@babel/runtime": "^7.22.3", | ||
"@remirror/core": "3.0.0-beta.2", | ||
"@remirror/core": "3.0.0-beta.3", | ||
"@remirror/messages": "3.0.0-beta.1", | ||
@@ -45,0 +45,0 @@ "@remirror/theme": "3.0.0-beta.1", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
146185
1388
+ Added@remirror/core@3.0.0-beta.3(transitive)
- Removed@remirror/core@3.0.0-beta.2(transitive)
Updated@remirror/core@3.0.0-beta.3