nuxt-strapi-blocks-renderer 1.0.5 → 1.0.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/README.md +5 -0
- package/dist/module.json +2 -2
- package/dist/runtime/utils/index.d.ts +3 -3
- package/dist/runtime/utils/{index.mjs → index.js} +17 -6
- package/dist/types.d.mts +1 -16
- package/dist/types.d.ts +1 -16
- package/package.json +23 -14
- /package/dist/runtime/composables/{useBlocksText.mjs → useBlocksText.js} +0 -0
package/README.md
CHANGED
|
@@ -7,6 +7,11 @@
|
|
|
7
7
|
|
|
8
8
|
A fully customizable Nuxt 3 module for rendering text with the new Blocks rich text editor element from Strapi CMS.
|
|
9
9
|
|
|
10
|
+
The implementation is based on Strapi's [Blocks React Renderer](https://github.com/strapi/blocks-react-renderer/).
|
|
11
|
+
|
|
12
|
+
- ✨ [Release notes](/CHANGELOG.md)
|
|
13
|
+
- 🏀 [Online stackblitz playground](https://stackblitz.com/github/freb97/nuxt-strapi-blocks-renderer?file=playground%2Fbasic%2Fpages%2Findex.vue)
|
|
14
|
+
|
|
10
15
|
## Installation
|
|
11
16
|
|
|
12
17
|
1. Install the Blocks renderer:
|
package/dist/module.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { VNode } from 'vue';
|
|
2
|
-
import type { BlockNode } from '#strapi-blocks-renderer/types';
|
|
3
|
-
export declare const textInlineNode: (node: TextInlineNode) => VNode | string;
|
|
2
|
+
import type { BlockNode, CodeBlockNode, DefaultInlineNode, HeadingBlockNode, ImageBlockNode, LinkInlineNode, ListBlockNode, ListItemInlineNode, ParagraphBlockNode, QuoteBlockNode, TextInlineNode } from '#strapi-blocks-renderer/types';
|
|
3
|
+
export declare const textInlineNode: (node: TextInlineNode) => (VNode | string)[] | VNode;
|
|
4
4
|
export declare const linkInlineNode: (node: LinkInlineNode) => VNode;
|
|
5
|
-
export declare const defaultInlineNode: (node: DefaultInlineNode) => VNode | string | undefined;
|
|
5
|
+
export declare const defaultInlineNode: (node: DefaultInlineNode) => (VNode | string)[] | VNode | undefined;
|
|
6
6
|
export declare const listItemInlineNode: (node: ListItemInlineNode) => VNode;
|
|
7
7
|
export declare const headingBlockNode: (node: HeadingBlockNode) => VNode;
|
|
8
8
|
export declare const paragraphBlockNode: (node: ParagraphBlockNode) => VNode;
|
|
@@ -3,18 +3,29 @@ const prefix = () => {
|
|
|
3
3
|
const { public: { strapiBlocksRenderer } } = useRuntimeConfig();
|
|
4
4
|
return strapiBlocksRenderer.blocksPrefix;
|
|
5
5
|
};
|
|
6
|
+
const getNodeText = (node) => {
|
|
7
|
+
const lines = [];
|
|
8
|
+
node.text.split("\n").forEach((line, index, array) => {
|
|
9
|
+
lines.push(line);
|
|
10
|
+
if (index !== array.length - 1) {
|
|
11
|
+
lines.push(h("br"));
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
return lines;
|
|
15
|
+
};
|
|
6
16
|
export const textInlineNode = (node) => {
|
|
17
|
+
const text = getNodeText(node);
|
|
7
18
|
if (node.bold)
|
|
8
|
-
return h(resolveComponent(prefix() + "BoldInlineNode"), () =>
|
|
19
|
+
return h(resolveComponent(prefix() + "BoldInlineNode"), () => text);
|
|
9
20
|
if (node.italic)
|
|
10
|
-
return h(resolveComponent(prefix() + "ItalicInlineNode"), () =>
|
|
21
|
+
return h(resolveComponent(prefix() + "ItalicInlineNode"), () => text);
|
|
11
22
|
if (node.underline)
|
|
12
|
-
return h(resolveComponent(prefix() + "UnderlineInlineNode"), () =>
|
|
23
|
+
return h(resolveComponent(prefix() + "UnderlineInlineNode"), () => text);
|
|
13
24
|
if (node.strikethrough)
|
|
14
|
-
return h(resolveComponent(prefix() + "StrikethroughInlineNode"), () =>
|
|
25
|
+
return h(resolveComponent(prefix() + "StrikethroughInlineNode"), () => text);
|
|
15
26
|
if (node.code)
|
|
16
|
-
return h(resolveComponent(prefix() + "CodeInlineNode"), () =>
|
|
17
|
-
return
|
|
27
|
+
return h(resolveComponent(prefix() + "CodeInlineNode"), () => text);
|
|
28
|
+
return text;
|
|
18
29
|
};
|
|
19
30
|
export const linkInlineNode = (node) => {
|
|
20
31
|
const linkComponent = resolveComponent(prefix() + "LinkInlineNode");
|
package/dist/types.d.mts
CHANGED
|
@@ -1,16 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import type { ModuleOptions } from './module.js'
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
declare module '@nuxt/schema' {
|
|
6
|
-
interface NuxtConfig { ['strapiBlocksRenderer']?: Partial<ModuleOptions> }
|
|
7
|
-
interface NuxtOptions { ['strapiBlocksRenderer']?: ModuleOptions }
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
declare module 'nuxt/schema' {
|
|
11
|
-
interface NuxtConfig { ['strapiBlocksRenderer']?: Partial<ModuleOptions> }
|
|
12
|
-
interface NuxtOptions { ['strapiBlocksRenderer']?: ModuleOptions }
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
export type { ModuleOptions, default } from './module.js'
|
|
1
|
+
export { type ModuleOptions, default } from './module.js'
|
package/dist/types.d.ts
CHANGED
|
@@ -1,16 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import type { ModuleOptions } from './module'
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
declare module '@nuxt/schema' {
|
|
6
|
-
interface NuxtConfig { ['strapiBlocksRenderer']?: Partial<ModuleOptions> }
|
|
7
|
-
interface NuxtOptions { ['strapiBlocksRenderer']?: ModuleOptions }
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
declare module 'nuxt/schema' {
|
|
11
|
-
interface NuxtConfig { ['strapiBlocksRenderer']?: Partial<ModuleOptions> }
|
|
12
|
-
interface NuxtOptions { ['strapiBlocksRenderer']?: ModuleOptions }
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
export type { ModuleOptions, default } from './module'
|
|
1
|
+
export { type ModuleOptions, default } from './module'
|
package/package.json
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-strapi-blocks-renderer",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"description": "Renderer for the strapi CMS blocks text content element.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "git+https://github.com/freb97/nuxt-strapi-blocks-renderer.git"
|
|
9
9
|
},
|
|
10
|
+
"author": {
|
|
11
|
+
"name": "Frederik Bußmann",
|
|
12
|
+
"email": "frederik@bussmann.io"
|
|
13
|
+
},
|
|
10
14
|
"type": "module",
|
|
11
15
|
"exports": {
|
|
12
16
|
".": {
|
|
@@ -34,27 +38,32 @@
|
|
|
34
38
|
"test:watch": "vitest watch"
|
|
35
39
|
},
|
|
36
40
|
"dependencies": {
|
|
37
|
-
"@nuxt/kit": "^3.
|
|
41
|
+
"@nuxt/kit": "^3.12.2",
|
|
38
42
|
"defu": "^6.1.4"
|
|
39
43
|
},
|
|
40
44
|
"devDependencies": {
|
|
41
|
-
"@
|
|
42
|
-
"@nuxt/
|
|
43
|
-
"@nuxt/
|
|
44
|
-
"@nuxt/
|
|
45
|
-
"@nuxt/
|
|
46
|
-
"@
|
|
47
|
-
"@
|
|
45
|
+
"@nuxt/devtools": "^1.3.7",
|
|
46
|
+
"@nuxt/eslint-config": "^0.3.13",
|
|
47
|
+
"@nuxt/module-builder": "^0.8.0",
|
|
48
|
+
"@nuxt/schema": "^3.12.2",
|
|
49
|
+
"@nuxt/test-utils": "^3.13.1",
|
|
50
|
+
"@stylistic/eslint-plugin": "^2.3.0",
|
|
51
|
+
"@types/node": "^20.14.9",
|
|
52
|
+
"@typescript-eslint/eslint-plugin": "^7.14.1",
|
|
48
53
|
"eslint": "^8.57.0",
|
|
49
|
-
"nuxt": "^3.
|
|
54
|
+
"nuxt": "^3.12.2",
|
|
55
|
+
"typescript": "^5.5.2",
|
|
50
56
|
"vitest": "^1.6.0",
|
|
51
|
-
"vue": "^3.4.
|
|
52
|
-
"vue-
|
|
53
|
-
"vue-
|
|
54
|
-
"typescript": "^5.4.5"
|
|
57
|
+
"vue": "^3.4.31",
|
|
58
|
+
"vue-eslint-parser": "^9.4.3",
|
|
59
|
+
"vue-tsc": "^2.0.22"
|
|
55
60
|
},
|
|
56
61
|
"packageManager": "npm@10.2.4",
|
|
57
62
|
"engines": {
|
|
58
63
|
"node": "^18.x || ^20.x"
|
|
64
|
+
},
|
|
65
|
+
"stackblitz": {
|
|
66
|
+
"startCommand": "npm run dev:prepare && npm run dev",
|
|
67
|
+
"file": "playground/basic/pages/index.vue"
|
|
59
68
|
}
|
|
60
69
|
}
|
|
File without changes
|