@tiptap/react 2.0.0-beta.11 → 2.0.0-beta.114

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.
Files changed (34) hide show
  1. package/LICENSE.md +1 -1
  2. package/README.md +2 -2
  3. package/dist/packages/react/src/BubbleMenu.d.ts +6 -3
  4. package/dist/packages/react/src/Editor.d.ts +1 -1
  5. package/dist/packages/react/src/EditorContent.d.ts +2 -2
  6. package/dist/packages/react/src/FloatingMenu.d.ts +6 -3
  7. package/dist/packages/react/src/NodeViewContent.d.ts +2 -2
  8. package/dist/packages/react/src/NodeViewWrapper.d.ts +2 -2
  9. package/dist/packages/react/src/ReactNodeViewRenderer.d.ts +12 -6
  10. package/dist/packages/react/src/ReactRenderer.d.ts +13 -10
  11. package/dist/packages/react/src/index.d.ts +6 -6
  12. package/dist/packages/react/src/useEditor.d.ts +2 -1
  13. package/dist/packages/react/src/useReactNodeView.d.ts +1 -1
  14. package/dist/tiptap-react.cjs.js +216 -147
  15. package/dist/tiptap-react.cjs.js.map +1 -1
  16. package/dist/tiptap-react.esm.js +215 -144
  17. package/dist/tiptap-react.esm.js.map +1 -1
  18. package/dist/tiptap-react.umd.js +218 -149
  19. package/dist/tiptap-react.umd.js.map +1 -1
  20. package/package.json +18 -10
  21. package/src/BubbleMenu.tsx +37 -15
  22. package/src/Editor.ts +2 -1
  23. package/src/EditorContent.tsx +9 -7
  24. package/src/FloatingMenu.tsx +37 -14
  25. package/src/NodeViewContent.tsx +10 -6
  26. package/src/NodeViewWrapper.tsx +12 -9
  27. package/src/ReactNodeViewRenderer.tsx +87 -33
  28. package/src/ReactRenderer.tsx +38 -14
  29. package/src/index.ts +6 -6
  30. package/src/useEditor.ts +16 -4
  31. package/src/useReactNodeView.ts +1 -2
  32. package/CHANGELOG.md +0 -96
  33. package/dist/tiptap-react.bundle.umd.min.js +0 -54
  34. package/dist/tiptap-react.bundle.umd.min.js.map +0 -1
package/src/useEditor.ts CHANGED
@@ -1,5 +1,6 @@
1
- import { useState, useEffect } from 'react'
2
1
  import { EditorOptions } from '@tiptap/core'
2
+ import { DependencyList, useEffect, useState } from 'react'
3
+
3
4
  import { Editor } from './Editor'
4
5
 
5
6
  function useForceUpdate() {
@@ -8,21 +9,32 @@ function useForceUpdate() {
8
9
  return () => setValue(value => value + 1)
9
10
  }
10
11
 
11
- export const useEditor = (options: Partial<EditorOptions> = {}) => {
12
+ export const useEditor = (options: Partial<EditorOptions> = {}, deps: DependencyList = []) => {
12
13
  const [editor, setEditor] = useState<Editor | null>(null)
13
14
  const forceUpdate = useForceUpdate()
14
15
 
15
16
  useEffect(() => {
17
+ let isMounted = true
18
+
16
19
  const instance = new Editor(options)
17
20
 
18
21
  setEditor(instance)
19
22
 
20
- instance.on('transaction', forceUpdate)
23
+ instance.on('transaction', () => {
24
+ requestAnimationFrame(() => {
25
+ requestAnimationFrame(() => {
26
+ if (isMounted) {
27
+ forceUpdate()
28
+ }
29
+ })
30
+ })
31
+ })
21
32
 
22
33
  return () => {
23
34
  instance.destroy()
35
+ isMounted = false
24
36
  }
25
- }, [])
37
+ }, deps)
26
38
 
27
39
  return editor
28
40
  }
