Skip to content

Commit e110ef5

Browse files
aaryan610Palanikannan1437sriramveeraghanta
authored
[WIKI-569] chore: migrate to tiptap v3 (#7526)
* chore: upgrade to tiptap v3 * chore: update starter kit * chore: tippy to floating-ui migration for mentions * chore: update remaining floating menus * chore: update setEditorValue function * fix: potential bugs * chore: extract out common floating ui positioning logic * fix: storage api * fix: bubble menu * fix: type errors * fix: type errors * chore: upgrade tiptap-markdown package * fix: mentions close callback * chore: update bubbling sequence * chore: update package.json * chore: update tiptap catalogs * fix: add error handling * fix: file plugin types * chore: update live package.json * fix: broken lock file --------- Co-authored-by: Palanikannan M <[email protected]> Co-authored-by: sriramveeraghanta <[email protected]>
1 parent 5951372 commit e110ef5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+1303
-1601
lines changed

apps/live/package.json

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
"@plane/editor": "workspace:*",
3030
"@plane/logger": "workspace:*",
3131
"@plane/types": "workspace:*",
32-
"@tiptap/core": "^2.22.3",
33-
"@tiptap/html": "^2.22.3",
32+
"@tiptap/core": "catalog:",
33+
"@tiptap/html": "catalog:",
3434
"axios": "catalog:",
3535
"compression": "1.8.1",
3636
"cors": "^2.8.5",
@@ -43,7 +43,8 @@
4343
"pino-http": "^10.3.0",
4444
"pino-pretty": "^11.2.2",
4545
"uuid": "catalog:",
46-
"y-prosemirror": "^1.2.15",
46+
"ws": "^8.18.3",
47+
"y-prosemirror": "^1.3.7",
4748
"y-protocols": "^1.0.6",
4849
"yjs": "^13.6.20",
4950
"zod": "^3.25.76"
@@ -59,11 +60,7 @@
5960
"@types/pino-http": "^5.8.4",
6061
"@types/uuid": "^9.0.1",
6162
"@types/ws": "^8.18.1",
62-
"concurrently": "^9.0.1",
63-
"nodemon": "^3.1.7",
64-
"ts-node": "^10.9.2",
6563
"tsdown": "catalog:",
66-
"typescript": "catalog:",
67-
"ws": "^8.18.3"
64+
"typescript": "catalog:"
6865
}
6966
}

