forked from github/plane
1e152c666c
* chore: moved app & space from apps to root * chore: modified workspace configuration * chore: modified dockerfiles for space and web * chore: modified icons for space * feat: updated files for new svg icons supported by next-images * chore: added /spaces base path for next * chore: added compose config for space * chore: updated husky configuration * chore: updated workflows for new configuration * chore: changed app name to web * fix: resolved build errors with web * chore: reset file tracing root for both projects * chore: added nginx config for deploy * fix: eslint and tsconfig settings for space app * husky setup fixes based on new dir * eslint fixes * prettier formatting --------- Co-authored-by: Henit Chobisa <chobisa.henit@gmail.com>
51 lines
1.8 KiB
TypeScript
51 lines
1.8 KiB
TypeScript
import { EditorProps } from "@tiptap/pm/view";
|
|
import { startImageUpload } from "./plugins/upload-image";
|
|
|
|
export function TiptapEditorProps(
|
|
workspaceSlug: string,
|
|
setIsSubmitting?: (isSubmitting: "submitting" | "submitted" | "saved") => void
|
|
): EditorProps {
|
|
return {
|
|
attributes: {
|
|
class: `prose prose-brand max-w-full prose-headings:font-display font-default focus:outline-none`,
|
|
},
|
|
handleDOMEvents: {
|
|
keydown: (_view, event) => {
|
|
// prevent default event listeners from firing when slash command is active
|
|
if (["ArrowUp", "ArrowDown", "Enter"].includes(event.key)) {
|
|
const slashCommand = document.querySelector("#slash-command");
|
|
if (slashCommand) {
|
|
return true;
|
|
}
|
|
}
|
|
},
|
|
},
|
|
handlePaste: (view, event) => {
|
|
if (event.clipboardData && event.clipboardData.files && event.clipboardData.files[0]) {
|
|
event.preventDefault();
|
|
const file = event.clipboardData.files[0];
|
|
const pos = view.state.selection.from;
|
|
startImageUpload(file, view, pos, workspaceSlug, setIsSubmitting);
|
|
return true;
|
|
}
|
|
return false;
|
|
},
|
|
handleDrop: (view, event, _slice, moved) => {
|
|
if (!moved && event.dataTransfer && event.dataTransfer.files && event.dataTransfer.files[0]) {
|
|
event.preventDefault();
|
|
const file = event.dataTransfer.files[0];
|
|
const coordinates = view.posAtCoords({
|
|
left: event.clientX,
|
|
top: event.clientY,
|
|
});
|
|
// here we deduct 1 from the pos or else the image will create an extra node
|
|
if (coordinates) {
|
|
startImageUpload(file, view, coordinates.pos - 1, workspaceSlug, setIsSubmitting);
|
|
}
|
|
return true;
|
|
}
|
|
return false;
|
|
},
|
|
};
|
|
}
|