@dotcms/vue 1.5.5-next.2350
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/README.md +719 -0
- package/index.d.ts +16 -0
- package/index.js +912 -0
- package/lib/__test__/mocks.d.ts +6 -0
- package/lib/client/dotcms-client.plugin.d.ts +79 -0
- package/lib/components/Column/Column.vue.d.ts +12 -0
- package/lib/components/Container/Container.vue.d.ts +11 -0
- package/lib/components/Container/ContainerNotFound.vue.d.ts +6 -0
- package/lib/components/Container/EmptyContainer.vue.d.ts +2 -0
- package/lib/components/Contentlet/Contentlet.vue.d.ts +14 -0
- package/lib/components/Contentlet/constants.d.ts +2 -0
- package/lib/components/DotCMSBlockEditorRenderer/DotCMSBlockEditorRenderer.vue.d.ts +5 -0
- package/lib/components/DotCMSBlockEditorRenderer/components/BlockEditorBlock.vue.d.ts +13 -0
- package/lib/components/DotCMSBlockEditorRenderer/components/blocks/BulletList.vue.d.ts +17 -0
- package/lib/components/DotCMSBlockEditorRenderer/components/blocks/CodeBlock.vue.d.ts +22 -0
- package/lib/components/DotCMSBlockEditorRenderer/components/blocks/DotContent.vue.d.ts +10 -0
- package/lib/components/DotCMSBlockEditorRenderer/components/blocks/DotImage.vue.d.ts +7 -0
- package/lib/components/DotCMSBlockEditorRenderer/components/blocks/DotVideo.vue.d.ts +7 -0
- package/lib/components/DotCMSBlockEditorRenderer/components/blocks/GridBlock.vue.d.ts +10 -0
- package/lib/components/DotCMSBlockEditorRenderer/components/blocks/Heading.vue.d.ts +22 -0
- package/lib/components/DotCMSBlockEditorRenderer/components/blocks/ListItem.vue.d.ts +17 -0
- package/lib/components/DotCMSBlockEditorRenderer/components/blocks/NoComponentProvided.vue.d.ts +6 -0
- package/lib/components/DotCMSBlockEditorRenderer/components/blocks/OrderedList.vue.d.ts +17 -0
- package/lib/components/DotCMSBlockEditorRenderer/components/blocks/Paragraph.vue.d.ts +22 -0
- package/lib/components/DotCMSBlockEditorRenderer/components/blocks/Quote.vue.d.ts +17 -0
- package/lib/components/DotCMSBlockEditorRenderer/components/blocks/TableRenderer.vue.d.ts +15 -0
- package/lib/components/DotCMSBlockEditorRenderer/components/blocks/TextBlock.vue.d.ts +13 -0
- package/lib/components/DotCMSBlockEditorRenderer/components/blocks/UnknownBlock.vue.d.ts +10 -0
- package/lib/components/DotCMSBlockEditorRenderer/types.d.ts +44 -0
- package/lib/components/DotCMSEditableText/DotCMSEditableText.vue.d.ts +15 -0
- package/lib/components/DotCMSEditableText/utils.d.ts +22 -0
- package/lib/components/DotCMSLayoutBody/DotCMSLayoutBody.vue.d.ts +5 -0
- package/lib/components/DotCMSLayoutBody/components/ErrorMessage.vue.d.ts +2 -0
- package/lib/components/DotCMSLayoutBody/types.d.ts +25 -0
- package/lib/components/DotCMSShow/DotCMSShow.vue.d.ts +35 -0
- package/lib/components/FallbackComponent/FallbackComponent.vue.d.ts +13 -0
- package/lib/components/Row/Row.vue.d.ts +13 -0
- package/lib/composables/useCheckVisibleContent.d.ts +16 -0
- package/lib/composables/useDotCMSShowWhen.d.ts +20 -0
- package/lib/composables/useEditableDotCMSPage.d.ts +37 -0
- package/lib/composables/useIsAnalyticsActive.d.ts +14 -0
- package/lib/composables/useIsDevMode.d.ts +23 -0
- package/lib/contexts/dotcms-page.context.d.ts +74 -0
- package/lib/utils/imageLoader.d.ts +54 -0
- package/lib/utils/toPlain.d.ts +12 -0
- package/package.json +47 -0
- package/test-setup.d.ts +0 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { MaybeRefOrGetter, Ref } from 'vue';
|
|
2
|
+
import { DotCMSComposedPageResponse, DotCMSExtendedPageResponse } from '@dotcms/types';
|
|
3
|
+
/**
|
|
4
|
+
* Composable to manage the editable state of a dotCMS page inside the Universal
|
|
5
|
+
* Visual Editor (UVE).
|
|
6
|
+
*
|
|
7
|
+
* It initializes the UVE, keeps the navigation in sync, and subscribes to
|
|
8
|
+
* content changes so the returned page response updates live while an editor is
|
|
9
|
+
* working. Outside of the UVE it is a pass-through: the returned ref simply
|
|
10
|
+
* holds the initial response.
|
|
11
|
+
*
|
|
12
|
+
* This is the Vue analog of the React SDK's `useEditableDotCMSPage` hook and the
|
|
13
|
+
* Angular SDK's `DotCMSEditablePageService.listen()`.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* import { useEditableDotCMSPage } from '@dotcms/vue';
|
|
18
|
+
* import { createDotCMSClient } from '@dotcms/client';
|
|
19
|
+
*
|
|
20
|
+
* const client = createDotCMSClient({
|
|
21
|
+
* dotcmsUrl: 'https://your-dotcms-instance.com',
|
|
22
|
+
* authToken: 'your-auth-token'
|
|
23
|
+
* });
|
|
24
|
+
*
|
|
25
|
+
* const pageResponse = await client.page.get('/');
|
|
26
|
+
* const page = useEditableDotCMSPage(pageResponse);
|
|
27
|
+
*
|
|
28
|
+
* // page.value.pageAsset — reactive; re-renders on UVE content changes.
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @param pageResponse the page response from `client.page.get()`. May be a plain
|
|
32
|
+
* value, a `ref`, or a getter — when it's reactive, the composable re-initializes
|
|
33
|
+
* the UVE for the new page (e.g. on client-side route changes) so no manual
|
|
34
|
+
* component remount is needed.
|
|
35
|
+
* @returns a reactive ref holding the (possibly live-updating) page response
|
|
36
|
+
*/
|
|
37
|
+
export declare function useEditableDotCMSPage<T extends DotCMSExtendedPageResponse>(pageResponse: MaybeRefOrGetter<DotCMSComposedPageResponse<T>>): Ref<DotCMSComposedPageResponse<T>>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Ref } from 'vue';
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
*
|
|
5
|
+
* Composable that tracks whether dotCMS Analytics is active on the page.
|
|
6
|
+
*
|
|
7
|
+
* Analytics may initialize after the page renders, so in addition to reading the
|
|
8
|
+
* current state on mount we subscribe to the `dotcms:analytics:ready` window
|
|
9
|
+
* event and re-evaluate when it fires. Used in live mode to decide whether the
|
|
10
|
+
* minimal contentlet attributes Analytics needs should be kept.
|
|
11
|
+
*
|
|
12
|
+
* @returns a ref that is `true` when Analytics is active
|
|
13
|
+
*/
|
|
14
|
+
export declare function useIsAnalyticsActive(): Ref<boolean>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ComputedRef, MaybeRefOrGetter } from 'vue';
|
|
2
|
+
import { DotCMSPageRendererMode } from '@dotcms/types';
|
|
3
|
+
/**
|
|
4
|
+
* @internal
|
|
5
|
+
*
|
|
6
|
+
* Resolve whether we are rendering in "development" mode — i.e. whether editor
|
|
7
|
+
* metadata (`data-dot-*` attributes, empty-state placeholders, fallback
|
|
8
|
+
* components) should be emitted. Inside the UVE it follows the UVE state (dev
|
|
9
|
+
* when mode is EDIT); otherwise it follows the renderer `mode`.
|
|
10
|
+
*/
|
|
11
|
+
export declare function resolveDevMode(mode: DotCMSPageRendererMode | undefined): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* @internal
|
|
14
|
+
*
|
|
15
|
+
* Computed development-mode flag. `getUVEState()` and the renderer `mode` are
|
|
16
|
+
* both available synchronously, so this resolves during setup — the editor
|
|
17
|
+
* `data-dot-*` attributes are present on the first render (which the UVE relies
|
|
18
|
+
* on to attach its tooling) with no per-instance `onMounted`.
|
|
19
|
+
*
|
|
20
|
+
* Called once at the layout root ({@link DotCMSLayoutBody}); the result is
|
|
21
|
+
* shared with the whole tree via the page context.
|
|
22
|
+
*/
|
|
23
|
+
export declare function useIsDevMode(mode: MaybeRefOrGetter<DotCMSPageRendererMode | undefined>): ComputedRef<boolean>;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { Component, ComputedRef, InjectionKey, Slot } from 'vue';
|
|
2
|
+
import { DotCMSPageAsset, DotCMSPageRendererMode } from '@dotcms/types';
|
|
3
|
+
/**
|
|
4
|
+
* The value carried by the dotCMS page context.
|
|
5
|
+
*
|
|
6
|
+
* This is the Vue analog of the React SDK's `DotCMSPageContext`. It is provided
|
|
7
|
+
* once by {@link DotCMSLayoutBody} and consumed by the layout tree (Container,
|
|
8
|
+
* Contentlet). It is also part of the public API: a custom content-type
|
|
9
|
+
* component rendered deep in the tree can read it via {@link useDotCMSPageContext}
|
|
10
|
+
* to access the page asset without prop drilling. This shape is stable.
|
|
11
|
+
*/
|
|
12
|
+
export interface DotCMSPageContextValue {
|
|
13
|
+
/** The dotCMS page asset containing the layout and containers. */
|
|
14
|
+
pageAsset: DotCMSPageAsset;
|
|
15
|
+
/** The renderer mode: `production` or `development`. */
|
|
16
|
+
mode: DotCMSPageRendererMode;
|
|
17
|
+
/**
|
|
18
|
+
* Map of content-type variable name to the Vue component that renders it.
|
|
19
|
+
* The special `CustomNoComponent` key is used as the fallback for unmatched
|
|
20
|
+
* content types.
|
|
21
|
+
*/
|
|
22
|
+
userComponents: Record<string, Component>;
|
|
23
|
+
/**
|
|
24
|
+
* Whether editor metadata (`data-dot-*`, placeholders, fallbacks) should be
|
|
25
|
+
* emitted. Resolved once at the layout root and shared with the whole tree
|
|
26
|
+
* so it isn't recomputed per contentlet.
|
|
27
|
+
*/
|
|
28
|
+
isDevMode: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Whether dotCMS Analytics is active. Resolved once at the layout root (a
|
|
31
|
+
* single `dotcms:analytics:ready` listener) and shared with the tree.
|
|
32
|
+
*/
|
|
33
|
+
isAnalyticsActive: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Named slots passed to {@link DotCMSLayoutBody}, keyed by contentlet
|
|
36
|
+
* identifier (the `contentlet-<identifier>` slot name, with the prefix
|
|
37
|
+
* stripped). When a contentlet has a matching slot, that slot content is
|
|
38
|
+
* rendered instead of the mapped component — the Vue analog of the React
|
|
39
|
+
* SDK's `slots` prop. Empty (or omitted) when no per-contentlet slots were
|
|
40
|
+
* provided; {@link DotCMSLayoutBody} always sets it.
|
|
41
|
+
*/
|
|
42
|
+
slots?: Record<string, Slot>;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Injection key for the dotCMS page context.
|
|
46
|
+
*
|
|
47
|
+
* The value is a `ComputedRef` so that live UVE updates to the page (a new page
|
|
48
|
+
* asset arriving via `uve-set-page-data`) propagate to every consumer that reads
|
|
49
|
+
* `ctx.value` — the whole layout tree re-renders reactively.
|
|
50
|
+
*
|
|
51
|
+
* Advanced: exported so consumers can `inject` directly, but prefer
|
|
52
|
+
* {@link useDotCMSPageContext}.
|
|
53
|
+
*/
|
|
54
|
+
export declare const DOTCMS_PAGE_CONTEXT: InjectionKey<ComputedRef<DotCMSPageContextValue>>;
|
|
55
|
+
/**
|
|
56
|
+
* Provides the dotCMS page context to descendant components.
|
|
57
|
+
*
|
|
58
|
+
* Advanced: {@link DotCMSLayoutBody} already provides this for the rendered tree,
|
|
59
|
+
* so most applications never call it. Exposed for consumers that render the
|
|
60
|
+
* layout tree themselves.
|
|
61
|
+
*
|
|
62
|
+
* @param value a computed producing the current context value
|
|
63
|
+
*/
|
|
64
|
+
export declare function provideDotCMSPageContext(value: ComputedRef<DotCMSPageContextValue>): void;
|
|
65
|
+
/**
|
|
66
|
+
* Injects the dotCMS page context as a reactive `ComputedRef`.
|
|
67
|
+
*
|
|
68
|
+
* Public: use this from a custom content-type component to read the current
|
|
69
|
+
* `pageAsset`, renderer `mode`, or editor state without prop drilling. Falls back
|
|
70
|
+
* to an empty context when used outside of a {@link DotCMSLayoutBody}.
|
|
71
|
+
*
|
|
72
|
+
* @returns the current page context value as a computed ref
|
|
73
|
+
*/
|
|
74
|
+
export declare function useDotCMSPageContext(): ComputedRef<DotCMSPageContextValue>;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Options for a single {@link DotCMSImageLoader} call.
|
|
3
|
+
*/
|
|
4
|
+
export interface DotCMSImageLoaderOptions {
|
|
5
|
+
/** Target width in pixels. Requests a resized image from the dotCMS image API. */
|
|
6
|
+
width?: number;
|
|
7
|
+
/**
|
|
8
|
+
* JPEG quality (1-100).
|
|
9
|
+
* @default 50
|
|
10
|
+
*/
|
|
11
|
+
quality?: number;
|
|
12
|
+
/**
|
|
13
|
+
* Language id for the asset.
|
|
14
|
+
* @default '1'
|
|
15
|
+
*/
|
|
16
|
+
languageId?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* A function that turns a dotCMS asset identifier (or path) into an image URL.
|
|
20
|
+
* Returned by {@link createDotCMSImageLoader}.
|
|
21
|
+
*/
|
|
22
|
+
export type DotCMSImageLoader = (src: string, options?: DotCMSImageLoaderOptions) => string;
|
|
23
|
+
/**
|
|
24
|
+
* Creates a dotCMS image URL builder.
|
|
25
|
+
*
|
|
26
|
+
* dotCMS serves images through its image API (the `/dA/` route), which handles
|
|
27
|
+
* on-the-fly resizing and optimization. This is the Vue analog of Angular's
|
|
28
|
+
* `provideDotCMSImageLoader`: Angular wires the same URL math into its
|
|
29
|
+
* `IMAGE_LOADER` token, while Vue has no such token, so this returns a plain
|
|
30
|
+
* function you call from a template.
|
|
31
|
+
*
|
|
32
|
+
* Absolute URLs (already `http(s)://…`) are returned unchanged, so mixing dotCMS
|
|
33
|
+
* assets with external/stock imagery just works.
|
|
34
|
+
*
|
|
35
|
+
* @param dotcmsUrl - Base URL of the dotCMS instance. When omitted (empty), URLs
|
|
36
|
+
* are site-relative (`/dA/…`), which is what you want behind a dev proxy.
|
|
37
|
+
* @returns a loader function `(src, options?) => url`
|
|
38
|
+
* @throws if `dotcmsUrl` is a non-empty, invalid URL
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```ts
|
|
42
|
+
* import { createDotCMSImageLoader } from '@dotcms/vue';
|
|
43
|
+
*
|
|
44
|
+
* // Absolute (production): points at the dotCMS host.
|
|
45
|
+
* const image = createDotCMSImageLoader(import.meta.env.VITE_DOTCMS_HOST);
|
|
46
|
+
* image(contentlet.inode, { width: 800 });
|
|
47
|
+
* // → https://demo.dotcms.com/dA/<inode>/800w/50q?language_id=1
|
|
48
|
+
*
|
|
49
|
+
* // Relative (dev proxy): omit the host so the Vite proxy handles /dA.
|
|
50
|
+
* const proxied = createDotCMSImageLoader();
|
|
51
|
+
* proxied(contentlet.inode, { width: 800 }); // → /dA/<inode>/800w/50q?language_id=1
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export declare function createDotCMSImageLoader(dotcmsUrl?: string): DotCMSImageLoader;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Recursively unwrap Vue reactivity (refs / reactive proxies) into a plain,
|
|
3
|
+
* structured-clone-safe object.
|
|
4
|
+
*
|
|
5
|
+
* The UVE bridge sends data to the editor via `postMessage`, which uses the
|
|
6
|
+
* structured clone algorithm — and that throws a `DataCloneError` on Vue
|
|
7
|
+
* reactive Proxies. Values passed to UVE actions (`initUVE`, `editContentlet`,
|
|
8
|
+
* `enableBlockEditorInline`, …) commonly come through reactive props or
|
|
9
|
+
* `reactive()`, so unwrap them first. Plain values pass through untouched;
|
|
10
|
+
* cycles are guarded and non-plain objects (e.g. `Date`) are preserved as-is.
|
|
11
|
+
*/
|
|
12
|
+
export declare function toPlain<T>(value: T): T;
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dotcms/vue",
|
|
3
|
+
"version": "1.5.5-next.2350",
|
|
4
|
+
"peerDependencies": {
|
|
5
|
+
"vue": ">=3.4"
|
|
6
|
+
},
|
|
7
|
+
"dependencies": {
|
|
8
|
+
"@dotcms/uve": "latest",
|
|
9
|
+
"@dotcms/client": "latest",
|
|
10
|
+
"@tinymce/tinymce-vue": "^6.1.0"
|
|
11
|
+
},
|
|
12
|
+
"devDependencies": {
|
|
13
|
+
"@dotcms/types": "latest"
|
|
14
|
+
},
|
|
15
|
+
"description": "Official Vue components library to render a dotCMS page.",
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/dotCMS/core.git#main"
|
|
19
|
+
},
|
|
20
|
+
"keywords": [
|
|
21
|
+
"dotCMS",
|
|
22
|
+
"CMS",
|
|
23
|
+
"Content Management",
|
|
24
|
+
"API Client",
|
|
25
|
+
"REST API",
|
|
26
|
+
"Vue",
|
|
27
|
+
"Vue 3",
|
|
28
|
+
"Components"
|
|
29
|
+
],
|
|
30
|
+
"type": "module",
|
|
31
|
+
"main": "./index.js",
|
|
32
|
+
"module": "./index.js",
|
|
33
|
+
"types": "./index.d.ts",
|
|
34
|
+
"exports": {
|
|
35
|
+
"./package.json": "./package.json",
|
|
36
|
+
".": {
|
|
37
|
+
"types": "./index.d.ts",
|
|
38
|
+
"import": "./index.js"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"author": "dotcms <dev@dotcms.com>",
|
|
42
|
+
"license": "MIT",
|
|
43
|
+
"bugs": {
|
|
44
|
+
"url": "https://github.com/dotCMS/core/issues"
|
|
45
|
+
},
|
|
46
|
+
"homepage": "https://github.com/dotCMS/core/tree/main/core-web/libs/sdk/vue/README.md"
|
|
47
|
+
}
|
package/test-setup.d.ts
ADDED
|
File without changes
|