editate 0.6.25 → 0.6.27
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/README.md +3 -2
- package/lib/doc/types.d.ts +2 -0
- package/lib/index.cjs +17 -10
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +17 -10
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -37,8 +37,8 @@ Both desktop and mobile browsers that support [beforeinput event](https://develo
|
|
|
37
37
|
2. Define your editor view declaratively. There are rules you have to follow:
|
|
38
38
|
- You must render all texts in the document as Text nodes in DOM.
|
|
39
39
|
- You must render `<br/>` in empty blocks (limitation of contenteditable).
|
|
40
|
-
- You must render hard breaks in the document as [block element](https://github.com/inokawa/editate/blob/
|
|
41
|
-
- You must render void nodes in the document as [void element](https://github.com/inokawa/editate/blob/
|
|
40
|
+
- You must render hard breaks in the document as [block element](https://github.com/inokawa/editate/blob/e466e941bd0bd4fd3f668ca365cd076f1cb333a2/src/dom/default.ts#L26).
|
|
41
|
+
- You must render void nodes in the document as [void element](https://github.com/inokawa/editate/blob/e466e941bd0bd4fd3f668ca365cd076f1cb333a2/src/dom/parser.ts#L174-L188).
|
|
42
42
|
3. Use `createPlainEditor`/`createEditor` to initialize `Editor` with the document.
|
|
43
43
|
4. Call `Editor.input` on mount, with `HTMLElement` which is the root of editor view.
|
|
44
44
|
5. Update your state with `onChange`, which will be called on edit.
|
|
@@ -247,6 +247,7 @@ If you find a problem, feel free to create an [issue](https://github.com/inokawa
|
|
|
247
247
|
- [Lexical](https://github.com/facebook/lexical)
|
|
248
248
|
- [Quill](https://github.com/slab/quill)
|
|
249
249
|
- [Tiptap](https://github.com/ueberdosis/tiptap)
|
|
250
|
+
- [Wordgard](https://wordgard.net/)
|
|
250
251
|
- [Draft.js](https://github.com/facebookarchive/draft-js)
|
|
251
252
|
- [rich-textarea](https://github.com/inokawa/rich-textarea) (my early project)
|
|
252
253
|
- [use-editable](https://github.com/FormidableLabs/use-editable)
|
package/lib/doc/types.d.ts
CHANGED
package/lib/index.cjs
CHANGED
|
@@ -580,14 +580,20 @@ var it = [], lt = () => {}, at = t => {
|
|
|
580
580
|
return r = n.nextNode();
|
|
581
581
|
}, i = () => {
|
|
582
582
|
const t = r.parentNode;
|
|
583
|
-
return
|
|
583
|
+
return f(() => {
|
|
584
584
|
for (o = 0; s(); ) {
|
|
585
585
|
if (c()) return !0;
|
|
586
586
|
if (!t.contains(r)) break;
|
|
587
587
|
}
|
|
588
588
|
return !1;
|
|
589
589
|
});
|
|
590
|
-
}, l = {
|
|
590
|
+
}, l = () => {
|
|
591
|
+
const t = c();
|
|
592
|
+
return 0 === t || 6 === t;
|
|
593
|
+
}, a = (t, e) => {
|
|
594
|
+
for (;(o = null) || (r = t ? n.previousSibling() : n.nextSibling()); ) if (e ? 4 === c() : !l()) return !0;
|
|
595
|
+
return !1;
|
|
596
|
+
}, u = {
|
|
591
597
|
t: () => {
|
|
592
598
|
for (;s(); ) {
|
|
593
599
|
const t = c();
|
|
@@ -601,26 +607,27 @@ var it = [], lt = () => {}, at = t => {
|
|
|
601
607
|
return 1 === t ? r.data.length : 2 === t ? 1 : 0;
|
|
602
608
|
},
|
|
603
609
|
u: t => {
|
|
604
|
-
o = null, n.currentNode = r = t
|
|
610
|
+
o = null, n.currentNode = r = t, l() && !a(!0) && (o = null, n.currentNode = r = t,
|
|
611
|
+
a(!1) || (o = null, n.currentNode = r = t));
|
|
605
612
|
},
|
|
606
613
|
h: () => {
|
|
607
|
-
|
|
614
|
+
a(!0, !0);
|
|
608
615
|
},
|
|
609
616
|
o: () => {
|
|
610
|
-
|
|
617
|
+
a(!1, !0);
|
|
611
618
|
},
|
|
612
619
|
p: () => {
|
|
613
620
|
for (;(o = null) || (r = n.parentNode()); ) if (4 === c()) return;
|
|
614
621
|
}
|
|
615
|
-
},
|
|
616
|
-
const s = n, i = r,
|
|
622
|
+
}, f = (e, c) => {
|
|
623
|
+
const s = n, i = r, l = o;
|
|
617
624
|
try {
|
|
618
|
-
return n || (n = t.createTreeWalker(r = c, 5)), e(
|
|
625
|
+
return n || (n = t.createTreeWalker(r = c, 5)), e(u);
|
|
619
626
|
} finally {
|
|
620
|
-
n = s, r = i, o =
|
|
627
|
+
n = s, r = i, o = l, n && i && (n.currentNode = i);
|
|
621
628
|
}
|
|
622
629
|
};
|
|
623
|
-
return
|
|
630
|
+
return f;
|
|
624
631
|
})(E, r), M = () => {
|
|
625
632
|
n.contentEditable = e ? "false" : "true", n.ariaReadOnly = e ? "true" : null;
|
|
626
633
|
};
|