@dialpad/dialtone-vue 4.0.0 → 4.0.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.
@@ -2733,25 +2733,18 @@ var Bi = {
2733
2733
  return {
2734
2734
  ...this.parent?.(),
2735
2735
  toggleCodeBlock: (e = {}) => ({ state: t, chain: n, commands: r }) => {
2736
- let i = t.schema.nodes[this.name], { $from: a } = t.selection;
2737
- if (a.parent.type === i) {
2738
- let e = t.schema.nodes.paragraph, r = a.parent.textContent.split("\n"), i = a.before(), o = a.parent;
2739
- return n().command(({ tr: n }) => {
2740
- let a = r.map((n) => e.create({}, n ? [t.schema.text(n)] : []));
2741
- return n.replaceWith(i, i + o.nodeSize, a), !0;
2742
- }).run();
2743
- }
2744
- let { from: o, to: s } = t.selection, c = [];
2745
- if (t.doc.nodesBetween(o, s, (e, t) => {
2746
- if (e.isTextblock) return c.push({
2736
+ let i = t.schema.nodes[this.name], { $from: a, $to: o } = t.selection, s = [];
2737
+ return t.doc.nodesBetween(a.pos, o.pos, (e, t) => {
2738
+ if (e.isTextblock) return s.push({
2747
2739
  node: e,
2748
2740
  pos: t
2749
2741
  }), !1;
2750
- }), c.length <= 1) return r.setNode(this.name, e);
2751
- let l = c.map(({ node: e }) => e.textContent).join("\n"), u = c[0].pos, d = c[c.length - 1], f = d.pos + d.node.nodeSize;
2752
- return n().command(({ tr: n }) => {
2753
- let r = l.length ? [t.schema.text(l)] : [];
2754
- return n.replaceWith(u, f, i.create(e, r)), !0;
2742
+ }), s.length <= 1 ? r.toggleNode(this.name, "paragraph", e) : s.every(({ node: e }) => e.type === i) ? r.toggleNode(this.name, "paragraph") : n().setNode(this.name, e).command(({ tr: e }) => {
2743
+ for (let n = s.length - 1; n > 0; n--) {
2744
+ let r = e.mapping.map(s[n].pos), a = r - 1;
2745
+ e.doc.resolve(a).parent.type === i && e.replaceWith(a, r + 1, t.schema.text("\n"));
2746
+ }
2747
+ return !0;
2755
2748
  }).run();
2756
2749
  }
2757
2750
  };
@@ -3080,4 +3073,4 @@ var Wi = /* @__PURE__ */ i(Vi, [["render", Ui]]);
3080
3073
  //#endregion
3081
3074
  export { Wi as t };
3082
3075
 
3083
- //# sourceMappingURL=RichTextEditor-DKpulIyi.js.map
3076
+ //# sourceMappingURL=RichTextEditor-CzMY0oVT.js.map