reactjs-tiptap-editor-pro 0.2.28 → 0.2.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -60
- package/src/components/ActionButton.tsx +103 -0
- package/src/components/ActionMenuButton.tsx +76 -0
- package/src/components/BubbleMenu.tsx +93 -0
- package/src/components/CharactorCount.tsx +50 -0
- package/src/components/ColorPicker.tsx +272 -0
- package/src/components/RichTextEditor.tsx +212 -0
- package/src/components/SizeSetter/SizeSetter.tsx +102 -0
- package/src/components/Toolbar.tsx +108 -0
- package/src/components/icons/Activity.tsx +19 -0
- package/src/components/icons/Animas.tsx +24 -0
- package/src/components/icons/AspectRatio.tsx +13 -0
- package/src/components/icons/Blockquote.tsx +17 -0
- package/src/components/icons/ColumnAddLeft.tsx +7 -0
- package/src/components/icons/ColumnAddRight.tsx +7 -0
- package/src/components/icons/DeleteColumn.tsx +26 -0
- package/src/components/icons/DeleteRow.tsx +26 -0
- package/src/components/icons/Direction.tsx +7 -0
- package/src/components/icons/Excalidraw.tsx +7 -0
- package/src/components/icons/ExportPdf.tsx +8 -0
- package/src/components/icons/ExportWord.tsx +24 -0
- package/src/components/icons/FileWordOutline.tsx +13 -0
- package/src/components/icons/Flag.tsx +19 -0
- package/src/components/icons/Food.tsx +20 -0
- package/src/components/icons/GIfIcon.tsx +10 -0
- package/src/components/icons/Icon.tsx +30 -0
- package/src/components/icons/ImportWord.tsx +23 -0
- package/src/components/icons/LeftToRight.tsx +7 -0
- package/src/components/icons/LineHeight.tsx +13 -0
- package/src/components/icons/MenuDown.tsx +24 -0
- package/src/components/icons/Mermaid.tsx +13 -0
- package/src/components/icons/NoFill.tsx +7 -0
- package/src/components/icons/Object.tsx +24 -0
- package/src/components/icons/RightToLeft.tsx +7 -0
- package/src/components/icons/SizeL.tsx +9 -0
- package/src/components/icons/SizeM.tsx +13 -0
- package/src/components/icons/SizeS.tsx +13 -0
- package/src/components/icons/Symbol.tsx +19 -0
- package/src/components/icons/Travel.tsx +24 -0
- package/src/components/icons/Twitter.tsx +7 -0
- package/src/components/icons/icons.ts +212 -0
- package/src/components/icons/index.ts +12 -0
- package/src/components/index.ts +9 -0
- package/src/components/menus/bubble.ts +395 -0
- package/src/components/menus/components/BubbleMenuContent.tsx +15 -0
- package/src/components/menus/components/BubbleMenuDrawer.tsx +128 -0
- package/src/components/menus/components/BubbleMenuExcalidraw.tsx +91 -0
- package/src/components/menus/components/BubbleMenuIframe.tsx +143 -0
- package/src/components/menus/components/BubbleMenuKatex.tsx +136 -0
- package/src/components/menus/components/BubbleMenuLink.tsx +99 -0
- package/src/components/menus/components/BubbleMenuMedia.tsx +235 -0
- package/src/components/menus/components/BubbleMenuMermaid.tsx +128 -0
- package/src/components/menus/components/BubbleMenuText.tsx +102 -0
- package/src/components/menus/components/BubbleMenuTwitter.tsx +91 -0
- package/src/components/menus/components/ColumnsBubbleMenu.tsx +59 -0
- package/src/components/menus/components/ContentMenu.tsx +396 -0
- package/src/components/menus/components/TableBubbleMenu.tsx +362 -0
- package/src/components/menus/index.ts +7 -0
- package/src/components/ui/button.tsx +56 -0
- package/src/components/ui/checkbox.tsx +30 -0
- package/src/components/ui/dialog.tsx +128 -0
- package/src/components/ui/dropdown-menu.tsx +203 -0
- package/src/components/ui/emoji-picker.tsx +166 -0
- package/src/components/ui/index.ts +14 -0
- package/src/components/ui/input.tsx +25 -0
- package/src/components/ui/label.tsx +26 -0
- package/src/components/ui/popover.tsx +31 -0
- package/src/components/ui/select.tsx +162 -0
- package/src/components/ui/separator.tsx +31 -0
- package/src/components/ui/switch.tsx +29 -0
- package/src/components/ui/tabs.tsx +55 -0
- package/src/components/ui/textarea.tsx +24 -0
- package/src/components/ui/toast.tsx +129 -0
- package/src/components/ui/toaster.tsx +44 -0
- package/src/components/ui/toggle.tsx +45 -0
- package/src/components/ui/tooltip.tsx +30 -0
- package/src/components/ui/use-toast.ts +197 -0
- package/src/constants/index.ts +223 -0
- package/src/constants/resetCSS.ts +139 -0
- package/src/extension-bundle.ts +2 -0
- package/src/extensions/Attachment/Attachment.ts +144 -0
- package/src/extensions/Attachment/components/NodeViewAttachment/FileIcon.tsx +69 -0
- package/src/extensions/Attachment/components/NodeViewAttachment/FileIconString.ts +28 -0
- package/src/extensions/Attachment/components/NodeViewAttachment/NodeViewAttachment.tsx +155 -0
- package/src/extensions/Attachment/components/NodeViewAttachment/index.module.scss +23 -0
- package/src/extensions/Attachment/index.ts +1 -0
- package/src/extensions/BaseKit.ts +253 -0
- package/src/extensions/Blockquote/Blockquote.ts +31 -0
- package/src/extensions/Blockquote/index.ts +1 -0
- package/src/extensions/Bold/Bold.ts +26 -0
- package/src/extensions/Bold/index.ts +1 -0
- package/src/extensions/BulletList/BulletList.ts +28 -0
- package/src/extensions/BulletList/index.ts +1 -0
- package/src/extensions/Clear/Clear.ts +24 -0
- package/src/extensions/Clear/index.ts +1 -0
- package/src/extensions/Code/Code.ts +26 -0
- package/src/extensions/Code/index.ts +1 -0
- package/src/extensions/CodeBlock/CodeBlock.ts +54 -0
- package/src/extensions/CodeBlock/components/CodeBlockActiveButton.tsx +66 -0
- package/src/extensions/CodeBlock/components/NodeViewCodeBlock/NodeViewCodeBlock.tsx +89 -0
- package/src/extensions/CodeBlock/components/NodeViewCodeBlock/index.module.scss +81 -0
- package/src/extensions/CodeBlock/highlighter.ts +132 -0
- package/src/extensions/CodeBlock/index.ts +1 -0
- package/src/extensions/CodeBlock/shiki-plugin.ts +213 -0
- package/src/extensions/Color/Color.ts +52 -0
- package/src/extensions/Color/components/ColorActionButton.tsx +104 -0
- package/src/extensions/Color/index.ts +1 -0
- package/src/extensions/Document/Document.ts +8 -0
- package/src/extensions/Document/index.ts +1 -0
- package/src/extensions/Drawer/Drawer.ts +177 -0
- package/src/extensions/Drawer/components/ControlDrawer/ControlDrawer.module.scss +85 -0
- package/src/extensions/Drawer/components/ControlDrawer/ControlDrawer.tsx +598 -0
- package/src/extensions/Drawer/components/ControlDrawer/icon.tsx +500 -0
- package/src/extensions/Drawer/components/DrawerActiveButton.tsx +239 -0
- package/src/extensions/Drawer/components/EditDrawerBlock.tsx +238 -0
- package/src/extensions/Drawer/components/NodeViewDrawer/NodeViewDrawer.tsx +260 -0
- package/src/extensions/Drawer/index.ts +1 -0
- package/src/extensions/Emoji/Emoji.ts +146 -0
- package/src/extensions/Emoji/components/EmojiList/EmojiList.tsx +103 -0
- package/src/extensions/Emoji/components/EmojiList/emojis.ts +1858 -0
- package/src/extensions/Emoji/components/EmojiPicker/EmojiPicker.tsx +61 -0
- package/src/extensions/Emoji/index.ts +1 -0
- package/src/extensions/Excalidraw/Excalidraw.ts +123 -0
- package/src/extensions/Excalidraw/components/ExcalidrawActiveButton.tsx +138 -0
- package/src/extensions/Excalidraw/components/NodeViewExcalidraw/NodeViewExcalidraw.tsx +178 -0
- package/src/extensions/Excalidraw/components/NodeViewExcalidraw/index.module.scss +43 -0
- package/src/extensions/Excalidraw/index.ts +1 -0
- package/src/extensions/ExportPdf/ExportPdf.ts +25 -0
- package/src/extensions/ExportPdf/index.ts +1 -0
- package/src/extensions/ExportWord/ExportWord.ts +87 -0
- package/src/extensions/ExportWord/index.ts +1 -0
- package/src/extensions/FontFamily/FontFamily.ts +64 -0
- package/src/extensions/FontFamily/components/FontFamilyButton.tsx +97 -0
- package/src/extensions/FontFamily/index.ts +1 -0
- package/src/extensions/FontSize/FontSize.ts +119 -0
- package/src/extensions/FontSize/components/FontSizeMenuButton.tsx +84 -0
- package/src/extensions/FontSize/index.ts +1 -0
- package/src/extensions/FormatPainter/FormatPainter.ts +121 -0
- package/src/extensions/FormatPainter/index.ts +1 -0
- package/src/extensions/Heading/Heading.ts +57 -0
- package/src/extensions/Heading/components/HeadingButton.tsx +96 -0
- package/src/extensions/Heading/index.ts +1 -0
- package/src/extensions/Highlight/Highlight.ts +36 -0
- package/src/extensions/Highlight/components/HighlightActionButton.tsx +108 -0
- package/src/extensions/Highlight/index.ts +1 -0
- package/src/extensions/History/History.ts +39 -0
- package/src/extensions/History/components/HistoryActionButton.tsx +74 -0
- package/src/extensions/History/index.ts +1 -0
- package/src/extensions/HorizontalRule/HorizontalRule.ts +42 -0
- package/src/extensions/HorizontalRule/index.ts +1 -0
- package/src/extensions/Iframe/Iframe.ts +140 -0
- package/src/extensions/Iframe/components/IframeNodeView.tsx +92 -0
- package/src/extensions/Iframe/components/index.module.scss +40 -0
- package/src/extensions/Iframe/embed.ts +487 -0
- package/src/extensions/Iframe/index.ts +1 -0
- package/src/extensions/Image/Image.ts +303 -0
- package/src/extensions/Image/components/ActionImageButton.tsx +186 -0
- package/src/extensions/Image/components/ImageCropper.tsx +198 -0
- package/src/extensions/Image/components/ImageView.tsx +271 -0
- package/src/extensions/Image/index.ts +1 -0
- package/src/extensions/Image/store.ts +15 -0
- package/src/extensions/ImageGif/ImageGif.ts +176 -0
- package/src/extensions/ImageGif/components/ImageGifActionButton.tsx +138 -0
- package/src/extensions/ImageGif/components/ImageGifView.tsx +260 -0
- package/src/extensions/ImageGif/index.ts +1 -0
- package/src/extensions/ImportWord/ImportWord.ts +52 -0
- package/src/extensions/ImportWord/components/ImportWordButton.tsx +151 -0
- package/src/extensions/ImportWord/index.ts +1 -0
- package/src/extensions/Indent/Indent.ts +110 -0
- package/src/extensions/Indent/index.ts +1 -0
- package/src/extensions/Italic/Italic.ts +29 -0
- package/src/extensions/Italic/index.ts +1 -0
- package/src/extensions/Katex/Katex.ts +109 -0
- package/src/extensions/Katex/components/KatexActiveButton.tsx +117 -0
- package/src/extensions/Katex/components/KatexWrapper.tsx +53 -0
- package/src/extensions/Katex/index.ts +1 -0
- package/src/extensions/LineHeight/LineHeight.ts +76 -0
- package/src/extensions/LineHeight/components/LineHeightDropdown.tsx +93 -0
- package/src/extensions/LineHeight/index.ts +1 -0
- package/src/extensions/Link/Link.ts +92 -0
- package/src/extensions/Link/components/LinkEditBlock.tsx +110 -0
- package/src/extensions/Link/components/LinkEditPopover.tsx +46 -0
- package/src/extensions/Link/components/LinkViewBlock.tsx +54 -0
- package/src/extensions/Link/index.ts +1 -0
- package/src/extensions/ListItem/ListItem.ts +1 -0
- package/src/extensions/ListItem/index.ts +1 -0
- package/src/extensions/Mention/Mention.ts +100 -0
- package/src/extensions/Mention/components/NodeViewMentionList/NodeViewMentionList.tsx +94 -0
- package/src/extensions/Mention/components/NodeViewMentionList/index.module.scss +38 -0
- package/src/extensions/Mention/index.ts +1 -0
- package/src/extensions/Mermaid/Mermaid.ts +177 -0
- package/src/extensions/Mermaid/components/EditMermaidBlock.tsx +155 -0
- package/src/extensions/Mermaid/components/MermaidActiveButton.tsx +151 -0
- package/src/extensions/Mermaid/components/NodeViewMermaid/NodeViewMermaid.tsx +260 -0
- package/src/extensions/Mermaid/index.ts +1 -0
- package/src/extensions/MoreMark/MoreMark.ts +102 -0
- package/src/extensions/MoreMark/components/ActionMoreButton.tsx +97 -0
- package/src/extensions/MoreMark/index.ts +1 -0
- package/src/extensions/MultiColumn/Column.ts +36 -0
- package/src/extensions/MultiColumn/MultiColumn.ts +111 -0
- package/src/extensions/MultiColumn/components/ColumnActionButton.ts +22 -0
- package/src/extensions/MultiColumn/index.ts +3 -0
- package/src/extensions/OrderedList/OrderedList.ts +28 -0
- package/src/extensions/OrderedList/index.ts +1 -0
- package/src/extensions/SearchAndReplace/SearchAndReplace.ts +395 -0
- package/src/extensions/SearchAndReplace/components/SearchAndReplaceButton.tsx +190 -0
- package/src/extensions/SearchAndReplace/index.ts +1 -0
- package/src/extensions/Selection/Selection.ts +32 -0
- package/src/extensions/Selection/index.ts +1 -0
- package/src/extensions/SlashCommand/SlashCommand.ts +255 -0
- package/src/extensions/SlashCommand/components/CommandsList.tsx +180 -0
- package/src/extensions/SlashCommand/groups.ts +183 -0
- package/src/extensions/SlashCommand/index.ts +1 -0
- package/src/extensions/SlashCommand/types.ts +24 -0
- package/src/extensions/Strike/Strike.ts +26 -0
- package/src/extensions/Strike/index.ts +1 -0
- package/src/extensions/Subscript/Subscript.ts +88 -0
- package/src/extensions/Subscript/index.ts +1 -0
- package/src/extensions/Table/Cell.ts +131 -0
- package/src/extensions/Table/Header.ts +93 -0
- package/src/extensions/Table/Row.ts +8 -0
- package/src/extensions/Table/Table.ts +60 -0
- package/src/extensions/Table/cell-background.ts +112 -0
- package/src/extensions/Table/components/CreateTablePopover.tsx +132 -0
- package/src/extensions/Table/components/TableActionButton.tsx +42 -0
- package/src/extensions/Table/index.ts +6 -0
- package/src/extensions/Table/utils.ts +352 -0
- package/src/extensions/TableOfContent/TableOfContent.ts +124 -0
- package/src/extensions/TableOfContent/components/NodeViewTableOfContent.tsx +116 -0
- package/src/extensions/TableOfContent/components/TableOfContentActionButton.tsx +27 -0
- package/src/extensions/TableOfContent/components/index.module.scss +40 -0
- package/src/extensions/TableOfContent/index.ts +1 -0
- package/src/extensions/TaskList/TaskList.ts +46 -0
- package/src/extensions/TaskList/index.ts +1 -0
- package/src/extensions/TextAlign/TextAlign.ts +68 -0
- package/src/extensions/TextAlign/components/TextAlignMenuButton.tsx +103 -0
- package/src/extensions/TextAlign/index.ts +1 -0
- package/src/extensions/TextBubble/TextBubble.ts +22 -0
- package/src/extensions/TextBubble/components/TextDropdown.tsx +146 -0
- package/src/extensions/TextBubble/index.ts +1 -0
- package/src/extensions/TextDirection/TextDirection.ts +97 -0
- package/src/extensions/TextDirection/components/TextDirectionButton.tsx +103 -0
- package/src/extensions/TextDirection/index.ts +1 -0
- package/src/extensions/TrailingNode/TrailingNode.ts +71 -0
- package/src/extensions/TrailingNode/index.ts +1 -0
- package/src/extensions/Twitter/Twitter.ts +161 -0
- package/src/extensions/Twitter/components/FormEditLinkTwitter.tsx +68 -0
- package/src/extensions/Twitter/components/NodeViewTweet.tsx +30 -0
- package/src/extensions/Twitter/components/TwitterActiveButton.tsx +41 -0
- package/src/extensions/Twitter/index.ts +1 -0
- package/src/extensions/UnderLine/Underline.ts +30 -0
- package/src/extensions/UnderLine/index.ts +1 -0
- package/src/extensions/Video/Video.ts +204 -0
- package/src/extensions/Video/components/ActiveVideoButton.tsx +191 -0
- package/src/extensions/Video/index.ts +1 -0
- package/src/extensions/Video/store.ts +15 -0
- package/src/extensions/index.ts +122 -0
- package/src/hooks/useActive.tsx +24 -0
- package/src/hooks/useAttributes.tsx +45 -0
- package/src/hooks/useCopy.tsx +20 -0
- package/src/hooks/useEditorState.tsx +23 -0
- package/src/hooks/useExtension.tsx +29 -0
- package/src/index.ts +8 -0
- package/src/lib/utils.ts +7 -0
- package/src/locale-bundle.ts +3 -0
- package/src/locales/en.ts +173 -0
- package/src/locales/hu.ts +173 -0
- package/src/locales/index.tsx +163 -0
- package/src/locales/pt-br.ts +173 -0
- package/src/locales/vi.ts +173 -0
- package/src/locales/zh-cn.ts +173 -0
- package/src/plugins/DragHandle/index.ts +375 -0
- package/src/plugins/DragHandle/range.ts +114 -0
- package/src/plugins/DragHandle/utils.ts +80 -0
- package/src/plugins/image-upload.ts +160 -0
- package/src/store/ProviderRichText.tsx +53 -0
- package/src/store/editableEditor.ts +15 -0
- package/src/store/fast-context.tsx +70 -0
- package/src/store/store.ts +35 -0
- package/src/styles/ProseMirror.scss +176 -0
- package/src/styles/columns.scss +23 -0
- package/src/styles/editor.scss +411 -0
- package/src/styles/global.scss +87 -0
- package/src/styles/index.scss +5 -0
- package/src/styles/mention.scss +6 -0
- package/src/theme/theme.ts +15 -0
- package/src/types.ts +271 -0
- package/src/utils/_event.ts +55 -0
- package/src/utils/color.ts +67 -0
- package/src/utils/columns.ts +142 -0
- package/src/utils/customEvents/customEvents.ts +18 -0
- package/src/utils/customEvents/events.constant.ts +11 -0
- package/src/utils/delete-node.ts +46 -0
- package/src/utils/dom-dataset.ts +121 -0
- package/src/utils/download.ts +17 -0
- package/src/utils/dynamicCSS.ts +192 -0
- package/src/utils/editor-container-size.ts +28 -0
- package/src/utils/file.ts +112 -0
- package/src/utils/getRenderContainer.ts +41 -0
- package/src/utils/indent.ts +99 -0
- package/src/utils/is-mobile.ts +57 -0
- package/src/utils/json.ts +18 -0
- package/src/utils/line-height.ts +109 -0
- package/src/utils/lru-cache.ts +145 -0
- package/src/utils/mitt.ts +114 -0
- package/src/utils/node.ts +92 -0
- package/src/utils/pdf.ts +72 -0
- package/src/utils/plateform.ts +49 -0
- package/src/utils/shortId.ts +5 -0
- package/src/utils/storage.ts +18 -0
- package/src/utils/utils.ts +71 -0
- package/src/vite-env.d.ts +3 -0
- package/lib/RichTextEditor-BC85Dn21.js +0 -8826
- package/lib/RichTextEditor-Cxm0yJdr.cjs +0 -141
- package/lib/extension-bundle.cjs +0 -33
- package/lib/extension-bundle.d.cts +0 -947
- package/lib/extension-bundle.d.ts +0 -947
- package/lib/extension-bundle.js +0 -5755
- package/lib/index-DV-nXpU1.cjs +0 -1
- package/lib/index-M6H3FoBi.js +0 -1147
- package/lib/index.cjs +0 -1
- package/lib/index.d.cts +0 -511
- package/lib/index.d.ts +0 -511
- package/lib/index.js +0 -16
- package/lib/locale-bundle.cjs +0 -1
- package/lib/locale-bundle.d.cts +0 -1140
- package/lib/locale-bundle.d.ts +0 -1140
- package/lib/locale-bundle.js +0 -9
- package/lib/style.css +0 -1
- package/lib/tiptap-DkWHMWDt.js +0 -6061
- package/lib/tiptap-gBG-1T-V.cjs +0 -116
- package/lib/vendor-BJ0Yf78E.cjs +0 -8114
- package/lib/vendor-Cpa6z-M0.js +0 -67575
|
@@ -0,0 +1,487 @@
|
|
|
1
|
+
interface ServiceType {
|
|
2
|
+
label: string
|
|
3
|
+
value: string
|
|
4
|
+
icon: any
|
|
5
|
+
}
|
|
6
|
+
export const VideoServices: ServiceType[] = [
|
|
7
|
+
{ label: '优酷', value: 'youku', icon: 'Youku' },
|
|
8
|
+
{
|
|
9
|
+
label: '哔哩哔哩',
|
|
10
|
+
value: 'bilibili',
|
|
11
|
+
icon: 'BiliBili',
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
label: '腾讯视频',
|
|
15
|
+
value: 'qqvideo',
|
|
16
|
+
icon: 'QQVideo',
|
|
17
|
+
},
|
|
18
|
+
];
|
|
19
|
+
|
|
20
|
+
export const MapServices: ServiceType[] = [
|
|
21
|
+
{ label: '高德地图', value: 'amap', icon: 'Gaode' },
|
|
22
|
+
{ label: '百度地图', value: 'baidu_map', icon: 'Baidu' },
|
|
23
|
+
];
|
|
24
|
+
|
|
25
|
+
export const DesignServices: ServiceType[] = [
|
|
26
|
+
{ label: '墨刀', value: 'modao', icon: 'Modao' },
|
|
27
|
+
{ label: '蓝湖', value: 'lanhu', icon: 'Lanhu' },
|
|
28
|
+
{ label: 'Figma', value: 'figma', icon: 'Figma' },
|
|
29
|
+
{ label: 'Canva', value: 'canva', icon: 'Canva' },
|
|
30
|
+
{ label: 'ProcessOn', value: 'processon', icon: 'Processon' },
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
export const DevelopServices: ServiceType[] = [
|
|
34
|
+
{ label: 'CodePen', value: 'codepen', icon: 'Codepen' },
|
|
35
|
+
];
|
|
36
|
+
|
|
37
|
+
export const DataServices: ServiceType[] = [
|
|
38
|
+
{ label: '金数据', value: 'jinshuju', icon: 'Jinshuju' },
|
|
39
|
+
];
|
|
40
|
+
|
|
41
|
+
export const OtherServices = [];
|
|
42
|
+
|
|
43
|
+
export const AllEmbedServices = [
|
|
44
|
+
...VideoServices,
|
|
45
|
+
...MapServices,
|
|
46
|
+
...DesignServices,
|
|
47
|
+
...DevelopServices,
|
|
48
|
+
...DataServices,
|
|
49
|
+
...OtherServices,
|
|
50
|
+
];
|
|
51
|
+
|
|
52
|
+
export function getEmbedService(value: any) {
|
|
53
|
+
for (const item of AllEmbedServices) {
|
|
54
|
+
if (item.value === value) {
|
|
55
|
+
return item;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return {};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Embed service link
|
|
64
|
+
* @id source id
|
|
65
|
+
* @exmplae example link
|
|
66
|
+
* @src source src, used in iframe
|
|
67
|
+
*/
|
|
68
|
+
export const EmbedServiceLink: any = {
|
|
69
|
+
youtube: {
|
|
70
|
+
example: 'https://www.youtube.com/watch?v=I4sMhHbHYXM',
|
|
71
|
+
src: 'https://www.youtube.com/embed/I4sMhHbHYXM',
|
|
72
|
+
srcPrefix: 'https://www.youtube.com/embed',
|
|
73
|
+
linkRule: [
|
|
74
|
+
/(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\s/]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[&?]v=)|youtu\.be\/)([\w-]{11})/,
|
|
75
|
+
],
|
|
76
|
+
},
|
|
77
|
+
youku: {
|
|
78
|
+
example:
|
|
79
|
+
'https://v.youku.com/v_show/id_XNDM0NDM4MTcy.html?spm=a2h0c.8166622.PhoneSokuUgc_4.dtitle',
|
|
80
|
+
src: 'https://player.youku.com/embed/XNDM0NDM4MTcy',
|
|
81
|
+
srcPrefix: 'https://player.youku.com/embed',
|
|
82
|
+
linkRule: ['v.youku.com\\/v_show\\/id_\\w+\\=*'],
|
|
83
|
+
idRule: 'id_\\w+\\=*',
|
|
84
|
+
},
|
|
85
|
+
bilibili: {
|
|
86
|
+
example: 'https://www.bilibili.com/video/BV1EJ411u7DN',
|
|
87
|
+
src: 'https://player.bilibili.com/player.html?bvid=BV1EJ411u7DN',
|
|
88
|
+
srcPrefix: 'https://player.bilibili.com/player.html?bvid',
|
|
89
|
+
linkRule: ['www.bilibili.com\\/video\\/\\w+'],
|
|
90
|
+
},
|
|
91
|
+
qqvideo: {
|
|
92
|
+
example: 'https://v.qq.com/x/cover/mzc0020006aw1mn/u0033nvzb5v.html',
|
|
93
|
+
src: 'https://v.qq.com/txp/iframe/player.html?vid=u0033nvzb5v',
|
|
94
|
+
srcPrefix: 'https://v.qq.com/txp/iframe/player.html?vid',
|
|
95
|
+
linkRule: ['v.qq.com\\/x\\/cover\\/\\w+\\/\\w+'],
|
|
96
|
+
},
|
|
97
|
+
amap: {
|
|
98
|
+
example: 'https://ditu.amap.com/',
|
|
99
|
+
src: 'https://www.amap.com/place/B000A45467',
|
|
100
|
+
srcPrefix: '',
|
|
101
|
+
linkRule: ['\\.amap\\.com'],
|
|
102
|
+
},
|
|
103
|
+
baidu_map: {
|
|
104
|
+
example: 'https://j.map.baidu.com/15/fo',
|
|
105
|
+
src: 'https://j.map.baidu.com/15/fo',
|
|
106
|
+
srcPrefix: '',
|
|
107
|
+
linkRule: ['map\\.baidu\\.com'],
|
|
108
|
+
},
|
|
109
|
+
modao: {
|
|
110
|
+
example:
|
|
111
|
+
'https://free.modao.cc/app/2cd26580a6717a147454df7470e7ec464093cba3/embed/v2#screen=sk71k6d1dfxulzx',
|
|
112
|
+
src: 'https://free.modao.cc/app/6UkpAxcGE3nPz52GLqhnOZgC7MATBSy/embed/v2',
|
|
113
|
+
srcPrefix: '',
|
|
114
|
+
linkRule: ['https:\\/\\/\\w+.modao.cc\\/app\\/\\w+\\/embed\\/v2'],
|
|
115
|
+
tips: 'Modao > More > Share > Embed > COPY',
|
|
116
|
+
},
|
|
117
|
+
lanhu: {
|
|
118
|
+
example: 'https://lanhuapp.com/link/#/invite?sid=evP7L',
|
|
119
|
+
src: 'https://lanhuapp.com/url/evP7L',
|
|
120
|
+
srcPrefix: '',
|
|
121
|
+
linkRule: ['https:\\/\\/lanhuapp.com\\/url\\/\\w+'],
|
|
122
|
+
tips: 'Lanhu > Project > Share > Copy Link',
|
|
123
|
+
},
|
|
124
|
+
figma: {
|
|
125
|
+
example: 'https://www.figma.com/file/aS9uSgPXoNpaPkzbjNcK8v/Demo?node-id=0%3A1',
|
|
126
|
+
src: 'https://www.figma.com/file/aS9uSgPXoNpaPkzbjNcK8v/Demo?node-id=0%3A1',
|
|
127
|
+
srcPrefix: 'https://www.figma.com/embed?embed_host=share&url',
|
|
128
|
+
linkRule: ['https:\\/\\/www.figma.com\\/file\\/\\w+'],
|
|
129
|
+
},
|
|
130
|
+
canva: {
|
|
131
|
+
example: 'https://www.canva.cn/design/DAD61-t29UI/view',
|
|
132
|
+
src: 'https://www.canva.cn/design/DAD61-t29UI/view',
|
|
133
|
+
srcPrefix: '',
|
|
134
|
+
linkRule: ['https:\\/\\/www.canva.cn\\/design\\/.+\\/view'],
|
|
135
|
+
},
|
|
136
|
+
processon: {
|
|
137
|
+
example: 'https://www.processon.com/embed/5ea99d8607912948b0e6fe78',
|
|
138
|
+
src: 'https://www.processon.com/embed/5ea99d8607912948b0e6fe78',
|
|
139
|
+
srcPrefix: '',
|
|
140
|
+
linkRule: ['https:\\/\\/www.processon.com\\/embed\\/\\w+'],
|
|
141
|
+
},
|
|
142
|
+
codepen: {
|
|
143
|
+
example: 'https://codepen.io/mekery/embed/YzyrKOJ',
|
|
144
|
+
src: 'https://codepen.io/mekery/embed/YzyrKOJ',
|
|
145
|
+
srcPrefix: '',
|
|
146
|
+
linkRule: ['https:\\/\\/codepen.io\\/.+\\/embed\\/\\w+'],
|
|
147
|
+
},
|
|
148
|
+
jinshuju: {
|
|
149
|
+
example: 'https://jinshuju.net/f/q9YvVf',
|
|
150
|
+
src: 'https://jinshuju.net/f/q9YvVf',
|
|
151
|
+
srcPrefix: '',
|
|
152
|
+
linkRule: ['https:\\/\\/jinshuju.net\\/f\\/\\w+'],
|
|
153
|
+
},
|
|
154
|
+
iframe: {
|
|
155
|
+
example: 'https://v.youku.com/v_show/id_XNDM0NDM4MTcy.html',
|
|
156
|
+
src: 'https://player.youku.com/embed/XNDM0NDM4MTcy',
|
|
157
|
+
srcPrefix: '',
|
|
158
|
+
linkRule: ['.+'],
|
|
159
|
+
},
|
|
160
|
+
googlemaps: {
|
|
161
|
+
example: 'https://goo.gl/maps/8Ys8b4K1ZJY2',
|
|
162
|
+
src: 'https://www.google.com/maps/embed?pb=https://goo.gl/maps/8Ys8b4K1ZJY2',
|
|
163
|
+
srcPrefix: '',
|
|
164
|
+
linkRule: ['https:\\/\\/goo.gl\\/maps\\/\\w+'],
|
|
165
|
+
},
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
function getYoutubeSrc(result: any) {
|
|
169
|
+
const link = EmbedServiceLink.youtube;
|
|
170
|
+
const url = result.matchedUrl;
|
|
171
|
+
result.validLink = true;
|
|
172
|
+
|
|
173
|
+
const splits = url.split('=');
|
|
174
|
+
const len = splits.length;
|
|
175
|
+
if (len > 0) {
|
|
176
|
+
const id = splits[len - 1];
|
|
177
|
+
result.src = `${link.srcPrefix}/${id}`;
|
|
178
|
+
result.validId = true;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
return result;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function getYoukuSrc(result: any) {
|
|
185
|
+
const link = EmbedServiceLink.youku as any;
|
|
186
|
+
const url = result.matchedUrl;
|
|
187
|
+
|
|
188
|
+
const idRule = link.idRule;
|
|
189
|
+
const regex = new RegExp(idRule);
|
|
190
|
+
const match = url.match(regex);
|
|
191
|
+
if (match && match.length > 0) {
|
|
192
|
+
const id = match[0].slice(3);
|
|
193
|
+
|
|
194
|
+
result.validId = true;
|
|
195
|
+
result.src = `${link.srcPrefix}/${id}`;
|
|
196
|
+
} else {
|
|
197
|
+
result.validId = false;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
return result;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
function getBilibiliSrc(result: any) {
|
|
204
|
+
const link = EmbedServiceLink.bilibili;
|
|
205
|
+
const url = result.matchedUrl;
|
|
206
|
+
|
|
207
|
+
const splits = url.split('/');
|
|
208
|
+
const len = splits.length;
|
|
209
|
+
if (len > 0) {
|
|
210
|
+
const id = splits[len - 1];
|
|
211
|
+
result.src = `${link.srcPrefix}=${id}`;
|
|
212
|
+
result.validId = true;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
return result;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
function getQQVideoSrc(result: any) {
|
|
219
|
+
const link = EmbedServiceLink.qqvideo;
|
|
220
|
+
const url = result.matchedUrl;
|
|
221
|
+
|
|
222
|
+
const splits = url.split('/');
|
|
223
|
+
const len = splits.length;
|
|
224
|
+
if (len > 0) {
|
|
225
|
+
const id = splits[len - 1];
|
|
226
|
+
result.src = `${link.srcPrefix}=${id}`;
|
|
227
|
+
result.validId = true;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
return result;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
function getAMapSrc(originalLink: any, result: any) {
|
|
234
|
+
result.src = originalLink;
|
|
235
|
+
result.validId = true;
|
|
236
|
+
|
|
237
|
+
return result;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
function getBaiduMapSrc(originalLink: any, result: any) {
|
|
241
|
+
result.src = originalLink;
|
|
242
|
+
result.validId = true;
|
|
243
|
+
|
|
244
|
+
return result;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
function getGoogleMapSrc(originalLink: any, result: any) {
|
|
248
|
+
result.src = originalLink;
|
|
249
|
+
result.validId = true;
|
|
250
|
+
result.originalLink = originalLink;
|
|
251
|
+
|
|
252
|
+
return result;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
function getModaoSrc(result: any) {
|
|
256
|
+
result.src = result.matchedUrl;
|
|
257
|
+
result.validId = true;
|
|
258
|
+
result.originalLink = result.src;
|
|
259
|
+
|
|
260
|
+
return result;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
function getLanhuSrc(result: any) {
|
|
264
|
+
result.src = result.matchedUrl;
|
|
265
|
+
result.validId = true;
|
|
266
|
+
result.originalLink = result.src;
|
|
267
|
+
|
|
268
|
+
return result;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
function getFigmaSrc(result: any) {
|
|
272
|
+
const link = EmbedServiceLink.figma;
|
|
273
|
+
result.src = `${link.srcPrefix}=${encodeURIComponent(result.matchedUrl)}`;
|
|
274
|
+
result.validId = true;
|
|
275
|
+
result.originalLink = result.matchedUrl;
|
|
276
|
+
|
|
277
|
+
return result;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
function getCanvaSrc(originalLink: any, result: any) {
|
|
281
|
+
result.src = `${result.matchedUrl}?embed`;
|
|
282
|
+
result.validId = true;
|
|
283
|
+
result.originalLink = originalLink;
|
|
284
|
+
|
|
285
|
+
return result;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
function getProcessonSrc(originalLink: any, result: any) {
|
|
289
|
+
result.src = `${result.matchedUrl}`;
|
|
290
|
+
result.validId = true;
|
|
291
|
+
result.originalLink = originalLink;
|
|
292
|
+
|
|
293
|
+
return result;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
function getCodepenSrc(result: any) {
|
|
297
|
+
result.src = `${result.matchedUrl}`;
|
|
298
|
+
result.validId = true;
|
|
299
|
+
result.originalLink = result.src;
|
|
300
|
+
|
|
301
|
+
return result;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
function getJinshujuSrc(originalLink: any, result: any) {
|
|
305
|
+
result.src = `${result.matchedUrl}?background=white&banner=show&embedded=true`;
|
|
306
|
+
result.validId = true;
|
|
307
|
+
result.originalLink = originalLink;
|
|
308
|
+
|
|
309
|
+
return result;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
function getCommonSrc(originalLink: any, result: any) {
|
|
313
|
+
result.src = `${result.matchedUrl}`;
|
|
314
|
+
result.validId = true;
|
|
315
|
+
result.originalLink = originalLink;
|
|
316
|
+
|
|
317
|
+
return result;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
function getMatchedUrl(service: any, originalLink: any, result: any) {
|
|
321
|
+
if (service === 'googlemaps') {
|
|
322
|
+
result.validLink = true;
|
|
323
|
+
result.matchedUrl = originalLink;
|
|
324
|
+
return result;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
const link = EmbedServiceLink[service];
|
|
328
|
+
const linkRule = link.linkRule;
|
|
329
|
+
|
|
330
|
+
for (const rule of linkRule) {
|
|
331
|
+
const regex = new RegExp(rule);
|
|
332
|
+
const match = originalLink.match(regex);
|
|
333
|
+
if (match && match.length > 0) {
|
|
334
|
+
result.validLink = true;
|
|
335
|
+
result.matchedUrl = service === 'youtube' ? match[1] : match[0];
|
|
336
|
+
|
|
337
|
+
return result;
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
return result;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
export function getExampleUrl(service: string) {
|
|
345
|
+
let exampleUrl = '';
|
|
346
|
+
const link = EmbedServiceLink[service];
|
|
347
|
+
if (link) {
|
|
348
|
+
exampleUrl = link.example;
|
|
349
|
+
}
|
|
350
|
+
return exampleUrl;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
function formatUrl(url: string) {
|
|
354
|
+
let service = 'iframe';
|
|
355
|
+
|
|
356
|
+
if (url.includes?.('youtube') || url.includes?.('youtu.be')) {
|
|
357
|
+
service = 'youtube';
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
if (url.includes('youku')) {
|
|
361
|
+
service = 'youku';
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
if (url.includes('bilibili')) {
|
|
365
|
+
service = 'bilibili';
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
if (url.includes('qq')) {
|
|
369
|
+
service = 'qqvideo';
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
if (url.includes('amap')) {
|
|
373
|
+
service = 'amap';
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
if (url.includes('map.baidu')) {
|
|
377
|
+
service = 'baidu_map';
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
if (url.includes('google.com/maps') || url.includes('maps.app.goo.gl')) {
|
|
381
|
+
service = 'googlemaps';
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
if (url.includes('modao')) {
|
|
385
|
+
service = 'modao';
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
if (url.includes('lanhuapp')) {
|
|
389
|
+
service = 'lanhu';
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
if (url.includes('figma')) {
|
|
393
|
+
service = 'figma';
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
if (url.includes('canva')) {
|
|
397
|
+
service = 'canva';
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
if (url.includes('processon')) {
|
|
401
|
+
service = 'processon';
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
if (url.includes('codepen')) {
|
|
405
|
+
service = 'codepen';
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
if (url.includes('jinshuju')) {
|
|
409
|
+
service = 'jinshuju';
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
if (url.includes('iframe')) {
|
|
413
|
+
service = 'iframe';
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
return service;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
export function getServiceSrc(originalLink: any) {
|
|
420
|
+
let result = {
|
|
421
|
+
validLink: false,
|
|
422
|
+
validId: false,
|
|
423
|
+
matchedUrl: '',
|
|
424
|
+
originalLink,
|
|
425
|
+
src: '',
|
|
426
|
+
};
|
|
427
|
+
|
|
428
|
+
const service = formatUrl(originalLink);
|
|
429
|
+
|
|
430
|
+
// matched url
|
|
431
|
+
result = getMatchedUrl(service, originalLink, result);
|
|
432
|
+
|
|
433
|
+
if (!result.validLink) {
|
|
434
|
+
return result;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
// src
|
|
438
|
+
switch (service) {
|
|
439
|
+
case 'youtube': {
|
|
440
|
+
return getYoutubeSrc(result);
|
|
441
|
+
}
|
|
442
|
+
case 'youku': {
|
|
443
|
+
return getYoukuSrc(result);
|
|
444
|
+
}
|
|
445
|
+
case 'bilibili': {
|
|
446
|
+
return getBilibiliSrc(result);
|
|
447
|
+
}
|
|
448
|
+
case 'qqvideo': {
|
|
449
|
+
return getQQVideoSrc(result);
|
|
450
|
+
}
|
|
451
|
+
case 'amap': {
|
|
452
|
+
return getAMapSrc(originalLink, result);
|
|
453
|
+
}
|
|
454
|
+
case 'baidu_map': {
|
|
455
|
+
return getBaiduMapSrc(originalLink, result);
|
|
456
|
+
}
|
|
457
|
+
case 'googlemaps': {
|
|
458
|
+
return getGoogleMapSrc(originalLink, result);
|
|
459
|
+
}
|
|
460
|
+
case 'modao': {
|
|
461
|
+
return getModaoSrc(result);
|
|
462
|
+
}
|
|
463
|
+
case 'lanhu': {
|
|
464
|
+
return getLanhuSrc(result);
|
|
465
|
+
}
|
|
466
|
+
case 'figma': {
|
|
467
|
+
return getFigmaSrc(result);
|
|
468
|
+
}
|
|
469
|
+
case 'canva': {
|
|
470
|
+
return getCanvaSrc(originalLink, result);
|
|
471
|
+
}
|
|
472
|
+
case 'processon': {
|
|
473
|
+
return getProcessonSrc(originalLink, result);
|
|
474
|
+
}
|
|
475
|
+
case 'codepen': {
|
|
476
|
+
return getCodepenSrc(result);
|
|
477
|
+
}
|
|
478
|
+
case 'jinshuju': {
|
|
479
|
+
return getJinshujuSrc(originalLink, result);
|
|
480
|
+
}
|
|
481
|
+
case 'iframe': {
|
|
482
|
+
return getCommonSrc(originalLink, result);
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
return result;
|
|
487
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Iframe';
|