@eldrajs/theme-vue 0.1.0 → 0.2.0

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/CHANGELOG.md CHANGED
@@ -5,6 +5,13 @@ Release-please writes the generated notes from commit messages and does not repl
5
5
 
6
6
  ## Unreleased
7
7
 
8
+ - `getBlockSchemaApiId(entry)` returns the **bare** block id for an entry whose `schemaApiId` (or
9
+ `schema.apiId`) is Core's `<themeId>:<apiId>`, stripping the theme's own id (the manifest's
10
+ `theme.id`, from `virtual:eldra/manifest`) and nothing else, so `blockImports`,
11
+ `data-eldra-schema` and the slot catalog stay keyed by the id `block.json` declares. The preview's
12
+ `editor:content-update` draft schema ids are normalised the same way. `virtual:eldra/manifest`
13
+ now types `theme.id`; a test mock should carry one.
14
+
8
15
  - `EldraContext` gains `messages` (reactive `{ defaultLocale, locales }`, flat dotted keys): the
9
16
  theme's resolved message catalogue, defaulting to the fallback catalogue
10
17
  (`{ defaultLocale: 'en-US', locales: {} }`) in `provideEldra()` (a new optional `messages` option
package/dist/index.d.ts CHANGED
@@ -224,7 +224,13 @@ export declare function useEldraLink(): (value: unknown) => ResolvedLink$1 | nul
224
224
  export declare function useEldraLocale(): EldraLocaleState;
225
225
  //#endregion
226
226
  //#region src/EldraBlockZone.d.ts
227
- /** Resolve the schema API id across both supported gateway response shapes. */
227
+ /**
228
+ * Resolve a block entry's **bare** block apiId across both supported gateway
229
+ * response shapes. Core spells a theme's block schema `<themeId>:<apiId>` on
230
+ * the wire; the theme's own id is stripped here (and only its own), so
231
+ * `blockImports`, `data-eldra-schema`, the slot catalog and the overlay all
232
+ * keep speaking the bare id `block.json` declares.
233
+ */
228
234
  export declare function getBlockSchemaApiId(entry: EntryDoc): string | null;
229
235
  export declare const EldraBlockZone: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
230
236
  blocks: {
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Fragment, computed, defineAsyncComponent, defineComponent, h, inject, nextTick, onBeforeUnmount, onMounted, onUpdated, provide, reactive, readonly, ref, shallowRef, toValue, watch, watchEffect } from "vue";
2
2
  import { EMPTY_THEME_MESSAGES, sanitizeLocaleMessages } from "@eldrajs/theme-core/i18n";
3
- import { DEFAULT_IMAGE_FRAMING, DEFAULT_LAYOUT_BREAKPOINTS, buildRichTextTree, buildRichTextTree as buildRichTextTree$1, buildTemplateBlockRenames, createLayoutRenderModel, createReusableLayoutRenderModel, createTemplateLayoutRenderModel, designTokenRevisionHash, generateDesignTokenCss, hiddenLayoutBreakpoints, imageFramingAttrs, imageFramingStyle, isBlockFieldLocalized, isBlockFieldLocalized as isBlockFieldLocalized$1, layoutIdentityOf, normalizeImageFraming, normalizeThemeDesignTokens, projectEntryDataLocale, registerBlockFields, restampRichTextPositions, safeHref } from "@eldrajs/theme-core";
3
+ import { DEFAULT_IMAGE_FRAMING, DEFAULT_LAYOUT_BREAKPOINTS, blockApiIdOf, buildRichTextTree, buildRichTextTree as buildRichTextTree$1, buildTemplateBlockRenames, createLayoutRenderModel, createReusableLayoutRenderModel, createTemplateLayoutRenderModel, designTokenRevisionHash, generateDesignTokenCss, hiddenLayoutBreakpoints, imageFramingAttrs, imageFramingStyle, isBlockFieldLocalized, isBlockFieldLocalized as isBlockFieldLocalized$1, layoutIdentityOf, normalizeImageFraming, normalizeThemeDesignTokens, projectEntryDataLocale, registerBlockFields, restampRichTextPositions, safeHref } from "@eldrajs/theme-core";
4
4
  import { linkTargetKeys, resolveLink, resolveLink as resolveLink$1, safeLinkHref } from "@eldrajs/theme-core/links";
5
5
  import blockImports from "virtual:eldra/blocks";
6
6
  import themeManifest from "virtual:eldra/manifest";
@@ -151,12 +151,20 @@ function useEldraLocale() {
151
151
  const INERT = createEldraLocaleState();
152
152
  //#endregion
153
153
  //#region src/EldraBlockZone.ts
154
- /** Resolve the schema API id across both supported gateway response shapes. */
154
+ /** This theme's own id, injected at build as the manifest's `theme.id`. */
155
+ const THEME_ID = themeManifest.theme?.id;
156
+ /**
157
+ * Resolve a block entry's **bare** block apiId across both supported gateway
158
+ * response shapes. Core spells a theme's block schema `<themeId>:<apiId>` on
159
+ * the wire; the theme's own id is stripped here (and only its own), so
160
+ * `blockImports`, `data-eldra-schema`, the slot catalog and the overlay all
161
+ * keep speaking the bare id `block.json` declares.
162
+ */
155
163
  function getBlockSchemaApiId(entry) {
156
164
  const direct = entry.schemaApiId;
157
- if (typeof direct === "string") return direct;
165
+ if (typeof direct === "string") return blockApiIdOf(direct, THEME_ID);
158
166
  const schema = entry.schema;
159
- if (typeof schema === "object" && schema !== null && typeof schema.apiId === "string") return schema.apiId;
167
+ if (typeof schema === "object" && schema !== null && typeof schema.apiId === "string") return blockApiIdOf(schema.apiId, THEME_ID);
160
168
  return null;
161
169
  }
162
170
  const componentCache = /* @__PURE__ */ new Map();
@@ -882,7 +890,7 @@ function startEldraPreview(context, opts) {
882
890
  overlay.acceptExternalUpdate(entries.map(({ entryId }) => entryId));
883
891
  for (const update of entries) {
884
892
  context.preview.sourceDrafts[update.entryId] = update.draftDoc;
885
- context.preview.draftSchemaApiIds[update.entryId] = update.schemaApiId;
893
+ context.preview.draftSchemaApiIds[update.entryId] = blockApiIdOf(update.schemaApiId, themeManifest.theme?.id);
886
894
  }
887
895
  projectDrafts(context);
888
896
  context.preview.refreshRevision += 1;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eldrajs/theme-vue",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Vue 3 bindings for the Eldra theme SDK: block zones, layouts, rich text and the Studio preview composables over @eldrajs/theme-core.",
5
5
  "keywords": [
6
6
  "cms",
@@ -36,7 +36,7 @@
36
36
  "provenance": true
37
37
  },
38
38
  "dependencies": {
39
- "@eldrajs/theme-core": "^0.1.0"
39
+ "@eldrajs/theme-core": "^0.2.0"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@vue/test-utils": "^2.4.6",