@samhammer/tiptob 2.3.13 → 2.3.16

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/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 Samhammer AG
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Samhammer AG
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -97,7 +97,6 @@ Below is a minimal example of initializing a TipTap editor. For more advanced us
97
97
  import { Editor } from '@tiptap/core';
98
98
  import StarterKit from '@tiptap/starter-kit';
99
99
 
100
-
101
100
  const editor = new Editor({
102
101
  element: document.querySelector('.editor'),
103
102
  extensions: [
@@ -631,8 +631,8 @@ function yo(n, e, t) {
631
631
  function vo(n, e, t, r) {
632
632
  let { index: i, offset: o } = n.findIndex(e), s = n.maybeChild(i);
633
633
  if (o == e || s.isText)
634
- return n.cut(0, e).append(t).append(n.cut(e));
635
- let l = vo(s.content, e - o - 1, t);
634
+ return r && !r.canReplace(i, i, t) ? null : n.cut(0, e).append(t).append(n.cut(e));
635
+ let l = vo(s.content, e - o - 1, t, s);
636
636
  return l && n.replaceChild(i, s.copy(l));
637
637
  }
638
638
  function al(n, e, t) {
@@ -2340,16 +2340,24 @@ class yi {
2340
2340
  e.nodeType == 3 ? this.addTextNode(e, t) : e.nodeType == 1 && this.addElement(e, t);
2341
2341
  }
2342
2342
  addTextNode(e, t) {
2343
- let r = e.nodeValue, i = this.top, o = i.options & xr ? "full" : this.localPreserveWS || (i.options & Kt) > 0;
2343
+ let r = e.nodeValue, i = this.top, o = i.options & xr ? "full" : this.localPreserveWS || (i.options & Kt) > 0, { schema: s } = this.parser;
2344
2344
  if (o === "full" || i.inlineContext(e) || /[^ \t\r\n\u000c]/.test(r)) {
2345
2345
  if (o)
2346
- o !== "full" ? r = r.replace(/\r?\n|\r/g, " ") : r = r.replace(/\r\n?/g, `
2346
+ if (o === "full")
2347
+ r = r.replace(/\r\n?/g, `
2347
2348
  `);
2349
+ else if (s.linebreakReplacement && /[\r\n]/.test(r) && this.top.findWrapping(s.linebreakReplacement.create())) {
2350
+ let l = r.split(/\r?\n|\r/);
2351
+ for (let a = 0; a < l.length; a++)
2352
+ a && this.insertNode(s.linebreakReplacement.create(), t, !0), l[a] && this.insertNode(s.text(l[a]), t, !/\S/.test(l[a]));
2353
+ r = "";
2354
+ } else
2355
+ r = r.replace(/\r?\n|\r/g, " ");
2348
2356
  else if (r = r.replace(/[ \t\r\n\u000c]+/g, " "), /^[ \t\r\n\u000c]/.test(r) && this.open == this.nodes.length - 1) {
2349
- let s = i.content[i.content.length - 1], l = e.previousSibling;
2350
- (!s || l && l.nodeName == "BR" || s.isText && /[ \t\r\n\u000c]$/.test(s.text)) && (r = r.slice(1));
2357
+ let l = i.content[i.content.length - 1], a = e.previousSibling;
2358
+ (!l || a && a.nodeName == "BR" || l.isText && /[ \t\r\n\u000c]$/.test(l.text)) && (r = r.slice(1));
2351
2359
  }
2352
- r && this.insertNode(this.parser.schema.text(r), t, !/\S/.test(r)), this.findInText(e);
2360
+ r && this.insertNode(s.text(r), t, !/\S/.test(r)), this.findInText(e);
2353
2361
  } else
2354
2362
  this.findInside(e);
2355
2363
  }
@@ -4311,11 +4319,11 @@ function Yl(n) {
4311
4319
  });
4312
4320
  }
4313
4321
  function Xl(n) {
4314
- let e = n.domSelection(), t = document.createRange();
4322
+ let e = n.domSelection();
4315
4323
  if (!e)
4316
4324
  return;
4317
- let r = n.cursorWrapper.dom, i = r.nodeName == "IMG";
4318
- i ? t.setStart(r.parentNode, ft(r) + 1) : t.setStart(r, 0), t.collapse(!0), e.removeAllRanges(), e.addRange(t), !i && !n.state.selection.visible && rn && Ko <= 11 && (r.disabled = !0, r.disabled = !1);
4325
+ let t = n.cursorWrapper.dom, r = t.nodeName == "IMG";
4326
+ r ? e.collapse(t.parentNode, ft(t) + 1) : e.collapse(t, 0), !r && !n.state.selection.visible && rn && Ko <= 11 && (t.disabled = !0, t.disabled = !1);
4319
4327
  }
4320
4328
  function Ql(n, e) {
4321
4329
  if (e instanceof O) {
@@ -4624,13 +4632,15 @@ function Zo(n, e, t, r, i) {
4624
4632
  let o = i.parent.type.spec.code, s, l;
4625
4633
  if (!t && !e)
4626
4634
  return null;
4627
- let a = e && (r || o || !t);
4635
+ let a = !!e && (r || o || !t);
4628
4636
  if (a) {
4629
4637
  if (n.someProp("transformPastedText", (p) => {
4630
4638
  e = p(e, o || r, n);
4631
4639
  }), o)
4632
- return e ? new S(k.from(n.state.schema.text(e.replace(/\r\n?/g, `
4633
- `))), 0, 0) : S.empty;
4640
+ return l = new S(k.from(n.state.schema.text(e.replace(/\r\n?/g, `
4641
+ `))), 0, 0), n.someProp("transformPasted", (p) => {
4642
+ l = p(l, n, !0);
4643
+ }), l;
4634
4644
  let f = n.someProp("clipboardTextParser", (p) => p(e, i, r, n));
4635
4645
  if (f)
4636
4646
  l = f;
@@ -4672,7 +4682,7 @@ function Zo(n, e, t, r, i) {
4672
4682
  l = Vi(l, f, p);
4673
4683
  }
4674
4684
  return n.someProp("transformPasted", (f) => {
4675
- l = f(l, n);
4685
+ l = f(l, n, a);
4676
4686
  }), l;
4677
4687
  }
4678
4688
  const sa = /^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;
@@ -4904,7 +4914,7 @@ class ba {
4904
4914
  o = u.parent, s = u.depth ? u.before() : 0;
4905
4915
  }
4906
4916
  const l = i ? null : r.target, a = l ? e.docView.nearestDesc(l, !0) : null;
4907
- this.target = a && a.dom.nodeType == 1 ? a.dom : null;
4917
+ this.target = a && a.nodeDOM.nodeType == 1 ? a.nodeDOM : null;
4908
4918
  let { selection: c } = e.state;
4909
4919
  (r.button == 0 && o.type.spec.draggable && o.type.spec.selectable !== !1 || c instanceof O && c.from <= s && c.to > s) && (this.mightDrag = {
4910
4920
  node: o,
@@ -5093,7 +5103,7 @@ ce.drop = (n, e) => {
5093
5103
  return;
5094
5104
  let o = n.state.doc.resolve(i.pos), s = r && r.slice;
5095
5105
  s ? n.someProp("transformPasted", (g) => {
5096
- s = g(s, n);
5106
+ s = g(s, n, !1);
5097
5107
  }) : s = Zo(n, as(t.dataTransfer), Yt ? null : t.dataTransfer.getData("text/html"), !1, o);
5098
5108
  let l = !!(r && cs(n, t));
5099
5109
  if (n.someProp("handleDrop", (g) => g(n, t, s || S.empty, l))) {