PluginProbe
Extendify / 3.1.4
Extendify v3.1.4
3.2.0 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.6 3.0.5 3.0.4 trunk 0.1.0 0.10.0 0.10.1 0.10.2 0.11.0 0.11.1 0.2.0 0.3.0 0.3.1 0.4.0 0.5.0 0.6.0 0.7.0 All 126 releases
extendify / src / Agent / lib / markdown.js

markdown.js in Extendify 3.1.4, at src/Agent/lib/markdown.js

36 lines 670 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { external, Icon } from '@wordpress/icons';
2
3 const homeUrl = window.extSharedData?.homeUrl;
4
5 const isExternalUrl = (url) => {
6 try {
7 const homeUrlObject = new URL(homeUrl);
8 const urlObject = new URL(url);
9
10 return homeUrlObject.hostname !== urlObject.hostname;
11 } catch {
12 return false;
13 }
14 };
15
16 export const customComponents = {
17 a: ({ href, children }) => {
18 const isExternal = isExternalUrl(href);
19
20 return (
21 <a
22 href={href}
23 {...(isExternal && {
24 target: '_blank',
25 rel: 'noopener noreferrer',
26 })}
27 >
28 {children}
29 {isExternal && (
30 <Icon icon={external} size={18} className="ml-0.5 inline" />
31 )}
32 </a>
33 );
34 },
35 };
36