@lazlon-platform/html-editor 0.2.1 → 0.2.2

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.
@@ -3,7 +3,6 @@ import type { Editor, NodeConstructor } from "../model/editor"
3
3
  import type { HistoryAction } from "../model/history"
4
4
  import type { Node, NodeProps } from "../model/node"
5
5
  import { GroupNode } from "../model/node/group"
6
- import { TextNode } from "../model/node/text"
7
6
  import type { Page } from "../model/page"
8
7
  import { flattenNodes } from "../model/traversal"
9
8
  import { getTargetRect } from "../ui/selection"
@@ -57,11 +56,6 @@ export function useAddNodeAction(page?: Page) {
57
56
  undo: ["delete-node", [targetPage.id, [node.id]]],
58
57
  })
59
58
 
60
- if (node instanceof TextNode) {
61
- editor.selection = new Set([node])
62
- setTimeout(() => node.tiptap.commands.focus())
63
- }
64
-
65
59
  return node as InstanceType<N>
66
60
  }
67
61
  }
@@ -20,7 +20,10 @@ export function EditableContent(props: {
20
20
  const selection = useStore(editor, "selection")
21
21
  const { action } = useStore(editor, "action")
22
22
  const prevContent = useRef(node.tiptap.getJSON())
23
- const [clicked, setClicked] = useState(false)
23
+
24
+ // start with selection.has(node) so that newly added editable nodes can be focused
25
+ const [clicked, setClicked] = useState(selection.has(node))
26
+
24
27
  const onDoubleClick = useDoubleClick(
25
28
  useCallback(() => {
26
29
  setClicked(true)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lazlon-platform/html-editor",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "lib"