@fileverse-dev/ddoc 7.1.0 → 7.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { c as s } from "./use-headless-editor-Bs_4LOHk.mjs";
1
+ import { c as s } from "./use-headless-editor-DjrTc5Rg.mjs";
2
2
  const n = (e) => {
3
3
  const { getYjsConvertor: t, mergeYjsUpdates: r } = s(e);
4
4
  return { getYjsConvertor: t, mergeYjsUpdates: r };
@@ -1,4 +1,4 @@
1
- import { bA as Cl, bB as re } from "./use-headless-editor-Bs_4LOHk.mjs";
1
+ import { bA as Cl, bB as re } from "./use-headless-editor-DjrTc5Rg.mjs";
2
2
  import Wl from "base64-js";
3
3
  import Bl from "jszip";
4
4
  var Qe = {}, na = "1.13.7", xc = typeof self == "object" && self.self === self && self || typeof global == "object" && global.global === global && global || Function("return this")() || {}, Zt = Array.prototype, ta = Object.prototype, vc = typeof Symbol < "u" ? Symbol.prototype : null, Sl = Zt.push, Ut = Zt.slice, st = ta.toString, Nl = ta.hasOwnProperty, Du = typeof ArrayBuffer < "u", Rl = typeof DataView < "u", Ol = Array.isArray, Uc = Object.keys, Tc = Object.create, _c = Du && ArrayBuffer.isView, kl = isNaN, Il = isFinite, yu = !{ toString: null }.propertyIsEnumerable("toString"), Ec = [
package/dist/index.es.js CHANGED
@@ -2,8 +2,8 @@ var Yc = Object.defineProperty;
2
2
  var Xc = (e, t, n) => t in e ? Yc(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
3
  var Q = (e, t, n) => Xc(e, typeof t != "symbol" ? t + "" : t, n);
4
4
  import { jsx as r, jsxs as v, Fragment as rt } from "react/jsx-runtime";
5
- import { P as Qn, a as Zn, i as va, p as ka, N as Qc, C as Zc, E as Jn, g as Jc, b as ed, u as Sa, l as td, d as St, e as _, f as qt, r as Na, n as es, h as yo, j as nd, k as Es, F as sd, L as od, m as Ta, o as rd, q as As, s as sr, I as je, S as id, t as or, v as ad, T as at, w as ld, x as Ea, y as cd, z as dd, A as Aa, B as $n, D as Ra, G as Nr, H as Tr, J as Ia, K as ud, M as Er, O as hd, Q as md, R as pd, U as fd, V as Da, W as gd, X as yd, Y as xd, Z as $s, _ as wd, $ as Lo, a0 as bd, a1 as Cd, a2 as xt, a3 as vd, a4 as yi, a5 as kd, a6 as Sd, a7 as Nd, a8 as Td, a9 as Dn, aa as Ma, ab as Ed, ac as bs, ad as Ad, ae as xo, af as Rd, ag as Id, ah as Dd, ai as Md, aj as Od, ak as Oa, al as Rs, am as Ba, an as Fa, ao as ws, ap as Bd, aq as rr, ar as xi, as as wi, at as Fd, au as _d, av as Ld, aw as _a, ax as Ud, ay as Pd, az as Hd, aA as zd, aB as Kd, aC as jd, aD as Vd, aE as Wd, aF as qd, aG as $d, aH as Gd, aI as Yd, aJ as Xd, aK as Qd, aL as Uo, aM as La, aN as Ua, aO as Zd, aP as Jd, aQ as eu, aR as tu, aS as an, aT as nu, aU as bi, aV as Cs, aW as Ar, aX as su, aY as Rr, aZ as ou, a_ as Po, a$ as ru, b0 as Pa, b1 as hs, b2 as iu, b3 as au, b4 as lu, b5 as cu, b6 as du, b7 as uu, b8 as hu, b9 as mu, ba as pu, bb as fu, bc as gu, bd as ir, be as ar, bf as yu, bg as xu, bh as wu, bi as bu, bj as Cu, bk as vu, bl as Ci, bm as ku, bn as Su, bo as vi, bp as Nu, bq as Tu, br as Eu, bs as Au, bt as Ru, bu as Ha, bv as ki, bw as Iu, bx as Du } from "./use-headless-editor-Bs_4LOHk.mjs";
6
- import { by as ay, bz as ly } from "./use-headless-editor-Bs_4LOHk.mjs";
5
+ import { P as Qn, a as Zn, i as va, p as ka, N as Qc, C as Zc, E as Jn, g as Jc, b as ed, u as Sa, l as td, d as St, e as _, f as qt, r as Na, n as es, h as yo, j as nd, k as Es, F as sd, L as od, m as Ta, o as rd, q as As, s as sr, I as je, S as id, t as or, v as ad, T as at, w as ld, x as Ea, y as cd, z as dd, A as Aa, B as $n, D as Ra, G as Nr, H as Tr, J as Ia, K as ud, M as Er, O as hd, Q as md, R as pd, U as fd, V as Da, W as gd, X as yd, Y as xd, Z as $s, _ as wd, $ as Lo, a0 as bd, a1 as Cd, a2 as xt, a3 as vd, a4 as yi, a5 as kd, a6 as Sd, a7 as Nd, a8 as Td, a9 as Dn, aa as Ma, ab as Ed, ac as bs, ad as Ad, ae as xo, af as Rd, ag as Id, ah as Dd, ai as Md, aj as Od, ak as Oa, al as Rs, am as Ba, an as Fa, ao as ws, ap as Bd, aq as rr, ar as xi, as as wi, at as Fd, au as _d, av as Ld, aw as _a, ax as Ud, ay as Pd, az as Hd, aA as zd, aB as Kd, aC as jd, aD as Vd, aE as Wd, aF as qd, aG as $d, aH as Gd, aI as Yd, aJ as Xd, aK as Qd, aL as Uo, aM as La, aN as Ua, aO as Zd, aP as Jd, aQ as eu, aR as tu, aS as an, aT as nu, aU as bi, aV as Cs, aW as Ar, aX as su, aY as Rr, aZ as ou, a_ as Po, a$ as ru, b0 as Pa, b1 as hs, b2 as iu, b3 as au, b4 as lu, b5 as cu, b6 as du, b7 as uu, b8 as hu, b9 as mu, ba as pu, bb as fu, bc as gu, bd as ir, be as ar, bf as yu, bg as xu, bh as wu, bi as bu, bj as Cu, bk as vu, bl as Ci, bm as ku, bn as Su, bo as vi, bp as Nu, bq as Tu, br as Eu, bs as Au, bt as Ru, bu as Ha, bv as ki, bw as Iu, bx as Du } from "./use-headless-editor-DjrTc5Rg.mjs";
6
+ import { by as ay, bz as ly } from "./use-headless-editor-DjrTc5Rg.mjs";
7
7
  import { flip as za, shift as Ka, offset as ja, arrow as Va, size as Wa, autoPlacement as qa, hide as $a, inline as Ga, computePosition as Ir } from "@floating-ui/dom";
8
8
  import Xe, { useRef as F, useEffect as P, useState as G, useCallback as M, useMemo as ve, forwardRef as bt, useReducer as Mu, useLayoutEffect as ln, memo as wo, createElement as lr, lazy as Ya, Suspense as Si, useImperativeHandle as Xa } from "react";
9
9
  import { createPortal as Ln } from "react-dom";
@@ -6,7 +6,8 @@ export type UploadFnType = (image: File) => Promise<string>;
6
6
  * This function creates a Prosemirror plugin that handles pasting and dropping of media files.
7
7
  * It accepts an upload function as a parameter which is used to upload the media files.
8
8
  * The plugin prevents the default paste and drop event, uploads the media file (if an upload function is provided),
9
- * creates a new node with the uploaded media file and replaces the current selection with the new node.
9
+ * creates a new node with the uploaded media file. Paste replaces the current selection;
10
+ * drop inserts at the drop position without deleting selected text.
10
11
  * If no upload function is provided, it reads the media file as DataURL and uses this in the new node.
11
12
  * The function returns a new instance of the Plugin.
12
13
  */
@@ -4,7 +4,9 @@ import { IpfsImageUploadResponse } from '../types';
4
4
 
5
5
  declare const UploadImagesPlugin: () => Plugin<DecorationSet>;
6
6
  export default UploadImagesPlugin;
7
- export declare function startImageUpload(file: File, view: EditorView, pos: number, ipfsImageUploadFn?: (file: File) => Promise<IpfsImageUploadResponse>): Promise<void>;
7
+ export declare function startImageUpload(file: File, view: EditorView, pos: number, ipfsImageUploadFn?: (file: File) => Promise<IpfsImageUploadResponse>, { replaceSelection }?: {
8
+ replaceSelection?: boolean;
9
+ }): Promise<void>;
8
10
  export declare const uploadFn: (image: File) => Promise<string>;
9
11
  export declare const uploadSecureImage: (url: string, image: File, publicKey: ArrayBuffer) => Promise<any>;
10
12
  export declare const handleDecryptImage: (url: string, encryptedKey: string, privateKey: string, iv: string) => Promise<string | undefined>;
@@ -17830,51 +17830,51 @@ function am(t, e, n) {
17830
17830
  const o = t.state.tr, s = t.state.doc.resolve(r), i = s.parent;
17831
17831
  return i.isTextblock && i.content.size === 0 ? o.replaceWith(s.before(), s.after(), n) : o.replaceRangeWith(r, r, n), o.setMeta(Ws, { remove: { id: e } }), t.dispatch(o), !0;
17832
17832
  }
17833
- async function qs(t, e, n, r) {
17833
+ async function qs(t, e, n, r, { replaceSelection: o = !0 } = {}) {
17834
17834
  if (!t.type.includes("image/")) {
17835
17835
  console.log("file is not an image");
17836
17836
  return;
17837
17837
  }
17838
- const o = {};
17838
+ const s = {};
17839
17839
  try {
17840
- const s = e.state.tr;
17841
- s.selection.empty || s.deleteSelection(), s.setMeta(Ws, {
17840
+ const i = e.state.tr;
17841
+ o && !i.selection.empty && i.deleteSelection(), i.setMeta(Ws, {
17842
17842
  add: {
17843
- id: o,
17843
+ id: s,
17844
17844
  pos: n - 1,
17845
17845
  content: "Uploading image..."
17846
17846
  }
17847
- }), e.dispatch(s);
17848
- const { schema: i } = e.state;
17849
- if (b0(e.state, o) == null) return;
17847
+ }), e.dispatch(i);
17848
+ const { schema: a } = e.state;
17849
+ if (b0(e.state, s) == null) return;
17850
17850
  if (t = await y0(t), r) {
17851
- const { ipfsUrl: l, encryptionKey: c, nonce: u, ipfsHash: d, authTag: f } = await r(t), p = i.nodes.resizableMedia.create({
17852
- encryptionKey: c,
17853
- ipfsUrl: l,
17854
- nonce: u,
17851
+ const { ipfsUrl: c, encryptionKey: u, nonce: d, ipfsHash: f, authTag: p } = await r(t), h = a.nodes.resizableMedia.create({
17852
+ encryptionKey: u,
17853
+ ipfsUrl: c,
17854
+ nonce: d,
17855
17855
  mimeType: t.type,
17856
17856
  version: "2",
17857
- ipfsHash: d,
17858
- authTag: f,
17857
+ ipfsHash: f,
17858
+ authTag: p,
17859
17859
  "media-type": "secure-img",
17860
17860
  width: "100%",
17861
17861
  height: "auto"
17862
17862
  });
17863
- am(e, o, p);
17863
+ am(e, s, h);
17864
17864
  } else {
17865
- const l = new FileReader();
17866
- l.readAsDataURL(t), l.onloadend = () => {
17867
- const { schema: c } = e.state, u = l.result, d = c.nodes.resizableMedia.create({
17868
- src: u,
17865
+ const c = new FileReader();
17866
+ c.readAsDataURL(t), c.onloadend = () => {
17867
+ const { schema: u } = e.state, d = c.result, f = u.nodes.resizableMedia.create({
17868
+ src: d,
17869
17869
  "media-type": "img"
17870
17870
  });
17871
- am(e, o, d);
17871
+ am(e, s, f);
17872
17872
  };
17873
17873
  }
17874
- } catch (s) {
17875
- console.error("Error during image upload: ", s);
17876
- const i = e.state.tr.setMeta(Ws, { remove: { id: o } });
17877
- e.dispatch(i);
17874
+ } catch (i) {
17875
+ console.error("Error during image upload: ", i);
17876
+ const a = e.state.tr.setMeta(Ws, { remove: { id: s } });
17877
+ e.dispatch(a);
17878
17878
  }
17879
17879
  }
17880
17880
  const Ks = (t, e) => t.type.includes("image") && !["image/png", "image/jpeg", "image/gif", "image/svg+xml"].includes(
@@ -39983,7 +39983,7 @@ ${u}
39983
39983
  f = h.showLoader(), p = h.removeLoader;
39984
39984
  }
39985
39985
  try {
39986
- const h = await a.arrayBuffer(), { default: m } = await import("./index-C27hDm2f.mjs").then((v) => v.i), { value: g } = await m.convertToHtml(
39986
+ const h = await a.arrayBuffer(), { default: m } = await import("./index-DOFcNLkR.mjs").then((v) => v.i), { value: g } = await m.convertToHtml(
39987
39987
  { arrayBuffer: h },
39988
39988
  {
39989
39989
  styleMap: hk,
@@ -41164,7 +41164,8 @@ const K4 = (t, e) => new G({
41164
41164
  c,
41165
41165
  n,
41166
41166
  a.pos,
41167
- e
41167
+ e,
41168
+ { replaceSelection: !1 }
41168
41169
  );
41169
41170
  } catch (d) {
41170
41171
  throw t(d.message || "Error uploading media"), new Error(
@@ -44301,7 +44302,7 @@ const G5 = (t, e) => {
44301
44302
  async function d(f, p, h) {
44302
44303
  if (f.type === "application/vnd.openxmlformats-officedocument.wordprocessingml.document" || f.name.endsWith(".docx"))
44303
44304
  try {
44304
- const m = await f.arrayBuffer(), { default: g } = await import("./index-C27hDm2f.mjs").then((C) => C.i), { value: y } = await g.convertToHtml(
44305
+ const m = await f.arrayBuffer(), { default: g } = await import("./index-DOFcNLkR.mjs").then((C) => C.i), { value: y } = await g.convertToHtml(
44305
44306
  { arrayBuffer: m },
44306
44307
  {
44307
44308
  styleMap: hk,
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@fileverse-dev/ddoc",
3
3
  "private": false,
4
4
  "description": "DDoc",
5
- "version": "7.1.0",
5
+ "version": "7.1.1",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "git+https://github.com/fileverse/fileverse-ddocs.git"