@dooherceg/tiptap-controlled-editor-with-table 0.0.11 → 0.0.12

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.
@@ -10,4 +10,4 @@ export interface SimpleEditorProps extends Omit<Partial<EditorOptions>, "content
10
10
  export interface SimpleEditorRef {
11
11
  getEditor: () => Editor | null;
12
12
  }
13
- export declare function SimpleEditor({ themeMode, content, onContentChange, placeholder, ref, }: SimpleEditorProps): import("react/jsx-runtime").JSX.Element | null;
13
+ export declare function SimpleEditor({ themeMode, content, onContentChange, placeholder, ref, autofocus, onFocus, onBlur, }: SimpleEditorProps): import("react/jsx-runtime").JSX.Element | null;
@@ -1,7 +1,7 @@
1
1
  import { jsx as p, jsxs as w, Fragment as at } from "react/jsx-runtime";
2
2
  import { useEditor as Ct, EditorContext as Lt, EditorContent as wt } from "@tiptap/react";
3
3
  import { useState as vt, useRef as q, useEffect as D, useImperativeHandle as Mt } from "react";
4
- import { Mark as Q, markPasteRule as xt, markInputRule as At, mergeAttributes as k, Node as L, nodeInputRule as It, ResizableNodeView as St, wrappingInputRule as S, renderNestedMarkdownContent as lt, Extension as C, parseIndentedBlocks as F, isNodeActive as _, isAtStartOfNode as Ht, isAtEndOfNode as Et, getNodeType as ut, getNodeAtPosition as $t, textInputRule as y, callOrReturn as dt, getExtensionField as ct, isNodeEmpty as Nt, isNodeSelection as Rt, findParentNodeClosestToPos as Pt } from "@tiptap/core";
4
+ import { Mark as Q, markPasteRule as xt, markInputRule as At, mergeAttributes as T, Node as L, nodeInputRule as It, ResizableNodeView as St, wrappingInputRule as S, renderNestedMarkdownContent as lt, Extension as C, parseIndentedBlocks as F, isNodeActive as _, isAtStartOfNode as Ht, isAtEndOfNode as Et, getNodeType as ut, getNodeAtPosition as $t, textInputRule as y, callOrReturn as dt, getExtensionField as ct, isNodeEmpty as Nt, isNodeSelection as Rt, findParentNodeClosestToPos as Pt } from "@tiptap/core";
5
5
  import { Plugin as H, PluginKey as E, TextSelection as Bt } from "prosemirror-state";
6
6
  import { dropCursor as Ot } from "prosemirror-dropcursor";
7
7
  import { DecorationSet as B, Decoration as K } from "prosemirror-view";
