Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 13 additions & 27 deletions apps/space/helpers/editor.helper.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// plane imports
import { MAX_FILE_SIZE } from "@plane/constants";
import { TFileHandler, TReadOnlyFileHandler } from "@plane/editor";
import { TFileHandler } from "@plane/editor";
import { SitesFileService } from "@plane/services";
import { getFileURL } from "@plane/utils";
// services
Expand All @@ -22,10 +22,11 @@ type TArgs = {
};

/**
* @description this function returns the file handler required by the read-only editors
* @description this function returns the file handler required by the editors
* @param {TArgs} args
*/
export const getReadOnlyEditorFileHandlers = (args: Pick<TArgs, "anchor" | "workspaceId">): TReadOnlyFileHandler => {
const { anchor, workspaceId } = args;
export const getEditorFileHandlers = (args: TArgs): TFileHandler => {
const { anchor, uploadFile, workspaceId } = args;

const getAssetSrc = async (path: string) => {
if (!path) return "";
Expand All @@ -38,31 +39,9 @@ export const getReadOnlyEditorFileHandlers = (args: Pick<TArgs, "anchor" | "work

return {
checkIfAssetExists: async () => true,
assetsUploadStatus: {},
getAssetDownloadSrc: getAssetSrc,
getAssetSrc: getAssetSrc,
restore: async (src: string) => {
if (src?.startsWith("http")) {
await sitesFileService.restoreOldEditorAsset(workspaceId, src);
} else {
await sitesFileService.restoreNewAsset(anchor, src);
}
},
};
};

/**
* @description this function returns the file handler required by the editors
* @param {TArgs} args
*/
export const getEditorFileHandlers = (args: TArgs): TFileHandler => {
const { anchor, uploadFile, workspaceId } = args;

return {
...getReadOnlyEditorFileHandlers({
anchor,
workspaceId,
}),
assetsUploadStatus: {},
upload: uploadFile,
delete: async (src: string) => {
if (src?.startsWith("http")) {
Expand All @@ -72,6 +51,13 @@ export const getEditorFileHandlers = (args: TArgs): TFileHandler => {
}
},
cancel: sitesFileService.cancelUpload,
restore: async (src: string) => {
if (src?.startsWith("http")) {
await sitesFileService.restoreOldEditorAsset(workspaceId, src);
} else {
await sitesFileService.restoreNewAsset(anchor, src);
}
},
validation: {
maxFileSize: MAX_FILE_SIZE,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ import {
stripAndTruncateHTML,
} from "@plane/utils";
// components
// helpers
import { LiteTextReadOnlyEditor } from "@/components/editor";
import { LiteTextEditor } from "@/components/editor/lite-text";

export const NotificationContent: FC<{
notification: TNotification;
Expand Down Expand Up @@ -100,7 +99,8 @@ export const NotificationContent: FC<{
<span className="text-custom-text-100 font-medium">{renderValue()}</span>
{notificationField === "comment" && renderCommentBox && (
<div className="scale-75 origin-left">
<LiteTextReadOnlyEditor
<LiteTextEditor
editable={false}
id=""
initialValue={newValue ?? ""}
workspaceId={workspaceId}
Expand Down
Loading