@dooherceg/tiptap-controlled-editor-with-table 0.0.3 → 0.0.4

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.
@@ -3,6 +3,7 @@ interface SimpleEditorProps extends Omit<Partial<EditorOptions>, "content"> {
3
3
  themeMode: "dark" | "light";
4
4
  content?: string;
5
5
  onContentChange?: (content: string) => void;
6
+ placeholder?: string;
6
7
  }
7
- export declare function SimpleEditor({ themeMode, content, onContentChange, }: SimpleEditorProps): import("react/jsx-runtime").JSX.Element | null;
8
+ export declare function SimpleEditor({ themeMode, content, onContentChange, placeholder, }: SimpleEditorProps): import("react/jsx-runtime").JSX.Element | null;
8
9
  export {};
@@ -171,14 +171,14 @@ import '../../../assets/simple-editor.css';var Me = /(?:^|\s)(==(?!\s+==)((?:[^=
171
171
  const { directions: t, minWidth: e, minHeight: r, alwaysPreserveAspectRatio: n } = this.options.resize;
172
172
  return ({ node: s, getPos: i, HTMLAttributes: a }) => {
173
173
  const o = document.createElement("img");
174
- Object.entries(a).forEach(([d, u]) => {
175
- if (u != null)
176
- switch (d) {
174
+ Object.entries(a).forEach(([u, d]) => {
175
+ if (d != null)
176
+ switch (u) {
177
177
  case "width":
178
178
  case "height":
179
179
  break;
180
180
  default:
181
- o.setAttribute(d, u);
181
+ o.setAttribute(u, d);
182
182
  break;
183
183
  }
184
184
  }), o.src = a.src;
@@ -186,17 +186,17 @@ import '../../../assets/simple-editor.css';var Me = /(?:^|\s)(==(?!\s+==)((?:[^=
186
186
  element: o,
187
187
  node: s,
188
188
  getPos: i,
189
- onResize: (d, u) => {
190
- o.style.width = `${d}px`, o.style.height = `${u}px`;
189
+ onResize: (u, d) => {
190
+ o.style.width = `${u}px`, o.style.height = `${d}px`;
191
191
  },
192
- onCommit: (d, u) => {
192
+ onCommit: (u, d) => {
193
193
  const h = i();
194
194
  h !== void 0 && this.editor.chain().setNodeSelection(h).updateAttributes(this.name, {
195
- width: d,
196
- height: u
195
+ width: u,
196
+ height: d
197
197
  }).run();
198
198
  },
199
- onUpdate: (d, u, h) => d.type === s.type,
199
+ onUpdate: (u, d, h) => u.type === s.type,
200
200
  options: {
201
201
  directions: t,
202
202
  min: {
@@ -405,11 +405,11 @@ var $ = (t, e) => {
405
405
  c.node().descendants((h, b) => {
406
406
  h.type.name === e && l.push({ node: h, pos: b });
407
407
  });
408
- const d = l.at(-1);
409
- if (!d)
408
+ const u = l.at(-1);
409
+ if (!u)
410
410
  return !1;
411
- const u = t.state.doc.resolve(c.start() + d.pos + 1);
412
- return t.chain().cut({ from: o.start() - 1, to: o.end() + 1 }, u.end()).joinForward().run();
411
+ const d = t.state.doc.resolve(c.start() + u.pos + 1);
412
+ return t.chain().cut({ from: o.start() - 1, to: o.end() + 1 }, d.end()).joinForward().run();
413
413
  }
414
414
  if (!_(t.state, e) || !St(t.state))
415
415
  return !1;
@@ -486,28 +486,28 @@ function _e(t) {
486
486
  if (!i)
487
487
  break;
488
488
  const [, a, o, c] = i, l = a.length;
489
- let d = c, u = r + 1;
489
+ let u = c, d = r + 1;
490
490
  const h = [s];
491
- for (; u < t.length; ) {
492
- const b = t[u];
491
+ for (; d < t.length; ) {
492
+ const b = t[d];
493
493
  if (b.match(et))
494
494
  break;
495
495
  if (b.trim() === "")
496
- h.push(b), d += `
497
- `, u += 1;
496
+ h.push(b), u += `
497
+ `, d += 1;
498
498
  else if (b.match(De))
499
- h.push(b), d += `
500
- ${b.slice(l + 2)}`, u += 1;
499
+ h.push(b), u += `
500
+ ${b.slice(l + 2)}`, d += 1;
501
501
  else
502
502
  break;
503
503
  }
504
504
  e.push({
505
505
  indent: l,
506
506
  number: parseInt(o, 10),
507
- content: d.trim(),
507
+ content: u.trim(),
508
508
  raw: h.join(`
509
509
  `)
510
- }), n = u, r = u;
510
+ }), n = d, r = d;
511
511
  }
512
512
  return [e, n];
513
513
  }
@@ -525,16 +525,16 @@ function yt(t, e, r) {
525
525
  raw: c,
526
526
  tokens: r.inlineTokens(c)
527
527
  });
528
- const d = o.slice(1).join(`
528
+ const u = o.slice(1).join(`
529
529
  `).trim();
530
- if (d) {
531
- const b = r.blockTokens(d);
530
+ if (u) {
531
+ const b = r.blockTokens(u);
532
532
  l.push(...b);
533
533
  }
534
- let u = i + 1;
534
+ let d = i + 1;
535
535
  const h = [];
536
- for (; u < t.length && t[u].indent > e; )
537
- h.push(t[u]), u += 1;
536
+ for (; d < t.length && t[d].indent > e; )
537
+ h.push(t[d]), d += 1;
538
538
  if (h.length > 0) {
539
539
  const b = Math.min(...h.map((g) => g.indent)), f = yt(h, b, r);
540
540
  l.push({
@@ -550,7 +550,7 @@ function yt(t, e, r) {
550
550
  type: "list_item",
551
551
  raw: a.raw,
552
552
  tokens: l
553
- }), i = u;
553
+ }), i = d;
554
554
  } else
555
555
  i += 1;
556
556
  }
@@ -769,16 +769,16 @@ var We = "listItem", rt = "textStyle", nt = /^(\d+)\.\s$/, je = L.create({
769
769
  },
770
770
  addNodeView() {
771
771
  return ({ node: t, HTMLAttributes: e, getPos: r, editor: n }) => {
772
- const s = document.createElement("li"), i = document.createElement("label"), a = document.createElement("span"), o = document.createElement("input"), c = document.createElement("div"), l = (d) => {
773
- var u, h;
774
- o.ariaLabel = ((h = (u = this.options.a11y) == null ? void 0 : u.checkboxLabel) == null ? void 0 : h.call(u, d, o.checked)) || `Task item checkbox for ${d.textContent || "empty task item"}`;
772
+ const s = document.createElement("li"), i = document.createElement("label"), a = document.createElement("span"), o = document.createElement("input"), c = document.createElement("div"), l = (u) => {
773
+ var d, h;
774
+ o.ariaLabel = ((h = (d = this.options.a11y) == null ? void 0 : d.checkboxLabel) == null ? void 0 : h.call(d, u, o.checked)) || `Task item checkbox for ${u.textContent || "empty task item"}`;
775
775
  };
776
- return l(t), i.contentEditable = "false", o.type = "checkbox", o.addEventListener("mousedown", (d) => d.preventDefault()), o.addEventListener("change", (d) => {
776
+ return l(t), i.contentEditable = "false", o.type = "checkbox", o.addEventListener("mousedown", (u) => u.preventDefault()), o.addEventListener("change", (u) => {
777
777
  if (!n.isEditable && !this.options.onReadOnlyChecked) {
778
778
  o.checked = !o.checked;
779
779
  return;
780
780
  }
781
- const { checked: u } = d.target;
781
+ const { checked: d } = u.target;
782
782
  n.isEditable && typeof r == "function" && n.chain().focus(void 0, { scrollIntoView: !1 }).command(({ tr: h }) => {
783
783
  const b = r();
784
784
  if (typeof b != "number")
@@ -786,17 +786,17 @@ var We = "listItem", rt = "textStyle", nt = /^(\d+)\.\s$/, je = L.create({
786
786
  const f = h.doc.nodeAt(b);
787
787
  return h.setNodeMarkup(b, void 0, {
788
788
  ...f?.attrs,
789
- checked: u
789
+ checked: d
790
790
  }), !0;
791
- }).run(), !n.isEditable && this.options.onReadOnlyChecked && (this.options.onReadOnlyChecked(t, u) || (o.checked = !o.checked));
792
- }), Object.entries(this.options.HTMLAttributes).forEach(([d, u]) => {
793
- s.setAttribute(d, u);
794
- }), s.dataset.checked = t.attrs.checked, o.checked = t.attrs.checked, i.append(o, a), s.append(i, c), Object.entries(e).forEach(([d, u]) => {
795
- s.setAttribute(d, u);
791
+ }).run(), !n.isEditable && this.options.onReadOnlyChecked && (this.options.onReadOnlyChecked(t, d) || (o.checked = !o.checked));
792
+ }), Object.entries(this.options.HTMLAttributes).forEach(([u, d]) => {
793
+ s.setAttribute(u, d);
794
+ }), s.dataset.checked = t.attrs.checked, o.checked = t.attrs.checked, i.append(o, a), s.append(i, c), Object.entries(e).forEach(([u, d]) => {
795
+ s.setAttribute(u, d);
796
796
  }), {
797
797
  dom: s,
798
798
  contentDOM: c,
799
- update: (d) => d.type !== this.type ? !1 : (s.dataset.checked = d.attrs.checked, o.checked = d.attrs.checked, l(d), !0)
799
+ update: (u) => u.type !== this.type ? !1 : (s.dataset.checked = u.attrs.checked, o.checked = u.attrs.checked, l(u), !0)
800
800
  };
801
801
  };
802
802
  },
@@ -1203,8 +1203,8 @@ C.create({
1203
1203
  return !0;
1204
1204
  if (s > n && i > n && i > s || !e.getMeta("paste"))
1205
1205
  return !1;
1206
- const o = e.selection.$head.pos, c = i - n, l = o - c, d = o;
1207
- return e.deleteRange(l, d), !(this.storage.characters({ node: e.doc }) > n);
1206
+ const o = e.selection.$head.pos, c = i - n, l = o - c, u = o;
1207
+ return e.deleteRange(l, u), !(this.storage.characters({ node: e.doc }) > n);
1208
1208
  }
1209
1209
  })
1210
1210
  ];
@@ -1283,7 +1283,7 @@ C.create({
1283
1283
  };
1284
1284
  }
1285
1285
  });
1286
- C.create({
1286
+ var gr = C.create({
1287
1287
  name: "placeholder",
1288
1288
  addOptions() {
1289
1289
  return {
@@ -1308,10 +1308,10 @@ C.create({
1308
1308
  return t.descendants((a, o) => {
1309
1309
  const c = n >= o && n <= o + a.nodeSize, l = !a.isLeaf && $t(a);
1310
1310
  if ((c || !this.options.showOnlyCurrent) && l) {
1311
- const d = [this.options.emptyNodeClass];
1312
- i && d.push(this.options.emptyEditorClass);
1313
- const u = K.node(o, o + a.nodeSize, {
1314
- class: d.join(" "),
1311
+ const u = [this.options.emptyNodeClass];
1312
+ i && u.push(this.options.emptyEditorClass);
1313
+ const d = K.node(o, o + a.nodeSize, {
1314
+ class: u.join(" "),
1315
1315
  "data-placeholder": typeof this.options.placeholder == "function" ? this.options.placeholder({
1316
1316
  editor: this.editor,
1317
1317
  node: a,
@@ -1319,7 +1319,7 @@ C.create({
1319
1319
  hasAnchor: c
1320
1320
  }) : this.options.placeholder
1321
1321
  });
1322
- s.push(u);
1322
+ s.push(d);
1323
1323
  }
1324
1324
  return this.options.includeChildren;
1325
1325
  }), B.create(t, s);
@@ -1328,8 +1328,7 @@ C.create({
1328
1328
  })
1329
1329
  ];
1330
1330
  }
1331
- });
1332
- var gr = C.create({
1331
+ }), br = C.create({
1333
1332
  name: "selection",
1334
1333
  addOptions() {
1335
1334
  return {
@@ -1372,9 +1371,9 @@ C.create({
1372
1371
  new H({
1373
1372
  key: e,
1374
1373
  appendTransaction: (s, i, a) => {
1375
- const { doc: o, tr: c, schema: l } = a, d = e.getState(a), u = o.content.size, h = l.nodes[r];
1376
- if (d)
1377
- return c.insert(u, h.create());
1374
+ const { doc: o, tr: c, schema: l } = a, u = e.getState(a), d = o.content.size, h = l.nodes[r];
1375
+ if (u)
1376
+ return c.insert(d, h.create());
1378
1377
  },
1379
1378
  state: {
1380
1379
  init: (s, i) => {
@@ -1420,7 +1419,7 @@ C.create({
1420
1419
  };
1421
1420
  }
1422
1421
  });
1423
- var br = L.create({
1422
+ var yr = L.create({
1424
1423
  name: "tableCell",
1425
1424
  addOptions() {
1426
1425
  return {
@@ -1461,7 +1460,7 @@ var br = L.create({
1461
1460
  renderHTML({ HTMLAttributes: t }) {
1462
1461
  return ["td", k(this.options.HTMLAttributes, t), 0];
1463
1462
  }
1464
- }), yr = L.create({
1463
+ }), kr = L.create({
1465
1464
  name: "tableHeader",
1466
1465
  addOptions() {
1467
1466
  return {
@@ -1494,7 +1493,7 @@ var br = L.create({
1494
1493
  renderHTML({ HTMLAttributes: t }) {
1495
1494
  return ["th", k(this.options.HTMLAttributes, t), 0];
1496
1495
  }
1497
- }), kr = L.create({
1496
+ }), Tr = L.create({
1498
1497
  name: "tableRow",
1499
1498
  addOptions() {
1500
1499
  return {
@@ -1516,10 +1515,10 @@ function j(t, e) {
1516
1515
  function it(t, e, r, n, s, i) {
1517
1516
  var a;
1518
1517
  let o = 0, c = !0, l = e.firstChild;
1519
- const d = t.firstChild;
1520
- if (d !== null)
1521
- for (let h = 0, b = 0; h < d.childCount; h += 1) {
1522
- const { colspan: f, colwidth: g } = d.child(h).attrs;
1518
+ const u = t.firstChild;
1519
+ if (u !== null)
1520
+ for (let h = 0, b = 0; h < u.childCount; h += 1) {
1521
+ const { colspan: f, colwidth: g } = u.child(h).attrs;
1523
1522
  for (let m = 0; m < f; m += 1, b += 1) {
1524
1523
  const T = s === b ? i : g && g[m], v = T ? `${T}px` : "";
1525
1524
  if (o += T || n, T || (c = !1), l) {
@@ -1538,10 +1537,10 @@ function it(t, e, r, n, s, i) {
1538
1537
  const h = l.nextSibling;
1539
1538
  (a = l.parentNode) == null || a.removeChild(l), l = h;
1540
1539
  }
1541
- const u = t.attrs.style && typeof t.attrs.style == "string" && /\bwidth\s*:/i.test(t.attrs.style);
1542
- c && !u ? (r.style.width = `${o}px`, r.style.minWidth = "") : (r.style.width = "", r.style.minWidth = `${o}px`);
1540
+ const d = t.attrs.style && typeof t.attrs.style == "string" && /\bwidth\s*:/i.test(t.attrs.style);
1541
+ c && !d ? (r.style.width = `${o}px`, r.style.minWidth = "") : (r.style.width = "", r.style.minWidth = `${o}px`);
1543
1542
  }
1544
- var Tr = class {
1543
+ var Cr = class {
1545
1544
  constructor(t, e) {
1546
1545
  this.node = t, this.cellMinWidth = e, this.dom = document.createElement("div"), this.dom.className = "tableWrapper", this.table = this.dom.appendChild(document.createElement("table")), t.attrs.style && (this.table.style.cssText = t.attrs.style), this.colgroup = this.table.appendChild(document.createElement("colgroup")), it(t, this.colgroup, this.table, e), this.contentDOM = this.table.appendChild(document.createElement("tbody"));
1547
1546
  }
@@ -1553,13 +1552,13 @@ var Tr = class {
1553
1552
  return !!(r && !n && (t.type === "attributes" || t.type === "childList" || t.type === "characterData"));
1554
1553
  }
1555
1554
  };
1556
- function Cr(t, e, r, n) {
1555
+ function Lr(t, e, r, n) {
1557
1556
  let s = 0, i = !0;
1558
1557
  const a = [], o = t.firstChild;
1559
1558
  if (!o)
1560
1559
  return {};
1561
- for (let u = 0, h = 0; u < o.childCount; u += 1) {
1562
- const { colspan: b, colwidth: f } = o.child(u).attrs;
1560
+ for (let d = 0, h = 0; d < o.childCount; d += 1) {
1561
+ const { colspan: b, colwidth: f } = o.child(d).attrs;
1563
1562
  for (let g = 0; g < b; g += 1, h += 1) {
1564
1563
  const m = r === h ? n : f && f[g];
1565
1564
  s += m || e, m || (i = !1);
@@ -1573,7 +1572,7 @@ function Cr(t, e, r, n) {
1573
1572
  function ot(t, e) {
1574
1573
  return t.createAndFill();
1575
1574
  }
1576
- function Lr(t) {
1575
+ function wr(t) {
1577
1576
  if (t.cached.tableNodeTypes)
1578
1577
  return t.cached.tableNodeTypes;
1579
1578
  const e = {};
@@ -1582,13 +1581,13 @@ function Lr(t) {
1582
1581
  n.spec.tableRole && (e[n.spec.tableRole] = n);
1583
1582
  }), t.cached.tableNodeTypes = e, e;
1584
1583
  }
1585
- function wr(t, e, r, n, s) {
1586
- const i = Lr(t), a = [], o = [];
1584
+ function vr(t, e, r, n, s) {
1585
+ const i = wr(t), a = [], o = [];
1587
1586
  for (let l = 0; l < r; l += 1) {
1588
- const d = ot(i.cell);
1589
- if (d && o.push(d), n) {
1590
- const u = ot(i.header_cell);
1591
- u && a.push(u);
1587
+ const u = ot(i.cell);
1588
+ if (u && o.push(u), n) {
1589
+ const d = ot(i.header_cell);
1590
+ d && a.push(d);
1592
1591
  }
1593
1592
  }
1594
1593
  const c = [];
@@ -1596,12 +1595,12 @@ function wr(t, e, r, n, s) {
1596
1595
  c.push(i.row.createChecked(null, n && l === 0 ? a : o));
1597
1596
  return i.table.createChecked(null, c);
1598
1597
  }
1599
- function vr(t) {
1598
+ function Mr(t) {
1600
1599
  return t instanceof pt;
1601
1600
  }
1602
1601
  var P = ({ editor: t }) => {
1603
1602
  const { selection: e } = t.state;
1604
- if (!vr(e))
1603
+ if (!Mr(e))
1605
1604
  return !1;
1606
1605
  let r = 0;
1607
1606
  const n = Rt(e.ranges[0].$from, (i) => i.type.name === "table");
@@ -1610,13 +1609,13 @@ var P = ({ editor: t }) => {
1610
1609
  return !1;
1611
1610
  ["tableCell", "tableHeader"].includes(i.type.name) && (r += 1);
1612
1611
  }), r === e.ranges.length ? (t.commands.deleteTable(), !0) : !1;
1613
- }, Mr = "";
1614
- function xr(t) {
1612
+ }, xr = "";
1613
+ function Ar(t) {
1615
1614
  return (t || "").replace(/\s+/g, " ").trim();
1616
1615
  }
1617
- function Ar(t, e, r = {}) {
1616
+ function Ir(t, e, r = {}) {
1618
1617
  var n;
1619
- const s = (n = r.cellLineSeparator) != null ? n : Mr;
1618
+ const s = (n = r.cellLineSeparator) != null ? n : xr;
1620
1619
  if (!t || !t.content || t.content.length === 0)
1621
1620
  return "";
1622
1621
  const i = [];
@@ -1625,7 +1624,7 @@ function Ar(t, e, r = {}) {
1625
1624
  f.content && f.content.forEach((m) => {
1626
1625
  let T = "";
1627
1626
  m.content && Array.isArray(m.content) && m.content.length > 1 ? T = m.content.map((O) => e.renderChildren(O)).join(s) : T = m.content ? e.renderChildren(m.content) : "";
1628
- const v = xr(T), I = m.type === "tableHeader";
1627
+ const v = Ar(T), I = m.type === "tableHeader";
1629
1628
  g.push({ text: v, isHeader: I });
1630
1629
  }), i.push(g);
1631
1630
  });
@@ -1640,18 +1639,18 @@ function Ar(t, e, r = {}) {
1640
1639
  v > o[m] && (o[m] = v), o[m] < 3 && (o[m] = 3);
1641
1640
  }
1642
1641
  });
1643
- const c = (f, g) => f + " ".repeat(Math.max(0, g - f.length)), l = i[0], d = l.some((f) => f.isHeader);
1644
- let u = `
1642
+ const c = (f, g) => f + " ".repeat(Math.max(0, g - f.length)), l = i[0], u = l.some((f) => f.isHeader);
1643
+ let d = `
1645
1644
  `;
1646
- const h = new Array(a).fill(0).map((f, g) => d && l[g] && l[g].text || "");
1647
- return u += `| ${h.map((f, g) => c(f, o[g])).join(" | ")} |
1648
- `, u += `| ${o.map((f) => "-".repeat(Math.max(3, f))).join(" | ")} |
1649
- `, (d ? i.slice(1) : i).forEach((f) => {
1650
- u += `| ${new Array(a).fill(0).map((g, m) => c(f[m] && f[m].text || "", o[m])).join(" | ")} |
1645
+ const h = new Array(a).fill(0).map((f, g) => u && l[g] && l[g].text || "");
1646
+ return d += `| ${h.map((f, g) => c(f, o[g])).join(" | ")} |
1647
+ `, d += `| ${o.map((f) => "-".repeat(Math.max(3, f))).join(" | ")} |
1648
+ `, (u ? i.slice(1) : i).forEach((f) => {
1649
+ d += `| ${new Array(a).fill(0).map((g, m) => c(f[m] && f[m].text || "", o[m])).join(" | ")} |
1651
1650
  `;
1652
- }), u;
1651
+ }), d;
1653
1652
  }
1654
- var Ir = Ar, Sr = L.create({
1653
+ var Sr = Ir, Hr = L.create({
1655
1654
  name: "table",
1656
1655
  // @ts-ignore
1657
1656
  addOptions() {
@@ -1662,7 +1661,7 @@ var Ir = Ar, Sr = L.create({
1662
1661
  handleWidth: 5,
1663
1662
  cellMinWidth: 25,
1664
1663
  // TODO: fix
1665
- View: Tr,
1664
+ View: Cr,
1666
1665
  lastColumnResizable: !0,
1667
1666
  allowTableNodeSelection: !1
1668
1667
  };
@@ -1675,7 +1674,7 @@ var Ir = Ar, Sr = L.create({
1675
1674
  return [{ tag: "table" }];
1676
1675
  },
1677
1676
  renderHTML({ node: t, HTMLAttributes: e }) {
1678
- const { colgroup: r, tableWidth: n, tableMinWidth: s } = Cr(t, this.options.cellMinWidth), i = e.style;
1677
+ const { colgroup: r, tableWidth: n, tableMinWidth: s } = Lr(t, this.options.cellMinWidth), i = e.style;
1679
1678
  function a() {
1680
1679
  return i || (n ? `width: ${n}` : `min-width: ${s}`);
1681
1680
  }
@@ -1704,11 +1703,11 @@ var Ir = Ar, Sr = L.create({
1704
1703
  }), r.push(e.createNode("tableRow", {}, s));
1705
1704
  }), e.createNode("table", void 0, r);
1706
1705
  },
1707
- renderMarkdown: (t, e) => Ir(t, e),
1706
+ renderMarkdown: (t, e) => Sr(t, e),
1708
1707
  addCommands() {
1709
1708
  return {
1710
1709
  insertTable: ({ rows: t = 3, cols: e = 3, withHeaderRow: r = !0 } = {}) => ({ tr: n, dispatch: s, editor: i }) => {
1711
- const a = wr(i.schema, t, e, r);
1710
+ const a = vr(i.schema, t, e, r);
1712
1711
  if (s) {
1713
1712
  const o = n.selection.from + 1;
1714
1713
  n.replaceSelectionWith(a).scrollIntoView().setSelection(Pt.near(n.doc.resolve(o)));
@@ -1777,14 +1776,14 @@ var Ir = Ar, Sr = L.create({
1777
1776
  tableRole: dt(ct(t, "tableRole", e))
1778
1777
  };
1779
1778
  }
1780
- }), Hr = C.create({
1779
+ }), Er = C.create({
1781
1780
  name: "tableKit",
1782
1781
  addExtensions() {
1783
1782
  const t = [];
1784
- return this.options.table !== !1 && t.push(Sr.configure(this.options.table)), this.options.tableCell !== !1 && t.push(br.configure(this.options.tableCell)), this.options.tableHeader !== !1 && t.push(yr.configure(this.options.tableHeader)), this.options.tableRow !== !1 && t.push(kr.configure(this.options.tableRow)), t;
1783
+ return this.options.table !== !1 && t.push(Hr.configure(this.options.table)), this.options.tableCell !== !1 && t.push(yr.configure(this.options.tableCell)), this.options.tableHeader !== !1 && t.push(kr.configure(this.options.tableHeader)), this.options.tableRow !== !1 && t.push(Tr.configure(this.options.tableRow)), t;
1785
1784
  }
1786
1785
  });
1787
- const Er = ({
1786
+ const $r = ({
1788
1787
  onHighlighterClick: t,
1789
1788
  onLinkClick: e,
1790
1789
  isMobile: r
@@ -1836,7 +1835,7 @@ const Er = ({
1836
1835
  } }) }),
1837
1836
  r && /* @__PURE__ */ p(A, {})
1838
1837
  ] });
1839
- }, $r = ({
1838
+ }, Nr = ({
1840
1839
  type: t,
1841
1840
  onBack: e
1842
1841
  }) => /* @__PURE__ */ w(at, { children: [
@@ -1847,14 +1846,15 @@ const Er = ({
1847
1846
  /* @__PURE__ */ p(A, {}),
1848
1847
  t === "highlighter" ? /* @__PURE__ */ p(Te, {}) : /* @__PURE__ */ p(we, {})
1849
1848
  ] });
1850
- function fn({
1849
+ function mn({
1851
1850
  themeMode: t,
1852
1851
  content: e,
1853
- onContentChange: r
1852
+ onContentChange: r,
1853
+ placeholder: n = ""
1854
1854
  }) {
1855
- const n = Ut(), { height: s } = Gt(), [i, a] = vt(
1855
+ const s = Ut(), { height: i } = Gt(), [a, o] = vt(
1856
1856
  "main"
1857
- ), o = q(null), c = q(!1), l = Ct({
1857
+ ), c = q(null), l = q(!1), u = Ct({
1858
1858
  immediatelyRender: !1,
1859
1859
  shouldRerenderOnTransaction: !1,
1860
1860
  editorProps: {
@@ -1883,59 +1883,62 @@ function fn({
1883
1883
  mr,
1884
1884
  Ve,
1885
1885
  Ke,
1886
- gr,
1886
+ br,
1887
1887
  Qt.configure({
1888
1888
  accept: "image/*",
1889
1889
  maxSize: Yt,
1890
1890
  limit: 3,
1891
1891
  upload: Xt,
1892
- onError: (u) => console.error("Upload failed:", u)
1892
+ onError: (h) => console.error("Upload failed:", h)
1893
1893
  }),
1894
- Hr.configure({
1894
+ Er.configure({
1895
1895
  table: {
1896
1896
  resizable: !0
1897
1897
  }
1898
+ }),
1899
+ gr.configure({
1900
+ placeholder: n
1898
1901
  })
1899
1902
  ],
1900
1903
  content: e,
1901
- onUpdate: ({ editor: u }) => {
1902
- if (!c.current && r) {
1903
- const h = u.getHTML();
1904
- r(h);
1904
+ onUpdate: ({ editor: h }) => {
1905
+ if (!l.current && r) {
1906
+ const b = h.getHTML();
1907
+ r(b);
1905
1908
  }
1906
1909
  }
1907
1910
  }), d = Ft({
1908
- editor: l,
1909
- overlayHeight: o.current?.getBoundingClientRect().height ?? 0
1911
+ editor: u,
1912
+ overlayHeight: c.current?.getBoundingClientRect().height ?? 0
1910
1913
  });
1911
1914
  return D(() => {
1912
- !n && i !== "main" && a("main");
1913
- }, [n, i]), D(() => {
1914
- l && e !== void 0 && l.getHTML() !== e && (c.current = !0, l.commands.setContent(e, { emitUpdate: !1 }), c.current = !1);
1915
- }, [e, l]), D(() => {
1915
+ !s && a !== "main" && o("main");
1916
+ }, [s, a]), D(() => {
1917
+ u && e !== void 0 && u.getHTML() !== e && (l.current = !0, u.commands.setContent(e, { emitUpdate: !1 }), l.current = !1);
1918
+ }, [e, u]), D(() => {
1916
1919
  document.documentElement.classList.toggle("dark", t === "dark");
1917
- }, [t]), l ? /* @__PURE__ */ p("div", { className: "simple-editor-wrapper", children: /* @__PURE__ */ w(Lt.Provider, { value: { editor: l }, children: [
1920
+ }, [t]), u ? /* @__PURE__ */ p("div", { className: "simple-editor-wrapper", children: /* @__PURE__ */ w(Lt.Provider, { value: { editor: u }, children: [
1918
1921
  /* @__PURE__ */ p(
1919
1922
  he,
1920
1923
  {
1921
- ref: o,
1924
+ ref: c,
1922
1925
  style: {
1923
- ...n ? {
1924
- bottom: `calc(100% - ${s - d.y}px)`
1926
+ ...s ? {
1927
+ bottom: `calc(100% - ${i - d.y}px)`
1925
1928
  } : {}
1926
1929
  },
1927
- children: i === "main" ? /* @__PURE__ */ p(
1928
- Er,
1930
+ children: a === "main" ? /* @__PURE__ */ p(
1931
+ $r,
1929
1932
  {
1930
- onHighlighterClick: () => a("highlighter"),
1931
- onLinkClick: () => a("link"),
1932
- isMobile: n
1933
+ onHighlighterClick: () => o("highlighter"),
1934
+ onLinkClick: () => o("link"),
1935
+ isMobile: s
1933
1936
  }
1934
1937
  ) : /* @__PURE__ */ p(
1935
- $r,
1938
+ Nr,
1936
1939
  {
1937
- type: i === "highlighter" ? "highlighter" : "link",
1938
- onBack: () => a("main")
1940
+ type: a === "highlighter" ? "highlighter" : "link",
1941
+ onBack: () => o("main")
1939
1942
  }
1940
1943
  )
1941
1944
  }
@@ -1944,7 +1947,7 @@ function fn({
1944
1947
  /* @__PURE__ */ p(
1945
1948
  wt,
1946
1949
  {
1947
- editor: l,
1950
+ editor: u,
1948
1951
  role: "presentation",
1949
1952
  className: "simple-editor-content"
1950
1953
  }
@@ -1952,5 +1955,5 @@ function fn({
1952
1955
  ] }) }) : null;
1953
1956
  }
1954
1957
  export {
1955
- fn as SimpleEditor
1958
+ mn as SimpleEditor
1956
1959
  };
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@dooherceg/tiptap-controlled-editor-with-table",
3
3
  "private": false,
4
4
  "baseUrl": "./",
5
- "version": "0.0.3",
5
+ "version": "0.0.4",
6
6
  "type": "module",
7
7
  "main": "dist/main.js",
8
8
  "types": "dist/main.d.ts",