@dfosco/storyboard-react 4.0.0-beta.0 → 4.0.0-beta.2
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 +3 -3
- package/src/canvas/CanvasPage.jsx +15 -4
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dfosco/storyboard-react",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@dfosco/storyboard-core": "4.0.0-beta.
|
|
7
|
-
"@dfosco/tiny-canvas": "4.0.0-beta.
|
|
6
|
+
"@dfosco/storyboard-core": "4.0.0-beta.2",
|
|
7
|
+
"@dfosco/tiny-canvas": "4.0.0-beta.2",
|
|
8
8
|
"@neodrag/react": "^2.3.1",
|
|
9
9
|
"glob": "^11.0.0",
|
|
10
10
|
"jsonc-parser": "^3.3.1"
|
|
@@ -1017,6 +1017,17 @@ export default function CanvasPage({ name }) {
|
|
|
1017
1017
|
return pathname
|
|
1018
1018
|
}
|
|
1019
1019
|
|
|
1020
|
+
/** Parse text as a web URL (http/https only). Returns URL object or null. */
|
|
1021
|
+
function looksLikeWebUrl(text) {
|
|
1022
|
+
try {
|
|
1023
|
+
const url = new URL(text)
|
|
1024
|
+
if (url.protocol === 'http:' || url.protocol === 'https:') return url
|
|
1025
|
+
return null
|
|
1026
|
+
} catch {
|
|
1027
|
+
return null
|
|
1028
|
+
}
|
|
1029
|
+
}
|
|
1030
|
+
|
|
1020
1031
|
function blobToDataUrl(blob) {
|
|
1021
1032
|
return new Promise((resolve, reject) => {
|
|
1022
1033
|
const reader = new FileReader()
|
|
@@ -1099,13 +1110,13 @@ export default function CanvasPage({ name }) {
|
|
|
1099
1110
|
e.preventDefault()
|
|
1100
1111
|
|
|
1101
1112
|
let type, props
|
|
1102
|
-
|
|
1103
|
-
|
|
1113
|
+
const url = looksLikeWebUrl(text)
|
|
1114
|
+
if (url) {
|
|
1104
1115
|
if (isFigmaUrl(text)) {
|
|
1105
1116
|
type = 'figma-embed'
|
|
1106
1117
|
props = { url: sanitizeFigmaUrl(text), width: 800, height: 450 }
|
|
1107
1118
|
} else if (isSameOriginPrototype(text)) {
|
|
1108
|
-
const pathPortion =
|
|
1119
|
+
const pathPortion = url.pathname + url.search + url.hash
|
|
1109
1120
|
const src = extractPrototypeSrc(pathPortion)
|
|
1110
1121
|
type = 'prototype'
|
|
1111
1122
|
props = { src: src || '/', originalSrc: src || '/', label: '', width: 800, height: 600 }
|
|
@@ -1113,7 +1124,7 @@ export default function CanvasPage({ name }) {
|
|
|
1113
1124
|
type = 'link-preview'
|
|
1114
1125
|
props = { url: text, title: '' }
|
|
1115
1126
|
}
|
|
1116
|
-
}
|
|
1127
|
+
} else {
|
|
1117
1128
|
type = 'markdown'
|
|
1118
1129
|
props = { content: text }
|
|
1119
1130
|
}
|