@udecode/plate-media
Advanced tools
Comparing version 36.0.0 to 36.0.10
@@ -50,2 +50,5 @@ import * as _udecode_plate_common from '@udecode/plate-common'; | ||
type EmbedUrlParser = (url: string) => EmbedUrlData | undefined; | ||
declare const parseMediaUrl: (url: string, { urlParsers, }: { | ||
urlParsers: EmbedUrlParser[]; | ||
}) => EmbedUrlData | undefined; | ||
declare const useMediaState: ({ urlParsers, }?: { | ||
@@ -65,3 +68,3 @@ urlParsers?: EmbedUrlParser[] | undefined; | ||
selected: boolean; | ||
url: string; | ||
unsafeUrl: string; | ||
}; | ||
@@ -648,2 +651,2 @@ | ||
export { type AudioPlugin, ELEMENT_AUDIO, ELEMENT_FILE, ELEMENT_IMAGE, ELEMENT_MEDIA, ELEMENT_MEDIA_EMBED, ELEMENT_PLACEHOLDER, ELEMENT_VIDEO, type EmbedUrlData, type EmbedUrlParser, type FilePlugin, FloatingMedia, FloatingMediaEditButton, FloatingMediaUrlInput, Image, type ImagePlugin, type InsertMediaOptions, type MediaPlaceholder, type MediaPlugin, MediaProvider, PlaceholderProvider, PreviewImage, type TAudioElement, type TFileElement, type TImageElement, type TMediaElement, type TMediaEmbedElement, type TPlaceholderElement, type TVideoElement, VIDEO_PROVIDERS, type VideoPlugin, createAudioPlugin, createFilePlugin, createImagePlugin, createMediaEmbedPlugin, createPlaceholderPlugin, createVideoPlugin, floatingMediaActions, floatingMediaSelectors, floatingMediaStore, imagePreviewActions, imagePreviewSelectors, imagePreviewStore, insertAudioPlaceholer, insertFilePlaceholer, insertImage, insertImagePlaceholder, insertMedia, insertMediaEmbed, insertPlaceHolder, insertVideoPlaceholder, isImageUrl, mediaStore, openImagePreView, parseIframeUrl, parseTwitterUrl, parseVideoUrl, type placeholderRule, placeholderStore, type previewItem, setMediaNode, submitFloatingMedia, useFloatingMediaEditButton, useFloatingMediaSelectors, useFloatingMediaUrlInput, useFloatingMediaUrlInputState, useImage, useImagePreview, useImagePreviewSelectors, useImagePreviewState, useMediaController, useMediaControllerDropDownMenu, useMediaControllerState, useMediaState, useMediaStore, useMediaToolbarButton, usePlaceholderElementState, usePlaceholderPopoverState, usePlaceholderStore, usePreviewImage, usePreviewImageState, useScaleInput, useScaleInputState, useZoom, withImage, withImageEmbed, withImageUpload }; | ||
export { type AudioPlugin, ELEMENT_AUDIO, ELEMENT_FILE, ELEMENT_IMAGE, ELEMENT_MEDIA, ELEMENT_MEDIA_EMBED, ELEMENT_PLACEHOLDER, ELEMENT_VIDEO, type EmbedUrlData, type EmbedUrlParser, type FilePlugin, FloatingMedia, FloatingMediaEditButton, FloatingMediaUrlInput, Image, type ImagePlugin, type InsertMediaOptions, type MediaPlaceholder, type MediaPlugin, MediaProvider, PlaceholderProvider, PreviewImage, type TAudioElement, type TFileElement, type TImageElement, type TMediaElement, type TMediaEmbedElement, type TPlaceholderElement, type TVideoElement, VIDEO_PROVIDERS, type VideoPlugin, createAudioPlugin, createFilePlugin, createImagePlugin, createMediaEmbedPlugin, createPlaceholderPlugin, createVideoPlugin, floatingMediaActions, floatingMediaSelectors, floatingMediaStore, imagePreviewActions, imagePreviewSelectors, imagePreviewStore, insertAudioPlaceholer, insertFilePlaceholer, insertImage, insertImagePlaceholder, insertMedia, insertMediaEmbed, insertPlaceHolder, insertVideoPlaceholder, isImageUrl, mediaStore, openImagePreView, parseIframeUrl, parseMediaUrl, parseTwitterUrl, parseVideoUrl, type placeholderRule, placeholderStore, type previewItem, setMediaNode, submitFloatingMedia, useFloatingMediaEditButton, useFloatingMediaSelectors, useFloatingMediaUrlInput, useFloatingMediaUrlInputState, useImage, useImagePreview, useImagePreviewSelectors, useImagePreviewState, useMediaController, useMediaControllerDropDownMenu, useMediaControllerState, useMediaState, useMediaStore, useMediaToolbarButton, usePlaceholderElementState, usePlaceholderPopoverState, usePlaceholderStore, usePreviewImage, usePreviewImageState, useScaleInput, useScaleInputState, useZoom, withImage, withImageEmbed, withImageUpload }; |
@@ -98,2 +98,3 @@ "use strict"; | ||
parseIframeUrl: () => parseIframeUrl, | ||
parseMediaUrl: () => parseMediaUrl, | ||
parseTwitterUrl: () => parseTwitterUrl, | ||
@@ -799,11 +800,2 @@ parseVideoUrl: () => parseVideoUrl, | ||
// src/video/createVideoPlugin.ts | ||
var import_plate_common8 = require("@udecode/plate-common"); | ||
var ELEMENT_VIDEO = "video"; | ||
var createVideoPlugin = (0, import_plate_common8.createPluginFactory)({ | ||
isElement: true, | ||
isVoid: true, | ||
key: ELEMENT_VIDEO | ||
}); | ||
// src/media-embed/createMediaEmbedPlugin.ts | ||
@@ -934,3 +926,37 @@ var import_server8 = require("@udecode/plate-common/server"); | ||
// src/video/createVideoPlugin.ts | ||
var import_plate_common8 = require("@udecode/plate-common"); | ||
var ELEMENT_VIDEO = "video"; | ||
var createVideoPlugin = (0, import_plate_common8.createPluginFactory)({ | ||
isElement: true, | ||
isVoid: true, | ||
key: ELEMENT_VIDEO | ||
}); | ||
// src/media/useMediaState.ts | ||
var allowedProtocols = /* @__PURE__ */ new Set(["https:", "http:"]); | ||
var parseMediaUrl = (url, { | ||
urlParsers | ||
}) => { | ||
const embed = (() => { | ||
for (const parser of urlParsers) { | ||
const data = parser(url); | ||
if (data) { | ||
return data; | ||
} | ||
} | ||
})(); | ||
if (embed == null ? void 0 : embed.url) { | ||
try { | ||
const { protocol } = new URL(embed.url); | ||
if (!allowedProtocols.has(protocol)) { | ||
return void 0; | ||
} | ||
} catch (e) { | ||
console.warn("Could not parse URL: " + embed.url); | ||
return void 0; | ||
} | ||
} | ||
return embed; | ||
}; | ||
var useMediaState = ({ | ||
@@ -947,8 +973,3 @@ urlParsers | ||
return; | ||
for (const parser of urlParsers) { | ||
const data = parser(url); | ||
if (data) { | ||
return data; | ||
} | ||
} | ||
return parseMediaUrl(url, { urlParsers }); | ||
}, [urlParsers, url]); | ||
@@ -970,3 +991,3 @@ const isTweet = (embed == null ? void 0 : embed.provider) === "twitter"; | ||
selected, | ||
url | ||
unsafeUrl: url | ||
}; | ||
@@ -1299,2 +1320,3 @@ }; | ||
parseIframeUrl, | ||
parseMediaUrl, | ||
parseTwitterUrl, | ||
@@ -1301,0 +1323,0 @@ parseVideoUrl, |
{ | ||
"name": "@udecode/plate-media", | ||
"version": "36.0.0", | ||
"version": "36.0.10", | ||
"description": "Plate Media plugin", | ||
@@ -48,3 +48,3 @@ "license": "MIT", | ||
"peerDependencies": { | ||
"@udecode/plate-common": ">=36.0.0", | ||
"@udecode/plate-common": ">=36.0.6", | ||
"react": ">=16.8.0", | ||
@@ -51,0 +51,0 @@ "react-dom": ">=16.8.0", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
245646
3153