nuxt-strapi-blocks-renderer 1.0.4 → 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 +3 -1
- package/dist/module.json +5 -1
- package/dist/runtime/components/StrapiBlocksText.vue +1 -0
- package/dist/runtime/utils/index.d.ts +2 -2
- package/dist/runtime/utils/{index.mjs → index.js} +17 -6
- package/package.json +15 -12
- /package/dist/runtime/composables/{useBlocksText.mjs → useBlocksText.js} +0 -0
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:
|
|
@@ -336,7 +338,7 @@ npm run lint:types
|
|
|
336
338
|
To run the Vitest unit tests, run the following command:
|
|
337
339
|
|
|
338
340
|
```bash
|
|
339
|
-
npm run
|
|
341
|
+
npm run test
|
|
340
342
|
````
|
|
341
343
|
|
|
342
344
|
### Release
|
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,11 +1,11 @@
|
|
|
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": {
|
|
7
7
|
"type": "git",
|
|
8
|
-
"url": "https://github.com/freb97/nuxt-strapi-blocks-renderer.git"
|
|
8
|
+
"url": "git+https://github.com/freb97/nuxt-strapi-blocks-renderer.git"
|
|
9
9
|
},
|
|
10
10
|
"type": "module",
|
|
11
11
|
"exports": {
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"release": "npm run lint && npm run test && npm run prepack && npm publish",
|
|
30
30
|
"release:ci": "npm run prepack && npm publish",
|
|
31
31
|
"lint:es": "eslint './**/*.{js,ts,vue}' --max-warnings=0",
|
|
32
|
-
"lint:types": "tsc --noEmit",
|
|
32
|
+
"lint:types": "vue-tsc --noEmit",
|
|
33
33
|
"test": "vitest run",
|
|
34
34
|
"test:watch": "vitest watch"
|
|
35
35
|
},
|
|
@@ -38,18 +38,21 @@
|
|
|
38
38
|
"defu": "^6.1.4"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@
|
|
42
|
-
"@nuxt/
|
|
43
|
-
"@nuxt/
|
|
44
|
-
"@nuxt/module-builder": "^0.5.5",
|
|
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",
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"vue
|
|
51
|
+
"typescript": "^5.4.5",
|
|
52
|
+
"vitest": "^1.6.0",
|
|
53
|
+
"vue": "^3.4.27",
|
|
54
|
+
"vue-eslint-parser": "^9.4.2",
|
|
55
|
+
"vue-tsc": "^2.0.19"
|
|
53
56
|
},
|
|
54
57
|
"packageManager": "npm@10.2.4",
|
|
55
58
|
"engines": {
|
|
File without changes
|