5htp-core 0.4.9-91 → 0.4.9-93
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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "5htp-core",
|
|
3
3
|
"description": "Convenient TypeScript framework designed for Performance and Productivity.",
|
|
4
|
-
"version": "0.4.9-
|
|
4
|
+
"version": "0.4.9-93",
|
|
5
5
|
"author": "Gaetan Le Gac (https://github.com/gaetanlegac)",
|
|
6
6
|
"repository": "git://github.com/gaetanlegac/5htp-core.git",
|
|
7
7
|
"license": "MIT",
|
|
@@ -18,8 +18,14 @@ export const Link = ({ to, ...props }: {
|
|
|
18
18
|
className?: string
|
|
19
19
|
} & React.HTMLProps<HTMLAnchorElement>) => {
|
|
20
20
|
|
|
21
|
+
const openNewTab = to && (
|
|
22
|
+
!['/', '#'].includes(to[0])
|
|
23
|
+
||
|
|
24
|
+
to.startsWith('//')
|
|
25
|
+
);
|
|
26
|
+
|
|
21
27
|
// External = open in new tab by default
|
|
22
|
-
if (
|
|
28
|
+
if (openNewTab)
|
|
23
29
|
props.target = '_blank';
|
|
24
30
|
// Otherwise, propagate to the router
|
|
25
31
|
else
|
package/src/server/utils/rte.ts
CHANGED
|
@@ -75,16 +75,24 @@ export class RteUtils {
|
|
|
75
75
|
json: string | LexicalState,
|
|
76
76
|
}> {
|
|
77
77
|
|
|
78
|
+
// Transform content
|
|
79
|
+
const assets: TContentAssets = {
|
|
80
|
+
attachements: [],
|
|
81
|
+
skeleton: []
|
|
82
|
+
}
|
|
83
|
+
|
|
78
84
|
// Parse content if string
|
|
79
85
|
let json: LexicalState;
|
|
80
|
-
if (typeof content === 'string') {
|
|
86
|
+
if (typeof content === 'string' && content.trim().startsWith('{')) {
|
|
81
87
|
try {
|
|
82
88
|
json = JSON.parse(content) as LexicalState;
|
|
83
89
|
} catch (error) {
|
|
84
90
|
throw new Anomaly("Invalid JSON format for the given JSON RTE content.");
|
|
85
91
|
}
|
|
86
|
-
} else
|
|
92
|
+
} else if (content && typeof content === 'object' && content.root)
|
|
87
93
|
json = content;
|
|
94
|
+
else
|
|
95
|
+
return { html: '', json: content, ...assets };
|
|
88
96
|
|
|
89
97
|
// Parse prev version if string
|
|
90
98
|
if (typeof options?.attachements?.prevVersion === 'string') {
|
|
@@ -95,12 +103,6 @@ export class RteUtils {
|
|
|
95
103
|
}
|
|
96
104
|
}
|
|
97
105
|
|
|
98
|
-
// Transform content
|
|
99
|
-
const assets: TContentAssets = {
|
|
100
|
-
attachements: [],
|
|
101
|
-
skeleton: []
|
|
102
|
-
}
|
|
103
|
-
|
|
104
106
|
const root = await this.processContent(json.root, async (node) => {
|
|
105
107
|
return await this.transformNode(node, assets, options);
|
|
106
108
|
});
|