nuxt-strapi-blocks-renderer 1.0.5 → 1.0.6
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
CHANGED
|
@@ -7,6 +7,8 @@
|
|
|
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
|
+
|
|
10
12
|
## Installation
|
|
11
13
|
|
|
12
14
|
1. Install the Blocks renderer:
|
package/dist/module.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { VNode } from 'vue';
|
|
2
2
|
import type { BlockNode } from '#strapi-blocks-renderer/types';
|
|
3
|
-
export declare const textInlineNode: (node: TextInlineNode) => VNode | string;
|
|
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-strapi-blocks-renderer",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"description": "Renderer for the strapi CMS blocks text content element.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -38,20 +38,21 @@
|
|
|
38
38
|
"defu": "^6.1.4"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@
|
|
42
|
-
"@nuxt/
|
|
43
|
-
"@nuxt/
|
|
44
|
-
"@nuxt/module-builder": "^0.6.0",
|
|
41
|
+
"@nuxt/devtools": "^1.3.2",
|
|
42
|
+
"@nuxt/eslint-config": "^0.3.13",
|
|
43
|
+
"@nuxt/module-builder": "^0.7.0",
|
|
45
44
|
"@nuxt/schema": "^3.11.2",
|
|
46
|
-
"@nuxt/test-utils": "^3.
|
|
47
|
-
"@stylistic/eslint-plugin": "^1.
|
|
45
|
+
"@nuxt/test-utils": "^3.13.1",
|
|
46
|
+
"@stylistic/eslint-plugin": "^2.1.0",
|
|
47
|
+
"@types/node": "^20.12.11",
|
|
48
|
+
"@typescript-eslint/eslint-plugin": "^7.11.0",
|
|
48
49
|
"eslint": "^8.57.0",
|
|
49
50
|
"nuxt": "^3.11.2",
|
|
51
|
+
"typescript": "^5.4.5",
|
|
50
52
|
"vitest": "^1.6.0",
|
|
51
53
|
"vue": "^3.4.27",
|
|
52
|
-
"vue-tsc": "^2.0.17",
|
|
53
54
|
"vue-eslint-parser": "^9.4.2",
|
|
54
|
-
"
|
|
55
|
+
"vue-tsc": "^2.0.19"
|
|
55
56
|
},
|
|
56
57
|
"packageManager": "npm@10.2.4",
|
|
57
58
|
"engines": {
|
|
File without changes
|