@mosetta/editor 0.0.29 → 0.0.32

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
@@ -1,5 +1,20 @@
1
1
  # @mosetta/editor
2
2
 
3
+ ## 0.0.32
4
+
5
+ - Built with the framework 0.0.12, whose `@mosetta/react` ships the guide to writing tiles — a new
6
+ project's tile palette starts on it.
7
+
8
+ ## 0.0.31
9
+
10
+ - Built with the framework 0.0.11: a block of a project's own tile palette, placed on a page, loads
11
+ from its palette wherever the workbench asks for it — the picker, the settings, the tree.
12
+
13
+ ## 0.0.30
14
+
15
+ - A block of a project's own tile palette is placed with its default settings, and its page and
16
+ preview show it: its code is loaded from the palette it comes from.
17
+
3
18
  ## 0.0.29
4
19
 
5
20
  - Built with the framework 0.0.10: the platform's pages run the framework a new project's tile
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mosetta/editor",
3
- "version": "0.0.29",
3
+ "version": "0.0.32",
4
4
  "license": "MIT",
5
5
  "description": "mosetta visual editor tile palette: block picker, page tree, inspector, isolated draft preview and the content API behind them.",
6
6
  "repository": {
@@ -14,15 +14,15 @@
14
14
  "dependencies": {
15
15
  "react": "*",
16
16
  "react-dom": "*",
17
- "@mosetta/content": "0.0.10",
18
- "@mosetta/core": "0.0.10",
19
- "@mosetta/di": "0.0.10",
20
- "@mosetta/stores": "0.0.10",
21
- "@mosetta/react": "0.0.10",
22
- "@mosetta/settings": "0.0.10",
23
- "@mosetta/ui": "0.0.10",
24
- "@mosetta/server-action": "0.0.10",
25
- "@mosetta/runtime": "0.0.10"
17
+ "@mosetta/core": "0.0.12",
18
+ "@mosetta/di": "0.0.12",
19
+ "@mosetta/stores": "0.0.12",
20
+ "@mosetta/content": "0.0.12",
21
+ "@mosetta/react": "0.0.12",
22
+ "@mosetta/settings": "0.0.12",
23
+ "@mosetta/server-action": "0.0.12",
24
+ "@mosetta/runtime": "0.0.12",
25
+ "@mosetta/ui": "0.0.12"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@types/react": "*",
@@ -52,8 +52,8 @@ function useBlockFacets(component: ICatalogEntry): TFacets {
52
52
  void (async () => {
53
53
  try {
54
54
  const [editor, block] = await Promise.all([
55
- component.hasEditor ? loadModule(holder, editorReferenceOf(component.id)) : Promise.resolve(undefined),
56
- loadModule(holder, component.id),
55
+ component.hasEditor ? loadModule(holder, editorReferenceOf(component.id), component.base) : Promise.resolve(undefined),
56
+ loadModule(holder, component.id, component.base),
57
57
  ]);
58
58
  const defaults = (block?.module as IComponentFacet | undefined)?.defaultSettings?.() ?? {};
59
59
  const facet = editor?.module as IEditorFacet | undefined;
@@ -343,6 +343,7 @@ export function BlockPicker({ session, point, autoFocus, onCancel, specimen }: I
343
343
  previewTimer.current = setTimeout(() => setPreview({
344
344
  reference: component.id,
345
345
  hasEditor: component.hasEditor,
346
+ ...(component.base ? { base: component.base } : {}),
346
347
  libraryRoot: libraryRootOf(component),
347
348
  anchor: { top, left, right },
348
349
  }), PREVIEW_DELAY_MS);
@@ -357,8 +358,9 @@ export function BlockPicker({ session, point, autoFocus, onCancel, specimen }: I
357
358
  session.insertNode(item.key, {});
358
359
  return;
359
360
  }
361
+ // a block of a project's tile palette loads from that palette's host
360
362
  const loaded: { module?: unknown } | undefined = holder.loadModule
361
- ? await holder.loadModule(item.key)
363
+ ? await holder.loadModule(item.key, item.component?.base)
362
364
  : holder.getModule(item.key);
363
365
  const mod = loaded?.module as IComponentModuleShape | undefined;
364
366
  session.insertNode(item.key, mod?.defaultSettings ? mod.defaultSettings() : {});
@@ -49,6 +49,8 @@ export interface IPreviewTarget {
49
49
  readonly reference: string;
50
50
  /** from the catalog: no editor facet, no declaration — nothing to load and nothing to ask */
51
51
  readonly hasEditor: boolean;
52
+ /** where the block's tile host keeps its tiles, when it is not the site's primary */
53
+ readonly base?: string;
52
54
  /** a root module of the block's OWN library, when it ships one (catalog `isRoot`) */
53
55
  readonly libraryRoot?: string;
54
56
  /** the hovered row, in window coordinates */
@@ -123,8 +125,8 @@ export function usePreviewPlan(target: IPreviewTarget | null, self: { namespace:
123
125
  void (async () => {
124
126
  try {
125
127
  const [editor, component] = await Promise.all([
126
- loadModule(holder, editorReferenceOf(target.reference)),
127
- loadModule(holder, target.reference),
128
+ loadModule(holder, editorReferenceOf(target.reference), target.base),
129
+ loadModule(holder, target.reference, target.base),
128
130
  ]);
129
131
  const loaded = editor?.module as IEditorFacet | undefined;
130
132
  // the facet's own blocks at the facet's own version — the preview was written at some earlier one
@@ -115,6 +115,12 @@ class CatalogService {
115
115
  return typeof file === 'string' && file && base ? `${base.publicBase}modules/${entity.id}/${file}` : undefined;
116
116
  }
117
117
 
118
+ /** the public base of an entity's tile host when it is not the primary — where a page loads it from */
119
+ private baseOf(entity: IModuleDescriptor): string | undefined {
120
+ const key = (entity as { provider?: string }).provider;
121
+ return key ? this.hosts.find((h) => h.key === key)?.publicBase : undefined;
122
+ }
123
+
118
124
  /** palette entries: requested types (default: components), each paired with its editor facet */
119
125
  async entries(types?: string[]): Promise<ICatalogEntry[]> {
120
126
  const all = await this.descriptors();
@@ -124,7 +130,8 @@ class CatalogService {
124
130
  .filter((d) => wanted.has(d.reference.type))
125
131
  .map((d) => {
126
132
  const iconUrl = this.fileUrl(d, (d as { icon?: unknown }).icon);
127
- return { ...d, hasEditor: editors.has(facetKey(d)), ...(iconUrl ? { iconUrl } : {}) };
133
+ const base = this.baseOf(d);
134
+ return { ...d, hasEditor: editors.has(facetKey(d)), ...(iconUrl ? { iconUrl } : {}), ...(base ? { base } : {}) };
128
135
  });
129
136
  }
130
137
 
@@ -42,8 +42,8 @@ const fallbackOf = (tree: IBlueprintNode): string | null => {
42
42
  return typeof named === 'string' ? named : null;
43
43
  };
44
44
 
45
- export async function loadModule(holder: ITilesHolder, reference: string) {
46
- const loaded = holder.loadModule ? await holder.loadModule(reference) : holder.getModule(reference);
45
+ export async function loadModule(holder: ITilesHolder, reference: string, base?: string) {
46
+ const loaded = holder.loadModule ? await holder.loadModule(reference, base) : holder.getModule(reference);
47
47
  return loaded?.error ? undefined : loaded;
48
48
  }
49
49