@ylzcc/editor 0.2.5 → 0.2.6

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.
package/dist/editor.es.js CHANGED
@@ -84630,33 +84630,33 @@ function LowlightPlugin({
84630
84630
  return B_;
84631
84631
  }
84632
84632
  const CodeBlockView = ({ editor: Ff, node: kh, updateAttributes: x_, extension: B_ }) => {
84633
- var lme, dme, fme, pme, hme, mme, _me;
84634
- const $_ = useContext(shareData), [$P, zP] = useState("light"), [eme, tme] = useState(((lme = kh == null ? void 0 : kh.attrs) == null ? void 0 : lme.exec) || !1), [nme, rme] = useState(!1), [ime, ome] = useState(!1), ame = (gme) => {
84633
+ var lme, dme, fme, pme, hme, mme;
84634
+ const $_ = useContext(shareData), [$P, zP] = useState("light"), [eme, tme] = useState(((lme = kh == null ? void 0 : kh.attrs) == null ? void 0 : lme.exec) || !1), [nme, rme] = useState(!1), [ime, ome] = useState(!1), ame = (_me) => {
84635
84635
  x_({
84636
- language: gme
84636
+ language: _me
84637
84637
  });
84638
- }, ume = (gme) => {
84639
- var Sme;
84640
- const vme = (Sme = gme == null ? void 0 : gme.target) == null ? void 0 : Sme.checked;
84641
- tme(vme), x_({
84642
- exec: vme
84638
+ }, ume = (_me) => {
84639
+ var vme;
84640
+ const gme = (vme = _me == null ? void 0 : _me.target) == null ? void 0 : vme.checked;
84641
+ tme(gme), x_({
84642
+ exec: gme
84643
84643
  });
84644
84644
  }, cme = () => {
84645
- var gme;
84646
- (gme = navigator == null ? void 0 : navigator.clipboard) == null || gme.writeText(kh == null ? void 0 : kh.textContent).then(() => {
84645
+ var _me;
84646
+ (_me = navigator == null ? void 0 : navigator.clipboard) == null || _me.writeText(kh == null ? void 0 : kh.textContent).then(() => {
84647
84647
  rme(!0);
84648
- const vme = setTimeout(() => {
84649
- rme(!1), clearTimeout(vme);
84648
+ const gme = setTimeout(() => {
84649
+ rme(!1), clearTimeout(gme);
84650
84650
  }, 2e3);
84651
84651
  });
84652
84652
  }, sme = () => {
84653
- var gme;
84654
- (gme = B_ == null ? void 0 : B_.options) == null || gme.onExec(kh == null ? void 0 : kh.textContent);
84653
+ var _me;
84654
+ (_me = B_ == null ? void 0 : B_.options) == null || _me.onExec(kh == null ? void 0 : kh.textContent);
84655
84655
  };
84656
84656
  return useEffect(() => {
84657
84657
  zP(eme ? "dark" : "light");
84658
84658
  }, [eme]), /* @__PURE__ */ jsxRuntimeExports.jsx(NodeViewWrapper, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `code-block code-block-${$P}`, onMouseEnter: () => ome(!0), onMouseLeave: () => ome(!1), children: [
84659
- ime && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "code-block-header", contentEditable: !1, children: [
84659
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "code-block-header", contentEditable: !1, style: { display: ime ? "flex" : "none" }, children: [
84660
84660
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "code-block-header-left", children: [
84661
84661
  /* @__PURE__ */ jsxRuntimeExports.jsx(
84662
84662
  Select$1,
@@ -84668,7 +84668,7 @@ const CodeBlockView = ({ editor: Ff, node: kh, updateAttributes: x_, extension:
84668
84668
  onChange: ame,
84669
84669
  options: [
84670
84670
  { value: "", label: "atuo" },
84671
- ...(hme = (pme = (fme = B_ == null ? void 0 : B_.options) == null ? void 0 : fme.lowlight) == null ? void 0 : pme.listLanguages()) == null ? void 0 : hme.map((gme) => ({ value: gme, label: gme }))
84671
+ ...(hme = (pme = (fme = B_ == null ? void 0 : B_.options) == null ? void 0 : fme.lowlight) == null ? void 0 : pme.listLanguages()) == null ? void 0 : hme.map((_me) => ({ value: _me, label: _me }))
84672
84672
  ]
84673
84673
  }
84674
84674
  ),
@@ -84676,7 +84676,7 @@ const CodeBlockView = ({ editor: Ff, node: kh, updateAttributes: x_, extension:
84676
84676
  Select$1,
84677
84677
  {
84678
84678
  disabled: !0,
84679
- defaultValue: ((mme = $_ == null ? void 0 : $_.template) == null ? void 0 : mme.name) || ((_me = $_ == null ? void 0 : $_.template) == null ? void 0 : _me.experEnv)
84679
+ defaultValue: (mme = $_ == null ? void 0 : $_.template) == null ? void 0 : mme.name
84680
84680
  }
84681
84681
  )
84682
84682
  ] }),
@@ -84761,6 +84761,10 @@ const CodeBlockView = ({ editor: Ff, node: kh, updateAttributes: x_, extension:
84761
84761
  kh && clearTimeout(kh);
84762
84762
  const { editor: nme, tip: rme } = Ff;
84763
84763
  nme.isEditable && (kh = setTimeout(() => {
84764
+ var ume, cme;
84765
+ const ime = (cme = (ume = nme == null ? void 0 : nme.view) == null ? void 0 : ume.state) == null ? void 0 : cme.selection, { from: ome, to: ame } = ime;
84766
+ if (console.log(ome, ame), ome != ame)
84767
+ return !1;
84764
84768
  rme == null || rme.move(eme, tme);
84765
84769
  }, 0));
84766
84770
  },
@@ -86299,13 +86303,16 @@ const upload = async (Ff) => {
86299
86303
  }, textToBase64 = (Ff) => {
86300
86304
  const x_ = new TextEncoder().encode(Ff), B_ = String.fromCharCode(...x_);
86301
86305
  return btoa(B_);
86306
+ }, getFileSuffix = (Ff) => {
86307
+ const kh = Ff.indexOf(".") > -1 ? Ff.split(".") : [];
86308
+ return kh.length > 0 ? kh[kh.length - 1] : "";
86302
86309
  }, marks = {
86303
86310
  strong: "bold",
86304
86311
  emphasis: "italic",
86305
86312
  delete: "strike",
86306
86313
  link: "link"
86307
86314
  }, toNodeObj = (Ff, kh) => {
86308
- var $_, $P, zP, eme;
86315
+ var $_, $P, zP, eme, tme;
86309
86316
  const x_ = {};
86310
86317
  x_.type = Ff == null ? void 0 : Ff.type;
86311
86318
  const B_ = kh ? [...kh] : [];
@@ -86322,6 +86329,9 @@ const upload = async (Ff) => {
86322
86329
  case "list":
86323
86330
  x_.type = Ff != null && Ff.ordered ? "orderedList" : "bulletList";
86324
86331
  break;
86332
+ case "listItem":
86333
+ ($_ = Ff.children) != null && $_.length || (x_.content = [{ type: "paragraph" }]);
86334
+ break;
86325
86335
  case "thematicBreak":
86326
86336
  x_.type = "horizontalRule";
86327
86337
  break;
@@ -86339,34 +86349,31 @@ const upload = async (Ff) => {
86339
86349
  break;
86340
86350
  default:
86341
86351
  {
86342
- const tme = Object.keys(marks);
86343
- if (tme != null && tme.includes(Ff == null ? void 0 : Ff.type))
86352
+ const nme = Object.keys(marks);
86353
+ if (nme != null && nme.includes(Ff == null ? void 0 : Ff.type))
86344
86354
  if (Ff.type === "link" && /\.pdf$/i.test(Ff.url))
86345
86355
  x_.type = "pdf", x_.attrs = { pdfUrl: Ff == null ? void 0 : Ff.url };
86346
86356
  else {
86347
- const nme = { type: marks[Ff == null ? void 0 : Ff.type] };
86348
- Ff.type === "link" && (nme.attrs = { href: Ff == null ? void 0 : Ff.url, target: "_blank" });
86349
- const rme = Ff == null ? void 0 : Ff.children;
86350
- (rme == null ? void 0 : rme.length) === 1 && rme[0].type === "text" ? (x_.type = "text", x_.text = rme[0].value, x_.marks = [...B_, nme]) : (x_.type = "fragment", B_.push(nme));
86357
+ const rme = { type: marks[Ff == null ? void 0 : Ff.type] };
86358
+ Ff.type === "link" && (rme.attrs = { href: Ff == null ? void 0 : Ff.url, target: "_blank" });
86359
+ const ime = Ff == null ? void 0 : Ff.children;
86360
+ (ime == null ? void 0 : ime.length) === 1 && ime[0].type === "text" ? (x_.type = "text", x_.text = ime[0].value, x_.marks = [...B_, rme]) : (x_.type = "fragment", B_.push(rme));
86351
86361
  }
86352
86362
  }
86353
86363
  break;
86354
86364
  }
86355
- if (($_ = Ff == null ? void 0 : Ff.children) != null && $_.length)
86356
- if ((Ff == null ? void 0 : Ff.type) === "paragraph" && (($P = Ff == null ? void 0 : Ff.children) == null ? void 0 : $P.length) === 1 && ((zP = Ff == null ? void 0 : Ff.children[0]) == null ? void 0 : zP.type) === "image") {
86365
+ if (($P = Ff == null ? void 0 : Ff.children) != null && $P.length)
86366
+ if ((Ff == null ? void 0 : Ff.type) === "paragraph" && ((zP = Ff == null ? void 0 : Ff.children) == null ? void 0 : zP.length) === 1 && ((eme = Ff == null ? void 0 : Ff.children[0]) == null ? void 0 : eme.type) === "image") {
86357
86367
  x_.type = "image";
86358
- const tme = Ff == null ? void 0 : Ff.children[0];
86359
- x_.attrs = { src: tme == null ? void 0 : tme.url, alt: tme == null ? void 0 : tme.alt, title: tme == null ? void 0 : tme.title };
86368
+ const nme = Ff == null ? void 0 : Ff.children[0];
86369
+ x_.attrs = { src: nme == null ? void 0 : nme.url, alt: nme == null ? void 0 : nme.alt, title: nme == null ? void 0 : nme.title };
86360
86370
  } else
86361
- x_.content = (eme = Ff == null ? void 0 : Ff.children) == null ? void 0 : eme.map((tme) => toNodeObj(tme, B_));
86371
+ x_.content = (tme = Ff == null ? void 0 : Ff.children) == null ? void 0 : tme.map((nme) => toNodeObj(nme, B_));
86362
86372
  return x_.type === "text" && (x_ != null && x_.content) && (x_ == null || delete x_.content), x_;
86363
86373
  }, toEditorJSON = (Ff) => {
86364
86374
  var x_, B_, $_;
86365
86375
  const kh = {};
86366
86376
  return kh.type = "document", (x_ = Ff == null ? void 0 : Ff.children) != null && x_.length && (kh.content = ($_ = (B_ = Ff == null ? void 0 : Ff.children) == null ? void 0 : B_.filter(($P) => ($P == null ? void 0 : $P.type) !== "definition")) == null ? void 0 : $_.map(($P) => toNodeObj($P))), kh;
86367
- }, getFileSuffix = (Ff) => {
86368
- const kh = Ff.indexOf(".") > -1 ? Ff.split(".") : [];
86369
- return kh.length > 0 ? kh[kh.length - 1] : "";
86370
86377
  }, marksMD = {
86371
86378
  bold: "strong",
86372
86379
  italic: "emphasis",
@@ -86446,7 +86453,7 @@ const upload = async (Ff) => {
86446
86453
  x_.type = "link", x_.url = (vme = Ff == null ? void 0 : Ff.attrs) == null ? void 0 : vme.pdfUrl;
86447
86454
  break;
86448
86455
  }
86449
- return (Sme = Ff == null ? void 0 : Ff.content) != null && Sme.length && (x_.children = (Eme = Ff == null ? void 0 : Ff.content) == null ? void 0 : Eme.map((bme) => toMDNodeObj(bme, B_))), x_;
86456
+ return (Sme = Ff == null ? void 0 : Ff.content) != null && Sme.length && (x_.children = (Eme = Ff == null ? void 0 : Ff.content) == null ? void 0 : Eme.map((bme) => toMDNodeObj(bme, B_))), x_.type === "code" && (x_ != null && x_.children) && (x_ == null || delete x_.children), x_;
86450
86457
  }, toMarkdownJson = (Ff) => {
86451
86458
  var x_, B_;
86452
86459
  const kh = {};
@@ -86670,7 +86677,7 @@ const upload = async (Ff) => {
86670
86677
  if (!eme || !nme)
86671
86678
  return;
86672
86679
  const cme = tippy(eme, {
86673
- placement: "bottom-start",
86680
+ placement: "right",
86674
86681
  content: nme,
86675
86682
  interactive: !0,
86676
86683
  duration: [300, 300],
@@ -140154,17 +140161,18 @@ let Editor = (Ff, kh) => {
140154
140161
  };
140155
140162
  }, []), useEffect(() => {
140156
140163
  const Dme = (Bme) => {
140157
- var $me, Ume, Vme;
140164
+ var $me, Ume, Vme, Gme;
140158
140165
  if ((($me = Bme == null ? void 0 : Bme.data) == null ? void 0 : $me.type) === "sectionChange") {
140159
- const Gme = (Vme = (Ume = Bme == null ? void 0 : Bme.data) == null ? void 0 : Ume.value) == null ? void 0 : Vme.template;
140160
- Ime(Gme);
140166
+ const zme = (Vme = (Ume = Bme == null ? void 0 : Bme.data) == null ? void 0 : Ume.value) == null ? void 0 : Vme.template;
140167
+ zme && ((Gme = Object.keys(zme)) == null ? void 0 : Gme.length) === 0 ? Ime("") : Ime(zme);
140161
140168
  }
140162
140169
  };
140163
140170
  return window.addEventListener("message", Dme), () => {
140164
140171
  window.removeEventListener("message", Dme);
140165
140172
  };
140166
140173
  }, [fme]), useEffect(() => {
140167
- Ime(eme);
140174
+ var Dme;
140175
+ eme && ((Dme = Object.keys(eme)) == null ? void 0 : Dme.length) === 0 ? Ime("") : Ime(eme);
140168
140176
  }, [eme]);
140169
140177
  const Tme = (Dme) => {
140170
140178
  const Bme = Dme == null ? void 0 : Dme.target;