@@ -1,12 +1,11 @@
1
1
  import { createContext, useContext } from 'react'
2
2
 
3
3
  export interface ReactNodeViewContextProps {
4
- isEditable: boolean,
5
4
  onDragStart: (event: DragEvent) => void,
5
+ nodeViewContentRef: (element: HTMLElement | null) => void,
6
6
  }
7
7
 
8
8
  export const ReactNodeViewContext = createContext<Partial<ReactNodeViewContextProps>>({
9
- isEditable: undefined,
10
9
  onDragStart: undefined,
11
10
  })
12
11
 
package/CHANGELOG.md DELETED
@@ -1,96 +0,0 @@
1
- # Change Log
2
-
3
- All notable changes to this project will be documented in this file.
4
- See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
-
6
- # [2.0.0-beta.11](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/react@2.0.0-beta.10...@tiptap/react@2.0.0-beta.11) (2021-04-01)
7
-
8
- **Note:** Version bump only for package @tiptap/react
9
-
10
-
11
-
12
-
13
-
14
- # [2.0.0-beta.10](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/react@2.0.0-beta.9...@tiptap/react@2.0.0-beta.10) (2021-04-01)
15
-
16
- **Note:** Version bump only for package @tiptap/react
17
-
18
-
19
-
20
-
21
-
22
- # [2.0.0-beta.9](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/react@2.0.0-beta.8...@tiptap/react@2.0.0-beta.9) (2021-03-31)
23
-
24
- **Note:** Version bump only for package @tiptap/react
25
-
26
-
27
-
28
-
29
-
30
- # [2.0.0-beta.8](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/react@2.0.0-beta.7...@tiptap/react@2.0.0-beta.8) (2021-03-31)
31
-
32
- **Note:** Version bump only for package @tiptap/react
33
-
34
-
35
-
36
-
37
-
38
- # [2.0.0-beta.7](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/react@2.0.0-beta.6...@tiptap/react@2.0.0-beta.7) (2021-03-31)
39
-
40
- **Note:** Version bump only for package @tiptap/react
41
-
42
-
43
-
44
-
45
-
46
- # [2.0.0-beta.6](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/react@2.0.0-beta.5...@tiptap/react@2.0.0-beta.6) (2021-03-28)
47
-
48
- **Note:** Version bump only for package @tiptap/react
49
-
50
-
51
-
52
-
53
-
54
- # [2.0.0-beta.5](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/react@2.0.0-beta.4...@tiptap/react@2.0.0-beta.5) (2021-03-24)
55
-
56
- **Note:** Version bump only for package @tiptap/react
57
-
58
-
59
-
60
-
61
-
62
- # [2.0.0-beta.4](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/react@2.0.0-beta.3...@tiptap/react@2.0.0-beta.4) (2021-03-18)
63
-
64
- **Note:** Version bump only for package @tiptap/react
65
-
66
-
67
-
68
-
69
-
70
- # [2.0.0-beta.3](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/react@2.0.0-beta.2...@tiptap/react@2.0.0-beta.3) (2021-03-16)
71
-
72
- **Note:** Version bump only for package @tiptap/react
73
-
74
-
75
-
76
-
77
-
78
- # [2.0.0-beta.2](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/react@2.0.0-beta.1...@tiptap/react@2.0.0-beta.2) (2021-03-09)
79
-
80
- **Note:** Version bump only for package @tiptap/react
81
-
82
-
83
-
84
-
85
-
86
- # [2.0.0-beta.1](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/react@2.0.0-alpha.2...@tiptap/react@2.0.0-beta.1) (2021-03-05)
87
-
88
- **Note:** Version bump only for package @tiptap/react
89
-
90
-
91
-
92
-
93
-
94
- # 2.0.0-alpha.2 (2021-02-26)
95
-
96
- **Note:** Version bump only for package @tiptap/react