@use-kona/editor 0.1.13 → 0.1.15

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.
@@ -14,29 +14,6 @@ const createEditor_createEditor = (plugins)=>()=>{
14
14
  if (!pluginInstance) throw new Error(`Plugin ${plugin.name} not found`);
15
15
  return pluginInstance.commands;
16
16
  };
17
- editorWithPlugins.normalizeNode = (entry)=>{
18
- const [node, path] = entry;
19
- const lastElement = editorWithPlugins.children[editorWithPlugins.children.length - 1];
20
- if (!lastElement || 'paragraph' !== lastElement.type) {
21
- const paragraph = {
22
- type: 'paragraph',
23
- children: [
24
- {
25
- text: ''
26
- }
27
- ]
28
- };
29
- Transforms.insertNodes(editorWithPlugins, paragraph, {
30
- at: [
31
- editorWithPlugins.children.length
32
- ]
33
- });
34
- }
35
- return normalizeNode([
36
- node,
37
- path
38
- ]);
39
- };
40
17
  editorWithPlugins.isVoid = (element)=>{
41
18
  const result = plugins.reduce((result, plugin)=>{
42
19
  const match = plugin.blocks?.find((el)=>element?.type === el.type);
@@ -1,4 +1,4 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
2
  import { useLayoutEffect, useRef, useState } from "react";
3
3
  import { createPortal } from "react-dom";
4
4
  import { useReadOnly, useSlateStatic } from "slate-react";
@@ -56,16 +56,24 @@ const Link = (props)=>{
56
56
  /*#__PURE__*/ jsx(InlineChromiumBugfix, {})
57
57
  ]
58
58
  }),
59
- isOpen && /*#__PURE__*/ createPortal(/*#__PURE__*/ jsx("div", {
60
- contentEditable: false,
61
- className: styles_module.hint,
62
- style: style,
63
- onMouseUp: handleMenuClick,
64
- children: renderHint({
65
- getLinkElement,
66
- getUrl,
67
- getEditor
68
- })
59
+ isOpen && /*#__PURE__*/ createPortal(/*#__PURE__*/ jsxs(Fragment, {
60
+ children: [
61
+ /*#__PURE__*/ jsx("div", {
62
+ className: styles_module.backdrop,
63
+ onClick: ()=>setOpen(false)
64
+ }),
65
+ /*#__PURE__*/ jsx("div", {
66
+ contentEditable: false,
67
+ className: styles_module.hint,
68
+ style: style,
69
+ onMouseUp: handleMenuClick,
70
+ children: renderHint({
71
+ getLinkElement,
72
+ getUrl,
73
+ getEditor
74
+ })
75
+ })
76
+ ]
69
77
  }), document.body)
70
78
  ]
71
79
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@use-kona/editor",
3
- "version": "0.1.13",
3
+ "version": "0.1.15",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./src/index.ts"
@@ -43,24 +43,6 @@ export const createEditor = (plugins: IPlugin[]) => () => {
43
43
  return pluginInstance.commands;
44
44
  };
45
45
 
46
- editorWithPlugins.normalizeNode = (entry) => {
47
- const [node, path] = entry;
48
-
49
- const lastElement =
50
- editorWithPlugins.children[editorWithPlugins.children.length - 1];
51
- if (!lastElement || (lastElement as CustomElement).type !== 'paragraph') {
52
- const paragraph = {
53
- type: 'paragraph',
54
- children: [{ text: '' }],
55
- };
56
- Transforms.insertNodes(editorWithPlugins, paragraph, {
57
- at: [editorWithPlugins.children.length],
58
- });
59
- }
60
-
61
- return normalizeNode([node, path]);
62
- };
63
-
64
46
  editorWithPlugins.isVoid = (element) => {
65
47
  const result = plugins.reduce<boolean | undefined>((result, plugin) => {
66
48
  const match = plugin.blocks?.find((el) => element?.type === el.type);
@@ -74,18 +74,21 @@ export const Link = (props: Props) => {
74
74
  </a>
75
75
  {isOpen &&
76
76
  createPortal(
77
- <div
78
- contentEditable={false}
79
- className={styles.hint}
80
- style={style}
81
- onMouseUp={handleMenuClick}
82
- >
83
- {renderHint({
84
- getLinkElement,
85
- getUrl,
86
- getEditor,
87
- })}
88
- </div>,
77
+ <>
78
+ <div className={styles.backdrop} onClick={() => setOpen(false)} />
79
+ <div
80
+ contentEditable={false}
81
+ className={styles.hint}
82
+ style={style}
83
+ onMouseUp={handleMenuClick}
84
+ >
85
+ {renderHint({
86
+ getLinkElement,
87
+ getUrl,
88
+ getEditor,
89
+ })}
90
+ </div>
91
+ </>,
89
92
  document.body,
90
93
  )}
91
94
  </Component>