apps/web/ce/hooks/use-editor-flagging.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export type TEditorFlaggingHookProps = {
2525
/**
2626
* @description extensions disabled in various editors
2727
*/
28-
export const useEditorFlagging = (props: TEditorFlaggingHookProps): TEditorFlaggingHookReturnType => ({
28+
export const useEditorFlagging = (_props: TEditorFlaggingHookProps): TEditorFlaggingHookReturnType => ({
2929
document: {
3030
disabled: ["ai", "collaboration-cursor"],
3131
flagged: [],

packages/editor/package.json

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"./styles": "./dist/styles/index.css"
2424
},
2525
"scripts": {
26-
"build": "tsdown",
26+
"build": "tsc && tsdown",
2727
"dev": "tsdown --watch",
2828
"check:lint": "eslint . --max-warnings 30",
2929
"check:types": "tsc --noEmit",
@@ -46,25 +46,23 @@
4646
"@plane/types": "workspace:*",
4747
"@plane/ui": "workspace:*",
4848
"@plane/utils": "workspace:*",
49-
"@tiptap/core": "^2.22.3",
50-
"@tiptap/extension-blockquote": "^2.22.3",
51-
"@tiptap/extension-character-count": "^2.22.3",
52-
"@tiptap/extension-collaboration": "^2.22.3",
53-
"@tiptap/extension-emoji": "^2.22.3",
54-
"@tiptap/extension-image": "^2.22.3",
55-
"@tiptap/extension-list-item": "^2.22.3",
56-
"@tiptap/extension-mention": "^2.22.3",
57-
"@tiptap/extension-placeholder": "^2.22.3",
58-
"@tiptap/extension-task-item": "^2.22.3",
59-
"@tiptap/extension-task-list": "^2.22.3",
60-
"@tiptap/extension-text-align": "^2.22.3",
61-
"@tiptap/extension-text-style": "^2.22.3",
62-
"@tiptap/extension-underline": "^2.22.3",
63-
"@tiptap/html": "^2.22.3",
64-
"@tiptap/pm": "^2.22.3",
65-
"@tiptap/react": "^2.22.3",
66-
"@tiptap/starter-kit": "^2.22.3",
67-
"@tiptap/suggestion": "^2.22.3",
49+
"@tiptap/core": "catalog:",
50+
"@tiptap/extension-blockquote": "^3.5.3",
51+
"@tiptap/extension-collaboration": "^3.5.3",
52+
"@tiptap/extension-emoji": "^3.5.3",
53+
"@tiptap/extension-image": "^3.5.3",
54+
"@tiptap/extension-list-item": "^3.5.3",
55+
"@tiptap/extension-mention": "^3.5.3",
56+
"@tiptap/extension-task-item": "^3.5.3",
57+
"@tiptap/extension-task-list": "^3.5.3",
58+
"@tiptap/extension-text-align": "^3.5.3",
59+
"@tiptap/extension-text-style": "^3.5.3",
60+
"@tiptap/extensions": "^3.5.3",
61+
"@tiptap/html": "catalog:",
62+
"@tiptap/pm": "^3.5.3",
63+
"@tiptap/react": "^3.5.3",
64+
"@tiptap/starter-kit": "^3.5.3",
65+
"@tiptap/suggestion": "^3.5.3",
6866
"emoji-regex": "^10.3.0",
6967
"highlight.js": "^11.8.0",
7068
"is-emoji-supported": "^0.0.5",
@@ -74,7 +72,7 @@
7472
"lucide-react": "catalog:",
7573
"prosemirror-codemark": "^0.4.2",
7674
"tippy.js": "^6.3.7",
77-
"tiptap-markdown": "^0.8.10",
75+
"tiptap-markdown": "^0.9.0",
7876
"uuid": "catalog:",
7977
"y-indexeddb": "^9.0.12",
8078
"y-prosemirror": "^1.2.15",
@@ -88,6 +86,7 @@
8886
"@types/node": "18.15.3",
8987
"@types/react": "catalog:",
9088
"@types/react-dom": "catalog:",
89+
"@types/uuid": "^8.3.4",
9190
"postcss": "^8.4.38",
9291
"tsdown": "catalog:",
9392
"typescript": "catalog:"
Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
1-
import { ExtensionFileSetStorageKey } from "@/plane-editor/types/storage";
1+
// plane imports
2+
import { ADDITIONAL_EXTENSIONS, CORE_EXTENSIONS } from "@plane/utils";
3+
// plane editor imports
4+
import type { ExtensionFileSetStorageKey } from "@/plane-editor/types/storage";
25

3-
export const NODE_FILE_MAP: {
4-
[key: string]: {
5-
fileSetName: ExtensionFileSetStorageKey;
6-
};
7-
} = {
8-
image: {
6+
export type NodeFileMapType = Partial<
7+
Record<
8+
CORE_EXTENSIONS | ADDITIONAL_EXTENSIONS,
9+
{
10+
fileSetName: ExtensionFileSetStorageKey;
11+
}
12+
>
13+
>;
14+
15+
export const NODE_FILE_MAP: NodeFileMapType = {
16+
[CORE_EXTENSIONS.IMAGE]: {
917
fileSetName: "deletedImageSet",
1018
},
11-
imageComponent: {
19+
[CORE_EXTENSIONS.CUSTOM_IMAGE]: {
1220
fileSetName: "deletedImageSet",
1321
},
1422
};
Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,4 @@
1-
import { CharacterCountStorage } from "@tiptap/extension-character-count";
2-
// constants
3-
import type { EmojiStorage } from "@tiptap/extension-emoji";
4-
import { CORE_EXTENSIONS } from "@/constants/extension";
51
// extensions
6-
import type { HeadingExtensionStorage } from "@/extensions";
7-
import type { CustomImageExtensionStorage } from "@/extensions/custom-image/types";
8-
import type { CustomLinkStorage } from "@/extensions/custom-link";
92
import type { ImageExtensionStorage } from "@/extensions/image";
10-
import type { UtilityExtensionStorage } from "@/extensions/utility";
11-
12-
export type ExtensionStorageMap = {
13-
[CORE_EXTENSIONS.CUSTOM_IMAGE]: CustomImageExtensionStorage;
14-
[CORE_EXTENSIONS.IMAGE]: ImageExtensionStorage;
15-
[CORE_EXTENSIONS.CUSTOM_LINK]: CustomLinkStorage;
16-
[CORE_EXTENSIONS.HEADINGS_LIST]: HeadingExtensionStorage;
17-
[CORE_EXTENSIONS.UTILITY]: UtilityExtensionStorage;
18-
[CORE_EXTENSIONS.EMOJI]: EmojiStorage;
19-
[CORE_EXTENSIONS.CHARACTER_COUNT]: CharacterCountStorage;
20-
};
213

224
export type ExtensionFileSetStorageKey = Extract<keyof ImageExtensionStorage, "deletedImageSet">;

packages/editor/src/core/components/editors/link-view-container.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ import { FC, useCallback, useEffect, useRef, useState } from "react";
44

55
// components
66
import { LinkView, LinkViewProps } from "@/components/links";
7-
import { CORE_EXTENSIONS } from "@/constants/extension";
8-
// components
9-
import { getExtensionStorage } from "@/helpers/get-extension-storage";
107

118
type Props = {
129
editor: Editor;
@@ -22,7 +19,7 @@ export const LinkViewContainer: FC<Props> = ({ editor, containerRef }) => {
2219
const editorState = useEditorState({
2320
editor,
2421
selector: ({ editor }: { editor: Editor }) => ({
25-
linkExtensionStorage: getExtensionStorage(editor, CORE_EXTENSIONS.CUSTOM_LINK),
22+
linkExtensionStorage: editor.storage.link,
2623
}),
2724
});
2825

packages/editor/src/core/components/menus/ai-menu.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { useCallback, useEffect, useRef, useState } from "react";
2-
import tippy, { Instance } from "tippy.js";
2+
import tippy, { type Instance } from "tippy.js";
33
// plane utils
44
import { cn } from "@plane/utils";
55
// types
6-
import { TAIHandler } from "@/types";
6+
import type { TAIHandler } from "@/types";
77

88
type Props = {
99
menu: TAIHandler["menu"];

packages/editor/src/core/components/menus/block-menu.tsx

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
11
import {
22
useFloating,
3+
autoUpdate,
34
offset,
45
flip,
56
shift,
6-
autoUpdate,
77
useDismiss,
88
useInteractions,
99
FloatingPortal,
1010
} from "@floating-ui/react";
1111
import type { Editor } from "@tiptap/react";
1212
import { Copy, LucideIcon, Trash2 } from "lucide-react";
1313
import { useCallback, useEffect, useRef, useState } from "react";
14-
// constants
1514
import { cn } from "@plane/utils";
15+
// constants
1616
import { CORE_EXTENSIONS } from "@/constants/extension";
17-
import { IEditorProps } from "@/types";
17+
// types
18+
import type { IEditorProps } from "@/types";
1819

1920
type Props = {
21+
disabledExtensions?: IEditorProps["disabledExtensions"];
2022
editor: Editor;
2123
flaggedExtensions?: IEditorProps["flaggedExtensions"];
22-
disabledExtensions?: IEditorProps["disabledExtensions"];
2324
};
2425

2526
export const BlockMenu = (props: Props) => {
@@ -74,15 +75,6 @@ export const BlockMenu = (props: Props) => {
7475
// Set the virtual reference as the reference element
7576
refs.setReference(virtualReferenceRef.current);
7677

77-
// Ensure the targeted block is selected
78-
const rect = dragHandle.getBoundingClientRect();
79-
const coords = { left: rect.left + rect.width / 2, top: rect.top + rect.height / 2 };
80-
const posAtCoords = editor.view.posAtCoords(coords);
81-
if (posAtCoords) {
82-
const $pos = editor.state.doc.resolve(posAtCoords.pos);
83-
const nodePos = $pos.before($pos.depth);
84-
editor.chain().setNodeSelection(nodePos).run();
85-
}
8678
// Show the menu
8779
openBlockMenu();
8880
return;
@@ -93,9 +85,10 @@ export const BlockMenu = (props: Props) => {
9385
closeBlockMenu();
9486
}
9587
},
96-
[editor, refs, openBlockMenu, closeBlockMenu]
88+
[refs, openBlockMenu, closeBlockMenu]
9789
);
9890

91+
// Set up event listeners
9992
useEffect(() => {
10093
const handleKeyDown = (event: KeyboardEvent) => {
10194
if (event.key === "Escape") {
@@ -106,10 +99,11 @@ export const BlockMenu = (props: Props) => {
10699
const handleScroll = () => {
107100
closeBlockMenu();
108101
};
102+
109103
document.addEventListener("click", handleClickDragHandle);
110104
document.addEventListener("contextmenu", handleClickDragHandle);
111105
document.addEventListener("keydown", handleKeyDown);
112-
document.addEventListener("scroll", handleScroll, true); // Using capture phase
106+
document.addEventListener("scroll", handleScroll, true);
113107

114108
return () => {
115109
document.removeEventListener("click", handleClickDragHandle);
@@ -200,6 +194,7 @@ export const BlockMenu = (props: Props) => {
200194
if (!isOpen) {
201195
return null;
202196
}
197+
203198
return (
204199
<FloatingPortal>
205200
<div
@@ -209,7 +204,6 @@ export const BlockMenu = (props: Props) => {
209204
}}
210205
style={{
211206
...floatingStyles,
212-
zIndex: 99,
213207
animationFillMode: "forwards",
214208
transitionTimingFunction: "cubic-bezier(0.16, 1, 0.3, 1)", // Expo ease out
215209
}}
@@ -218,13 +212,11 @@ export const BlockMenu = (props: Props) => {
218212
"transition-all duration-300 transform origin-top-right",
219213
isAnimatedIn ? "opacity-100 scale-100" : "opacity-0 scale-75"
220214
)}
221-
data-prevent-outside-click
222215
{...getFloatingProps()}
223216
>
224217
{MENU_ITEMS.map((item) => {
225-
if (item.isDisabled) {
226-
return null;
227-
}
218+
if (item.isDisabled) return null;
219+
228220
return (
229221
<button
230222
key={item.key}

0 commit comments

Comments
 (0)