@commonpub/layer 0.7.6 → 0.7.7
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commonpub/layer",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./nuxt.config.ts",
|
|
6
6
|
"files": [
|
|
@@ -51,15 +51,15 @@
|
|
|
51
51
|
"vue-router": "^4.3.0",
|
|
52
52
|
"zod": "^4.3.6",
|
|
53
53
|
"@commonpub/auth": "0.5.0",
|
|
54
|
-
"@commonpub/config": "0.9.0",
|
|
55
|
-
"@commonpub/docs": "0.6.2",
|
|
56
54
|
"@commonpub/editor": "0.7.0",
|
|
55
|
+
"@commonpub/config": "0.9.0",
|
|
57
56
|
"@commonpub/explainer": "0.7.4",
|
|
57
|
+
"@commonpub/docs": "0.6.2",
|
|
58
58
|
"@commonpub/learning": "0.5.0",
|
|
59
|
-
"@commonpub/schema": "0.9.4",
|
|
60
59
|
"@commonpub/protocol": "0.9.7",
|
|
61
|
-
"@commonpub/
|
|
62
|
-
"@commonpub/server": "2.27.
|
|
60
|
+
"@commonpub/schema": "0.9.4",
|
|
61
|
+
"@commonpub/server": "2.27.6",
|
|
62
|
+
"@commonpub/ui": "0.8.5"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
65
|
"@testing-library/jest-dom": "^6.9.1",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
import { provide } from 'vue';
|
|
2
3
|
import type { BlockTuple } from '@commonpub/editor';
|
|
3
|
-
import { BlockCanvas, EditorShell, useBlockEditor, type BlockTypeGroup } from '@commonpub/editor/vue';
|
|
4
|
+
import { BlockCanvas, EditorShell, useBlockEditor, UPLOAD_HANDLER_KEY, type BlockTypeGroup } from '@commonpub/editor/vue';
|
|
4
5
|
import type { PageTreeItem } from '../../../components/editors/DocsPageTree.vue';
|
|
5
6
|
|
|
6
7
|
definePageMeta({ layout: false, middleware: 'auth' });
|
|
@@ -9,6 +10,15 @@ const route = useRoute();
|
|
|
9
10
|
const siteSlug = computed(() => route.params.siteSlug as string);
|
|
10
11
|
const { show: toast } = useToast();
|
|
11
12
|
|
|
13
|
+
// Provide upload handler to block components (ImageBlock, GalleryBlock)
|
|
14
|
+
provide(UPLOAD_HANDLER_KEY, async (file: File) => {
|
|
15
|
+
const formData = new FormData();
|
|
16
|
+
formData.append('file', file);
|
|
17
|
+
formData.append('purpose', 'content');
|
|
18
|
+
const res = await $fetch<{ url: string; width?: number | null; height?: number | null }>('/api/files/upload', { method: 'POST', body: formData });
|
|
19
|
+
return { url: res.url, width: res.width ?? null, height: res.height ?? null };
|
|
20
|
+
});
|
|
21
|
+
|
|
12
22
|
// ═══ DATA FETCHING ═══
|
|
13
23
|
const { data: site, refresh: refreshSite } = await useFetch<{ id: string; name: string; slug: string; description: string; ownerId: string; versions?: Array<{ id: string; version: string; isDefault: boolean }> }>(() => `/api/docs/${siteSlug.value}`);
|
|
14
24
|
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import type { Component } from 'vue';
|
|
3
|
+
import { provide } from 'vue';
|
|
3
4
|
import type { BlockTuple } from '@commonpub/editor';
|
|
4
|
-
import { BlockCanvas, useBlockEditor } from '@commonpub/editor/vue';
|
|
5
|
+
import { BlockCanvas, useBlockEditor, UPLOAD_HANDLER_KEY, SEARCH_PRODUCTS_KEY } from '@commonpub/editor/vue';
|
|
5
6
|
import { isExplainerDocument, createEmptyDocument } from '@commonpub/explainer';
|
|
6
7
|
import type { ExplainerDocument } from '@commonpub/explainer';
|
|
7
8
|
import { ExplainerSectionEditor } from '@commonpub/explainer/vue';
|
|
@@ -93,6 +94,20 @@ const { errors: publishErrors, showErrors: showPublishErrors, validate, dismiss:
|
|
|
93
94
|
getBlockTuples: getContentForSave as () => BlockTuple[],
|
|
94
95
|
});
|
|
95
96
|
|
|
97
|
+
// --- Provide upload + search handlers to block components via inject ---
|
|
98
|
+
provide(UPLOAD_HANDLER_KEY, async (file: File) => {
|
|
99
|
+
const formData = new FormData();
|
|
100
|
+
formData.append('file', file);
|
|
101
|
+
formData.append('purpose', 'content');
|
|
102
|
+
const res = await $fetch<{ url: string; width?: number | null; height?: number | null }>('/api/files/upload', { method: 'POST', body: formData });
|
|
103
|
+
return { url: res.url, width: res.width ?? null, height: res.height ?? null };
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
provide(SEARCH_PRODUCTS_KEY, async (query: string) => {
|
|
107
|
+
const res = await $fetch<{ items: Array<{ id: string; name: string; slug: string; description: string | null; category: string | null; imageUrl: string | null; purchaseUrl: string | null }> }>(`/api/products?q=${encodeURIComponent(query)}&limit=10`);
|
|
108
|
+
return res.items ?? [];
|
|
109
|
+
});
|
|
110
|
+
|
|
96
111
|
// --- Specialized editor component map ---
|
|
97
112
|
const editorMap: Record<string, Component> = {
|
|
98
113
|
article: resolveComponent('EditorsArticleEditor') as Component,
|