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 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/ecd70f084f2fbb54d36bfd3b682f2dd8bbc3f547/src/dom/default.ts#L25).
41
- - You must render void nodes in the document as [void element](https://github.com/inokawa/editate/blob/ecd70f084f2fbb54d36bfd3b682f2dd8bbc3f547/src/dom/default.ts#L47).
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)
@@ -2,6 +2,8 @@ export interface TextNode {
2
2
  readonly text: string;
3
3
  }
4
4
  export interface VoidNode {
5
+ readonly [key: string]: any;
6
+ readonly text?: never;
5
7
  }
6
8
  export type InlineNode = TextNode | VoidNode;
7
9
  export interface BlockNode {
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 a(() => {
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
- for (;(o = null) || (r = n.previousSibling()); ) if (4 === c()) return;
614
+ a(!0, !0);
608
615
  },
609
616
  o: () => {
610
- for (;(o = null) || (r = n.nextSibling()); ) if (4 === c()) return;
617
+ a(!1, !0);
611
618
  },
612
619
  p: () => {
613
620
  for (;(o = null) || (r = n.parentNode()); ) if (4 === c()) return;
614
621
  }
615
- }, a = (e, c) => {
616
- const s = n, i = r, a = o;
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(l);
625
+ return n || (n = t.createTreeWalker(r = c, 5)), e(u);
619
626
  } finally {
620
- n = s, r = i, o = a, n && i && (n.currentNode = i);
627
+ n = s, r = i, o = l, n && i && (n.currentNode = i);
621
628
  }
622
629
  };
623
- return a;
630
+ return f;
624
631
  })(E, r), M = () => {
625
632
  n.contentEditable = e ? "false" : "true", n.ariaReadOnly = e ? "true" : null;
626
633
  };