@fileverse-dev/ddoc 2.0.3-patch-9 → 2.0.3-patch-10

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.
Files changed (2) hide show
  1. package/dist/index.es.js +32 -20
  2. package/package.json +1 -1
package/dist/index.es.js CHANGED
@@ -98575,48 +98575,60 @@ const _y = ({
98575
98575
  return {
98576
98576
  "Mod-Alt-0": () => this.editor.commands.setDBlock(),
98577
98577
  Enter: ({ editor: t }) => {
98578
- var d, h, p;
98578
+ var g;
98579
98579
  const {
98580
98580
  selection: { $head: e, from: n, to: r },
98581
98581
  doc: i
98582
- } = t.state, a = e.node(e.depth - 1), s = e.toString().split("/"), l = s.some((m) => m.includes("table"));
98582
+ } = t.state, a = e.node(e.depth - 1), o = e.node(e.depth), l = e.toString().split("/"), c = n + 4, u = l.some((v) => v.includes("table")), f = (a == null ? void 0 : a.type.name) === "listItem" || (a == null ? void 0 : a.type.name) === "taskItem", d = (a == null ? void 0 : a.type.name) === "taskItem";
98583
98583
  if ((a == null ? void 0 : a.type.name) !== "dBlock") {
98584
- const m = s.some((w) => w.includes("taskList")), g = (a == null ? void 0 : a.type.name) === "listItem" || (a == null ? void 0 : a.type.name) === "taskItem";
98585
- return n !== r && g ? t.chain().deleteSelection().focus().run() : l ? !1 : ((d = a == null ? void 0 : a.lastChild) == null ? void 0 : d.textContent) === "" && ((h = a == null ? void 0 : a.lastChild) == null ? void 0 : h.type.name) === "paragraph" && g ? t.chain().deleteNode(m ? "taskItem" : "listItem").insertContentAt(n, {
98584
+ if (n !== r && f)
98585
+ return t.chain().deleteSelection().focus().run();
98586
+ if (u)
98587
+ return !1;
98588
+ const k = o.textContent === "" && o.type.name === "paragraph" && f, w = e.node(e.depth - 2), b = e.index(e.depth - 2) === w.childCount - 1, M = ["bulletList", "orderedList", "taskList"].includes(
98589
+ e.node(e.depth - 2).type.name
98590
+ ), S = b && M, L = !b && M, E = e.node(e.depth - 2).childCount > 1;
98591
+ return k && E ? S ? t.chain().deleteNode(d ? "taskItem" : "listItem").insertContentAt(n, {
98586
98592
  type: "dBlock",
98587
98593
  content: [
98588
98594
  {
98589
98595
  type: "paragraph"
98590
98596
  }
98591
98597
  ]
98592
- }).focus().run() : !1;
98598
+ }).focus().run() : L ? t.chain().deleteCurrentNode().insertContentAt(n, {
98599
+ type: d ? "taskItem" : "listItem",
98600
+ content: [
98601
+ {
98602
+ type: "paragraph"
98603
+ }
98604
+ ]
98605
+ }).focus(c).run() : t.chain().liftListItem(d ? "taskItem" : "listItem").focus().run() : !1;
98593
98606
  }
98594
- let c = -1, u = "";
98595
- i.descendants((m, g) => {
98596
- if (c !== -1) return !1;
98597
- if (m.type.name === this.name) return;
98598
- const [v, k] = [g, g + m.nodeSize];
98599
- return v <= n && r <= k && (c = k, u = m.type.name), !1;
98607
+ let h = -1, p = "";
98608
+ i.descendants((v, k) => {
98609
+ if (h !== -1) return !1;
98610
+ if (v.type.name === this.name) return;
98611
+ const [w, b] = [k, k + v.nodeSize];
98612
+ return w <= n && r <= b && (h = b, p = v.type.name), !1;
98600
98613
  });
98601
- const f = (p = i.slice(n, c)) == null ? void 0 : p.toJSON().content;
98614
+ const m = (g = i.slice(n, h)) == null ? void 0 : g.toJSON().content;
98602
98615
  try {
98603
- const m = n + 4;
98604
- return ["columns", "heading"].includes(u) ? t.chain().insertContent({
98616
+ return p === "codeBlock" ? t.chain().newlineInCode().focus().run() : ["columns", "heading"].includes(p) ? t.chain().insertContent({
98605
98617
  type: "dBlock",
98606
98618
  content: [
98607
98619
  {
98608
98620
  type: "paragraph"
98609
98621
  }
98610
98622
  ]
98611
- }).focus(m).run() : t.chain().insertContentAt(
98612
- { from: n, to: c },
98623
+ }).focus(c).run() : t.chain().insertContentAt(
98624
+ { from: n, to: h },
98613
98625
  {
98614
98626
  type: this.name,
98615
- content: f
98627
+ content: m
98616
98628
  }
98617
- ).focus(m).run();
98618
- } catch (m) {
98619
- return console.error(`Error inserting content into dBlock node: ${m}`), !1;
98629
+ ).focus(c).run();
98630
+ } catch (v) {
98631
+ return console.error(`Error inserting content into dBlock node: ${v}`), !1;
98620
98632
  }
98621
98633
  },
98622
98634
  Backspace: ({ editor: t }) => {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@fileverse-dev/ddoc",
3
3
  "private": false,
4
4
  "description": "DDoc",
5
- "version": "2.0.3-patch-9",
5
+ "version": "2.0.3-patch-10",
6
6
  "main": "dist/index.es.js",
7
7
  "module": "dist/index.es.js",
8
8
  "exports": {