fix: validation of public and private assets (#5878)
This commit is contained in:
parent
6f8df3279c
commit
c940a2921e
3 changed files with 9 additions and 11 deletions
|
|
@ -248,7 +248,7 @@ export const CustomImageBlock: React.FC<CustomImageBlockProps> = (props) => {
|
|||
try {
|
||||
setHasErroredOnFirstLoad(true);
|
||||
// this is a type error from tiptap, don't remove await until it's fixed
|
||||
await editor?.commands.restoreImage?.(remoteImageSrc);
|
||||
await editor?.commands.restoreImage?.(node.attrs.src);
|
||||
imageRef.current.src = remoteImageSrc;
|
||||
} catch {
|
||||
// if the image failed to even restore, then show the error state
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import { TFileHandler } from "@plane/editor";
|
|||
import { MAX_FILE_SIZE } from "@/constants/common";
|
||||
// helpers
|
||||
import { getFileURL } from "@/helpers/file.helper";
|
||||
import { checkURLValidity } from "@/helpers/string.helper";
|
||||
// services
|
||||
import { FileService } from "@/services/file.service";
|
||||
const fileService = new FileService();
|
||||
|
|
@ -34,7 +33,7 @@ export const getEditorFileHandlers = (args: TArgs): TFileHandler => {
|
|||
return {
|
||||
getAssetSrc: (path) => {
|
||||
if (!path) return "";
|
||||
if (checkURLValidity(path)) {
|
||||
if (path?.startsWith("http")) {
|
||||
return path;
|
||||
} else {
|
||||
return getEditorAssetSrc(anchor, path) ?? "";
|
||||
|
|
@ -42,14 +41,14 @@ export const getEditorFileHandlers = (args: TArgs): TFileHandler => {
|
|||
},
|
||||
upload: uploadFile,
|
||||
delete: async (src: string) => {
|
||||
if (checkURLValidity(src)) {
|
||||
if (src?.startsWith("http")) {
|
||||
await fileService.deleteOldEditorAsset(workspaceId, src);
|
||||
} else {
|
||||
await fileService.deleteNewAsset(getEditorAssetSrc(anchor, src) ?? "");
|
||||
}
|
||||
},
|
||||
restore: async (src: string) => {
|
||||
if (checkURLValidity(src)) {
|
||||
if (src?.startsWith("http")) {
|
||||
await fileService.restoreOldEditorAsset(workspaceId, src);
|
||||
} else {
|
||||
await fileService.restoreNewAsset(anchor, src);
|
||||
|
|
@ -73,7 +72,7 @@ export const getReadOnlyEditorFileHandlers = (
|
|||
return {
|
||||
getAssetSrc: (path) => {
|
||||
if (!path) return "";
|
||||
if (checkURLValidity(path)) {
|
||||
if (path?.startsWith("http")) {
|
||||
return path;
|
||||
} else {
|
||||
return getEditorAssetSrc(anchor, path) ?? "";
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
import { TFileHandler } from "@plane/editor";
|
||||
// helpers
|
||||
import { getBase64Image, getFileURL } from "@/helpers/file.helper";
|
||||
import { checkURLValidity } from "@/helpers/string.helper";
|
||||
// services
|
||||
import { FileService } from "@/services/file.service";
|
||||
const fileService = new FileService();
|
||||
|
|
@ -46,7 +45,7 @@ export const getEditorFileHandlers = (args: TArgs): TFileHandler => {
|
|||
return {
|
||||
getAssetSrc: (path) => {
|
||||
if (!path) return "";
|
||||
if (checkURLValidity(path)) {
|
||||
if (path?.startsWith("http")) {
|
||||
return path;
|
||||
} else {
|
||||
return (
|
||||
|
|
@ -60,7 +59,7 @@ export const getEditorFileHandlers = (args: TArgs): TFileHandler => {
|
|||
},
|
||||
upload: uploadFile,
|
||||
delete: async (src: string) => {
|
||||
if (checkURLValidity(src)) {
|
||||
if (src?.startsWith("http")) {
|
||||
await fileService.deleteOldWorkspaceAsset(workspaceId, src);
|
||||
} else {
|
||||
await fileService.deleteNewAsset(
|
||||
|
|
@ -73,7 +72,7 @@ export const getEditorFileHandlers = (args: TArgs): TFileHandler => {
|
|||
}
|
||||
},
|
||||
restore: async (src: string) => {
|
||||
if (checkURLValidity(src)) {
|
||||
if (src?.startsWith("http")) {
|
||||
await fileService.restoreOldEditorAsset(workspaceId, src);
|
||||
} else {
|
||||
await fileService.restoreNewAsset(workspaceSlug, src);
|
||||
|
|
@ -97,7 +96,7 @@ export const getReadOnlyEditorFileHandlers = (
|
|||
return {
|
||||
getAssetSrc: (path) => {
|
||||
if (!path) return "";
|
||||
if (checkURLValidity(path)) {
|
||||
if (path?.startsWith("http")) {
|
||||
return path;
|
||||
} else {
|
||||
return (
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue