Compare commits

...

32 Commits

Author SHA1 Message Date
Palanikannan M 99bd9702e0 Merge branch 'preview' into chore/upgrade-editor 2024-10-21 17:01:45 +05:30
Palanikannan M 65bc63093a fix: editor content check added 2024-10-07 19:54:40 +05:30
Palanikannan M 1ab86d8935 fix: upgraded editor packages 2024-10-07 12:51:45 +05:30
Palanikannan M ce74c6693e Merge branch 'preview' into chore/upgrade-editor 2024-10-04 20:52:14 +05:30
Palanikannan M 5f1f75b6d6 chore: upgrade packages 2024-09-16 13:18:29 +05:30
Palanikannan M 5c27a726bb chore: remove console logs 2024-09-16 13:15:06 +05:30
Palanikannan M e297f7f98f fix: drop upload fixed 2024-09-16 12:51:41 +05:30
Palanikannan M 8b9418d8fa fix: old images not rendered as new ones 2024-09-16 12:25:58 +05:30
Palanikannan M 78b1c50a7d fix: editor readonly content set properly 2024-09-13 21:11:37 +05:30
Palanikannan M fa5cfd5fc3 fix: fixed multi time file opener 2024-09-13 21:09:08 +05:30
Palanikannan M 2e1745e905 chore: remove file handler 2024-09-13 16:25:33 +05:30
Aaryan Khandelwal 5a9548680f style: read-only image 2024-09-13 16:14:30 +05:30
Aaryan Khandelwal f8d85fd633 refactor: custom image extension folder structure 2024-09-13 15:50:26 +05:30
Aaryan Khandelwal 2583038b0a style: image selected and hover states 2024-09-13 15:12:10 +05:30
Palanikannan M 47cf78e4f6 fix: css image css 2024-09-13 14:34:52 +05:30
Palanikannan M 2502d5144d fix: reverted back document info changes 2024-09-13 14:24:55 +05:30
Palanikannan M c0fb56c71b fix: reverted back styles 2024-09-13 14:23:14 +05:30
Palanikannan M 47542b69ce Merge branch 'feat/custom-image-component' into fix/image-upload-realtime 2024-09-13 14:16:23 +05:30
Palanikannan M 1e014d7c0e feat: custom image component editor 2024-09-13 14:12:45 +05:30
Palanikannan M b200b3382a fix: drag drop menu 2024-09-12 21:18:45 +05:30
Palanikannan M 4b61f9b541 fix: resize image real time sync 2024-09-12 17:04:11 +05:30
Palanikannan M d8308cfce4 fix: image insertion at pos and loading effect added 2024-09-12 16:26:46 +05:30
Palanikannan M 56a0b9f236 fix: types of updateAttributes 2024-09-12 15:15:02 +05:30
Palanikannan M d5a1d4e26a fix: removed unused stuff 2024-09-12 15:09:22 +05:30
Aaryan Khandelwal 8eaf6ed0de style: image resize handler 2024-09-12 13:57:45 +05:30
Aaryan Khandelwal f080e3f098 style: image drop node 2024-09-12 13:35:04 +05:30
Palanikannan M bd5482afef fix: type errors 2024-09-12 12:58:49 +05:30
Palanikannan M 3d81be7da8 fix: added new image extension to backend 2024-09-11 21:17:54 +05:30
Palanikannan M 5db937cbf7 fix: combine two extensions 2024-09-11 20:46:25 +05:30
Palanikannan M 7ebd714e2a feat: add custom image node for uploads 2024-09-11 19:20:55 +05:30
Palanikannan M f71ca5802f fix: svg image file error message fixed 2024-09-09 20:27:02 +05:30
Palanikannan M 16be6ff37d fix: svg not supported in image uploads 2024-09-09 16:02:14 +05:30
6 changed files with 777 additions and 970 deletions
+22 -22
View File
@@ -36,41 +36,41 @@
},
"dependencies": {
"@floating-ui/react": "^0.26.4",
"@hocuspocus/provider": "^2.13.5",
"@hocuspocus/provider": "^2.13.6",
"@plane/ui": "*",
"@tiptap/core": "^2.1.13",
"@tiptap/extension-blockquote": "^2.1.13",
"@tiptap/extension-character-count": "^2.6.5",
"@tiptap/extension-collaboration": "^2.3.2",
"@tiptap/extension-image": "^2.1.13",
"@tiptap/extension-list-item": "^2.1.13",
"@tiptap/extension-mention": "^2.1.13",
"@tiptap/extension-placeholder": "^2.3.0",
"@tiptap/extension-task-item": "^2.1.13",
"@tiptap/extension-task-list": "^2.1.13",
"@tiptap/extension-text-style": "^2.7.1",
"@tiptap/extension-underline": "^2.1.13",
"@tiptap/pm": "^2.1.13",
"@tiptap/react": "^2.1.13",
"@tiptap/starter-kit": "^2.1.13",
"@tiptap/suggestion": "^2.0.13",
"@tiptap/core": "^2.8.0",
"@tiptap/extension-blockquote": "^2.8.0",
"@tiptap/extension-character-count": "^2.8.0",
"@tiptap/extension-collaboration": "^2.8.0",
"@tiptap/extension-image": "^2.8.0",
"@tiptap/extension-list-item": "^2.8.0",
"@tiptap/extension-mention": "^2.8.0",
"@tiptap/extension-placeholder": "^2.8.0",
"@tiptap/extension-task-item": "^2.8.0",
"@tiptap/extension-task-list": "^2.8.0",
"@tiptap/extension-text-style": "^2.8.0",
"@tiptap/extension-underline": "^2.8.0",
"@tiptap/pm": "^2.8.0",
"@tiptap/react": "^2.8.0",
"@tiptap/starter-kit": "^2.8.0",
"@tiptap/suggestion": "^2.8.0",
"class-variance-authority": "^0.7.0",
"clsx": "^1.2.1",
"highlight.js": "^11.8.0",
"jsx-dom-cjs": "^8.0.3",
"linkifyjs": "^4.1.3",
"lowlight": "^3.0.0",
"lucide-react": "^0.378.0",
"lowlight": "^3.1.0",
"lucide-react": "^0.439.0",
"prosemirror-codemark": "^0.4.2",
"react-moveable": "^0.54.2",
"tailwind-merge": "^1.14.0",
"tippy.js": "^6.3.7",
"tiptap-markdown": "^0.8.9",
"tiptap-markdown": "^0.8.10",
"uuid": "^10.0.0",
"y-indexeddb": "^9.0.12",
"y-prosemirror": "^1.2.5",
"y-prosemirror": "^1.2.12",
"y-protocols": "^1.0.6",
"yjs": "^13.6.15"
"yjs": "^13.6.18"
},
"devDependencies": {
"@plane/eslint-config": "*",
@@ -1,3 +1,4 @@
import { HocuspocusProvider } from "@hocuspocus/provider";
import CharacterCount from "@tiptap/extension-character-count";
import Placeholder from "@tiptap/extension-placeholder";
import TaskItem from "@tiptap/extension-task-item";
@@ -1,4 +1,7 @@
import ImageExt from "@tiptap/extension-image";
import { ReactNodeViewRenderer } from "@tiptap/react";
// extensions
import { CustomImageNode } from "@/extensions";
export const ImageExtensionWithoutProps = () =>
ImageExt.extend({
@@ -16,4 +19,8 @@ export const ImageExtensionWithoutProps = () =>
},
};
},
addNodeView() {
return ReactNodeViewRenderer(CustomImageNode);
},
});
@@ -66,6 +66,21 @@ export const useEditor = (props: CustomEditorProps) => {
const editorRef: MutableRefObject<Editor | null> = useRef(null);
const savedSelectionRef = useRef(savedSelection);
const editor = useTiptapEditor({
immediatelyRender: true,
shouldRerenderOnTransaction: false,
enableContentCheck: true,
onContentError({ editor, error, disableCollaboration }) {
// Disable collaboration to prevent syncing invalid content
disableCollaboration();
// Prevent emitting updates
const emitUpdate = false;
// Disable further user input
editor.setEditable(false, emitUpdate);
console.log("onContentError", error);
},
editorProps: {
...CoreEditorProps({
editorClassName,
@@ -45,11 +45,31 @@ export const nodeDOMAtCoords = (coords: { x: number; y: number }) => {
".image-upload-component",
].join(", ");
const hasNestedImg = (el: Element): boolean => {
if (el.tagName.toLowerCase() === "img") return true;
// @ts-expect-error todo
for (const child of el.children) {
if (hasNestedImg(child)) return true;
}
return false;
};
for (const elem of elements) {
const elemHasNestedImg = hasNestedImg(elem);
if (elem.matches("p:first-child") && elem.parentElement?.matches(".ProseMirror")) {
return elem;
}
// if the element is a <p> tag and has a nested img i.e. the new image
// component
if (elem.matches("p") && elemHasNestedImg) {
return null;
}
if (elem.matches("div") && elemHasNestedImg) {
return elem;
}
// if the element is a <p> tag that is the first child of a td or th
if (
(elem.matches("td > p:first-child") || elem.matches("th > p:first-child")) &&
+712 -948
View File
File diff suppressed because it is too large Load Diff