@@ -83,7 +83,7 @@ import '../../../assets/simple-editor.css';var xe = /(?:^|\s)(==(?!\s+==)((?:[^=
83
83
  ];
84
84
  },
85
85
  renderHTML({ HTMLAttributes: t }) {
86
- return ["mark", k(this.options.HTMLAttributes, t), 0];
86
+ return ["mark", T(this.options.HTMLAttributes, t), 0];
87
87
  },
88
88
  renderMarkdown: (t, e) => `==${e.renderChildren(t)}==`,
89
89
  parseMarkdown: (t, e) => e.applyMark("highlight", e.parseInline(t.tokens || [])),
@@ -176,7 +176,7 @@ import '../../../assets/simple-editor.css';var xe = /(?:^|\s)(==(?!\s+==)((?:[^=
176
176
  ];
177
177
  },
178
178
  renderHTML({ HTMLAttributes: t }) {
179
- return ["img", k(this.options.HTMLAttributes, t)];
179
+ return ["img", T(this.options.HTMLAttributes, t)];
180
180
  },
181
181
  parseMarkdown: (t, e) => e.createNode("image", {
182
182
  src: t.href,
@@ -194,14 +194,14 @@ import '../../../assets/simple-editor.css';var xe = /(?:^|\s)(==(?!\s+==)((?:[^=
194
194
  const { directions: t, minWidth: e, minHeight: r, alwaysPreserveAspectRatio: n } = this.options.resize;
195
195
  return ({ node: s, getPos: i, HTMLAttributes: a }) => {
196
196
  const o = document.createElement("img");
197
- Object.entries(a).forEach(([d, u]) => {
198
- if (u != null)
199
- switch (d) {
197
+ Object.entries(a).forEach(([u, d]) => {
198
+ if (d != null)
199
+ switch (u) {
200
200
  case "width":
201
201
  case "height":
202
202
  break;
203
203
  default:
204
- o.setAttribute(d, u);
204
+ o.setAttribute(u, d);
205
205
  break;
206
206
  }
207
207
  }), o.src = a.src;
@@ -209,17 +209,17 @@ import '../../../assets/simple-editor.css';var xe = /(?:^|\s)(==(?!\s+==)((?:[^=
209
209
  element: o,
210
210
  node: s,
211
211
  getPos: i,
212
- onResize: (d, u) => {
213
- o.style.width = `${d}px`, o.style.height = `${u}px`;
212
+ onResize: (u, d) => {
213
+ o.style.width = `${u}px`, o.style.height = `${d}px`;
214
214
  },
215
- onCommit: (d, u) => {
216
- const h = i();
217
- h !== void 0 && this.editor.chain().setNodeSelection(h).updateAttributes(this.name, {
218
- width: d,
219
- height: u
215
+ onCommit: (u, d) => {
216
+ const f = i();
217
+ f !== void 0 && this.editor.chain().setNodeSelection(f).updateAttributes(this.name, {
218
+ width: u,
219
+ height: d
220
220
  }).run();
221
221
  },
222
- onUpdate: (d, u, h) => d.type === s.type,
222
+ onUpdate: (u, d, f) => u.type === s.type,
223
223
  options: {
224
224
  directions: t,
225
225
  min: {
@@ -275,7 +275,7 @@ import '../../../assets/simple-editor.css';var xe = /(?:^|\s)(==(?!\s+==)((?:[^=
275
275
  return [{ tag: "ul" }];
276
276
  },
277
277
  renderHTML({ HTMLAttributes: t }) {
278
- return ["ul", k(this.options.HTMLAttributes, t), 0];
278
+ return ["ul", T(this.options.HTMLAttributes, t), 0];
279
279
  },
280
280
  markdownTokenName: "list",
281
281
  parseMarkdown: (t, e) => t.type !== "list" || t.ordered ? [] : {
@@ -330,7 +330,7 @@ import '../../../assets/simple-editor.css';var xe = /(?:^|\s)(==(?!\s+==)((?:[^=
330
330
  ];
331
331
  },
332
332
  renderHTML({ HTMLAttributes: t }) {
333
- return ["li", k(this.options.HTMLAttributes, t), 0];
333
+ return ["li", T(this.options.HTMLAttributes, t), 0];
334
334
  },
335
335
  markdownTokenName: "list_item",
336
336
  parseMarkdown: (t, e) => {
@@ -425,14 +425,14 @@ var $ = (t, e) => {
425
425
  return !1;
426
426
  if (!_(t.state, e) && ht(t.state, e, r)) {
427
427
  const { $anchor: o } = t.state.selection, c = t.state.doc.resolve(o.before() - 1), l = [];
428
- c.node().descendants((h, m) => {
429
- h.type.name === e && l.push({ node: h, pos: m });
428
+ c.node().descendants((f, b) => {
429
+ f.type.name === e && l.push({ node: f, pos: b });
430
430
  });
431
- const d = l.at(-1);
432
- if (!d)
431
+ const u = l.at(-1);
432
+ if (!u)
433
433
  return !1;
434
- const u = t.state.doc.resolve(c.start() + d.pos + 1);
435
- return t.chain().cut({ from: o.start() - 1, to: o.end() + 1 }, u.end()).joinForward().run();
434
+ const d = t.state.doc.resolve(c.start() + u.pos + 1);
435
+ return t.chain().cut({ from: o.start() - 1, to: o.end() + 1 }, d.end()).joinForward().run();
436
436
  }
437
437
  if (!_(t.state, e) || !Ht(t.state))
438
438
  return !1;
@@ -509,28 +509,28 @@ function ze(t) {
509
509
  if (!i)
510
510
  break;
511
511
  const [, a, o, c] = i, l = a.length;
512
- let d = c, u = r + 1;
513
- const h = [s];
514
- for (; u < t.length; ) {
515
- const m = t[u];
516
- if (m.match(et))
512
+ let u = c, d = r + 1;
513
+ const f = [s];
514
+ for (; d < t.length; ) {
515
+ const b = t[d];
516
+ if (b.match(et))
517
517
  break;
518
- if (m.trim() === "")
519
- h.push(m), d += `
520
- `, u += 1;
521
- else if (m.match(_e))
522
- h.push(m), d += `
523
- ${m.slice(l + 2)}`, u += 1;
518
+ if (b.trim() === "")
519
+ f.push(b), u += `
520
+ `, d += 1;
521
+ else if (b.match(_e))
522
+ f.push(b), u += `
523
+ ${b.slice(l + 2)}`, d += 1;
524
524
  else
525
525
  break;
526
526
  }
527
527
  e.push({
528
528
  indent: l,
529
529
  number: parseInt(o, 10),
530
- content: d.trim(),
531
- raw: h.join(`
530
+ content: u.trim(),
531
+ raw: f.join(`
532
532
  `)
533
- }), n = u, r = u;
533
+ }), n = d, r = d;
534
534
  }
535
535
  return [e, n];
536
536
  }
@@ -548,24 +548,24 @@ function yt(t, e, r) {
548
548
  raw: c,
549
549
  tokens: r.inlineTokens(c)
550
550
  });
551
- const d = o.slice(1).join(`
551
+ const u = o.slice(1).join(`
552
552
  `).trim();
553
- if (d) {
554
- const m = r.blockTokens(d);
555
- l.push(...m);
553
+ if (u) {
554
+ const b = r.blockTokens(u);
555
+ l.push(...b);
556
556
  }
557
- let u = i + 1;
558
- const h = [];
559
- for (; u < t.length && t[u].indent > e; )
560
- h.push(t[u]), u += 1;
561
- if (h.length > 0) {
562
- const m = Math.min(...h.map((b) => b.indent)), f = yt(h, m, r);
557
+ let d = i + 1;
558
+ const f = [];
559
+ for (; d < t.length && t[d].indent > e; )
560
+ f.push(t[d]), d += 1;
561
+ if (f.length > 0) {
562
+ const b = Math.min(...f.map((g) => g.indent)), h = yt(f, b, r);
563
563
  l.push({
564
564
  type: "list",
565
565
  ordered: !0,
566
- start: h[0].number,
567
- items: f,
568
- raw: h.map((b) => b.raw).join(`
566
+ start: f[0].number,
567
+ items: h,
568
+ raw: f.map((g) => g.raw).join(`
569
569
  `)
570
570
  });
571
571
  }
@@ -573,7 +573,7 @@ function yt(t, e, r) {
573
573
  type: "list_item",
574
574
  raw: a.raw,
575
575
  tokens: l
576
- }), i = u;
576
+ }), i = d;
577
577
  } else
578
578
  i += 1;
579
579
  }
@@ -638,7 +638,7 @@ var je = "listItem", rt = "textStyle", nt = /^(\d+)\.\s$/, Qe = L.create({
638
638
  },
639
639
  renderHTML({ HTMLAttributes: t }) {
640
640
  const { start: e, ...r } = t;
641
- return e === 1 ? ["ol", k(this.options.HTMLAttributes, r), 0] : ["ol", k(this.options.HTMLAttributes, t), 0];
641
+ return e === 1 ? ["ol", T(this.options.HTMLAttributes, r), 0] : ["ol", T(this.options.HTMLAttributes, t), 0];
642
642
  },
643
643
  markdownTokenName: "list",
644
644
  parseMarkdown: (t, e) => {
@@ -750,7 +750,7 @@ var je = "listItem", rt = "textStyle", nt = /^(\d+)\.\s$/, Qe = L.create({
750
750
  renderHTML({ node: t, HTMLAttributes: e }) {
751
751
  return [
752
752
  "li",
753
- k(this.options.HTMLAttributes, e, {
753
+ T(this.options.HTMLAttributes, e, {
754
754
  "data-type": this.name
755
755
  }),
756
756
  [
@@ -792,34 +792,34 @@ var je = "listItem", rt = "textStyle", nt = /^(\d+)\.\s$/, Qe = L.create({
792
792
  },
793
793
  addNodeView() {
794
794
  return ({ node: t, HTMLAttributes: e, getPos: r, editor: n }) => {
795
- const s = document.createElement("li"), i = document.createElement("label"), a = document.createElement("span"), o = document.createElement("input"), c = document.createElement("div"), l = (d) => {
796
- var u, h;
797
- 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"}`;
795
+ const s = document.createElement("li"), i = document.createElement("label"), a = document.createElement("span"), o = document.createElement("input"), c = document.createElement("div"), l = (u) => {
796
+ var d, f;
797
+ o.ariaLabel = ((f = (d = this.options.a11y) == null ? void 0 : d.checkboxLabel) == null ? void 0 : f.call(d, u, o.checked)) || `Task item checkbox for ${u.textContent || "empty task item"}`;
798
798
  };
799
- return l(t), i.contentEditable = "false", o.type = "checkbox", o.addEventListener("mousedown", (d) => d.preventDefault()), o.addEventListener("change", (d) => {
799
+ return l(t), i.contentEditable = "false", o.type = "checkbox", o.addEventListener("mousedown", (u) => u.preventDefault()), o.addEventListener("change", (u) => {
800
800
  if (!n.isEditable && !this.options.onReadOnlyChecked) {
801
801
  o.checked = !o.checked;
802
802
  return;
803
803
  }
804
- const { checked: u } = d.target;
805
- n.isEditable && typeof r == "function" && n.chain().focus(void 0, { scrollIntoView: !1 }).command(({ tr: h }) => {
806
- const m = r();
807
- if (typeof m != "number")
804
+ const { checked: d } = u.target;
805
+ n.isEditable && typeof r == "function" && n.chain().focus(void 0, { scrollIntoView: !1 }).command(({ tr: f }) => {
806
+ const b = r();
807
+ if (typeof b != "number")
808
808
  return !1;
809
- const f = h.doc.nodeAt(m);
810
- return h.setNodeMarkup(m, void 0, {
811
- ...f?.attrs,
812
- checked: u
809
+ const h = f.doc.nodeAt(b);
810
+ return f.setNodeMarkup(b, void 0, {
811
+ ...h?.attrs,
812
+ checked: d
813
813
  }), !0;
814
- }).run(), !n.isEditable && this.options.onReadOnlyChecked && (this.options.onReadOnlyChecked(t, u) || (o.checked = !o.checked));
815
- }), Object.entries(this.options.HTMLAttributes).forEach(([d, u]) => {
816
- s.setAttribute(d, u);
817
- }), 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]) => {
818
- s.setAttribute(d, u);
814
+ }).run(), !n.isEditable && this.options.onReadOnlyChecked && (this.options.onReadOnlyChecked(t, d) || (o.checked = !o.checked));
815
+ }), Object.entries(this.options.HTMLAttributes).forEach(([u, d]) => {
816
+ s.setAttribute(u, d);
817
+ }), 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]) => {
818
+ s.setAttribute(u, d);
819
819
  }), {
820
820
  dom: s,
821
821
  contentDOM: c,
822
- update: (d) => d.type !== this.type ? !1 : (s.dataset.checked = d.attrs.checked, o.checked = d.attrs.checked, l(d), !0)
822
+ update: (u) => u.type !== this.type ? !1 : (s.dataset.checked = u.attrs.checked, o.checked = u.attrs.checked, l(u), !0)
823
823
  };
824
824
  };
825
825
  },
@@ -855,7 +855,7 @@ var je = "listItem", rt = "textStyle", nt = /^(\d+)\.\s$/, Qe = L.create({
855
855
  ];
856
856
  },
857
857
  renderHTML({ HTMLAttributes: t }) {
858
- return ["ul", k(this.options.HTMLAttributes, t, { "data-type": this.name }), 0];
858
+ return ["ul", T(this.options.HTMLAttributes, t, { "data-type": this.name }), 0];
859
859
  },
860
860
  parseMarkdown: (t, e) => e.createNode("taskList", {}, e.parseChildren(t.items || [])),
861
861
  renderMarkdown: (t, e) => t.content ? e.renderChildren(t.content, `
@@ -975,7 +975,7 @@ var Ve = Q.create({
975
975
  ];
976
976
  },
977
977
  renderHTML({ HTMLAttributes: t }) {
978
- return ["sub", k(this.options.HTMLAttributes, t), 0];
978
+ return ["sub", T(this.options.HTMLAttributes, t), 0];
979
979
  },
980
980
  addCommands() {
981
981
  return {
@@ -1010,7 +1010,7 @@ var Ve = Q.create({
1010
1010
  ];
1011
1011
  },
1012
1012
  renderHTML({ HTMLAttributes: t }) {
1013
- return ["sup", k(this.options.HTMLAttributes, t), 0];
1013
+ return ["sup", T(this.options.HTMLAttributes, t), 0];
1014
1014
  },
1015
1015
  addCommands() {
1016
1016
  return {
@@ -1226,8 +1226,8 @@ C.create({
1226
1226
  return !0;
1227
1227
  if (s > n && i > n && i > s || !e.getMeta("paste"))
1228
1228
  return !1;
1229
- const o = e.selection.$head.pos, c = i - n, l = o - c, d = o;
1230
- return e.deleteRange(l, d), !(this.storage.characters({ node: e.doc }) > n);
1229
+ const o = e.selection.$head.pos, c = i - n, l = o - c, u = o;
1230
+ return e.deleteRange(l, u), !(this.storage.characters({ node: e.doc }) > n);
1231
1231
  }
1232
1232
  })
1233
1233
  ];
@@ -1331,10 +1331,10 @@ var br = C.create({
1331
1331
  return t.descendants((a, o) => {
1332
1332
  const c = n >= o && n <= o + a.nodeSize, l = !a.isLeaf && Nt(a);
1333
1333
  if ((c || !this.options.showOnlyCurrent) && l) {
1334
- const d = [this.options.emptyNodeClass];
1335
- i && d.push(this.options.emptyEditorClass);
1336
- const u = K.node(o, o + a.nodeSize, {
1337
- class: d.join(" "),
1334
+ const u = [this.options.emptyNodeClass];
1335
+ i && u.push(this.options.emptyEditorClass);
1336
+ const d = K.node(o, o + a.nodeSize, {
1337
+ class: u.join(" "),
1338
1338
  "data-placeholder": typeof this.options.placeholder == "function" ? this.options.placeholder({
1339
1339
  editor: this.editor,
1340
1340
  node: a,
@@ -1342,7 +1342,7 @@ var br = C.create({
1342
1342
  hasAnchor: c
1343
1343
  }) : this.options.placeholder
1344
1344
  });
1345
- s.push(u);
1345
+ s.push(d);
1346
1346
  }
1347
1347
  return this.options.includeChildren;
1348
1348
  }), B.create(t, s);
@@ -1394,9 +1394,9 @@ C.create({
1394
1394
  new H({
1395
1395
  key: e,
1396
1396
  appendTransaction: (s, i, a) => {
1397
- const { doc: o, tr: c, schema: l } = a, d = e.getState(a), u = o.content.size, h = l.nodes[r];
1398
- if (d)
1399
- return c.insert(u, h.create());
1397
+ const { doc: o, tr: c, schema: l } = a, u = e.getState(a), d = o.content.size, f = l.nodes[r];
1398
+ if (u)
1399
+ return c.insert(d, f.create());
1400
1400
  },
1401
1401
  state: {
1402
1402
  init: (s, i) => {
@@ -1481,7 +1481,7 @@ var kr = L.create({
1481
1481
  return [{ tag: "td" }];
1482
1482
  },
1483
1483
  renderHTML({ HTMLAttributes: t }) {
1484
- return ["td", k(this.options.HTMLAttributes, t), 0];
1484
+ return ["td", T(this.options.HTMLAttributes, t), 0];
1485
1485
  }
1486
1486
  }), Tr = L.create({
1487
1487
  name: "tableHeader",
@@ -1514,7 +1514,7 @@ var kr = L.create({
1514
1514
  return [{ tag: "th" }];
1515
1515
  },
1516
1516
  renderHTML({ HTMLAttributes: t }) {
1517
- return ["th", k(this.options.HTMLAttributes, t), 0];
1517
+ return ["th", T(this.options.HTMLAttributes, t), 0];
1518
1518
  }
1519
1519
  }), Cr = L.create({
1520
1520
  name: "tableRow",
@@ -1529,7 +1529,7 @@ var kr = L.create({
1529
1529
  return [{ tag: "tr" }];
1530
1530
  },
1531
1531
  renderHTML({ HTMLAttributes: t }) {
1532
- return ["tr", k(this.options.HTMLAttributes, t), 0];
1532
+ return ["tr", T(this.options.HTMLAttributes, t), 0];
1533
1533
  }
1534
1534
  });
1535
1535
  function j(t, e) {
@@ -1538,30 +1538,30 @@ function j(t, e) {
1538
1538
  function it(t, e, r, n, s, i) {
1539
1539
  var a;
1540
1540
  let o = 0, c = !0, l = e.firstChild;
1541
- const d = t.firstChild;
1542
- if (d !== null)
1543
- for (let h = 0, m = 0; h < d.childCount; h += 1) {
1544
- const { colspan: f, colwidth: b } = d.child(h).attrs;
1545
- for (let g = 0; g < f; g += 1, m += 1) {
1546
- const T = s === m ? i : b && b[g], v = T ? `${T}px` : "";
1547
- if (o += T || n, T || (c = !1), l) {
1541
+ const u = t.firstChild;
1542
+ if (u !== null)
1543
+ for (let f = 0, b = 0; f < u.childCount; f += 1) {
1544
+ const { colspan: h, colwidth: g } = u.child(f).attrs;
1545
+ for (let m = 0; m < h; m += 1, b += 1) {
1546
+ const k = s === b ? i : g && g[m], v = k ? `${k}px` : "";
1547
+ if (o += k || n, k || (c = !1), l) {
1548
1548
  if (l.style.width !== v) {
1549
- const [I, N] = j(n, T);
1549
+ const [I, N] = j(n, k);
1550
1550
  l.style.setProperty(I, N);
1551
1551
  }
1552
1552
  l = l.nextSibling;
1553
1553
  } else {
1554
- const I = document.createElement("col"), [N, O] = j(n, T);
1554
+ const I = document.createElement("col"), [N, O] = j(n, k);
1555
1555
  I.style.setProperty(N, O), e.appendChild(I);
1556
1556
  }
1557
1557
  }
1558
1558
  }
1559
1559
  for (; l; ) {
1560
- const h = l.nextSibling;
1561
- (a = l.parentNode) == null || a.removeChild(l), l = h;
1560
+ const f = l.nextSibling;
1561
+ (a = l.parentNode) == null || a.removeChild(l), l = f;
1562
1562
  }
1563
- const u = t.attrs.style && typeof t.attrs.style == "string" && /\bwidth\s*:/i.test(t.attrs.style);
1564
- c && !u ? (r.style.width = `${o}px`, r.style.minWidth = "") : (r.style.width = "", r.style.minWidth = `${o}px`);
1563
+ const d = t.attrs.style && typeof t.attrs.style == "string" && /\bwidth\s*:/i.test(t.attrs.style);
1564
+ c && !d ? (r.style.width = `${o}px`, r.style.minWidth = "") : (r.style.width = "", r.style.minWidth = `${o}px`);
1565
1565
  }
1566
1566
  var Lr = class {
1567
1567
  constructor(t, e) {
@@ -1580,13 +1580,13 @@ function wr(t, e, r, n) {
1580
1580
  const a = [], o = t.firstChild;
1581
1581
  if (!o)
1582
1582
  return {};
1583
- for (let u = 0, h = 0; u < o.childCount; u += 1) {
1584
- const { colspan: m, colwidth: f } = o.child(u).attrs;
1585
- for (let b = 0; b < m; b += 1, h += 1) {
1586
- const g = r === h ? n : f && f[b];
1587
- s += g || e, g || (i = !1);
1588
- const [T, v] = j(e, g);
1589
- a.push(["col", { style: `${T}: ${v}` }]);
1583
+ for (let d = 0, f = 0; d < o.childCount; d += 1) {
1584
+ const { colspan: b, colwidth: h } = o.child(d).attrs;
1585
+ for (let g = 0; g < b; g += 1, f += 1) {
1586
+ const m = r === f ? n : h && h[g];
1587
+ s += m || e, m || (i = !1);
1588
+ const [k, v] = j(e, m);
1589
+ a.push(["col", { style: `${k}: ${v}` }]);
1590
1590
  }
1591
1591
  }
1592
1592
  const c = i ? `${s}px` : "", l = i ? "" : `${s}px`;
@@ -1607,10 +1607,10 @@ function vr(t) {
1607
1607
  function Mr(t, e, r, n, s) {
1608
1608
  const i = vr(t), a = [], o = [];
1609
1609
  for (let l = 0; l < r; l += 1) {
1610
- const d = ot(i.cell);
1611
- if (d && o.push(d), n) {
1612
- const u = ot(i.header_cell);
1613
- u && a.push(u);
1610
+ const u = ot(i.cell);
1611
+ if (u && o.push(u), n) {
1612
+ const d = ot(i.header_cell);
1613
+ d && a.push(d);
1614
1614
  }
1615
1615
  }
1616
1616
  const c = [];
@@ -1642,36 +1642,36 @@ function Sr(t, e, r = {}) {
1642
1642
  if (!t || !t.content || t.content.length === 0)
1643
1643
  return "";
1644
1644
  const i = [];
1645
- t.content.forEach((f) => {
1646
- const b = [];
1647
- f.content && f.content.forEach((g) => {
1648
- let T = "";
1649
- g.content && Array.isArray(g.content) && g.content.length > 1 ? T = g.content.map((O) => e.renderChildren(O)).join(s) : T = g.content ? e.renderChildren(g.content) : "";
1650
- const v = Ir(T), I = g.type === "tableHeader";
1651
- b.push({ text: v, isHeader: I });
1652
- }), i.push(b);
1645
+ t.content.forEach((h) => {
1646
+ const g = [];
1647
+ h.content && h.content.forEach((m) => {
1648
+ let k = "";
1649
+ m.content && Array.isArray(m.content) && m.content.length > 1 ? k = m.content.map((O) => e.renderChildren(O)).join(s) : k = m.content ? e.renderChildren(m.content) : "";
1650
+ const v = Ir(k), I = m.type === "tableHeader";
1651
+ g.push({ text: v, isHeader: I });
1652
+ }), i.push(g);
1653
1653
  });
1654
- const a = i.reduce((f, b) => Math.max(f, b.length), 0);
1654
+ const a = i.reduce((h, g) => Math.max(h, g.length), 0);
1655
1655
  if (a === 0)
1656
1656
  return "";
1657
1657
  const o = new Array(a).fill(0);
1658
- i.forEach((f) => {
1659
- var b;
1660
- for (let g = 0; g < a; g += 1) {
1661
- const v = (((b = f[g]) == null ? void 0 : b.text) || "").length;
1662
- v > o[g] && (o[g] = v), o[g] < 3 && (o[g] = 3);
1658
+ i.forEach((h) => {
1659
+ var g;
1660
+ for (let m = 0; m < a; m += 1) {
1661
+ const v = (((g = h[m]) == null ? void 0 : g.text) || "").length;
1662
+ v > o[m] && (o[m] = v), o[m] < 3 && (o[m] = 3);
1663
1663
  }
1664
1664
  });
1665
- const c = (f, b) => f + " ".repeat(Math.max(0, b - f.length)), l = i[0], d = l.some((f) => f.isHeader);
1666
- let u = `
1665
+ const c = (h, g) => h + " ".repeat(Math.max(0, g - h.length)), l = i[0], u = l.some((h) => h.isHeader);
1666
+ let d = `
1667
1667
  `;
1668
- const h = new Array(a).fill(0).map((f, b) => d && l[b] && l[b].text || "");
1669
- return u += `| ${h.map((f, b) => c(f, o[b])).join(" | ")} |
1670
- `, u += `| ${o.map((f) => "-".repeat(Math.max(3, f))).join(" | ")} |
1671
- `, (d ? i.slice(1) : i).forEach((f) => {
1672
- u += `| ${new Array(a).fill(0).map((b, g) => c(f[g] && f[g].text || "", o[g])).join(" | ")} |
1668
+ const f = new Array(a).fill(0).map((h, g) => u && l[g] && l[g].text || "");
1669
+ return d += `| ${f.map((h, g) => c(h, o[g])).join(" | ")} |
1670
+ `, d += `| ${o.map((h) => "-".repeat(Math.max(3, h))).join(" | ")} |
1671
+ `, (u ? i.slice(1) : i).forEach((h) => {
1672
+ d += `| ${new Array(a).fill(0).map((g, m) => c(h[m] && h[m].text || "", o[m])).join(" | ")} |
1673
1673
  `;
1674
- }), u;
1674
+ }), d;
1675
1675
  }
1676
1676
  var Hr = Sr, Er = L.create({
1677
1677
  name: "table",
@@ -1703,7 +1703,7 @@ var Hr = Sr, Er = L.create({
1703
1703
  }
1704
1704
  const o = [
1705
1705
  "table",
1706
- k(this.options.HTMLAttributes, e, {
1706
+ T(this.options.HTMLAttributes, e, {
1707
1707
  style: a()
1708
1708
  }),
1709
1709
  r,
@@ -1874,13 +1874,19 @@ function _n({
1874
1874
  content: e,
1875
1875
  onContentChange: r,
1876
1876
  placeholder: n = "",
1877
- ref: s
1877
+ ref: s,
1878
+ autofocus: i,
1879
+ onFocus: a,
1880
+ onBlur: o
1878
1881
  }) {
1879
- const i = de(), { height: a } = ce(), [o, c] = vt(
1882
+ const c = de(), { height: l } = ce(), [u, d] = vt(
1880
1883
  "main"
1881
- ), l = q(null), d = q(!1), u = Ct({
1884
+ ), f = q(null), b = q(!1), h = Ct({
1882
1885
  immediatelyRender: !1,
1883
1886
  shouldRerenderOnTransaction: !1,
1887
+ autofocus: i,
1888
+ onFocus: a,
1889
+ onBlur: o,
1884
1890
  editorProps: {
1885
1891
  attributes: {
1886
1892
  autocomplete: "off",
@@ -1926,49 +1932,49 @@ function _n({
1926
1932
  ],
1927
1933
  content: e,
1928
1934
  onUpdate: ({ editor: m }) => {
1929
- if (!d.current && r) {
1930
- const f = m.getHTML();
1931
- r(f);
1935
+ if (!b.current && r) {
1936
+ const k = m.getHTML();
1937
+ r(k);
1932
1938
  }
1933
1939
  }
1934
- }), h = ue({
1935
- editor: u,
1936
- overlayHeight: l.current?.getBoundingClientRect().height ?? 0
1940
+ }), g = ue({
1941
+ editor: h,
1942
+ overlayHeight: f.current?.getBoundingClientRect().height ?? 0
1937
1943
  });
1938
1944
  return D(() => {
1939
- !i && o !== "main" && c("main");
1940
- }, [i, o]), D(() => {
1941
- u && e !== void 0 && u.getHTML() !== e && (d.current = !0, u.commands.setContent(e, { emitUpdate: !1 }), d.current = !1);
1942
- }, [e, u]), D(() => {
1945
+ !c && u !== "main" && d("main");
1946
+ }, [c, u]), D(() => {
1947
+ h && e !== void 0 && h.getHTML() !== e && (b.current = !0, h.commands.setContent(e, { emitUpdate: !1 }), b.current = !1);
1948
+ }, [e, h]), D(() => {
1943
1949
  document.documentElement.classList.toggle("dark", t === "dark");
1944
1950
  }, [t]), Mt(
1945
1951
  s,
1946
1952
  () => ({
1947
- getEditor: () => u
1953
+ getEditor: () => h
1948
1954
  }),
1949
- [u]
1950
- ), u ? /* @__PURE__ */ p("div", { className: "simple-editor-wrapper", children: /* @__PURE__ */ w(Lt.Provider, { value: { editor: u }, children: [
1955
+ [h]
1956
+ ), h ? /* @__PURE__ */ p("div", { className: "simple-editor-wrapper", children: /* @__PURE__ */ w(Lt.Provider, { value: { editor: h }, children: [
1951
1957
  /* @__PURE__ */ p(
1952
1958
  Kt,
1953
1959
  {
1954
- ref: l,
1960
+ ref: f,
1955
1961
  style: {
1956
- ...i ? {
1957
- bottom: `calc(100% - ${a - h.y}px)`
1962
+ ...c ? {
1963
+ bottom: `calc(100% - ${l - g.y}px)`
1958
1964
  } : {}
1959
1965
  },
1960
- children: o === "main" ? /* @__PURE__ */ p(
1966
+ children: u === "main" ? /* @__PURE__ */ p(
1961
1967
  Nr,
1962
1968
  {
1963
- onHighlighterClick: () => c("highlighter"),
1964
- onLinkClick: () => c("link"),
1965
- isMobile: i
1969
+ onHighlighterClick: () => d("highlighter"),
1970
+ onLinkClick: () => d("link"),
1971
+ isMobile: c
1966
1972
  }
1967
1973
  ) : /* @__PURE__ */ p(
1968
1974
  Rr,
1969
1975
  {
1970
- type: o === "highlighter" ? "highlighter" : "link",
1971
- onBack: () => c("main")
1976
+ type: u === "highlighter" ? "highlighter" : "link",
1977
+ onBack: () => d("main")
1972
1978
  }
1973
1979
  )
1974
1980
  }
@@ -1977,7 +1983,7 @@ function _n({
1977
1983
  /* @__PURE__ */ p(
1978
1984
  wt,
1979
1985
  {
1980
- editor: u,
1986
+ editor: h,
1981
1987
  role: "presentation",
1982
1988
  className: "simple-editor-content"
1983
1989
  }
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.11",
5
+ "version": "0.0.12",
6
6
  "type": "module",
7
7
  "main": "dist/main.js",
8
8
  "types": "dist/main.d.ts",