@blocklet/pages-kit 0.5.41 → 0.5.42
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/lib/cjs/builtin/utils.js +6 -5
- package/lib/cjs/tsconfig.tsbuildinfo +1 -1
- package/lib/cjs/utils/property.js +11 -0
- package/lib/esm/builtin/utils.js +6 -5
- package/lib/esm/tsconfig.tsbuildinfo +1 -1
- package/lib/esm/utils/property.js +11 -0
- package/lib/types/tsconfig.tsbuildinfo +1 -1
- package/lib/types/types/core.d.ts +11 -0
- package/lib/types/types/state.d.ts +2 -15
- package/package.json +4 -4
|
@@ -37,6 +37,7 @@ exports.getComponentDependencies = getComponentDependencies;
|
|
|
37
37
|
const xss_1 = require("@blocklet/xss");
|
|
38
38
|
const snakeCase_1 = __importDefault(require("lodash/snakeCase"));
|
|
39
39
|
const yaml = __importStar(require("yaml"));
|
|
40
|
+
const utils_1 = require("../builtin/utils");
|
|
40
41
|
const common_1 = require("./common");
|
|
41
42
|
exports.sanitize = (0, xss_1.initSanitize)();
|
|
42
43
|
function componentUMDName({ componentId }) {
|
|
@@ -192,6 +193,16 @@ function parsePropertyValue(property, inputValue, { locale, defaultLocale, prope
|
|
|
192
193
|
},
|
|
193
194
|
};
|
|
194
195
|
}
|
|
196
|
+
if (property.type === 'url') {
|
|
197
|
+
if (value?.mediaKitUrl?.startsWith('mediakit://') && value?.url?.startsWith('mediakit://')) {
|
|
198
|
+
return {
|
|
199
|
+
url: (0, utils_1.getMediaKitAbsoluteUrl)(value.mediaKitUrl) ?? (0, utils_1.getMediaKitAbsoluteUrl)(value.url) ?? value.url,
|
|
200
|
+
mediaKitUrl: value.mediaKitUrl,
|
|
201
|
+
width: value.width,
|
|
202
|
+
height: value.height,
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
}
|
|
195
206
|
return value;
|
|
196
207
|
}
|
|
197
208
|
function assignNullableFields(properties, newProperties) {
|
package/lib/esm/builtin/utils.js
CHANGED
|
@@ -8,11 +8,12 @@ export function getComponentMountPoint(name) {
|
|
|
8
8
|
return globalThis.blocklet?.componentMountPoints.find((i) => i.name === name || i.did === name)?.mountPoint;
|
|
9
9
|
}
|
|
10
10
|
export function getMediaKitAbsoluteUrl(url) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
if (url && url.startsWith('mediakit://') && typeof window !== 'undefined') {
|
|
12
|
+
const PREFIX = window.blocklet?.prefix || '/';
|
|
13
|
+
// 这里使用 Pages Kit DID,因为 Pages Kit /uploads 是 Media Kit /uploads 的超集
|
|
14
|
+
const PAGES_KIT_DID = 'z8iZiDFg3vkkrPwsiba1TLXy3H9XHzFERsP8o';
|
|
15
|
+
const PAGES_KIT_PREFIX = blocklet?.componentMountPoints.find((i) => i.did === PAGES_KIT_DID)?.mountPoint || joinURL(PREFIX, '/image-bin');
|
|
16
|
+
return window.location.origin + joinURL(PAGES_KIT_PREFIX, 'uploads', url.replace('mediakit://', ''));
|
|
16
17
|
}
|
|
17
18
|
return url;
|
|
18
19
|
}
|