forked from github/plane
removed shadow, added alert if not saved and ts errors
This commit is contained in:
parent
fccad32ecf
commit
ab6bf6aba0
@ -69,11 +69,13 @@ export const IssueDescriptionForm: FC<IssueDetailsProps> = ({
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isSubmitting === "submitted") {
|
if (isSubmitting === "submitted") {
|
||||||
|
setShowAlert(false);
|
||||||
setTimeout(async () => {
|
setTimeout(async () => {
|
||||||
setIsSubmitting("saved");
|
setIsSubmitting("saved");
|
||||||
}, 2000);
|
}, 2000);
|
||||||
}
|
}
|
||||||
}, [isSubmitting]);
|
}, [isSubmitting, setShowAlert]);
|
||||||
|
|
||||||
|
|
||||||
// reset form values
|
// reset form values
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -112,9 +114,8 @@ export const IssueDescriptionForm: FC<IssueDetailsProps> = ({
|
|||||||
{characterLimit && (
|
{characterLimit && (
|
||||||
<div className="pointer-events-none absolute bottom-1 right-1 z-[2] rounded bg-custom-background-100 text-custom-text-200 p-0.5 text-xs">
|
<div className="pointer-events-none absolute bottom-1 right-1 z-[2] rounded bg-custom-background-100 text-custom-text-200 p-0.5 text-xs">
|
||||||
<span
|
<span
|
||||||
className={`${
|
className={`${watch("name").length === 0 || watch("name").length > 255 ? "text-red-500" : ""
|
||||||
watch("name").length === 0 || watch("name").length > 255 ? "text-red-500" : ""
|
}`}
|
||||||
}`}
|
|
||||||
>
|
>
|
||||||
{watch("name").length}
|
{watch("name").length}
|
||||||
</span>
|
</span>
|
||||||
@ -134,16 +135,18 @@ export const IssueDescriptionForm: FC<IssueDetailsProps> = ({
|
|||||||
<Tiptap
|
<Tiptap
|
||||||
value={
|
value={
|
||||||
!value ||
|
!value ||
|
||||||
value === "" ||
|
value === "" ||
|
||||||
(typeof value === "object" && Object.keys(value).length === 0)
|
(typeof value === "object" && Object.keys(value).length === 0)
|
||||||
? watch("description_html")
|
? watch("description_html")
|
||||||
: value
|
: value
|
||||||
}
|
}
|
||||||
debouncedUpdatesEnabled={true}
|
debouncedUpdatesEnabled={true}
|
||||||
|
setShouldShowAlert={setShowAlert}
|
||||||
setIsSubmitting={setIsSubmitting}
|
setIsSubmitting={setIsSubmitting}
|
||||||
customClassName="min-h-[150px]"
|
customClassName="min-h-[150px]"
|
||||||
editorContentCustomClassNames="pb-9"
|
editorContentCustomClassNames="pb-9"
|
||||||
onChange={(description: Object, description_html: string) => {
|
onChange={(description: Object, description_html: string) => {
|
||||||
|
setShowAlert(true);
|
||||||
setIsSubmitting("submitting");
|
setIsSubmitting("submitting");
|
||||||
onChange(description_html);
|
onChange(description_html);
|
||||||
setValue("description", description);
|
setValue("description", description);
|
||||||
@ -156,9 +159,8 @@ export const IssueDescriptionForm: FC<IssueDetailsProps> = ({
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<div
|
<div
|
||||||
className={`absolute right-5 bottom-5 text-xs text-custom-text-200 border border-custom-border-400 rounded-xl w-[6.5rem] py-1 z-10 flex items-center justify-center ${
|
className={`absolute right-5 bottom-5 text-xs text-custom-text-200 border border-custom-border-400 rounded-xl w-[6.5rem] py-1 z-10 flex items-center justify-center ${isSubmitting === "saved" ? "fadeOut" : "fadeIn"
|
||||||
isSubmitting === "saved" ? "fadeOut" : "fadeIn"
|
}`}
|
||||||
}`}
|
|
||||||
>
|
>
|
||||||
{isSubmitting === "submitting" ? "Saving..." : "Saved"}
|
{isSubmitting === "submitting" ? "Saving..." : "Saved"}
|
||||||
</div>
|
</div>
|
||||||
|
@ -12,7 +12,7 @@ export const ImageResizer = ({ editor }: { editor: Editor }) => {
|
|||||||
src: imageInfo.src,
|
src: imageInfo.src,
|
||||||
width: Number(imageInfo.style.width.replace("px", "")),
|
width: Number(imageInfo.style.width.replace("px", "")),
|
||||||
height: Number(imageInfo.style.height.replace("px", "")),
|
height: Number(imageInfo.style.height.replace("px", "")),
|
||||||
});
|
} as any);
|
||||||
editor.commands.setNodeSelection(selection.from);
|
editor.commands.setNodeSelection(selection.from);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -23,46 +23,30 @@ export const ImageResizer = ({ editor }: { editor: Editor }) => {
|
|||||||
target={document.querySelector(".ProseMirror-selectednode") as any}
|
target={document.querySelector(".ProseMirror-selectednode") as any}
|
||||||
container={null}
|
container={null}
|
||||||
origin={false}
|
origin={false}
|
||||||
/* Resize event edges */
|
|
||||||
edge={false}
|
edge={false}
|
||||||
throttleDrag={0}
|
throttleDrag={0}
|
||||||
/* When resize or scale, keeps a ratio of the width, height. */
|
|
||||||
keepRatio={true}
|
keepRatio={true}
|
||||||
/* resizable*/
|
|
||||||
/* Only one of resizable, scalable, warpable can be used. */
|
|
||||||
resizable={true}
|
resizable={true}
|
||||||
throttleResize={0}
|
throttleResize={0}
|
||||||
onResize={({
|
onResize={({
|
||||||
target,
|
target,
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
// dist,
|
|
||||||
delta,
|
delta,
|
||||||
}: // direction,
|
}:
|
||||||
// clientX,
|
|
||||||
// clientY,
|
|
||||||
any) => {
|
any) => {
|
||||||
delta[0] && (target!.style.width = `${width}px`);
|
delta[0] && (target!.style.width = `${width}px`);
|
||||||
delta[1] && (target!.style.height = `${height}px`);
|
delta[1] && (target!.style.height = `${height}px`);
|
||||||
}}
|
}}
|
||||||
// { target, isDrag, clientX, clientY }: any
|
|
||||||
onResizeEnd={() => {
|
onResizeEnd={() => {
|
||||||
updateMediaSize();
|
updateMediaSize();
|
||||||
}}
|
}}
|
||||||
/* scalable */
|
|
||||||
/* Only one of resizable, scalable, warpable can be used. */
|
|
||||||
scalable={true}
|
scalable={true}
|
||||||
throttleScale={0}
|
|
||||||
/* Set the direction of resizable */
|
|
||||||
renderDirections={["w", "e"]}
|
renderDirections={["w", "e"]}
|
||||||
onScale={({
|
onScale={({
|
||||||
target,
|
target,
|
||||||
// scale,
|
|
||||||
// dist,
|
|
||||||
// delta,
|
|
||||||
transform,
|
transform,
|
||||||
}: // clientX,
|
}:
|
||||||
// clientY,
|
|
||||||
any) => {
|
any) => {
|
||||||
target!.style.transform = transform;
|
target!.style.transform = transform;
|
||||||
}}
|
}}
|
||||||
|
@ -19,6 +19,7 @@ export interface ITiptapRichTextEditor {
|
|||||||
editorContentCustomClassNames?: string;
|
editorContentCustomClassNames?: string;
|
||||||
onChange?: (json: any, html: string) => void;
|
onChange?: (json: any, html: string) => void;
|
||||||
setIsSubmitting?: (isSubmitting: "submitting" | "submitted" | "saved") => void;
|
setIsSubmitting?: (isSubmitting: "submitting" | "submitted" | "saved") => void;
|
||||||
|
setShouldShowAlert?: (showAlert: boolean) => void;
|
||||||
editable?: boolean;
|
editable?: boolean;
|
||||||
forwardedRef?: any;
|
forwardedRef?: any;
|
||||||
debouncedUpdatesEnabled?: boolean;
|
debouncedUpdatesEnabled?: boolean;
|
||||||
@ -31,6 +32,7 @@ const Tiptap = (props: ITiptapRichTextEditor) => {
|
|||||||
forwardedRef,
|
forwardedRef,
|
||||||
editable,
|
editable,
|
||||||
setIsSubmitting,
|
setIsSubmitting,
|
||||||
|
setShouldShowAlert,
|
||||||
editorContentCustomClassNames,
|
editorContentCustomClassNames,
|
||||||
value,
|
value,
|
||||||
noBorder,
|
noBorder,
|
||||||
@ -46,6 +48,7 @@ const Tiptap = (props: ITiptapRichTextEditor) => {
|
|||||||
onUpdate: async ({ editor }) => {
|
onUpdate: async ({ editor }) => {
|
||||||
// for instant feedback loop
|
// for instant feedback loop
|
||||||
setIsSubmitting?.("submitting");
|
setIsSubmitting?.("submitting");
|
||||||
|
setShouldShowAlert?.(true);
|
||||||
checkForNodeDeletions(editor);
|
checkForNodeDeletions(editor);
|
||||||
if (debouncedUpdatesEnabled) {
|
if (debouncedUpdatesEnabled) {
|
||||||
debouncedUpdates({ onChange, editor });
|
debouncedUpdates({ onChange, editor });
|
||||||
@ -113,7 +116,7 @@ const Tiptap = (props: ITiptapRichTextEditor) => {
|
|||||||
}, 500);
|
}, 500);
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
||||||
const editorClassNames = `relative w-full max-w-screen-lg sm:rounded-lg sm:shadow-lg mt-2 p-3 relative focus:outline-none rounded-md
|
const editorClassNames = `relative w-full max-w-screen-lg sm:rounded-lg mt-2 p-3 relative focus:outline-none rounded-md
|
||||||
${noBorder ? "" : "border border-custom-border-200"} ${borderOnFocus ? "focus:border border-custom-border-300" : "focus:border-0"
|
${noBorder ? "" : "border border-custom-border-200"} ${borderOnFocus ? "focus:border border-custom-border-300" : "focus:border-0"
|
||||||
} ${customClassName}`;
|
} ${customClassName}`;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user