@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.
@@ -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) {
@@ -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
- const PREFIX = window.blocklet?.prefix || '/';
12
- const IMAGE_BIN_DID = 'z8ia1mAXo8ZE7ytGF36L5uBf9kD2kenhqFGp9';
13
- const IMAGE_BIN_PREFIX = blocklet?.componentMountPoints.find((i) => i.did === IMAGE_BIN_DID)?.mountPoint || joinURL(PREFIX, '/image-bin');
14
- if (url && url.startsWith('mediakit://')) {
15
- return window.location.origin + joinURL(IMAGE_BIN_PREFIX, 'uploads', url.replace('mediakit://', ''));
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
  }